]> gitweb.factorcode.org Git - factor.git/commitdiff
Merge branch 'master' of git://factorcode.org/git/factor
authorMatthew Willis <matthew.willis@mac.com>
Sun, 30 Mar 2008 13:28:13 +0000 (06:28 -0700)
committerMatthew Willis <matthew.willis@mac.com>
Sun, 30 Mar 2008 13:28:13 +0000 (06:28 -0700)
448 files changed:
.gitignore
Makefile
build-support/factor.sh [new file with mode: 0755]
build-support/grovel.c
build-support/target [deleted file]
build-support/wordsize.c [deleted file]
core/alien/alien.factor
core/arrays/arrays.factor [changed mode: 0644->0755]
core/assocs/assocs-tests.factor [changed mode: 0644->0755]
core/assocs/assocs.factor
core/bit-arrays/bit-arrays-tests.factor
core/bootstrap/compiler/compiler.factor
core/bootstrap/image/image.factor
core/bootstrap/layouts/layouts.factor
core/bootstrap/primitives.factor
core/bootstrap/stage1.factor
core/bootstrap/stage2.factor
core/classes/algebra/algebra-docs.factor [new file with mode: 0755]
core/classes/algebra/algebra-tests.factor [new file with mode: 0755]
core/classes/algebra/algebra.factor [new file with mode: 0755]
core/classes/classes-docs.factor
core/classes/classes-tests.factor
core/classes/classes.factor
core/classes/mixin/mixin.factor
core/classes/predicate/predicate-docs.factor
core/classes/predicate/predicate.factor
core/classes/tuple/authors.txt [new file with mode: 0644]
core/classes/tuple/summary.txt [new file with mode: 0644]
core/classes/tuple/tuple-docs.factor [new file with mode: 0755]
core/classes/tuple/tuple-tests.factor [new file with mode: 0755]
core/classes/tuple/tuple.factor [new file with mode: 0755]
core/classes/union/union.factor
core/combinators/combinators-docs.factor
core/combinators/combinators.factor
core/compiler/constants/constants.factor
core/compiler/tests/curry.factor
core/compiler/tests/templates.factor
core/continuations/continuations.factor
core/cpu/architecture/architecture.factor
core/cpu/arm/architecture/architecture.factor
core/cpu/arm/assembler/assembler.factor
core/cpu/arm/intrinsics/intrinsics.factor
core/cpu/ppc/allot/allot.factor
core/cpu/ppc/architecture/architecture.factor
core/cpu/ppc/intrinsics/intrinsics.factor
core/cpu/x86/32/32.factor
core/cpu/x86/64/64.factor
core/cpu/x86/allot/allot.factor
core/cpu/x86/architecture/architecture.factor
core/cpu/x86/assembler/assembler.factor
core/cpu/x86/intrinsics/intrinsics.factor
core/debugger/debugger.factor
core/dlists/dlists-tests.factor
core/effects/effects.factor
core/generator/registers/registers.factor
core/generic/generic-docs.factor
core/generic/generic-tests.factor
core/generic/generic.factor
core/generic/math/math.factor
core/generic/standard/standard.factor
core/hashtables/hashtables-docs.factor
core/hashtables/hashtables.factor
core/heaps/heaps-tests.factor
core/heaps/heaps.factor
core/inference/class/class.factor
core/inference/dataflow/dataflow.factor
core/inference/inference-tests.factor
core/inference/known-words/known-words.factor
core/inference/transforms/transforms-tests.factor
core/inference/transforms/transforms.factor
core/io/backend/backend.factor
core/io/encodings/binary/binary-docs.factor
core/io/encodings/encodings-docs.factor
core/io/encodings/encodings-tests.factor
core/io/encodings/encodings.factor
core/io/encodings/utf8/utf8-docs.factor
core/io/files/files-docs.factor
core/io/files/files-tests.factor
core/io/files/files.factor
core/io/io-tests.factor
core/kernel/kernel-docs.factor
core/kernel/kernel.factor
core/listener/listener.factor
core/math/intervals/intervals-tests.factor
core/math/intervals/intervals.factor
core/mirrors/mirrors-docs.factor
core/mirrors/mirrors-tests.factor
core/mirrors/mirrors.factor
core/optimizer/control/control.factor
core/optimizer/def-use/def-use-tests.factor
core/optimizer/inlining/inlining.factor
core/optimizer/known-words/known-words.factor
core/optimizer/math/math.factor
core/optimizer/optimizer-tests.factor
core/optimizer/pattern-match/pattern-match.factor [changed mode: 0644->0755]
core/parser/parser-docs.factor
core/parser/parser-tests.factor
core/parser/parser.factor
core/prettyprint/backend/backend.factor
core/prettyprint/prettyprint-tests.factor
core/prettyprint/prettyprint.factor
core/quotations/quotations.factor
core/refs/refs.factor
core/sequences/sequences-tests.factor
core/sequences/sequences.factor
core/slots/deprecated/deprecated.factor
core/slots/slots-docs.factor
core/slots/slots.factor
core/sorting/sorting.factor
core/source-files/source-files.factor
core/splitting/splitting.factor
core/syntax/syntax-docs.factor
core/syntax/syntax.factor
core/tuples/authors.txt [deleted file]
core/tuples/summary.txt [deleted file]
core/tuples/tuples-docs.factor [deleted file]
core/tuples/tuples-tests.factor [deleted file]
core/tuples/tuples.factor [deleted file]
core/vectors/vectors-tests.factor
core/vocabs/loader/loader-tests.factor
core/vocabs/loader/loader.factor
core/vocabs/vocabs.factor
core/words/words-tests.factor
core/words/words.factor
extra/bake/bake.factor
extra/benchmark/benchmark.factor
extra/benchmark/raytracer/raytracer.factor
extra/benchmark/reverse-complement/reverse-complement-tests.factor
extra/benchmark/reverse-complement/reverse-complement.factor
extra/benchmark/spectral-norm/spectral-norm.factor
extra/benchmark/typecheck2/typecheck2.factor
extra/benchmark/typecheck3/typecheck3.factor
extra/benchmark/typecheck4/typecheck4.factor
extra/bitfields/bitfields.factor
extra/boids/boids.factor
extra/boids/ui/ui.factor
extra/bootstrap/random/random.factor
extra/builder/benchmark/benchmark.factor
extra/builder/builder.factor
extra/builder/release/release.factor
extra/builder/util/util.factor
extra/bunny/bunny.factor
extra/bunny/model/model.factor
extra/bunny/outlined/outlined.factor
extra/cairo/ffi/ffi.factor
extra/cairo/lib/lib.factor
extra/cairo/png/png.factor
extra/calendar/calendar.factor
extra/calendar/format/format.factor
extra/calendar/windows/windows.factor
extra/cfdg/cfdg.factor
extra/classes/tuple/lib/authors.txt [new file with mode: 0644]
extra/classes/tuple/lib/lib-docs.factor [new file with mode: 0644]
extra/classes/tuple/lib/lib-tests.factor [new file with mode: 0644]
extra/classes/tuple/lib/lib.factor [new file with mode: 0755]
extra/cocoa/dialogs/dialogs.factor
extra/colors/hsv/hsv.factor
extra/combinators/cleave/cleave-docs.factor [deleted file]
extra/combinators/cleave/cleave.factor
extra/combinators/lib/lib-tests.factor
extra/combinators/lib/lib.factor
extra/concurrency/distributed/distributed-tests.factor
extra/concurrency/distributed/distributed.factor
extra/crypto/rsa/rsa.factor
extra/crypto/sha1/sha1.factor
extra/db/db.factor
extra/db/postgresql/lib/lib.factor
extra/db/postgresql/postgresql.factor
extra/db/sql/sql.factor
extra/db/sqlite/sqlite.factor
extra/db/tuples/tuples.factor
extra/db/types/types.factor
extra/delegate/delegate.factor
extra/documents/documents.factor
extra/editors/editors.factor
extra/editors/jedit/jedit.factor [changed mode: 0644->0755]
extra/editors/ultraedit/ultraedit.factor
extra/editors/wordpad/wordpad.factor
extra/faq/faq.factor
extra/fry/fry-docs.factor
extra/help/handbook/handbook.factor
extra/help/help.factor
extra/help/lint/lint.factor
extra/help/markup/markup.factor
extra/help/syntax/syntax.factor
extra/help/topics/topics.factor
extra/http/client/client.factor
extra/http/http.factor
extra/http/server/actions/actions.factor
extra/http/server/auth/login/login.factor
extra/http/server/callbacks/callbacks.factor
extra/http/server/components/components.factor
extra/http/server/db/db.factor
extra/http/server/server.factor
extra/http/server/sessions/sessions.factor
extra/http/server/sessions/storage/assoc/assoc.factor
extra/http/server/sessions/storage/db/db.factor
extra/http/server/static/static.factor
extra/http/server/templating/fhtml/fhtml-tests.factor
extra/http/server/templating/fhtml/fhtml.factor
extra/http/server/validators/validators.factor
extra/icfp/2006/2006.factor
extra/inverse/inverse.factor
extra/io/buffers/buffers-docs.factor
extra/io/buffers/buffers-tests.factor
extra/io/buffers/buffers.factor
extra/io/encodings/8-bit/8-bit-docs.factor [new file with mode: 0644]
extra/io/encodings/8-bit/8-bit-tests.factor [new file with mode: 0644]
extra/io/encodings/8-bit/8-bit.factor [new file with mode: 0755]
extra/io/encodings/8-bit/8859-1.TXT [new file with mode: 0644]
extra/io/encodings/8-bit/8859-10.TXT [new file with mode: 0644]
extra/io/encodings/8-bit/8859-11.TXT [new file with mode: 0644]
extra/io/encodings/8-bit/8859-13.TXT [new file with mode: 0644]
extra/io/encodings/8-bit/8859-14.TXT [new file with mode: 0644]
extra/io/encodings/8-bit/8859-15.TXT [new file with mode: 0644]
extra/io/encodings/8-bit/8859-16.TXT [new file with mode: 0644]
extra/io/encodings/8-bit/8859-2.TXT [new file with mode: 0644]
extra/io/encodings/8-bit/8859-3.TXT [new file with mode: 0644]
extra/io/encodings/8-bit/8859-4.TXT [new file with mode: 0644]
extra/io/encodings/8-bit/8859-5.TXT [new file with mode: 0644]
extra/io/encodings/8-bit/8859-6.TXT [new file with mode: 0644]
extra/io/encodings/8-bit/8859-7.TXT [new file with mode: 0644]
extra/io/encodings/8-bit/8859-8.TXT [new file with mode: 0644]
extra/io/encodings/8-bit/8859-9.TXT [new file with mode: 0644]
extra/io/encodings/8-bit/CP037.TXT [new file with mode: 0644]
extra/io/encodings/8-bit/CP1252.TXT [new file with mode: 0644]
extra/io/encodings/8-bit/KOI8-R.TXT [new file with mode: 0644]
extra/io/encodings/8-bit/ROMAN.TXT [new file with mode: 0644]
extra/io/encodings/8-bit/authors.txt [new file with mode: 0644]
extra/io/encodings/8-bit/summary.txt [new file with mode: 0644]
extra/io/encodings/8-bit/tags.txt [new file with mode: 0644]
extra/io/encodings/ascii/ascii-docs.factor [new file with mode: 0644]
extra/io/encodings/latin1/authors.txt [deleted file]
extra/io/encodings/latin1/latin1-docs.factor [deleted file]
extra/io/encodings/latin1/latin1-tests.factor [deleted file]
extra/io/encodings/latin1/latin1.factor [deleted file]
extra/io/encodings/latin1/summary.txt [deleted file]
extra/io/encodings/latin1/tags.txt [deleted file]
extra/io/encodings/strict/authors.txt [new file with mode: 0644]
extra/io/encodings/strict/strict-docs.factor [new file with mode: 0644]
extra/io/encodings/strict/strict-tests.factor [new file with mode: 0644]
extra/io/encodings/strict/strict.factor [new file with mode: 0644]
extra/io/encodings/strict/summary.txt [new file with mode: 0644]
extra/io/encodings/strict/tags.txt [new file with mode: 0644]
extra/io/encodings/utf16/utf16-docs.factor
extra/io/encodings/utf16/utf16-tests.factor
extra/io/encodings/utf16/utf16.factor
extra/io/launcher/launcher-docs.factor
extra/io/launcher/launcher.factor
extra/io/nonblocking/nonblocking-docs.factor
extra/io/nonblocking/nonblocking.factor
extra/io/paths/paths.factor
extra/io/priority/priority.factor [deleted file]
extra/io/sockets/impl/impl.factor
extra/io/unix/backend/backend.factor
extra/io/unix/files/files-tests.factor
extra/io/unix/files/files.factor
extra/io/unix/launcher/launcher-tests.factor
extra/io/unix/launcher/launcher.factor
extra/io/unix/priority/priority.factor [deleted file]
extra/io/unix/select/select.factor
extra/io/unix/unix.factor
extra/io/windows/ce/backend/backend.factor
extra/io/windows/files/files.factor
extra/io/windows/launcher/launcher.factor
extra/io/windows/nt/backend/backend.factor
extra/io/windows/nt/files/files-tests.factor [new file with mode: 0644]
extra/io/windows/nt/files/files.factor
extra/io/windows/nt/nt-tests.factor [deleted file]
extra/io/windows/nt/sockets/sockets.factor
extra/io/windows/windows.factor
extra/jamshred/tunnel/tunnel.factor
extra/json/writer/writer.factor
extra/koszul/koszul.factor
extra/lazy-lists/lazy-lists.factor
extra/levenshtein/levenshtein.factor
extra/lint/lint.factor
extra/locals/locals.factor
extra/lsys/strings/interpret/interpret.factor
extra/lsys/strings/rewrite/rewrite.factor
extra/lsys/strings/strings.factor
extra/lsys/ui/ui.factor
extra/macros/macros.factor
extra/match/match.factor
extra/math/analysis/analysis.factor
extra/math/complex/complex.factor
extra/math/functions/functions.factor
extra/math/matrices/matrices.factor
extra/math/polynomials/polynomials.factor
extra/math/quaternions/quaternions.factor
extra/math/ratios/ratios.factor
extra/math/statistics/statistics.factor
extra/maze/maze.factor
extra/memoize/memoize.factor
extra/models/models-docs.factor
extra/money/money.factor
extra/multi-methods/multi-methods.factor
extra/new-effects/new-effects.factor [new file with mode: 0644]
extra/opengl/demo-support/demo-support.factor
extra/opengl/opengl.factor
extra/opengl/shaders/shaders.factor
extra/openssl/openssl-docs.factor [new file with mode: 0644]
extra/openssl/openssl-tests.factor
extra/parser-combinators/parser-combinators.factor
extra/peg/ebnf/ebnf-tests.factor
extra/peg/ebnf/ebnf.factor
extra/peg/expr/expr.factor
extra/peg/parsers/parsers-tests.factor
extra/peg/parsers/parsers.factor
extra/peg/peg-docs.factor
extra/peg/peg-tests.factor
extra/peg/peg.factor
extra/project-euler/009/009.factor
extra/project-euler/014/014.factor
extra/project-euler/026/026.factor
extra/project-euler/027/027.factor
extra/project-euler/033/033.factor
extra/project-euler/039/039.factor
extra/project-euler/044/044.factor
extra/project-euler/075/075.factor
extra/project-euler/079/079.factor
extra/project-euler/project-euler.factor
extra/random-tester/random/random.factor
extra/random-weighted/random-weighted.factor
extra/random/blum-blum-shub/blum-blum-shub.factor
extra/random/dummy/dummy.factor
extra/random/mersenne-twister/mersenne-twister-tests.factor
extra/random/mersenne-twister/mersenne-twister.factor
extra/random/random-docs.factor [new file with mode: 0644]
extra/random/random-tests.factor [new file with mode: 0644]
extra/random/random.factor
extra/random/unix/unix.factor
extra/random/windows/windows.factor
extra/raptor/cron/cron.factor
extra/raptor/cronjobs.factor
extra/raptor/raptor.factor
extra/regexp/regexp.factor
extra/regexp2/regexp2.factor
extra/reports/noise/noise.factor
extra/reports/optimizer/optimizer.factor
extra/roman/roman.factor
extra/semantic-db/semantic-db-tests.factor
extra/serialize/serialize.factor
extra/shufflers/shufflers.factor
extra/singleton/singleton.factor
extra/springies/springies.factor
extra/springies/ui/ui.factor
extra/sudoku/sudoku.factor
extra/tar/tar.factor
extra/tools/completion/completion.factor
extra/tools/deploy/backend/backend.factor
extra/tools/deploy/deploy-tests.factor
extra/tools/deploy/macosx/macosx.factor
extra/tools/deploy/shaker/shaker.factor
extra/tools/deploy/shaker/strip-cocoa.factor
extra/tools/deploy/test/3/3.factor
extra/tools/disassembler/disassembler-tests.factor
extra/tools/vocabs/vocabs.factor
extra/tools/walker/walker.factor
extra/tuple-arrays/tuple-arrays.factor
extra/tuple-syntax/tuple-syntax.factor
extra/tuples/lib/authors.txt [deleted file]
extra/tuples/lib/lib-docs.factor [deleted file]
extra/tuples/lib/lib-tests.factor [deleted file]
extra/tuples/lib/lib.factor [deleted file]
extra/ui/commands/commands.factor
extra/ui/freetype/freetype.factor
extra/ui/gadgets/borders/borders.factor
extra/ui/gadgets/buttons/buttons.factor
extra/ui/gadgets/canvas/canvas.factor
extra/ui/gadgets/editors/editors.factor
extra/ui/gadgets/frames/frames-docs.factor
extra/ui/gadgets/gadgets-docs.factor
extra/ui/gadgets/gadgets.factor
extra/ui/gadgets/grids/grids-tests.factor
extra/ui/gadgets/labelled/labelled.factor
extra/ui/gadgets/lists/lists.factor
extra/ui/gadgets/packs/packs-docs.factor
extra/ui/gadgets/panes/panes.factor
extra/ui/gadgets/presentations/presentations-tests.factor
extra/ui/gadgets/scrollers/scrollers.factor
extra/ui/gadgets/tracks/tracks-docs.factor
extra/ui/gestures/gestures.factor
extra/ui/operations/operations.factor [changed mode: 0644->0755]
extra/ui/tools/interactor/interactor.factor
extra/ui/tools/listener/listener.factor
extra/ui/tools/search/search.factor
extra/ui/tools/walker/walker.factor
extra/ui/x11/x11.factor
extra/unicode/breaks/breaks.factor
extra/unicode/case/case.factor
extra/unicode/normalize/normalize.factor
extra/unicode/syntax/syntax.factor
extra/units/units-tests.factor
extra/units/units.factor
extra/unix/bsd/bsd.factor
extra/unix/bsd/freebsd/freebsd.factor [new file with mode: 0644]
extra/unix/bsd/macosx/macosx.factor [new file with mode: 0644]
extra/unix/bsd/netbsd/netbsd.factor [new file with mode: 0644]
extra/unix/bsd/openbsd/openbsd.factor [new file with mode: 0644]
extra/unix/kqueue/freebsd/freebsd.factor [new file with mode: 0644]
extra/unix/kqueue/kqueue.factor
extra/unix/kqueue/macosx/macosx.factor [new file with mode: 0644]
extra/unix/kqueue/netbsd/netbsd.factor [new file with mode: 0644]
extra/unix/kqueue/openbsd/openbsd.factor [new file with mode: 0644]
extra/unix/process/process.factor
extra/unix/stat/linux/64/64.factor
extra/unix/stat/netbsd/32/32.factor [new file with mode: 0644]
extra/unix/stat/netbsd/64/64.factor [new file with mode: 0644]
extra/unix/stat/netbsd/netbsd.factor
extra/unix/types/netbsd/32/32.factor [new file with mode: 0755]
extra/unix/types/netbsd/64/64.factor [new file with mode: 0755]
extra/unix/types/netbsd/netbsd.factor
extra/unix/unix.factor
extra/windows/advapi32/advapi32.factor
extra/windows/com/syntax/syntax.factor
extra/windows/kernel32/kernel32.factor
extra/windows/types/types.factor
extra/xml-rpc/xml-rpc.factor [changed mode: 0644->0755]
extra/xml/data/data.factor [changed mode: 0644->0755]
extra/xml/tests/errors.factor
extra/xml/tests/templating.factor
extra/xml/tests/test.factor
extra/xml/tokenize/tokenize.factor
extra/xml/utilities/utilities.factor
extra/xml/xml.factor
extra/xmode/catalog/catalog.factor
extra/xmode/code2html/responder/responder.factor
misc/factor.sh [deleted file]
vm/data_gc.c
vm/debug.c
vm/image.c
vm/layouts.h
vm/os-linux-x86-32.h [deleted file]
vm/os-linux-x86-64.h [deleted file]
vm/os-linux-x86.32.h [new file with mode: 0644]
vm/os-linux-x86.64.h [new file with mode: 0644]
vm/os-netbsd-x86.32.h [new file with mode: 0644]
vm/os-netbsd-x86.64.h [new file with mode: 0644]
vm/os-netbsd.h
vm/os-solaris-x86.32.h [new file with mode: 0644]
vm/os-solaris-x86.64.h [new file with mode: 0644]
vm/os-solaris.h
vm/platform.h
vm/primitives.c
vm/run.c
vm/types.c
vm/types.h

index 7e1e52d866e724259091b91bcdff1f1119397855..f2cf3de1192bd8a28d8ed4143e8658d9ed6a02bf 100644 (file)
@@ -18,4 +18,4 @@ factor
 temp
 logs
 work
-buildsupport/wordsize
+build-support/wordsize
index ecb333a0b21f99d3e6c8beb1f1948518f3ba7453..5f7cdca06dcc6304b8508ebdb1d951f0d1646dd6 100755 (executable)
--- a/Makefile
+++ b/Makefile
@@ -45,8 +45,8 @@ DLL_OBJS = $(PLAF_DLL_OBJS) \
 
 EXE_OBJS = $(PLAF_EXE_OBJS)
 
-default: build-support/wordsize
-       $(MAKE) `./build-support/target`
+default:
+       $(MAKE) `./build-support/factor.sh make-target`
 
 help:
        @echo "Run '$(MAKE)' with one of the following parameters:"
@@ -162,9 +162,6 @@ factor: $(DLL_OBJS) $(EXE_OBJS)
        $(CC) $(LIBS) $(LIBPATH) -L. $(LINK_WITH_ENGINE) \
                $(CFLAGS) -o $@$(EXE_SUFFIX)$(EXE_EXTENSION) $(EXE_OBJS)
 
-build-support/wordsize: build-support/wordsize.c
-       gcc build-support/wordsize.c -o build-support/wordsize
-
 clean:
        rm -f vm/*.o
        rm -f factor*.dll libfactor*.*
diff --git a/build-support/factor.sh b/build-support/factor.sh
new file mode 100755 (executable)
index 0000000..476e885
--- /dev/null
@@ -0,0 +1,458 @@
+#!/usr/bin/env bash
+
+# Programs returning != 0 will not cause script to exit
+set +e
+
+# Case insensitive string comparison
+shopt -s nocaseglob
+#shopt -s nocasematch
+
+ECHO=echo
+OS=
+ARCH=
+WORD=
+NO_UI=
+GIT_PROTOCOL=${GIT_PROTOCOL:="git"}
+GIT_URL=${GIT_URL:=$GIT_PROTOCOL"://factorcode.org/git/factor.git"}
+
+test_program_installed() {
+    if ! [[ -n `type -p $1` ]] ; then
+        return 0;
+    fi
+    return 1;
+}
+
+ensure_program_installed() {
+    installed=0;
+    for i in $* ;
+    do
+        $ECHO -n "Checking for $i..."
+        test_program_installed $i
+        if [[ $? -eq 0 ]]; then
+            echo -n "not "
+        else    
+            installed=$(( $installed + 1 ))
+        fi
+        $ECHO "found!"
+    done
+    if [[ $installed -eq 0 ]] ; then
+        $ECHO -n "Install "
+        if [[ $# -eq 1 ]] ; then
+            $ECHO -n $1
+        else
+            $ECHO -n "any of [ $* ]"
+        fi
+        $ECHO " and try again."
+        exit 1
+    fi
+}
+
+check_ret() {
+    RET=$?
+    if [[ $RET -ne 0 ]] ; then
+       $ECHO $1 failed
+       exit 2
+    fi
+}
+
+check_gcc_version() {
+    $ECHO -n "Checking gcc version..."
+    GCC_VERSION=`$CC --version`
+    check_ret gcc
+    if [[ $GCC_VERSION == *3.3.* ]] ; then
+        $ECHO "bad!"
+        $ECHO "You have a known buggy version of gcc (3.3)"
+        $ECHO "Install gcc 3.4 or higher and try again."
+        exit 3
+    fi
+    $ECHO "ok."
+}
+
+set_downloader() {
+    test_program_installed wget curl
+    if [[ $? -ne 0 ]] ; then
+        DOWNLOADER=wget
+    else
+        DOWNLOADER="curl -O"
+    fi
+}
+
+set_md5sum() {
+    test_program_installed md5sum
+    if [[ $? -ne 0 ]] ; then
+        MD5SUM=md5sum
+    else
+        MD5SUM="md5 -r"
+    fi
+}
+
+set_gcc() {
+    case $OS in
+        openbsd) ensure_program_installed egcc; CC=egcc;;
+       netbsd) if [[ $WORD -eq 64 ]] ; then
+                       CC=/usr/pkg/gcc34/bin/gcc
+               else
+                       CC=gcc
+               fi ;;
+        *) CC=gcc;;
+    esac
+}
+
+set_make() {
+    case $OS in
+        netbsd) MAKE='gmake';;
+        freebsd) MAKE='gmake';;
+        openbsd) MAKE='gmake';;
+        dragonflybsd) MAKE='gmake';;
+        *) MAKE='make';;
+    esac
+    if ! [[ $MAKE -eq 'gmake' ]] ; then
+       ensure_program_installed gmake
+    fi
+}
+
+check_installed_programs() {
+    ensure_program_installed chmod
+    ensure_program_installed uname
+    ensure_program_installed git
+    ensure_program_installed wget curl
+    ensure_program_installed gcc
+    ensure_program_installed make gmake
+    ensure_program_installed md5sum md5
+    ensure_program_installed cut
+    check_gcc_version
+}
+
+check_library_exists() {
+    GCC_TEST=factor-library-test.c
+    GCC_OUT=factor-library-test.out
+    $ECHO -n "Checking for library $1..."
+    $ECHO "int main(){return 0;}" > $GCC_TEST
+    $CC $GCC_TEST -o $GCC_OUT -l $1
+    if [[ $? -ne 0 ]] ; then
+        $ECHO "not found!"
+        $ECHO "Warning: library $1 not found."
+        $ECHO "***Factor will compile NO_UI=1"
+        NO_UI=1
+    fi
+    rm -f $GCC_TEST
+    check_ret rm
+    rm -f $GCC_OUT
+    check_ret rm
+    $ECHO "found."
+}
+
+check_X11_libraries() {
+    check_library_exists freetype
+    check_library_exists GLU
+    check_library_exists GL
+    check_library_exists X11
+}
+
+check_libraries() {
+    case $OS in
+            linux) check_X11_libraries;;
+    esac
+}
+
+check_factor_exists() {
+    if [[ -d "factor" ]] ; then
+        $ECHO "A directory called 'factor' already exists."
+        $ECHO "Rename or delete it and try again."
+        exit 4
+    fi
+}
+
+find_os() {
+    $ECHO "Finding OS..."
+    uname_s=`uname -s`
+    check_ret uname
+    case $uname_s in
+        CYGWIN_NT-5.2-WOW64) OS=winnt;;
+        *CYGWIN_NT*) OS=winnt;;
+        *CYGWIN*) OS=winnt;;
+        *darwin*) OS=macosx;;
+        *Darwin*) OS=macosx;;
+        *linux*) OS=linux;;
+        *Linux*) OS=linux;;
+        *NetBSD*) OS=netbsd;;
+        *FreeBSD*) OS=freebsd;;
+        *OpenBSD*) OS=openbsd;;
+        *DragonFly*) OS=dragonflybsd;;
+    esac
+}
+
+find_architecture() {
+    $ECHO "Finding ARCH..."
+    uname_m=`uname -m`
+    check_ret uname
+    case $uname_m in
+       i386) ARCH=x86;;
+       i686) ARCH=x86;;
+       amd64) ARCH=x86;;
+       *86) ARCH=x86;;
+       *86_64) ARCH=x86;;
+       "Power Macintosh") ARCH=ppc;;
+    esac
+}
+
+write_test_program() {
+    echo "#include <stdio.h>" > $C_WORD.c
+    echo "int main(){printf(\"%d\", 8*sizeof(void*)); return 0; }" >> $C_WORD.c
+}
+
+find_word_size() {
+    $ECHO "Finding WORD..."
+    C_WORD=factor-word-size
+    write_test_program
+    gcc -o $C_WORD $C_WORD.c
+    WORD=$(./$C_WORD)
+    check_ret $C_WORD
+    rm -f $C_WORD*
+}
+
+set_factor_binary() {
+    case $OS in
+        # winnt) FACTOR_BINARY=factor-nt;;
+        # macosx) FACTOR_BINARY=./Factor.app/Contents/MacOS/factor;;
+        *) FACTOR_BINARY=factor;;
+    esac
+}
+
+echo_build_info() {
+    $ECHO OS=$OS
+    $ECHO ARCH=$ARCH
+    $ECHO WORD=$WORD
+    $ECHO FACTOR_BINARY=$FACTOR_BINARY
+    $ECHO MAKE_TARGET=$MAKE_TARGET
+    $ECHO BOOT_IMAGE=$BOOT_IMAGE
+    $ECHO MAKE_IMAGE_TARGET=$MAKE_IMAGE_TARGET
+    $ECHO GIT_PROTOCOL=$GIT_PROTOCOL
+    $ECHO GIT_URL=$GIT_URL
+    $ECHO DOWNLOADER=$DOWNLOADER
+    $ECHO CC=$CC
+    $ECHO MAKE=$MAKE
+}
+
+set_build_info() {
+    if ! [[ -n $OS && -n $ARCH && -n $WORD ]] ; then
+        $ECHO "OS: $OS"
+        $ECHO "ARCH: $ARCH"
+        $ECHO "WORD: $WORD"
+        $ECHO "OS, ARCH, or WORD is empty.  Please report this"
+        exit 5
+    fi
+
+    MAKE_TARGET=$OS-$ARCH-$WORD
+    MAKE_IMAGE_TARGET=$ARCH.$WORD
+    BOOT_IMAGE=boot.$ARCH.$WORD.image
+    if [[ $OS == macosx && $ARCH == ppc ]] ; then
+        MAKE_IMAGE_TARGET=$OS-$ARCH
+        MAKE_TARGET=$OS-$ARCH
+        BOOT_IMAGE=boot.macosx-ppc.image
+    fi
+    if [[ $OS == linux && $ARCH == ppc ]] ; then
+        MAKE_IMAGE_TARGET=$OS-$ARCH
+        MAKE_TARGET=$OS-$ARCH
+        BOOT_IMAGE=boot.linux-ppc.image
+    fi
+}
+
+find_build_info() {
+    find_os
+    find_architecture
+    find_word_size
+    set_factor_binary
+    set_build_info
+       set_downloader
+       set_gcc
+       set_make
+    echo_build_info
+}
+
+invoke_git() {
+    git $*
+    check_ret git
+}
+
+git_clone() {
+    echo "Downloading the git repository from factorcode.org..."
+    invoke_git clone $GIT_URL
+}
+
+git_pull_factorcode() {
+    echo "Updating the git repository from factorcode.org..."
+    invoke_git pull $GIT_URL master
+}
+
+cd_factor() {
+    cd factor
+    check_ret cd
+}
+
+invoke_make() {
+   $MAKE $*
+   check_ret $MAKE
+}
+
+make_clean() {
+    invoke_make clean
+}
+
+make_factor() {
+    invoke_make NO_UI=$NO_UI $MAKE_TARGET -j5
+}
+
+update_boot_images() {
+    echo "Deleting old images..."
+    rm checksums.txt* > /dev/null 2>&1
+    rm $BOOT_IMAGE.* > /dev/null 2>&1
+    rm temp/staging.*.image > /dev/null 2>&1
+    if [[ -f $BOOT_IMAGE ]] ; then
+        get_url http://factorcode.org/images/latest/checksums.txt
+        factorcode_md5=`cat checksums.txt|grep $BOOT_IMAGE|cut -f2 -d' '`;
+        set_md5sum
+        case $OS in
+             netbsd) disk_md5=`md5 $BOOT_IMAGE | cut -f4 -d' '`;;
+             *) disk_md5=`$MD5SUM $BOOT_IMAGE|cut -f1 -d' '` ;;
+        esac
+        echo "Factorcode md5: $factorcode_md5";
+        echo "Disk md5: $disk_md5";
+        if [[ "$factorcode_md5" == "$disk_md5" ]] ; then
+            echo "Your disk boot image matches the one on factorcode.org."
+        else
+            rm $BOOT_IMAGE > /dev/null 2>&1
+            get_boot_image;
+        fi
+    else
+        get_boot_image
+    fi
+}
+
+get_boot_image() {
+    echo "Downloading boot image $BOOT_IMAGE."
+    get_url http://factorcode.org/images/latest/$BOOT_IMAGE
+}
+
+get_url() {
+    if [[ $DOWNLOADER -eq "" ]] ; then
+        set_downloader;
+    fi
+    echo $DOWNLOADER $1 ;
+    $DOWNLOADER $1
+    check_ret $DOWNLOADER
+}
+
+maybe_download_dlls() {
+    if [[ $OS == winnt ]] ; then
+        get_url http://factorcode.org/dlls/freetype6.dll
+        get_url http://factorcode.org/dlls/zlib1.dll
+        get_url http://factorcode.org/dlls/OpenAL32.dll
+        get_url http://factorcode.org/dlls/alut.dll
+        get_url http://factorcode.org/dlls/comerr32.dll
+        get_url http://factorcode.org/dlls/gssapi32.dll
+        get_url http://factorcode.org/dlls/iconv.dll
+        get_url http://factorcode.org/dlls/k5sprt32.dll
+        get_url http://factorcode.org/dlls/krb5_32.dll
+        get_url http://factorcode.org/dlls/libcairo-2.dll
+        get_url http://factorcode.org/dlls/libeay32.dll
+        get_url http://factorcode.org/dlls/libiconv2.dll
+        get_url http://factorcode.org/dlls/libintl3.dll
+        get_url http://factorcode.org/dlls/libpq.dll
+        get_url http://factorcode.org/dlls/libxml2.dll
+        get_url http://factorcode.org/dlls/libxslt.dll
+        get_url http://factorcode.org/dlls/msvcr71.dll
+        get_url http://factorcode.org/dlls/ogg.dll
+        get_url http://factorcode.org/dlls/pgaevent.dll
+        get_url http://factorcode.org/dlls/sqlite3.dll
+        get_url http://factorcode.org/dlls/ssleay32.dll
+        get_url http://factorcode.org/dlls/theora.dll
+        get_url http://factorcode.org/dlls/vorbis.dll
+        chmod 777 *.dll
+        check_ret chmod
+    fi
+}
+
+get_config_info() {
+    find_build_info
+    check_installed_programs
+    check_libraries
+}
+
+bootstrap() {
+    ./$FACTOR_BINARY -i=$BOOT_IMAGE
+}
+
+install() {
+    check_factor_exists
+    get_config_info
+    git_clone
+    cd_factor
+    make_factor
+    get_boot_image
+    maybe_download_dlls
+    bootstrap
+}
+
+
+update() {
+    get_config_info
+    git_pull_factorcode
+    make_clean
+    make_factor
+}
+
+update_bootstrap() {
+    update_boot_images
+    bootstrap
+}
+
+refresh_image() {
+    ./$FACTOR_BINARY -script -e="USE: vocabs.loader refresh-all USE: memory save 0 USE: system exit"
+    check_ret factor
+}
+
+make_boot_image() {
+    ./$FACTOR_BINARY -script -e="\"$MAKE_IMAGE_TARGET\" USE: bootstrap.image make-image save 0 USE: system exit"
+    check_ret factor
+
+}
+
+install_build_system_apt() {
+    ensure_program_installed yes
+    yes | sudo apt-get install sudo libc6-dev libfreetype6-dev libx11-dev xorg-dev glutg3-dev wget git-core git-doc rlwrap gcc make
+    check_ret sudo
+}
+
+install_build_system_port() {
+    test_program_installed git
+    if [[ $? -ne 1 ]] ; then
+       ensure_program_installed yes
+               echo "git not found."
+               echo "This script requires either git-core or port."
+               echo "If it fails, install git-core or port and try again."
+       ensure_program_installed port
+               echo "Installing git-core with port...this will take awhile."
+       yes | sudo port install git-core
+    fi
+}
+
+usage() {
+    echo "usage: $0 install|install-x11|install-macosx|self-update|quick-update|update|bootstrap|net-bootstrap|make-target"
+    echo "If you are behind a firewall, invoke as:"
+    echo "env GIT_PROTOCOL=http $0 <command>"
+}
+
+case "$1" in
+    install) install ;;
+    install-x11) install_build_system_apt; install ;;
+    install-macosx) install_build_system_port; install ;;
+    self-update) update; make_boot_image; bootstrap;;
+    quick-update) update; refresh_image ;;
+    update) update; update_bootstrap ;;
+    bootstrap) get_config_info; bootstrap ;;
+    dlls) get_config_info; maybe_download_dlls;;
+    net-bootstrap) get_config_info; update_boot_images; bootstrap ;;
+       make-target) ECHO=false; find_build_info; echo $MAKE_TARGET ;;
+    *) usage ;;
+esac
index 8422ec197c24f255efb9e3c6591623475963c7cc..2eee054dab0c5675a85082d58ce4b89759c9fcc9 100644 (file)
@@ -1,4 +1,5 @@
 #include <stdio.h>
+#include <sys/event.h>
 
 #if defined(__FreeBSD__)
        #define BSD
@@ -141,10 +142,12 @@ void unix_constants()
        constant(EINTR);
        constant(EAGAIN);
        constant(EINPROGRESS);
-    constant(PROT_READ);
+       constant(PROT_READ);
        constant(PROT_WRITE);
        constant(MAP_FILE);
        constant(MAP_SHARED);
+       grovel(pid_t);
+
 }
        
 int main() {
@@ -158,7 +161,13 @@ int main() {
        openbsd_stat();
        openbsd_types();
 #endif
+       grovel(blkcnt_t);
+        grovel(blksize_t);
+        //grovel(fflags_t);
+        grovel(ssize_t);
 
+       grovel(size_t);
+       grovel(struct kevent);
 #ifdef UNIX
        unix_types();
        unix_constants();
diff --git a/build-support/target b/build-support/target
deleted file mode 100755 (executable)
index 1903a6d..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-#!/bin/sh
-
-if [ \( `uname -s ` = FreeBSD \) -a \( `uname -p` = i386 \) ]
-then
-  echo freebsd-x86-32
-elif [ \( `uname -s` = FreeBSD \) -a \( `uname -m` = amd64 \) ]
-then
-  echo freebsd-x86-64
-elif [ \( `uname -s` = OpenBSD \) -a \( `uname -m` = i386 \) ]
-then
-  echo openbsd-x86-32
-elif [ \( `uname -s` = OpenBSD \) -a \( `uname -m` = amd64 \) ]
-then
-  echo openbsd-x86-64
-elif [ \( `uname -s` = NetBSD \) -a \( `uname -p` = i386 \) ]
-then
-  echo netbsd-x86-32
-elif [ \( `uname -s` = NetBSD \) -a \( `uname -p` = x86_64 \) ]
-then
-  echo netbsd-x86-64
-elif [ \( `uname -s` = Darwin \) -a \( `uname -p` = powerpc \) ]
-then
-  echo macosx-ppc
-elif [ `uname -s` = Darwin ]
-then
-  echo macosx-x86-`./build-support/wordsize`
-elif [ \( `uname -s` = Linux \) -a \( `uname -m` = i686 \) ]
-then
-  echo linux-x86-32
-elif [ \( `uname -s` = Linux \) -a \( `uname -m` = x86_64 \) ]
-then
-  echo linux-x86-64
-elif [ \( `uname -o` = Cygwin \) -a \( `uname -m` = i686 \) ]
-then
-  echo winnt-x86-`./build-support/wordsize`
-else
-  echo help
-fi
diff --git a/build-support/wordsize.c b/build-support/wordsize.c
deleted file mode 100644 (file)
index a0e7d0b..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-
-#include <stdio.h>
-
-int main ()
-{
-  printf("%d", 8*sizeof(void*));
-  return 0;
-}
index 436d73e874b264632b1d420986f637cd23492811..cfa9fb2e1626c506f1c87e0de3d6336a1b01d66e 100755 (executable)
@@ -1,13 +1,12 @@
 ! Copyright (C) 2004, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: assocs kernel math namespaces sequences system
-kernel.private tuples bit-arrays byte-arrays float-arrays 
-arrays ;
+kernel.private bit-arrays byte-arrays float-arrays arrays ;
 IN: alien
 
 ! Some predicate classes used by the compiler for optimization
 ! purposes
-PREDICATE: alien simple-alien
+PREDICATE: simple-alien < alien
     underlying-alien not ;
 
 UNION: simple-c-ptr
@@ -18,7 +17,7 @@ alien POSTPONE: f byte-array bit-array float-array ;
 
 DEFER: pinned-c-ptr?
 
-PREDICATE: alien pinned-alien
+PREDICATE: pinned-alien < alien
     underlying-alien pinned-c-ptr? ;
 
 UNION: pinned-c-ptr
@@ -40,7 +39,7 @@ M: alien equal?
         2dup [ expired? ] either? [
             [ expired? ] both?
         ] [
-            [ alien-address ] 2apply =
+            [ alien-address ] bi@ =
         ] if
     ] [
         2drop f
old mode 100644 (file)
new mode 100755 (executable)
index 714973e..414c645
@@ -31,4 +31,4 @@ INSTANCE: array sequence
 
 : 4array ( w x y z -- array ) { } 4sequence ; flushable
 
-PREDICATE: array pair length 2 number= ;
+PREDICATE: pair < array length 2 number= ;
old mode 100644 (file)
new mode 100755 (executable)
index a0a60e8..c4db604
@@ -93,3 +93,14 @@ unit-test
 ] [
     F{ 1.0 2.0 } [ dup ] H{ } map>assoc
 ] unit-test
+
+[ { 3 } ] [
+    [
+        3
+        H{ } clone
+        2 [
+            2dup [ , f ] cache drop
+        ] times
+        2drop
+    ] { } make
+] unit-test
index ff0938e001da68648a5bebbb268e820da8860297..b911faf67234d54e5671f1f2aa05d5a9feb186c4 100755 (executable)
@@ -115,7 +115,7 @@ M: assoc assoc-clone-like ( assoc exemplar -- newassoc )
     swap [ swapd set-at ] curry assoc-each ;
 
 : union ( assoc1 assoc2 -- union )
-    2dup [ assoc-size ] 2apply + pick new-assoc
+    2dup [ assoc-size ] bi@ + pick new-assoc
     [ rot update ] keep [ swap update ] keep ;
 
 : diff ( assoc1 assoc2 -- diff )
@@ -134,11 +134,11 @@ M: assoc assoc-clone-like ( assoc exemplar -- newassoc )
     (substitute) map ;
 
 : cache ( key assoc quot -- value )
-    2over at [
+    2over at* [
         >r 3drop r>
     ] [
-        pick rot >r >r call dup r> r> set-at
-    ] if* ; inline
+        drop pick rot >r >r call dup r> r> set-at
+    ] if ; inline
 
 : change-at ( key assoc quot -- )
     [ >r at r> call ] 3keep drop set-at ; inline
index 5774b86e45f3f808dbcd5903d0d5e831e541497e..e28c16c3c25c5acd496b9ad4f6e171996b031714 100755 (executable)
@@ -21,7 +21,7 @@ IN: bit-arrays.tests
     { t f t } { f t f }
 ] [
     { t f t } >bit-array dup clone dup [ not ] change-each
-    [ >array ] 2apply
+    [ >array ] bi@
 ] unit-test
 
 [
index 04d57dff1629023664c1586a843b6cc0e201694d..7d4db3c473a69612453f36ca38cf7c81946f6feb 100755 (executable)
@@ -2,8 +2,8 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: compiler cpu.architecture vocabs.loader system sequences
 namespaces parser kernel kernel.private classes classes.private
-arrays hashtables vectors tuples sbufs inference.dataflow
-hashtables.private sequences.private math tuples.private
+arrays hashtables vectors classes.tuple sbufs inference.dataflow
+hashtables.private sequences.private math classes.tuple.private
 growable namespaces.private assocs words generator command-line
 vocabs io prettyprint libc compiler.units ;
 IN: bootstrap.compiler
@@ -36,7 +36,7 @@ nl
 {
     roll -roll declare not
 
-    tuple-class-eq? array? hashtable? vector?
+    array? hashtable? vector?
     tuple? sbuf? node? tombstone?
 
     array-capacity array-nth set-array-nth
index 52a24967550ff6ba74ed1bdee4e6cf0a4e0023e6..deb54fdeeb6d230ab19374dac660d4a9c4676f87 100755 (executable)
@@ -4,10 +4,11 @@ USING: alien arrays bit-arrays byte-arrays generic assocs
 hashtables assocs hashtables.private io kernel kernel.private
 math namespaces parser prettyprint sequences sequences.private
 strings sbufs vectors words quotations assocs system layouts
-splitting growable classes tuples words.private
-io.binary io.files vocabs vocabs.loader source-files
-definitions debugger float-arrays quotations.private
-sequences.private combinators io.encodings.binary ;
+splitting growable classes classes.tuple classes.tuple.private
+words.private io.binary io.files vocabs vocabs.loader
+source-files definitions debugger float-arrays
+quotations.private sequences.private combinators
+io.encodings.binary ;
 IN: bootstrap.image
 
 : my-arch ( -- arch )
@@ -294,17 +295,14 @@ M: bit-array ' bit-array emit-dummy-array ;
 
 M: float-array ' float-array emit-dummy-array ;
 
-! Arrays
-: emit-array ( list type tag -- pointer )
-    >r >r [ ' ] map r> r> [
-        dup length emit-fixnum
-        emit-seq
-    ] emit-object ;
-
-: emit-tuple ( obj -- pointer )
+! Tuples
+: emit-tuple ( tuple -- pointer )
     [
-        [ tuple>array unclip transfer-word , % ] { } make
-        tuple type-number dup emit-array
+        [
+            dup class transfer-word tuple-layout ' ,
+            tuple>array 1 tail-slice [ ' ] map %
+        ] { } make
+        tuple type-number dup [ emit-seq ] emit-object
     ]
     ! Hack
     over class word-name "tombstone" =
@@ -312,11 +310,31 @@ M: float-array ' float-array emit-dummy-array ;
 
 M: tuple ' emit-tuple ;
 
+M: tuple-layout '
+    objects get [
+        [
+            dup layout-hashcode ' ,
+            dup layout-class ' ,
+            dup layout-size ' ,
+            dup layout-superclasses ' ,
+            layout-echelon ' ,
+        ] { } make
+        \ tuple-layout type-number
+        object tag-number [ emit-seq ] emit-object
+    ] cache ;
+
 M: tombstone '
     delegate
     "((tombstone))" "((empty))" ? "hashtables.private" lookup
     word-def first objects get [ emit-tuple ] cache ;
 
+! Arrays
+: emit-array ( list type tag -- pointer )
+    >r >r [ ' ] map r> r> [
+        dup length emit-fixnum
+        emit-seq
+    ] emit-object ;
+
 M: array '
     array type-number object tag-number emit-array ;
 
@@ -348,8 +366,10 @@ M: curry '
 : emit-global ( -- )
     [
         {
-            dictionary source-files
-            typemap builtins class<map class-map update-map
+            dictionary source-files builtins
+            update-map class<-cache class-not-cache
+            classes-intersect-cache class-and-cache
+            class-or-cache
         } [ dup get swap bootstrap-word set ] each
     ] H{ } make-assoc
     bootstrap-global set
index e15a7b4d7c26e80149569b59f5091ead215f2475..846cce153bb62ad2d391d0233b74c949b3a75484 100755 (executable)
@@ -2,13 +2,13 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: namespaces math words kernel alien byte-arrays
 hashtables vectors strings sbufs arrays bit-arrays
-float-arrays quotations assocs layouts tuples ;
+float-arrays quotations assocs layouts classes.tuple.private ;
 
 BIN: 111 tag-mask set
 8 num-tags set
 3 tag-bits set
 
-19 num-types set
+20 num-types set
 
 H{
     { fixnum      BIN: 000 }
@@ -33,4 +33,5 @@ tag-numbers get H{
     { alien 16 }
     { word 17 }
     { byte-array 18 }
+    { tuple-layout 19 }
 } union type-numbers set
index 825ee05584aa6ee4bf82cd357f6aa4027299b745..2e1a7f9f57a797ad3469a1be054ab25fc2cefddc 100755 (executable)
@@ -2,10 +2,10 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: alien arrays byte-arrays generic hashtables
 hashtables.private io kernel math namespaces parser sequences
-strings vectors words quotations assocs layouts classes tuples
-kernel.private vocabs vocabs.loader source-files definitions
-slots.deprecated classes.union compiler.units
-bootstrap.image.private io.files ;
+strings vectors words quotations assocs layouts classes
+classes.tuple classes.tuple.private kernel.private vocabs
+vocabs.loader source-files definitions slots.deprecated
+classes.union compiler.units bootstrap.image.private io.files ;
 IN: bootstrap.primitives
 
 "Creating primitives and basic runtime structures..." print flush
@@ -31,6 +31,9 @@ crossref off
 H{ } clone dictionary set
 H{ } clone changed-words set
 H{ } clone root-cache set
+H{ } clone source-files set
+H{ } clone update-map set
+init-caches
 
 ! Vocabulary for slot accessors
 "accessors" create-vocab drop
@@ -43,6 +46,9 @@ call
 call
 call
 
+! After we execute bootstrap/layouts
+num-types get f <array> builtins set
+
 ! Create some empty vocabs where the below primitives and
 ! classes will go
 {
@@ -54,6 +60,8 @@ call
     "byte-arrays"
     "byte-vectors"
     "classes.private"
+    "classes.tuple"
+    "classes.tuple.private"
     "compiler.units"
     "continuations.private"
     "float-arrays"
@@ -85,19 +93,12 @@ call
     "system.private"
     "threads.private"
     "tools.profiler.private"
-    "tuples"
-    "tuples.private"
     "words"
     "words.private"
     "vectors"
     "vectors.private"
 } [ create-vocab drop ] each
 
-H{ } clone source-files set
-H{ } clone update-map set
-H{ } clone class<map set
-H{ } clone class-map set
-
 ! Builtin classes
 : builtin-predicate-quot ( class -- quot )
     [
@@ -130,9 +131,6 @@ H{ } clone class-map set
     dup define-builtin-predicate
     r> define-builtin-slots ;
 
-H{ } clone typemap set
-num-types get f <array> builtins set
-
 ! Forward definitions
 "object" "kernel" create t "class" set-word-prop
 "object" "kernel" create union-class "metaclass" set-word-prop
@@ -145,8 +143,6 @@ num-types get f <array> builtins set
 "bignum" "math" create { } define-builtin
 "bignum" "math" create ">bignum" "math" create 1quotation "coercer" set-word-prop
 
-"tuple" "kernel" create { } define-builtin
-
 "ratio" "math" create {
     {
         { "integer" "math" }
@@ -182,8 +178,6 @@ num-types get f <array> builtins set
 
 "f" "syntax" lookup { } define-builtin
 
-! do not word...
-
 "array" "arrays" create { } define-builtin
 
 "wrapper" "kernel" create {
@@ -297,9 +291,57 @@ define-builtin
 
 "callstack" "kernel" create { } define-builtin
 
+"tuple-layout" "classes.tuple.private" create {
+    {
+        { "fixnum" "math" }
+        "hashcode"
+        { "layout-hashcode" "classes.tuple.private" }
+        f
+    }
+    {
+        { "word" "words" }
+        "class"
+        { "layout-class" "classes.tuple.private" }
+        f
+    }
+    {
+        { "fixnum" "math" }
+        "size"
+        { "layout-size" "classes.tuple.private" }
+        f
+    }
+    {
+        { "array" "arrays" }
+        "superclasses"
+        { "layout-superclasses" "classes.tuple.private" }
+        f
+    }
+    {
+        { "fixnum" "math" }
+        "echelon"
+        { "layout-echelon" "classes.tuple.private" }
+        f
+    }
+} define-builtin
+
+"tuple" "kernel" create { } define-builtin
+
+"tuple" "kernel" lookup
+{
+    {
+        { "object" "kernel" }
+        "delegate"
+        { "delegate" "kernel" }
+        { "set-delegate" "kernel" }
+    }
+}
+define-tuple-slots
+
+"tuple" "kernel" lookup define-tuple-layout
+
 ! Define general-t type, which is any object that is not f.
 "general-t" "kernel" create
-"f" "syntax" lookup builtins get remove [ ] subset f union-class
+f "f" "syntax" lookup builtins get remove [ ] subset union-class
 define-class
 
 "f" "syntax" create [ not ] "predicate" set-word-prop
@@ -311,18 +353,20 @@ define-class
 ! Catch-all class for providing a default method.
 "object" "kernel" create [ drop t ] "predicate" set-word-prop
 "object" "kernel" create
-builtins get [ ] subset f union-class define-class
+f builtins get [ ] subset union-class define-class
 
 ! Class of objects with object tag
 "hi-tag" "classes.private" create
-builtins get num-tags get tail f union-class define-class
+f builtins get num-tags get tail union-class define-class
 
 ! Null class with no instances.
 "null" "kernel" create [ drop f ] "predicate" set-word-prop
-"null" "kernel" create { } f union-class define-class
+"null" "kernel" create f { } union-class define-class
 
 ! Create special tombstone values
-"tombstone" "hashtables.private" create { } define-tuple-class
+"tombstone" "hashtables.private" create
+"tuple" "kernel" lookup
+{ } define-tuple-class
 
 "((empty))" "hashtables.private" create
 "tombstone" "hashtables.private" lookup f
@@ -334,6 +378,7 @@ builtins get num-tags get tail f union-class define-class
 
 ! Some tuple classes
 "hashtable" "hashtables" create
+"tuple" "kernel" lookup
 {
     {
         { "array-capacity" "sequences.private" }
@@ -354,6 +399,7 @@ builtins get num-tags get tail f union-class define-class
 } define-tuple-class
 
 "sbuf" "sbufs" create
+"tuple" "kernel" lookup
 {
     {
         { "string" "strings" }
@@ -369,6 +415,7 @@ builtins get num-tags get tail f union-class define-class
 } define-tuple-class
 
 "vector" "vectors" create
+"tuple" "kernel" lookup
 {
     {
         { "array" "arrays" }
@@ -384,6 +431,7 @@ builtins get num-tags get tail f union-class define-class
 } define-tuple-class
 
 "byte-vector" "byte-vectors" create
+"tuple" "kernel" lookup
 {
     {
         { "byte-array" "byte-arrays" }
@@ -399,6 +447,7 @@ builtins get num-tags get tail f union-class define-class
 } define-tuple-class
 
 "bit-vector" "bit-vectors" create
+"tuple" "kernel" lookup
 {
     {
         { "bit-array" "bit-arrays" }
@@ -414,6 +463,7 @@ builtins get num-tags get tail f union-class define-class
 } define-tuple-class
 
 "float-vector" "float-vectors" create
+"tuple" "kernel" lookup
 {
     {
         { "float-array" "float-arrays" }
@@ -429,6 +479,7 @@ builtins get num-tags get tail f union-class define-class
 } define-tuple-class
 
 "curry" "kernel" create
+"tuple" "kernel" lookup
 {
     {
         { "object" "kernel" }
@@ -443,7 +494,12 @@ builtins get num-tags get tail f union-class define-class
     }
 } define-tuple-class
 
+"curry" "kernel" lookup
+dup f "inline" set-word-prop
+dup tuple-layout [ <tuple-boa> ] curry define
+
 "compose" "kernel" create
+"tuple" "kernel" lookup
 {
     {
         { "object" "kernel" }
@@ -458,6 +514,10 @@ builtins get num-tags get tail f union-class define-class
     }
 } define-tuple-class
 
+"compose" "kernel" lookup
+dup f "inline" set-word-prop
+dup tuple-layout [ <tuple-boa> ] curry define
+
 ! Primitive words
 : make-primitive ( word vocab n -- )
     >r create dup reset-word r>
@@ -632,16 +692,15 @@ builtins get num-tags get tail f union-class define-class
     { "<wrapper>" "kernel" }
     { "(clone)" "kernel" }
     { "<string>" "strings" }
-    { "(>tuple)" "tuples.private" }
     { "array>quotation" "quotations.private" }
     { "quotation-xt" "quotations" }
-    { "<tuple>" "tuples.private" }
-    { "tuple>array" "tuples" }
+    { "<tuple>" "classes.tuple.private" }
+    { "<tuple-layout>" "classes.tuple.private" }
     { "profiling" "tools.profiler.private" }
     { "become" "kernel.private" }
     { "(sleep)" "threads.private" }
     { "<float-array>" "float-arrays" }
-    { "<tuple-boa>" "tuples.private" }
+    { "<tuple-boa>" "classes.tuple.private" }
     { "class-hash" "kernel.private" }
     { "callstack>array" "kernel" }
     { "innermost-frame-quot" "kernel.private" }
index 74b4d03cbb62a250f7bacf28e097edab76068afd..34f758c9df9150ff8eb6b87af99b59e08af5d780 100755 (executable)
@@ -39,7 +39,7 @@ vocabs.loader system debugger continuations ;
 
     [
         "resource:core/bootstrap/stage2.factor"
-        dup resource-exists? [
+        dup exists? [
             [ run-file ]
             [
                 :c
index f472e0158f245459c9416bf19ac262a0ba36070b..bbb2e44843164525f58aa8f1e18a1754cc3e3868 100755 (executable)
@@ -23,7 +23,7 @@ SYMBOL: bootstrap-time
 
 : load-components ( -- )
     "exclude" "include"
-    [ get-global " " split [ empty? not ] subset ] 2apply
+    [ get-global " " split [ empty? not ] subset ] bi@
     seq-diff
     [ "bootstrap." prepend require ] each ;
 
diff --git a/core/classes/algebra/algebra-docs.factor b/core/classes/algebra/algebra-docs.factor
new file mode 100755 (executable)
index 0000000..87c7204
--- /dev/null
@@ -0,0 +1,55 @@
+USING: help.markup help.syntax kernel classes ;\r
+IN: classes.algebra\r
+\r
+ARTICLE: "class-operations" "Class operations"\r
+"Set-theoretic operations on classes:"\r
+{ $subsection class< }\r
+{ $subsection class-and }\r
+{ $subsection class-or }\r
+{ $subsection classes-intersect? }\r
+"Topological sort:"\r
+{ $subsection sort-classes }\r
+{ $subsection min-class }\r
+"Low-level implementation detail:"\r
+{ $subsection class-types }\r
+{ $subsection flatten-class }\r
+{ $subsection flatten-builtin-class }\r
+{ $subsection class-types }\r
+{ $subsection class-tags } ;\r
+\r
+HELP: flatten-builtin-class\r
+{ $values { "class" class } { "assoc" "an assoc whose keys are classes" } }\r
+{ $description "Outputs a set of tuple classes whose union is the smallest cover of " { $snippet "class" } " intersected with " { $link tuple } "." } ;\r
+\r
+HELP: flatten-class\r
+{ $values { "class" class } { "assoc" "an assoc whose keys are classes" } }\r
+{ $description "Outputs a set of builtin and tuple classes whose union is the smallest cover of " { $snippet "class" } "." } ;\r
+\r
+HELP: class-types\r
+{ $values { "class" class } { "seq" "an increasing sequence of integers" } }\r
+{ $description "Outputs a sequence of builtin type numbers whose instances can possibly be instances of the given class." } ;\r
+\r
+HELP: class<\r
+{ $values { "first" "a class" } { "second" "a class" } { "?" "a boolean" } }\r
+{ $description "Tests if all instances of " { $snippet "class1" } " are also instances of " { $snippet "class2" } "." }\r
+{ $notes "Classes are partially ordered. This means that if " { $snippet "class1 <= class2" } " and " { $snippet "class2 <= class1" } ", then " { $snippet "class1 = class2" } ". Also, if " { $snippet "class1 <= class2" } " and " { $snippet "class2 <= class3" } ", then " { $snippet "class1 <= class3" } "." } ;\r
+\r
+HELP: sort-classes\r
+{ $values { "seq" "a sequence of class" } { "newseq" "a new seqence of classes" } }\r
+{ $description "Outputs a topological sort of a sequence of classes. Larger classes come before their subclasses." } ;\r
+\r
+HELP: class-or\r
+{ $values { "first" class } { "second" class } { "class" class } }\r
+{ $description "Outputs the smallest anonymous class containing both " { $snippet "class1" } " and " { $snippet "class2" } "." } ;\r
+\r
+HELP: class-and\r
+{ $values { "first" class } { "second" class } { "class" class } }\r
+{ $description "Outputs the largest anonymous class contained in both " { $snippet "class1" } " and " { $snippet "class2" } "." } ;\r
+\r
+HELP: classes-intersect?\r
+{ $values { "first" class } { "second" class } { "?" "a boolean" } }\r
+{ $description "Tests if two classes have a non-empty intersection. If the intersection is empty, no object can be an instance of both classes at once." } ;\r
+\r
+HELP: min-class\r
+{ $values { "class" class } { "seq" "a sequence of class words" } { "class/f" "a class word or " { $link f } } }\r
+{ $description "If all classes in " { $snippet "seq" } " that intersect " { $snippet "class" } " are subtypes of " { $snippet "class" } ", outputs the last such element of " { $snippet "seq" } ". If any conditions fail to hold, outputs " { $link f } "." } ;\r
diff --git a/core/classes/algebra/algebra-tests.factor b/core/classes/algebra/algebra-tests.factor
new file mode 100755 (executable)
index 0000000..cdf817e
--- /dev/null
@@ -0,0 +1,201 @@
+IN: classes.algebra.tests\r
+USING: alien arrays definitions generic assocs hashtables io\r
+kernel math namespaces parser prettyprint sequences strings\r
+tools.test vectors words quotations classes classes.algebra\r
+classes.private classes.union classes.mixin classes.predicate\r
+vectors definitions source-files compiler.units growable\r
+random inference effects ;\r
+\r
+: class= [ class< ] 2keep swap class< and ;\r
+\r
+: class-and* >r class-and r> class= ;\r
+\r
+: class-or* >r class-or r> class= ;\r
+\r
+[ t ] [ object  object  object class-and* ] unit-test\r
+[ t ] [ fixnum  object  fixnum class-and* ] unit-test\r
+[ t ] [ object  fixnum  fixnum class-and* ] unit-test\r
+[ t ] [ fixnum  fixnum  fixnum class-and* ] unit-test\r
+[ t ] [ fixnum  integer fixnum class-and* ] unit-test\r
+[ t ] [ integer fixnum  fixnum class-and* ] unit-test\r
+\r
+[ t ] [ vector    fixnum   null   class-and* ] unit-test\r
+[ t ] [ number    object   number class-and* ] unit-test\r
+[ t ] [ object    number   number class-and* ] unit-test\r
+[ t ] [ slice     reversed null   class-and* ] unit-test\r
+[ t ] [ general-t \ f      null   class-and* ] unit-test\r
+[ t ] [ general-t \ f      object class-or*  ] unit-test\r
+\r
+TUPLE: first-one ;\r
+TUPLE: second-one ;\r
+UNION: both first-one union-class ;\r
+\r
+[ t ] [ both tuple classes-intersect? ] unit-test\r
+[ t ] [ vector virtual-sequence null class-and* ] unit-test\r
+[ f ] [ vector virtual-sequence classes-intersect? ] unit-test\r
+\r
+[ t ] [ number vector class-or sequence classes-intersect? ] unit-test\r
+\r
+[ f ] [ number vector class-and sequence classes-intersect? ] unit-test\r
+\r
+[ t ] [ \ fixnum \ integer class< ] unit-test\r
+[ t ] [ \ fixnum \ fixnum class< ] unit-test\r
+[ f ] [ \ integer \ fixnum class< ] unit-test\r
+[ t ] [ \ integer \ object class< ] unit-test\r
+[ f ] [ \ integer \ null class< ] unit-test\r
+[ t ] [ \ null \ object class< ] unit-test\r
+\r
+[ t ] [ \ generic \ word class< ] unit-test\r
+[ f ] [ \ word \ generic class< ] unit-test\r
+\r
+[ f ] [ \ reversed \ slice class< ] unit-test\r
+[ f ] [ \ slice \ reversed class< ] unit-test\r
+\r
+PREDICATE: no-docs < word "documentation" word-prop not ;\r
+\r
+UNION: no-docs-union no-docs integer ;\r
+\r
+[ t ] [ no-docs no-docs-union class< ] unit-test\r
+[ f ] [ no-docs-union no-docs class< ] unit-test\r
+\r
+TUPLE: a ;\r
+TUPLE: b ;\r
+UNION: c a b ;\r
+\r
+[ t ] [ \ c \ tuple class< ] unit-test\r
+[ f ] [ \ tuple \ c class< ] unit-test\r
+\r
+[ t ] [ \ tuple-class \ class class< ] unit-test\r
+[ f ] [ \ class \ tuple-class class< ] unit-test\r
+\r
+TUPLE: delegate-clone ;\r
+\r
+[ t ] [ \ null \ delegate-clone class< ] unit-test\r
+[ f ] [ \ object \ delegate-clone class< ] unit-test\r
+[ f ] [ \ object \ delegate-clone class< ] unit-test\r
+[ t ] [ \ delegate-clone \ tuple class< ] unit-test\r
+[ f ] [ \ tuple \ delegate-clone class< ] unit-test\r
+\r
+TUPLE: a1 ;\r
+TUPLE: b1 ;\r
+TUPLE: c1 ;\r
+\r
+UNION: x1 a1 b1 ;\r
+UNION: y1 a1 c1 ;\r
+UNION: z1 b1 c1 ;\r
+\r
+[ f ] [ z1 x1 y1 class-and class< ] unit-test\r
+\r
+[ t ] [ x1 y1 class-and a1 class< ] unit-test\r
+\r
+[ f ] [ y1 z1 class-and x1 classes-intersect? ] unit-test\r
+\r
+[ f ] [ b1 c1 class-or a1 b1 class-or a1 c1 class-and class-and class< ] unit-test\r
+\r
+[ t ] [ a1 b1 class-or a1 c1 class-or class-and a1 class< ] unit-test\r
+\r
+[ f ] [ a1 c1 class-or b1 c1 class-or class-and a1 b1 class-or classes-intersect? ] unit-test\r
+\r
+[ f ] [ growable hi-tag classes-intersect? ] unit-test\r
+\r
+[ t ] [\r
+    growable tuple sequence class-and class<\r
+] unit-test\r
+\r
+[ t ] [\r
+    growable assoc class-and tuple class<\r
+] unit-test\r
+\r
+[ t ] [ object \ f \ f class-not class-or class< ] unit-test\r
+\r
+[ t ] [ fixnum class-not integer class-and bignum class= ] unit-test\r
+\r
+[ f ] [ integer integer class-not classes-intersect? ] unit-test\r
+\r
+[ t ] [ array number class-not class< ] unit-test\r
+\r
+[ f ] [ bignum number class-not class< ] unit-test\r
+\r
+[ vector ] [ vector class-not class-not ] unit-test\r
+\r
+[ t ] [ fixnum fixnum bignum class-or class< ] unit-test\r
+\r
+[ f ] [ fixnum class-not integer class-and array class< ] unit-test\r
+\r
+[ f ] [ fixnum class-not integer class< ] unit-test\r
+\r
+[ f ] [ number class-not array class< ] unit-test\r
+\r
+[ f ] [ fixnum class-not array class< ] unit-test\r
+\r
+[ t ] [ number class-not integer class-not class< ] unit-test\r
+\r
+[ t ] [ vector array class-not class-and vector class= ] unit-test\r
+\r
+[ f ] [ fixnum class-not number class-and array classes-intersect? ] unit-test\r
+\r
+[ f ] [ fixnum class-not integer class< ] unit-test\r
+\r
+[ t ] [ null class-not object class= ] unit-test\r
+\r
+[ t ] [ object class-not null class= ] unit-test\r
+\r
+[ f ] [ object class-not object class= ] unit-test\r
+\r
+[ f ] [ null class-not null class= ] unit-test\r
+\r
+! Test for hangs?\r
+: random-class classes random ;\r
+\r
+: random-op\r
+    {\r
+        class-and\r
+        class-or\r
+        class-not\r
+    } random ;\r
+\r
+10 [\r
+    [ ] [\r
+        20 [ drop random-op ] map >quotation\r
+        [ infer effect-in [ random-class ] times ] keep\r
+        call\r
+        drop\r
+    ] unit-test\r
+] times\r
+\r
+: random-boolean\r
+    { t f } random ;\r
+\r
+: boolean>class\r
+    object null ? ;\r
+\r
+: random-boolean-op\r
+    {\r
+        and\r
+        or\r
+        not\r
+        xor\r
+    } random ;\r
+\r
+: class-xor [ class-or ] 2keep class-and class-not class-and ;\r
+\r
+: boolean-op>class-op\r
+    {\r
+        { and class-and }\r
+        { or class-or }\r
+        { not class-not }\r
+        { xor class-xor }\r
+    } at ;\r
+\r
+20 [\r
+    [ t ] [\r
+        20 [ drop random-boolean-op ] [ ] map-as dup .\r
+        [ infer effect-in [ drop random-boolean ] map dup . ] keep\r
+        \r
+        [ >r [ ] each r> call ] 2keep\r
+        \r
+        >r [ boolean>class ] each r> [ boolean-op>class-op ] map call object class=\r
+        \r
+        =\r
+    ] unit-test\r
+] times\r
diff --git a/core/classes/algebra/algebra.factor b/core/classes/algebra/algebra.factor
new file mode 100755 (executable)
index 0000000..2945bd2
--- /dev/null
@@ -0,0 +1,233 @@
+! Copyright (C) 2004, 2008 Slava Pestov.\r
+! See http://factorcode.org/license.txt for BSD license.\r
+USING: kernel classes combinators accessors sequences arrays\r
+vectors assocs namespaces words sorting layouts math hashtables\r
+;\r
+IN: classes.algebra\r
+\r
+: 2cache ( key1 key2 assoc quot -- value )\r
+    >r >r 2array r> [ first2 ] r> compose cache ; inline\r
+\r
+DEFER: (class<)\r
+\r
+: class< ( first second -- ? )\r
+    class<-cache get [ (class<) ] 2cache ;\r
+\r
+DEFER: (class-not)\r
+\r
+: class-not ( class -- complement )\r
+    class-not-cache get [ (class-not) ] cache ;\r
+\r
+DEFER: (classes-intersect?) ( first second -- ? )\r
+\r
+: classes-intersect? ( first second -- ? )\r
+    classes-intersect-cache get [ (classes-intersect?) ] 2cache ;\r
+\r
+DEFER: (class-and)\r
+\r
+: class-and ( first second -- class )\r
+    class-and-cache get [ (class-and) ] 2cache ;\r
+\r
+DEFER: (class-or)\r
+\r
+: class-or ( first second -- class )\r
+    class-or-cache get [ (class-or) ] 2cache ;\r
+\r
+TUPLE: anonymous-union members ;\r
+\r
+C: <anonymous-union> anonymous-union\r
+\r
+TUPLE: anonymous-intersection members ;\r
+\r
+C: <anonymous-intersection> anonymous-intersection\r
+\r
+TUPLE: anonymous-complement class ;\r
+\r
+C: <anonymous-complement> anonymous-complement\r
+\r
+: superclass< ( first second -- ? )\r
+    >r superclass r> class< ;\r
+\r
+: left-union-class< ( first second -- ? )\r
+    >r members r> [ class< ] curry all? ;\r
+\r
+: right-union-class< ( first second -- ? )\r
+    members [ class< ] with contains? ;\r
+\r
+: left-anonymous-union< ( first second -- ? )\r
+    >r members>> r> [ class< ] curry all? ;\r
+\r
+: right-anonymous-union< ( first second -- ? )\r
+    members>> [ class< ] with contains? ;\r
+\r
+: left-anonymous-intersection< ( first second -- ? )\r
+    >r members>> r> [ class< ] curry contains? ;\r
+\r
+: right-anonymous-intersection< ( first second -- ? )\r
+    members>> [ class< ] with all? ;\r
+\r
+: anonymous-complement< ( first second -- ? )\r
+    [ class>> ] bi@ swap class< ;\r
+\r
+: (class<) ( first second -- -1/0/1 )  \r
+    {\r
+        { [ 2dup eq? ] [ 2drop t ] }\r
+        { [ dup object eq? ] [ 2drop t ] }\r
+        { [ over null eq? ] [ 2drop t ] }\r
+        { [ 2dup [ anonymous-complement? ] both? ] [ anonymous-complement< ] }\r
+        { [ over anonymous-union? ] [ left-anonymous-union< ] }\r
+        { [ over anonymous-intersection? ] [ left-anonymous-intersection< ] }\r
+        { [ over anonymous-complement? ] [ 2drop f ] }\r
+        { [ over members ] [ left-union-class< ] }\r
+        { [ dup anonymous-union? ] [ right-anonymous-union< ] }\r
+        { [ dup anonymous-intersection? ] [ right-anonymous-intersection< ] }\r
+        { [ dup anonymous-complement? ] [ class>> classes-intersect? not ] }\r
+        { [ dup members ] [ right-union-class< ] }\r
+        { [ over superclass ] [ superclass< ] }\r
+        { [ t ] [ 2drop f ] }\r
+    } cond ;\r
+\r
+: anonymous-union-intersect? ( first second -- ? )\r
+    members>> [ classes-intersect? ] with contains? ;\r
+\r
+: anonymous-intersection-intersect? ( first second -- ? )\r
+    members>> [ classes-intersect? ] with all? ;\r
+\r
+: anonymous-complement-intersect? ( first second -- ? )\r
+    class>> class< not ;\r
+\r
+: union-class-intersect? ( first second -- ? )\r
+    members [ classes-intersect? ] with contains? ;\r
+\r
+: tuple-class-intersect? ( first second -- ? )\r
+    {\r
+        { [ over tuple eq? ] [ 2drop t ] }\r
+        { [ over builtin-class? ] [ 2drop f ] }\r
+        { [ over tuple-class? ] [ [ class< ] 2keep swap class< or ] }\r
+        { [ t ] [ swap classes-intersect? ] }\r
+    } cond ;\r
+\r
+: builtin-class-intersect? ( first second -- ? )\r
+    {\r
+        { [ 2dup eq? ] [ 2drop t ] }\r
+        { [ over builtin-class? ] [ 2drop f ] }\r
+        { [ t ] [ swap classes-intersect? ] }\r
+    } cond ;\r
+\r
+: (classes-intersect?) ( first second -- ? )\r
+    {\r
+        { [ dup anonymous-union? ] [ anonymous-union-intersect? ] }\r
+        { [ dup anonymous-intersection? ] [ anonymous-intersection-intersect? ] }\r
+        { [ dup anonymous-complement? ] [ anonymous-complement-intersect? ] }\r
+        { [ dup tuple-class? ] [ tuple-class-intersect? ] }\r
+        { [ dup builtin-class? ] [ builtin-class-intersect? ] }\r
+        { [ dup superclass ] [ superclass classes-intersect? ] }\r
+        { [ dup members ] [ union-class-intersect? ] }\r
+    } cond ;\r
+\r
+: left-union-and ( first second -- class )\r
+    >r members r> [ class-and ] curry map <anonymous-union> ;\r
+\r
+: right-union-and ( first second -- class )\r
+    members [ class-and ] with map <anonymous-union> ;\r
+\r
+: left-anonymous-union-and ( first second -- class )\r
+    >r members>> r> [ class-and ] curry map <anonymous-union> ;\r
+\r
+: right-anonymous-union-and ( first second -- class )\r
+    members>> [ class-and ] with map <anonymous-union> ;\r
+\r
+: left-anonymous-intersection-and ( first second -- class )\r
+    >r members>> r> add <anonymous-intersection> ;\r
+\r
+: right-anonymous-intersection-and ( first second -- class )\r
+    members>> swap add <anonymous-intersection> ;\r
+\r
+: (class-and) ( first second -- class )\r
+    {\r
+        { [ 2dup class< ] [ drop ] }\r
+        { [ 2dup swap class< ] [ nip ] }\r
+        { [ 2dup classes-intersect? not ] [ 2drop null ] }\r
+        { [ dup members ] [ right-union-and ] }\r
+        { [ dup anonymous-union? ] [ right-anonymous-union-and ] }\r
+        { [ dup anonymous-intersection? ] [ right-anonymous-intersection-and ] }\r
+        { [ over members ] [ left-union-and ] }\r
+        { [ over anonymous-union? ] [ left-anonymous-union-and ] }\r
+        { [ over anonymous-intersection? ] [ left-anonymous-intersection-and ] }\r
+        { [ t ] [ 2array <anonymous-intersection> ] }\r
+    } cond ;\r
+\r
+: left-anonymous-union-or ( first second -- class )\r
+    >r members>> r> add <anonymous-union> ;\r
+\r
+: right-anonymous-union-or ( first second -- class )\r
+    members>> swap add <anonymous-union> ;\r
+\r
+: (class-or) ( first second -- class )\r
+    {\r
+        { [ 2dup class< ] [ nip ] }\r
+        { [ 2dup swap class< ] [ drop ] }\r
+        { [ dup anonymous-union? ] [ right-anonymous-union-or ] }\r
+        { [ over anonymous-union? ] [ left-anonymous-union-or ] }\r
+        { [ t ] [ 2array <anonymous-union> ] }\r
+    } cond ;\r
+\r
+: (class-not) ( class -- complement )\r
+    {\r
+        { [ dup anonymous-complement? ] [ class>> ] }\r
+        { [ dup object eq? ] [ drop null ] }\r
+        { [ dup null eq? ] [ drop object ] }\r
+        { [ t ] [ <anonymous-complement> ] }\r
+    } cond ;\r
+\r
+: largest-class ( seq -- n elt )\r
+    dup [\r
+        [ 2dup class< >r swap class< not r> and ]\r
+        with subset empty?\r
+    ] curry find [ "Topological sort failed" throw ] unless* ;\r
+\r
+: sort-classes ( seq -- newseq )\r
+    >vector\r
+    [ dup empty? not ]\r
+    [ dup largest-class >r over delete-nth r> ]\r
+    [ ] unfold nip ;\r
+\r
+: min-class ( class seq -- class/f )\r
+    [ dupd classes-intersect? ] subset dup empty? [\r
+        2drop f\r
+    ] [\r
+        tuck [ class< ] with all? [ peek ] [ drop f ] if\r
+    ] if ;\r
+\r
+: (flatten-class) ( class -- )\r
+    {\r
+        { [ dup tuple-class? ] [ dup set ] }\r
+        { [ dup builtin-class? ] [ dup set ] }\r
+        { [ dup members ] [ members [ (flatten-class) ] each ] }\r
+        { [ dup superclass ] [ superclass (flatten-class) ] }\r
+        { [ t ] [ drop ] }\r
+    } cond ;\r
+\r
+: flatten-class ( class -- assoc )\r
+    [ (flatten-class) ] H{ } make-assoc ;\r
+\r
+: class-hashes ( class -- seq )\r
+    flatten-class keys [\r
+        dup builtin-class?\r
+        [ "type" word-prop ] [ hashcode ] if\r
+    ] map ;\r
+\r
+: flatten-builtin-class ( class -- assoc )\r
+    flatten-class [\r
+        dup tuple class< [ 2drop tuple tuple ] when\r
+    ] assoc-map ;\r
+\r
+: class-types ( class -- seq )\r
+    flatten-builtin-class keys\r
+    [ "type" word-prop ] map natural-sort ;\r
+\r
+: class-tags ( class -- tag/f )\r
+    class-types [\r
+        dup num-tags get >=\r
+        [ drop object tag-number ] when\r
+    ] map prune ;\r
index 1e711731537fe630ba760b7f76cd707cbbdecb74..9573de89498124dbc9ee1297e31e86c53bfe6be8 100755 (executable)
@@ -12,21 +12,6 @@ $nl
 { $subsection builtin-class? }
 "See " { $link "type-index" } " for a list of built-in classes." ;
 
-ARTICLE: "class-operations" "Class operations"
-"Set-theoretic operations on classes:"
-{ $subsection class< }
-{ $subsection class-and }
-{ $subsection class-or }
-{ $subsection classes-intersect? }
-"Topological sort:"
-{ $subsection sort-classes }
-{ $subsection min-class }
-"Low-level implementation detail:"
-{ $subsection types }
-{ $subsection flatten-class }
-{ $subsection flatten-builtin-class }
-{ $subsection flatten-union-class } ;
-
 ARTICLE: "class-predicates" "Class predicate words"
 "With a handful of exceptions, each class has a membership predicate word, named " { $snippet { $emphasis "class" } "?" } " . A quotation calling this predicate is stored in the " { $snippet "\"predicate\"" } " word property."
 $nl
@@ -93,15 +78,9 @@ HELP: tuple-class
 { $class-description "The class of tuple class words." }
 { $examples { $example "USING: classes prettyprint ;" "TUPLE: name title first last ;" "name tuple-class? ." "t" } } ;
 
-HELP: typemap
-{ $var-description "Hashtable mapping unions to class words, used to implement " { $link class-and } " and " { $link class-or } "." } ;
-
 HELP: builtins
 { $var-description "Vector mapping type numbers to builtin class words." } ;
 
-HELP: class<map
-{ $var-description "Hashtable mapping each class to a set of classes which are contained in that class under the " { $link (class<) } " relation. The " { $link class< } " word uses this hashtable to avoid frequent expensive calls to " { $link (class<) } "." } ;
-
 HELP: update-map
 { $var-description "Hashtable mapping each class to a set of classes defined in terms of this class. The " { $link define-class } " word uses this information to update generic words when classes are redefined." } ;
 
@@ -121,70 +100,13 @@ $low-level-note ;
 
 HELP: superclass
 { $values { "class" class } { "super" class } }
-{ $description "Outputs the superclass of a class. All instances of this class are also instances of the superclass." }
-{ $notes "If " { $link class< } " yields that one class is a subtype of another, it does not imply that a superclass relation is involved. The superclass relation is a technical implementation detail of predicate and tuple classes." } ;
+{ $description "Outputs the superclass of a class. All instances of this class are also instances of the superclass." } ;
 
 HELP: members
 { $values { "class" class } { "seq" "a sequence of union members, or " { $link f } } }
 { $description "If " { $snippet "class" } " is a union class, outputs a sequence of its member classes, otherwise outputs " { $link f } "." } ;
 
-HELP: flatten-union-class
-{ $values { "class" class } { "assoc" "an assoc whose keys are classes" } }
-{ $description "Outputs the set of classes whose union is equal to " { $snippet "class" } ". Unions are expanded recursively so the output assoc does not contain any union classes. However, it may contain predicate classes whose superclasses are unions." } ;
-
-HELP: flatten-builtin-class
-{ $values { "class" class } { "assoc" "an assoc whose keys are classes" } }
-{ $description "Outputs a set of tuple classes whose union is the smallest cover of " { $snippet "class" } " intersected with " { $link tuple } "." } ;
-
-HELP: flatten-class
-{ $values { "class" class } { "assoc" "an assoc whose keys are classes" } }
-{ $description "Outputs a set of builtin and tuple classes whose union is the smallest cover of " { $snippet "class" } "." } ;
-
-HELP: types
-{ $values { "class" class } { "seq" "an increasing sequence of integers" } }
-{ $description "Outputs a sequence of builtin type numbers whose instances can possibly be instances of the given class." } ;
-
-HELP: class-empty?
-{ $values { "class" "a class" } { "?" "a boolean" } }
-{ $description "Tests if a class is a union class with no members." }
-{ $examples { $example "USING: classes kernel prettyprint ;" "null class-empty? ." "t" } } ;
-
-HELP: (class<)
-{ $values { "class1" "a class" } { "class2" "a class" } { "?" "a boolean" } }
-{ $description "Performs the calculation for " { $link class< } ". There is never any reason to call this word from user code since " { $link class< } " outputs identical values and caches results for better performance." } ;
-
-HELP: class<
-{ $values { "class1" "a class" } { "class2" "a class" } { "?" "a boolean" } }
-{ $description "Tests if all instances of " { $snippet "class1" } " are also instances of " { $snippet "class2" } "." }
-{ $notes "Classes are partially ordered. This means that if " { $snippet "class1 <= class2" } " and " { $snippet "class2 <= class1" } ", then " { $snippet "class1 = class2" } ". Also, if " { $snippet "class1 <= class2" } " and " { $snippet "class2 <= class3" } ", then " { $snippet "class1 <= class3" } "." } ;
-
-HELP: sort-classes
-{ $values { "seq" "a sequence of class" } { "newseq" "a new seqence of classes" } }
-{ $description "Outputs a topological sort of a sequence of classes. Larger classes come before their subclasses." } ;
-
-HELP: lookup-union
-{ $values { "classes" "a hashtable mapping class words to themselves" } { "class" class } }
-{ $description "Given a set of classes represented as a hashtable with equal keys and values, looks up a previously-defined union class having those members. If no union is defined, outputs " { $link object } "." } ;
-
-{ class-and class-or lookup-union } related-words
-
-HELP: class-or
-{ $values { "class1" class } { "class2" class } { "class" class } }
-{ $description "Outputs the smallest known class containing both " { $snippet "class1" } " and " { $snippet "class2" } "." } ;
-
-HELP: class-and
-{ $values { "class1" class } { "class2" class } { "class" class } }
-{ $description "Outputs the largest known class contained in both " { $snippet "class1" } " and " { $snippet "class2" } ". If the intersection is non-empty but no union class with those exact members is defined, outputs " { $link object } ". If the intersection is empty, outputs " { $link null } "." } ;
-
-HELP: classes-intersect?
-{ $values { "class1" class } { "class2" class } { "?" "a boolean" } }
-{ $description "Tests if two classes have a non-empty intersection. If the intersection is empty, no object can be an instance of both classes at once." } ;
-
-HELP: min-class
-{ $values { "class" class } { "seq" "a sequence of class words" } { "class/f" "a class word or " { $link f } } }
-{ $description "If all classes in " { $snippet "seq" } " that intersect " { $snippet "class" } " are subtypes of " { $snippet "class" } ", outputs the last such element of " { $snippet "seq" } ". If any conditions fail to hold, outputs " { $link f } "." } ;
-
 HELP: define-class
 { $values { "word" word } { "members" "a sequence of class words" } { "superclass" class } { "metaclass" class } }
-{ $description "Sets a property indicating this word is a class word, thus making it an instance of " { $link class } ", and registers it with " { $link typemap } " and " { $link class<map } "." }
+{ $description "Sets a property indicating this word is a class word, thus making it an instance of " { $link class } ", and registers it with " { $link update-map } "." }
 $low-level-note ;
index 3322c3b043ad8e9a0e0324e02356878c52f8a145..ae9e6ec154a6ad6f734e848675fb8858b7b3e798 100755 (executable)
@@ -2,64 +2,10 @@ USING: alien arrays definitions generic assocs hashtables io
 kernel math namespaces parser prettyprint sequences strings
 tools.test vectors words quotations classes
 classes.private classes.union classes.mixin classes.predicate
-vectors definitions source-files compiler.units ;
+classes.algebra vectors definitions source-files
+compiler.units ;
 IN: classes.tests
 
-H{ } "s" set
-
-[ ] [ 1 2 "s" get push-at ] unit-test
-[ 1 ] [ 2 "s" get at first ] unit-test
-[ ] [ 1 2 "s" get pop-at ] unit-test
-[ t ] [ 2 "s" get at empty? ] unit-test
-
-[ object ] [ object object class-and ] unit-test
-[ fixnum ] [ fixnum object class-and ] unit-test
-[ fixnum ] [ object fixnum class-and ] unit-test
-[ fixnum ] [ fixnum fixnum class-and ] unit-test
-[ fixnum ] [ fixnum integer class-and ] unit-test
-[ fixnum ] [ integer fixnum class-and ] unit-test
-[ null ] [ vector fixnum class-and ] unit-test
-[ number ] [ number object class-and ] unit-test
-[ number ] [ object number class-and ] unit-test
-[ null ] [ slice reversed class-and ] unit-test
-[ null ] [ general-t \ f class-and ] unit-test
-[ object ] [ general-t \ f class-or ] unit-test
-
-TUPLE: first-one ;
-TUPLE: second-one ;
-UNION: both first-one union-class ;
-
-[ t ] [ both tuple classes-intersect? ] unit-test
-[ null ] [ vector virtual-sequence class-and ] unit-test
-[ f ] [ vector virtual-sequence classes-intersect? ] unit-test
-
-[ t ] [ \ fixnum \ integer class< ] unit-test
-[ t ] [ \ fixnum \ fixnum class< ] unit-test
-[ f ] [ \ integer \ fixnum class< ] unit-test
-[ t ] [ \ integer \ object class< ] unit-test
-[ f ] [ \ integer \ null class< ] unit-test
-[ t ] [ \ null \ object class< ] unit-test
-
-[ t ] [ \ generic \ word class< ] unit-test
-[ f ] [ \ word \ generic class< ] unit-test
-
-[ f ] [ \ reversed \ slice class< ] unit-test
-[ f ] [ \ slice \ reversed class< ] unit-test
-
-PREDICATE: word no-docs "documentation" word-prop not ;
-
-UNION: no-docs-union no-docs integer ;
-
-[ t ] [ no-docs no-docs-union class< ] unit-test
-[ f ] [ no-docs-union no-docs class< ] unit-test
-
-TUPLE: a ;
-TUPLE: b ;
-UNION: c a b ;
-
-[ t ] [ \ c \ tuple class< ] unit-test
-[ f ] [ \ tuple \ c class< ] unit-test
-
 ! DEFER: bah
 ! FORGET: bah
 UNION: bah fixnum alien ;
@@ -76,17 +22,13 @@ M: union-1 generic-update-test drop "union-1" ;
 [ t ] [ union-1 number class< ] unit-test
 [ "union-1" ] [ 1.0 generic-update-test ] unit-test
 
-[ union-1 ] [ fixnum float class-or ] unit-test
-
 "IN: classes.tests USE: math USE: arrays UNION: union-1 rational array ;" eval
 
 [ t ] [ bignum union-1 class< ] unit-test
 [ f ] [ union-1 number class< ] unit-test
 [ "union-1" ] [ { 1.0 } generic-update-test ] unit-test
 
-[ object ] [ fixnum float class-or ] unit-test
-
-"IN: classes.tests USE: math PREDICATE: integer union-1 even? ;" eval
+"IN: classes.tests USE: math PREDICATE: union-1 < integer even? ;" eval
 
 [ f ] [ union-1 union-class? ] unit-test
 [ t ] [ union-1 predicate-class? ] unit-test
@@ -118,6 +60,9 @@ M: assoc-mixin collection-size assoc-size ;
 [ 2 ] [ H{ { 1 2 } { 2 3 } } collection-size ] unit-test
 
 ! Test mixing in of new classes after the fact
+DEFER: mx1
+FORGET: mx1
+
 MIXIN: mx1
 
 INSTANCE: integer mx1
@@ -131,12 +76,8 @@ INSTANCE: integer mx1
 [ t ] [ array mx1 class< ] unit-test
 [ f ] [ mx1 number class< ] unit-test
 
-[ mx1 ] [ array integer class-or ] unit-test
-
 [ \ mx1 forget ] with-compilation-unit
 
-[ f ] [ array integer class-or mx1 = ] unit-test
-
 ! Empty unions were causing problems
 GENERIC: empty-union-test
 
@@ -155,28 +96,12 @@ UNION: redefine-bug-2 redefine-bug-1 quotation ;
 
 [ t ] [ fixnum redefine-bug-2 class< ] unit-test
 [ t ] [ quotation redefine-bug-2 class< ] unit-test
-[ redefine-bug-2 ] [ fixnum quotation class-or ] unit-test
 
 [ ] [ "IN: classes.tests USE: math UNION: redefine-bug-1 bignum ;" eval ] unit-test
 
 [ t ] [ bignum redefine-bug-1 class< ] unit-test
 [ f ] [ fixnum redefine-bug-2 class< ] unit-test
 [ t ] [ bignum redefine-bug-2 class< ] unit-test
-[ f ] [ fixnum quotation class-or redefine-bug-2 eq? ] unit-test
-[ redefine-bug-2 ] [ bignum quotation class-or ] unit-test
-
-! Another issue similar to the above
-UNION: forget-class-bug-1 integer ;
-UNION: forget-class-bug-2 forget-class-bug-1 dll ;
-
-[
-    \ forget-class-bug-1 forget
-    \ forget-class-bug-2 forget
-] with-compilation-unit
-
-[ f ] [ forget-class-bug-1 typemap get values [ memq? ] with contains? ] unit-test
-
-[ f ] [ forget-class-bug-2 typemap get values [ memq? ] with contains? ] unit-test
 
 USE: io.streams.string
 
index e47dbd20e57721341e816c2658420caed2d0493d..435c7413a35e6971101baacabc32a35283cf876b 100755 (executable)
@@ -1,25 +1,42 @@
 ! Copyright (C) 2004, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
+USING: arrays definitions assocs kernel kernel.private
+slots.private namespaces sequences strings words vectors math
+quotations combinators sorting effects graphs vocabs ;
 IN: classes
-USING: arrays definitions assocs kernel
-kernel.private slots.private namespaces sequences strings words
-vectors math quotations combinators sorting effects graphs ;
 
-PREDICATE: word class ( obj -- ? ) "class" word-prop ;
+SYMBOL: class<-cache
+SYMBOL: class-not-cache
+SYMBOL: classes-intersect-cache
+SYMBOL: class-and-cache
+SYMBOL: class-or-cache
+
+: init-caches ( -- )
+    H{ } clone class<-cache set
+    H{ } clone class-not-cache set
+    H{ } clone classes-intersect-cache set
+    H{ } clone class-and-cache set
+    H{ } clone class-or-cache set ;
+
+: reset-caches ( -- )
+    class<-cache get clear-assoc
+    class-not-cache get clear-assoc
+    classes-intersect-cache get clear-assoc
+    class-and-cache get clear-assoc
+    class-or-cache get clear-assoc ;
+
+PREDICATE: class < word ( obj -- ? ) "class" word-prop ;
 
-SYMBOL: typemap
-SYMBOL: class-map
-SYMBOL: class<map
 SYMBOL: update-map
 SYMBOL: builtins
 
-PREDICATE: class builtin-class
+PREDICATE: builtin-class < class
     "metaclass" word-prop builtin-class eq? ;
 
-PREDICATE: class tuple-class
+PREDICATE: tuple-class < class
     "metaclass" word-prop tuple-class eq? ;
 
-: classes ( -- seq ) class<map get keys ;
+: classes ( -- seq ) all-words [ class? ] subset ;
 
 : type>class ( n -- class ) builtins get-global nth ;
 
@@ -30,153 +47,22 @@ PREDICATE: class tuple-class
 
 : predicate-effect 1 { "?" } <effect> ;
 
-PREDICATE: word predicate "predicating" word-prop >boolean ;
+PREDICATE: predicate < word "predicating" word-prop >boolean ;
 
 : define-predicate ( class quot -- )
     >r "predicate" word-prop first
     r> predicate-effect define-declared ;
 
 : superclass ( class -- super )
-    "superclass" word-prop ;
-
-: members ( class -- seq ) "members" word-prop ;
-
-: class-empty? ( class -- ? ) members dup [ empty? ] when ;
-
-: (flatten-union-class) ( class -- )
-    dup members [
-        [ (flatten-union-class) ] each
-    ] [
-        dup set
-    ] ?if ;
-
-: flatten-union-class ( class -- assoc )
-    [ (flatten-union-class) ] H{ } make-assoc ;
-
-: (flatten-class) ( class -- )
-    {
-        { [ dup tuple-class? ] [ dup set ] }
-        { [ dup builtin-class? ] [ dup set ] }
-        { [ dup members ] [ members [ (flatten-class) ] each ] }
-        { [ dup superclass ] [ superclass (flatten-class) ] }
-        { [ t ] [ drop ] }
-    } cond ;
-
-: flatten-class ( class -- assoc )
-    [ (flatten-class) ] H{ } make-assoc ;
-
-: class-hashes ( class -- seq )
-    flatten-class keys [
-        dup builtin-class?
-        [ "type" word-prop ] [ hashcode ] if
-    ] map ;
-
-: (flatten-builtin-class) ( class -- )
-    {
-        { [ dup members ] [ members [ (flatten-builtin-class) ] each ] }
-        { [ dup superclass ] [ superclass (flatten-builtin-class) ] }
-        { [ t ] [ dup set ] }
-    } cond ;
-
-: flatten-builtin-class ( class -- assoc )
-    [ (flatten-builtin-class) ] H{ } make-assoc ;
+    #! Output f for non-classes to work with algebra code
+    dup class? [ "superclass" word-prop ] [ drop f ] if ;
 
-: types ( class -- seq )
-    flatten-builtin-class keys
-    [ "type" word-prop ] map natural-sort ;
+: superclasses ( class -- supers )
+    [ dup ] [ dup superclass swap ] [ ] unfold reverse nip ;
 
-: class< ( class1 class2 -- ? ) swap class<map get at key? ;
-
-<PRIVATE
-
-DEFER: (class<)
-
-: superclass< ( cls1 cls2 -- ? )
-    >r superclass r> 2dup and [ (class<) ] [ 2drop f ] if ;
-
-: union-class< ( cls1 cls2 -- ? )
-    [ flatten-union-class ] 2apply keys
-    [ nip [ (class<) ] with contains? ] curry assoc-all? ;
-
-: (class<) ( class1 class2 -- ? )
-    {
-        { [ 2dup eq? ] [ 2drop t ] }
-        { [ over class-empty? ] [ 2drop t ] }
-        { [ 2dup superclass< ] [ 2drop t ] }
-        { [ 2dup [ members not ] both? ] [ 2drop f ] }
-        { [ t ] [ union-class< ] }
-    } cond ;
-
-: lookup-union ( classes -- class )
-    typemap get at dup empty? [ drop object ] [ first ] if ;
-
-: lookup-tuple-union ( classes -- class )
-    class-map get at dup empty? [ drop object ] [ first ] if ;
-
-! : (class-or) ( class class -- class )
-!     [ flatten-builtin-class ] 2apply union lookup-union ;
-! 
-! : (class-and) ( class class -- class )
-!     [ flatten-builtin-class ] 2apply intersect lookup-union ;
-
-: class-or-fixup ( set set -- set )
-    union
-    tuple over key?
-    [ [ drop tuple-class? not ] assoc-subset ] when ;
-
-: (class-or) ( class class -- class )
-    [ flatten-class ] 2apply class-or-fixup lookup-tuple-union ;
-
-: (class-and) ( class class -- class )
-    2dup [ tuple swap class< ] either? [
-        [ flatten-builtin-class ] 2apply
-        intersect lookup-union
-    ] [
-        [ flatten-class ] 2apply
-        intersect lookup-tuple-union
-    ] if ;
-
-: tuple-class-and ( class1 class2 -- class )
-    dupd eq? [ drop null ] unless ;
-
-: largest-class ( seq -- n elt )
-    dup [
-        [ 2dup class< >r swap class< not r> and ]
-        with subset empty?
-    ] curry find [ "Topological sort failed" throw ] unless* ;
-
-PRIVATE>
-
-: sort-classes ( seq -- newseq )
-    >vector
-    [ dup empty? not ]
-    [ dup largest-class >r over delete-nth r> ]
-    [ ] unfold nip ;
-
-: class-or ( class1 class2 -- class )
-    {
-        { [ 2dup class< ] [ nip ] }
-        { [ 2dup swap class< ] [ drop ] }
-        { [ t ] [ (class-or) ] }
-    } cond ;
-
-: class-and ( class1 class2 -- class )
-    {
-        { [ 2dup class< ] [ drop ] }
-        { [ 2dup swap class< ] [ nip ] }
-        { [ 2dup [ tuple-class? ] both? ] [ tuple-class-and ] }
-        { [ t ] [ (class-and) ] }
-    } cond ;
-
-: classes-intersect? ( class1 class2 -- ? )
-    class-and class-empty? not ;
-
-: min-class ( class seq -- class/f )
-    [ dupd classes-intersect? ] subset dup empty? [
-        2drop f
-    ] [
-        tuck [ class< ] with all? [ peek ] [ drop f ] if
-    ] if ;
+: members ( class -- seq )
+    #! Output f for non-classes to work with algebra code
+    dup class? [ "members" word-prop ] [ drop f ] if ;
 
 GENERIC: reset-class ( class -- )
 
@@ -184,36 +70,9 @@ M: word reset-class drop ;
 
 <PRIVATE
 
-! class<map
-: bigger-classes ( class -- seq )
-    classes [ (class<) ] with subset ;
-
-: bigger-classes+ ( class -- )
-    [ bigger-classes [ dup ] H{ } map>assoc ] keep
-    class<map get set-at ;
-
-: bigger-classes- ( class -- )
-    class<map get delete-at ;
-
-: smaller-classes ( class -- seq )
-    classes swap [ (class<) ] curry subset ;
-
-: smaller-classes+ ( class -- )
-    dup smaller-classes class<map get add-vertex ;
-
-: smaller-classes- ( class -- )
-    dup smaller-classes class<map get remove-vertex ;
-
-: class<map+ ( class -- )
-    H{ } clone over class<map get set-at
-    dup smaller-classes+ bigger-classes+ ;
-
-: class<map- ( class -- )
-    dup smaller-classes- bigger-classes- ;
-
 ! update-map
 : class-uses ( class -- seq )
-    [ dup members % superclass [ , ] when* ] { } make ;
+    dup members swap superclass [ add ] when* ;
 
 : class-usages ( class -- assoc )
     [ update-map get at ] closure ;
@@ -224,54 +83,12 @@ M: word reset-class drop ;
 : update-map- ( class -- )
     dup class-uses update-map get remove-vertex ;
 
-! typemap
-: push-at ( value key assoc -- )
-    2dup at* [
-        2nip push
-    ] [
-        drop >r >r 1vector r> r> set-at
-    ] if ;
-
-: typemap+ ( class -- )
-    dup flatten-builtin-class typemap get push-at ;
-
-: pop-at ( value key assoc -- )
-    at* [ delete ] [ 2drop ] if ;
-
-: typemap- ( class -- )
-    dup flatten-builtin-class typemap get pop-at ;
-
-! class-map
-: class-map+ ( class -- )
-    dup flatten-class class-map get push-at ;
-
-: class-map- ( class -- )
-    dup flatten-class class-map get pop-at ;
-
-! Class definition
-: cache-class ( class -- )
-    dup typemap+ dup class-map+ dup class<map+ update-map+ ;
-
-: cache-classes ( assoc -- )
-    [ drop cache-class ] assoc-each ;
-
-GENERIC: uncache-class ( class -- )
-
-M: class uncache-class
-    dup update-map- dup class<map- dup class-map- typemap- ;
-
-M: word uncache-class drop ;
-
-: uncache-classes ( assoc -- )
-    [ drop uncache-class ] assoc-each ;
-
-PRIVATE>
-
-: define-class-props ( members superclass metaclass -- assoc )
+: define-class-props ( superclass members metaclass -- assoc )
     [
-        "metaclass" set
-        dup [ bootstrap-word ] when "superclass" set
-        [ bootstrap-word ] map "members" set
+        [ dup [ bootstrap-word ] when "superclass" set ]
+        [ [ bootstrap-word ] map "members" set ]
+        [ "metaclass" set ]
+        tri*
     ] H{ } make-assoc ;
 
 : (define-class) ( word props -- )
@@ -282,33 +99,31 @@ PRIVATE>
     over "predicating" set-word-prop
     t "class" set-word-prop ;
 
-GENERIC: update-predicate ( class -- )
+PRIVATE>
+
+GENERIC: update-class ( class -- )
 
-M: class update-predicate drop ;
+M: class update-class drop ;
 
-: update-predicates ( assoc -- )
-    [ drop update-predicate ] assoc-each ;
+: update-classes ( assoc -- )
+    [ drop update-class ] assoc-each ;
 
 GENERIC: update-methods ( assoc -- )
 
-: define-class ( word members superclass metaclass -- )
+: define-class ( word superclass members metaclass -- )
     #! If it was already a class, update methods after.
+    reset-caches
     define-class-props
-    over class? >r
-    over class-usages [
-        uncache-classes
-        dupd (define-class)
-    ] keep cache-classes r>
-    [ class-usages dup update-predicates update-methods ]
-    [ drop ] if ;
+    [ drop update-map- ]
+    [ (define-class) ] [
+        drop
+        [ update-map+ ] [
+            class-usages
+            [ update-classes ]
+            [ update-methods ] bi
+        ] bi
+    ] 2tri ;
 
 GENERIC: class ( object -- class ) inline
 
 M: object class type type>class ;
-
-<PRIVATE
-
-: class-of-tuple ( obj -- class )
-    2 slot { word } declare ; inline
-
-PRIVATE>
index f9b987eb782c8f5d2377cf0a109d6b46155f1bcf..eb6b3bd6e2a8c462bca13a3cd20ee479276105c9 100755 (executable)
@@ -1,10 +1,10 @@
 ! Copyright (C) 2004, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: classes classes.union words kernel sequences
-definitions combinators arrays ;
+definitions combinators arrays accessors ;
 IN: classes.mixin
 
-PREDICATE: union-class mixin-class "mixin" word-prop ;
+PREDICATE: mixin-class < union-class "mixin" word-prop ;
 
 M: mixin-class reset-class
     { "metaclass" "members" "mixin" } reset-props ;
@@ -47,14 +47,13 @@ TUPLE: mixin-instance loc class mixin ;
 M: mixin-instance equal?
     {
         { [ over mixin-instance? not ] [ f ] }
-        { [ 2dup [ mixin-instance-class ] 2apply = not ] [ f ] }
-        { [ 2dup [ mixin-instance-mixin ] 2apply = not ] [ f ] }
+        { [ 2dup [ mixin-instance-class ] bi@ = not ] [ f ] }
+        { [ 2dup [ mixin-instance-mixin ] bi@ = not ] [ f ] }
         { [ t ] [ t ] }
     } cond 2nip ;
 
 M: mixin-instance hashcode*
-    { mixin-instance-class mixin-instance-mixin } get-slots
-    2array hashcode* ;
+    [ class>> ] [ mixin>> ] bi 2array hashcode* ;
 
 : <mixin-instance> ( class mixin -- definition )
     { set-mixin-instance-class set-mixin-instance-mixin }
index a65392773dbbb14e6b5a518b46b26becc621e607..d03d97cd4c6d4018a71bc471871225d0a1f6bd89 100755 (executable)
@@ -14,7 +14,7 @@ ARTICLE: "predicates" "Predicate classes"
 ABOUT: "predicates"
 
 HELP: define-predicate-class
-{ $values { "superclass" class } { "class" class } { "definition" "a quotation with stack effect " { $snippet "( superclass -- ? )" } } }
+{ $values { "class" class } { "superclass" class } { "definition" "a quotation with stack effect " { $snippet "( superclass -- ? )" } } }
 { $description "Defines a predicate class. This is the run time equivalent of " { $link POSTPONE: PREDICATE: } "." }
 { $notes "This word must be called from inside " { $link with-compilation-unit } "." }
 { $side-effects "class" } ;
index 6d1c727ee2ec99d162b1f7c8a3e80e1509980f28..b2a5a03bb42b5aa1db096df1096b6e566b20bffe 100755 (executable)
@@ -1,9 +1,9 @@
-! Copyright (C) 2004, 2007 Slava Pestov.
+! Copyright (C) 2004, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: classes kernel namespaces words ;
 IN: classes.predicate
 
-PREDICATE: class predicate-class
+PREDICATE: predicate-class < class
     "metaclass" word-prop predicate-class eq? ;
 
 : predicate-quot ( class -- quot )
@@ -13,9 +13,9 @@ PREDICATE: class predicate-class
         "predicate-definition" word-prop , [ drop f ] , \ if ,
     ] [ ] make ;
 
-: define-predicate-class ( superclass class definition -- )
-    >r dup f roll predicate-class define-class r>
-    dupd "predicate-definition" set-word-prop
+: define-predicate-class ( class superclass definition -- )
+    >r dupd f predicate-class define-class
+    r> dupd "predicate-definition" set-word-prop
     dup predicate-quot define-predicate ;
 
 M: predicate-class reset-class
diff --git a/core/classes/tuple/authors.txt b/core/classes/tuple/authors.txt
new file mode 100644 (file)
index 0000000..1901f27
--- /dev/null
@@ -0,0 +1 @@
+Slava Pestov
diff --git a/core/classes/tuple/summary.txt b/core/classes/tuple/summary.txt
new file mode 100644 (file)
index 0000000..4dbb643
--- /dev/null
@@ -0,0 +1 @@
+Object system implementation
diff --git a/core/classes/tuple/tuple-docs.factor b/core/classes/tuple/tuple-docs.factor
new file mode 100755 (executable)
index 0000000..7123d5c
--- /dev/null
@@ -0,0 +1,290 @@
+USING: generic help.markup help.syntax kernel
+classes.tuple.private classes slots quotations words arrays
+generic.standard sequences definitions compiler.units ;
+IN: classes.tuple
+
+ARTICLE: "tuple-constructors" "Constructors"
+"Tuples are created by calling one of two words:"
+{ $subsection construct-empty }
+{ $subsection construct-boa }
+"By convention, construction logic is encapsulated in a word named after the tuple class surrounded in angle brackets; for example, the constructor word for a " { $snippet "point" } " class might be named " { $snippet "<point>" } "."
+$nl
+"A shortcut for defining BOA constructors:"
+{ $subsection POSTPONE: C: }
+"Examples of constructors:"
+{ $code
+    "TUPLE: color red green blue alpha ;"
+    ""
+    "C: <rgba> rgba"
+    ": <rgba> color construct-boa ; ! identical to above"
+    ""
+    ": <rgb> f <rgba> ;"
+    ""
+    ": <color> construct-empty ;"
+    ": <color> f f f f <rgba> ; ! identical to above"
+} ;
+
+ARTICLE: "tuple-delegation" "Tuple delegation"
+"If a generic word having the " { $link standard-combination } " method combination is called on a tuple for which it does not have an applicable method, the method call is forwarded to the tuple's " { $emphasis "delegate" } ". If no delegate is set, a " { $link no-method } " error is thrown."
+{ $subsection delegate }
+{ $subsection set-delegate }
+"A tuple's delegate should either be another tuple, or " { $link f } ", indicating no delegate is set. Delegation from a tuple to an object of some other type is not fully supported and should be used with caution."
+$nl
+"Factor uses delegation in place of implementation inheritance, but it is not a direct substitute; in particular, the semantics differ in that a delegated method call receives the delegate on the stack, not the original object."
+$nl
+"A pair of words examine delegation chains:"
+{ $subsection delegates }
+{ $subsection is? }
+"An example:"
+{ $example
+    "TUPLE: ellipse center radius ;"
+    "TUPLE: colored color ;"
+    "{ 0 0 } 10 <ellipse> \"my-ellipse\" set"
+    "{ 1 0 0 } <colored> \"my-shape\" set"
+    "\"my-ellipse\" get \"my-shape\" get set-delegate"
+    "\"my-shape\" get dup color>> swap center>> .s"
+    "{ 0 0 }\n{ 1 0 0 }"
+} ;
+
+ARTICLE: "tuple-introspection" "Tuple introspection"
+"In addition to the slot reader and writer words which " { $link POSTPONE: TUPLE: } " defines for every tuple class, it is possible to construct and take apart entire tuples in a generic way."
+{ $subsection >tuple }
+{ $subsection tuple>array }
+{ $subsection tuple-slots }
+"Tuple classes can also be defined at run time:"
+{ $subsection define-tuple-class }
+{ $see-also "slots" "mirrors" } ;
+
+ARTICLE: "tuple-examples" "Tuple examples"
+"An example:"
+{ $code "TUPLE: employee name salary position ;" }
+"This defines a class word named " { $snippet "employee" } ", a predicate " { $snippet "employee?" } ", and the following slot accessors:"
+{ $table
+    { "Reader" "Writer" "Setter" "Changer" }
+    { { $snippet "name>>" }    { $snippet "(>>name)" }    { $snippet ">>name" }    { $snippet "change-name" }    }
+    { { $snippet "salary>>" } { $snippet "(>>salary)" } { $snippet ">>salary" } { $snippet "change-salary" } }
+    { { $snippet "position>>" }   { $snippet "(>>position)" }   { $snippet ">>position" }   { $snippet "change-position" }   }
+}
+"We can define a constructor which makes an empty employee:"
+{ $code ": <employee> ( -- employee )"
+    "    employee construct-empty ;" }
+"Or we may wish the default constructor to always give employees a starting salary:"
+{ $code
+    ": <employee> ( -- employee )"
+    "    employee construct-empty"
+    "        40000 >>salary ;"
+}
+"We can define more refined constructors:"
+{ $code
+    ": <manager> ( -- manager )"
+    "    <employee> \"project manager\" >>position ;" }
+"An alternative strategy is to define the most general BOA constructor first:"
+{ $code
+    ": <employee> ( name position -- person )"
+    "    40000 employee construct-boa ;"
+}
+"Now we can define more specific constructors:"
+{ $code
+    ": <manager> ( name -- person )"
+    "    \"manager\" <person> ;" }
+"An example using reader words:"
+{ $code
+    "TUPLE: check to amount number ;"
+    ""
+    "SYMBOL: checks"
+    ""
+    ": <check> ( to amount -- check )"
+    "    checks counter check construct-boa ;"
+    ""
+    ": biweekly-paycheck ( employee -- check )"
+    "    dup name>> swap salary>> 26 / <check> ;"
+}
+"An example of using a changer:"
+{ $code
+    ": positions"
+    "    {"
+    "        \"junior programmer\""
+    "        \"senior programmer\""
+    "        \"project manager\""
+    "        \"department manager\""
+    "        \"executive\""
+    "        \"CTO\""
+    "        \"CEO\""
+    "        \"enterprise Java world dictator\""
+    "    } ;"
+    ""
+    ": next-position ( role -- newrole )"
+    "    positions [ index 1+ ] keep nth ;"
+    ""
+    ": promote ( person -- person )"
+    "    [ 1.2 * ] change-salary"
+    "    [ next-position ] change-position ;"
+} ;
+
+ARTICLE: "tuples" "Tuples"
+"Tuples are user-defined classes composed of named slots."
+{ $subsection "tuple-examples" }
+"A parsing word defines tuple classes:"
+{ $subsection POSTPONE: TUPLE: }
+"For each tuple class, several words are defined. First, there is the class word, a class predicate, and accessor words for each slot."
+$nl
+"The class word is used for defining methods on the tuple class; it has the same name as the tuple class. The predicate is named " { $snippet { $emphasis "name" } "?" } ". Tuple slots are accessed via accessor words:"
+{ $subsection "accessors" }
+"Initially, no specific words are defined for constructing new instances of the tuple. Constructors must be defined explicitly:"
+{ $subsection "tuple-constructors" }
+"Further topics:"
+{ $subsection "tuple-delegation" }
+{ $subsection "tuple-introspection" }
+"Tuple literal syntax is documented in " { $link "syntax-tuples" } "." ;
+
+ABOUT: "tuples"
+
+HELP: delegate
+{ $values { "obj" object } { "delegate" object } }
+{ $description "Returns an object's delegate, or " { $link f } " if no delegate is set." }
+{ $notes "A direct consequence of this behavior is that an object may not have a delegate of " { $link f } "." } ;
+
+HELP: set-delegate
+{ $values { "delegate" object } { "tuple" tuple } }
+{ $description "Sets a tuple's delegate. Method calls not handled by the tuple's class will now be passed on to the delegate." } ;
+
+HELP: tuple=
+{ $values { "tuple1" tuple } { "tuple2" tuple } { "?" "a boolean" } }
+{ $description "Low-level tuple equality test. User code should use " { $link = } " instead." }
+{ $warning "This word is in the " { $vocab-link "classes.tuple.private" } " vocabulary because it does not do any type checking. Passing values which are not tuples can result in memory corruption." } ;
+
+HELP: permutation
+{ $values { "seq1" sequence } { "seq2" sequence } { "permutation" "a sequence whose elements are integers or " { $link f } } }
+{ $description "Outputs a permutation for taking " { $snippet "seq1" } " to " { $snippet "seq2" } "." } ;
+
+HELP: reshape-tuple
+{ $values { "oldtuple" tuple } { "permutation" "a sequence whose elements are integers or " { $link f } } { "newtuple" tuple } }
+{ $description "Permutes the slots of a tuple. If a tuple class is redefined at runtime, this word is called on every instance to change its shape to conform to the new layout." } ;
+
+HELP: reshape-tuples
+{ $values { "class" tuple-class } { "superclass" class } { "newslots" "a sequence of strings" } }
+{ $description "Changes the shape of every instance of " { $snippet "class" } " for a new slot layout." } ;
+
+HELP: removed-slots
+{ $values { "class" tuple-class } { "newslots" "a sequence of strings" } { "seq" "a sequence of strings" } }
+{ $description "Outputs the sequence of existing tuple slot names not in " { $snippet "newslots" } "." } ;
+
+HELP: forget-slots
+{ $values { "class" tuple-class } { "slots" "a sequence of strings" } }
+{ $description "Forgets accessor words for existing tuple slots which are not in " { $snippet "newslots" } "." } ;
+
+HELP: tuple
+{ $class-description "The class of tuples. This class is further partitioned into disjoint subclasses; each tuple shape defined by " { $link POSTPONE: TUPLE: } " is a new class."
+$nl
+"Tuple classes have additional word properties:"
+{ $list
+    { { $snippet "\"constructor\"" } " - a word for creating instances of this tuple class" }
+    { { $snippet "\"predicate\"" } " - a quotation which tests if the top of the stack is an instance of this tuple class" }
+    { { $snippet "\"slots\"" } " - a sequence of " { $link slot-spec } " instances" }
+    { { $snippet "\"slot-names\"" } " - a sequence of strings naming the tuple's slots" }
+    { { $snippet "\"tuple-size\"" } " - the number of slots" }
+} } ;
+
+HELP: define-tuple-predicate
+{ $values { "class" tuple-class } }
+{ $description "Defines a predicate word that tests if the top of the stack is an instance of " { $snippet "class" } ". This will only work if " { $snippet "class" } " is a tuple class." }
+$low-level-note ;
+
+HELP: redefine-tuple-class
+{ $values { "class" class } { "superclass" class } { "slots" "a sequence of strings" } }
+{ $description "If the new slot layout differs from the existing one, updates all existing instances of this tuple class, and forgets any slot accessor words which are no longer needed."
+$nl
+"If the class is not a tuple class word, this word does nothing." }
+$low-level-note ;
+
+HELP: tuple-slots
+{ $values { "tuple" tuple } { "seq" sequence } }
+{ $description "Pushes a sequence of tuple slot values, not including the tuple class word and delegate." } ;
+
+{ tuple-slots tuple>array } related-words
+
+HELP: define-tuple-slots
+{ $values { "class" tuple-class } { "slots" "a sequence of strings" } }
+{ $description "Defines slot accessor and mutator words for the tuple." }
+$low-level-note ;
+
+HELP: check-tuple
+{ $values { "class" class } }
+{ $description "Throws a " { $link check-tuple } " error if " { $snippet "word" } " is not a tuple class word." }
+{ $error-description "Thrown if " { $link POSTPONE: C: } " is called with a word which does not name a tuple class." } ;
+
+HELP: define-tuple-class
+{ $values { "class" word } { "superclass" class } { "slots" "a sequence of strings" } }
+{ $description "Defines a tuple class inheriting from " { $snippet "superclass" } " with slots named by " { $snippet "slots" } ". This is the run time equivalent of " { $link POSTPONE: TUPLE: } "." }
+{ $notes "This word must be called from inside " { $link with-compilation-unit } "." }
+{ $side-effects "class" } ;
+
+{ tuple-class define-tuple-class POSTPONE: TUPLE: } related-words
+
+HELP: delegates
+{ $values { "obj" object } { "seq" sequence } }
+{ $description "Outputs the delegation chain of an object. The first element of " { $snippet "seq" } " is " { $snippet "obj" } " itself. If " { $snippet "obj" } " is " { $link f } ", an empty sequence is output." } ;
+
+HELP: is?
+{ $values { "obj" object } { "quot" "a quotation with stack effect " { $snippet "( obj -- ? )" } } { "?" "a boolean" } }
+{ $description "Tests if the object or one of its delegates satisfies the predicate quotation."
+$nl
+"Class membership test predicates only test if an object is a direct instance of that class. Sometimes, you need to check delegates, since this gives a clearer picture of what operations the object supports." } ;
+
+HELP: >tuple
+{ $values { "seq" sequence } { "tuple" tuple } }
+{ $description "Creates a tuple with slot values taken from a sequence. The first element of the sequence must be a tuple class word, the second a delegate, and the remainder the declared slots."
+$nl
+"If the sequence has too many elements, they are ignored, and if it has too few, the remaining slots in the tuple are set to " { $link f } "." }
+{ $errors "Throws an error if the first element of the sequence is not a tuple class word." } ;
+
+HELP: tuple>array ( tuple -- array )
+{ $values { "tuple" tuple } { "array" array } }
+{ $description "Outputs an array having the tuple's slots as elements. The first element is the tuple class word and the second is the delegate; the remainder are declared slots." } ;
+
+HELP: <tuple> ( layout -- tuple )
+{ $values { "layout" tuple-layout } { "tuple" tuple } }
+{ $description "Low-level tuple constructor. User code should never call this directly, and instead use " { $link construct-empty } "." } ;
+
+HELP: <tuple-boa> ( ... layout -- tuple )
+{ $values { "..." "values" } { "layout" tuple-layout } { "tuple" tuple } }
+{ $description "Low-level tuple constructor. User code should never call this directly, and instead use " { $link construct-boa } "." } ;
+
+HELP: construct-empty
+{ $values { "class" tuple-class } { "tuple" tuple } }
+{ $description "Creates a new instance of " { $snippet "class" } " with all slots initially set to " { $link f } "." }
+{ $examples
+    { $example
+        "USING: kernel prettyprint ;"
+        "TUPLE: employee number name department ;"
+        "employee construct-empty ."
+        "T{ employee f f f f }"
+    }
+} ;
+
+HELP: construct
+{ $values { "..." "slot values" } { "slots" "a sequence of setter words" } { "class" tuple-class } { "tuple" tuple } }
+{ $description "Creates a new instance of " { $snippet "class" } ", storing consecutive stack values into the slots of the new tuple using setter words in " { $snippet "slots" } ". The top-most stack element is stored in the right-most slot." }
+{ $examples
+    "We can define a class:"
+    { $code "TUPLE: color red green blue alpha ;" }
+    "Together with two constructors:"
+    { $code
+        ": <rgb> ( r g b -- color )"
+        "    { set-color-red set-color-green set-color-blue }"
+        "    color construct ;"
+        ""
+        ": <rgba> ( r g b a -- color )"
+        "    { set-color-red set-color-green set-color-blue set-color-alpha }"
+        "    color construct ;"
+    }
+    "The last definition is actually equivalent to the following:"
+    { $code ": <rgba> ( r g b a -- color ) rgba construct-boa ;" }
+    "Which can be abbreviated further:"
+    { $code "C: <rgba> color" }
+} ;
+
+HELP: construct-boa
+{ $values { "..." "slot values" } { "class" tuple-class } { "tuple" tuple } }
+{ $description "Creates a new instance of " { $snippet "class" } " and fill in the slots from the stack, with the top-most stack element being stored in the right-most slot." }
+{ $notes "The " { $snippet "-boa" } " suffix is shorthand for ``by order of arguments'', and ``BOA constructor'' is a pun on ``boa constrictor''." } ;
diff --git a/core/classes/tuple/tuple-tests.factor b/core/classes/tuple/tuple-tests.factor
new file mode 100755 (executable)
index 0000000..9b82281
--- /dev/null
@@ -0,0 +1,391 @@
+USING: definitions generic kernel kernel.private math
+math.constants parser sequences tools.test words assocs
+namespaces quotations sequences.private classes continuations
+generic.standard effects classes.tuple classes.tuple.private
+arrays vectors strings compiler.units accessors classes.algebra
+calendar prettyprint io.streams.string splitting ;
+IN: classes.tuple.tests
+
+TUPLE: rect x y w h ;
+: <rect> rect construct-boa ;
+
+: move ( x rect -- rect )
+    [ + ] change-x ;
+
+[ f ] [ 10 20 30 40 <rect> dup clone 5 swap move = ] unit-test
+
+[ t ] [ 10 20 30 40 <rect> dup clone 0 swap move = ] unit-test
+
+GENERIC: delegation-test
+M: object delegation-test drop 3 ;
+TUPLE: quux-tuple ;
+: <quux-tuple> quux-tuple construct-empty ;
+M: quux-tuple delegation-test drop 4 ;
+TUPLE: quuux-tuple ;
+: <quuux-tuple> { set-delegate } quuux-tuple construct ;
+
+[ 3 ] [ <quux-tuple> <quuux-tuple> delegation-test ] unit-test
+
+GENERIC: delegation-test-2
+TUPLE: quux-tuple-2 ;
+: <quux-tuple-2> quux-tuple-2 construct-empty ;
+M: quux-tuple-2 delegation-test-2 drop 4 ;
+TUPLE: quuux-tuple-2 ;
+: <quuux-tuple-2> { set-delegate } quuux-tuple-2 construct ;
+
+[ 4 ] [ <quux-tuple-2> <quuux-tuple-2> delegation-test-2 ] unit-test
+
+! Make sure we handle tuple class redefinition
+TUPLE: redefinition-test ;
+
+C: <redefinition-test> redefinition-test
+
+<redefinition-test> "redefinition-test" set
+
+[ t ] [ "redefinition-test" get redefinition-test? ] unit-test
+
+"IN: classes.tuple.tests TUPLE: redefinition-test ;" eval
+
+[ t ] [ "redefinition-test" get redefinition-test? ] unit-test
+
+! Make sure we handle changing shapes!
+TUPLE: point x y ;
+
+C: <point> point
+
+[ ] [ 100 200 <point> "p" set ] unit-test
+
+! Use eval to sequence parsing explicitly
+[ ] [ "IN: classes.tuple.tests TUPLE: point x y z ;" eval ] unit-test
+
+[ 100 ] [ "p" get x>> ] unit-test
+[ 200 ] [ "p" get y>> ] unit-test
+[ f ] [ "p" get "z>>" "accessors" lookup execute ] unit-test
+
+"p" get 300 ">>z" "accessors" lookup execute drop
+
+[ 4 ] [ "p" get tuple-size ] unit-test
+
+[ 300 ] [ "p" get "z>>" "accessors" lookup execute ] unit-test
+
+"IN: classes.tuple.tests TUPLE: point z y ;" eval
+
+[ 3 ] [ "p" get tuple-size ] unit-test
+
+[ "p" get x>> ] must-fail
+[ 200 ] [ "p" get y>> ] unit-test
+[ 300 ] [ "p" get "z>>" "accessors" lookup execute ] unit-test
+
+TUPLE: predicate-test ;
+
+C: <predicate-test> predicate-test
+
+: predicate-test drop f ;
+
+[ t ] [ <predicate-test> predicate-test? ] unit-test
+
+PREDICATE: silly-pred < tuple
+    class \ rect = ;
+
+GENERIC: area
+M: silly-pred area dup w>> swap h>> * ;
+
+TUPLE: circle radius ;
+M: circle area radius>> sq pi * ;
+
+[ 200 ] [ T{ rect f 0 0 10 20 } area ] unit-test
+
+! Hashcode breakage
+TUPLE: empty ;
+
+C: <empty> empty
+
+[ t ] [ <empty> hashcode fixnum? ] unit-test
+
+TUPLE: delegate-clone ;
+
+[ T{ delegate-clone T{ empty f } } ]
+[ T{ delegate-clone T{ empty f } } clone ] unit-test
+
+! Compiler regression
+[ t length ] [ object>> t eq? ] must-fail-with
+
+[ "<constructor-test>" ]
+[ "TUPLE: constructor-test ; C: <constructor-test> constructor-test" eval word word-name ] unit-test
+
+TUPLE: size-test a b c d ;
+
+[ t ] [
+    T{ size-test } tuple-size
+    size-test tuple-size =
+] unit-test
+
+GENERIC: <yo-momma>
+
+TUPLE: yo-momma ;
+
+"IN: classes.tuple.tests C: <yo-momma> yo-momma" eval
+
+[ f ] [ \ <yo-momma> generic? ] unit-test
+
+! Test forget
+[
+    [ t ] [ \ yo-momma class? ] unit-test
+    [ ] [ \ yo-momma forget ] unit-test
+    [ f ] [ \ yo-momma update-map get values memq? ] unit-test
+
+    [ f ] [ \ yo-momma crossref get at ] unit-test
+] with-compilation-unit
+
+TUPLE: loc-recording ;
+
+[ f ] [ \ loc-recording where not ] unit-test
+
+! 'forget' wasn't robust enough
+
+TUPLE: forget-robustness ;
+
+GENERIC: forget-robustness-generic
+
+M: forget-robustness forget-robustness-generic ;
+
+M: integer forget-robustness-generic ;
+
+[
+    [ ] [ \ forget-robustness-generic forget ] unit-test
+    [ ] [ \ forget-robustness forget ] unit-test
+    [ ] [ { forget-robustness forget-robustness-generic } forget ] unit-test
+] with-compilation-unit
+
+! rapido found this one
+GENERIC# m1 0 ( s n -- n )
+GENERIC# m2 1 ( s n -- v )
+
+TUPLE: t1 ;
+
+M: t1 m1 drop ;
+M: t1 m2 nip ;
+
+TUPLE: t2 ;
+
+M: t2 m1 drop ;
+M: t2 m2 nip ;
+
+TUPLE: t3 ;
+
+M: t3 m1 drop ;
+M: t3 m2 nip ;
+
+TUPLE: t4 ;
+
+M: t4 m1 drop ;
+M: t4 m2 nip ;
+
+C: <t4> t4
+
+[ 1 ] [ 1 <t4> m1 ] unit-test
+[ 1 ] [ <t4> 1 m2 ] unit-test
+
+! another combination issue
+GENERIC: silly
+
+UNION: my-union slice repetition column array vector reversed ;
+
+M: my-union silly "x" ;
+
+M: array silly "y" ;
+
+M: column silly "fdsfds" ;
+
+M: repetition silly "zzz" ;
+
+M: reversed silly "zz" ;
+
+M: slice silly "tt" ;
+
+M: string silly "t" ;
+
+M: vector silly "z" ;
+
+[ "zz" ] [ 123 <reversed> silly nip ] unit-test
+
+! Typo
+SYMBOL: not-a-tuple-class
+
+[
+    "IN: classes.tuple.tests C: <not-a-tuple-class> not-a-tuple-class"
+    eval
+] must-fail
+
+[ t ] [
+    "not-a-tuple-class" "classes.tuple.tests" lookup symbol?
+] unit-test
+
+! Missing check
+[ not-a-tuple-class construct-boa ] must-fail
+[ not-a-tuple-class construct-empty ] must-fail
+
+TUPLE: erg's-reshape-problem a b c d ;
+
+C: <erg's-reshape-problem> erg's-reshape-problem
+
+! We want to make sure constructors are recompiled when
+! tuples are reshaped
+: cons-test-1 \ erg's-reshape-problem construct-empty ;
+: cons-test-2 \ erg's-reshape-problem construct-boa ;
+
+"IN: classes.tuple.tests TUPLE: erg's-reshape-problem a b c d e f ;" eval
+
+[ ] [ 1 2 3 4 5 6 cons-test-2 "a" set ] unit-test
+
+[ t ] [ cons-test-1 tuple-size "a" get tuple-size = ] unit-test
+
+[
+    "IN: classes.tuple.tests SYMBOL: not-a-class C: <not-a-class> not-a-class" eval
+] [ [ no-tuple-class? ] is? ] must-fail-with
+
+! Inheritance
+TUPLE: computer cpu ram ;
+C: <computer> computer
+
+[ "TUPLE: computer cpu ram ;" ] [
+    [ \ computer see ] with-string-writer string-lines second
+] unit-test
+
+TUPLE: laptop < computer battery ;
+C: <laptop> laptop
+
+[ t ] [ laptop tuple-class? ] unit-test
+[ t ] [ laptop tuple class< ] unit-test
+[ t ] [ laptop computer class< ] unit-test
+[ t ] [ laptop computer classes-intersect? ] unit-test
+
+[ ] [ "Pentium" 128 3 hours <laptop> "laptop" set ] unit-test
+[ t ] [ "laptop" get laptop? ] unit-test
+[ t ] [ "laptop" get computer? ] unit-test
+[ t ] [ "laptop" get tuple? ] unit-test
+
+[ "Pentium" ] [ "laptop" get cpu>> ] unit-test
+[ 128 ] [ "laptop" get ram>> ] unit-test
+[ t ] [ "laptop" get battery>> 3 hours = ] unit-test
+
+[ laptop ] [
+    "laptop" get tuple-layout
+    dup layout-echelon swap
+    layout-superclasses nth
+] unit-test
+
+[ "TUPLE: laptop < computer battery ;" ] [
+    [ \ laptop see ] with-string-writer string-lines second
+] unit-test
+
+[ { tuple computer laptop } ] [ laptop superclasses ] unit-test
+
+TUPLE: server < computer rackmount ;
+C: <server> server
+
+[ t ] [ server tuple-class? ] unit-test
+[ t ] [ server tuple class< ] unit-test
+[ t ] [ server computer class< ] unit-test
+[ t ] [ server computer classes-intersect? ] unit-test
+
+[ ] [ "PowerPC" 64 "1U" <server> "server" set ] unit-test
+[ t ] [ "server" get server? ] unit-test
+[ t ] [ "server" get computer? ] unit-test
+[ t ] [ "server" get tuple? ] unit-test
+
+[ "PowerPC" ] [ "server" get cpu>> ] unit-test
+[ 64 ] [ "server" get ram>> ] unit-test
+[ "1U" ] [ "server" get rackmount>> ] unit-test
+
+[ f ] [ "server" get laptop? ] unit-test
+[ f ] [ "laptop" get server? ] unit-test
+
+[ f ] [ server laptop class< ] unit-test
+[ f ] [ laptop server class< ] unit-test
+[ f ] [ laptop server classes-intersect? ] unit-test
+
+[ f ] [ 1 2 <computer> laptop? ] unit-test
+[ f ] [ \ + server? ] unit-test
+
+[ "TUPLE: server < computer rackmount ;" ] [
+    [ \ server see ] with-string-writer string-lines second
+] unit-test
+
+[
+    "IN: classes.tuple.tests TUPLE: bad-superclass < word ;" eval
+] must-fail
+
+! Reshaping with inheritance
+TUPLE: electronic-device ;
+
+[ ] [ "IN: classes.tuple.tests TUPLE: computer < electronic-device ;" eval ] unit-test
+
+[ f ] [ electronic-device laptop class< ] unit-test
+[ t ] [ server electronic-device class< ] unit-test
+[ t ] [ laptop server class-or electronic-device class< ] unit-test
+
+[ t ] [ "laptop" get electronic-device? ] unit-test
+[ t ] [ "laptop" get computer? ] unit-test
+[ t ] [ "laptop" get laptop? ] unit-test
+[ f ] [ "laptop" get server? ] unit-test
+
+[ t ] [ "server" get electronic-device? ] unit-test
+[ t ] [ "server" get computer? ] unit-test
+[ f ] [ "server" get laptop? ] unit-test
+[ t ] [ "server" get server? ] unit-test
+
+[ ] [ "IN: classes.tuple.tests TUPLE: computer ;" eval ] unit-test
+
+[ f ] [ "laptop" get electronic-device? ] unit-test
+[ t ] [ "laptop" get computer? ] unit-test
+
+! Redefinition problem
+TUPLE: redefinition-problem ;
+
+UNION: redefinition-problem' redefinition-problem integer ;
+
+[ t ] [ 3 redefinition-problem'? ] unit-test
+
+TUPLE: redefinition-problem-2 ;
+
+"IN: classes.tuple.tests TUPLE: redefinition-problem < redefinition-problem-2 ;" eval
+
+[ t ] [ 3 redefinition-problem'? ] unit-test
+
+! Hardcore unit tests
+USE: threads
+
+\ thread slot-names "slot-names" set
+
+[ ] [
+    [
+        \ thread tuple { "xxx" } "slot-names" get append
+        define-tuple-class
+    ] with-compilation-unit
+
+    [ 1337 sleep ] "Test" spawn drop
+
+    [
+        \ thread tuple "slot-names" get
+        define-tuple-class
+    ] with-compilation-unit
+] unit-test
+
+USE: vocabs
+
+\ vocab slot-names "slot-names" set
+
+[ ] [
+    [
+        \ vocab tuple { "xxx" } "slot-names" get append
+        define-tuple-class
+    ] with-compilation-unit
+
+    all-words drop
+
+    [
+        \ vocab tuple "slot-names" get
+        define-tuple-class
+    ] with-compilation-unit
+] unit-test
diff --git a/core/classes/tuple/tuple.factor b/core/classes/tuple/tuple.factor
new file mode 100755 (executable)
index 0000000..a452d0e
--- /dev/null
@@ -0,0 +1,218 @@
+! Copyright (C) 2005, 2008 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: arrays definitions hashtables kernel
+kernel.private math namespaces sequences sequences.private
+strings vectors words quotations memory combinators generic
+classes classes.private slots.deprecated slots.private slots
+compiler.units math.private accessors assocs ;
+IN: classes.tuple
+
+M: tuple delegate 2 slot ;
+
+M: tuple set-delegate 2 set-slot ;
+
+M: tuple class 1 slot 2 slot { word } declare ;
+
+ERROR: no-tuple-class class ;
+
+<PRIVATE
+
+GENERIC: tuple-layout ( object -- layout )
+
+M: class tuple-layout "layout" word-prop ;
+
+M: tuple tuple-layout 1 slot ;
+
+: tuple-size tuple-layout layout-size ; inline
+
+PRIVATE>
+
+: check-tuple ( class -- )
+    dup tuple-class?
+    [ drop ] [ no-tuple-class ] if ;
+
+: tuple>array ( tuple -- array )
+    dup tuple-layout
+    [ layout-size swap [ array-nth ] curry map ] keep
+    layout-class add* ;
+
+: >tuple ( seq -- tuple )
+    dup first tuple-layout <tuple> [
+        >r 1 tail-slice dup length r>
+        [ tuple-size min ] keep
+        [ set-array-nth ] curry
+        2each
+    ] keep ;
+
+: slot-names ( class -- seq )
+    "slots" word-prop [ name>> ] map ;
+
+<PRIVATE
+
+: tuple= ( tuple1 tuple2 -- ? )
+    over tuple-layout over tuple-layout eq? [
+        dup tuple-size -rot
+        [ >r over r> array-nth >r array-nth r> = ] 2curry
+        all-integers?
+    ] [
+        2drop f
+    ] if ;
+
+! Predicate generation. We optimize at the expense of simplicity
+
+: (tuple-predicate-quot) ( class -- quot )
+    #! 4 slot == layout-superclasses
+    #! 5 slot == layout-echelon
+    [
+        [ 1 slot dup 5 slot ] %
+        dup tuple-layout layout-echelon ,
+        [ fixnum>= ] %
+        [
+            dup tuple-layout layout-echelon ,
+            [ swap 4 slot array-nth ] %
+            literalize ,
+            [ eq? ] %
+        ] [ ] make ,
+        [ drop f ] ,
+        \ if ,
+    ] [ ] make ;
+
+: tuple-predicate-quot ( class -- quot )
+    [
+        [ dup tuple? ] %
+        (tuple-predicate-quot) ,
+        [ drop f ] ,
+        \ if ,
+    ] [ ] make ;
+
+: define-tuple-predicate ( class -- )
+    dup tuple-predicate-quot define-predicate ;
+
+: superclass-size ( class -- n )
+    superclasses 1 head-slice*
+    [ slot-names length ] map sum ;
+
+: generate-tuple-slots ( class slots -- slots )
+    over superclass-size 2 + simple-slots ;
+
+: define-tuple-slots ( class slots -- )
+    dupd generate-tuple-slots
+    [ "slots" set-word-prop ]
+    [ define-accessors ]
+    [ define-slots ] 2tri ;
+
+: make-tuple-layout ( class -- layout )
+    [ ]
+    [ [ superclass-size ] [ "slots" word-prop length ] bi + ]
+    [ superclasses dup length 1- ] tri
+    <tuple-layout> ;
+
+: define-tuple-layout ( class -- )
+    dup make-tuple-layout "layout" set-word-prop ;
+
+: removed-slots ( class newslots -- seq )
+    swap slot-names seq-diff ;
+
+: forget-slots ( class slots -- )
+    dupd removed-slots [
+        [ reader-word forget-method ]
+        [ writer-word forget-method ] 2bi
+    ] with each ;
+
+: permutation ( seq1 seq2 -- permutation )
+    swap [ index ] curry map ;
+
+: reshape-tuple ( oldtuple permutation -- newtuple )
+    >r tuple>array 2 cut r>
+    [ [ swap ?nth ] [ drop f ] if* ] with map
+    append >tuple ;
+
+: reshape-tuples ( class superclass newslots -- )
+    nip
+    >r dup slot-names r> permutation
+    [
+        >r "predicate" word-prop instances dup
+        r> [ reshape-tuple ] curry map
+        become
+    ] 2curry after-compilation ;
+
+: define-new-tuple-class ( class superclass slots -- )
+    [ drop f tuple-class define-class ]
+    [ nip define-tuple-slots ] [
+        2drop
+        class-usages keys [ tuple-class? ] subset [
+            [ define-tuple-layout ]
+            [ define-tuple-predicate ]
+            bi
+        ] each
+    ] 3tri ;
+
+: redefine-tuple-class ( class superclass slots -- )
+    [ reshape-tuples ]
+    [
+        nip
+        [ forget-slots ]
+        [ drop changed-word ]
+        [ drop redefined ]
+        2tri
+    ]
+    [ define-new-tuple-class ]
+    3tri ;
+
+: tuple-class-unchanged? ( class superclass slots -- ? )
+    rot tuck [ superclass = ] [ slot-names = ] 2bi* and ;
+
+PRIVATE>
+
+GENERIC# define-tuple-class 2 ( class superclass slots -- )
+
+M: word define-tuple-class
+    define-new-tuple-class ;
+
+M: tuple-class define-tuple-class
+    3dup tuple-class-unchanged?
+    [ 3dup redefine-tuple-class ] unless
+    3drop ;
+
+: define-error-class ( class superclass slots -- )
+    pick >r define-tuple-class r>
+    dup [ construct-boa throw ] curry define ;
+
+M: tuple clone
+    (clone) dup delegate clone over set-delegate ;
+
+M: tuple equal?
+    over tuple? [ tuple= ] [ 2drop f ] if ;
+
+: delegates ( obj -- seq )
+    [ dup ] [ [ delegate ] keep ] [ ] unfold nip ;
+
+: is? ( obj quot -- ? ) >r delegates r> contains? ; inline
+
+M: tuple hashcode*
+    [
+        dup tuple-size -rot 0 -rot [
+            swapd array-nth hashcode* bitxor
+        ] 2curry reduce
+    ] recursive-hashcode ;
+
+: tuple-slots ( tuple -- seq ) tuple>array 2 tail ;
+
+! Definition protocol
+M: tuple-class reset-class
+    { "metaclass" "superclass" "slots" "layout" } reset-props ;
+
+M: object get-slots ( obj slots -- ... )
+    [ execute ] with each ;
+
+M: object set-slots ( ... obj slots -- )
+    <reversed> get-slots ;
+
+M: object construct-empty ( class -- tuple )
+    tuple-layout <tuple> ;
+
+M: object construct ( ... slots class -- tuple )
+    construct-empty [ swap set-slots ] keep ;
+
+M: object construct-boa ( ... class -- tuple )
+    tuple-layout <tuple-boa> ;
index c1c82d158b443cfc56712745d42c5dfc635591f6..e9b98770dc3273a3c9061e01b040d6e6bbef6a6f 100755 (executable)
@@ -4,7 +4,7 @@ USING: words sequences kernel assocs combinators classes
 generic.standard namespaces arrays math quotations ;
 IN: classes.union
 
-PREDICATE: class union-class
+PREDICATE: union-class < class
     "metaclass" word-prop union-class eq? ;
 
 ! Union classes for dispatch on multiple classes.
@@ -33,10 +33,10 @@ PREDICATE: class union-class
 : define-union-predicate ( class -- )
     dup members union-predicate-quot define-predicate ;
 
-M: union-class update-predicate define-union-predicate ;
+M: union-class update-class define-union-predicate ;
 
 : define-union-class ( class members -- )
-    dupd f union-class define-class define-union-predicate ;
+    f swap union-class define-class ;
 
 M: union-class reset-class
     { "metaclass" "members" } reset-props ;
index f5d4470bde6729565f10893f4ed8cdeb0b0b41d8..f497fd20e52812fa1b6b4472a24159c109bb3db5 100755 (executable)
@@ -10,18 +10,54 @@ ARTICLE: "combinators-quot" "Quotation construction utilities"
 { $subsection alist>quot } ;
 
 ARTICLE: "combinators" "Additional combinators"
-"The " { $vocab-link "combinators" } " vocabulary is usually used because it provides two combinators which abstract out nested chains of " { $link if } ":"
+"The " { $vocab-link "combinators" } " vocabulary provides generalizations of certain combinators from the " { $vocab-link "kernel" } " vocabulary."
+$nl
+"Generalization of " { $link bi } " and " { $link tri } ":"
+{ $subsection cleave }
+"Generalization of " { $link bi* } " and " { $link tri* } ":"
+{ $subsection spread }
+"Two combinators which abstract out nested chains of " { $link if } ":"
 { $subsection cond }
 { $subsection case }
+"The " { $vocab-link "combinators" } " also provides some less frequently-used features."
+$nl
 "A combinator which can help with implementing methods on " { $link hashcode* } ":"
 { $subsection recursive-hashcode }
 "An oddball combinator:"
 { $subsection with-datastack }
 { $subsection "combinators-quot" }
-{ $see-also "quotations" "basic-combinators" } ;
+{ $see-also "quotations" "dataflow" } ;
 
 ABOUT: "combinators"
 
+HELP: cleave
+{ $values { "x" object } { "seq" "a sequence of quotations with stack effect " { $snippet "( x -- ... )" } } }
+{ $description "Applies each quotation to the object in turn." }
+{ $examples
+    "The " { $link bi } " combinator takes one value and two quotations; the " { $link tri } " combinator takes one value and three quotations. The " { $link cleave } " combinator takes one value and any number of quotations, and is essentially equivalent to a chain of " { $link keep } " forms:"
+    { $code
+        "! Equivalent"
+        "{ [ p ] [ q ] [ r ] [ s ] } cleave"
+        "[ p ] keep [ q ] keep [ r ] keep s"
+    }
+} ;
+
+{ bi tri cleave } related-words
+
+HELP: spread
+{ $values { "objs..." "objects" } { "seq" "a sequence of quotations with stack effect " { $snippet "( x -- ... )" } } }
+{ $description "Applies each quotation to the object in turn." }
+{ $examples
+    "The " { $link bi* } " combinator takes two values and two quotations; the " { $link tri* } " combinator takes three values and three quotations. The " { $link spread } " combinator takes " { $snippet "n" } " values and " { $snippet "n" } " quotations, where " { $snippet "n" } " is the length of the input sequence, and is essentially equivalent to series of retain stack manipulations:"
+    { $code
+        "! Equivalent"
+        "{ [ p ] [ q ] [ r ] [ s ] } spread"
+        ">r >r >r p r> q r> r r> s"
+    }
+} ;
+
+{ bi* tri* spread } related-words
+
 HELP: alist>quot
 { $values { "default" "a quotation" } { "assoc" "a sequence of quotation pairs" } { "quot" "a new quotation" } }
 { $description "Constructs a quotation which calls the first quotation in each pair of " { $snippet "assoc" } " until one of them outputs a true value, and then calls the second quotation in the corresponding pair. Quotations are called in reverse order, and if no quotation outputs a true value then " { $snippet "default" } " is called." }
index 807b372e1d19c4eba828f4c0d798a052ea256941..e19847dbd4155a2e87697fab8e015a5e89d64d43 100755 (executable)
@@ -5,6 +5,26 @@ USING: arrays sequences sequences.private math.private
 kernel kernel.private math assocs quotations vectors
 hashtables sorting ;
 
+: cleave ( x seq -- )
+    [ call ] with each ;
+
+: cleave>quot ( seq -- quot )
+    [ [ keep ] curry ] map concat [ drop ] append ;
+
+: 2cleave ( x seq -- )
+    [ [ call ] 3keep drop ] each 2drop ;
+
+: 2cleave>quot ( seq -- quot )
+    [ [ 2keep ] curry ] map concat [ 2drop ] append ;
+
+: spread>quot ( seq -- quot )
+    [ length [ >r ] <repetition> concat ]
+    [ [ [ r> ] prepend ] map concat ] bi
+    append ;
+
+: spread ( objs... seq -- )
+    spread>quot call ;
+
 ERROR: no-cond ;
 
 : cond ( assoc -- )
index 277a64225ac29de82900fd1a9c77ba7fa71cef45..11f64c9373353a8a97a7b8e76c2cdc4d86d67e2f 100755 (executable)
@@ -15,7 +15,7 @@ IN: compiler.constants
 : byte-array-offset 2 bootstrap-cells object tag-number - ;
 : alien-offset 3 bootstrap-cells object tag-number - ;
 : underlying-alien-offset bootstrap-cell object tag-number - ;
-: tuple-class-offset 2 bootstrap-cells tuple tag-number - ;
+: tuple-class-offset bootstrap-cell tuple tag-number - ;
 : class-hash-offset bootstrap-cell object tag-number - ;
 : word-xt-offset 8 bootstrap-cells object tag-number - ;
 : word-code-offset 9 bootstrap-cells object tag-number - ;
index d2e7115f8f673bc699aa937744167e75c30ff6c8..61d20fd8abfc96098dcc5b41b86798e719540b4a 100755 (executable)
@@ -10,7 +10,7 @@ IN: compiler.tests
 [ 3 ] [ 5 2 [ [ - ] 2curry 9 swap call /i ] compile-call ] unit-test
 [ 3 ] [ 5 2 [ [ - ] 2curry >r 9 r> call /i ] compile-call ] unit-test
 
-[ -10 -20 ] [ 10 20 -1 [ [ * ] curry 2apply ] compile-call ] unit-test
+[ -10 -20 ] [ 10 20 -1 [ [ * ] curry bi@ ] compile-call ] unit-test
 
 [ [ 5 2 - ] ] [ 5 [ [ 2 - ] curry ] compile-call >quotation ] unit-test
 [ [ 5 2 - ] ] [ [ 5 [ 2 - ] curry ] compile-call >quotation ] unit-test
index 1c19730ec0373dea9973f4fad338aa5eadf6e3f2..081a8fd47ce195d4e3155ea73623e5adbe07c683 100755 (executable)
@@ -72,17 +72,17 @@ unit-test
 ] unit-test
 
 [ 12 13 ] [
-    -12 -13 [ [ 0 swap fixnum-fast ] 2apply ] compile-call
+    -12 -13 [ [ 0 swap fixnum-fast ] bi@ ] compile-call
 ] unit-test
 
 [ -1 2 ] [ 1 2 [ >r 0 swap fixnum- r> ] compile-call ] unit-test
 
 [ 12 13 ] [
-    -12 -13 [ [ 0 swap fixnum- ] 2apply ] compile-call
+    -12 -13 [ [ 0 swap fixnum- ] bi@ ] compile-call
 ] unit-test
 
-[ 2 ] [
-    SBUF" " [ 2 slot 2 [ slot ] keep ] compile-call nip
+[ 1 ] [
+    SBUF" " [ 1 slot 1 [ slot ] keep ] compile-call nip
 ] unit-test
 
 ! Test slow shuffles
index 13b31cfde672dafba2a659b67d55ad94d1c2ab71..a2c296e8cea456dd10cd21ab94c49dd4d48bc29d 100755 (executable)
@@ -1,7 +1,8 @@
 ! Copyright (C) 2003, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: arrays vectors kernel kernel.private sequences
-namespaces math splitting sorting quotations assocs ;
+namespaces math splitting sorting quotations assocs
+combinators accessors ;
 IN: continuations
 
 SYMBOL: error
@@ -43,12 +44,12 @@ C: <continuation> continuation
 
 : >continuation< ( continuation -- data call retain name catch )
     {
-        continuation-data
-        continuation-call
-        continuation-retain
-        continuation-name
-        continuation-catch
-    } get-slots ;
+        [ data>>   ]
+        [ call>>   ]
+        [ retain>> ]
+        [ name>>   ]
+        [ catch>>  ]
+    } cleave ;
 
 : ifcc ( capture restore -- )
     #! After continuation is being captured, the stacks looks
index cd6c8b61f7ec26cbad5dedebf9e79cd6e6b0f78b..8d1e1f281f8563f0e4b14c65189a736997cbbb46 100755 (executable)
@@ -153,11 +153,11 @@ M: f v>operand drop \ f tag-number ;
 
 M: object load-literal v>operand load-indirect ;
 
-PREDICATE: integer small-slot cells small-enough? ;
+PREDICATE: small-slot < integer cells small-enough? ;
 
-PREDICATE: integer small-tagged v>operand small-enough? ;
+PREDICATE: small-tagged < integer v>operand small-enough? ;
 
-PREDICATE: integer inline-array 32 < ;
+PREDICATE: inline-array < integer 32 < ;
 
 : if-small-struct ( n size true false -- ? )
     >r >r over not over struct-small-enough? and
index 8742a693cb39d7e1aa096f923666587f9d3ba22d..563dd10bc4d7b78fde4bea2d461ba959b3af854e 100755 (executable)
@@ -63,7 +63,7 @@ M: arm-backend load-indirect ( obj reg -- )
 
 M: immediate load-literal
     over v>operand small-enough? [
-        [ v>operand ] 2apply swap MOV
+        [ v>operand ] bi@ swap MOV
     ] [
         v>operand load-indirect
     ] if ;
@@ -322,10 +322,10 @@ M: arm-backend fp-shadows-int? ( -- ? ) f ;
 
 ! Alien intrinsics
 M: arm-backend %unbox-byte-array ( dst src -- )
-    [ v>operand ] 2apply byte-array-offset ADD ;
+    [ v>operand ] bi@ byte-array-offset ADD ;
 
 M: arm-backend %unbox-alien ( dst src -- )
-    [ v>operand ] 2apply alien-offset <+> LDR ;
+    [ v>operand ] bi@ alien-offset <+> LDR ;
 
 M: arm-backend %unbox-f ( dst src -- )
     drop v>operand 0 MOV ;
index d10b24de4e4d5f259a1f8d98fcd9ef133dbb3b68..5a69f93d85faaf3c3934a324f98d09bc1bb0f079 100755 (executable)
@@ -27,7 +27,7 @@ SYMBOL: R15
 { R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 }
 define-registers
 
-PREDICATE: word register register >boolean ;
+PREDICATE: register < word register >boolean ;
 
 GENERIC: register ( register -- n )
 M: word register "register" word-prop ;
index 29210afaa55bc89c7a0b36590fa12f9cdffdd810..e9902888eb7114247dc6d4ebe01a538dece3475b 100755 (executable)
@@ -5,8 +5,8 @@ cpu.arm.architecture cpu.arm.allot kernel kernel.private math
 math.private namespaces sequences words
 quotations byte-arrays hashtables.private hashtables generator
 generator.registers generator.fixup sequences.private sbufs
-sbufs.private vectors vectors.private system tuples.private
-layouts strings.private slots.private ;
+sbufs.private vectors vectors.private system
+classes.tuple.private layouts strings.private slots.private ;
 IN: cpu.arm.intrinsics
 
 : %slot-literal-known-tag
index df0a08a86dab494663390e6bf3ce135bb533150f..6c37fce4f1d16bd0e8c8314d48afb097303b7cbc 100755 (executable)
@@ -33,7 +33,7 @@ IN: cpu.ppc.allot
     f fresh-object ;
 
 M: ppc-backend %box-float ( dst src -- )
-    [ v>operand ] 2apply %allot-float 12 MR ;
+    [ v>operand ] bi@ %allot-float 12 MR ;
 
 : %allot-bignum ( #digits -- )
     #! 1 cell header, 1 cell length, 1 cell sign, + digits
index 1daf3ac622e83ab7836887b0eee9cc88a4181158..903ac32df9e17dc1ae50572d807693a6de32ea54 100755 (executable)
@@ -71,7 +71,7 @@ M: ds-loc loc>operand ds-loc-n cells neg ds-reg swap ;
 M: rs-loc loc>operand rs-loc-n cells neg rs-reg swap ;
 
 M: immediate load-literal
-    [ v>operand ] 2apply LOAD ;
+    [ v>operand ] bi@ LOAD ;
 
 M: ppc-backend load-indirect ( obj reg -- )
     [ 0 swap LOAD32 rc-absolute-ppc-2/2 rel-literal ] keep
@@ -138,7 +138,7 @@ M: ppc-backend %replace
     >r v>operand r> loc>operand STW ;
 
 M: ppc-backend %unbox-float ( dst src -- )
-    [ v>operand ] 2apply float-offset LFD ;
+    [ v>operand ] bi@ float-offset LFD ;
 
 M: ppc-backend %inc-d ( n -- ) ds-reg dup rot cells ADDI ;
 
@@ -291,10 +291,10 @@ M: ppc-backend %unbox-small-struct
 
 ! Alien intrinsics
 M: ppc-backend %unbox-byte-array ( dst src -- )
-    [ v>operand ] 2apply byte-array-offset ADDI ;
+    [ v>operand ] bi@ byte-array-offset ADDI ;
 
 M: ppc-backend %unbox-alien ( dst src -- )
-    [ v>operand ] 2apply alien-offset LWZ ;
+    [ v>operand ] bi@ alien-offset LWZ ;
 
 M: ppc-backend %unbox-f ( dst src -- )
     drop 0 swap v>operand LI ;
index 91bf5ed1e3075d4ff055674461c3fba366364fb0..7aa78ce52e4e396bc13a704332b2e6c3846679e7 100755 (executable)
@@ -6,9 +6,9 @@ kernel.private math math.private namespaces sequences words
 generic quotations byte-arrays hashtables hashtables.private
 generator generator.registers generator.fixup sequences.private
 sbufs vectors system layouts math.floats.private
-classes tuples tuples.private sbufs.private vectors.private
-strings.private slots.private combinators bit-arrays
-float-arrays compiler.constants ;
+classes classes.tuple classes.tuple.private sbufs.private
+vectors.private strings.private slots.private combinators
+bit-arrays float-arrays compiler.constants ;
 IN: cpu.ppc.intrinsics
 
 : %slot-literal-known-tag
@@ -479,19 +479,17 @@ IN: cpu.ppc.intrinsics
 } define-intrinsic
 
 \ <tuple> [
-    tuple "n" get 2 + cells %allot
-    ! Store length
-    "n" operand 12 LI
+    tuple "layout" get layout-size 2 + cells %allot
+    ! Store layout
+    "layout" get 12 load-indirect
     12 11 cell STW
-    ! Store class
-    "class" operand 11 2 cells STW
     ! Zero out the rest of the tuple
     f v>operand 12 LI
-    "n" get 1- [ 12 11 rot 3 + cells STW ] each
+    "layout" get layout-size [ 12 11 rot 2 + cells STW ] each
     ! Store tagged ptr in reg
     "tuple" get tuple %store-tagged
 ] H{
-    { +input+ { { f "class" } { [ inline-array? ] "n" } } }
+    { +input+ { { [ tuple-layout? ] "layout" } } }
     { +scratch+ { { f "tuple" } } }
     { +output+ { "tuple" } }
 } define-intrinsic
index 81a7d7cd0248d0d9af91c15cfb4c57a7e4fa27e3..f4af421cddd6f628d603c8bf120facf79f47ec1c 100755 (executable)
@@ -8,7 +8,7 @@ alien.compiler combinators command-line
 compiler compiler.units io vocabs.loader accessors ;
 IN: cpu.x86.32
 
-PREDICATE: x86-backend x86-32-backend
+PREDICATE: x86-32-backend < x86-backend
     x86-backend-cell 4 = ;
 
 ! We implement the FFI for Linux, OS X and Windows all at once.
index 25e32225d4eb10acf0146f3ebdeb40c86f3b53f4..c2af60e983dccb37c3c3a4550b1be3ea2f2a62e2 100755 (executable)
@@ -8,7 +8,7 @@ layouts alien alien.accessors alien.compiler alien.structs slots
 splitting assocs ;
 IN: cpu.x86.64
 
-PREDICATE: x86-backend amd64-backend
+PREDICATE: amd64-backend < x86-backend
     x86-backend-cell 8 = ;
 
 M: amd64-backend ds-reg R14 ;
index f837a92504e426491c87eae129ff8f70e96e8f17..5519a9a8d569a8618b14488b0d4fd69f77df3fe5 100755 (executable)
@@ -101,6 +101,6 @@ M: x86-backend %box-alien ( dst src -- )
         ] %allot
         "end" get JMP
         "f" resolve-label
-        f [ v>operand ] 2apply MOV
+        f [ v>operand ] bi@ MOV
         "end" resolve-label
     ] with-scope ;
index 49b05ea48f593b6662f2c0d75c248f5a2a4b3002..31fa4c8e4b7153dd882142f3e6dd18c6806e64c7 100755 (executable)
@@ -109,9 +109,9 @@ M: x86-backend %dispatch-label ( word -- )
     0 cell, rc-absolute-cell rel-word ;
 
 M: x86-backend %unbox-float ( dst src -- )
-    [ v>operand ] 2apply float-offset [+] MOVSD ;
+    [ v>operand ] bi@ float-offset [+] MOVSD ;
 
-M: x86-backend %peek [ v>operand ] 2apply MOV ;
+M: x86-backend %peek [ v>operand ] bi@ MOV ;
 
 M: x86-backend %replace swap %peek ;
 
@@ -156,16 +156,16 @@ M: x86-backend %unbox-small-struct ( size -- )
 
 M: x86-backend struct-small-enough? ( size -- ? )
     { 1 2 4 8 } member?
-    os { "linux" "solaris" } member? not and ;
+    os { "linux" "netbsd" "solaris" } member? not and ;
 
 M: x86-backend %return ( -- ) 0 %unwind ;
 
 ! Alien intrinsics
 M: x86-backend %unbox-byte-array ( dst src -- )
-    [ v>operand ] 2apply byte-array-offset [+] LEA ;
+    [ v>operand ] bi@ byte-array-offset [+] LEA ;
 
 M: x86-backend %unbox-alien ( dst src -- )
-    [ v>operand ] 2apply alien-offset [+] MOV ;
+    [ v>operand ] bi@ alien-offset [+] MOV ;
 
 M: x86-backend %unbox-f ( dst src -- )
     drop v>operand 0 MOV ;
index 65caec412eeef710193046625c8148676cc86365..796388ffe1c06fb417401f6ef64fe486a1819295 100755 (executable)
@@ -52,13 +52,23 @@ GENERIC: extended? ( op -- ? )
 
 M: object extended? drop f ;
 
-PREDICATE: word register "register" word-prop ;
+PREDICATE: register < word
+    "register" word-prop ;
 
-PREDICATE: register register-8 "register-size" word-prop 8 = ;
-PREDICATE: register register-16 "register-size" word-prop 16 = ;
-PREDICATE: register register-32 "register-size" word-prop 32 = ;
-PREDICATE: register register-64 "register-size" word-prop 64 = ;
-PREDICATE: register register-128 "register-size" word-prop 128 = ;
+PREDICATE: register-8 < register
+    "register-size" word-prop 8 = ;
+
+PREDICATE: register-16 < register
+    "register-size" word-prop 16 = ;
+
+PREDICATE: register-32 < register
+    "register-size" word-prop 32 = ;
+
+PREDICATE: register-64 < register
+    "register-size" word-prop 64 = ;
+
+PREDICATE: register-128 < register
+    "register-size" word-prop 128 = ;
 
 M: register extended? "register" word-prop 7 > ;
 
@@ -285,7 +295,7 @@ GENERIC: (MOV-I) ( src dst -- )
 M: register (MOV-I) t HEX: b8 short-operand cell, ;
 M: operand (MOV-I) BIN: 000 t HEX: c7 1-operand 4, ;
 
-PREDICATE: word callable register? not ;
+PREDICATE: callable < word register? not ;
 
 GENERIC: MOV ( dst src -- )
 M: integer MOV swap (MOV-I) ;
index 99a89eab059321edba8a5f0f78980cc5a76ac01c..f5409a24f54d3065eb09c4d27c46550f8634fdd8 100755 (executable)
@@ -6,8 +6,8 @@ kernel.private math math.private namespaces quotations sequences
 words generic byte-arrays hashtables hashtables.private
 generator generator.registers generator.fixup sequences.private
 sbufs sbufs.private vectors vectors.private layouts system
-tuples.private strings.private slots.private compiler.constants
-;
+classes.tuple.private strings.private slots.private
+compiler.constants ;
 IN: cpu.x86.intrinsics
 
 ! Type checks
@@ -336,19 +336,20 @@ IN: cpu.x86.intrinsics
 } define-intrinsic
 
 \ <tuple> [
-    tuple "n" get 2 + cells [
-        ! Store length
-        1 object@ "n" operand MOV
-        ! Store class
-        2 object@ "class" operand MOV
+    tuple "layout" get layout-size 2 + cells [
+        ! Store layout
+        "layout" get "scratch" get load-literal
+        1 object@ "scratch" operand MOV
         ! Zero out the rest of the tuple
-        "n" operand 1- [ 3 + object@ f v>operand MOV ] each
+        "layout" get layout-size [
+            2 + object@ f v>operand MOV
+        ] each
         ! Store tagged ptr in reg
         "tuple" get tuple %store-tagged
     ] %allot
 ] H{
-    { +input+ { { f "class" } { [ inline-array? ] "n" } } }
-    { +scratch+ { { f "tuple" } } }
+    { +input+ { { [ tuple-layout? ] "layout" } } }
+    { +scratch+ { { f "tuple" } { f "scratch" } } }
     { +output+ { "tuple" } }
 } define-intrinsic
 
index 4775093ba746df1f1bd032d501cddfca919a6b5a..033ae0680ca4bbd3281874e26c1a6c3ed4f7bebc 100755 (executable)
@@ -3,7 +3,7 @@
 USING: arrays definitions generic hashtables inspector io kernel
 math namespaces prettyprint sequences assocs sequences.private
 strings io.styles vectors words system splitting math.parser
-tuples continuations continuations.private combinators
+classes.tuple continuations continuations.private combinators
 generic.math io.streams.duplex classes compiler.units
 generic.standard vocabs threads threads.private init
 kernel.private libc io.encodings ;
@@ -82,7 +82,7 @@ ERROR: assert got expect ;
 : depth ( -- n ) datastack length ;
 
 : trim-datastacks ( seq1 seq2 -- seq1' seq2' )
-    2dup [ length ] 2apply min tuck tail >r tail r> ;
+    2dup [ length ] bi@ min tuck tail >r tail r> ;
 
 ERROR: relative-underflow stack ;
 
@@ -156,7 +156,7 @@ M: relative-overflow summary
 : primitive-error.
     "Unimplemented primitive" print drop ;
 
-PREDICATE: array kernel-error ( obj -- ? )
+PREDICATE: kernel-error < array
     {
         { [ dup empty? ] [ drop f ] }
         { [ dup first "kernel-error" = not ] [ drop f ] }
index 2bc0e6a3fbc9e5ac9bd57e3440b9fb68b400b408..28db6e1cbdde52a27604c4d63835ed936d2b7582 100755 (executable)
@@ -63,7 +63,7 @@ IN: dlists.tests
 [ 0 ] [ <dlist> 1 over push-front dup pop-front* dlist-length ] unit-test
 
 : assert-same-elements
-    [ prune natural-sort ] 2apply assert= ;
+    [ prune natural-sort ] bi@ assert= ;
 
 : dlist-push-all [ push-front ] curry each ;
 
index 23e8daf1229f181f6c2f1d742e5f7d5ce8aafbdc..aed4a64c6cd4c2efad730046d5b2c58a12bce98c 100755 (executable)
@@ -18,8 +18,8 @@ TUPLE: effect in out terminated? ;
         { [ dup not ] [ t ] }
         { [ over effect-terminated? ] [ t ] }
         { [ dup effect-terminated? ] [ f ] }
-        { [ 2dup [ effect-in length ] 2apply > ] [ f ] }
-        { [ 2dup [ effect-height ] 2apply = not ] [ f ] }
+        { [ 2dup [ effect-in length ] bi@ > ] [ f ] }
+        { [ 2dup [ effect-height ] bi@ = not ] [ f ] }
         { [ t ] [ t ] }
     } cond 2nip ;
 
index 307e3a99f1a8a47bd47af4218b9457915d842577..aac1b2cdc63b37db130ac20e2d99babd687f5593 100755 (executable)
@@ -1,9 +1,9 @@
 ! Copyright (C) 2006, 2007 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: arrays assocs classes classes.private combinators
-cpu.architecture generator.fixup hashtables kernel layouts math
-namespaces quotations sequences system vectors words effects
-alien byte-arrays bit-arrays float-arrays ;
+USING: arrays assocs classes classes.private classes.algebra
+combinators cpu.architecture generator.fixup hashtables kernel
+layouts math namespaces quotations sequences system vectors
+words effects alien byte-arrays bit-arrays float-arrays ;
 IN: generator.registers
 
 SYMBOL: +input+
@@ -79,7 +79,7 @@ M: ds-loc minimal-ds-loc* ds-loc-n min ;
 M: ds-loc operand-class* ds-loc-class ;
 M: ds-loc set-operand-class set-ds-loc-class ;
 M: ds-loc live-loc?
-    over ds-loc? [ [ ds-loc-n ] 2apply = not ] [ 2drop t ] if ;
+    over ds-loc? [ [ ds-loc-n ] bi@ = not ] [ 2drop t ] if ;
 
 ! A retain stack location.
 TUPLE: rs-loc n class ;
@@ -89,7 +89,7 @@ TUPLE: rs-loc n class ;
 M: rs-loc operand-class* rs-loc-class ;
 M: rs-loc set-operand-class set-rs-loc-class ;
 M: rs-loc live-loc?
-    over rs-loc? [ [ rs-loc-n ] 2apply = not ] [ 2drop t ] if ;
+    over rs-loc? [ [ rs-loc-n ] bi@ = not ] [ 2drop t ] if ;
 
 UNION: loc ds-loc rs-loc ;
 
@@ -206,7 +206,7 @@ INSTANCE: constant value
     %move ;
 
 : %move ( dst src -- )
-    2dup [ move-spec ] 2apply 2array {
+    2dup [ move-spec ] bi@ 2array {
         { { f f } [ %move-bug ] }
         { { f unboxed-c-ptr } [ %move-bug ] }
         { { f unboxed-byte-array } [ %move-bug ] }
@@ -318,7 +318,7 @@ M: phantom-stack cut-phantom
 
 : phantoms ( -- phantom phantom ) phantom-d get phantom-r get ;
 
-: each-phantom ( quot -- ) phantoms rot 2apply ; inline
+: each-phantom ( quot -- ) phantoms rot bi@ ; inline
 
 : finalize-heights ( -- ) [ finalize-height ] each-phantom ;
 
@@ -442,7 +442,7 @@ M: loc lazy-store
 : fast-shuffle? ( live-locs -- ? )
     #! Test if we have enough free registers to load all
     #! shuffle inputs at once.
-    T{ int-regs } free-vregs [ length ] 2apply <= ;
+    T{ int-regs } free-vregs [ length ] bi@ <= ;
 
 : finalize-locs ( -- )
     #! Perform any deferred stack shuffling.
@@ -488,7 +488,7 @@ M: loc lazy-store
 
 : phantom&spec ( phantom spec -- phantom' spec' )
     [ length f pad-left ] keep
-    [ <reversed> ] 2apply ; inline
+    [ <reversed> ] bi@ ; inline
 
 : phantom&spec-agree? ( phantom spec quot -- ? )
     >r phantom&spec r> 2all? ; inline
@@ -520,7 +520,7 @@ M: loc lazy-store
     swap lazy-load ;
 
 : output-vregs ( -- seq seq )
-    +output+ +clobber+ [ get [ get ] map ] 2apply ;
+    +output+ +clobber+ [ get [ get ] map ] bi@ ;
 
 : clash? ( seq -- ? )
     phantoms append [
@@ -581,13 +581,14 @@ M: loc lazy-store
         2drop t
     ] if ;
 
+: class-tags ( class -- tag/f )
+    class-types [
+        dup num-tags get >=
+        [ drop object tag-number ] when
+    ] map prune ;
+
 : class-tag ( class -- tag/f )
-    dup hi-tag class< [
-        drop object tag-number
-    ] [
-        flatten-builtin-class keys
-        dup length 1 = [ first tag-number ] [ drop f ] if
-    ] if ;
+    class-tags dup length 1 = [ first ] [ drop f ] if ;
 
 : class-matches? ( actual expected -- ? )
     {
index b59c92c7980331414094018e5b9cd0e367e2da28..56de801e7a04c0785ff7b129ec7b529dfbccdfe5 100755 (executable)
@@ -1,6 +1,6 @@
-USING: help.markup help.syntax words classes definitions kernel
-alien sequences math quotations generic.standard generic.math
-combinators ;
+USING: help.markup help.syntax words classes classes.algebra
+definitions kernel alien sequences math quotations
+generic.standard generic.math combinators ;
 IN: generic
 
 ARTICLE: "method-order" "Method precedence"
index 785600cfb0e32553b7b50a2a8fb901fa4362f0ac..6a7f8f29fcdd83be8516c0f1cdd3a9e4676a76bc 100755 (executable)
@@ -1,8 +1,8 @@
 USING: alien arrays definitions generic generic.standard
 generic.math assocs hashtables io kernel math namespaces parser
 prettyprint sequences strings tools.test vectors words
-quotations classes continuations layouts classes.union sorting
-compiler.units ;
+quotations classes classes.algebra continuations layouts
+classes.union sorting compiler.units ;
 IN: generic.tests
 
 GENERIC: foobar ( x -- y )
@@ -44,7 +44,7 @@ M: object funny drop 0 ;
 [ 2 ] [ [ { } ] funny ] unit-test
 [ 0 ] [ { } funny ] unit-test
 
-PREDICATE: funnies very-funny number? ;
+PREDICATE: very-funny < funnies number? ;
 
 GENERIC: gooey ( x -- y )
 M: very-funny gooey sq ;
index 8fe5e4921ad2039ebfd3e4b72d622f3347e53fc3..131b7e57c9b9f67225df8fef96babfafc8bc11ee 100755 (executable)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: words kernel sequences namespaces assocs hashtables
 definitions kernel.private classes classes.private
-quotations arrays vocabs effects ;
+classes.algebra quotations arrays vocabs effects ;
 IN: generic
 
 ! Method combination protocol
@@ -19,7 +19,8 @@ M: object perform-combination
 
 GENERIC: make-default-method ( generic combination -- method )
 
-PREDICATE: word generic "combination" word-prop >boolean ;
+PREDICATE: generic < word
+    "combination" word-prop >boolean ;
 
 M: generic definition drop f ;
 
@@ -30,7 +31,7 @@ M: generic definition drop f ;
 : method ( class generic -- method/f )
     "methods" word-prop at ;
 
-PREDICATE: pair method-spec
+PREDICATE: method-spec < pair
     first2 generic? swap class? and ;
 
 : order ( generic -- seq )
@@ -55,7 +56,7 @@ TUPLE: check-method class generic ;
 : method-word-name ( class word -- string )
     word-name "/" rot word-name 3append ;
 
-PREDICATE: word method-body
+PREDICATE: method-body < word
     "method-generic" word-prop >boolean ;
 
 M: method-body stack-effect
@@ -138,7 +139,7 @@ M: method-body forget*
 
 M: class forget* ( class -- )
     dup forget-methods
-    dup uncache-class
+    dup update-map-
     forget-word ;
 
 M: assoc update-methods ( assoc -- )
index 46f57a16290ffd02b12cddd152463dc0bb8ffaa5..85bd736139dff33624fe85c81f023f6eb1bdfb38 100755 (executable)
@@ -1,11 +1,11 @@
-! Copyright (C) 2005, 2007 Slava Pestov.
+! Copyright (C) 2005, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: arrays generic hashtables kernel kernel.private
 math namespaces sequences words quotations layouts combinators
-sequences.private classes definitions ;
+sequences.private classes classes.algebra definitions ;
 IN: generic.math
 
-PREDICATE: class math-class ( object -- ? )
+PREDICATE: math-class < class
     dup null bootstrap-word eq? [
         drop f
     ] [
@@ -16,8 +16,8 @@ PREDICATE: class math-class ( object -- ? )
 
 : math-precedence ( class -- n )
     {
-        { [ dup class-empty? ] [ drop { -1 -1 } ] }
-        { [ dup math-class? ] [ types last/first ] }
+        { [ dup null class< ] [ drop { -1 -1 } ] }
+        { [ dup math-class? ] [ class-types last/first ] }
         { [ t ] [ drop { 100 100 } ] }
     } cond ;
     
@@ -79,7 +79,7 @@ M: math-combination perform-combination
         ] if nip
     ] math-vtable nip ;
 
-PREDICATE: generic math-generic ( word -- ? )
+PREDICATE: math-generic < generic ( word -- ? )
     "combination" word-prop math-combination? ;
 
 M: math-generic definer drop \ MATH: f ;
index 37f72e7d95eff9f6f822824d9b5fc98912092975..4447c5a2640c75473d568b31d7d9d9256118839a 100755 (executable)
@@ -3,7 +3,7 @@
 USING: arrays assocs kernel kernel.private slots.private math
 namespaces sequences vectors words quotations definitions
 hashtables layouts combinators sequences.private generic
-classes classes.private ;
+classes classes.algebra classes.private ;
 IN: generic.standard
 
 TUPLE: standard-combination # ;
@@ -174,13 +174,13 @@ M: hook-combination perform-combination
 : define-simple-generic ( word -- )
     T{ standard-combination f 0 } define-generic ;
 
-PREDICATE: generic standard-generic
+PREDICATE: standard-generic < generic
     "combination" word-prop standard-combination? ;
 
-PREDICATE: standard-generic simple-generic
+PREDICATE: simple-generic < standard-generic
     "combination" word-prop standard-combination-# zero? ;
 
-PREDICATE: generic hook-generic
+PREDICATE: hook-generic < generic
     "combination" word-prop hook-combination? ;
 
 GENERIC: dispatch# ( word -- n )
index d62afdffb5d74e68afe3edafca542e86d3757560..2a4be9c5708fd2b284e00ca2a1d3cf8ffd0ca5b1 100755 (executable)
@@ -32,14 +32,28 @@ $nl
 { $code "H{ } clone" }
 "To convert an assoc to a hashtable:"
 { $subsection >hashtable }
+"Further topics:"
+{ $subsection "hashtables.keys" }
+{ $subsection "hashtables.utilities" }
+{ $subsection "hashtables.private" } ;
+
+ARTICLE: "hashtables.keys" "Hashtable keys"
+"Hashtables rely on the " { $link hashcode } " word to rapidly locate values associated with keys. The objects used as keys in a hashtable must obey certain restrictions."
+$nl
+"The " { $link hashcode } " of a key is a function of the its slot values, and if the hashcode changes then the hashtable will be left in an inconsistent state. The easiest way to avoid this problem is to never mutate objects used as hashtable keys."
+$nl
+"In certain advanced applications, this cannot be avoided and the best design involves mutating hashtable keys. In this case, a custom " { $link hashcode* } " method must be defined which only depends on immutable slots."
+$nl
+"In addition, the " { $link equal? } " and " { $link hashcode* } " methods must be congruent, and if one is defined the other should be defined also. This is documented in detail in the documentation for these respective words." ;
+
+ARTICLE: "hashtables.utilities" "Hashtable utilities"
 "Utility words to create a new hashtable from a single key/value pair:"
 { $subsection associate }
 { $subsection ?set-at }
 "The final two words pertain to sequences but use a hashtable internally. Removing duplicate elements from a sequence in linear time, using a hashtable:"
 { $subsection prune }
 "Test if a sequence contains duplicates in linear time:"
-{ $subsection all-unique? }
-{ $subsection "hashtables.private" } ;
+{ $subsection all-unique? } ;
 
 ABOUT: "hashtables"
 
index 7d8c6f0b5f85299491fcb27e430b61efcf095ff5..5ac49ffa2fcb56887d28de35ebdc56d26d07bd21 100755 (executable)
@@ -18,14 +18,9 @@ IN: hashtables
 : (key@) ( key keys i -- array n ? )
     3dup swap array-nth
     dup ((empty)) eq?
-      [ 3drop nip f f ]
-      [
-        =
-          [ rot drop t ]
-          [ probe (key@) ]
-        if
-      ]
-    if ; inline
+    [ 3drop nip f f ] [
+        = [ rot drop t ] [ probe (key@) ] if
+    ] if ; inline
 
 : key@ ( key hash -- array n ? )
     hash-array 2dup hash@ (key@) ; inline
@@ -89,17 +84,18 @@ IN: hashtables
         ] if
     ] if ; inline
 
-: find-pair ( array quot -- key value ? ) 0 rot (find-pair) ; inline
+: find-pair ( array quot -- key value ? )
+    0 rot (find-pair) ; inline
 
 : (rehash) ( hash array -- )
     [ swap pick (set-hash) drop f ] find-pair 2drop 2drop ;
 
 : hash-large? ( hash -- ? )
-    dup hash-count 3 fixnum*fast
-    swap hash-array array-capacity > ;
+    [ hash-count 3 fixnum*fast  ]
+    [ hash-array array-capacity ] bi > ;
 
 : hash-stale? ( hash -- ? )
-    dup hash-deleted 10 fixnum*fast swap hash-count fixnum> ;
+    [ hash-deleted 10 fixnum*fast ] [ hash-count ] bi fixnum> ;
 
 : grow-hash ( hash -- )
     [ dup hash-array swap assoc-size 1+ ] keep
@@ -160,7 +156,7 @@ M: hashtable clone
 
 M: hashtable equal?
     over hashtable? [
-        2dup [ assoc-size ] 2apply number=
+        2dup [ assoc-size ] bi@ number=
         [ assoc= ] [ 2drop f ] if
     ] [ 2drop f ] if ;
 
@@ -183,10 +179,13 @@ M: hashtable assoc-like
     [ 3drop ] [ dupd dupd set-at swap push ] if ; inline
 
 : prune ( seq -- newseq )
-    dup length <hashtable> over length <vector>
-    rot [ >r 2dup r> (prune) ] each nip ;
+    [ length <hashtable> ]
+    [ length <vector> ]
+    [ ] tri
+    [ >r 2dup r> (prune) ] each nip ;
 
 : all-unique? ( seq -- ? )
-    dup prune [ length ] 2apply = ;
+    [ length ]
+    [ prune length ] bi = ;
 
 INSTANCE: hashtable assoc
index 0b3123c87b8512e5bb9dea272bd721accb142f5c..77560c7444b0657869bdd6a1b882f9929a288323 100755 (executable)
@@ -66,8 +66,8 @@ IN: heaps.tests
         dup heap-data clone swap
     ] keep 3 /i [ 2dup >r delete-random r> heap-delete ] times
     heap-data
-    [ [ entry-key ] map ] 2apply
-    [ natural-sort ] 2apply ;
+    [ [ entry-key ] map ] bi@
+    [ natural-sort ] bi@ ;
 
 11 [
     [ t ] swap [ 2^ delete-test sequence= ] curry unit-test
index caab0d8f8e85dbe67a503616882d3ac17be289d2..34a4dc0d49766870d42601c5648e799b84d3c45a 100755 (executable)
@@ -2,7 +2,7 @@
 ! Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel math sequences arrays assocs sequences.private
-growable ;
+growable accessors ;
 IN: heaps
 
 MIXIN: priority-queue
@@ -161,7 +161,7 @@ M: priority-queue heap-push* ( value key heap -- entry )
     [ swapd heap-push ] curry assoc-each ;
 
 : >entry< ( entry -- key value )
-    { entry-value entry-key } get-slots ;
+    [ value>> ] [ key>> ] bi ;
 
 M: priority-queue heap-peek ( heap -- value key )
     data-first >entry< ;
index 690571de9821e914b0456cc2e0a1687ba4644850..ed36ca489064ea12d12f2d23fab4d2eeea18f5e7 100755 (executable)
@@ -2,8 +2,8 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: arrays generic assocs hashtables inference kernel
 math namespaces sequences words parser math.intervals
-effects classes inference.dataflow inference.backend
-combinators ;
+effects classes classes.algebra inference.dataflow
+inference.backend combinators ;
 IN: inference.class
 
 ! Class inference
@@ -26,8 +26,8 @@ C: <literal-constraint> literal-constraint
 M: literal-constraint equal?
     over literal-constraint? [
         2dup
-        [ literal-constraint-literal ] 2apply eql? >r
-        [ literal-constraint-value ] 2apply = r> and
+        [ literal-constraint-literal ] bi@ eql? >r
+        [ literal-constraint-value ] bi@ = r> and
     ] [
         2drop f
     ] if ;
@@ -88,8 +88,11 @@ M: interval-constraint apply-constraint
     swap interval-constraint-value intersect-value-interval ;
 
 : set-class-interval ( class value -- )
-    >r "interval" word-prop dup
-    [ r> set-value-interval* ] [ r> 2drop ] if ;
+    over class? [
+        over "interval" word-prop [
+            >r "interval" word-prop r> set-value-interval*
+        ] [ 2drop ] if
+    ] [ 2drop ] if ;
 
 : value-class* ( value -- class )
     value-classes get at object or ;
index 23b5343c9ce399b2eed1ff73ebb6fa15b9522b59..0b6cf040283a79eac079153e5445ddcd0d7a44f7 100755 (executable)
@@ -102,7 +102,7 @@ TUPLE: #label word loop? ;
 : #label ( word label -- node )
     \ #label param-node [ set-#label-word ] keep ;
 
-PREDICATE: #label #loop #label-loop? ;
+PREDICATE: #loop < #label #label-loop? ;
 
 TUPLE: #entry ;
 
@@ -309,9 +309,9 @@ SYMBOL: node-stack
 
 DEFER: #tail?
 
-PREDICATE: #merge #tail-merge node-successor #tail? ;
+PREDICATE: #tail-merge < #merge node-successor #tail? ;
 
-PREDICATE: #values #tail-values node-successor #tail? ;
+PREDICATE: #tail-values < #values node-successor #tail? ;
 
 UNION: #tail
     POSTPONE: f #return #tail-values #tail-merge #terminate ;
index 4f5d19926470d1e47f64efd35cf595eba617f26b..84014512aaf1e5be04b8e2e2fb058029f7c19ff8 100755 (executable)
@@ -3,9 +3,9 @@ inference.dataflow kernel classes kernel.private math
 math.parser math.private namespaces namespaces.private parser
 sequences strings vectors words quotations effects tools.test
 continuations generic.standard sorting assocs definitions
-prettyprint io inspector tuples classes.union classes.predicate
-debugger threads.private io.streams.string io.timeouts
-io.thread sequences.private ;
+prettyprint io inspector classes.tuple classes.union
+classes.predicate debugger threads.private io.streams.string
+io.timeouts io.thread sequences.private ;
 IN: inference.tests
 
 { 0 2 } [ 2 "Hello" ] must-infer-as
@@ -224,7 +224,7 @@ DEFER: do-crap*
 MATH: xyz
 M: fixnum xyz 2array ;
 M: float xyz
-    [ 3 ] 2apply swapd >r 2array swap r> 2array swap ;
+    [ 3 ] bi@ swapd >r 2array swap r> 2array swap ;
 
 [ [ xyz ] infer ] [ inference-error? ] must-fail-with
 
index 08fb56ced7ed22a56d7b6dde95ddff2fdc86976b..79e41c8ae45c2b7b0c29235b051ea01c48332516 100755 (executable)
@@ -9,9 +9,9 @@ kernel.private math math.private memory namespaces
 namespaces.private parser prettyprint quotations
 quotations.private sbufs sbufs.private sequences
 sequences.private slots.private strings strings.private system
-threads.private tuples tuples.private vectors vectors.private
-words words.private assocs inspector compiler.units
-system.private ;
+threads.private classes.tuple classes.tuple.private vectors
+vectors.private words words.private assocs inspector
+compiler.units system.private ;
 IN: inference.known-words
 
 ! Shuffle words
@@ -135,7 +135,7 @@ M: object infer-call
 ! Variadic tuple constructor
 \ <tuple-boa> [
     \ <tuple-boa>
-    peek-d value-literal { tuple } <effect>
+    peek-d value-literal layout-size { tuple } <effect>
     make-call-node
 ] "infer" set-word-prop
 
@@ -565,14 +565,11 @@ set-primitive-effect
 \ quotation-xt { quotation } { integer } <effect> set-primitive-effect
 \ quotation-xt make-flushable
 
-\ <tuple> { word integer } { quotation } <effect> set-primitive-effect
+\ <tuple> { tuple-layout } { tuple } <effect> set-primitive-effect
 \ <tuple> make-flushable
 
-\ (>tuple) { array } { tuple } <effect> set-primitive-effect
-\ (>tuple) make-flushable
-
-\ tuple>array { tuple } { array } <effect> set-primitive-effect
-\ tuple>array make-flushable
+\ <tuple-layout> { word fixnum array fixnum } { tuple-layout } <effect> set-primitive-effect
+\ <tuple-layout> make-foldable
 
 \ datastack { } { array } <effect> set-primitive-effect
 \ datastack make-flushable
index 88aac780c10dbf2b55f5ce1898bf618c3b922b19..cb8024d3c5a29b952a586734039d774e2d21ae85 100755 (executable)
@@ -1,6 +1,6 @@
 IN: inference.transforms.tests
 USING: sequences inference.transforms tools.test math kernel
-quotations inference ;
+quotations inference accessors combinators words arrays ;
 
 : compose-n-quot <repetition> >quotation ;
 : compose-n compose-n-quot call ;
@@ -32,3 +32,27 @@ TUPLE: a-tuple x y z ;
     { set-a-tuple-x set-a-tuple-x } set-slots ;
 
 [ [ set-slots-test-2 ] infer ] must-fail
+
+TUPLE: color r g b ;
+
+C: <color> color
+
+: cleave-test { [ r>> ] [ g>> ] [ b>> ] } cleave ;
+
+{ 1 3 } [ cleave-test ] must-infer-as
+
+[ 1 2 3 ] [ 1 2 3 <color> cleave-test ] unit-test
+
+[ 1 2 3 ] [ 1 2 3 <color> \ cleave-test word-def call ] unit-test
+
+: 2cleave-test { [ 2array ] [ + ] [ - ] } 2cleave ;
+
+[ { 1 2 } 3 -1 ] [ 1 2 2cleave-test ] unit-test
+
+[ { 1 2 } 3 -1 ] [ 1 2 \ 2cleave-test word-def call ] unit-test
+
+: spread-test { [ sq ] [ neg ] [ recip ] } spread ;
+
+[ 16 -3 1/6 ] [ 4 3 6 spread-test ] unit-test
+
+[ 16 -3 1/6 ] [ 4 3 6 \ spread-test word-def call ] unit-test
index a829bad47efbef1dbd52054bad45f19f5e20f079..200208c6a5be9eb1032121134ee74f8277d545ea 100755 (executable)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: arrays kernel words sequences generic math namespaces
 quotations assocs combinators math.bitfields inference.backend
-inference.dataflow inference.state tuples.private effects
+inference.dataflow inference.state classes.tuple.private effects
 inspector hashtables ;
 IN: inference.transforms
 
@@ -39,6 +39,12 @@ IN: inference.transforms
     ] if
 ] 1 define-transform
 
+\ cleave [ cleave>quot ] 1 define-transform
+
+\ 2cleave [ 2cleave>quot ] 1 define-transform
+
+\ spread [ spread>quot ] 1 define-transform
+
 ! Bitfields
 GENERIC: (bitfield-quot) ( spec -- quot )
 
@@ -76,7 +82,7 @@ M: duplicated-slots-error summary
 
 \ construct-boa [
     dup +inlined+ depends-on
-    dup tuple-size [ <tuple-boa> ] 2curry
+    tuple-layout [ <tuple-boa> ] curry
 ] 1 define-transform
 
 \ construct-empty [
@@ -84,7 +90,7 @@ M: duplicated-slots-error summary
     peek-d value? [
         pop-literal
         dup +inlined+ depends-on
-        dup tuple-size [ <tuple> ] 2curry
+        tuple-layout [ <tuple> ] curry
         swap infer-quot
     ] [
         \ construct-empty 1 1 <effect> make-call-node
index 1595ecd576a4db126966e41c0674d2c24bc704cd..6bcd4483856ecedf516a077d62cb65b9410be7d9 100755 (executable)
@@ -1,6 +1,7 @@
 ! Copyright (C) 2007, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: init kernel system namespaces io io.encodings io.encodings.utf8 ;
+USING: init kernel system namespaces io io.encodings
+io.encodings.utf8 init assocs ;
 IN: io.backend
 
 SYMBOL: io-backend
@@ -17,14 +18,13 @@ HOOK: io-multiplex io-backend ( ms -- )
 
 HOOK: normalize-directory io-backend ( str -- newstr )
 
-M: object normalize-directory ;
-
 HOOK: normalize-pathname io-backend ( str -- newstr )
 
-M: object normalize-pathname ;
+M: object normalize-directory normalize-pathname ;
 
 : set-io-backend ( io-backend -- )
-    io-backend set-global init-io init-stdio ;
+    io-backend set-global init-io init-stdio
+    "io.files" init-hooks get at call ;
 
 [ init-io embedded? [ init-stdio ] unless ]
 "io.backend" add-init-hook
index 823eea67be19c18883bedcbb92a821435a999673..fdd9828867c6e060d7dc77e5d84912ec48219d5e 100644 (file)
@@ -2,4 +2,7 @@ USING: help.syntax help.markup ;
 IN: io.encodings.binary
 
 HELP: binary
-{ $class-description "This is the encoding descriptor for binary I/O. Making an encoded stream with the binary encoding is a no-op; streams with this encoding deal with byte-arrays, not strings." } ;
+{ $class-description "This is the encoding descriptor for binary I/O. Making an encoded stream with the binary encoding is a no-op; streams with this encoding deal with byte-arrays, not strings." }
+{ $see-also "encodings-introduction" } ;
+
+ABOUT: binary
index fd5ddaa82d3d65912339618c9fce7a4e71611d7a..bdd9e56d87df19a0bf065c1b6251cab45db1ac90 100644 (file)
@@ -1,15 +1,16 @@
 USING: help.markup help.syntax ;
 IN: io.encodings
 
-ABOUT: "encodings"
+ABOUT: "io.encodings"
 
 ARTICLE: "io.encodings" "I/O encodings"
-"Many streams deal with bytes, rather than Unicode code points, at some level. The translation between these two things is specified by an encoding. To abstract this away from the programmer, Factor provides a system where these streams are associated with an encoding which is always used when the stream is read from or written to. For most purposes, an encoding descriptor consisting of a symbol is all that is needed when initializing a stream."
+"Bytes can't be understood in isolation as text. They must be interpreted under a certain encoding. Factor provides utilities for dealing with encoded text by declaring that a stream has a particular encoding, and utilities to encode and decode strings."
 { $subsection "encodings-constructors" }
 { $subsection "encodings-descriptors" }
 { $subsection "encodings-protocol" } ;
 
-ARTICLE: "encodings-constructors" "Constructing an encoded stream"
+ARTICLE: "encodings-constructors" "Manually constructing an encoded stream"
+"The following words can be used to construct encoded streams. Note that they are usually not used directly, but rather by the stream constructors themselves. Most stream constructors take an encoding descriptor as a parameter and internally call these constructors."
 { $subsection <encoder> }
 { $subsection <decoder> }
 { $subsection <encoder-duplex> } ;
@@ -18,47 +19,56 @@ HELP: <encoder>
 { $values { "stream" "an output stream" }
     { "encoding" "an encoding descriptor" }
     { "newstream" "an encoded output stream" } }
-{ $description "Wraps the given stream in a new stream using the given encoding for all output. The encoding descriptor can either be a class or an instance of something conforming to the " { $link "encodings-protocol" } "." } ;
+{ $description "Wraps the given stream in a new stream using the given encoding for all output. The encoding descriptor can either be a class or an instance of something conforming to the " { $link "encodings-protocol" } "." }
+$low-level-note ;
 
 HELP: <decoder>
 { $values { "stream" "an input stream" }
     { "encoding" "an encoding descriptor" }
     { "newstream" "an encoded output stream" } }
-{ $description "Wraps the given stream in a new stream using the given encoding for all input. The encoding descriptor can either be a class or an instance of something conforming to the " { $link "encodings-protocol" } "." } ;
+{ $description "Wraps the given stream in a new stream using the given encoding for all input. The encoding descriptor can either be a class or an instance of something conforming to the " { $link "encodings-protocol" } "." }
+$low-level-note ;
 
 HELP: <encoder-duplex>
 { $values { "stream-in" "an input stream" }
     { "stream-out" "an output stream" }
     { "encoding" "an encoding descriptor" }
     { "duplex" "an encoded duplex stream" } }
-{ $description "Wraps the given streams in an encoder or decoder stream, and puts them together in a duplex stream for input and output. If either input stream is already encoded, that encoding is stripped off before it is reencoded. The encoding descriptor must conform to the " { $link "encodings-protocol" } "." } ;
+{ $description "Wraps the given streams in an encoder or decoder stream, and puts them together in a duplex stream for input and output. If either input stream is already encoded, that encoding is stripped off before it is reencoded. The encoding descriptor must conform to the " { $link "encodings-protocol" } "." }
+$low-level-note ;
 
 { <encoder> <decoder> <encoder-duplex> } related-words
 
 ARTICLE: "encodings-descriptors" "Encoding descriptors"
 "An encoding descriptor is something which can be used for input or output streams to encode or decode files. It must conform to the " { $link "encodings-protocol" } ". Encodings which you can use are defined in the following vocabularies:"
-$nl { $vocab-link "io.encodings.utf8" }
-$nl { $vocab-link "io.encodings.ascii" }
-$nl { $vocab-link "io.encodings.binary" }
-$nl { $vocab-link "io.encodings.utf16" } ;
+{ $vocab-subsection "ASCII" "io.encodings.ascii" }
+{ $vocab-subsection "Binary" "io.encodings.binary" }
+{ $vocab-subsection "Strict encodings" "io.encodings.strict" }
+{ $vocab-subsection "8-bit encodings" "io.encodings.8-bit" }
+{ $vocab-subsection "UTF-8" "io.encodings.utf8" }
+{ $vocab-subsection "UTF-16" "io.encodings.utf16" }
+{ $see-also "encodings-introduction" } ;
 
 ARTICLE: "encodings-protocol" "Encoding protocol"
-"An encoding descriptor must implement the following methods. The methods are implemented on tuple classes by instantiating the class and calling the method again."
+"There are two parts to implementing a new encoding. First, methods for creating an encoded or decoded stream must be provided. These have defaults, however, which wrap a stream in an encoder or decoder wrapper with the given encoding descriptor."
+{ $subsection <encoder> }
+{ $subsection <decoder> }
+"If an encoding might be contained in the code slot of an encoder or decoder tuple, then the following methods must be implemented to read or write one code point from a stream:"
 { $subsection decode-char }
 { $subsection encode-char }
-"The following methods are optional:"
-{ $subsection <encoder> }
-{ $subsection <decoder> } ;
+{ $see-also "encodings-introduction" } ;
 
 HELP: decode-char
 { $values { "stream" "an underlying input stream" }
     { "encoding" "An encoding descriptor tuple" } { "char/f" "a code point or " { $link f } } }
-{ $description "Reads a single code point from the underlying stream, interpreting it by the encoding. This should not be used directly." } ;
+{ $contract "Reads a single code point from the underlying stream, interpreting it by the encoding." }
+$low-level-note ;
 
 HELP: encode-char
 { $values { "char" "a character" }
     { "stream" "an underlying output stream" }
     { "encoding" "an encoding descriptor" } }
-{ $description "Writes the code point in the encoding to the underlying stream given. This should not be used directly." } ;
+{ $contract "Writes the code point in the encoding to the underlying stream given." }
+$low-level-note ;
 
 { encode-char decode-char } related-words
index 73d2efa7d476d86c399421dc28f8415c65e69c44..397d1ea89c3b40b40dd4784debfc1f2755cc4014 100755 (executable)
@@ -6,7 +6,7 @@ IN: io.streams.encodings.tests
     resource-path ascii <file-reader> ;
     
 [ { } ]
-[ "/core/io/test/empty-file.txt" <resource-reader> lines ]
+[ "core/io/test/empty-file.txt" <resource-reader> lines ]
 unit-test
 
 : lines-test ( stream -- line1 line2 )
@@ -16,21 +16,21 @@ unit-test
     "This is a line."
     "This is another line."
 ] [
-    "/core/io/test/windows-eol.txt" <resource-reader> lines-test
+    "core/io/test/windows-eol.txt" <resource-reader> lines-test
 ] unit-test
 
 [
     "This is a line."
     "This is another line."
 ] [
-    "/core/io/test/mac-os-eol.txt" <resource-reader> lines-test
+    "core/io/test/mac-os-eol.txt" <resource-reader> lines-test
 ] unit-test
 
 [
     "This is a line."
     "This is another line."
 ] [
-    "/core/io/test/unix-eol.txt" <resource-reader> lines-test
+    "core/io/test/unix-eol.txt" <resource-reader> lines-test
 ] unit-test
 
 [
index a781b63ad58d0090aabb307215e69ddf73b917e2..2ef26096e08234f46975632beb19119e9e8c7a62 100755 (executable)
@@ -1,9 +1,9 @@
 ! Copyright (C) 2008 Daniel Ehrenberg.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: math kernel sequences sbufs vectors namespaces
-growable strings io classes continuations combinators
-io.styles io.streams.plain splitting
-io.streams.duplex byte-arrays sequences.private ;
+USING: math kernel sequences sbufs vectors namespaces growable
+strings io classes continuations combinators io.styles
+io.streams.plain splitting io.streams.duplex byte-arrays
+sequences.private accessors ;
 IN: io.encodings
 
 ! The encoding descriptor protocol
@@ -34,7 +34,7 @@ M: tuple-class <decoder> construct-empty <decoder> ;
 M: tuple <decoder> f decoder construct-boa ;
 
 : >decoder< ( decoder -- stream encoding )
-    { decoder-stream decoder-code } get-slots ;
+    [ stream>> ] [ code>> ] bi ;
 
 : cr+ t swap set-decoder-cr ; inline
 
@@ -108,7 +108,7 @@ M: tuple-class <encoder> construct-empty <encoder> ;
 M: tuple <encoder> encoder construct-boa ;
 
 : >encoder< ( encoder -- stream encoding )
-    { encoder-stream encoder-code } get-slots ;
+    [ stream>> ] [ code>> ] bi ;
 
 M: encoder stream-write1
     >encoder< encode-char ;
index dbbc193a02f91fb461cb36f33c5eeb35f75dafa0..7a29039eca25688348a293b578a68d60eb70b1f4 100755 (executable)
@@ -1,11 +1,8 @@
-USING: help.markup help.syntax io.encodings strings io.files ;
+USING: help.markup help.syntax ;
 IN: io.encodings.utf8
 
-ARTICLE: "io.encodings.utf8" "Working with UTF8-encoded data"
-"The UTF8 encoding is a variable-width encoding. 7-bit ASCII characters are encoded as single bytes, and other Unicode code points are encoded as 2 to 4 byte sequences. The encoding descriptor for UTF-8:"
-{ $subsection utf8 } ;
-
 HELP: utf8
-{ $class-description "This is the class of encoding tuples which denote a UTF-8 encoding. This conforms to the " { $link "encodings-protocol" } "." } ;
+{ $class-description "This is the encoding descriptor for a UTF-8 encoding. UTF-8 is a variable-width encoding. 7-bit ASCII characters are encoded as single bytes, and other Unicode code points are encoded as 2 to 4 byte sequences." }
+{ $see-also "encodings-introduction" } ;
 
-ABOUT: "io.encodings.utf8"
+ABOUT: utf8
index 1a3bde0e5cf2b67b935414a63bf58f28622fbefe..195356922331c6f495a1b368f3b270ba8169b88e 100755 (executable)
@@ -20,9 +20,6 @@ ARTICLE: "pathnames" "Pathname manipulation"
 { $subsection file-name }
 { $subsection last-path-separator }
 { $subsection append-path }
-"Pathnames relative to Factor's install directory:"
-{ $subsection resource-path }
-{ $subsection ?resource-path }
 "Pathnames relative to Factor's temporary files directory:"
 { $subsection temp-directory }
 { $subsection temp-file }
@@ -248,12 +245,6 @@ HELP: resource-path
 { $values { "path" "a pathname string" } { "newpath" "a pathname string" } }
 { $description "Resolve a path relative to the Factor source code location. This first checks if the " { $link resource-path } " variable is set to a path, and if not, uses the parent directory of the current image." } ;
 
-HELP: ?resource-path
-{ $values { "path" "a pathname string" } { "newpath" "a string" } }
-{ $description "If the path is prefixed with " { $snippet "\"resource:\"" } ", prepends the resource path." } ;
-
-{ resource-path ?resource-path } related-words
-
 HELP: pathname
 { $class-description "Class of pathname presentations. Path name presentations can be created by calling " { $link <pathname> } ". Instances can be passed to " { $link write-object } " to output a clickable pathname." } ;
 
index 4cda463983880016c30628b4cb333f58fe7d894b..9920d8d25cc9ef4abe93b0868ee98099c49b838a 100755 (executable)
@@ -1,14 +1,66 @@
 IN: io.files.tests
-USING: tools.test io.files io threads kernel continuations io.encodings.ascii
-io.files.unique sequences strings accessors ;
+USING: tools.test io.files io threads kernel continuations
+io.encodings.ascii io.files.unique sequences strings accessors
+io.encodings.utf8 ;
 
 [ ] [ "blahblah" temp-file dup exists? [ delete-directory ] [ drop ] if ] unit-test
 [ ] [ "blahblah" temp-file make-directory ] unit-test
 [ t ] [ "blahblah" temp-file directory? ] unit-test
 
+[ t ] [
+    [ temp-directory "loldir" append-path delete-directory ] ignore-errors
+    temp-directory [
+        "loldir" make-directory
+    ] with-directory
+    temp-directory "loldir" append-path exists?
+] unit-test
+
+[ ] [
+    [ temp-directory "loldir" append-path delete-directory ] ignore-errors
+    temp-directory [
+        "loldir" make-directory
+        "loldir" delete-directory
+    ] with-directory
+] unit-test
+
+[ "file1 contents" ] [
+    [ temp-directory "loldir" append-path delete-directory ] ignore-errors
+    temp-directory [
+        "file1 contents" "file1" utf8 set-file-contents
+        "file1" "file2" copy-file
+        "file2" utf8 file-contents
+    ] with-directory
+    "file1" temp-file delete-file
+    "file2" temp-file delete-file
+] unit-test
+
+[ "file3 contents" ] [
+    temp-directory [
+        "file3 contents" "file3" utf8 set-file-contents
+        "file3" "file4" move-file
+        "file4" utf8 file-contents
+    ] with-directory
+    "file4" temp-file delete-file
+] unit-test
+
+[ ] [
+    temp-directory [
+        "file5" touch-file
+        "file5" delete-file
+    ] with-directory
+] unit-test
+
+[ ] [
+    temp-directory [
+        "file6" touch-file
+        "file6" link-info drop
+    ] with-directory
+] unit-test
+
 [ "passwd" ] [ "/etc/passwd" file-name ] unit-test
 [ "awk" ] [ "/usr/libexec/awk/" file-name ] unit-test
 [ "awk" ] [ "/usr/libexec/awk///" file-name ] unit-test
+[ "" ] [ "" file-name ] unit-test
 
 [ ] [
     { "Hello world." }
@@ -65,7 +117,7 @@ io.files.unique sequences strings accessors ;
 
 [ ] [ "test-quux.txt" temp-file ascii [ [ yield "Hi" write ] "Test" spawn drop ] with-file-writer ] unit-test
 
-[ ] [ "test-quux.txt" "quux-test.txt" [ temp-file ] 2apply move-file ] unit-test
+[ ] [ "test-quux.txt" "quux-test.txt" [ temp-file ] bi@ move-file ] unit-test
 [ t ] [ "quux-test.txt" temp-file exists? ] unit-test
 
 [ ] [ "quux-test.txt" temp-file delete-file ] unit-test
@@ -81,6 +133,18 @@ io.files.unique sequences strings accessors ;
     "delete-tree-test" temp-file delete-tree
 ] unit-test
 
+[ { { "kernel" t } } ] [
+    "core" resource-path [
+        "." directory [ first "kernel" = ] subset
+    ] with-directory
+] unit-test
+
+[ { { "kernel" t } } ] [
+    "resource:core" [
+        "." directory [ first "kernel" = ] subset
+    ] with-directory
+] unit-test
+
 [ ] [
     "copy-tree-test/a/b/c" temp-file make-directories
 ] unit-test
@@ -129,6 +193,15 @@ io.files.unique sequences strings accessors ;
 
 [ t ] [ cwd "misc" resource-path [ ] with-directory cwd = ] unit-test
 
+[ t ] [
+    temp-directory [ "hi41" "test41" utf8 set-file-contents ] with-directory
+    temp-directory "test41" append-path utf8 file-contents "hi41" =
+] unit-test
+
+[ t ] [
+    temp-directory [ "test41" file-info size>> ] with-directory 4 =
+] unit-test
+
 [ ] [ "append-test" temp-file dup exists? [ delete-file ] [ drop ] if ] unit-test
 
 [ ] [ "append-test" temp-file ascii <file-appender> dispose ] unit-test
@@ -144,3 +217,51 @@ io.files.unique sequences strings accessors ;
         ] keep file-info size>>
     ] with-unique-file
 ] unit-test
+
+[ "/usr/lib" ] [ "/usr" "lib" append-path ] unit-test
+[ "/usr/lib" ] [ "/usr/" "lib" append-path ] unit-test
+[ "/lib" ] [ "/usr/" "/lib" append-path ] unit-test
+[ "/lib/" ] [ "/usr/" "/lib/" append-path ] unit-test
+[ "/usr/lib" ] [ "/usr" "./lib" append-path ] unit-test
+[ "/usr/lib/" ] [ "/usr" "./lib/" append-path ] unit-test
+[ "/lib" ] [ "/usr" "../lib" append-path ] unit-test
+[ "/lib/" ] [ "/usr" "../lib/" append-path ] unit-test
+
+[ "" ] [ "" "." append-path ] unit-test
+[ "" ".." append-path ] must-fail
+
+[ "/" ] [ "/" "./." append-path ] unit-test
+[ "/" ] [ "/" "././" append-path ] unit-test
+[ "/a/b/lib" ] [ "/a/b/c/d/e/f/" "../../../../lib" append-path ] unit-test
+[ "/a/b/lib/" ] [ "/a/b/c/d/e/f/" "../../../../lib/" append-path ] unit-test
+
+[ "" "../lib/" append-path ] must-fail
+[ "lib" ] [ "" "lib" append-path ] unit-test
+[ "lib" ] [ "" "./lib" append-path ] unit-test
+
+[ "/lib/bux" ] [ "/usr" "/lib/bux" append-path ] unit-test
+[ "/lib/bux/" ] [ "/usr" "/lib/bux/" append-path ] unit-test
+
+[ "foo/bar/." parent-directory ] must-fail
+[ "foo/bar/./" parent-directory ] must-fail
+[ "foo/bar/baz/.." parent-directory ] must-fail
+[ "foo/bar/baz/../" parent-directory ] must-fail
+
+[ "." parent-directory ] must-fail
+[ "./" parent-directory ] must-fail
+[ ".." parent-directory ] must-fail
+[ "../" parent-directory ] must-fail
+[ "../../" parent-directory ] must-fail
+[ "foo/.." parent-directory ] must-fail
+[ "foo/../" parent-directory ] must-fail
+[ "" parent-directory ] must-fail
+[ "." ] [ "boot.x86.64.image" parent-directory ] unit-test
+
+[ "bar/foo" ] [ "bar/baz" "..///foo" append-path ] unit-test
+[ "bar/baz/foo" ] [ "bar/baz" ".///foo" append-path ] unit-test
+[ "bar/foo" ] [ "bar/baz" "./..//foo" append-path ] unit-test
+[ "bar/foo" ] [ "bar/baz" "./../././././././///foo" append-path ] unit-test
+
+[ t ] [ "resource:core" absolute-path? ] unit-test
+[ t ] [ "/foo" absolute-path? ] unit-test
+[ f ] [ "" absolute-path? ] unit-test
index 21cc7c8f0a9833def30f908641ebdbbcee59e623..48098e612d10cd341cffaf0b752a3da4b2fd3a77 100755 (executable)
@@ -3,7 +3,7 @@
 USING: io.backend io.files.private io hashtables kernel math
 memory namespaces sequences strings assocs arrays definitions
 system combinators splitting sbufs continuations io.encodings
-io.encodings.binary ;
+io.encodings.binary init ;
 IN: io.files
 
 HOOK: (file-reader) io-backend ( path -- stream )
@@ -13,61 +13,135 @@ HOOK: (file-writer) io-backend ( path -- stream )
 HOOK: (file-appender) io-backend ( path -- stream )
 
 : <file-reader> ( path encoding -- stream )
-    swap (file-reader) swap <decoder> ;
+    swap normalize-pathname (file-reader) swap <decoder> ;
 
 : <file-writer> ( path encoding -- stream )
-    swap (file-writer) swap <encoder> ;
+    swap normalize-pathname (file-writer) swap <encoder> ;
 
 : <file-appender> ( path encoding -- stream )
-    swap (file-appender) swap <encoder> ;
+    swap normalize-pathname (file-appender) swap <encoder> ;
 
-HOOK: rename-file io-backend ( from to -- )
+: file-lines ( path encoding -- seq )
+    <file-reader> lines ;
+
+: with-file-reader ( path encoding quot -- )
+    >r <file-reader> r> with-stream ; inline
+
+: file-contents ( path encoding -- str )
+    <file-reader> contents ;
+
+: with-file-writer ( path encoding quot -- )
+    >r <file-writer> r> with-stream ; inline
+
+: set-file-lines ( seq path encoding -- )
+    [ [ print ] each ] with-file-writer ;
+
+: set-file-contents ( str path encoding -- )
+    [ write ] with-file-writer ;
+
+: with-file-appender ( path encoding quot -- )
+    >r <file-appender> r> with-stream ; inline
 
 ! Pathnames
 : path-separator? ( ch -- ? ) windows? "/\\" "/" ? member? ;
 
+: path-separator ( -- string ) windows? "\\" "/" ? ;
+
 : right-trim-separators ( str -- newstr )
     [ path-separator? ] right-trim ;
 
 : left-trim-separators ( str -- newstr )
     [ path-separator? ] left-trim ;
 
-: append-path ( str1 str2 -- str )
-    >r right-trim-separators "/" r>
-    left-trim-separators 3append ;
-
-: prepend-path ( str1 str2 -- str )
-    swap append-path ; inline
-
 : last-path-separator ( path -- n ? )
     [ length 1- ] keep [ path-separator? ] find-last* ;
 
 HOOK: root-directory? io-backend ( path -- ? )
 
-M: object root-directory? ( path -- ? ) path-separator? ;
-
-: special-directory? ( name -- ? ) { "." ".." } member? ;
+M: object root-directory? ( path -- ? )
+    dup empty? [ drop f ] [ [ path-separator? ] all? ] if ;
 
 ERROR: no-parent-directory path ;
 
 : parent-directory ( path -- parent )
-    right-trim-separators {
-        { [ dup empty? ] [ drop "/" ] }
-        { [ dup root-directory? ] [ ] }
-        { [ dup [ path-separator? ] contains? not ] [ drop "." ] }
+    dup root-directory? [
+        right-trim-separators
+        dup last-path-separator [
+            1+ cut
+        ] [
+            drop "." swap
+        ] if
+        { "" "." ".." } member? [
+            no-parent-directory
+        ] when
+    ] unless ;
+
+<PRIVATE
+
+: head-path-separator? ( path1 ? -- ?' )
+    [
+        dup empty? [ drop t ] [ first path-separator? ] if
+    ] [
+        drop f
+    ] if ;
+
+: head.? ( path -- ? ) "." ?head head-path-separator? ;
+
+: head..? ( path -- ? ) ".." ?head head-path-separator? ;
+
+: append-path-empty ( path1 path2 -- path' )
+    {
+        { [ dup head.? ] [
+            1 tail left-trim-separators append-path-empty
+        ] }
+        { [ dup head..? ] [ drop no-parent-directory ] }
+        { [ t ] [ nip ] }
+    } cond ;
+
+PRIVATE>
+
+: windows-absolute-path? ( path -- path ? )
+    {
+        { [ dup length 2 < ] [ f ] }
+        { [ dup second CHAR: : = ] [ t ] }
+        { [ t ] [ f ] }
+    } cond ;
+
+: absolute-path? ( path -- ? )
+    {
+        { [ dup empty? ] [ f ] }
+        { [ dup "resource:" head? ] [ t ] }
+        { [ dup first path-separator? ] [ t ] }
+        { [ windows? ] [ windows-absolute-path? ] }
+        { [ t ] [ f ] }
+    } cond nip ;
+
+: append-path ( str1 str2 -- str )
+    {
+        { [ over empty? ] [ append-path-empty ] }
+        { [ dup empty? ] [ drop ] }
+        { [ dup absolute-path? ] [ nip ] }
+        { [ dup head.? ] [ 1 tail left-trim-separators append-path ] }
+        { [ dup head..? ] [
+            2 tail left-trim-separators
+            >r parent-directory r> append-path
+        ] }
         { [ t ] [
-            dup last-path-separator drop 1+ cut
-            special-directory? [ no-parent-directory ] when
+            >r right-trim-separators "/" r>
+            left-trim-separators 3append
         ] }
     } cond ;
 
+: prepend-path ( str1 str2 -- str )
+    swap append-path ; inline
+
 : file-name ( path -- string )
-    right-trim-separators {
-        { [ dup empty? ] [ drop "/" ] }
-        { [ dup last-path-separator ] [ 1+ tail ] }
-        { [ t ] [ drop ] }
-    } cond ;
+    dup root-directory? [
+        right-trim-separators
+        dup last-path-separator [ 1+ tail ] [ drop ] if
+    ] unless ;
 
+! File info
 TUPLE: file-info type size permissions modified ;
 
 HOOK: file-info io-backend ( path -- info )
@@ -94,8 +168,18 @@ HOOK: cd io-backend ( path -- )
 
 HOOK: cwd io-backend ( -- path )
 
+SYMBOL: current-directory
+
+M: object cwd ( -- path ) "." ;
+
+[ cwd current-directory set-global ] "io.files" add-init-hook
+
 : with-directory ( path quot -- )
-    cwd [ cd ] curry rot cd [ ] cleanup ; inline
+    >r normalize-pathname r>
+    current-directory swap with-variable ; inline
+
+: set-current-directory ( path -- )
+    normalize-pathname current-directory set ;
 
 ! Creating directories
 HOOK: make-directory io-backend ( path -- )
@@ -118,7 +202,7 @@ HOOK: make-directory io-backend ( path -- )
         dup string?
         [ tuck append-path directory? 2array ] [ nip ] if
     ] with map
-    [ first special-directory? not ] subset ;
+    [ first { "." ".." } member? not ] subset ;
 
 : directory ( path -- seq )
     normalize-directory dup (directory) fixup-directory ;
@@ -193,11 +277,19 @@ DEFER: copy-tree-into
     "resource-path" get [ image parent-directory ] unless*
     prepend-path ;
 
-: ?resource-path ( path -- newpath )
-    "resource:" ?head [ resource-path ] when ;
+: temp-directory ( -- path )
+    "temp" resource-path dup make-directories ;
 
-: resource-exists? ( path -- ? )
-    ?resource-path exists? ;
+: temp-file ( name -- path )
+    temp-directory prepend-path ;
+
+M: object normalize-pathname ( path -- path' )
+    "resource:" ?head [
+        left-trim-separators resource-path
+        normalize-pathname
+    ] [
+        current-directory get prepend-path
+    ] if ;
 
 ! Pathname presentations
 TUPLE: pathname string ;
@@ -206,35 +298,6 @@ C: <pathname> pathname
 
 M: pathname <=> [ pathname-string ] compare ;
 
-: file-lines ( path encoding -- seq )
-    <file-reader> lines ;
-
-: with-file-reader ( path encoding quot -- )
-    >r <file-reader> r> with-stream ; inline
-
-: file-contents ( path encoding -- str )
-    <file-reader> contents ;
-
-: with-file-writer ( path encoding quot -- )
-    >r <file-writer> r> with-stream ; inline
-
-: set-file-lines ( seq path encoding -- )
-    [ [ print ] each ] with-file-writer ;
-
-: set-file-contents ( str path encoding -- )
-    [ write ] with-file-writer ;
-
-: with-file-appender ( path encoding quot -- )
-    >r <file-appender> r> with-stream ; inline
-
-: temp-directory ( -- path )
-    "temp" resource-path
-    dup exists? not
-      [ dup make-directory ]
-    when ;
-
-: temp-file ( name -- path ) temp-directory prepend-path ;
-
 ! Home directory
 : home ( -- dir )
     {
index 8a9089a564bb56bc9675977d50d3359f79a2ddac..b7d1cf81c875567381ec16ec595d0bd33cfb5227 100755 (executable)
@@ -1,10 +1,10 @@
 USING: arrays io io.files kernel math parser strings system
-tools.test words namespaces io.encodings.latin1
+tools.test words namespaces io.encodings.8-bit
 io.encodings.binary ;
 IN: io.tests
 
 [ f ] [
-    "resource:/core/io/test/no-trailing-eol.factor" run-file
+    "resource:core/io/test/no-trailing-eol.factor" run-file
     "foo" "io.tests" lookup
 ] unit-test
 
@@ -14,14 +14,14 @@ IN: io.tests
 [
     "This is a line.\rThis is another line.\r"
 ] [
-    "/core/io/test/mac-os-eol.txt" <resource-reader>
+    "core/io/test/mac-os-eol.txt" <resource-reader>
     [ 500 read ] with-stream
 ] unit-test
 
 [
     255
 ] [
-    "/core/io/test/binary.txt" <resource-reader>
+    "core/io/test/binary.txt" <resource-reader>
     [ read1 ] with-stream >fixnum
 ] unit-test
 
@@ -36,7 +36,7 @@ IN: io.tests
     }
 ] [
     [
-        "/core/io/test/separator-test.txt" <resource-reader> [
+        "core/io/test/separator-test.txt" <resource-reader> [
             "J" read-until 2array ,
             "i" read-until 2array ,
             "X" read-until 2array ,
index 0babb14fa75ce99edb886bea2dce410c77ba4e7c..a4468690967e9a8ae5b1e88ce0c05f6d5505e504 100755 (executable)
@@ -43,29 +43,86 @@ $nl
 "An alternative to using " { $link >r } " and " { $link r> } " is the following:"
 { $subsection dip } ;
 
-ARTICLE: "basic-combinators" "Basic combinators"
-"The following pair of words invoke words and quotations reflectively:"
-{ $subsection call }
-{ $subsection execute }
-"These words are used to implement " { $emphasis "combinators" } ", which are words that take code from the stack. Note that combinator definitions must be followed by the " { $link POSTPONE: inline } " declaration in order to compile in the optimizing compiler; for example:"
+ARTICLE: "cleave-combinators" "Cleave combinators"
+"The cleave combinators apply multiple quotations to a single value."
+$nl
+"Two quotations:"
+{ $subsection bi }
+{ $subsection 2bi }
+"Three quotations:"
+{ $subsection tri }
+{ $subsection 2tri }
+"Technically, the cleave combinators are redundant because they can be simulated using shuffle words and other combinators, and in addition, they do not reduce token counts by much, if at all. However, they can make code more readable by expressing intention and exploiting any inherent symmetry. For example, a piece of code which performs three operations on the top of the stack can be written in one of two ways:"
 { $code
-    ": keep ( x quot -- x )"
-    "    over >r call r> ; inline"
+    "! First alternative; uses keep"
+    "[ 1 + ] keep"
+    "[ 1 - ] keep"
+    "2 *"
+    "! Second alternative: uses tri"
+    "[ 1 + ]"
+    "[ 1 - ]"
+    "[ 2 * ] tri"
 }
-"Word inlining is documented in " { $link "declarations" } "."
+"The latter is more aesthetically pleasing than the former."
 $nl
-"There are some words that combine shuffle words with " { $link call } ". They are useful for implementing higher-level combinators."
+"A generalization of the above combinators to any number of quotations can be found in " { $link "combinators" } "."
+$nl
+"From the Merriam-Webster Dictionary: "
+$nl
+{ $strong "cleave" }
+{ $list
+  { $emphasis "To divide by or as if by a cutting blow" }
+  { $emphasis "To separate into distinct parts and especially into groups having divergent views" }
+} ;
+
+ARTICLE: "spread-combinators" "Spread combinators"
+"The spread combinators apply multiple quotations to multiple values. The " { $snippet "*" } " suffix signifies spreading."
+$nl
+"Two quotations:"
+{ $subsection bi* }
+{ $subsection 2bi* }
+"Three quotations:"
+{ $subsection tri* }
+"Technically, the spread combinators are redundant because they can be simulated using shuffle words and other combinators, and in addition, they do not reduce token counts by much, if at all. However, they can make code more readable by expressing intention and exploiting any inherent symmetry. For example, a piece of code which performs three operations on three related values can be written in one of two ways:"
+{ $code
+    "! First alternative; uses retain stack explicitly"
+    ">r >r 1 +"
+    "r> 1 -"
+    "r> 2 *"
+    "! Second alternative: uses tri*"
+    "[ 1 + ]"
+    "[ 1 - ]"
+    "[ 2 * ] tri*"
+}
+
+$nl
+"A generalization of the above combinators to any number of quotations can be found in " { $link "combinators" } "." ;
+
+ARTICLE: "apply-combinators" "Apply combinators"
+"The apply combinators apply multiple quotations to multiple values. The " { $snippet "@" } " suffix signifies application."
+$nl
+"Two quotations:"
+{ $subsection bi@ }
+{ $subsection 2bi@ }
+"Three quotations:"
+{ $subsection tri@ }
+"A pair of utility words built from " { $link bi@ } ":"
+{ $subsection both? }
+{ $subsection either? } ;
+
+ARTICLE: "slip-keep-combinators" "The slip and keep combinators"
+"The slip combinators invoke a quotation further down on the stack. They are most useful for implementing other combinators:"
 { $subsection slip }
 { $subsection 2slip }
+{ $subsection 3slip }
+"The dip combinator invokes the quotation at the top of the stack, hiding the value underneath:"
+{ $subsection dip }
+"The keep combinators invoke a quotation which takes a number of values off the stack, and then they restore those values:"
 { $subsection keep }
 { $subsection 2keep }
-{ $subsection 3keep }
-{ $subsection 2apply }
-"A pair of utility words built from " { $link 2apply } ":"
-{ $subsection both? }
-{ $subsection either? }
-"A looping combinator:"
-{ $subsection while }
+{ $subsection 3keep } ;
+
+ARTICLE: "compositional-combinators" "Compositional combinators"
 "Quotations can be composed using efficient quotation-specific operations:"
 { $subsection curry }
 { $subsection 2curry }
@@ -73,8 +130,21 @@ $nl
 { $subsection with }
 { $subsection compose }
 { $subsection 3compose }
-"Quotations also implement the sequence protocol, and can be manipulated with sequence words; see " { $link "quotations" } "."
-{ $see-also "combinators" } ;
+"Quotations also implement the sequence protocol, and can be manipulated with sequence words; see " { $link "quotations" } "." ;
+
+ARTICLE: "implementing-combinators" "Implementing combinators"
+"The following pair of words invoke words and quotations reflectively:"
+{ $subsection call }
+{ $subsection execute }
+"These words are used to implement combinators. Note that combinator definitions must be followed by the " { $link POSTPONE: inline } " declaration in order to compile in the optimizing compiler; for example:"
+{ $code
+    ": keep ( x quot -- x )"
+    "    over >r call r> ; inline"
+}
+"Word inlining is documented in " { $link "declarations" } "."
+$nl
+"A looping combinator:"
+{ $subsection while } ;
 
 ARTICLE: "booleans" "Booleans"
 "In Factor, any object that is not " { $link f } " has a true value, and " { $link f } " has a false value. The " { $link t } " object is the canonical true value."
@@ -115,15 +185,13 @@ ARTICLE: "conditionals" "Conditionals and logic"
 { $subsection ?if }
 "Sometimes instead of branching, you just need to pick one of two values:"
 { $subsection ? }
-"Forms which abstract away common patterns involving multiple nested branches:"
-{ $subsection cond }
-{ $subsection case }
 "There are some logical operations on booleans:"
 { $subsection >boolean }
 { $subsection not }
 { $subsection and }
 { $subsection or }
 { $subsection xor }
+"See " { $link "combinators" } " for forms which abstract away common patterns involving multiple nested branches."
 { $see-also "booleans" "bitwise-arithmetic" both? either? } ;
 
 ARTICLE: "equality" "Equality and comparison testing"
@@ -146,7 +214,23 @@ $nl
 "An object can be cloned; the clone has distinct identity but equal value:"
 { $subsection clone } ;
 
-! Defined in handbook.factor
+ARTICLE: "dataflow" "Data and control flow"
+{ $subsection "evaluator" }
+{ $subsection "words" }
+{ $subsection "effects" }
+{ $subsection "booleans" }
+{ $subsection "shuffle-words" }
+"A central concept in Factor is that of a " { $emphasis "combinator" } ", which is a word taking code as input."
+{ $subsection "cleave-combinators" }
+{ $subsection "spread-combinators" }
+{ $subsection "apply-combinators" }
+{ $subsection "slip-keep-combinators" }
+{ $subsection "conditionals" }
+{ $subsection "combinators" }
+"Advanced topics:"
+{ $subsection "implementing-combinators" }
+{ $subsection "continuations" } ;
+
 ABOUT: "dataflow"
 
 HELP: eq? ( obj1 obj2 -- ? )
@@ -211,12 +295,12 @@ HELP: hashcode*
 { $values { "depth" integer } { "obj" object } { "code" fixnum } }
 { $contract "Outputs the hashcode of an object. The hashcode operation must satisfy the following properties:"
 { $list
-    { "if two objects are equal under " { $link = } ", they must have equal hashcodes" }
-    { "if the hashcode of an object depends on the values of its slots, the hashcode of the slots must be computed recursively by calling " { $link hashcode* } " with a " { $snippet "level" } " parameter decremented by one. This avoids excessive work while still computing well-distributed hashcodes. The " { $link recursive-hashcode } " combinator can help with implementing this logic" }
-    { "the hashcode should be a " { $link fixnum } ", however returning a " { $link bignum } " will not cause any problems other than potential performance degradation."
-    "the hashcode is only permitted to change between two invocations if the object was mutated in some way" }
+    { "If two objects are equal under " { $link = } ", they must have equal hashcodes." }
+    { "If the hashcode of an object depends on the values of its slots, the hashcode of the slots must be computed recursively by calling " { $link hashcode* } " with a " { $snippet "level" } " parameter decremented by one. This avoids excessive work while still computing well-distributed hashcodes. The " { $link recursive-hashcode } " combinator can help with implementing this logic," }
+    { "The hashcode should be a " { $link fixnum } ", however returning a " { $link bignum } " will not cause any problems other than potential performance degradation." }
+    { "The hashcode is only permitted to change between two invocations if the object or one of its slot values was mutated." }
 }
-"If mutable objects are used as hashtable keys, they must not be mutated in such a way that their hashcode changes. Doing so will violate bucket sorting invariants and result in undefined behavior." } ;
+"If mutable objects are used as hashtable keys, they must not be mutated in such a way that their hashcode changes. Doing so will violate bucket sorting invariants and result in undefined behavior. See " { $link "hashtables.keys" } " for details." } ;
 
 HELP: hashcode
 { $values { "obj" object } { "code" fixnum } }
@@ -242,6 +326,8 @@ HELP: equal?
         { { $snippet "a = b" } " implies " { $snippet "b = a" } }
         { { $snippet "a = b" } " and " { $snippet "b = c" } " implies " { $snippet "a = c" } }
     }
+    $nl
+    "If a class defines a custom equality comparison test, it should also define a compatible method for the " { $link hashcode* } " generic word."
 }
 { $examples
     "To define a tuple class such that two instances are only equal if they are both the same instance, we can add a method to " { $link equal? } " which always returns " { $link f } ". Since " { $link = } " handles the case where the two objects are " { $link eq? } ", this method will never be called with two " { $link eq? } " objects, so such a definition is valid:"
@@ -376,9 +462,152 @@ HELP: 3keep
 { $values { "quot" "a quotation with stack effect " { $snippet "( x y z -- )" } } { "x" object } { "y" object } { "z" object } }
 { $description "Call a quotation with three values on the stack, restoring the values when the quotation returns." } ;
 
-HELP: 2apply
-{ $values { "quot" "a quotation with stack effect " { $snippet "( obj -- )" } } { "x" object } { "y" object } }
-{ $description "Applies the quotation to " { $snippet "x" } ", then to " { $snippet "y" } "." } ;
+HELP: bi
+{ $values { "x" object } { "p" "a quotation with stack effect " { $snippet "( x -- ... )" } } { "q" "a quotation with stack effect " { $snippet "( x -- ... )" } } }
+{ $description "Applies " { $snippet "p" } " to " { $snippet "x" } ", then applies " { $snippet "q" } " to " { $snippet "x" } "." }
+{ $examples
+    "If " { $snippet "[ p ]" } " and " { $snippet "[ q ]" } " have stack effect " { $snippet "( x -- )" } ", then the following two lines are equivalent:"
+    { $code
+        "[ p ] [ q ] bi"
+        "dup p q"
+    }
+    "If " { $snippet "[ p ]" } " and " { $snippet "[ q ]" } " have stack effect " { $snippet "( x -- y )" } ", then the following two lines are equivalent:"
+    { $code
+        "[ p ] [ q ] bi"
+        "dup p swap q"
+    }
+    "In general, the following two lines are equivalent:"
+    { $code
+        "[ p ] [ q ] bi"
+        "[ p ] keep q"
+    }
+    
+} ;
+
+HELP: 2bi
+{ $values { "x" object } { "y" object } { "p" "a quotation with stack effect " { $snippet "( x y -- ... )" } } { "q" "a quotation with stack effect " { $snippet "( x y -- ... )" } } }
+{ $description "Applies " { $snippet "p" } " to the two input values, then applies " { $snippet "q" } " to the two input values." }
+{ $examples
+    "If " { $snippet "[ p ]" } " and " { $snippet "[ q ]" } " have stack effect " { $snippet "( x y -- )" } ", then the following two lines are equivalent:"
+    { $code
+        "[ p ] [ q ] 2bi"
+        "2dup p q"
+    }
+    "If " { $snippet "[ p ]" } " and " { $snippet "[ q ]" } " have stack effect " { $snippet "( x y -- z )" } ", then the following two lines are equivalent:"
+    { $code
+        "[ p ] [ q ] 2bi"
+        "2dup p swap q"
+    }
+    "In general, the following two lines are equivalent:"
+    { $code
+        "[ p ] [ q ] 2bi"
+        "[ p ] 2keep q"
+    }
+} ;
+
+HELP: tri
+{ $values { "x" object } { "p" "a quotation with stack effect " { $snippet "( x -- ... )" } } { "q" "a quotation with stack effect " { $snippet "( x -- ... )" } } { "r" "a quotation with stack effect " { $snippet "( x -- ... )" } } }
+{ $description "Applies " { $snippet "p" } " to " { $snippet "x" } ", then applies " { $snippet "q" } " to " { $snippet "x" } ", and finally applies " { $snippet "r" } " to " { $snippet "x" } "." }
+{ $examples
+    "If " { $snippet "[ p ]" } ", " { $snippet "[ q ]" } " and " { $snippet "[ r ]" } " have stack effect " { $snippet "( x -- )" } ", then the following two lines are equivalent:"
+    { $code
+        "[ p ] [ q ] [ r ] tri"
+        "dup p dup q r"
+    }
+    "If " { $snippet "[ p ]" } ", " { $snippet "[ q ]" } " and " { $snippet "[ r ]" } " have stack effect " { $snippet "( x -- y )" } ", then the following two lines are equivalent:"
+    { $code
+        "[ p ] [ q ] [ r ] tri"
+        "dup p over q rot r"
+    }
+    "In general, the following two lines are equivalent:"
+    { $code
+        "[ p ] [ q ] [ r ] tri"
+        "[ p ] keep [ q ] keep r"
+    }
+} ;
+
+HELP: 2tri
+{ $values { "x" object } { "y" object } { "p" "a quotation with stack effect " { $snippet "( x y -- ... )" } } { "q" "a quotation with stack effect " { $snippet "( x y -- ... )" } } { "r" "a quotation with stack effect " { $snippet "( x y -- ... )" } } }
+{ $description "Applies " { $snippet "p" } " to the two input values, then applies " { $snippet "q" } " to the two input values, and finally applies " { $snippet "r" } " to the two input values." }
+{ $examples
+    "If " { $snippet "[ p ]" } ", " { $snippet "[ q ]" } " and " { $snippet "[ r ]" } " have stack effect " { $snippet "( x y -- )" } ", then the following two lines are equivalent:"
+    { $code
+        "[ p ] [ q ] [ r ] 2tri"
+        "2dup p 2dup q r"
+    }
+    "In general, the following two lines are equivalent:"
+    { $code
+        "[ p ] [ q ] [ r ] 2tri"
+        "[ p ] 2keep [ q ] 2keep r"
+    }
+} ;
+
+
+HELP: bi*
+{ $values { "x" object } { "y" object } { "p" "a quotation with stack effect " { $snippet "( x -- ... )" } } { "q" "a quotation with stack effect " { $snippet "( y -- ... )" } } }
+{ $description "Applies " { $snippet "p" } " to " { $snippet "x" } ", then applies " { $snippet "q" } " to " { $snippet "y" } "." }
+{ $examples
+    "The following two lines are equivalent:"
+    { $code
+        "[ p ] [ q ] bi*"
+        ">r p r> q"
+    }
+} ;
+
+HELP: 2bi*
+{ $values { "w" object } { "x" object } { "y" object } { "z" object } { "p" "a quotation with stack effect " { $snippet "( w x -- ... )" } } { "q" "a quotation with stack effect " { $snippet "( y z -- ... )" } } }
+{ $description "Applies " { $snippet "p" } " to " { $snippet "w" } " and " { $snippet "x" } ", then applies " { $snippet "q" } " to " { $snippet "y" } " and " { $snippet "z" } "." }
+{ $examples
+    "The following two lines are equivalent:"
+    { $code
+        "[ p ] [ q ] 2bi*"
+        ">r >r q r> r> q"
+    }
+} ;
+
+HELP: tri*
+{ $values { "x" object } { "y" object } { "z" object } { "p" "a quotation with stack effect " { $snippet "( x -- ... )" } } { "q" "a quotation with stack effect " { $snippet "( y -- ... )" } } { "r" "a quotation with stack effect " { $snippet "( z -- ... )" } } }
+{ $description "Applies " { $snippet "p" } " to " { $snippet "x" } ", then applies " { $snippet "q" } " to " { $snippet "y" } ", and finally applies " { $snippet "r" } " to " { $snippet "z" } "." }
+{ $examples
+    "The following two lines are equivalent:"
+    { $code
+        "[ p ] [ q ] [ r ] tri*"
+        ">r >r q r> q r> r"
+    }
+} ;
+
+HELP: bi@
+{ $values { "x" object } { "y" object } { "quot" "a quotation with stack effect " { $snippet "( obj -- )" } } }
+{ $description "Applies the quotation to " { $snippet "x" } ", then to " { $snippet "y" } "." }
+{ $examples
+    "The following two lines are equivalent:"
+    { $code
+        "[ p ] bi@"
+        ">r p r> p"
+    }
+} ;
+
+HELP: 2bi@
+{ $values { "w" object } { "x" object } { "y" object } { "z" object } { "quot" "a quotation with stack effect " { $snippet "( obj1 obj2 -- )" } } }
+{ $description "Applies the quotation to " { $snippet "w" } " and " { $snippet "x" } ", then to " { $snippet "y" } " and " { $snippet "z" } "." }
+{ $examples
+    "The following two lines are equivalent:"
+    { $code
+        "[ p ] 2bi@"
+        ">r >r p r> r> p"
+    }
+} ;
+
+HELP: tri@
+{ $values { "x" object } { "y" object } { "z" object } { "quot" "a quotation with stack effect " { $snippet "( obj -- )" } } }
+{ $description "Applies the quotation to " { $snippet "x" } ", then to " { $snippet "y" } ", and finally to " { $snippet "z" } "." }
+{ $examples
+    "The following two lines are equivalent:"
+    { $code
+        "[ p ] tri@"
+        ">r >r p r> p r> p"
+    }
+} ;
 
 HELP: if ( cond true false -- )
 { $values { "cond" "a generalized boolean" } { "true" quotation } { "false" quotation } }
index 61574e406fcc4876f77e92141bf4aa09e1701295..ab42a1b9039453aa3b96c59019b61e791dec2d44 100755 (executable)
@@ -1,4 +1,4 @@
-! Copyright (C) 2004, 2007 Slava Pestov.
+! Copyright (C) 2004, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel.private ;
 IN: kernel
@@ -27,24 +27,28 @@ DEFER: if
 
 : if ( ? true false -- ) ? call ;
 
-: if* ( cond true false -- )
-    pick [ drop call ] [ 2nip call ] if ; inline
-
-: ?if ( default cond true false -- )
-    pick [ roll 2drop call ] [ 2nip call ] if ; inline
-
+! Single branch
 : unless ( cond false -- )
     swap [ drop ] [ call ] if ; inline
 
-: unless* ( cond false -- )
-    over [ drop ] [ nip call ] if ; inline
-
 : when ( cond true -- )
     swap [ call ] [ drop ] if ; inline
 
+! Anaphoric
+: if* ( cond true false -- )
+    pick [ drop call ] [ 2nip call ] if ; inline
+
 : when* ( cond true -- )
     over [ call ] [ 2drop ] if ; inline
 
+: unless* ( cond false -- )
+    over [ drop ] [ nip call ] if ; inline
+
+! Default
+: ?if ( default cond true false -- )
+    pick [ roll 2drop call ] [ 2nip call ] if ; inline
+
+! Slippers
 : slip ( quot x -- x ) >r call r> ; inline
 
 : 2slip ( quot x y -- x y ) >r >r call r> r> ; inline
@@ -53,6 +57,7 @@ DEFER: if
 
 : dip ( obj quot -- obj ) swap slip ; inline
 
+! Keepers
 : keep ( x quot -- x ) over slip ; inline
 
 : 2keep ( x y quot -- x y ) 2over 2slip ; inline
@@ -60,36 +65,55 @@ DEFER: if
 : 3keep ( x y z quot -- x y z )
     >r 3dup r> -roll 3slip ; inline
 
-: 2apply ( x y quot -- ) tuck 2slip call ; inline
+! Cleavers
+: bi ( x p q -- )
+    >r keep r> call ; inline
 
-: while ( pred body tail -- )
-    >r >r dup slip r> r> roll
-    [ >r tuck 2slip r> while ]
-    [ 2nip call ] if ; inline
+: tri ( x p q r -- )
+    >r pick >r bi r> r> call ; inline
 
-! Quotation building
-USE: tuples.private
+! Double cleavers
+: 2bi ( x y p q -- )
+    >r 2keep r> call ; inline
 
-: curry ( obj quot -- curry )
-    \ curry 4 <tuple-boa> ;
+: 2tri ( x y p q r -- )
+    >r >r 2keep r> 2keep r> call ; inline
 
-: 2curry ( obj1 obj2 quot -- curry )
-    curry curry ; inline
+! Triple cleavers
+: 3bi ( x y z p q -- )
+    >r 3keep r> call ; inline
 
-: 3curry ( obj1 obj2 obj3 quot -- curry )
-    curry curry curry ; inline
+: 3tri ( x y z p q r -- )
+    >r >r 3keep r> 3keep r> call ; inline
 
-: with ( param obj quot -- obj curry )
-    swapd [ swapd call ] 2curry ; inline
+! Spreaders
+: bi* ( x y p q -- )
+    >r swap slip r> call ; inline
 
-: compose ( quot1 quot2 -- curry )
-    \ compose 4 <tuple-boa> ;
+: tri* ( x y z p q r -- )
+    >r rot >r bi* r> r> call ; inline
 
-: 3compose ( quot1 quot2 quot3 -- curry )
-    compose compose ; inline
+! Double spreaders
+: 2bi* ( w x y z p q -- )
+    >r -rot 2slip r> call ; inline
 
-! Object protocol
+! Appliers
+: bi@ ( x y quot -- )
+    tuck 2slip call ; inline
+
+: tri@ ( x y z quot -- )
+    tuck >r bi@ r> call ; inline
+
+! Double appliers
+: 2bi@ ( w x y z quot -- )
+    dup -roll 3slip call ; inline
+
+: while ( pred body tail -- )
+    >r >r dup slip r> r> roll
+    [ >r tuck 2slip r> while ]
+    [ 2nip call ] if ; inline
 
+! Object protocol
 GENERIC: delegate ( obj -- delegate )
 
 M: object delegate drop f ;
@@ -118,7 +142,6 @@ M: object clone ;
 M: callstack clone (clone) ;
 
 ! Tuple construction
-
 GENERIC# get-slots 1 ( tuple slots -- ... )
 
 GENERIC# set-slots 1 ( ... tuple slots -- )
@@ -132,8 +155,20 @@ GENERIC: construct-boa ( ... class -- tuple )
 : construct-delegate ( delegate class -- tuple )
     >r { set-delegate } r> construct ; inline
 
-! Booleans
+! Quotation building
+: 2curry ( obj1 obj2 quot -- curry )
+    curry curry ; inline
 
+: 3curry ( obj1 obj2 obj3 quot -- curry )
+    curry curry curry ; inline
+
+: with ( param obj quot -- obj curry )
+    swapd [ swapd call ] 2curry ; inline
+
+: 3compose ( quot1 quot2 quot3 -- curry )
+    compose compose ; inline
+
+! Booleans
 : not ( obj -- ? ) f eq? ; inline
 
 : >boolean ( obj -- ? ) t f ? ; inline
@@ -144,11 +179,11 @@ GENERIC: construct-boa ( ... class -- tuple )
 
 : xor ( obj1 obj2 -- ? ) dup not swap ? ; inline
 
-: both? ( x y quot -- ? ) 2apply and ; inline
+: both? ( x y quot -- ? ) bi@ and ; inline
 
-: either? ( x y quot -- ? ) 2apply or ; inline
+: either? ( x y quot -- ? ) bi@ or ; inline
 
-: compare ( obj1 obj2 quot -- n ) 2apply <=> ; inline
+: compare ( obj1 obj2 quot -- n ) bi@ <=> ; inline
 
 : most ( x y quot -- z )
     >r 2dup r> call [ drop ] [ nip ] if ; inline
index 16ee2705fe14d49bc8ac8773d42e46a233e6617d..bf262b77a26be3d0e8b19dbfba122b944da28710 100755 (executable)
@@ -3,7 +3,7 @@
 USING: arrays hashtables io kernel math math.parser memory
 namespaces parser sequences strings io.styles
 io.streams.duplex vectors words generic system combinators
-tuples continuations debugger definitions compiler.units ;
+continuations debugger definitions compiler.units ;
 IN: listener
 
 SYMBOL: quit-flag
index 5a3fe777b68db5272675eaf0f474e68d34214207..f6317e747592a674ce0ba2324a6bb3690b29c6b8 100755 (executable)
@@ -169,7 +169,7 @@ IN: math.intervals.tests
 
 : random-interval ( -- interval )
     1000 random dup 2 1000 random + +
-    1 random zero? [ [ neg ] 2apply swap ] when
+    1 random zero? [ [ neg ] bi@ swap ] when
     4 random {
         { 0 [ [a,b] ] }
         { 1 [ [a,b) ] }
@@ -197,7 +197,7 @@ IN: math.intervals.tests
     0 pick interval-contains? over first { / /i } member? and [
         3drop t
     ] [
-        [ >r [ random-element ] 2apply ! 2dup . .
+        [ >r [ random-element ] bi@ ! 2dup . .
         r> first execute ] 3keep
         second execute interval-contains?
     ] if ;
@@ -214,7 +214,7 @@ IN: math.intervals.tests
 
 : comparison-test
     random-interval random-interval random-comparison
-    [ >r [ random-element ] 2apply r> first execute ] 3keep
+    [ >r [ random-element ] bi@ r> first execute ] 3keep
     second execute dup incomparable eq? [
         2drop t
     ] [
index d1c458065f5e313233dccc531fe245808620261b..cc51060f634b9d1436091a76ff59aab854d5c565 100755 (executable)
@@ -67,7 +67,7 @@ C: <interval> interval
 
 : (interval-op) ( p1 p2 quot -- p3 )
     2over >r >r
-    >r [ first ] 2apply r> call
+    >r [ first ] bi@ r> call
     r> r> [ second ] both? 2array ; inline
 
 : interval-op ( i1 i2 quot -- i3 )
@@ -108,7 +108,7 @@ C: <interval> interval
 
 : interval-intersect ( i1 i2 -- i3 )
     2dup and [
-        [ interval>points ] 2apply swapd
+        [ interval>points ] bi@ swapd
         [ swap endpoint> ] most
         >r [ swap endpoint< ] most r>
         make-interval
@@ -118,7 +118,7 @@ C: <interval> interval
 
 : interval-union ( i1 i2 -- i3 )
     2dup and [
-        [ interval>points 2array ] 2apply append points>interval
+        [ interval>points 2array ] bi@ append points>interval
     ] [
         2drop f
     ] if ;
@@ -131,17 +131,17 @@ C: <interval> interval
 
 : interval-singleton? ( int -- ? )
     interval>points
-    2dup [ second ] 2apply and
-    [ [ first ] 2apply = ]
+    2dup [ second ] bi@ and
+    [ [ first ] bi@ = ]
     [ 2drop f ] if ;
 
 : interval-length ( int -- n )
     dup
-    [ interval>points [ first ] 2apply swap - ]
+    [ interval>points [ first ] bi@ swap - ]
     [ drop 0 ] if ;
 
 : interval-closure ( i1 -- i2 )
-    dup [ interval>points [ first ] 2apply [a,b] ] when ;
+    dup [ interval>points [ first ] bi@ [a,b] ] when ;
 
 : interval-shift ( i1 i2 -- i3 )
     #! Inaccurate; could be tighter
@@ -163,7 +163,7 @@ C: <interval> interval
     [ min ] interval-op interval-closure ;
 
 : interval-interior ( i1 -- i2 )
-    interval>points [ first ] 2apply (a,b) ;
+    interval>points [ first ] bi@ (a,b) ;
 
 : interval-division-op ( i1 i2 quot -- i3 )
     >r 0 over interval-closure interval-contains?
@@ -186,13 +186,13 @@ SYMBOL: incomparable
 : left-endpoint-< ( i1 i2 -- ? )
     [ swap interval-subset? ] 2keep
     [ nip interval-singleton? ] 2keep
-    [ interval-from ] 2apply =
+    [ interval-from ] bi@ =
     and and ;
 
 : right-endpoint-< ( i1 i2 -- ? )
     [ interval-subset? ] 2keep
     [ drop interval-singleton? ] 2keep
-    [ interval-to ] 2apply =
+    [ interval-to ] bi@ =
     and and ;
 
 : (interval<) over interval-from over interval-from endpoint< ;
index 29ed153a2e4496de911643445230b4f1ac16528d..725a757e613b135176fec093dec2687d30d95e31 100755 (executable)
@@ -36,7 +36,7 @@ HELP: <mirror>
         "TUPLE: circle center radius ;"
         "C: <circle> circle"
         "{ 100 50 } 15 <circle> <mirror> >alist ."
-        "{ { \"center\" { 100 50 } } { \"radius\" 15 } }"
+        "{ { \"delegate\" f } { \"center\" { 100 50 } } { \"radius\" 15 } }"
     }
 } ;
 
index 8f2964b19d955b74e25f81015d8ed7395449f775..11e57720004d16190b532f645dba572e6d561590 100755 (executable)
@@ -5,7 +5,7 @@ TUPLE: foo bar baz ;
 
 C: <foo> foo
 
-[ { "bar" "baz" } ] [ 1 2 <foo> <mirror> keys ] unit-test
+[ { "delegate" "bar" "baz" } ] [ 1 2 <foo> <mirror> keys ] unit-test
 
 [ 1 t ] [ "bar" 1 2 <foo> <mirror> at* ] unit-test
 
index 8f12bbb2f4120c04a8aee1da8305b80e85e4c8de..fde8728858dce4a10236d66c51f6f47d6080b267 100755 (executable)
@@ -1,17 +1,15 @@
 ! Copyright (C) 2007, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: assocs hashtables kernel sequences generic words
-arrays classes slots slots.private tuples math vectors
+arrays classes slots slots.private classes.tuple math vectors
 quotations sorting prettyprint ;
 IN: mirrors
 
-GENERIC: object-slots ( obj -- seq )
+: all-slots ( class -- slots )
+    superclasses [ "slots" word-prop ] map concat ;
 
-M: object object-slots class "slots" word-prop ;
-
-M: tuple object-slots
-    dup class "slots" word-prop
-    swap delegate [ 1 tail-slice ] unless ;
+: object-slots ( obj -- seq )
+    class all-slots ;
 
 TUPLE: mirror object slots ;
 
index b04d4677ce371f2cb3fb97d8c394065387f2b31d..c108e3b1a7d03499b77b087f0e73c5be938d1c62 100755 (executable)
@@ -3,8 +3,8 @@
 USING: arrays generic assocs inference inference.class
 inference.dataflow inference.backend inference.state io kernel
 math namespaces sequences vectors words quotations hashtables
-combinators classes generic.math continuations optimizer.def-use
-optimizer.backend generic.standard ;
+combinators classes classes.algebra generic.math continuations
+optimizer.def-use optimizer.backend generic.standard ;
 IN: optimizer.control
 
 ! ! ! Rudimentary CFA
index d5e8e2d75d51a13ab6846d60819792a009261163..f22cce9fa87dcf46dbbbc3c96434dad6e72103ae 100755 (executable)
@@ -99,7 +99,7 @@ namespaces assocs kernel sequences math tools.test words ;
 ] unit-test
 
 : regression-2 ( x y -- x.y )
-    [ p1 ] 2apply [
+    [ p1 ] bi@ [
         [
             rot
             [ 2swap [ swapd * -rot p2 +@ ] 2keep ]
index 04d7ab4ee5b33d1ba722cbcaf7f33bc75127de71..1f3df92421b52f5a94b0d61de93a997b7b84a06d 100755 (executable)
@@ -3,10 +3,10 @@
 USING: arrays generic assocs inference inference.class
 inference.dataflow inference.backend inference.state io kernel
 math namespaces sequences vectors words quotations hashtables
-combinators classes generic.math continuations optimizer.def-use
-optimizer.backend generic.standard optimizer.specializers
-optimizer.def-use optimizer.pattern-match generic.standard
-optimizer.control kernel.private ;
+combinators classes classes.algebra generic.math continuations
+optimizer.def-use optimizer.backend generic.standard
+optimizer.specializers optimizer.def-use optimizer.pattern-match
+generic.standard optimizer.control kernel.private ;
 IN: optimizer.inlining
 
 : remember-inlining ( node history -- )
@@ -175,7 +175,7 @@ DEFER: (flat-length)
 : optimistic-inline? ( #call -- ? )
     dup node-param "specializer" word-prop dup [
         >r node-input-classes r> specialized-length tail*
-        [ types length 1 = ] all?
+        [ class-types length 1 = ] all?
     ] [
         2drop f
     ] if ;
index 18c98c5115faa8d21227fc69a30eed88c1e40e7c..aef48452de11a94905152fba478fe744596f7d9a 100755 (executable)
@@ -6,16 +6,16 @@ inference.class kernel assocs math math.private kernel.private
 sequences words parser vectors strings sbufs io namespaces
 assocs quotations sequences.private io.binary io.crc32
 io.streams.string layouts splitting math.intervals
-math.floats.private tuples tuples.private classes
-optimizer.def-use optimizer.backend optimizer.pattern-match
-optimizer.inlining float-arrays sequences.private combinators ;
+math.floats.private classes.tuple classes.tuple.private classes
+classes.algebra optimizer.def-use optimizer.backend
+optimizer.pattern-match optimizer.inlining float-arrays
+sequences.private combinators ;
 
-! the output of <tuple> and <tuple-boa> has the class which is
-! its second-to-last input
 { <tuple> <tuple-boa> } [
     [
-        dup node-in-d dup length 2 - swap nth node-literal
-        dup class? [ drop tuple ] unless 1array f
+        dup node-in-d peek node-literal
+        dup tuple-layout? [ layout-class ] [ drop tuple ] if
+        1array f
     ] "output-classes" set-word-prop
 ] each
 
@@ -89,10 +89,10 @@ optimizer.inlining float-arrays sequences.private combinators ;
 
 ! type applied to an object of a known type can be folded
 : known-type? ( node -- ? )
-    node-class-first types length 1 number= ;
+    node-class-first class-types length 1 number= ;
 
 : fold-known-type ( node -- node )
-    dup node-class-first types inline-literals ;
+    dup node-class-first class-types inline-literals ;
 
 \ type [
     { [ dup known-type? ] [ fold-known-type ] }
index 7afc177d106f5cd85f4a9137e8a531d80dffafde..abe48ec27208f09e10988db7f4f621fd9cab2ded 100755 (executable)
@@ -5,9 +5,10 @@ USING: alien alien.accessors arrays generic hashtables kernel
 assocs math math.private kernel.private sequences words parser
 inference.class inference.dataflow vectors strings sbufs io
 namespaces assocs quotations math.intervals sequences.private
-combinators splitting layouts math.parser classes generic.math
-optimizer.pattern-match optimizer.backend optimizer.def-use
-optimizer.inlining generic.standard system ;
+combinators splitting layouts math.parser classes
+classes.algebra generic.math optimizer.pattern-match
+optimizer.backend optimizer.def-use optimizer.inlining
+generic.standard system ;
 
 { + bignum+ float+ fixnum+fast } {
     { { number 0 } [ drop ] }
@@ -112,7 +113,7 @@ optimizer.inlining generic.standard system ;
 : post-process ( class interval node -- classes intervals )
     dupd won't-overflow?
     [ >r dup { f integer } member? [ drop fixnum ] when r> ] when
-    [ dup [ 1array ] when ] 2apply ;
+    [ dup [ 1array ] when ] bi@ ;
 
 : math-output-interval-1 ( node word -- interval )
     dup [
@@ -146,7 +147,7 @@ optimizer.inlining generic.standard system ;
 ] each
 
 : intervals ( node -- i1 i2 )
-    node-in-d first2 [ value-interval* ] 2apply ;
+    node-in-d first2 [ value-interval* ] bi@ ;
 
 : math-output-interval-2 ( node word -- interval )
     dup [
index 3abccecc7f53023a7a487ef9c9378630f26a4ca5..aa081e8e2cee4654c024d329017effdea72980d9 100755 (executable)
@@ -1,8 +1,9 @@
 USING: arrays compiler.units generic hashtables inference kernel
 kernel.private math optimizer prettyprint sequences sbufs
 strings tools.test vectors words sequences.private quotations
-optimizer.backend classes inference.dataflow tuples.private
-continuations growable optimizer.inlining namespaces hints ;
+optimizer.backend classes classes.algebra inference.dataflow
+classes.tuple.private continuations growable optimizer.inlining
+namespaces hints ;
 IN: optimizer.tests
 
 [ H{ { 1 5 } { 3 4 } { 2 5 } } ] [
old mode 100644 (file)
new mode 100755 (executable)
index ed78330..0e7e801
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 IN: optimizer.pattern-match
 USING: kernel sequences inference namespaces generic
-combinators classes inference.dataflow ;
+combinators classes classes.algebra inference.dataflow ;
 
 ! Funny pattern matching
 SYMBOL: @
index 4d200c17d2343d506395e7655122f62d53f6bb1f..cc4e2c0a4206863bff21ed8823a668b85dfc5f69 100755 (executable)
@@ -333,12 +333,14 @@ HELP: CREATE
 { $errors "Throws an error if the end of the line is reached." }
 $parsing-note ;
 
-HELP: no-word
-{ $values { "name" string } { "newword" word } }
-{ $description "Throws a " { $link no-word } " error." }
+HELP: no-word-error
 { $error-description "Thrown if the parser encounters a token which does not name a word in the current vocabulary search path. If any words with this name exist in vocabularies not part of the search path, a number of restarts will offer to add those vocabularies to the search path and use the chosen word." }
 { $notes "Apart from a missing " { $link POSTPONE: USE: } ", this error can also indicate an ordering issue. In Factor, words must be defined before they can be called. Mutual recursion can be implemented via " { $link POSTPONE: DEFER: } "." } ;
 
+HELP: no-word
+{ $values { "name" string } { "newword" word } }
+{ $description "Throws a " { $link no-word-error } "." } ;
+
 HELP: search
 { $values { "str" string } { "word/f" "a word or " { $link f } } }
 { $description "Searches for a word by name in the current vocabulary search path. If no such word could be found, outputs " { $link f } "." }
index f024eda54c91493ec8aec22bb1114d90a2c207d5..6bd4abb7e106727a0d9b20dd2af8104e7f0bbfc7 100755 (executable)
@@ -1,7 +1,8 @@
 USING: arrays math parser tools.test kernel generic words
 io.streams.string namespaces classes effects source-files
 assocs sequences strings io.files definitions continuations
-sorting tuples compiler.units debugger vocabs vocabs.loader ;
+sorting classes.tuple compiler.units debugger vocabs
+vocabs.loader ;
 IN: parser.tests
 
 [
@@ -321,7 +322,7 @@ IN: parser.tests
     [
         "IN: parser.tests \\ class-fwd-test"
         <string-reader> "redefining-a-class-3" parse-stream drop
-    ] [ [ no-word? ] is? ] must-fail-with
+    ] [ [ no-word-error? ] is? ] must-fail-with
 
     [ ] [
         "IN: parser.tests TUPLE: class-fwd-test ; SYMBOL: class-fwd-test"
@@ -331,7 +332,7 @@ IN: parser.tests
     [
         "IN: parser.tests \\ class-fwd-test"
         <string-reader> "redefining-a-class-3" parse-stream drop
-    ] [ [ no-word? ] is? ] must-fail-with
+    ] [ [ no-word-error? ] is? ] must-fail-with
 
     [
         "IN: parser.tests : foo ; TUPLE: foo ;"
@@ -389,7 +390,7 @@ IN: parser.tests
 ] with-scope
 
 [ ] [
-    "IN: parser.tests USE: kernel PREDICATE: object foo ( x -- y ) ;" eval
+    "IN: parser.tests USE: kernel PREDICATE: foo < object ( x -- y ) ;" eval
 ] unit-test
 
 [ t ] [
index 28822db70887ae16b4d7342c1dbea9ee60ae5f83..36e5decd05caac01b3ab23b7e8808af153a0b2db 100755 (executable)
@@ -5,16 +5,18 @@ namespaces prettyprint sequences strings vectors words
 quotations inspector io.styles io combinators sorting
 splitting math.parser effects continuations debugger 
 io.files io.streams.string vocabs io.encodings.utf8
-source-files classes hashtables compiler.errors compiler.units ;
+source-files classes hashtables compiler.errors compiler.units
+accessors ;
 IN: parser
 
 TUPLE: lexer text line line-text line-length column ;
 
 : next-line ( lexer -- )
-    0 over set-lexer-column
-    dup lexer-line over lexer-text ?nth over set-lexer-line-text
-    dup lexer-line-text length over set-lexer-line-length
-    dup lexer-line 1+ swap set-lexer-line ;
+    dup [ line>> ] [ text>> ] bi ?nth >>line-text
+    dup line-text>> length >>line-length
+    [ 1+ ] change-line
+    0 >>column
+    drop ;
 
 : <lexer> ( text -- lexer )
     0 { set-lexer-text set-lexer-line } lexer construct
@@ -159,8 +161,7 @@ TUPLE: parse-error file line col text ;
 
 : <parse-error> ( msg -- error )
     file get
-    lexer get
-    { lexer-line lexer-column lexer-line-text } get-slots
+    lexer get [ line>> ] [ column>> ] [ line-text>> ] tri
     parse-error construct-boa
     [ set-delegate ] keep ;
 
@@ -214,7 +215,7 @@ SYMBOL: in
 
 ERROR: unexpected want got ;
 
-PREDICATE: unexpected unexpected-eof
+PREDICATE: unexpected-eof < unexpected
     unexpected-got not ;
 
 : unexpected-eof ( word -- * ) f unexpected ;
@@ -251,13 +252,13 @@ PREDICATE: unexpected unexpected-eof
         [ "Use the word " swap summary append ] keep
     ] { } map>assoc ;
 
-TUPLE: no-word name ;
+TUPLE: no-word-error name ;
 
-M: no-word summary
+M: no-word-error summary
     drop "Word not found in current vocabulary search path" ;
 
 : no-word ( name -- newword )
-    dup \ no-word construct-boa
+    dup no-word-error construct-boa
     swap words-named [ forward-reference? not ] subset
     word-restarts throw-restarts
     dup word-vocabulary (use+) ;
@@ -288,6 +289,14 @@ M: no-word summary
 : CREATE-METHOD ( -- method )
     scan-word bootstrap-word scan-word create-method-in ;
 
+: parse-tuple-definition ( -- class superclass slots )
+    CREATE-CLASS
+    scan {
+        { ";" [ tuple f ] }
+        { "<" [ scan-word ";" parse-tokens ] }
+        [ >r tuple ";" parse-tokens r> add* ]
+    } case ;
+
 ERROR: staging-violation word ;
 
 M: staging-violation summary
@@ -358,6 +367,10 @@ ERROR: bad-number ;
 
 : (M:) CREATE-METHOD parse-definition ;
 
+: scan-object ( -- object )
+    scan-word dup parsing?
+    [ V{ } clone swap execute first ] when ;
+
 GENERIC: expected>string ( obj -- str )
 
 M: f expected>string drop "end of input" ;
@@ -462,7 +475,7 @@ SYMBOL: interactive-vocabs
 
 : removed-definitions ( -- definitions )
     new-definitions old-definitions
-    [ get first2 union ] 2apply diff ;
+    [ get first2 union ] bi@ diff ;
 
 : smudged-usage ( -- usages referenced removed )
     removed-definitions filter-moved keys [
@@ -512,7 +525,7 @@ SYMBOL: interactive-vocabs
     [
         [
             [ parsing-file ] keep
-            [ ?resource-path utf8 <file-reader> ] keep
+            [ utf8 <file-reader> ] keep
             parse-stream
         ] with-compiler-errors
     ] [
@@ -524,7 +537,7 @@ SYMBOL: interactive-vocabs
     [ dup parse-file call ] assert-depth drop ;
 
 : ?run-file ( path -- )
-    dup resource-exists? [ run-file ] [ drop ] if ;
+    dup exists? [ run-file ] [ drop ] if ;
 
 : bootstrap-file ( path -- )
     [ parse-file % ] [ run-file ] if-bootstrapping ;
index 226595aa4d38d8dd3bf15fd72904271895624dc8..c9019b029d70dd486cb077f79f38cb4b7fa38c00 100755 (executable)
@@ -4,7 +4,8 @@ USING: arrays byte-arrays byte-vectors bit-arrays bit-vectors
 generic hashtables io assocs kernel math namespaces sequences
 strings sbufs io.styles vectors words prettyprint.config
 prettyprint.sections quotations io io.files math.parser effects
-tuples classes float-arrays float-vectors ;
+classes.tuple classes.tuple.private classes float-arrays
+float-vectors ;
 IN: prettyprint.backend
 
 GENERIC: pprint* ( obj -- )
@@ -202,3 +203,6 @@ M: wrapper pprint*
     ] [
         pprint-object
     ] if ;
+
+M: tuple-layout pprint*
+    "( tuple layout )" swap present-text ;
index 8df97effb6da1b565cd08a5eaa7521447c0f0fa2..35b30ac46f4d64826b3e1c7bace9d1b0344f43c8 100755 (executable)
@@ -329,3 +329,9 @@ M: f generic-see-test-with-f ;
 [ "USING: prettyprint.tests ;\nM: f generic-see-test-with-f ;\n" ] [
     [ \ f \ generic-see-test-with-f method see ] with-string-writer
 ] unit-test
+
+PREDICATE: predicate-see-test < integer even? ;
+
+[ "USING: math ;\nIN: prettyprint.tests\nPREDICATE: predicate-see-test < integer even? ;\n" ] [
+    [ \ predicate-see-test see ] with-string-writer
+] unit-test
index 8bce81650f6b895138252e123c7ca99fa38b972d..d294f95be68ede79308ff58a0a7e36af604cd0e2 100755 (executable)
@@ -1,11 +1,11 @@
-! Copyright (C) 2003, 2007 Slava Pestov.
+! Copyright (C) 2003, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 IN: prettyprint
 USING: alien arrays generic generic.standard assocs io kernel
 math namespaces sequences strings io.styles io.streams.string
 vectors words prettyprint.backend prettyprint.sections
 prettyprint.config sorting splitting math.parser vocabs
-definitions effects tuples io.files classes continuations
+definitions effects classes.tuple io.files classes continuations
 hashtables classes.mixin classes.union classes.predicate
 combinators quotations ;
 
@@ -114,7 +114,7 @@ SYMBOL: ->
 
 : remove-breakpoints ( quot pos -- quot' )
     over quotation? [
-        1+ cut [ (remove-breakpoints) ] 2apply
+        1+ cut [ (remove-breakpoints) ] bi@
         [ -> ] swap 3append
     ] [
         drop
@@ -247,8 +247,9 @@ M: mixin-class see-class*
 
 M: predicate-class see-class*
     <colon \ PREDICATE: pprint-word
-    dup superclass pprint-word
     dup pprint-word
+    "<" text
+    dup superclass pprint-word
     <block
     "predicate-definition" word-prop pprint-elements
     pprint-; block> block> ;
@@ -256,7 +257,10 @@ M: predicate-class see-class*
 M: tuple-class see-class*
     <colon \ TUPLE: pprint-word
     dup pprint-word
-    "slot-names" word-prop [ text ] each
+    dup superclass tuple eq? [
+        "<" text dup superclass pprint-word
+    ] unless
+    slot-names [ text ] each
     pprint-; block> ;
 
 M: word see-class* drop ;
index 65c6da2b065a836ec1983c9d4e794f97ac294f14..c0f15a9388c7e8edfd1fbc342ce430650bb3d748 100755 (executable)
@@ -7,12 +7,12 @@ IN: quotations
 
 M: quotation call (call) ;
 
-M: curry call dup 4 slot swap 5 slot call ;
+M: curry call dup 3 slot swap 4 slot call ;
 
-M: compose call dup 4 slot swap 5 slot slip call ;
+M: compose call dup 3 slot swap 4 slot slip call ;
 
 M: wrapper equal?
-    over wrapper? [ [ wrapped ] 2apply = ] [ 2drop f ] if ;
+    over wrapper? [ [ wrapped ] bi@ = ] [ 2drop f ] if ;
 
 UNION: callable quotation curry compose ;
 
index fb67db93329980eb4da2a071e39ffd613a3f8b7c..c52c5daf9e77d72116e137ca47788eec419cc4bc 100644 (file)
@@ -1,6 +1,6 @@
-! Copyright (C) 2007 Slava Pestov
+! Copyright (C) 2007, 2008 Slava Pestov
 ! See http://factorcode.org/license.txt for BSD license.
-USING: tuples kernel assocs ;
+USING: classes.tuple kernel assocs accessors ;
 IN: refs
 
 TUPLE: ref assoc key ;
@@ -8,7 +8,7 @@ TUPLE: ref assoc key ;
 : <ref> ( assoc key class -- tuple )
     >r ref construct-boa r> construct-delegate ; inline
 
-: >ref< ( ref -- key assoc ) dup ref-key swap ref-assoc ;
+: >ref< ( ref -- key assoc ) [ key>> ] [ assoc>> ] bi ;
 
 : delete-ref ( ref -- ) >ref< delete-at ;
 GENERIC: get-ref ( ref -- obj )
index c545a9baee5aa406c005ebf4dbbcd5794f96c92a..3a30824084ff985c20ef3de4e3374a56d26fb427 100755 (executable)
@@ -169,13 +169,13 @@ unit-test
 
 [ f ] [ { "a" "b" "c" } { "a" "b" "c" } mismatch ] unit-test
 
-[ V{ } V{ } ] [ { "a" "b" } { "a" "b" } drop-prefix [ >vector ] 2apply ] unit-test
+[ V{ } V{ } ] [ { "a" "b" } { "a" "b" } drop-prefix [ >vector ] bi@ ] unit-test
 
-[ V{ "C" } V{ "c" } ] [ { "a" "b" "C" } { "a" "b" "c" } drop-prefix [ >vector ] 2apply ] unit-test
+[ V{ "C" } V{ "c" } ] [ { "a" "b" "C" } { "a" "b" "c" } drop-prefix [ >vector ] bi@ ] unit-test
 
 [ -1 1 "abc" <slice> ] must-fail
 
-[ V{ "a" "b" } V{ } ] [ { "X" "a" "b" } { "X" } drop-prefix [ >vector ] 2apply ] unit-test
+[ V{ "a" "b" } V{ } ] [ { "X" "a" "b" } { "X" } drop-prefix [ >vector ] bi@ ] unit-test
 
 [ -1 ] [ "ab" "abc" <=> ] unit-test
 [ 1 ] [ "abc" "ab" <=> ] unit-test
index 14674ba2f213bb86262a9468087b0b0d2655626a..1f2a6c550136c75ea4339de71661d7933d3c06f3 100755 (executable)
@@ -60,7 +60,7 @@ INSTANCE: immutable-sequence sequence
     #! A bit of a pain; can't call cell-bits here
     7 getenv 8 * 5 - 2^ 1- ; foldable
 
-PREDICATE: fixnum array-capacity
+PREDICATE: array-capacity < fixnum
     0 max-array-capacity between? ;
 
 : array-capacity ( array -- n )
@@ -300,9 +300,9 @@ M: immutable-sequence clone-like like ;
 : change-nth ( i seq quot -- )
     [ >r nth r> call ] 3keep drop set-nth ; inline
 
-: min-length ( seq1 seq2 -- n ) [ length ] 2apply min ; inline
+: min-length ( seq1 seq2 -- n ) [ length ] bi@ min ; inline
 
-: max-length ( seq1 seq2 -- n ) [ length ] 2apply max ; inline
+: max-length ( seq1 seq2 -- n ) [ length ] bi@ max ; inline
 
 <PRIVATE
 
@@ -369,7 +369,7 @@ PRIVATE>
     (2each) each-integer ; inline
 
 : 2reverse-each ( seq1 seq2 quot -- )
-    >r [ <reversed> ] 2apply r> 2each ; inline
+    >r [ <reversed> ] bi@ r> 2each ; inline
 
 : 2reduce ( seq1 seq2 identity quot -- result )
     >r -rot r> 2each ; inline
@@ -460,7 +460,7 @@ M: sequence <=>
     [ -rot 2nth-unsafe <=> ] [ [ length ] compare ] if* ;
 
 : sequence= ( seq1 seq2 -- ? )
-    2dup [ length ] 2apply number=
+    2dup [ length ] bi@ number=
     [ mismatch not ] [ 2drop f ] if ; inline
 
 : move ( to from seq -- )
@@ -620,12 +620,12 @@ M: sequence <=>
             [ drop nip ]
             [ 2drop first ]
             [ >r drop first2 r> call ]
-            [ >r drop first3 r> 2apply ]
+            [ >r drop first3 r> bi@ ]
         } dispatch
     ] [
         drop
         >r >r halves r> r>
-        [ [ binary-reduce ] 2curry 2apply ] keep
+        [ [ binary-reduce ] 2curry bi@ ] keep
         call
     ] if ; inline
 
index cc93aeeff25a4fcc750b44e4378e89a2f75d297c..2ec8f3d0d1398501a1f501ec2fe3723377a8c5bf 100755 (executable)
@@ -8,7 +8,7 @@ IN: slots.deprecated
 : reader-effect ( class spec -- effect )\r
     >r ?word-name 1array r> slot-spec-name 1array <effect> ;\r
 \r
-PREDICATE: word slot-reader "reading" word-prop >boolean ;\r
+PREDICATE: slot-reader < word "reading" word-prop >boolean ;\r
 \r
 : set-reader-props ( class spec -- )\r
     2dup reader-effect\r
@@ -30,7 +30,7 @@ PREDICATE: word slot-reader "reading" word-prop >boolean ;
 : writer-effect ( class spec -- effect )\r
     slot-spec-name swap ?word-name 2array 0 <effect> ;\r
 \r
-PREDICATE: word slot-writer "writing" word-prop >boolean ;\r
+PREDICATE: slot-writer < word "writing" word-prop >boolean ;\r
 \r
 : set-writer-props ( class spec -- )\r
     2dup writer-effect\r
index e4bb3078299d0d7ecda0f9124ce4e969a7121975..2b0d721f3e87c87ca424fa5c2a555bf3760d19b7 100755 (executable)
@@ -1,6 +1,6 @@
 USING: help.markup help.syntax generic kernel.private parser
 words kernel quotations namespaces sequences words arrays
-effects generic.standard tuples slots.private classes
+effects generic.standard classes.tuple slots.private classes
 strings math ;
 IN: slots
 
@@ -12,7 +12,7 @@ ARTICLE: "accessors" "Slot accessors"
 }
 "In addition, two utility words are defined for each distinct slot name used in the system:"
 { $list
-    { "The " { $emphasis "setter" } " is named " { $snippet "(>>" { $emphasis "slot" } ")" } " and stores a value into a slot. It has stack effect " { $snippet "( object value -- object )" } "." }
+    { "The " { $emphasis "setter" } " is named " { $snippet ">>" { $emphasis "slot" } } " and stores a value into a slot. It has stack effect " { $snippet "( object value -- object )" } "." }
     { "The " { $emphasis "changer" } " is named " { $snippet "change-" { $emphasis "slot" } } ". It applies a quotation to the current slot value and stores the result back in the slot; it has stack effect " { $snippet "( object quot -- object )" } "." }
 }
 "Since the reader and writer are generic, words can be written which do not depend on the specific class of tuple passed in, but instead work on any tuple that defines slots with certain names."
index ed5de3a4394e3afb8a655d050344c65635468c86..dfd5c1b32a113bf993a037de2877fb7b9521c372 100755 (executable)
@@ -46,7 +46,7 @@ C: <slot-spec> slot-spec
 : define-writer ( class slot name -- )
     writer-word [ set-slot ] define-slot-word ;
 
-: setter-effect T{ effect f { "object" "value" } { "value" } } ; inline
+: setter-effect T{ effect f { "object" "value" } { "object" } } ; inline
 
 : setter-word ( name -- word )
     ">>" prepend setter-effect create-accessor ;
index ab2ce210106cc19efbce0829b9cf2d05e43637c2..5f81b1718771d4905a94416a617b015d24969b36 100755 (executable)
@@ -32,7 +32,7 @@ DEFER: sort
     ] if ; inline
 
 : merge ( sorted1 sorted2 quot -- result )
-    >r [ [ <iterator> ] 2apply ] 2keep r>
+    >r [ [ <iterator> ] bi@ ] 2keep r>
     rot length rot length + <vector>
     [ (merge) ] keep underlying ; inline
 
index f4428e4e8b7bb9935950e33e58e3ad868fc66546..8dea367b6b48be1351e2d6bb0c5a89b614ee4c23 100755 (executable)
@@ -48,7 +48,7 @@ uses definitions ;
 
 : reset-checksums ( -- )
     source-files get [
-        swap ?resource-path dup exists? [
+        swap dup exists? [
             utf8 file-lines swap record-checksum
         ] [ 2drop ] if
     ] assoc-each ;
index 419a30dda4c37ead76d8c98c1475afe67cd8d834..9be1d5fc64a532575485c6071baa62b74ca28fb4 100755 (executable)
@@ -56,7 +56,7 @@ INSTANCE: groups sequence
     ] if ;
 
 : last-split1 ( seq subseq -- before after )
-    [ <reversed> ] 2apply split1 [ reverse ] 2apply
+    [ <reversed> ] bi@ split1 [ reverse ] bi@
     dup [ swap ] when ;
 
 : (split) ( separators n seq -- )
index c0ceb4119a0db2871f043928db7eb480963d863e..bd349953df9b1feae3fd638ba590808a5fc2d4bc 100755 (executable)
@@ -1,6 +1,6 @@
 USING: generic help.syntax help.markup kernel math parser words
-effects classes generic.standard tuples generic.math arrays
-io.files vocabs.loader io sequences assocs ;
+effects classes generic.standard classes.tuple generic.math
+arrays io.files vocabs.loader io sequences assocs ;
 IN: syntax
 
 ARTICLE: "parser-algorithm" "Parser algorithm"
@@ -543,8 +543,8 @@ HELP: INSTANCE:
 { $description "Makes " { $snippet "instance" } " an instance of " { $snippet "mixin" } "." } ;
 
 HELP: PREDICATE:
-{ $syntax "PREDICATE: superclass class predicate... ;" }
-{ $values { "superclass" "an existing class word" } { "class" "a new class word to define" } { "predicate" "membership test with stack effect " { $snippet "( superclass -- ? )" } } }
+{ $syntax "PREDICATE: class < superclass predicate... ;" }
+{ $values { "class" "a new class word to define" } { "superclass" "an existing class word" } { "predicate" "membership test with stack effect " { $snippet "( superclass -- ? )" } } }
 { $description
     "Defines a predicate class deriving from " { $snippet "superclass" } "."
     $nl
@@ -557,11 +557,9 @@ HELP: PREDICATE:
 } ;
 
 HELP: TUPLE:
-{ $syntax "TUPLE: class slots... ;" }
+{ $syntax "TUPLE: class slots... ;" "TUPLE: class < superclass slots ... ;" }
 { $values { "class" "a new tuple class to define" } { "slots" "a list of slot names" } }
-{ $description "Defines a new tuple class."
-$nl
-"Tuples are user-defined classes with instances composed of named slots. All tuple classes are subtypes of the built-in " { $link tuple } " type." } ;
+{ $description "Defines a new tuple class. The superclass is optional; if left unspecified, it defaults to " { $link tuple } "." } ;
 
 HELP: ERROR:
 { $syntax "ERROR: class slots... ;" }
index 843f3725423e6806acafc90f9eca43c9869d5079..19fdf0e45f2fb58999c05998d055d7368de04f01 100755 (executable)
@@ -3,10 +3,10 @@
 USING: alien arrays bit-arrays bit-vectors byte-arrays
 byte-vectors definitions generic hashtables kernel math
 namespaces parser sequences strings sbufs vectors words
-quotations io assocs splitting tuples generic.standard
+quotations io assocs splitting classes.tuple generic.standard
 generic.math classes io.files vocabs float-arrays float-vectors
 classes.union classes.mixin classes.predicate compiler.units
-combinators ;
+combinators debugger ;
 IN: bootstrap.syntax
 
 ! These words are defined as a top-level form, instead of with
@@ -148,13 +148,14 @@ IN: bootstrap.syntax
     ] define-syntax
 
     "PREDICATE:" [
-        scan-word
         CREATE-CLASS
+        scan "<" assert=
+        scan-word
         parse-definition define-predicate-class
     ] define-syntax
 
     "TUPLE:" [
-        CREATE-CLASS ";" parse-tokens define-tuple-class
+        parse-tuple-definition define-tuple-class
     ] define-syntax
 
     "C:" [
@@ -164,15 +165,13 @@ IN: bootstrap.syntax
     ] define-syntax
 
     "ERROR:" [
-        CREATE-CLASS dup ";" parse-tokens define-tuple-class
-        dup save-location
-        dup [ construct-boa throw ] curry define
+        parse-tuple-definition
+        pick save-location
+        define-error-class
     ] define-syntax
 
     "FORGET:" [
-        scan-word
-        dup parsing? [ V{ } clone swap execute first ] when
-        forget
+        scan-object forget
     ] define-syntax
 
     "(" [
diff --git a/core/tuples/authors.txt b/core/tuples/authors.txt
deleted file mode 100644 (file)
index 1901f27..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Slava Pestov
diff --git a/core/tuples/summary.txt b/core/tuples/summary.txt
deleted file mode 100644 (file)
index 4dbb643..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Object system implementation
diff --git a/core/tuples/tuples-docs.factor b/core/tuples/tuples-docs.factor
deleted file mode 100755 (executable)
index 09d9388..0000000
+++ /dev/null
@@ -1,290 +0,0 @@
-USING: generic help.markup help.syntax kernel
-tuples.private classes slots quotations words arrays
-generic.standard sequences definitions compiler.units ;
-IN: tuples
-
-ARTICLE: "tuple-constructors" "Constructors"
-"Tuples are created by calling one of two words:"
-{ $subsection construct-empty }
-{ $subsection construct-boa }
-"By convention, construction logic is encapsulated in a word named after the tuple class surrounded in angle brackets; for example, the constructor word for a " { $snippet "point" } " class might be named " { $snippet "<point>" } "."
-$nl
-"A shortcut for defining BOA constructors:"
-{ $subsection POSTPONE: C: }
-"Examples of constructors:"
-{ $code
-    "TUPLE: color red green blue alpha ;"
-    ""
-    "C: <rgba> rgba"
-    ": <rgba> color construct-boa ; ! identical to above"
-    ""
-    ": <rgb> f <rgba> ;"
-    ""
-    ": <color> construct-empty ;"
-    ": <color> f f f f <rgba> ; ! identical to above"
-} ;
-
-ARTICLE: "tuple-delegation" "Tuple delegation"
-"If a generic word having the " { $link standard-combination } " method combination is called on a tuple for which it does not have an applicable method, the method call is forwarded to the tuple's " { $emphasis "delegate" } ". If no delegate is set, a " { $link no-method } " error is thrown."
-{ $subsection delegate }
-{ $subsection set-delegate }
-"A tuple's delegate should either be another tuple, or " { $link f } ", indicating no delegate is set. Delegation from a tuple to an object of some other type is not fully supported and should be used with caution."
-$nl
-"Factor uses delegation in place of implementation inheritance, but it is not a direct substitute; in particular, the semantics differ in that a delegated method call receives the delegate on the stack, not the original object."
-$nl
-"A pair of words examine delegation chains:"
-{ $subsection delegates }
-{ $subsection is? }
-"An example:"
-{ $example
-    "TUPLE: ellipse center radius ;"
-    "TUPLE: colored color ;"
-    "{ 0 0 } 10 <ellipse> \"my-ellipse\" set"
-    "{ 1 0 0 } <colored> \"my-shape\" set"
-    "\"my-ellipse\" get \"my-shape\" get set-delegate"
-    "\"my-shape\" get dup color>> swap center>> .s"
-    "{ 0 0 }\n{ 1 0 0 }"
-} ;
-
-ARTICLE: "tuple-introspection" "Tuple introspection"
-"In addition to the slot reader and writer words which " { $link POSTPONE: TUPLE: } " defines for every tuple class, it is possible to construct and take apart entire tuples in a generic way."
-{ $subsection >tuple }
-{ $subsection tuple>array }
-{ $subsection tuple-slots }
-"Tuple classes can also be defined at run time:"
-{ $subsection define-tuple-class }
-{ $see-also "slots" "mirrors" } ;
-
-ARTICLE: "tuple-examples" "Tuple examples"
-"An example:"
-{ $code "TUPLE: employee name salary position ;" }
-"This defines a class word named " { $snippet "employee" } ", a predicate " { $snippet "employee?" } ", and the following slot accessors:"
-{ $table
-    { "Reader" "Writer" "Setter" "Changer" }
-    { { $snippet "name>>" }    { $snippet "(>>name)" }    { $snippet ">>name" }    { $snippet "change-name" }    }
-    { { $snippet "salary>>" } { $snippet "(>>salary)" } { $snippet ">>salary" } { $snippet "change-salary" } }
-    { { $snippet "position>>" }   { $snippet "(>>position)" }   { $snippet ">>position" }   { $snippet "change-position" }   }
-}
-"We can define a constructor which makes an empty employee:"
-{ $code ": <employee> ( -- employee )"
-    "    employee construct-empty ;" }
-"Or we may wish the default constructor to always give employees a starting salary:"
-{ $code
-    ": <employee> ( -- employee )"
-    "    employee construct-empty"
-    "        40000 >>salary ;"
-}
-"We can define more refined constructors:"
-{ $code
-    ": <manager> ( -- manager )"
-    "    <employee> \"project manager\" >>position ;" }
-"An alternative strategy is to define the most general BOA constructor first:"
-{ $code
-    ": <employee> ( name position -- person )"
-    "    40000 employee construct-boa ;"
-}
-"Now we can define more specific constructors:"
-{ $code
-    ": <manager> ( name -- person )"
-    "    \"manager\" <person> ;" }
-"An example using reader words:"
-{ $code
-    "TUPLE: check to amount number ;"
-    ""
-    "SYMBOL: checks"
-    ""
-    ": <check> ( to amount -- check )"
-    "    checks counter check construct-boa ;"
-    ""
-    ": biweekly-paycheck ( employee -- check )"
-    "    dup name>> swap salary>> 26 / <check> ;"
-}
-"An example of using a changer:"
-{ $code
-    ": positions"
-    "    {"
-    "        \"junior programmer\""
-    "        \"senior programmer\""
-    "        \"project manager\""
-    "        \"department manager\""
-    "        \"executive\""
-    "        \"CTO\""
-    "        \"CEO\""
-    "        \"enterprise Java world dictator\""
-    "    } ;"
-    ""
-    ": next-position ( role -- newrole )"
-    "    positions [ index 1+ ] keep nth ;"
-    ""
-    ": promote ( person -- person )"
-    "    [ 1.2 * ] change-salary"
-    "    [ next-position ] change-position ;"
-} ;
-
-ARTICLE: "tuples" "Tuples"
-"Tuples are user-defined classes composed of named slots."
-{ $subsection "tuple-examples" }
-"A parsing word defines tuple classes:"
-{ $subsection POSTPONE: TUPLE: }
-"For each tuple class, several words are defined. First, there is the class word, a class predicate, and accessor words for each slot."
-$nl
-"The class word is used for defining methods on the tuple class; it has the same name as the tuple class. The predicate is named " { $snippet { $emphasis "name" } "?" } ". Tuple slots are accessed via accessor words:"
-{ $subsection "accessors" }
-"Initially, no specific words are defined for constructing new instances of the tuple. Constructors must be defined explicitly:"
-{ $subsection "tuple-constructors" }
-"Further topics:"
-{ $subsection "tuple-delegation" }
-{ $subsection "tuple-introspection" }
-"Tuple literal syntax is documented in " { $link "syntax-tuples" } "." ;
-
-ABOUT: "tuples"
-
-HELP: delegate
-{ $values { "obj" object } { "delegate" object } }
-{ $description "Returns an object's delegate, or " { $link f } " if no delegate is set." }
-{ $notes "A direct consequence of this behavior is that an object may not have a delegate of " { $link f } "." } ;
-
-HELP: set-delegate
-{ $values { "delegate" object } { "tuple" tuple } }
-{ $description "Sets a tuple's delegate. Method calls not handled by the tuple's class will now be passed on to the delegate." } ;
-
-HELP: tuple=
-{ $values { "tuple1" tuple } { "tuple2" tuple } { "?" "a boolean" } }
-{ $description "Low-level tuple equality test. User code should use " { $link = } " instead." }
-{ $warning "This word is in the " { $vocab-link "tuples.private" } " vocabulary because it does not do any type checking. Passing values which are not tuples can result in memory corruption." } ;
-
-HELP: tuple-class-eq?
-{ $values { "obj" object } { "class" tuple-class } { "?" "a boolean" } }
-{ $description "Tests if " { $snippet "obj" } " is an instance of " { $snippet "class" } "." } ;
-
-HELP: permutation
-{ $values { "seq1" sequence } { "seq2" sequence } { "permutation" "a sequence whose elements are integers or " { $link f } } }
-{ $description "Outputs a permutation for taking " { $snippet "seq1" } " to " { $snippet "seq2" } "." } ;
-
-HELP: reshape-tuple
-{ $values { "oldtuple" tuple } { "permutation" "a sequence whose elements are integers or " { $link f } } { "newtuple" tuple } }
-{ $description "Permutes the slots of a tuple. If a tuple class is redefined at runtime, this word is called on every instance to change its shape to conform to the new layout." } ;
-
-HELP: reshape-tuples
-{ $values { "class" tuple-class } { "newslots" "a sequence of strings" } }
-{ $description "Changes the shape of every instance of " { $snippet "class" } " for a new slot layout." } ;
-
-HELP: old-slots
-{ $values { "class" tuple-class } { "newslots" "a sequence of strings" } { "seq" "a sequence of strings" } }
-{ $description "Outputs the sequence of existing tuple slot names not in " { $snippet "newslots" } "." } ;
-
-HELP: forget-slots
-{ $values { "class" tuple-class } { "newslots" "a sequence of strings" } }
-{ $description "Forgets accessor words for existing tuple slots which are not in " { $snippet "newslots" } "." } ;
-
-HELP: tuple
-{ $class-description "The class of tuples. This class is further partitioned into disjoint subclasses; each tuple shape defined by " { $link POSTPONE: TUPLE: } " is a new class."
-$nl
-"Tuple classes have additional word properties:"
-{ $list
-    { { $snippet "\"constructor\"" } " - a word for creating instances of this tuple class" }
-    { { $snippet "\"predicate\"" } " - a quotation which tests if the top of the stack is an instance of this tuple class" }
-    { { $snippet "\"slots\"" } " - a sequence of " { $link slot-spec } " instances" }
-    { { $snippet "\"slot-names\"" } " - a sequence of strings naming the tuple's slots" }
-    { { $snippet "\"tuple-size\"" } " - the number of slots" }
-} } ;
-
-HELP: define-tuple-predicate
-{ $values { "class" tuple-class } }
-{ $description "Defines a predicate word that tests if the top of the stack is an instance of " { $snippet "class" } ". This will only work if " { $snippet "class" } " is a tuple class." }
-$low-level-note ;
-
-HELP: check-shape
-{ $values { "class" class } { "newslots" "a sequence of strings" } }
-{ $description "If the new slot layout differs from the existing one, updates all existing instances of this tuple class, and forgets any slot accessor words which are no longer needed."
-$nl
-"If the class is not a tuple class word, this word does nothing." }
-$low-level-note ;
-
-HELP: tuple-slots
-{ $values { "tuple" tuple } { "seq" sequence } }
-{ $description "Pushes a sequence of tuple slot values, not including the tuple class word and delegate." } ;
-
-{ tuple-slots tuple>array } related-words
-
-HELP: define-tuple-slots
-{ $values { "class" tuple-class } { "slots" "a sequence of strings" } }
-{ $description "Defines slot accessor and mutator words for the tuple." }
-$low-level-note ;
-
-HELP: check-tuple
-{ $values { "class" class } }
-{ $description "Throws a " { $link check-tuple } " error if " { $snippet "word" } " is not a tuple class word." }
-{ $error-description "Thrown if " { $link POSTPONE: C: } " is called with a word which does not name a tuple class." } ;
-
-HELP: define-tuple-class
-{ $values { "class" word } { "slots" "a sequence of strings" } }
-{ $description "Defines a tuple class with slots named by " { $snippet "slots" } ". This is the run time equivalent of " { $link POSTPONE: TUPLE: } "." }
-{ $notes "This word must be called from inside " { $link with-compilation-unit } "." }
-{ $side-effects "class" } ;
-
-{ tuple-class define-tuple-class POSTPONE: TUPLE: } related-words
-
-HELP: delegates
-{ $values { "obj" object } { "seq" sequence } }
-{ $description "Outputs the delegation chain of an object. The first element of " { $snippet "seq" } " is " { $snippet "obj" } " itself. If " { $snippet "obj" } " is " { $link f } ", an empty sequence is output." } ;
-
-HELP: is?
-{ $values { "obj" object } { "quot" "a quotation with stack effect " { $snippet "( obj -- ? )" } } { "?" "a boolean" } }
-{ $description "Tests if the object or one of its delegates satisfies the predicate quotation."
-$nl
-"Class membership test predicates only test if an object is a direct instance of that class. Sometimes, you need to check delegates, since this gives a clearer picture of what operations the object supports." } ;
-
-HELP: >tuple
-{ $values { "seq" sequence } { "tuple" tuple } }
-{ $description "Creates a tuple with slot values taken from a sequence. The first element of the sequence must be a tuple class word, the second a delegate, and the remainder the declared slots."
-$nl
-"If the sequence has too many elements, they are ignored, and if it has too few, the remaining slots in the tuple are set to " { $link f } "." }
-{ $errors "Throws an error if the first element of the sequence is not a tuple class word." } ;
-
-HELP: tuple>array ( tuple -- array )
-{ $values { "tuple" tuple } { "array" array } }
-{ $description "Outputs an array having the tuple's slots as elements. The first element is the tuple class word and the second is the delegate; the remainder are declared slots." } ;
-
-HELP: <tuple> ( class n -- tuple )
-{ $values { "class" tuple-class } { "n" "a non-negative integer" } { "tuple" tuple } }
-{ $description "Low-level tuple constructor. User code should never call this directly, and instead use the constructor word which is defined for each tuple. See " { $link "tuples" } "." } ;
-
-HELP: construct-empty
-{ $values { "class" tuple-class } { "tuple" tuple } }
-{ $description "Creates a new instance of " { $snippet "class" } " with all slots initially set to " { $link f } "." }
-{ $examples
-    { $example
-        "USING: kernel prettyprint ;"
-        "TUPLE: employee number name department ;"
-        "employee construct-empty ."
-        "T{ employee f f f f }"
-    }
-} ;
-
-HELP: construct
-{ $values { "..." "slot values" } { "slots" "a sequence of setter words" } { "class" tuple-class } { "tuple" tuple } }
-{ $description "Creates a new instance of " { $snippet "class" } ", storing consecutive stack values into the slots of the new tuple using setter words in " { $snippet "slots" } ". The top-most stack element is stored in the right-most slot." }
-{ $examples
-    "We can define a class:"
-    { $code "TUPLE: color red green blue alpha ;" }
-    "Together with two constructors:"
-    { $code
-        ": <rgb> ( r g b -- color )"
-        "    { set-color-red set-color-green set-color-blue }"
-        "    color construct ;"
-        ""
-        ": <rgba> ( r g b a -- color )"
-        "    { set-color-red set-color-green set-color-blue set-color-alpha }"
-        "    color construct ;"
-    }
-    "The last definition is actually equivalent to the following:"
-    { $code ": <rgba> ( r g b a -- color ) rgba construct-boa ;" }
-    "Which can be abbreviated further:"
-    { $code "C: <rgba> color" }
-} ;
-
-HELP: construct-boa
-{ $values { "..." "slot values" } { "class" tuple-class } { "tuple" tuple } }
-{ $description "Creates a new instance of " { $snippet "class" } " and fill in the slots from the stack, with the top-most stack element being stored in the right-most slot." }
-{ $notes "The " { $snippet "-boa" } " suffix is shorthand for ``by order of arguments'', and ``BOA constructor'' is a pun on ``boa constrictor''." } ;
diff --git a/core/tuples/tuples-tests.factor b/core/tuples/tuples-tests.factor
deleted file mode 100755 (executable)
index b5076ea..0000000
+++ /dev/null
@@ -1,276 +0,0 @@
-USING: definitions generic kernel kernel.private math
-math.constants parser sequences tools.test words assocs
-namespaces quotations sequences.private classes continuations
-generic.standard effects tuples tuples.private arrays vectors
-strings compiler.units ;
-IN: tuples.tests
-
-[ t ] [ \ tuple-class \ class class< ] unit-test
-[ f ] [ \ class \ tuple-class class< ] unit-test
-
-TUPLE: rect x y w h ;
-: <rect> rect construct-boa ;
-
-: move ( x rect -- )
-    [ rect-x + ] keep set-rect-x ;
-
-[ f ] [ 10 20 30 40 <rect> dup clone 5 swap [ move ] keep = ] unit-test
-
-[ t ] [ 10 20 30 40 <rect> dup clone 0 swap [ move ] keep = ] unit-test
-
-GENERIC: delegation-test
-M: object delegation-test drop 3 ;
-TUPLE: quux-tuple ;
-: <quux-tuple> quux-tuple construct-empty ;
-M: quux-tuple delegation-test drop 4 ;
-TUPLE: quuux-tuple ;
-: <quuux-tuple> { set-delegate } quuux-tuple construct ;
-
-[ 3 ] [ <quux-tuple> <quuux-tuple> delegation-test ] unit-test
-
-GENERIC: delegation-test-2
-TUPLE: quux-tuple-2 ;
-: <quux-tuple-2> quux-tuple-2 construct-empty ;
-M: quux-tuple-2 delegation-test-2 drop 4 ;
-TUPLE: quuux-tuple-2 ;
-: <quuux-tuple-2> { set-delegate } quuux-tuple-2 construct ;
-
-[ 4 ] [ <quux-tuple-2> <quuux-tuple-2> delegation-test-2 ] unit-test
-
-! Make sure we handle changing shapes!
-TUPLE: point x y ;
-
-C: <point> point
-
-100 200 <point> "p" set
-
-! Use eval to sequence parsing explicitly
-"IN: tuples.tests TUPLE: point x y z ;" eval
-
-[ 100 ] [ "p" get point-x ] unit-test
-[ 200 ] [ "p" get point-y ] unit-test
-[ f ] [ "p" get "point-z" "tuples.tests" lookup execute ] unit-test
-
-300 "p" get "set-point-z" "tuples.tests" lookup execute
-
-"IN: tuples.tests TUPLE: point z y ;" eval
-
-[ "p" get point-x ] must-fail
-[ 200 ] [ "p" get point-y ] unit-test
-[ 300 ] [ "p" get "point-z" "tuples.tests" lookup execute ] unit-test
-
-TUPLE: predicate-test ;
-
-C: <predicate-test> predicate-test
-
-: predicate-test drop f ;
-
-[ t ] [ <predicate-test> predicate-test? ] unit-test
-
-PREDICATE: tuple silly-pred
-    class \ rect = ;
-
-GENERIC: area
-M: silly-pred area dup rect-w swap rect-h * ;
-
-TUPLE: circle radius ;
-M: circle area circle-radius sq pi * ;
-
-[ 200 ] [ T{ rect f 0 0 10 20 } area ] unit-test
-
-! Hashcode breakage
-TUPLE: empty ;
-
-C: <empty> empty
-
-[ t ] [ <empty> hashcode fixnum? ] unit-test
-
-TUPLE: delegate-clone ;
-
-[ T{ delegate-clone T{ empty f } } ]
-[ T{ delegate-clone T{ empty f } } clone ] unit-test
-
-[ t ] [ \ null \ delegate-clone class< ] unit-test
-[ f ] [ \ object \ delegate-clone class< ] unit-test
-[ f ] [ \ object \ delegate-clone class< ] unit-test
-[ t ] [ \ delegate-clone \ tuple class< ] unit-test
-[ f ] [ \ tuple \ delegate-clone class< ] unit-test
-
-! Compiler regression
-[ t length ] [ no-method-object t eq? ] must-fail-with
-
-[ "<constructor-test>" ]
-[ "TUPLE: constructor-test ; C: <constructor-test> constructor-test" eval word word-name ] unit-test
-
-TUPLE: size-test a b c d ;
-
-[ t ] [
-    T{ size-test } array-capacity
-    size-test tuple-size =
-] unit-test
-
-GENERIC: <yo-momma>
-
-TUPLE: yo-momma ;
-
-"IN: tuples.tests C: <yo-momma> yo-momma" eval
-
-[ f ] [ \ <yo-momma> generic? ] unit-test
-
-! Test forget
-[
-    [ t ] [ \ yo-momma class? ] unit-test
-    [ ] [ \ yo-momma forget ] unit-test
-    [ f ] [ \ yo-momma typemap get values memq? ] unit-test
-
-    [ f ] [ \ yo-momma crossref get at ] unit-test
-] with-compilation-unit
-
-TUPLE: loc-recording ;
-
-[ f ] [ \ loc-recording where not ] unit-test
-
-! 'forget' wasn't robust enough
-
-TUPLE: forget-robustness ;
-
-GENERIC: forget-robustness-generic
-
-M: forget-robustness forget-robustness-generic ;
-
-M: integer forget-robustness-generic ;
-
-[
-    [ ] [ \ forget-robustness-generic forget ] unit-test
-    [ ] [ \ forget-robustness forget ] unit-test
-    [ ] [ { forget-robustness forget-robustness-generic } forget ] unit-test
-] with-compilation-unit
-
-! rapido found this one
-GENERIC# m1 0 ( s n -- n )
-GENERIC# m2 1 ( s n -- v )
-
-TUPLE: t1 ;
-
-M: t1 m1 drop ;
-M: t1 m2 nip ;
-
-TUPLE: t2 ;
-
-M: t2 m1 drop ;
-M: t2 m2 nip ;
-
-TUPLE: t3 ;
-
-M: t3 m1 drop ;
-M: t3 m2 nip ;
-
-TUPLE: t4 ;
-
-M: t4 m1 drop ;
-M: t4 m2 nip ;
-
-C: <t4> t4
-
-[ 1 ] [ 1 <t4> m1 ] unit-test
-[ 1 ] [ <t4> 1 m2 ] unit-test
-
-! another combination issue
-GENERIC: silly
-
-UNION: my-union slice repetition column array vector reversed ;
-
-M: my-union silly "x" ;
-
-M: array silly "y" ;
-
-M: column silly "fdsfds" ;
-
-M: repetition silly "zzz" ;
-
-M: reversed silly "zz" ;
-
-M: slice silly "tt" ;
-
-M: string silly "t" ;
-
-M: vector silly "z" ;
-
-[ "zz" ] [ 123 <reversed> silly nip ] unit-test
-
-! Typo
-SYMBOL: not-a-tuple-class
-
-[
-    "IN: tuples.tests C: <not-a-tuple-class> not-a-tuple-class"
-    eval
-] must-fail
-
-[ t ] [
-    "not-a-tuple-class" "tuples.tests" lookup symbol?
-] unit-test
-
-! Missing check
-[ not-a-tuple-class construct-boa ] must-fail
-[ not-a-tuple-class construct-empty ] must-fail
-
-TUPLE: erg's-reshape-problem a b c d ;
-
-C: <erg's-reshape-problem> erg's-reshape-problem
-
-! We want to make sure constructors are recompiled when
-! tuples are reshaped
-: cons-test-1 \ erg's-reshape-problem construct-empty ;
-: cons-test-2 \ erg's-reshape-problem construct-boa ;
-: cons-test-3
-    { set-erg's-reshape-problem-a }
-    \ erg's-reshape-problem construct ;
-
-"IN: tuples.tests TUPLE: erg's-reshape-problem a b c d e f ;" eval
-
-[ ] [ 1 2 3 4 5 6 cons-test-2 "a" set ] unit-test
-
-[ t ] [ cons-test-1 array-capacity "a" get array-capacity = ] unit-test
-
-[ t ] [ 1 cons-test-3 array-capacity "a" get array-capacity = ] unit-test
-
-[
-    "IN: tuples.tests SYMBOL: not-a-class C: <not-a-class> not-a-class" eval
-] [ [ no-tuple-class? ] is? ] must-fail-with
-
-! Hardcore unit tests
-USE: threads
-
-\ thread "slot-names" word-prop "slot-names" set
-
-[ ] [
-    [
-        \ thread { "xxx" } "slot-names" get append
-        define-tuple-class
-    ] with-compilation-unit
-
-    [ 1337 sleep ] "Test" spawn drop
-
-    [
-        \ thread "slot-names" get
-        define-tuple-class
-    ] with-compilation-unit
-] unit-test
-
-USE: vocabs
-
-\ vocab "slot-names" word-prop "slot-names" set
-
-[ ] [
-    [
-        \ vocab { "xxx" } "slot-names" get append
-        define-tuple-class
-    ] with-compilation-unit
-
-    all-words drop
-
-    [
-        \ vocab "slot-names" get
-        define-tuple-class
-    ] with-compilation-unit
-] unit-test
diff --git a/core/tuples/tuples.factor b/core/tuples/tuples.factor
deleted file mode 100755 (executable)
index 02ce49d..0000000
+++ /dev/null
@@ -1,150 +0,0 @@
-! Copyright (C) 2005, 2007 Slava Pestov.
-! See http://factorcode.org/license.txt for BSD license.
-USING: arrays definitions hashtables kernel
-kernel.private math namespaces sequences sequences.private
-strings vectors words quotations memory combinators generic
-classes classes.private slots slots.deprecated slots.private
-compiler.units ;
-IN: tuples
-
-M: tuple delegate 3 slot ;
-
-M: tuple set-delegate 3 set-slot ;
-
-M: tuple class class-of-tuple ;
-
-<PRIVATE
-
-: tuple= ( tuple1 tuple2 -- ? )
-    over array-capacity over array-capacity tuck number= [
-        -rot
-        [ >r over r> array-nth >r array-nth r> = ] 2curry
-        all-integers?
-    ] [
-        3drop f
-    ] if ;
-
-: tuple-class-eq? ( obj class -- ? )
-    over tuple? [ swap 2 slot eq? ] [ 2drop f ] if ; inline
-
-: permutation ( seq1 seq2 -- permutation )
-    swap [ index ] curry map ;
-
-: reshape-tuple ( oldtuple permutation -- newtuple )
-    >r tuple>array 2 cut r>
-    [ [ swap ?nth ] [ drop f ] if* ] with map
-    append (>tuple) ;
-
-: reshape-tuples ( class newslots -- )
-    >r dup "slot-names" word-prop r> permutation
-    [
-        >r [ swap class eq? ] curry instances dup r>
-        [ reshape-tuple ] curry map
-        become
-    ] 2curry after-compilation ;
-
-: old-slots ( class newslots -- seq )
-    swap "slots" word-prop 1 tail-slice
-    [ slot-spec-name swap member? not ] with subset ;
-
-: forget-slots ( class newslots -- )
-    dupd old-slots [
-        2dup
-        slot-spec-reader 2array forget
-        slot-spec-writer 2array forget
-    ] with each ;
-
-: check-shape ( class newslots -- )
-    over tuple-class? [
-        over "slot-names" word-prop over = [
-            2dup forget-slots
-            2dup reshape-tuples
-            over changed-word
-            over redefined
-        ] unless
-    ] when 2drop ;
-
-GENERIC: tuple-size ( class -- size )
-
-M: tuple-class tuple-size "slot-names" word-prop length 2 + ;
-
-PRIVATE>
-
-: define-tuple-predicate ( class -- )
-    dup [ tuple-class-eq? ] curry define-predicate ;
-
-: delegate-slot-spec
-    T{ slot-spec f
-        object
-        "delegate"
-        3
-        delegate
-        set-delegate
-    } ;
-
-: define-tuple-slots ( class slots -- )
-    dupd 4 simple-slots
-    2dup [ slot-spec-name ] map "slot-names" set-word-prop
-    2dup delegate-slot-spec add* "slots" set-word-prop
-    2dup define-slots
-    define-accessors ;
-
-ERROR: no-tuple-class class ;
-
-: check-tuple ( class -- )
-    dup tuple-class?
-    [ drop ] [ no-tuple-class ] if ;
-
-: define-tuple-class ( class slots -- )
-    2dup check-shape
-    over f tuple tuple-class define-class
-    over define-tuple-predicate
-    define-tuple-slots ;
-
-M: tuple clone
-    (clone) dup delegate clone over set-delegate ;
-
-M: tuple equal?
-    over tuple? [ tuple= ] [ 2drop f ] if ;
-
-: (delegates) ( obj -- )
-    [ dup , delegate (delegates) ] when* ;
-
-: delegates ( obj -- seq )
-    [ dup ] [ [ delegate ] keep ] [ ] unfold nip ;
-
-: is? ( obj quot -- ? ) >r delegates r> contains? ; inline
-
-: >tuple ( seq -- tuple )
-    >vector dup first tuple-size over set-length
-    >array (>tuple) ;
-
-M: tuple hashcode*
-    [
-        dup array-capacity -rot 0 -rot [
-            swapd array-nth hashcode* bitxor
-        ] 2curry reduce
-    ] recursive-hashcode ;
-
-: tuple-slots ( tuple -- seq ) tuple>array 2 tail ;
-
-! Definition protocol
-M: tuple-class reset-class
-    {
-        "metaclass" "superclass" "slot-names" "slots"
-    } reset-props ;
-
-M: object get-slots ( obj slots -- ... )
-    [ execute ] with each ;
-
-M: object set-slots ( ... obj slots -- )
-    <reversed> get-slots ;
-
-M: object construct-empty ( class -- tuple )
-    dup tuple-size <tuple> ;
-
-M: object construct ( ... slots class -- tuple )
-    construct-empty [ swap set-slots ] keep ;
-
-M: object construct-boa ( ... class -- tuple )
-    dup tuple-size <tuple-boa> ;
index d990f5f31cbe9dbb9b0c79a8617169ec9b142dba..18aa0f3fa776f60e003b430339432e040a0abe15 100755 (executable)
@@ -77,7 +77,7 @@ IN: vectors.tests
 
 [ f ] [
     V{ 1 2 3 4 } dup clone
-    [ underlying ] 2apply eq?
+    [ underlying ] bi@ eq?
 ] unit-test
 
 [ 0 ] [
index 85399ca9e71728efbd7ecd28fa9db568675c48a2..4b978932bc58cb010caac6d4654071019edb9308 100755 (executable)
@@ -2,7 +2,7 @@
 IN: vocabs.loader.tests
 USING: vocabs.loader tools.test continuations vocabs math
 kernel arrays sequences namespaces io.streams.string
-parser source-files words assocs tuples definitions
+parser source-files words assocs classes.tuple definitions
 debugger compiler.units tools.vocabs ;
 
 ! This vocab should not exist, but just in case...
@@ -68,7 +68,7 @@ IN: vocabs.loader.tests
     <string-reader>
     "resource:core/vocabs/loader/test/a/a.factor"
     parse-stream
-] [ [ no-word? ] is? ] must-fail-with
+] [ [ no-word-error? ] is? ] must-fail-with
 
 0 "count-me" set-global
 
index 9478c1f4f7a7d33773edaf2a31f389d24f919d03..57947eefb031cc89c9b93ba2f8bb2ce5c354aa3a 100755 (executable)
@@ -25,7 +25,7 @@ V{
 
 : vocab-dir? ( root name -- ? )
     over [
-        ".factor" vocab-dir+ append-path resource-exists?
+        ".factor" vocab-dir+ append-path exists?
     ] [
         2drop f
     ] if ;
index f111b5bc7410d14c6715699f93e6bfedacdd62f6..886417b715a73df72ef31e5a9c4e0d8050686342 100755 (executable)
@@ -94,7 +94,7 @@ TUPLE: vocab-link name ;
 
 M: vocab-link equal?
     over vocab-link?
-    [ [ vocab-link-name ] 2apply = ] [ 2drop f ] if ;
+    [ [ vocab-link-name ] bi@ = ] [ 2drop f ] if ;
 
 M: vocab-link hashcode*
     vocab-link-name hashcode* ;
index 4d9933147b970885313121612958a78e69b1fed4..cef6b1994389e82a7db13e75b6baff8bb623836f 100755 (executable)
@@ -1,6 +1,7 @@
 USING: arrays generic assocs kernel math namespaces
 sequences tools.test words definitions parser quotations
-vocabs continuations tuples compiler.units io.streams.string ;
+vocabs continuations classes.tuple compiler.units
+io.streams.string ;
 IN: words.tests
 
 [ 4 ] [
index de253e6fee679bf619ee3b849a1d730c8428a75b..5c0d84d4cc16f2f7242e62b6384bffed536cd7cc 100755 (executable)
@@ -23,17 +23,17 @@ M: word definition word-def ;
 
 ERROR: undefined ;
 
-PREDICATE: word deferred ( obj -- ? )
+PREDICATE: deferred < word ( obj -- ? )
     word-def [ undefined ] = ;
 M: deferred definer drop \ DEFER: f ;
 M: deferred definition drop f ;
 
-PREDICATE: word symbol ( obj -- ? )
+PREDICATE: symbol < word ( obj -- ? )
     dup <wrapper> 1array swap word-def sequence= ;
 M: symbol definer drop \ SYMBOL: f ;
 M: symbol definition drop f ;
 
-PREDICATE: word primitive ( obj -- ? )
+PREDICATE: primitive < word ( obj -- ? )
     word-def [ do-primitive ] tail? ;
 M: primitive definer drop \ PRIMITIVE: f ;
 M: primitive definition drop f ;
index 19d89f67f0dc247026eb986493c5236fb70e9a95..987122f05cfbd3c4a4dc480ccda11fec99ef82ea 100644 (file)
@@ -1,6 +1,6 @@
 
 USING: kernel parser namespaces quotations arrays vectors strings
-       sequences assocs tuples math combinators ;
+       sequences assocs classes.tuple math combinators ;
 
 IN: bake
 
index 26f1a9e96d6967f37851e01e01115c6938a136f4..a75251331f3c6a8449c00876503157ddfd463971 100755 (executable)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel vocabs vocabs.loader tools.time tools.vocabs
 arrays assocs io.styles io help.markup prettyprint sequences
-continuations debugger combinators.cleave ;
+continuations debugger ;
 IN: benchmark
 
 : run-benchmark ( vocab -- result )
index dbd1f5131b1bc2e8035c8c9084880dcfb2fb5a36..3ec8cb4245e68212279365276635989bd458da55 100755 (executable)
@@ -133,7 +133,7 @@ DEFER: create ( level c r -- scene )
     pick 1 = [ <sphere> nip ] [ create-group ] if ;
 
 : ss-point ( dx dy -- point )
-    [ oversampling /f ] 2apply 0.0 3float-array ;
+    [ oversampling /f ] bi@ 0.0 3float-array ;
 
 : ss-grid ( -- ss-grid )
     oversampling [ oversampling [ ss-point ] with map ] map ;
@@ -150,7 +150,7 @@ DEFER: create ( level c r -- scene )
 : pixel-grid ( -- grid )
     size reverse [
         size [
-            [ size 0.5 * - ] 2apply swap size
+            [ size 0.5 * - ] bi@ swap size
             3float-array
         ] with map
     ] map ;
index c8d4714802e4c7c1039668722c35ae59ea5e307f..c66de87cb584152ab1d86c6c05dad852939ad88c 100755 (executable)
@@ -5,7 +5,7 @@ io.files kernel ;
 [ "c071aa7e007a9770b2fb4304f55a17e5" ] [\r
     "extra/benchmark/reverse-complement/reverse-complement-test-in.txt"\r
     "extra/benchmark/reverse-complement/reverse-complement-test-out.txt"\r
-    [ resource-path ] 2apply\r
+    [ resource-path ] bi@\r
     reverse-complement\r
 \r
     "extra/benchmark/reverse-complement/reverse-complement-test-out.txt"\r
index 9c782e65e618492b0abdf201f62de506f8c90a1b..d83b72018799976f11277f7c3726fbcbaad47d86 100755 (executable)
@@ -1,6 +1,6 @@
 USING: io io.files io.streams.duplex kernel sequences
 sequences.private strings vectors words memoize splitting
-hints unicode.case continuations io.encodings.latin1 ;
+hints unicode.case continuations io.encodings.ascii ;
 IN: benchmark.reverse-complement
 
 MEMO: trans-map ( -- str )
@@ -32,8 +32,8 @@ HINTS: do-line vector string ;
     readln [ do-line (reverse-complement) ] [ show-seq ] if* ;
 
 : reverse-complement ( infile outfile -- )
-    latin1 <file-writer> [
-        swap latin1 <file-reader> [
+    ascii <file-writer> [
+        swap ascii <file-reader> [
             swap <duplex-stream> [
                 500000 <vector> (reverse-complement)
             ] with-stream
index 42bae7d0d1cda0b65ca221ef6b5217684ac3f33a..7eddeefc1b0a97717590a25085466dfebb8d399f 100644 (file)
@@ -7,7 +7,7 @@ IN: benchmark.spectral-norm
 : fast-truncate >fixnum >float ; inline
 
 : eval-A ( i j -- n )
-    [ >float ] 2apply
+    [ >float ] bi@
     dupd + dup 1+ * 2 /f fast-truncate + 1+
     recip ; inline
 
index d7977063eece6d9642ff67615a79fd9e3a4398aa..0fc1debb670dc35d4e5203f26b161d9dc140a30c 100644 (file)
@@ -3,7 +3,7 @@ IN: benchmark.typecheck2
 
 TUPLE: hello n ;
 
-: hello-n* dup tuple? [ 4 slot ] [ 3 throw ] if ;
+: hello-n* dup tuple? [ 3 slot ] [ 3 throw ] if ;
 
 : foo 0 100000000 [ over hello-n* + ] times ;
 
index e85fb2850ca381fd9204b0d444d70f2990e23a23..9a58e0a79587fbb63d7576d72c2e4b58351d6656 100644 (file)
@@ -3,7 +3,7 @@ IN: benchmark.typecheck3
 
 TUPLE: hello n ;
 
-: hello-n* dup tag 2 eq? [ 4 slot ] [ 3 throw ] if ;
+: hello-n* dup tag 2 eq? [ 3 slot ] [ 3 throw ] if ;
 
 : foo 0 100000000 [ over hello-n* + ] times ;
 
index a1362a68ab6d8250c92399c37cdd1091c7adf73c..eb211e97e72c396e8588b62b3a083bdb65bb5a8f 100644 (file)
@@ -3,7 +3,7 @@ IN: benchmark.typecheck4
 
 TUPLE: hello n ;
 
-: hello-n* 4 slot ;
+: hello-n* 3 slot ;
 
 : foo 0 100000000 [ over hello-n* + ] times ;
 
index 175f66f4a6b79b29325be9a3f0b378d4180c24c0..114809377b71f74877991179653f74f9d33df82a 100644 (file)
@@ -63,7 +63,7 @@ M: check< summary drop "Number exceeds upper bound" ;
     [ range>accessor ] map ;
 
 : clear-range ( range -- num )
-    first2 dupd + [ 2^ 1- ] 2apply bitnot bitor ;
+    first2 dupd + [ 2^ 1- ] bi@ bitnot bitor ;
 
 : range>setter ( range -- quot )
     [
index 611e00a9b4af04eb2ce5326409ec542b57a46cf0..4ea20629c1192a3a0b644fb8aeb7d9df16201580 100644 (file)
@@ -6,7 +6,6 @@ USING: kernel namespaces
        math.vectors
        math.trig
        combinators arrays sequences random vars
-       combinators.cleave
        combinators.lib ;
 
 IN: boids
@@ -81,7 +80,7 @@ VAR: separation-radius
 
 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
-: relative-position ( self other -- v ) swap [ boid-pos ] 2apply v- ;
+: relative-position ( self other -- v ) swap [ boid-pos ] bi@ v- ;
 
 : relative-angle ( self other -- angle )
 over boid-vel -rot relative-position angle-between ;
index b545f4106029e4a029fa5b685e5c936a2a098ef2..a1feac381dd21044c927e540b6c3e1ccccbdf9aa 100755 (executable)
@@ -19,7 +19,6 @@ USING: kernel namespaces
        ui.gadgets.packs
        ui.gadgets.grids
        ui.gestures
-       combinators.cleave
        assocs.lib vars rewrite-closures boids ;
 
 IN: boids.ui
index b61e002526224c156ea714e103835215b7591581..daf35b9c03babc4bc7f44359afa6cebd5f6bdac5 100755 (executable)
@@ -1,6 +1,6 @@
 USING: vocabs.loader sequences system
 random random.mersenne-twister combinators init
-namespaces ;
+namespaces random ;
 
 "random.mersenne-twister" require
 
@@ -9,5 +9,6 @@ namespaces ;
     { [ unix? ] [ "random.unix" require ] }
 } cond
 
+! [ [ 32 random-bits ] with-secure-random <mersenne-twister> random-generator set-global ]
 [ millis <mersenne-twister> random-generator set-global ]
 "generator.random" add-init-hook
index 2f38462976c5c4a1cfc3cf8a77a736afdc19f955..9e5e9328318fb653ac0d885436e9dede67ed8a7e 100644 (file)
@@ -19,11 +19,11 @@ IN: builder.benchmark
   2array ;
 
 : compare-tables ( old new -- table )
-  [ passing-benchmarks ] 2apply
+  [ passing-benchmarks ] bi@
   [ benchmark-difference ] with map ;
 
 : benchmark-deltas ( -- table )
-  "../benchmarks" "benchmarks" [ eval-file ] 2apply
+  "../benchmarks" "benchmarks" [ eval-file ] bi@
   compare-tables
   sort-values ;
 
index 19734a3266245f798415ff2d5fd7c29dfe09bc21..461d9512095322411912a4467fc00b0e1c6cbefe 100644 (file)
@@ -13,6 +13,12 @@ IN: builder
 
 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
+! : cd ( path -- ) current-directory set ;
+
+: cd ( path -- ) set-current-directory ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
 : prepare-build-machine ( -- )
   builds make-directory
   builds cd
index 0e26abe02fcb9710dff9657ecc84bc68b462ec58..d76eda8013ef975f94e74e39fa8fdf456941e9ce 100644 (file)
@@ -1,6 +1,6 @@
 
 USING: kernel system namespaces sequences splitting combinators
-       io.files io.launcher
+       io io.files io.launcher
        bake combinators.cleave builder.common builder.util ;
 
 IN: builder.release
@@ -20,21 +20,15 @@ IN: builder.release
     "boot.x86.32.image"
     "boot.x86.64.image"
     "boot.macosx-ppc.image"
+    "boot.linux-ppc.image"
     "vm"
     "temp"
     "logs"
     ".git"
     ".gitignore"
     "Makefile"
-    "cp_dir"
     "unmaintained"
-    "misc/target"
-    "misc/wordsize"
-    "misc/wordsize.c"
-    "misc/macos-release.sh"
-    "misc/source-release.sh"
-    "misc/windows-release.sh"
-    "misc/version.sh"
+    "build-support"
   } ;
 
 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@@ -91,6 +85,39 @@ IN: builder.release
 : remove-factor-app ( -- )
   macosx? not [ { "rm" "-rf" "Factor.app" } try-process ] when ;
 
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+SYMBOL: upload-to-factorcode
+
+: platform ( -- string ) { os cpu- } to-strings "-" join ;
+
+: remote-location ( -- dest )
+  "factorcode.org:/var/www/factorcode.org/newsite/downloads"
+  platform
+  append-path ;
+    
+: upload ( -- )
+  { "scp" archive-name remote-location } to-strings
+  [ "Error uploading binary to factorcode" print ]
+  run-or-bail ;
+
+: maybe-upload ( -- )
+  upload-to-factorcode get
+    [ upload ]
+  when ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+! : release ( -- )
+!   "factor"
+!     [
+!       remove-factor-app
+!       remove-common-files
+!     ]
+!   with-directory
+!   make-archive
+!   archive-name releases move-file-into ;
+
 : release ( -- )
   "factor"
     [
@@ -99,6 +126,7 @@ IN: builder.release
     ]
   with-directory
   make-archive
+  maybe-upload
   archive-name releases move-file-into ;
 
 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
index 55ff38d40814e48c071dab8162a49194aacee03d..92b9af41ef284fcd572295fff1869eb362156cc9 100644 (file)
@@ -88,7 +88,7 @@ USING: bootstrap.image bootstrap.image.download io.streams.null ;
 
 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
-: longer? ( seq seq -- ? ) [ length ] 2apply > ; 
+: longer? ( seq seq -- ? ) [ length ] bi@ > ; 
 
 : maybe-tail* ( seq n -- seq )
   2dup longer?
index 963379896dcba6fe39e54cce9c17dcfdbdfeb7de..43b9edcd0098d6a8ca3adfbc3dc9c8ad96cf10f6 100755 (executable)
@@ -1,11 +1,10 @@
-USING: alien alien.c-types arrays sequences math
-math.vectors math.matrices math.parser io io.files kernel opengl
-opengl.gl opengl.glu shuffle http.client vectors
-namespaces ui.gadgets ui.gadgets.canvas ui.render ui splitting
-combinators tools.time system combinators.lib combinators.cleave
-float-arrays continuations opengl.demo-support multiline
-ui.gestures
-bunny.fixed-pipeline bunny.cel-shaded bunny.outlined bunny.model ;
+USING: alien alien.c-types arrays sequences math math.vectors
+math.matrices math.parser io io.files kernel opengl opengl.gl
+opengl.glu shuffle http.client vectors namespaces ui.gadgets
+ui.gadgets.canvas ui.render ui splitting combinators tools.time
+system combinators.lib float-arrays continuations
+opengl.demo-support multiline ui.gestures bunny.fixed-pipeline
+bunny.cel-shaded bunny.outlined bunny.model ;
 IN: bunny
 
 TUPLE: bunny-gadget model geom draw-seq draw-n ;
index 1d90209ed48bfa177ed889e3f89d1e86418c2552..2cb0df5ca11d6c5eaa0aae17fa9a4395c5811b9f 100755 (executable)
@@ -1,8 +1,8 @@
-USING: alien alien.c-types arrays sequences math math.vectors math.matrices
-    math.parser io io.files kernel opengl opengl.gl opengl.glu io.encodings.ascii
-    opengl.capabilities shuffle http.client vectors splitting tools.time system
-    combinators combinators.cleave float-arrays continuations namespaces
-    sequences.lib ;
+USING: alien alien.c-types arrays sequences math math.vectors
+math.matrices math.parser io io.files kernel opengl opengl.gl
+opengl.glu io.encodings.ascii opengl.capabilities shuffle
+http.client vectors splitting tools.time system combinators
+float-arrays continuations namespaces sequences.lib ;
 IN: bunny.model
 
 : numbers ( str -- seq )
@@ -64,16 +64,19 @@ TUPLE: bunny-buffers array element-array nv ni ;
     bunny-dlist construct-boa ;
 
 : <bunny-buffers> ( model -- geom )
-    [
-        [ first concat ] [ second concat ] bi
-        append >float-array
-        GL_ARRAY_BUFFER swap GL_STATIC_DRAW <gl-buffer>
-    ] [
-        third concat >c-uint-array
-        GL_ELEMENT_ARRAY_BUFFER swap GL_STATIC_DRAW <gl-buffer>
-    ]
-    [ first length 3 * ] [ third length 3 * ] tetra
-    bunny-buffers construct-boa ;
+    {
+        [
+            [ first concat ] [ second concat ] bi
+            append >float-array
+            GL_ARRAY_BUFFER swap GL_STATIC_DRAW <gl-buffer>
+        ]
+        [
+            third concat >c-uint-array
+            GL_ELEMENT_ARRAY_BUFFER swap GL_STATIC_DRAW <gl-buffer>
+        ]
+        [ first length 3 * ]
+        [ third length 3 * ]
+    } cleave bunny-buffers construct-boa ;
 
 GENERIC: bunny-geom ( geom -- )
 GENERIC: draw-bunny ( geom draw -- )
index 6295e3b9ded137815cbf6f1f1a6b61894d3f18aa..6a2f54cceb2014239e6be6f761f101b60eafa4d7 100755 (executable)
@@ -1,7 +1,6 @@
-USING: arrays bunny.model bunny.cel-shaded
-combinators.cleave continuations kernel math multiline
-opengl opengl.shaders opengl.framebuffers opengl.gl
-opengl.capabilities sequences ui.gadgets combinators.cleave ;
+USING: arrays bunny.model bunny.cel-shaded continuations kernel
+math multiline opengl opengl.shaders opengl.framebuffers
+opengl.gl opengl.capabilities sequences ui.gadgets combinators ;
 IN: bunny.outlined
 
 STRING: outlined-pass1-fragment-shader-main-source
index 76ce27975b53c9d4b3cbf19e911517e8b4b14889..c319ade93bd13073a9315900f7a89ec8eb6ef12c 100644 (file)
@@ -203,6 +203,9 @@ C-ENUM:
     CAIRO_HINT_METRICS_ON
 ;
 
+FUNCTION: char* cairo_status_to_string ( cairo_status_t status ) ;
+FUNCTION: cairo_status_t cairo_status ( cairo_t* cr ) ;
+
 : cairo_create ( cairo_surface_t -- cairo_t )
     "cairo_t*" "cairo" "cairo_create" [ "void*" ] alien-invoke ;
 
index 1b969978a392890037b10a343b71fd44914f86d4..4f532cd9eccc01d0f68b51b7f71ecba0460ed956 100755 (executable)
@@ -1,8 +1,7 @@
 ! Copyright (C) 2008 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: alien.c-types cairo.ffi continuations destructors
-kernel libc locals math combinators.cleave shuffle
-accessors ;
+kernel libc locals math shuffle accessors ;
 IN: cairo.lib
 
 TUPLE: cairo-t alien ;
index 55828cde9c804ea21de82d12a6fc33ac2924bd40..774a1afe8e890c226ad068bbedeb190aabc2953e 100755 (executable)
@@ -1,17 +1,34 @@
 ! Copyright (C) 2008 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: arrays combinators.cleave kernel
-accessors math ui.gadgets ui.render opengl.gl byte-arrays
-namespaces opengl cairo.ffi cairo.lib ;
+USING: arrays kernel accessors math ui.gadgets ui.render
+opengl.gl byte-arrays namespaces opengl cairo.ffi cairo.lib
+inspector sequences combinators io.backend ;
 IN: cairo.png
 
 TUPLE: png surface width height cairo-t array ;
 TUPLE: png-gadget png ;
 
+ERROR: cairo-error string ;
+
+: check-zero
+    dup zero? [
+        "PNG dimension is 0" cairo-error
+    ] when ;
+
+: cairo-png-error ( n -- )
+    {
+        { [ dup CAIRO_STATUS_NO_MEMORY = ] [ "Cairo: no memory" cairo-error ] }
+        { [ dup CAIRO_STATUS_FILE_NOT_FOUND = ] [ "Cairo: file not found" cairo-error ] }
+        { [ dup CAIRO_STATUS_READ_ERROR = ] [ "Cairo: read error" cairo-error ] }
+        { [ t ] [ drop ] }
+    } cond ;
+
 : <png> ( path -- png )
+    normalize-pathname
     cairo_image_surface_create_from_png
-    dup [ cairo_image_surface_get_width ]
-    [ cairo_image_surface_get_height ] [ ] tri
+    dup cairo_surface_status cairo-png-error
+    dup [ cairo_image_surface_get_width check-zero ]
+    [ cairo_image_surface_get_height check-zero ] [ ] tri
     cairo-surface>array png construct-boa ;
 
 : write-png ( png path -- )
@@ -34,6 +51,7 @@ M: png-gadget draw-gadget* ( gadget -- )
         png>>
         [ width>> ]
         [ height>> GL_RGBA GL_UNSIGNED_BYTE ]
+        ! [ height>> GL_BGRA GL_UNSIGNED_BYTE ]
         [ array>> ] tri
         glDrawPixels
     ] with-translation ;
@@ -43,3 +61,5 @@ M: png-gadget graft* ( gadget -- )
 
 M: png-gadget ungraft* ( gadget -- )
     png>> surface>> cairo_destroy ;
+
+! "resource:misc/icons/Factor_1x16.png" USE: cairo.png <png-gadget> gadget.
index 06425975d42663172182edf4ddc8546303fa5744..6c29c0d1aca74fb6b82e1a9acc661ddfed4de7ca 100755 (executable)
@@ -2,8 +2,8 @@
 ! See http://factorcode.org/license.txt for BSD license.
 
 USING: arrays kernel math math.functions namespaces sequences
-strings tuples system vocabs.loader calendar.backend threads
-accessors combinators locals ;
+strings system vocabs.loader calendar.backend threads
+accessors combinators locals classes.tuple ;
 IN: calendar
 
 TUPLE: timestamp year month day hour minute second gmt-offset ;
@@ -84,10 +84,10 @@ PRIVATE>
     ] ;
 
 : >date< ( timestamp -- year month day )
-    { year>> month>> day>> } get-slots ;
+    [ year>> ] [ month>> ] [ day>> ] tri ;
 
 : >time< ( timestamp -- hour minute second )
-    { hour>> minute>> second>> } get-slots ;
+    [ hour>> ] [ minute>> ] [ second>> ] tri ;
 
 : instant ( -- dt ) 0 0 0 0 0 0 <duration> ;
 : years ( n -- dt ) instant swap >>year ;
@@ -185,7 +185,7 @@ M: number +second ( timestamp n -- timestamp )
     [ month>>  +month  ] keep
     [ year>>   +year   ] keep ; inline
 
-: +slots [ 2apply + ] curry 2keep ; inline
+: +slots [ bi@ + ] curry 2keep ; inline
 
 PRIVATE>
 
@@ -244,9 +244,9 @@ M: timestamp <=> ( ts1 ts2 -- n )
     [ >gmt tuple-slots ] compare ;
 
 : (time-) ( timestamp timestamp -- n )
-    [ >gmt ] 2apply
-    [ [ >date< julian-day-number ] 2apply - 86400 * ] 2keep
-    [ >time< >r >r 3600 * r> 60 * r> + + ] 2apply - + ;
+    [ >gmt ] bi@
+    [ [ >date< julian-day-number ] bi@ - 86400 * ] 2keep
+    [ >time< >r >r 3600 * r> 60 * r> + + ] bi@ - + ;
 
 M: timestamp time-
     #! Exact calendar-time difference
index 0ac0ebb2c3550697968e48f89eeab0ab381f9ab2..26ed873fd33541b573bcb89c252e5b8845cc8ffa 100755 (executable)
@@ -1,6 +1,5 @@
 USING: math math.parser kernel sequences io calendar\r
-accessors arrays io.streams.string combinators accessors\r
-combinators.cleave ;\r
+accessors arrays io.streams.string combinators accessors ;\r
 IN: calendar.format\r
 \r
 GENERIC: day. ( obj -- )\r
@@ -183,7 +182,7 @@ M: timestamp year. ( timestamp -- )
     [\r
         [ month>> month-abbreviations nth write ] keep bl\r
         [ day>> number>string 2 32 pad-left write ] keep bl\r
-        dup now [ year>> ] 2apply = [\r
+        dup now [ year>> ] bi@ = [\r
             [ hour>> write-00 ] keep ":" write\r
             minute>> write-00\r
         ] [\r
index 6986902ff15011f1ac70eac3fb49cca44d69e079..8548e4ee524a811cbc0a05e7a8d60e1c99423226 100755 (executable)
@@ -1,6 +1,5 @@
 USING: calendar.backend namespaces alien.c-types
-windows windows.kernel32 kernel math combinators.cleave
-combinators ;
+windows windows.kernel32 kernel math combinators ;
 IN: calendar.windows
 
 TUPLE: windows-calendar ;
index c3ada955337518f0066a6368c3ee798d35129aa3..8a1d93aceb25a8e2b9ce7617fd2452fc303b7443 100644 (file)
@@ -3,7 +3,7 @@ USING: kernel alien.c-types combinators namespaces arrays
        sequences sequences.lib namespaces.lib splitting
        math math.functions math.vectors math.trig
        opengl.gl opengl.glu opengl ui ui.gadgets.slate
-       combinators.cleave vars
+       vars
        random-weighted colors.hsv cfdg.gl ;
 
 IN: cfdg
diff --git a/extra/classes/tuple/lib/authors.txt b/extra/classes/tuple/lib/authors.txt
new file mode 100644 (file)
index 0000000..7c1b2f2
--- /dev/null
@@ -0,0 +1 @@
+Doug Coleman
diff --git a/extra/classes/tuple/lib/lib-docs.factor b/extra/classes/tuple/lib/lib-docs.factor
new file mode 100644 (file)
index 0000000..20431da
--- /dev/null
@@ -0,0 +1,27 @@
+USING: help.syntax help.markup kernel prettyprint sequences ;
+IN: classes.tuple.lib
+
+HELP: >tuple<
+{ $values { "class" "a tuple class" } }
+{ $description "Explodes the tuple so that tuple slots are on the stack in the order listed in the tuple." }
+{ $example
+    "USING: kernel prettyprint classes.tuple.lib ;"
+    "TUPLE: foo a b c ;"
+    "1 2 3 \\ foo construct-boa \\ foo >tuple< .s"
+    "1\n2\n3"
+}
+{ $notes "Words using " { $snippet ">tuple<" } " may be compiled." }
+{ $see-also >tuple*< } ;
+
+HELP: >tuple*<
+{ $values { "class" "a tuple class" } }
+{ $description "Explodes the tuple so that tuple slots ending with '*' are on the stack in the order listed in the tuple." }
+{ $example
+    "USING: kernel prettyprint classes.tuple.lib ;"
+    "TUPLE: foo a bb* ccc dddd* ;"
+    "1 2 3 4 \\ foo construct-boa \\ foo >tuple*< .s"
+    "2\n4"
+}
+{ $notes "Words using " { $snippet ">tuple*<" } " may be compiled." }
+{ $see-also >tuple< } ;
+
diff --git a/extra/classes/tuple/lib/lib-tests.factor b/extra/classes/tuple/lib/lib-tests.factor
new file mode 100644 (file)
index 0000000..328f83d
--- /dev/null
@@ -0,0 +1,8 @@
+USING: kernel tools.test classes.tuple.lib ;
+IN: classes.tuple.lib.tests
+
+TUPLE: foo a b* c d* e f* ;
+
+[ 1 2 3 4 5 6 ] [ 1 2 3 4 5 6 \ foo construct-boa \ foo >tuple< ] unit-test
+[ 2 4 6 ] [ 1 2 3 4 5 6 \ foo construct-boa \ foo >tuple*< ] unit-test
+
diff --git a/extra/classes/tuple/lib/lib.factor b/extra/classes/tuple/lib/lib.factor
new file mode 100755 (executable)
index 0000000..38104a4
--- /dev/null
@@ -0,0 +1,17 @@
+! Copyright (C) 2007 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: kernel macros sequences slots words mirrors ;
+IN: classes.tuple.lib
+
+: reader-slots ( seq -- quot )
+    [ slot-spec-reader ] map [ get-slots ] curry ;
+
+MACRO: >tuple< ( class -- )
+    all-slots 1 tail-slice reader-slots ;
+
+MACRO: >tuple*< ( class -- )
+    all-slots
+    [ slot-spec-name "*" tail? ] subset
+    reader-slots ;
+
+
index ea77c496a21b30a62b37779bc189f28d996274b0..606526a240fafa48b6ae6d03c110f2d648c1ef09 100644 (file)
@@ -26,7 +26,7 @@ IN: cocoa.dialogs
     [ -> filenames CF>string-array ] [ drop f ] if ;
 
 : split-path ( path -- dir file )
-    "/" last-split1 [ <NSString> ] 2apply ;
+    "/" last-split1 [ <NSString> ] bi@ ;
 
 : save-panel ( path -- paths )
     <NSSavePanel> dup
index 8d91d971e412a49be6d85c9276de3f21fb7a73c8..dd2811822be91a55e7e9d5114d5b36d2ba9406cb 100644 (file)
@@ -1,8 +1,7 @@
 ! Copyright (C) 2007 Eduardo Cavazos
 ! See http://factorcode.org/license.txt for BSD license.
 
-USING: kernel combinators arrays sequences math math.functions
-       combinators.cleave ;
+USING: kernel combinators arrays sequences math math.functions ;
 
 IN: colors.hsv
 
diff --git a/extra/combinators/cleave/cleave-docs.factor b/extra/combinators/cleave/cleave-docs.factor
deleted file mode 100644 (file)
index 46e9abc..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-
-USING: kernel quotations help.syntax help.markup ;
-
-IN: combinators.cleave
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-ARTICLE: "cleave-combinators" "Cleave Combinators"
-
-"Basic cleavers:"
-
-{ $subsection bi  }
-{ $subsection tri }
-
-"General cleave: "
-{ $subsection cleave }
-
-"Cleave combinators for quotations with arity 2:"
-{ $subsection 2bi  }
-{ $subsection 2tri }
-
-{ $notes
-  "From the Merriam-Webster Dictionary: "
-  $nl
-  { $strong "cleave" }
-  { $list
-    { $emphasis "To divide by or as if by a cutting blow" }
-    { $emphasis "To separate into distinct parts and especially into "
-                "groups having divergent views" } }
-  $nl
-  "The Joy programming language has a " { $emphasis "cleave" } " combinator." }
-
-;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-HELP: bi
-
-  { $values { "x" object }
-            { "p" quotation }
-            { "q" quotation }
-          
-            { "p(x)" "p applied to x" }
-            { "q(x)" "q applied to x" } } ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-HELP: tri
-
-  { $values { "x" object }
-            { "p" quotation }
-            { "q" quotation }
-            { "r" quotation }
-          
-            { "p(x)" "p applied to x" }
-            { "q(x)" "q applied to x" }
-            { "r(x)" "r applied to x" } } ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-HELP: cleave
-
-{ $code "( obj { q1 q2 ... qN } -- q1(obj) q2(obj) ... qN(obj) )" } ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-{ bi tri cleave 2bi 2tri } related-words
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-ARTICLE: "spread-combinators" "Spread Combinators"
-
-{ $subsection bi* }
-{ $subsection tri* }
-{ $subsection spread } ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-HELP: bi*
-
-  { $values { "x" object }
-            { "y" object }
-            { "p" quotation }
-            { "q" quotation }
-          
-            { "p(x)" "p applied to x" }
-            { "q(y)" "q applied to y" } } ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-HELP: tri*
-
-  { $values { "x" object }
-            { "y" object }
-            { "z" object }
-            { "p" quotation }
-            { "q" quotation }
-            { "r" quotation }
-          
-            { "p(x)" "p applied to x" }
-            { "q(y)" "q applied to y" }
-            { "r(z)" "r applied to z" } } ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-HELP: spread
-
-{ $code "( v1 v2 ... vN { q1 q2 ... qN } -- q1(v1) q2(v2) ... qN(vN) )" } ;
\ No newline at end of file
index 1bc7480198555fb7c6540c37df355bbd98b807be..d99fe7e1d2939ac52f47af00a59a56294b3a1421 100644 (file)
@@ -1,78 +1,8 @@
 
-USING: kernel sequences macros ;
+USING: kernel sequences macros combinators ;
 
 IN: combinators.cleave
 
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-! The cleaver family
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: bi  ( x p q   -- p(x) q(x)      ) >r keep r> call          ; inline
-: tri ( x p q r -- p(x) q(x) r(x) ) >r pick >r bi r> r> call ; inline
-
-: tetra ( obj quot quot quot quot -- val val val val )
-  >r >r pick >r bi r> r> r> bi ; inline
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: 2bi ( x y p q -- p(x,y) q(x,y) ) >r 2keep r> call ; inline
-
-: 2tri ( x y z p q r -- p(x,y,z) q(x,y,z) r(x,y,z) )
-  >r >r 2keep r> 2keep r> call ; inline
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-! General cleave
-
-MACRO: cleave ( seq -- )
-  dup
-    [ drop [ dup ] ] map concat
-  swap
-  dup
-    [ drop [ >r ] ]  map concat
-  swap
-    [ [ r> ] append ] map concat
-  3append
-    [ drop ]
-  append ;
-
-MACRO: 2cleave ( seq -- )
-  dup
-    [ drop [ 2dup ] ] map concat
-  swap
-  dup
-    [ drop [ >r >r ] ] map concat
-  swap
-    [ [ r> r> ] append ] map concat
-  3append
-    [ 2drop ]
-  append ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-! The spread family
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: bi* ( x y p q -- p(x) q(y) ) >r swap slip r> call ; inline
-
-: 2bi* ( w x y z p q -- p(x) q(y) ) >r -rot 2slip r> call ; inline
-
-: tri* ( x y z p q r -- p(x) q(y) r(z) )
-  >r rot >r bi* r> r> call ; inline
-
-: tetra* ( obj obj obj obj quot quot quot quot -- val val val val )
-  >r roll >r tri* r> r> call ; inline
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-! General spread
-
-MACRO: spread ( seq -- )
-  dup
-    [ drop [ >r ] ]        map concat
-  swap
-    [ [ r> ] prepend ] map concat
-  append ;
-
 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 ! Cleave into array
 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
index 0a08948346bab65c20d1deedf5d95398992a5877..ed481f72e678bf20075e54abd20ed64eb2b8b1dd 100755 (executable)
@@ -46,3 +46,8 @@ IN: combinators.lib.tests
         [ dup array? ] [ dup vector? ] [ dup float? ]
     } || nip
 ] unit-test
+
+
+{ 1 1 } [
+    [ even? ] [ drop 1 ] [ drop 2 ] ifte
+] must-infer-as
index 459938c885c575fd5cbf43b9469eefff9710d5d5..deb03f72e2cfc7ea953ee6c21a8a3bb9f80db8ab 100755 (executable)
@@ -1,10 +1,10 @@
-! Copyright (C) 2007 Slava Pestov, Chris Double, Doug Coleman,
-!                    Eduardo Cavazos, Daniel Ehrenberg.
+! Copyright (C) 2007, 2008 Slava Pestov, Chris Double,
+!                          Doug Coleman, Eduardo Cavazos,
+!                          Daniel Ehrenberg.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel combinators namespaces quotations hashtables
+USING: kernel combinators fry namespaces quotations hashtables
 sequences assocs arrays inference effects math math.ranges
-arrays.lib shuffle macros bake combinators.cleave
-continuations ;
+arrays.lib shuffle macros bake continuations ;
 
 IN: combinators.lib
 
@@ -34,9 +34,8 @@ MACRO: nwith ( quot n -- )
 
 MACRO: napply ( n -- )
   2 [a,b]
-  [ [ ] [ 1- ] bi
-    [ , ntuck , nslip ]
-    bake ]
+  [ [ 1- ] [ ] bi
+    '[ , ntuck , nslip ] ]
   map concat >quotation [ call ] append ;
 
 : 3apply ( obj obj obj quot -- ) 3 napply ; inline
@@ -88,26 +87,21 @@ MACRO: || ( quots -- ? ) [ [ t ] ] f short-circuit ;
 ! ifte
 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
+MACRO: preserving ( predicate -- quot )
+    dup infer effect-in
+    dup 1+
+    '[ , , nkeep , nrot ] ;
+
 MACRO: ifte ( quot quot quot -- )
-    pick infer effect-in
-    dup 1+ swap
-    [ >r >r , nkeep , nrot r> r> if ]
-    bake ;
+    '[ , preserving , , if ] ;
 
 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 ! switch
 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
-: preserving ( predicate -- quot )
-    dup infer effect-in
-    dup 1+ spin
-    [ , , nkeep , nrot ]
-    bake ;
-
 MACRO: switch ( quot -- )
-    [ [ preserving ] [ ] bi* ] assoc-map
-    [ , cond ]
-    bake ;
+    [ [ [ preserving ] curry ] dip ] assoc-map
+    [ cond ] curry ;
 
 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
index 0941eb4251574ace9702bb265bee3a4bb56dd1de..856c37a6bc84ddd1b84130335c676d1485c4eee1 100755 (executable)
@@ -1,7 +1,7 @@
 IN: concurrency.distributed.tests\r
 USING: tools.test concurrency.distributed kernel io.files\r
 arrays io.sockets system combinators threads math sequences\r
-concurrency.messaging ;\r
+concurrency.messaging continuations ;\r
 \r
 : test-node\r
     {\r
@@ -9,6 +9,8 @@ concurrency.messaging ;
         { [ windows? ] [ "127.0.0.1" 1238 <inet4> ] }\r
     } cond ;\r
 \r
+[ ] [ [ "distributed-concurrency-test" temp-file delete-file ] ignore-errors ] unit-test\r
+\r
 [ ] [ test-node dup 1array swap (start-node) ] unit-test\r
 \r
 [ ] [ yield ] unit-test\r
index c007e9f152d0ead5d78be07c390fae80e46bc9d0..6704272305e16cc1afd520953f54f57d97016000 100755 (executable)
@@ -1,8 +1,7 @@
 ! Copyright (C) 2005 Chris Double. All Rights Reserved.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: serialize sequences concurrency.messaging
-threads io io.server qualified arrays
-namespaces kernel io.encodings.binary combinators.cleave
+USING: serialize sequences concurrency.messaging threads io
+io.server qualified arrays namespaces kernel io.encodings.binary
 accessors ;
 QUALIFIED: io.sockets
 IN: concurrency.distributed
index ffb2a64b763a4da4a46b6ce41a9e7f96a0528032..ccf17da4e809f2dea433988a16a12e78652e3ba2 100644 (file)
@@ -24,7 +24,7 @@ C: <rsa> rsa
 : modulus-phi ( numbits -- n phi ) 
     #! Loop until phi is not divisible by the public key.
     dup rsa-primes [ * ] 2keep
-    [ 1- ] 2apply *
+    [ 1- ] bi@ *
     dup public-key gcd nip 1 = [
         rot drop
     ] [
index af3671e7d922433be02f7d9d1b808aca5427e7bd..8f3d3e6eccc713a122ce6f035e81c877e76b9e68 100755 (executable)
@@ -124,5 +124,5 @@ SYMBOLS: h0 h1 h2 h3 h4 A B C D E w K ;
 : byte-array>sha1-interleave ( string -- seq )
     [ zero? ] left-trim
     dup length odd? [ 1 tail ] when
-    seq>2seq [ byte-array>sha1 ] 2apply
+    seq>2seq [ byte-array>sha1 ] bi@
     swap 2seq>seq ;
index f9e946fc20b94eb41136430523771e72b1df1981..55e672ec806d13d8fd8834259e60c89e13b94068 100755 (executable)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2008 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: arrays assocs classes continuations kernel math
-namespaces sequences sequences.lib tuples words strings
+namespaces sequences sequences.lib classes.tuple words strings
 tools.walker accessors ;
 IN: db
 
index 270be886c5b8a41e19fcd618270e84b593cc4f1a..bfe7dab3ce21344abfe35aebd62c9d2d72303ddb 100755 (executable)
@@ -2,10 +2,10 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: arrays continuations db io kernel math namespaces
 quotations sequences db.postgresql.ffi alien alien.c-types
-db.types tools.walker ascii splitting math.parser
-combinators combinators.cleave libc shuffle calendar.format
-byte-arrays destructors prettyprint accessors
-strings serialize io.encodings.binary io.streams.byte-array ;
+db.types tools.walker ascii splitting math.parser combinators
+libc shuffle calendar.format byte-arrays destructors prettyprint
+accessors strings serialize io.encodings.binary
+io.streams.byte-array ;
 IN: db.postgresql.lib
 
 : postgresql-result-error-message ( res -- str/f )
index 8a6f8632ec134ee5e3cae9283183258b490359fb..f9805560adfda016beb7b9b1db467e7e6ef420ae 100755 (executable)
@@ -5,7 +5,7 @@ kernel math math.parser namespaces prettyprint quotations
 sequences debugger db db.postgresql.lib db.postgresql.ffi
 db.tuples db.types tools.annotations math.ranges
 combinators sequences.lib classes locals words tools.walker
-combinators.cleave namespaces.lib ;
+namespaces.lib ;
 IN: db.postgresql
 
 TUPLE: postgresql-db host port pgopts pgtty db user pass ;
index 1de4bdfb5a0126c241d2e1312060b250db0eb3e9..99dde992808fb7df45541cee32f56741caa7b661 100755 (executable)
@@ -1,4 +1,4 @@
-USING: kernel parser quotations tuples words
+USING: kernel parser quotations classes.tuple words
 namespaces.lib namespaces sequences arrays combinators
 prettyprint strings math.parser sequences.lib math symbols ;
 USE: tools.walker
index d7d954c0dcdac99ced0f5404a0112c1be91eecda..9b3185bcf2052e43c4b862e57b7548d408d125fe 100755 (executable)
@@ -2,10 +2,10 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: alien arrays assocs classes compiler db
 hashtables io.files kernel math math.parser namespaces
-prettyprint sequences strings tuples alien.c-types
+prettyprint sequences strings classes.tuple alien.c-types
 continuations db.sqlite.lib db.sqlite.ffi db.tuples
 words combinators.lib db.types combinators
-combinators.cleave io namespaces.lib ;
+io namespaces.lib ;
 USE: tools.walker
 IN: db.sqlite
 
index 0f69b0fafb823d2e69159a0ec60e23b1f373f1be..7fc059c9b31ba38dafdf59f54e410abb93c3c960 100755 (executable)
@@ -1,10 +1,9 @@
 ! Copyright (C) 2008 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: arrays assocs classes db kernel namespaces
-tuples words sequences slots math
+classes.tuple words sequences slots math
 math.parser io prettyprint db.types continuations
-mirrors sequences.lib tools.walker combinators.lib
-combinators.cleave ;
+mirrors sequences.lib tools.walker combinators.lib ;
 IN: db.tuples
 
 : define-persistent ( class table columns -- )
index 94a8d6f3921aaede181cfb49421138b207a2d79d..3c73a933e927e4a9cb858a894a66814b22849d9f 100755 (executable)
@@ -3,7 +3,7 @@
 USING: arrays assocs db kernel math math.parser
 sequences continuations sequences.deep sequences.lib
 words namespaces tools.walker slots slots.private classes
-mirrors tuples combinators calendar.format symbols
+mirrors classes.tuple combinators calendar.format symbols
 singleton ;
 IN: db.types
 
index 67b8a39320e86ad0e331cc6776af38f4901cf404..7f24d6258fc605a5e512da69553407d4f6ae42a7 100755 (executable)
@@ -10,7 +10,7 @@ IN: delegate
     CREATE-WORD dup define-symbol
     parse-definition swap define-protocol ; parsing
 
-PREDICATE: word protocol "protocol-words" word-prop ;
+PREDICATE: protocol < word "protocol-words" word-prop ;
 
 GENERIC: group-words ( group -- words )
 
index 60ae592d4ce3ab5f619ee490e3a08640f75a42e1..14f0dc41acd066e659f6bb75be97acab1d2c43db 100755 (executable)
@@ -12,7 +12,7 @@ IN: documents
 
 : =line ( n loc -- newloc ) second 2array ;
 
-: lines-equal? ( loc1 loc2 -- ? ) [ first ] 2apply number= ;
+: lines-equal? ( loc1 loc2 -- ? ) [ first ] bi@ number= ;
 
 TUPLE: document locs ;
 
@@ -46,7 +46,7 @@ TUPLE: document locs ;
     2over = [
         3drop
     ] [
-        >r [ first ] 2apply 1+ dup <slice> r> each
+        >r [ first ] bi@ 1+ dup <slice> r> each
     ] if ; inline
 
 : start/end-on-line ( from to line# -- n1 n2 )
@@ -85,7 +85,7 @@ TUPLE: document locs ;
 
 : (set-doc-range) ( newlines from to lines -- )
     [ prepare-insert ] 3keep
-    >r [ first ] 2apply 1+ r>
+    >r [ first ] bi@ 1+ r>
     replace-slice ;
 
 : set-doc-range ( string from to document -- )
index 4ee906bccbb224ed0a92f0257ba9f995d6925342..85d58e75728f9b4cdbc2b50a11592ef409572a51 100755 (executable)
@@ -1,8 +1,9 @@
-! Copyright (C) 2005, 2007 Slava Pestov.
+! Copyright (C) 2005, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: parser kernel namespaces sequences definitions io.files
-inspector continuations tuples tools.crossref tools.vocabs 
-io prettyprint source-files assocs vocabs vocabs.loader ;
+inspector continuations tools.crossref tools.vocabs 
+io prettyprint source-files assocs vocabs vocabs.loader
+io.backend splitting classes.tuple ;
 IN: editors
 
 TUPLE: no-edit-hook ;
@@ -25,11 +26,8 @@ SYMBOL: edit-hook
     require ;
 
 : edit-location ( file line -- )
-    edit-hook get [
-        >r >r ?resource-path r> r> call
-    ] [
-        no-edit-hook edit-location
-    ] if* ;
+    >r normalize-pathname "\\\\?\\" ?head drop r>
+    edit-hook get [ call ] [ no-edit-hook edit-location ] if* ;
 
 : edit ( defspec -- )
     where [ first2 edit-location ] when* ;
@@ -39,7 +37,7 @@ SYMBOL: edit-hook
 
 : :edit ( -- )
     error get delegates [ parse-error? ] find-last nip [
-        dup parse-error-file source-file-path ?resource-path
+        dup parse-error-file source-file-path
         swap parse-error-line edit-location
     ] when* ;
 
old mode 100644 (file)
new mode 100755 (executable)
index 7b6066d..92320ad
@@ -8,7 +8,7 @@ io.encodings.utf8 ;
 IN: editors.jedit
 
 : jedit-server-info ( -- port auth )
-    home "/.jedit/server" append-path ascii [
+    home ".jedit/server" append-path ascii [
         readln drop
         readln string>number
         readln string>number
index 1fef9f3350266d81ae405d57909dc119dfbebb6d..d0bb789c1b9bc6a2159725afffcc9e9c6c1b34db 100755 (executable)
@@ -5,7 +5,7 @@ IN: editors.ultraedit
 : ultraedit-path ( -- path )
     \ ultraedit-path get-global [
         program-files
-        "\\IDM Computer Solutions\\UltraEdit-32\\uedit32.exe" append-path
+        "IDM Computer Solutions\\UltraEdit-32\\uedit32.exe" append-path
     ] unless* ;
 
 : ultraedit ( file line -- )
index d1f979e0f3a74ce26ebdcf9690b25b91bf9f667d..3f3dd6cab10215d0b9af8b7ede9f5919fd070cfd 100755 (executable)
@@ -5,10 +5,10 @@ IN: editors.wordpad
 
 : wordpad-path ( -- path )
     \ wordpad-path get [
-        program-files "\\Windows NT\\Accessories\\wordpad.exe" append-path
+        program-files "Windows NT\\Accessories\\wordpad.exe" append-path
     ] unless* ;
 
 : wordpad ( file line -- )
-    drop wordpad-path swap 2array run-detached drop ;
+    drop wordpad-path swap 2array dup . run-detached drop ;
 
 [ wordpad ] edit-hook set-global
index d7624466f7cf8f8971a7939dfa005007450570f5..c6d9cd04d292a3d17efbc766982522078bad8e29 100644 (file)
@@ -91,7 +91,7 @@ C: <faq> faq
 : faq-sections, ( question-lists -- )
     unclip question-list-seq length 1+ dupd
     [ question-list-seq length + ] accumulate nip
-    0 -rot [ pick question-list>html [ , nl, ] 2apply 1+ ] 2each drop ;
+    0 -rot [ pick question-list>html [ , nl, ] bi@ 1+ ] 2each drop ;
 
 : faq>html ( faq -- div )
     "div" [
index 739e7d012cb7bc67d9776f0be1abb3cea4fb9ab9..84d02d529d4be2cd4da108d0d5b957ee78b245f6 100755 (executable)
@@ -69,7 +69,7 @@ $nl
     { { $link curry } { $snippet ": curry '[ , @ ] ;" } }\r
     { { $link with } { $snippet ": with swapd '[ , _ @ ] ;" } }\r
     { { $link compose } { $snippet ": compose '[ @ @ ] ;" } }\r
-    { { $link 2apply } { $snippet ": 2apply tuck '[ , @ , @ ] call ;" } }\r
+    { { $link bi@ } { $snippet ": bi@ tuck '[ , @ , @ ] call ;" } }\r
 } ;\r
 \r
 ARTICLE: "fry.philosophy" "Fried quotation philosophy"\r
index 1310b581338f470e7933825044a485100d52f1f2..912c3c35f3f371ce37dd4fe491b2701e44418324 100755 (executable)
@@ -68,17 +68,6 @@ ARTICLE: "evaluator" "Evaluation semantics"
 "If the last action performed is the execution of a word, the current quotation is not saved on the call stack; this is known as " { $snippet "tail-recursion" } " and allows iterative algorithms to execute without incurring unbounded call stack usage."
 { $see-also "compiler" } ;
 
-ARTICLE: "dataflow" "Data and control flow"
-{ $subsection "evaluator" }
-{ $subsection "words" }
-{ $subsection "effects" }
-{ $subsection "shuffle-words" }
-{ $subsection "booleans" }
-{ $subsection "conditionals" }
-{ $subsection "basic-combinators" }
-{ $subsection "combinators" }
-{ $subsection "continuations" } ;
-
 USING: concurrency.combinators
 concurrency.messaging
 concurrency.promises
@@ -170,7 +159,24 @@ ARTICLE: "collections" "Collections"
 { $subsection "graphs" }
 { $subsection "buffers" } ;
 
-USING: io.sockets io.launcher io.mmap io.monitors ;
+USING: io.sockets io.launcher io.mmap io.monitors
+io.encodings.utf8 io.encodings.binary io.encodings.ascii io.files ;
+
+ARTICLE: "encodings-introduction" "An introduction to encodings"
+"In order to express text in terms of binary, some sort of encoding has to be used. In a modern context, this is understood as a two-way mapping between Unicode code points (characters) and some amount of binary. Since English isn't the only language in the world, ASCII is not sufficient as a mapping from binary to Unicode; it can't even express em-dashes or curly quotes. Unicode was designed as a universal character set that could potentially represent everything." $nl
+"Not all encodings can represent all Unicode code points, but Unicode can represent basically everything that exists in modern encodings. Some encodings are language-specific, and some can represent everything in Unicode. Though the world is moving toward Unicode and UTF-8, the reality today is that there are several encodings which must be taken into account." $nl
+"Factor uses a system of encoding descriptors to denote encodings. Encoding descriptors are objects which describe encodings. Examples are " { $link utf8 } ", " { $link ascii } " and " { $link binary } ". Encoding descriptors can be passed around independently. Each encoding descriptor has some method for constructing an encoded or decoded stream, and the resulting stream has an encoding descriptor stored which has methods for reading or writing characters." $nl
+"Constructors for streams which deal with bytes usually take an encoding as an explicit parameter. For example, to open a text file for reading whose contents are in UTF-8, use the following"
+{ $code "\"file.txt\" utf8 <file-reader>" }
+"If there is an error in the encoded stream, a replacement character (0xFFFD) will be inserted. To throw an exception upon error, use a strict encoding as follows"
+{ $code "\"file.txt\" utf8 strict <file-reader>" }
+"In a similar way, encodings can be specified when opening a file for writing."
+{ $code "\"file.txt\" ascii <file-writer>" }
+"An encoding is also needed for some words that don't return streams, such as " { $link file-contents } ", for example"
+{ $code "\"file.txt\" utf16 file-contents" }
+"Encoding descriptors are also used by " { $link "io.streams.byte-array" } " and taken by combinators like " { $link with-file-writer } " and " { $link with-byte-reader } " which deal with streams. It is " { $emphasis "not" } " used with " { $link "io.streams.string" } " because these deal with abstract text."
+$nl
+"When the " { $link binary } " encoding is used, a " { $link byte-array } " is expected for writing and returned for reading, since the stream deals with bytes. All other encodings deal with strings, since they are used to represent text." ;
 
 ARTICLE: "io" "Input and output"
 { $heading "Streams" }
@@ -188,6 +194,7 @@ ARTICLE: "io" "Input and output"
 { $subsection "io.mmap" }
 { $subsection "io.monitors" }
 { $heading "Encodings" }
+{ $subsection "encodings-introduction" }
 { $subsection "io.encodings" }
 { $subsection "io.encodings.string" }
 { $heading "Other features" }
index 9e4d02802b70d87f055c7729b014296a71ba4c53..4e8424f7a3340f6ce6f143050ec92821b29849fa 100755 (executable)
@@ -2,9 +2,9 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: arrays io kernel namespaces parser prettyprint sequences
 words assocs definitions generic quotations effects slots
-continuations tuples debugger combinators vocabs help.stylesheet
-help.topics help.crossref help.markup sorting classes
-vocabs.loader ;
+continuations classes.tuple debugger combinators vocabs
+help.stylesheet help.topics help.crossref help.markup sorting
+classes vocabs.loader ;
 IN: help
 
 GENERIC: word-help* ( word -- content )
index b65e44fda47d02aade362c6381b5f832586472a0..01e08473c6957e7c518bb3d7dd98f1ca95f83ced 100755 (executable)
@@ -59,7 +59,7 @@ IN: help.lint
 
 : check-see-also ( word element -- )
     nip \ $see-also swap elements [
-        1 tail dup prune [ length ] 2apply assert=
+        1 tail dup prune [ length ] bi@ assert=
     ] each ;
 
 : vocab-exists? ( name -- ? )
index 9c3615f629c017c6a6ffad2aa292d269ed7ecb36..5dc7255eed45248b0a4d431c4bf6333f3b07b4a4 100755 (executable)
@@ -14,7 +14,7 @@ IN: help.markup
 
 ! Element types are words whose name begins with $.
 
-PREDICATE: array simple-element
+PREDICATE: simple-element < array
     dup empty? [ drop t ] [ first word? not ] if ;
 
 SYMBOL: last-element
index e006a9816babe860808d183c06709a3526a7358d..9450f87215d93ee33bf5a2947cedc2c2c7a1b8cb 100755 (executable)
@@ -16,6 +16,4 @@ IN: help.syntax
     over add-article >link r> remember-definition ; parsing
 
 : ABOUT:
-    scan-word dup parsing? [
-        V{ } clone swap execute first
-    ] when in get vocab set-vocab-help ; parsing
+    scan-object in get vocab set-vocab-help ; parsing
index 4a86d49a285720b175947003a153c11da5b9366c..c12c392eb327073ae2ddc7eef44bae580cae961a 100755 (executable)
@@ -16,7 +16,7 @@ M: link >link ;
 M: vocab-spec >link ;
 M: object >link link construct-boa ;
 
-PREDICATE: link word-link link-name word? ;
+PREDICATE: word-link < link link-name word? ;
 
 M: link summary
     [
index fc85cce3adce49cb4bb8a65579dd126c209daa45..e4bbf0279f1e4992933ae717ae6d72ae76419cec 100755 (executable)
@@ -3,7 +3,7 @@
 USING: assocs http kernel math math.parser namespaces sequences
 io io.sockets io.streams.string io.files io.timeouts strings
 splitting calendar continuations accessors vectors
-io.encodings.latin1 io.encodings.binary fry ;
+io.encodings.8-bit io.encodings.binary fry ;
 IN: http.client
 
 DEFER: http-request
index 0bb983c53d16d599e16cdae5245ffba7dd7b4d15..6ff4829b486cc6e36d003dd628242b4426c08dc4 100755 (executable)
@@ -4,8 +4,7 @@ USING: fry hashtables io io.streams.string kernel math
 namespaces math.parser assocs sequences strings splitting ascii
 io.encodings.utf8 io.encodings.string namespaces unicode.case
 combinators vectors sorting accessors calendar
-calendar.format quotations arrays combinators.cleave
-combinators.lib byte-arrays ;
+calendar.format quotations arrays combinators.lib byte-arrays ;
 IN: http
 
 : http-port 80 ; inline
@@ -107,7 +106,7 @@ IN: http
 : query>assoc ( query -- assoc )
     dup [
         "&" split [
-            "=" split1 [ dup [ url-decode ] when ] 2apply
+            "=" split1 [ dup [ url-decode ] when ] bi@
         ] H{ } map>assoc
     ] when ;
 
index f39980037db263e834bd803634eb3c4b5e7f79ef..fcafa57ff6257b1839f5f04d30c2ea2c80122bda 100755 (executable)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.\r
 USING: accessors sequences kernel assocs combinators\r
 http.server http.server.validators http hashtables namespaces\r
-combinators.cleave fry continuations locals ;\r
+fry continuations locals ;\r
 IN: http.server.actions\r
 \r
 SYMBOL: +append-path\r
index 8c61a9dd47b85b4584a067752b02a0b51e2961d7..89984b0e8473d0e40b39f14229aa996d10db4b55 100755 (executable)
@@ -6,8 +6,8 @@ http.server.auth.providers http.server.auth.providers.null
 http.server.actions http.server.components http.server.sessions\r
 http.server.templating.fhtml http.server.validators\r
 http.server.auth http sequences io.files namespaces hashtables\r
-fry io.sockets combinators.cleave arrays threads locals\r
-qualified continuations destructors ;\r
+fry io.sockets arrays threads locals qualified continuations\r
+destructors ;\r
 IN: http.server.auth.login\r
 QUALIFIED: smtp\r
 \r
index ab629ae2362acb9cce2fc430e7c1cb12ab32ac58..e1b737a9c67162ace49f072d6ea3109d9c4221f2 100755 (executable)
@@ -3,8 +3,7 @@
 ! See http://factorcode.org/license.txt for BSD license.\r
 USING: html http http.server io kernel math namespaces\r
 continuations calendar sequences assocs hashtables\r
-accessors arrays alarms quotations combinators\r
-combinators.cleave fry assocs.lib ;\r
+accessors arrays alarms quotations combinators fry assocs.lib ;\r
 IN: http.server.callbacks\r
 \r
 SYMBOL: responder\r
index 516abe79a50392dbecc0163f68625564f4842070..bd95bf4407ea2ba9582099a09c3a7f186a78a8a3 100755 (executable)
@@ -1,10 +1,10 @@
 ! Copyright (C) 2008 Slava Pestov
 ! See http://factorcode.org/license.txt for BSD license.
-USING: html.elements http.server.validators accessors
-namespaces kernel io math.parser assocs classes words tuples
-arrays sequences io.files http.server.templating.fhtml
-http.server.actions splitting mirrors hashtables
-combinators.cleave fry continuations math ;
+USING: html.elements http.server.validators accessors namespaces
+kernel io math.parser assocs classes words classes.tuple arrays
+sequences io.files http.server.templating.fhtml
+http.server.actions splitting mirrors hashtables fry
+continuations math ;
 IN: http.server.components
 
 SYMBOL: components
index 0b2e9bccc31ddb73b164688c6bbe1351df3dd2da..a0d732c1efb54cdc42213f6ef6ad17061b5350e9 100755 (executable)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2008 Slava Pestov.\r
 ! See http://factorcode.org/license.txt for BSD license.\r
 USING: db http.server kernel accessors\r
-continuations namespaces destructors combinators.cleave ;\r
+continuations namespaces destructors ;\r
 IN: http.server.db\r
 \r
 TUPLE: db-persistence responder db params ;\r
index 6b3ae5273039622480f56b31429689d3e4f38ea2..2cc0f80f030e43d24d62c04ea340dc96aaf103f6 100755 (executable)
@@ -4,7 +4,7 @@ USING: assocs kernel namespaces io io.timeouts strings splitting
 threads http sequences prettyprint io.server logging calendar
 html.elements accessors math.parser combinators.lib
 tools.vocabs debugger html continuations random combinators
-destructors io.encodings.latin1 fry combinators.cleave ;
+destructors io.encodings.8-bit fry ;
 IN: http.server
 
 GENERIC: call-responder ( path responder -- response )
index aea1bef930cd078c7036d4b353d06314f2bdc64f..a3d06e8f18357b88ec0fbdc0c003cf9105cc7f54 100755 (executable)
@@ -3,8 +3,8 @@
 USING: assocs calendar kernel math.parser namespaces random
 accessors http http.server
 http.server.sessions.storage http.server.sessions.storage.assoc
-quotations hashtables sequences fry combinators.cleave
-html.elements symbols continuations destructors ;
+quotations hashtables sequences fry html.elements symbols
+continuations destructors ;
 IN: http.server.sessions
 
 ! ! ! ! ! !
index f72f34e4d2e1c23cf03728b07c1eaa5e6afb2509..4bdc52b86e710c2281be542466a229a22aaddf9c 100755 (executable)
@@ -1,8 +1,7 @@
 ! Copyright (C) 2008 Slava Pestov.\r
 ! See http://factorcode.org/license.txt for BSD license.\r
-USING: assocs assocs.lib accessors\r
-http.server.sessions.storage combinators.cleave alarms kernel\r
-fry http.server ;\r
+USING: assocs assocs.lib accessors http.server.sessions.storage\r
+alarms kernel fry http.server ;\r
 IN: http.server.sessions.storage.assoc\r
 \r
 TUPLE: sessions-in-memory sessions alarms ;\r
index 4d87aea5a380528c12da6a03bbbcfa510356dee5..471b7fa6dfa7a00f00d4ad43b35d77aa72119d25 100755 (executable)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.\r
 USING: assocs accessors http.server.sessions.storage\r
 alarms kernel http.server db.tuples db.types singleton\r
-combinators.cleave math.parser ;\r
+math.parser ;\r
 IN: http.server.sessions.storage.db\r
 \r
 SINGLETON: sessions-in-db\r
index 37c3a63d765b174f348d31433a3a8964a82f6086..905c7320ca7096aa7901e2d2de0a781633cb79a2 100755 (executable)
@@ -3,8 +3,7 @@
 USING: calendar html io io.files kernel math math.parser http\r
 http.server namespaces parser sequences strings assocs\r
 hashtables debugger http.mime sorting html.elements logging\r
-calendar.format accessors io.encodings.binary\r
-combinators.cleave fry ;\r
+calendar.format accessors io.encodings.binary fry ;\r
 IN: http.server.static\r
 \r
 ! special maps mime types to quots with effect ( path -- )\r
@@ -39,7 +38,9 @@ TUPLE: file-responder root hook special ;
     [ 2drop <304> ] [ file-responder get hook>> call ] if ;\r
 \r
 : serving-path ( filename -- filename )\r
-    "" or file-responder get root>> prepend-path ;\r
+    file-responder get root>> right-trim-separators\r
+    "/"\r
+    rot "" or left-trim-separators 3append ;\r
 \r
 : serve-file ( filename -- response )\r
     dup mime-type\r
index 2e253d9132117b8e128e6f50882f8e75fd613d49..9d8a6f4617e6c57a4edd5dcc1a21f8f75b19eb01 100755 (executable)
@@ -9,7 +9,7 @@ IN: http.server.templating.fhtml.tests
     [
         ".fhtml" append [ run-template ] with-string-writer
     ] keep
-    ".html" append ?resource-path utf8 file-contents = ;
+    ".html" append utf8 file-contents = ;
 
 [ t ] [ "example" test-template ] unit-test
 [ t ] [ "bug" test-template ] unit-test
index 630054ccfac28375ec5976e3b6238fe0f44088d0..f3d9d54a25e91acd34884f66c0c424a99e8acd08 100755 (executable)
@@ -83,7 +83,7 @@ DEFER: <% delimiter
             templating-vocab use+
             ! so that reload works properly
             dup source-file file set
-            ?resource-path utf8 file-contents
+            utf8 file-contents
             [ eval-template ] [ html-error. drop ] recover
         ] with-file-vocabs
     ] assert-depth ;
index b3710f6439b5cad705aa8431737fe3d08e4fff46..32a1125809ae71f43b06cecf3f6a430c74d29887 100755 (executable)
@@ -1,8 +1,7 @@
 ! Copyright (C) 2006, 2008 Slava Pestov
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel continuations sequences math namespaces
-math.parser assocs regexp fry unicode.categories
-combinators.cleave sequences ;
+math.parser assocs regexp fry unicode.categories sequences ;
 IN: http.server.validators
 
 SYMBOL: validation-failed?
index 1740e8a52333f0a0fcae77eb68309d5fe5097084..e88301c7f88ac7d8d45d7747def55e53580bd88e 100755 (executable)
@@ -51,14 +51,14 @@ SYMBOL: open-arrays
 
 : binary-op ( quot -- ? )
     >r get-cba r>
-    swap >r >r [ reg-val ] 2apply swap r> call r>
+    swap >r >r [ reg-val ] bi@ swap r> call r>
     set-reg f ; inline
 
 : op1 ( opcode -- ? )
     [ swap arr-val ] binary-op ;
 
 : op2 ( opcode -- ? )
-    get-cba >r [ reg-val ] 2apply r> reg-val set-arr f ;
+    get-cba >r [ reg-val ] bi@ r> reg-val set-arr f ;
 
 : op3 ( opcode -- ? )
     [ + >32bit ] binary-op ;
index 4bb620083fa75f16cd5c75b4b375773201748b50..1b7badd94a9a2d16a5da4b94caf502cf8c9aab2a 100755 (executable)
@@ -1,7 +1,8 @@
 USING: kernel words inspector slots quotations sequences assocs
 math arrays inference effects shuffle continuations debugger
-tuples namespaces vectors bit-arrays byte-arrays strings sbufs
-math.functions macros sequences.private combinators ;
+classes.tuple namespaces vectors bit-arrays byte-arrays strings
+sbufs math.functions macros sequences.private combinators
+mirrors combinators.lib ;
 IN: inverse
 
 TUPLE: fail ;
@@ -54,43 +55,49 @@ M: no-inverse summary
 : undo-literal ( object -- quot )
     [ =/fail ] curry ;
 
-PREDICATE: word normal-inverse "inverse" word-prop ;
-PREDICATE: word math-inverse "math-inverse" word-prop ;
-PREDICATE: word pop-inverse "pop-length" word-prop ;
+PREDICATE: normal-inverse < word "inverse" word-prop ;
+PREDICATE: math-inverse < word "math-inverse" word-prop ;
+PREDICATE: pop-inverse < word "pop-length" word-prop ;
 UNION: explicit-inverse normal-inverse math-inverse pop-inverse ;
 
-: inline-word ( word -- )
-    {
-        { [ dup word? not over symbol? or ] [ , ] }
-        { [ dup explicit-inverse? ] [ , ] }
-        ! { [ dup compound? over { if dispatch } member? not and ]
-          ! [ word-def [ inline-word ] each ] }
-        { [ dup word? over { if dispatch } member? not and ]
-          [ word-def [ inline-word ] each ] }
-        { [ drop t ] [ "Quotation is not invertible" throw ] }
-    } cond ;
-
-: math-exp? ( n n word -- ? )
-    { + - * / ^ } member? -rot [ number? ] both? and ;
-
-: (fold-constants) ( quot -- )
-    dup length 3 < [ % ] [
-        dup first3 3dup math-exp?
-        [ execute , 3 ] [ 2drop , 1 ] if
-        tail-slice (fold-constants) 
-    ] if ;
-
-: fold-constants ( quot -- folded )
-    [ (fold-constants) ] [ ] make ;
-
-: do-inlining ( quot -- inlined-quot )
-    [ [ inline-word ] each ] [ ] make fold-constants ;
+: enough? ( stack quot -- ? )
+    [ >r length r> 1quotation infer effect-in >= ] [ 3drop f ]
+    recover ;
+
+: fold-word ( stack quot -- stack )
+    2dup enough?
+    [ 1quotation with-datastack ] [ >r % r> , { } ] if ;
+
+: fold ( quot -- folded-quot )
+    [ { } swap [ fold-word ] each % ] [ ] make ; 
+
+: flattenable? ( object -- ? )
+    [ [ word? ] [ primitive? not ] and? ] [
+        { "inverse" "math-inverse" "pop-inverse" }
+        [ word-prop ] with contains? not
+    ] and? ; 
+
+: (flatten) ( quot -- )
+    [ dup flattenable? [ word-def (flatten) ] [ , ] if ] each ;
+
+ : retain-stack-overflow? ( error -- ? )
+    { "kernel-error" 14 f f } = ;
+
+: flatten ( quot -- expanded )
+    [ [ (flatten) ] [ ] make ] [
+        dup retain-stack-overflow?
+        [ drop "No inverse defined on recursive word" ] when
+        throw
+    ] recover ;
 
 GENERIC: inverse ( revquot word -- revquot* quot )
 
 M: object inverse undo-literal ;
+
 M: symbol inverse undo-literal ;
 
+M: word inverse drop "Inverse is undefined" throw ;
+
 M: normal-inverse inverse
     "inverse" word-prop ;
 
@@ -108,7 +115,7 @@ M: pop-inverse inverse
     [ unclip-slice inverse % (undo) ] if ;
 
 : [undo] ( quot -- undo )
-    do-inlining reverse [ (undo) ] [ ] make ;
+    flatten fold reverse [ (undo) ] [ ] make ;
 
 MACRO: undo ( quot -- ) [undo] ;
 
@@ -144,10 +151,10 @@ MACRO: undo ( quot -- ) [undo] ;
 \ - [ + ] [ - ] define-math-inverse
 \ * [ / ] [ / ] define-math-inverse
 \ / [ * ] [ / ] define-math-inverse
-\ ^ [ recip ^ ] [ [ log ] 2apply / ] define-math-inverse
+\ ^ [ recip ^ ] [ [ log ] bi@ / ] define-math-inverse
 
 \ ? 2 [
-    [ assert-literal ] 2apply
+    [ assert-literal ] bi@
     [ swap >r over = r> swap [ 2drop f ] [ = [ t ] [ fail ] if ] if ]
     2curry
 ] define-pop-inverse
@@ -191,7 +198,7 @@ MACRO: undo ( quot -- ) [undo] ;
     "predicate" word-prop [ dupd call assure ] curry ;
 
 : slot-readers ( class -- quot )
-    "slots" word-prop 1 tail ! tail gets rid of delegate
+    all-slots 1 tail ! tail gets rid of delegate
     [ slot-spec-reader 1quotation [ keep ] curry ] map concat
     [ ] like [ drop ] compose ;
 
index 5ce9b714272be99606c39dcd2b6996d61fcdb08f..a11a7adeadfa4571d6b3a4ccaf0bc38b498153cb 100755 (executable)
@@ -18,9 +18,7 @@ $nl
 "Reading from the buffer:"
 { $subsection buffer-peek }
 { $subsection buffer-pop }
-{ $subsection buffer> }
-{ $subsection buffer>> }
-{ $subsection buffer-until }
+{ $subsection buffer-read }
 "Writing to the buffer:"
 { $subsection extend-buffer }
 { $subsection byte>buffer }
@@ -47,10 +45,6 @@ HELP: buffer-free
 { $description "De-allocates a buffer's underlying storage. The buffer may not be used after being freed." }
 { $warning "You " { $emphasis "must" } " free a buffer using this word, before letting the GC collect the buffer tuple instance." } ;
 
-HELP: (buffer>>)
-{ $values { "buffer" buffer } { "byte-array" byte-array } }
-{ $description "Collects the entire contents of the buffer into a string." } ;
-
 HELP: buffer-reset
 { $values { "n" "a non-negative integer" } { "buffer" buffer } }
 { $description "Resets the fill pointer to 0 and the position to " { $snippet "count" } "." } ;
@@ -67,17 +61,13 @@ HELP: buffer-end
 { $values { "buffer" buffer } { "alien" alien } }
 { $description "Outputs the memory address of the current fill-pointer." } ;
 
-HELP: (buffer>)
+HELP: (buffer-read)
 { $values { "n" "a non-negative integer" } { "buffer" buffer } { "byte-array" byte-array } }
-{ $description "Outputs a string of the first " { $snippet "n" } " characters at the buffer's current position. If there are less than " { $snippet "n" } " characters available, the output is truncated." } ;
+{ $description "Outputs a byte array of the first " { $snippet "n" } " bytes at the buffer's current position. If there are less than " { $snippet "n" } " bytes available, the output is truncated." } ;
 
-HELP: buffer>
+HELP: buffer-read
 { $values { "n" "a non-negative integer" } { "buffer" buffer } { "byte-array" byte-array } }
-{ $description "Collects a string of " { $snippet "n" } " characters starting from the buffer's current position, and advances the position accordingly. If there are less than " { $snippet "n" } " characters available, the output is truncated." } ;
-
-HELP: buffer>>
-{ $values { "buffer" buffer } { "byte-array" byte-array } }
-{ $description "Collects the contents of the buffer into a string, and resets the position and fill pointer to 0." } ;
+{ $description "Collects a byte array of " { $snippet "n" } " bytes starting from the buffer's current position, and advances the position accordingly. If there are less than " { $snippet "n" } " bytes available, the output is truncated." } ;
 
 HELP: buffer-length
 { $values { "buffer" buffer } { "n" "a non-negative integer" } }
@@ -103,7 +93,7 @@ HELP: check-overflow
 
 HELP: >buffer
 { $values { "byte-array" byte-array } { "buffer" buffer } }
-{ $description "Copies a string to the buffer's fill pointer, and advances it accordingly." } ;
+{ $description "Copies a byte array to the buffer's fill pointer, and advances it accordingly." } ;
 
 HELP: byte>buffer
 { $values { "byte" "a byte" } { "buffer" buffer } }
@@ -121,7 +111,3 @@ HELP: buffer-peek
 HELP: buffer-pop
 { $values { "buffer" buffer } { "byte" "a byte" } }
 { $description "Outputs the byte at the buffer position and advances the position." } ;
-
-HELP: buffer-until
-{ $values { "separators" "a sequence of bytes" } { "buffer" buffer } { "byte-array" byte-array } { "separator" "a byte or " { $link f } } }
-{ $description "Searches the buffer for a byte appearing in " { $snippet "separators" } ", starting from " { $link buffer-pos } ". If a separator is found, all data up to but not including the separator is output, together with the separator itself; otherwise the remainder of the buffer's contents are output together with " { $link f } "." } ;
index 1f3e262fedca0224adaa5bef5fe213ec72fc932b..f66f9ed313d53b20c170e303be4cd8dedb6ad52f 100755 (executable)
@@ -1,6 +1,6 @@
 IN: io.buffers.tests
 USING: alien alien.c-types io.buffers kernel kernel.private libc
-sequences tools.test namespaces byte-arrays strings ;
+sequences tools.test namespaces byte-arrays strings accessors ;
 
 : buffer-set ( string buffer -- )
     over >byte-array over buffer-ptr byte-array>memory
@@ -9,24 +9,29 @@ sequences tools.test namespaces byte-arrays strings ;
 : string>buffer ( string -- buffer )
     dup length <buffer> tuck buffer-set ;
 
+: buffer-read-all ( buffer -- byte-array )
+    [ [ pos>> ] [ ptr>> ] bi <displaced-alien> ]
+    [ buffer-length ] bi
+    memory>byte-array ;
+
 [ B{ } 65536 ] [
     65536 <buffer>
-    dup (buffer>>)
+    dup buffer-read-all
     over buffer-capacity
     rot buffer-free
 ] unit-test
 
 [ "hello world" "" ] [
     "hello world" string>buffer
-    dup (buffer>>) >string
+    dup buffer-read-all >string
     0 pick buffer-reset
-    over (buffer>>) >string
+    over buffer-read-all >string
     rot buffer-free
 ] unit-test
 
 [ "hello" ] [
     "hello world" string>buffer
-    5 over buffer> >string swap buffer-free
+    5 over buffer-read >string swap buffer-free
 ] unit-test
 
 [ 11 ] [
@@ -37,7 +42,7 @@ sequences tools.test namespaces byte-arrays strings ;
 [ "hello world" ] [
     "hello" 1024 <buffer> [ buffer-set ] keep
     " world" >byte-array over >buffer
-    dup (buffer>>) >string swap buffer-free
+    dup buffer-read-all >string swap buffer-free
 ] unit-test
 
 [ CHAR: e ] [
@@ -45,33 +50,8 @@ sequences tools.test namespaces byte-arrays strings ;
     1 over buffer-consume [ buffer-pop ] keep buffer-free
 ] unit-test
 
-[ "hello" CHAR: \r ] [
-    "hello\rworld" string>buffer
-    "\r" over buffer-until >r >string r>
-    rot buffer-free
-] unit-test
-
-[ "hello" CHAR: \r ] [
-    "hello\rworld" string>buffer
-    "\n\r" over buffer-until >r >string r>
-    rot buffer-free
-] unit-test
-
-[ "hello\rworld" f ] [
-    "hello\rworld" string>buffer
-    "X" over buffer-until >r >string r>
-    rot buffer-free
-] unit-test
-
-[ "hello" CHAR: \r "world" CHAR: \n ] [
-    "hello\rworld\n" string>buffer
-    [ "\r\n" swap buffer-until >r >string r> ] keep
-    [ "\r\n" swap buffer-until >r >string r> ] keep
-    buffer-free
-] unit-test
-
 "hello world" string>buffer "b" set
-[ "hello world" ] [ 1000 "b" get buffer> >string ] unit-test
+[ "hello world" ] [ 1000 "b" get buffer-read >string ] unit-test
 "b" get buffer-free
 
 100 <buffer> "b" set
index 7d51d04d7bf271e75b9a44e362c604e85cd18362..8b00e59d23cbe03426b81d1af63ba2823b74ae69 100755 (executable)
@@ -3,7 +3,8 @@
 ! See http://factorcode.org/license.txt for BSD license.
 IN: io.buffers
 USING: alien alien.accessors alien.c-types alien.syntax kernel
-kernel.private libc math sequences byte-arrays strings hints ;
+kernel.private libc math sequences byte-arrays strings hints
+accessors ;
 
 TUPLE: buffer size ptr fill pos ;
 
@@ -37,46 +38,21 @@ TUPLE: buffer size ptr fill pos ;
 : buffer-pop ( buffer -- byte )
     dup buffer-peek 1 rot buffer-consume ;
 
-: (buffer>) ( n buffer -- byte-array )
-    [ dup buffer-fill swap buffer-pos - min ] keep
+: (buffer-read) ( n buffer -- byte-array )
+    [ [ fill>> ] [ pos>> ] bi - min ] keep
     buffer@ swap memory>byte-array ;
 
-: buffer> ( n buffer -- byte-array )
-    [ (buffer>) ] 2keep buffer-consume ;
-
-: (buffer>>) ( buffer -- byte-array )
-    dup buffer-pos over buffer-ptr <displaced-alien>
-    over buffer-fill rot buffer-pos - memory>byte-array ;
-
-: buffer>> ( buffer -- byte-array )
-    dup (buffer>>) 0 rot buffer-reset ;
-
-: search-buffer-until ( start end alien separators -- n )
-    [ >r swap alien-unsigned-1 r> memq? ] 2curry find* drop ;
-
-HINTS: search-buffer-until { fixnum fixnum simple-alien string } ;
-
-: finish-buffer-until ( buffer n -- byte-array separator )
-    [
-        over buffer-pos -
-        over buffer>
-        swap buffer-pop
-    ] [
-        buffer>> f
-    ] if* ;
-
-: buffer-until ( separators buffer -- byte-array separator )
-    tuck { buffer-pos buffer-fill buffer-ptr } get-slots roll
-    search-buffer-until finish-buffer-until ;
+: buffer-read ( n buffer -- byte-array )
+    [ (buffer-read) ] [ buffer-consume ] 2bi ;
 
 : buffer-length ( buffer -- n )
-    dup buffer-fill swap buffer-pos - ;
+    [ fill>> ] [ pos>> ] bi - ;
 
 : buffer-capacity ( buffer -- n )
-    dup buffer-size swap buffer-fill - ;
+    [ size>> ] [ fill>> ] bi - ;
 
 : buffer-empty? ( buffer -- ? )
-    buffer-fill zero? ;
+    fill>> zero? ;
 
 : extend-buffer ( n buffer -- )
     2dup buffer-ptr swap realloc
@@ -93,7 +69,7 @@ HINTS: search-buffer-until { fixnum fixnum simple-alien string } ;
 : byte>buffer ( byte buffer -- )
     1 over check-overflow
     [ buffer-end 0 set-alien-unsigned-1 ] keep
-    [ buffer-fill 1+ ] keep set-buffer-fill ;
+    [ 1+ ] change-fill drop ;
 
 : n>buffer ( n buffer -- )
     [ buffer-fill + ] keep 
diff --git a/extra/io/encodings/8-bit/8-bit-docs.factor b/extra/io/encodings/8-bit/8-bit-docs.factor
new file mode 100644 (file)
index 0000000..e8dadc1
--- /dev/null
@@ -0,0 +1,114 @@
+! Copyright (C) 2008 Daniel Ehrenberg
+! See http://factorcode.org/license.txt for BSD license.
+USING: help.syntax help.markup io.encodings.8-bit.private ;
+IN: io.encodings.8-bit
+
+ARTICLE: "io.encodings.8-bit" "8-bit encodings"
+"Many encodings are a simple mapping of bytes onto characters. The " { $vocab-link "io.encodings.8-bit" } " vocabulary implements these generically using existing resource files. These encodings should be used with extreme caution, as fully general Unicode encodings like UTF-8 are nearly always more appropriate. The following 8-bit encodings are already defined:"
+{ $subsection latin1 }
+{ $subsection latin2 }
+{ $subsection latin3 }
+{ $subsection latin4 }
+{ $subsection latin/cyrillic }
+{ $subsection latin/arabic }
+{ $subsection latin/greek }
+{ $subsection latin/hebrew }
+{ $subsection latin5 }
+{ $subsection latin6 }
+{ $subsection latin/thai }
+{ $subsection latin7 }
+{ $subsection latin8 }
+{ $subsection latin9 }
+{ $subsection latin10 }
+{ $subsection koi8-r }
+{ $subsection windows-1252 }
+{ $subsection ebcdic }
+{ $subsection mac-roman }
+"Words used in defining these"
+{ $subsection 8-bit }
+{ $subsection define-8-bit-encoding } ;
+
+ABOUT: "io.encodings.8-bit"
+
+HELP: 8-bit
+{ $class-description "Describes an 8-bit encoding, including its name (a symbol) and a table used for encoding and decoding." } ;
+
+HELP: define-8-bit-encoding
+{ $values { "name" "a string" } { "path" "a path" } }
+{ $description "Creates a new encoding with the given name, using the resource file at the path to tell how to encode and decode octets. The resource file should be in a similar format to those at " { $url "ftp://ftp.unicode.org/Public/MAPPINGS/ISO8859/" } } ;
+
+HELP: latin1
+{ $description "This is the ISO-8859-1 encoding, also called Latin-1: Western European. It is an 8-bit superset of ASCII which is the default for a mimetype starting with 'text' and provides the characters necessary for most western European languages." } 
+{ $see-also "encodings-introduction" } ;
+
+HELP: latin2
+{ $description "This is the ISO-8859-2 encoding, also called Latin-2: Eastern European. It is an 8-bit superset of ASCII and provides the characters necessary for most eastern European languages." } 
+{ $see-also "encodings-introduction" } ;
+
+HELP: latin3
+{ $description "This is the ISO-8859-3 encoding, also called Latin-3: South European. It is an 8-bit superset of ASCII and provides the characters necessary for Turkish, Maltese and Esperanto." } 
+{ $see-also "encodings-introduction" } ;
+
+HELP: latin4
+{ $description "This is the ISO-8859-4 encoding, also called Latin-4: North European. It is an 8-bit superset of ASCII and provides the characters necessary for Latvian, Lithuanian, Estonian, Greenlandic and Sami." } 
+{ $see-also "encodings-introduction" } ;
+
+HELP: latin/cyrillic
+{ $description "This is the ISO-8859-5 encoding, also called Latin/Cyrillic. It is an 8-bit superset of ASCII and provides the characters necessary for most languages which use Cyrilic, including Russian, Macedonian, Belarusian, Bulgarian, Serbian, and Ukrainian. KOI8-R is used much more commonly." } 
+{ $see-also "encodings-introduction" } ;
+
+HELP: latin/arabic
+{ $description "This is the ISO-8859-6 encoding, also called Latin/Arabic. It is an 8-bit superset of ASCII and provides the characters necessary for Arabic, though not other languages which use Arabic script." } 
+{ $see-also "encodings-introduction" } ;
+
+HELP: latin/greek
+{ $description "This is the ISO-8859-7 encoding, also called Latin/Greek. It is an 8-bit superset of ASCII and provides the characters necessary for Greek written in modern monotonic orthography, or ancient Greek without accent marks." } 
+{ $see-also "encodings-introduction" } ;
+
+HELP: latin/hebrew
+{ $description "This is the ISO-8859-8 encoding, also called Latin/Hebrew. It is an 8-bit superset of ASCII and provides the characters necessary for modern Hebrew without explicit vowels. Generally, this is interpreted in logical order, making it ISO-8859-8-I, technically." }
+{ $see-also "encodings-introduction" } ;
+
+HELP: latin5
+{ $description "This is the ISO-8859-9 encoding, also called Latin-5: Turkish. It is an 8-bit superset of ASCII and provides the characters necessary for Turkish, similar to Latin-1 but replacing the spots used for Icelandic with characters used in Turkish." } 
+{ $see-also "encodings-introduction" } ;
+
+HELP: latin6
+{ $description "This is the ISO-8859-10 encoding, also called Latin-6: Nordic. It is an 8-bit superset of ASCII containing the same characters as Latin-4, but rearranged to be of better use to nordic languages." } 
+{ $see-also "encodings-introduction" } ;
+
+HELP: latin/thai
+{ $description "This is the ISO-8859-11 encoding, also called Latin/Thai. It is an 8-bit superset of ASCII containing the characters necessary to represent Thai. It is basically identical to TIS-620." } 
+{ $see-also "encodings-introduction" } ;
+
+HELP: latin7
+{ $description "This is the ISO-8859-13 encoding, also called Latin-7: Baltic Rim. It is an 8-bit superset of ASCII containing all characters necesary to represent Baltic Rim languages, as previous character sets were incomplete." } 
+{ $see-also "encodings-introduction" } ;
+
+HELP: latin8
+{ $description "This is the ISO-8859-14 encoding, also called Latin-8: Celtic. It is an 8-bit superset of ASCII designed for Celtic languages like Gaelic and Breton." } 
+{ $see-also "encodings-introduction" } ;
+
+HELP: latin9
+{ $description "This is the ISO-8859-15 encoding, also called Latin-9 and unoffically as Latin-0. It is an 8-bit superset of ASCII designed as a modification of Latin-1, removing little-used characters in favor of the Euro symbol and other characters." } 
+{ $see-also "encodings-introduction" } ;
+
+HELP: latin10
+{ $description "This is the ISO-8859-16 encoding, also called Latin-10: South-Eastern European. It is an 8-bit superset of ASCII." } 
+{ $see-also "encodings-introduction" } ;
+
+HELP: windows-1252
+{ $description "Windows 1252 is an 8-bit superset of ASCII which is closely related to Latin-1. Control characters in the 0x80 to 0x9F range are replaced with printable characters such as the Euro symbol." } 
+{ $see-also "encodings-introduction" } ;
+
+HELP: ebcdic
+{ $description "EBCDIC is an 8-bit legacy encoding designed for IBM mainframes like System/360 in the 1960s. It has since fallen into disuse. It contains large unallocated regions, and the version included here (code page 37) contains auxiliary characters in this region for English- and Portugese-speaking countries." } 
+{ $see-also "encodings-introduction" } ;
+
+HELP: mac-roman
+{ $description "Mac Roman is an 8-bit superset of ASCII which was the standard encoding on Mac OS prior to version 10. It is incompatible with Latin-1 in all but a few places and ASCII, and it is suitable for encoding many Western European languages." } 
+{ $see-also "encodings-introduction" } ;
+
+HELP: koi8-r
+{ $description "KOI8-R is an 8-bit superset of ASCII which encodes the Cyrillic alphabet, as used in Russian and Bulgarian. Characters are in such an order that, if the eight bit is stripped, text is still interpretable as ASCII. Block-building characters also exist." } 
+{ $see-also "encodings-introduction" } ;
diff --git a/extra/io/encodings/8-bit/8-bit-tests.factor b/extra/io/encodings/8-bit/8-bit-tests.factor
new file mode 100644 (file)
index 0000000..24cd413
--- /dev/null
@@ -0,0 +1,10 @@
+USING: io.encodings.string io.encodings.8-bit tools.test strings arrays ;
+IN: io.encodings.8-bit.tests
+
+[ B{ CHAR: f CHAR: o CHAR: o } ] [ "foo" latin1 encode ] unit-test
+[ { 256 } >string latin1 encode ] must-fail
+[ B{ 255 } ] [ { 255 } latin1 encode ] unit-test
+
+[ "bar" ] [ "bar" latin1 decode ] unit-test
+[ { CHAR: b 233 CHAR: r } ] [ { CHAR: b 233 CHAR: r } latin1 decode >array ] unit-test
+[ { HEX: fffd HEX: 20AC } ] [ { HEX: 81 HEX: 80 } windows-1252 decode >array ] unit-test
diff --git a/extra/io/encodings/8-bit/8-bit.factor b/extra/io/encodings/8-bit/8-bit.factor
new file mode 100755 (executable)
index 0000000..259173f
--- /dev/null
@@ -0,0 +1,83 @@
+! Copyright (C) 2008 Daniel Ehrenberg
+! See http://factorcode.org/license.txt for BSD license.
+USING: math.parser arrays io.encodings sequences kernel assocs
+hashtables io.encodings.ascii generic parser classes.tuple words
+io io.files splitting namespaces math compiler.units accessors ;
+IN: io.encodings.8-bit
+
+<PRIVATE
+
+: mappings {
+    { "latin1" "8859-1" }
+    { "latin2" "8859-2" }
+    { "latin3" "8859-3" }
+    { "latin4" "8859-4" }
+    { "latin/cyrillic" "8859-5" }
+    { "latin/arabic" "8859-6" }
+    { "latin/greek" "8859-7" }
+    { "latin/hebrew" "8859-8" }
+    { "latin5" "8859-9" }
+    { "latin6" "8859-10" }
+    { "latin/thai" "8859-11" }
+    { "latin7" "8859-13" }
+    { "latin8" "8859-14" }
+    { "latin9" "8859-15" }
+    { "latin10" "8859-16" }
+    { "koi8-r" "KOI8-R" }
+    { "windows-1252" "CP1252" }
+    { "ebcdic" "CP037" }
+    { "mac-roman" "ROMAN" }
+} ;
+
+: full-path ( file-name -- path )
+    "extra/io/encodings/8-bit/" ".TXT"
+    swapd 3append resource-path ;
+
+: tail-if ( seq n -- newseq )
+    2dup swap length <= [ tail ] [ drop ] if ;
+
+: process-contents ( lines -- assoc )
+    [ "#" split1 drop ] map
+    [ empty? not ] subset
+    [ "\t" split 2 head [ 2 tail-if hex> ] map ] map ;
+
+: byte>ch ( assoc -- array )
+    256 replacement-char <array>
+    [ [ swapd set-nth ] curry assoc-each ] keep ;
+
+: ch>byte ( assoc -- newassoc )
+    [ swap ] assoc-map >hashtable ;
+
+: parse-file ( file-name -- byte>ch ch>byte )
+    ascii file-lines process-contents
+    [ byte>ch ] [ ch>byte ] bi ;
+
+TUPLE: 8-bit name decode encode ;
+
+: encode-8-bit ( char stream assoc -- )
+    swapd at* [ encode-error ] unless swap stream-write1 ;
+
+M: 8-bit encode-char
+    encode>> encode-8-bit ;
+
+: decode-8-bit ( stream array -- char/f )
+    swap stream-read1 dup
+    [ swap nth [ replacement-char ] unless* ]
+    [ nip ] if ;
+
+M: 8-bit decode-char
+    decode>> decode-8-bit ;
+
+: make-8-bit ( word byte>ch ch>byte -- )
+    [ 8-bit construct-boa ] 2curry dupd curry define ;
+
+: define-8-bit-encoding ( name path -- )
+    >r in get create r> parse-file make-8-bit ;
+
+PRIVATE>
+
+[
+    "io.encodings.8-bit" in [
+        mappings [ full-path define-8-bit-encoding ] assoc-each
+    ] with-variable
+] with-compilation-unit
diff --git a/extra/io/encodings/8-bit/8859-1.TXT b/extra/io/encodings/8-bit/8859-1.TXT
new file mode 100644 (file)
index 0000000..473ecab
--- /dev/null
@@ -0,0 +1,303 @@
+#
+#      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/extra/io/encodings/8-bit/8859-10.TXT b/extra/io/encodings/8-bit/8859-10.TXT
new file mode 100644 (file)
index 0000000..374a42b
--- /dev/null
@@ -0,0 +1,303 @@
+#
+#      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/extra/io/encodings/8-bit/8859-11.TXT b/extra/io/encodings/8-bit/8859-11.TXT
new file mode 100644 (file)
index 0000000..192bd9d
--- /dev/null
@@ -0,0 +1,297 @@
+#
+#      Name:             ISO/IEC 8859-11:2001 to Unicode
+#      Unicode version:  3.2
+#      Table version:    1.0
+#      Table format:     Format A
+#      Date:             2002 October 7
+#      Authors:          Ken Whistler <kenw@sybase.com>
+#
+#      Copyright (c) 2002 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-11:2001 characters map into Unicode.
+#
+#      ISO/IEC 8859-11:2001 is equivalent to TIS 620-2533 (1990) with
+#      the addition of 0xA0 NO-BREAK SPACE.
+#
+#      Format:  Three tab-separated columns
+#               Column #1 is the ISO/IEC 8859-11 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-11 order.
+#
+#      Version history:
+#              2002 October 7  Created
+#
+#      Updated versions of this file may be found in:
+#              <ftp://ftp.unicode.org/Public/MAPPINGS/>
+#
+#      For any comments or problems, please use the Unicode
+#      web contact form at:
+#              http://www.unicode.org/unicode/reporting.html
+#
+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   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
+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
diff --git a/extra/io/encodings/8-bit/8859-13.TXT b/extra/io/encodings/8-bit/8859-13.TXT
new file mode 100644 (file)
index 0000000..cd11b53
--- /dev/null
@@ -0,0 +1,299 @@
+#
+#      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/extra/io/encodings/8-bit/8859-14.TXT b/extra/io/encodings/8-bit/8859-14.TXT
new file mode 100644 (file)
index 0000000..73e9855
--- /dev/null
@@ -0,0 +1,301 @@
+#
+#      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 <http://www.cl.cam.ac.uk/~mgk25/>
+#                        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/extra/io/encodings/8-bit/8859-15.TXT b/extra/io/encodings/8-bit/8859-15.TXT
new file mode 100644 (file)
index 0000000..ab2f32f
--- /dev/null
@@ -0,0 +1,303 @@
+#
+#      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 <http://www.cl.cam.ac.uk/~mgk25/>
+#                        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/extra/io/encodings/8-bit/8859-16.TXT b/extra/io/encodings/8-bit/8859-16.TXT
new file mode 100644 (file)
index 0000000..c0dcf0d
--- /dev/null
@@ -0,0 +1,299 @@
+#
+#      Name:             ISO/IEC 8859-16:2001 to Unicode
+#      Unicode version:  3.0
+#      Table version:    1.0
+#      Table format:     Format A
+#      Date:             2001 July 26
+#      Authors:          Markus Kuhn <http://www.cl.cam.ac.uk/~mgk25/>
+#
+#      Copyright (c) 1999-2001 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-16:2001 characters map into Unicode.
+#
+#      Format:  Three tab-separated columns
+#               Column #1 is the ISO/IEC 8859-16 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-16 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   0x0104  #       LATIN CAPITAL LETTER A WITH OGONEK
+0xA2   0x0105  #       LATIN SMALL LETTER A WITH OGONEK
+0xA3   0x0141  #       LATIN CAPITAL LETTER L WITH STROKE
+0xA4   0x20AC  #       EURO SIGN
+0xA5   0x201E  #       DOUBLE LOW-9 QUOTATION MARK
+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   0x0218  #       LATIN CAPITAL LETTER S WITH COMMA BELOW
+0xAB   0x00AB  #       LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+0xAC   0x0179  #       LATIN CAPITAL LETTER Z WITH ACUTE
+0xAD   0x00AD  #       SOFT HYPHEN
+0xAE   0x017A  #       LATIN SMALL LETTER Z WITH ACUTE
+0xAF   0x017B  #       LATIN CAPITAL LETTER Z WITH DOT ABOVE
+0xB0   0x00B0  #       DEGREE SIGN
+0xB1   0x00B1  #       PLUS-MINUS SIGN
+0xB2   0x010C  #       LATIN CAPITAL LETTER C WITH CARON
+0xB3   0x0142  #       LATIN SMALL LETTER L WITH STROKE
+0xB4   0x017D  #       LATIN CAPITAL LETTER Z WITH CARON
+0xB5   0x201D  #       RIGHT DOUBLE QUOTATION MARK
+0xB6   0x00B6  #       PILCROW SIGN
+0xB7   0x00B7  #       MIDDLE DOT
+0xB8   0x017E  #       LATIN SMALL LETTER Z WITH CARON
+0xB9   0x010D  #       LATIN SMALL LETTER C WITH CARON
+0xBA   0x0219  #       LATIN SMALL LETTER S WITH COMMA BELOW
+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   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
+0xC3   0x0102  #       LATIN CAPITAL LETTER A WITH BREVE
+0xC4   0x00C4  #       LATIN CAPITAL LETTER A WITH DIAERESIS
+0xC5   0x0106  #       LATIN CAPITAL LETTER C WITH ACUTE
+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   0x0110  #       LATIN CAPITAL LETTER D WITH STROKE
+0xD1   0x0143  #       LATIN CAPITAL LETTER N WITH ACUTE
+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   0x0150  #       LATIN CAPITAL LETTER O WITH DOUBLE ACUTE
+0xD6   0x00D6  #       LATIN CAPITAL LETTER O WITH DIAERESIS
+0xD7   0x015A  #       LATIN CAPITAL LETTER S WITH ACUTE
+0xD8   0x0170  #       LATIN CAPITAL LETTER U WITH DOUBLE ACUTE
+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   0x0118  #       LATIN CAPITAL LETTER E WITH OGONEK
+0xDE   0x021A  #       LATIN CAPITAL LETTER T WITH COMMA BELOW
+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   0x0107  #       LATIN SMALL LETTER C WITH ACUTE
+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   0x0111  #       LATIN SMALL LETTER D WITH STROKE
+0xF1   0x0144  #       LATIN SMALL LETTER N WITH ACUTE
+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   0x0151  #       LATIN SMALL LETTER O WITH DOUBLE ACUTE
+0xF6   0x00F6  #       LATIN SMALL LETTER O WITH DIAERESIS
+0xF7   0x015B  #       LATIN SMALL LETTER S WITH ACUTE
+0xF8   0x0171  #       LATIN SMALL LETTER U WITH DOUBLE ACUTE
+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   0x0119  #       LATIN SMALL LETTER E WITH OGONEK
+0xFE   0x021B  #       LATIN SMALL LETTER T WITH COMMA BELOW
+0xFF   0x00FF  #       LATIN SMALL LETTER Y WITH DIAERESIS
diff --git a/extra/io/encodings/8-bit/8859-2.TXT b/extra/io/encodings/8-bit/8859-2.TXT
new file mode 100644 (file)
index 0000000..e45df25
--- /dev/null
@@ -0,0 +1,303 @@
+#
+#      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/extra/io/encodings/8-bit/8859-3.TXT b/extra/io/encodings/8-bit/8859-3.TXT
new file mode 100644 (file)
index 0000000..9b6ac69
--- /dev/null
@@ -0,0 +1,296 @@
+#
+#      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/extra/io/encodings/8-bit/8859-4.TXT b/extra/io/encodings/8-bit/8859-4.TXT
new file mode 100644 (file)
index 0000000..662e698
--- /dev/null
@@ -0,0 +1,303 @@
+#
+#      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/extra/io/encodings/8-bit/8859-5.TXT b/extra/io/encodings/8-bit/8859-5.TXT
new file mode 100644 (file)
index 0000000..a7ed1ce
--- /dev/null
@@ -0,0 +1,303 @@
+#
+#      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/extra/io/encodings/8-bit/8859-6.TXT b/extra/io/encodings/8-bit/8859-6.TXT
new file mode 100644 (file)
index 0000000..69ac7f5
--- /dev/null
@@ -0,0 +1,260 @@
+#
+#      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/extra/io/encodings/8-bit/8859-7.TXT b/extra/io/encodings/8-bit/8859-7.TXT
new file mode 100644 (file)
index 0000000..bc46b74
--- /dev/null
@@ -0,0 +1,308 @@
+#
+#      Name:             ISO 8859-7:2003 to Unicode
+#      Unicode version:  4.0
+#      Table version:    2.0
+#      Table format:     Format A
+#      Date:             2003-Nov-12
+#      Authors:          Ken Whistler <kenw@sybase.com>
+#
+#      Copyright (c) 1991-2003 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:2003 characters map into Unicode.
+#
+#      ISO 8859-7:1987 is equivalent to ISO-IR-126, ELOT 928,
+#      and ECMA 118. ISO 8859-7:2003 adds two currency signs 
+#      and one other character not in the earlier standard.
+#
+#      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
+#
+#      2.0 version updates 1.0 version by adding mappings for the
+#      three newly added characters 0xA4, 0xA5, 0xAA.
+#
+#      Updated versions of this file may be found in:
+#              <http://www.unicode.org/Public/MAPPINGS/>
+#
+#      Any comments or problems, contact the Unicode Consortium at:
+#              <http://www.unicode.org/reporting.html>
+#
+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
+0xA4   0x20AC  #       EURO SIGN
+0xA5   0x20AF  #       DRACHMA SIGN
+0xA6   0x00A6  #       BROKEN BAR
+0xA7   0x00A7  #       SECTION SIGN
+0xA8   0x00A8  #       DIAERESIS
+0xA9   0x00A9  #       COPYRIGHT SIGN
+0xAA   0x037A  #       GREEK YPOGEGRAMMENI
+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/extra/io/encodings/8-bit/8859-8.TXT b/extra/io/encodings/8-bit/8859-8.TXT
new file mode 100644 (file)
index 0000000..bc8da4c
--- /dev/null
@@ -0,0 +1,270 @@
+#
+#      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/extra/io/encodings/8-bit/8859-9.TXT b/extra/io/encodings/8-bit/8859-9.TXT
new file mode 100644 (file)
index 0000000..22901f1
--- /dev/null
@@ -0,0 +1,307 @@
+#
+#      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/extra/io/encodings/8-bit/CP037.TXT b/extra/io/encodings/8-bit/CP037.TXT
new file mode 100644 (file)
index 0000000..43186f7
--- /dev/null
@@ -0,0 +1,273 @@
+#
+#    Name:     cp037_IBMUSCanada to Unicode table
+#    Unicode version: 2.0
+#    Table version: 2.00
+#    Table format:  Format A
+#    Date:          04/24/96
+#    Contact: Shawn.Steele@microsoft.com
+#    
+#    General notes: none
+#
+#    Format: Three tab-separated columns
+#        Column #1 is the cp037_IBMUSCanada 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 cp037_IBMUSCanada order
+#
+0x00   0x0000  #NULL
+0x01   0x0001  #START OF HEADING
+0x02   0x0002  #START OF TEXT
+0x03   0x0003  #END OF TEXT
+0x04   0x009C  #CONTROL
+0x05   0x0009  #HORIZONTAL TABULATION
+0x06   0x0086  #CONTROL
+0x07   0x007F  #DELETE
+0x08   0x0097  #CONTROL
+0x09   0x008D  #CONTROL
+0x0A   0x008E  #CONTROL
+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   0x009D  #CONTROL
+0x15   0x0085  #CONTROL
+0x16   0x0008  #BACKSPACE
+0x17   0x0087  #CONTROL
+0x18   0x0018  #CANCEL
+0x19   0x0019  #END OF MEDIUM
+0x1A   0x0092  #CONTROL
+0x1B   0x008F  #CONTROL
+0x1C   0x001C  #FILE SEPARATOR
+0x1D   0x001D  #GROUP SEPARATOR
+0x1E   0x001E  #RECORD SEPARATOR
+0x1F   0x001F  #UNIT SEPARATOR
+0x20   0x0080  #CONTROL
+0x21   0x0081  #CONTROL
+0x22   0x0082  #CONTROL
+0x23   0x0083  #CONTROL
+0x24   0x0084  #CONTROL
+0x25   0x000A  #LINE FEED
+0x26   0x0017  #END OF TRANSMISSION BLOCK
+0x27   0x001B  #ESCAPE
+0x28   0x0088  #CONTROL
+0x29   0x0089  #CONTROL
+0x2A   0x008A  #CONTROL
+0x2B   0x008B  #CONTROL
+0x2C   0x008C  #CONTROL
+0x2D   0x0005  #ENQUIRY
+0x2E   0x0006  #ACKNOWLEDGE
+0x2F   0x0007  #BELL
+0x30   0x0090  #CONTROL
+0x31   0x0091  #CONTROL
+0x32   0x0016  #SYNCHRONOUS IDLE
+0x33   0x0093  #CONTROL
+0x34   0x0094  #CONTROL
+0x35   0x0095  #CONTROL
+0x36   0x0096  #CONTROL
+0x37   0x0004  #END OF TRANSMISSION
+0x38   0x0098  #CONTROL
+0x39   0x0099  #CONTROL
+0x3A   0x009A  #CONTROL
+0x3B   0x009B  #CONTROL
+0x3C   0x0014  #DEVICE CONTROL FOUR
+0x3D   0x0015  #NEGATIVE ACKNOWLEDGE
+0x3E   0x009E  #CONTROL
+0x3F   0x001A  #SUBSTITUTE
+0x40   0x0020  #SPACE
+0x41   0x00A0  #NO-BREAK SPACE
+0x42   0x00E2  #LATIN SMALL LETTER A WITH CIRCUMFLEX
+0x43   0x00E4  #LATIN SMALL LETTER A WITH DIAERESIS
+0x44   0x00E0  #LATIN SMALL LETTER A WITH GRAVE
+0x45   0x00E1  #LATIN SMALL LETTER A WITH ACUTE
+0x46   0x00E3  #LATIN SMALL LETTER A WITH TILDE
+0x47   0x00E5  #LATIN SMALL LETTER A WITH RING ABOVE
+0x48   0x00E7  #LATIN SMALL LETTER C WITH CEDILLA
+0x49   0x00F1  #LATIN SMALL LETTER N WITH TILDE
+0x4A   0x00A2  #CENT SIGN
+0x4B   0x002E  #FULL STOP
+0x4C   0x003C  #LESS-THAN SIGN
+0x4D   0x0028  #LEFT PARENTHESIS
+0x4E   0x002B  #PLUS SIGN
+0x4F   0x007C  #VERTICAL LINE
+0x50   0x0026  #AMPERSAND
+0x51   0x00E9  #LATIN SMALL LETTER E WITH ACUTE
+0x52   0x00EA  #LATIN SMALL LETTER E WITH CIRCUMFLEX
+0x53   0x00EB  #LATIN SMALL LETTER E WITH DIAERESIS
+0x54   0x00E8  #LATIN SMALL LETTER E WITH GRAVE
+0x55   0x00ED  #LATIN SMALL LETTER I WITH ACUTE
+0x56   0x00EE  #LATIN SMALL LETTER I WITH CIRCUMFLEX
+0x57   0x00EF  #LATIN SMALL LETTER I WITH DIAERESIS
+0x58   0x00EC  #LATIN SMALL LETTER I WITH GRAVE
+0x59   0x00DF  #LATIN SMALL LETTER SHARP S (GERMAN)
+0x5A   0x0021  #EXCLAMATION MARK
+0x5B   0x0024  #DOLLAR SIGN
+0x5C   0x002A  #ASTERISK
+0x5D   0x0029  #RIGHT PARENTHESIS
+0x5E   0x003B  #SEMICOLON
+0x5F   0x00AC  #NOT SIGN
+0x60   0x002D  #HYPHEN-MINUS
+0x61   0x002F  #SOLIDUS
+0x62   0x00C2  #LATIN CAPITAL LETTER A WITH CIRCUMFLEX
+0x63   0x00C4  #LATIN CAPITAL LETTER A WITH DIAERESIS
+0x64   0x00C0  #LATIN CAPITAL LETTER A WITH GRAVE
+0x65   0x00C1  #LATIN CAPITAL LETTER A WITH ACUTE
+0x66   0x00C3  #LATIN CAPITAL LETTER A WITH TILDE
+0x67   0x00C5  #LATIN CAPITAL LETTER A WITH RING ABOVE
+0x68   0x00C7  #LATIN CAPITAL LETTER C WITH CEDILLA
+0x69   0x00D1  #LATIN CAPITAL LETTER N WITH TILDE
+0x6A   0x00A6  #BROKEN BAR
+0x6B   0x002C  #COMMA
+0x6C   0x0025  #PERCENT SIGN
+0x6D   0x005F  #LOW LINE
+0x6E   0x003E  #GREATER-THAN SIGN
+0x6F   0x003F  #QUESTION MARK
+0x70   0x00F8  #LATIN SMALL LETTER O WITH STROKE
+0x71   0x00C9  #LATIN CAPITAL LETTER E WITH ACUTE
+0x72   0x00CA  #LATIN CAPITAL LETTER E WITH CIRCUMFLEX
+0x73   0x00CB  #LATIN CAPITAL LETTER E WITH DIAERESIS
+0x74   0x00C8  #LATIN CAPITAL LETTER E WITH GRAVE
+0x75   0x00CD  #LATIN CAPITAL LETTER I WITH ACUTE
+0x76   0x00CE  #LATIN CAPITAL LETTER I WITH CIRCUMFLEX
+0x77   0x00CF  #LATIN CAPITAL LETTER I WITH DIAERESIS
+0x78   0x00CC  #LATIN CAPITAL LETTER I WITH GRAVE
+0x79   0x0060  #GRAVE ACCENT
+0x7A   0x003A  #COLON
+0x7B   0x0023  #NUMBER SIGN
+0x7C   0x0040  #COMMERCIAL AT
+0x7D   0x0027  #APOSTROPHE
+0x7E   0x003D  #EQUALS SIGN
+0x7F   0x0022  #QUOTATION MARK
+0x80   0x00D8  #LATIN CAPITAL LETTER O WITH STROKE
+0x81   0x0061  #LATIN SMALL LETTER A
+0x82   0x0062  #LATIN SMALL LETTER B
+0x83   0x0063  #LATIN SMALL LETTER C
+0x84   0x0064  #LATIN SMALL LETTER D
+0x85   0x0065  #LATIN SMALL LETTER E
+0x86   0x0066  #LATIN SMALL LETTER F
+0x87   0x0067  #LATIN SMALL LETTER G
+0x88   0x0068  #LATIN SMALL LETTER H
+0x89   0x0069  #LATIN SMALL LETTER I
+0x8A   0x00AB  #LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+0x8B   0x00BB  #RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
+0x8C   0x00F0  #LATIN SMALL LETTER ETH (ICELANDIC)
+0x8D   0x00FD  #LATIN SMALL LETTER Y WITH ACUTE
+0x8E   0x00FE  #LATIN SMALL LETTER THORN (ICELANDIC)
+0x8F   0x00B1  #PLUS-MINUS SIGN
+0x90   0x00B0  #DEGREE SIGN
+0x91   0x006A  #LATIN SMALL LETTER J
+0x92   0x006B  #LATIN SMALL LETTER K
+0x93   0x006C  #LATIN SMALL LETTER L
+0x94   0x006D  #LATIN SMALL LETTER M
+0x95   0x006E  #LATIN SMALL LETTER N
+0x96   0x006F  #LATIN SMALL LETTER O
+0x97   0x0070  #LATIN SMALL LETTER P
+0x98   0x0071  #LATIN SMALL LETTER Q
+0x99   0x0072  #LATIN SMALL LETTER R
+0x9A   0x00AA  #FEMININE ORDINAL INDICATOR
+0x9B   0x00BA  #MASCULINE ORDINAL INDICATOR
+0x9C   0x00E6  #LATIN SMALL LIGATURE AE
+0x9D   0x00B8  #CEDILLA
+0x9E   0x00C6  #LATIN CAPITAL LIGATURE AE
+0x9F   0x00A4  #CURRENCY SIGN
+0xA0   0x00B5  #MICRO SIGN
+0xA1   0x007E  #TILDE
+0xA2   0x0073  #LATIN SMALL LETTER S
+0xA3   0x0074  #LATIN SMALL LETTER T
+0xA4   0x0075  #LATIN SMALL LETTER U
+0xA5   0x0076  #LATIN SMALL LETTER V
+0xA6   0x0077  #LATIN SMALL LETTER W
+0xA7   0x0078  #LATIN SMALL LETTER X
+0xA8   0x0079  #LATIN SMALL LETTER Y
+0xA9   0x007A  #LATIN SMALL LETTER Z
+0xAA   0x00A1  #INVERTED EXCLAMATION MARK
+0xAB   0x00BF  #INVERTED QUESTION MARK
+0xAC   0x00D0  #LATIN CAPITAL LETTER ETH (ICELANDIC)
+0xAD   0x00DD  #LATIN CAPITAL LETTER Y WITH ACUTE
+0xAE   0x00DE  #LATIN CAPITAL LETTER THORN (ICELANDIC)
+0xAF   0x00AE  #REGISTERED SIGN
+0xB0   0x005E  #CIRCUMFLEX ACCENT
+0xB1   0x00A3  #POUND SIGN
+0xB2   0x00A5  #YEN SIGN
+0xB3   0x00B7  #MIDDLE DOT
+0xB4   0x00A9  #COPYRIGHT SIGN
+0xB5   0x00A7  #SECTION SIGN
+0xB6   0x00B6  #PILCROW SIGN
+0xB7   0x00BC  #VULGAR FRACTION ONE QUARTER
+0xB8   0x00BD  #VULGAR FRACTION ONE HALF
+0xB9   0x00BE  #VULGAR FRACTION THREE QUARTERS
+0xBA   0x005B  #LEFT SQUARE BRACKET
+0xBB   0x005D  #RIGHT SQUARE BRACKET
+0xBC   0x00AF  #MACRON
+0xBD   0x00A8  #DIAERESIS
+0xBE   0x00B4  #ACUTE ACCENT
+0xBF   0x00D7  #MULTIPLICATION SIGN
+0xC0   0x007B  #LEFT CURLY BRACKET
+0xC1   0x0041  #LATIN CAPITAL LETTER A
+0xC2   0x0042  #LATIN CAPITAL LETTER B
+0xC3   0x0043  #LATIN CAPITAL LETTER C
+0xC4   0x0044  #LATIN CAPITAL LETTER D
+0xC5   0x0045  #LATIN CAPITAL LETTER E
+0xC6   0x0046  #LATIN CAPITAL LETTER F
+0xC7   0x0047  #LATIN CAPITAL LETTER G
+0xC8   0x0048  #LATIN CAPITAL LETTER H
+0xC9   0x0049  #LATIN CAPITAL LETTER I
+0xCA   0x00AD  #SOFT HYPHEN
+0xCB   0x00F4  #LATIN SMALL LETTER O WITH CIRCUMFLEX
+0xCC   0x00F6  #LATIN SMALL LETTER O WITH DIAERESIS
+0xCD   0x00F2  #LATIN SMALL LETTER O WITH GRAVE
+0xCE   0x00F3  #LATIN SMALL LETTER O WITH ACUTE
+0xCF   0x00F5  #LATIN SMALL LETTER O WITH TILDE
+0xD0   0x007D  #RIGHT CURLY BRACKET
+0xD1   0x004A  #LATIN CAPITAL LETTER J
+0xD2   0x004B  #LATIN CAPITAL LETTER K
+0xD3   0x004C  #LATIN CAPITAL LETTER L
+0xD4   0x004D  #LATIN CAPITAL LETTER M
+0xD5   0x004E  #LATIN CAPITAL LETTER N
+0xD6   0x004F  #LATIN CAPITAL LETTER O
+0xD7   0x0050  #LATIN CAPITAL LETTER P
+0xD8   0x0051  #LATIN CAPITAL LETTER Q
+0xD9   0x0052  #LATIN CAPITAL LETTER R
+0xDA   0x00B9  #SUPERSCRIPT ONE
+0xDB   0x00FB  #LATIN SMALL LETTER U WITH CIRCUMFLEX
+0xDC   0x00FC  #LATIN SMALL LETTER U WITH DIAERESIS
+0xDD   0x00F9  #LATIN SMALL LETTER U WITH GRAVE
+0xDE   0x00FA  #LATIN SMALL LETTER U WITH ACUTE
+0xDF   0x00FF  #LATIN SMALL LETTER Y WITH DIAERESIS
+0xE0   0x005C  #REVERSE SOLIDUS
+0xE1   0x00F7  #DIVISION SIGN
+0xE2   0x0053  #LATIN CAPITAL LETTER S
+0xE3   0x0054  #LATIN CAPITAL LETTER T
+0xE4   0x0055  #LATIN CAPITAL LETTER U
+0xE5   0x0056  #LATIN CAPITAL LETTER V
+0xE6   0x0057  #LATIN CAPITAL LETTER W
+0xE7   0x0058  #LATIN CAPITAL LETTER X
+0xE8   0x0059  #LATIN CAPITAL LETTER Y
+0xE9   0x005A  #LATIN CAPITAL LETTER Z
+0xEA   0x00B2  #SUPERSCRIPT TWO
+0xEB   0x00D4  #LATIN CAPITAL LETTER O WITH CIRCUMFLEX
+0xEC   0x00D6  #LATIN CAPITAL LETTER O WITH DIAERESIS
+0xED   0x00D2  #LATIN CAPITAL LETTER O WITH GRAVE
+0xEE   0x00D3  #LATIN CAPITAL LETTER O WITH ACUTE
+0xEF   0x00D5  #LATIN CAPITAL LETTER O WITH TILDE
+0xF0   0x0030  #DIGIT ZERO
+0xF1   0x0031  #DIGIT ONE
+0xF2   0x0032  #DIGIT TWO
+0xF3   0x0033  #DIGIT THREE
+0xF4   0x0034  #DIGIT FOUR
+0xF5   0x0035  #DIGIT FIVE
+0xF6   0x0036  #DIGIT SIX
+0xF7   0x0037  #DIGIT SEVEN
+0xF8   0x0038  #DIGIT EIGHT
+0xF9   0x0039  #DIGIT NINE
+0xFA   0x00B3  #SUPERSCRIPT THREE
+0xFB   0x00DB  #LATIN CAPITAL LETTER U WITH CIRCUMFLEX
+0xFC   0x00DC  #LATIN CAPITAL LETTER U WITH DIAERESIS
+0xFD   0x00D9  #LATIN CAPITAL LETTER U WITH GRAVE
+0xFE   0x00DA  #LATIN CAPITAL LETTER U WITH ACUTE
+0xFF   0x009F  #CONTROL
diff --git a/extra/io/encodings/8-bit/CP1252.TXT b/extra/io/encodings/8-bit/CP1252.TXT
new file mode 100644 (file)
index 0000000..8ff4b20
--- /dev/null
@@ -0,0 +1,274 @@
+#
+#    Name:     cp1252 to Unicode table
+#    Unicode version: 2.0
+#    Table version: 2.01
+#    Table format:  Format A
+#    Date:          04/15/98
+#
+#    Contact:       Shawn.Steele@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/extra/io/encodings/8-bit/KOI8-R.TXT b/extra/io/encodings/8-bit/KOI8-R.TXT
new file mode 100644 (file)
index 0000000..5105610
--- /dev/null
@@ -0,0 +1,302 @@
+#
+#      Name:             KOI8-R (RFC1489) to Unicode
+#      Unicode version:  3.0
+#      Table version:    1.0
+#      Table format:     Format A
+#      Date:             18 August 1999
+#      Authors:          Helmut Richter <richter@lrz.de>
+#
+#      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
+#       KOI8-R characters map into Unicode. The underlying document is the
+#      mapping described in RFC 1489. No statements are made as to whether
+#      this mapping is the same as the mapping defined as "Code Page 878"
+#      with some vendors.
+#
+#      Format:  Three tab-separated columns
+#               Column #1 is the KOI8-R 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 KOI8-R order.
+#
+#      Version history
+#      1.0 version: created.
+#
+#      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   0x2500  #       BOX DRAWINGS LIGHT HORIZONTAL
+0x81   0x2502  #       BOX DRAWINGS LIGHT VERTICAL
+0x82   0x250C  #       BOX DRAWINGS LIGHT DOWN AND RIGHT
+0x83   0x2510  #       BOX DRAWINGS LIGHT DOWN AND LEFT
+0x84   0x2514  #       BOX DRAWINGS LIGHT UP AND RIGHT
+0x85   0x2518  #       BOX DRAWINGS LIGHT UP AND LEFT
+0x86   0x251C  #       BOX DRAWINGS LIGHT VERTICAL AND RIGHT
+0x87   0x2524  #       BOX DRAWINGS LIGHT VERTICAL AND LEFT
+0x88   0x252C  #       BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
+0x89   0x2534  #       BOX DRAWINGS LIGHT UP AND HORIZONTAL
+0x8A   0x253C  #       BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
+0x8B   0x2580  #       UPPER HALF BLOCK
+0x8C   0x2584  #       LOWER HALF BLOCK
+0x8D   0x2588  #       FULL BLOCK
+0x8E   0x258C  #       LEFT HALF BLOCK
+0x8F   0x2590  #       RIGHT HALF BLOCK
+0x90   0x2591  #       LIGHT SHADE
+0x91   0x2592  #       MEDIUM SHADE
+0x92   0x2593  #       DARK SHADE
+0x93   0x2320  #       TOP HALF INTEGRAL
+0x94   0x25A0  #       BLACK SQUARE
+0x95   0x2219  #       BULLET OPERATOR
+0x96   0x221A  #       SQUARE ROOT
+0x97   0x2248  #       ALMOST EQUAL TO
+0x98   0x2264  #       LESS-THAN OR EQUAL TO
+0x99   0x2265  #       GREATER-THAN OR EQUAL TO
+0x9A   0x00A0  #       NO-BREAK SPACE
+0x9B   0x2321  #       BOTTOM HALF INTEGRAL
+0x9C   0x00B0  #       DEGREE SIGN
+0x9D   0x00B2  #       SUPERSCRIPT TWO
+0x9E   0x00B7  #       MIDDLE DOT
+0x9F   0x00F7  #       DIVISION SIGN
+0xA0   0x2550  #       BOX DRAWINGS DOUBLE HORIZONTAL
+0xA1   0x2551  #       BOX DRAWINGS DOUBLE VERTICAL
+0xA2   0x2552  #       BOX DRAWINGS DOWN SINGLE AND RIGHT DOUBLE
+0xA3   0x0451  #       CYRILLIC SMALL LETTER IO
+0xA4   0x2553  #       BOX DRAWINGS DOWN DOUBLE AND RIGHT SINGLE
+0xA5   0x2554  #       BOX DRAWINGS DOUBLE DOWN AND RIGHT
+0xA6   0x2555  #       BOX DRAWINGS DOWN SINGLE AND LEFT DOUBLE
+0xA7   0x2556  #       BOX DRAWINGS DOWN DOUBLE AND LEFT SINGLE
+0xA8   0x2557  #       BOX DRAWINGS DOUBLE DOWN AND LEFT
+0xA9   0x2558  #       BOX DRAWINGS UP SINGLE AND RIGHT DOUBLE
+0xAA   0x2559  #       BOX DRAWINGS UP DOUBLE AND RIGHT SINGLE
+0xAB   0x255A  #       BOX DRAWINGS DOUBLE UP AND RIGHT
+0xAC   0x255B  #       BOX DRAWINGS UP SINGLE AND LEFT DOUBLE
+0xAD   0x255C  #       BOX DRAWINGS UP DOUBLE AND LEFT SINGLE
+0xAE   0x255D  #       BOX DRAWINGS DOUBLE UP AND LEFT
+0xAF   0x255E  #       BOX DRAWINGS VERTICAL SINGLE AND RIGHT DOUBLE
+0xB0   0x255F  #       BOX DRAWINGS VERTICAL DOUBLE AND RIGHT SINGLE
+0xB1   0x2560  #       BOX DRAWINGS DOUBLE VERTICAL AND RIGHT
+0xB2   0x2561  #       BOX DRAWINGS VERTICAL SINGLE AND LEFT DOUBLE
+0xB3   0x0401  #       CYRILLIC CAPITAL LETTER IO
+0xB4   0x2562  #       BOX DRAWINGS VERTICAL DOUBLE AND LEFT SINGLE
+0xB5   0x2563  #       BOX DRAWINGS DOUBLE VERTICAL AND LEFT
+0xB6   0x2564  #       BOX DRAWINGS DOWN SINGLE AND HORIZONTAL DOUBLE
+0xB7   0x2565  #       BOX DRAWINGS DOWN DOUBLE AND HORIZONTAL SINGLE
+0xB8   0x2566  #       BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL
+0xB9   0x2567  #       BOX DRAWINGS UP SINGLE AND HORIZONTAL DOUBLE
+0xBA   0x2568  #       BOX DRAWINGS UP DOUBLE AND HORIZONTAL SINGLE
+0xBB   0x2569  #       BOX DRAWINGS DOUBLE UP AND HORIZONTAL
+0xBC   0x256A  #       BOX DRAWINGS VERTICAL SINGLE AND HORIZONTAL DOUBLE
+0xBD   0x256B  #       BOX DRAWINGS VERTICAL DOUBLE AND HORIZONTAL SINGLE
+0xBE   0x256C  #       BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL
+0xBF   0x00A9  #       COPYRIGHT SIGN
+0xC0   0x044E  #       CYRILLIC SMALL LETTER YU
+0xC1   0x0430  #       CYRILLIC SMALL LETTER A
+0xC2   0x0431  #       CYRILLIC SMALL LETTER BE
+0xC3   0x0446  #       CYRILLIC SMALL LETTER TSE
+0xC4   0x0434  #       CYRILLIC SMALL LETTER DE
+0xC5   0x0435  #       CYRILLIC SMALL LETTER IE
+0xC6   0x0444  #       CYRILLIC SMALL LETTER EF
+0xC7   0x0433  #       CYRILLIC SMALL LETTER GHE
+0xC8   0x0445  #       CYRILLIC SMALL LETTER HA
+0xC9   0x0438  #       CYRILLIC SMALL LETTER I
+0xCA   0x0439  #       CYRILLIC SMALL LETTER SHORT I
+0xCB   0x043A  #       CYRILLIC SMALL LETTER KA
+0xCC   0x043B  #       CYRILLIC SMALL LETTER EL
+0xCD   0x043C  #       CYRILLIC SMALL LETTER EM
+0xCE   0x043D  #       CYRILLIC SMALL LETTER EN
+0xCF   0x043E  #       CYRILLIC SMALL LETTER O
+0xD0   0x043F  #       CYRILLIC SMALL LETTER PE
+0xD1   0x044F  #       CYRILLIC SMALL LETTER YA
+0xD2   0x0440  #       CYRILLIC SMALL LETTER ER
+0xD3   0x0441  #       CYRILLIC SMALL LETTER ES
+0xD4   0x0442  #       CYRILLIC SMALL LETTER TE
+0xD5   0x0443  #       CYRILLIC SMALL LETTER U
+0xD6   0x0436  #       CYRILLIC SMALL LETTER ZHE
+0xD7   0x0432  #       CYRILLIC SMALL LETTER VE
+0xD8   0x044C  #       CYRILLIC SMALL LETTER SOFT SIGN
+0xD9   0x044B  #       CYRILLIC SMALL LETTER YERU
+0xDA   0x0437  #       CYRILLIC SMALL LETTER ZE
+0xDB   0x0448  #       CYRILLIC SMALL LETTER SHA
+0xDC   0x044D  #       CYRILLIC SMALL LETTER E
+0xDD   0x0449  #       CYRILLIC SMALL LETTER SHCHA
+0xDE   0x0447  #       CYRILLIC SMALL LETTER CHE
+0xDF   0x044A  #       CYRILLIC SMALL LETTER HARD SIGN
+0xE0   0x042E  #       CYRILLIC CAPITAL LETTER YU
+0xE1   0x0410  #       CYRILLIC CAPITAL LETTER A
+0xE2   0x0411  #       CYRILLIC CAPITAL LETTER BE
+0xE3   0x0426  #       CYRILLIC CAPITAL LETTER TSE
+0xE4   0x0414  #       CYRILLIC CAPITAL LETTER DE
+0xE5   0x0415  #       CYRILLIC CAPITAL LETTER IE
+0xE6   0x0424  #       CYRILLIC CAPITAL LETTER EF
+0xE7   0x0413  #       CYRILLIC CAPITAL LETTER GHE
+0xE8   0x0425  #       CYRILLIC CAPITAL LETTER HA
+0xE9   0x0418  #       CYRILLIC CAPITAL LETTER I
+0xEA   0x0419  #       CYRILLIC CAPITAL LETTER SHORT I
+0xEB   0x041A  #       CYRILLIC CAPITAL LETTER KA
+0xEC   0x041B  #       CYRILLIC CAPITAL LETTER EL
+0xED   0x041C  #       CYRILLIC CAPITAL LETTER EM
+0xEE   0x041D  #       CYRILLIC CAPITAL LETTER EN
+0xEF   0x041E  #       CYRILLIC CAPITAL LETTER O
+0xF0   0x041F  #       CYRILLIC CAPITAL LETTER PE
+0xF1   0x042F  #       CYRILLIC CAPITAL LETTER YA
+0xF2   0x0420  #       CYRILLIC CAPITAL LETTER ER
+0xF3   0x0421  #       CYRILLIC CAPITAL LETTER ES
+0xF4   0x0422  #       CYRILLIC CAPITAL LETTER TE
+0xF5   0x0423  #       CYRILLIC CAPITAL LETTER U
+0xF6   0x0416  #       CYRILLIC CAPITAL LETTER ZHE
+0xF7   0x0412  #       CYRILLIC CAPITAL LETTER VE
+0xF8   0x042C  #       CYRILLIC CAPITAL LETTER SOFT SIGN
+0xF9   0x042B  #       CYRILLIC CAPITAL LETTER YERU
+0xFA   0x0417  #       CYRILLIC CAPITAL LETTER ZE
+0xFB   0x0428  #       CYRILLIC CAPITAL LETTER SHA
+0xFC   0x042D  #       CYRILLIC CAPITAL LETTER E
+0xFD   0x0429  #       CYRILLIC CAPITAL LETTER SHCHA
+0xFE   0x0427  #       CYRILLIC CAPITAL LETTER CHE
+0xFF   0x042A  #       CYRILLIC CAPITAL LETTER HARD SIGN
diff --git a/extra/io/encodings/8-bit/ROMAN.TXT b/extra/io/encodings/8-bit/ROMAN.TXT
new file mode 100644 (file)
index 0000000..5b3b8b4
--- /dev/null
@@ -0,0 +1,370 @@
+#=======================================================================
+#   File name:  ROMAN.TXT
+#
+#   Contents:   Map (external version) from Mac OS Roman
+#               character set to Unicode 2.1 and later.
+#
+#   Copyright:  (c) 1994-2002, 2005 by Apple Computer, Inc., all rights
+#               reserved.
+#
+#   Contact:    charsets@apple.com
+#
+#   Changes:
+#
+#       c02  2005-Apr-05    Update header comments. Matches internal xml
+#                           <c1.1> and Text Encoding Converter 2.0.
+#      b4,c1 2002-Dec-19    Update URLs, notes. Matches internal
+#                           utom<b5>.
+#       b03  1999-Sep-22    Update contact e-mail address. Matches
+#                           internal utom<b4>, ufrm<b3>, and Text
+#                           Encoding Converter version 1.5.
+#       b02  1998-Aug-18    Encoding changed for Mac OS 8.5; change
+#                           mapping of 0xDB from CURRENCY SIGN to
+#                           EURO SIGN. Matches internal utom<b3>,
+#                           ufrm<b3>.
+#       n08  1998-Feb-05    Minor update to header comments
+#       n06  1997-Dec-14    Add warning about future changes to 0xDB
+#                           from CURRENCY SIGN to EURO SIGN. Clarify
+#                           some header information
+#       n04  1997-Dec-01    Update to match internal utom<n3>, ufrm<n22>:
+#                           Change standard mapping for 0xBD from U+2126
+#                           to its canonical decomposition, U+03A9.
+#       n03  1995-Apr-15    First version (after fixing some typos).
+#                           Matches internal ufrm<n9>.
+#
+# Standard header:
+# ----------------
+#
+#   Apple, the Apple logo, and Macintosh are trademarks of Apple
+#   Computer, Inc., registered in the United States and other countries.
+#   Unicode is a trademark of Unicode Inc. For the sake of brevity,
+#   throughout this document, "Macintosh" can be used to refer to
+#   Macintosh computers and "Unicode" can be used to refer to the
+#   Unicode standard.
+#
+#   Apple Computer, Inc. ("Apple") makes no warranty or representation,
+#   either express or implied, with respect to this document and the
+#   included data, its quality, accuracy, or fitness for a particular
+#   purpose. In no event will Apple be liable for direct, indirect,
+#   special, incidental, or consequential damages resulting from any
+#   defect or inaccuracy in this document or the included data.
+#
+#   These mapping tables and character lists are subject to change.
+#   The latest tables should be available from the following:
+#
+#   <http://www.unicode.org/Public/MAPPINGS/VENDORS/APPLE/>
+#
+#   For general information about Mac OS encodings and these mapping
+#   tables, see the file "README.TXT".
+#
+# Format:
+# -------
+#
+#   Three tab-separated columns;
+#   '#' begins a comment which continues to the end of the line.
+#     Column #1 is the Mac OS Roman code (in hex as 0xNN)
+#     Column #2 is the corresponding Unicode (in hex as 0xNNNN)
+#     Column #3 is a comment containing the Unicode name
+#
+#   The entries are in Mac OS Roman code order.
+#
+#   One of these mappings requires the use of a corporate character.
+#   See the file "CORPCHAR.TXT" and notes below.
+#
+#   Control character mappings are not shown in this table, following
+#   the conventions of the standard UTC mapping tables. However, the
+#   Mac OS Roman character set uses the standard control characters at
+#   0x00-0x1F and 0x7F.
+#
+# Notes on Mac OS Roman:
+# ----------------------
+#
+#   This is a legacy Mac OS encoding; in the Mac OS X Carbon and Cocoa
+#   environments, it is only supported directly in programming
+#   interfaces for QuickDraw Text, the Script Manager, and related
+#   Text Utilities. For other purposes it is supported via transcoding
+#   to and from Unicode.
+#
+#   This character set is used for at least the following Mac OS
+#   localizations: U.S., British, Canadian French, French, Swiss
+#   French, German, Swiss German, Italian, Swiss Italian, Dutch,
+#   Swedish, Norwegian, Danish, Finnish, Spanish, Catalan,
+#   Portuguese, Brazilian, and the default International system.
+#
+#   Variants of Mac OS Roman are used for Croatian, Icelandic,
+#   Turkish, Romanian, and other encodings. Separate mapping tables
+#   are available for these encodings.
+#
+#   Before Mac OS 8.5, code point 0xDB was CURRENCY SIGN, and was
+#   mapped to U+00A4. In Mac OS 8.5 and later versions, code point
+#   0xDB is changed to EURO SIGN and maps to U+20AC; the standard
+#   Apple fonts are updated for Mac OS 8.5 to reflect this. There is
+#   a "currency sign" variant of the Mac OS Roman encoding that still
+#   maps 0xDB to U+00A4; this can be used for older fonts.
+#
+#   Before Mac OS 8.5, the ROM bitmap versions of the fonts Chicago,
+#   New York, Geneva, and Monaco did not implement the full Mac OS
+#   Roman character set; they only supported character codes up to
+#   0xD8. The TrueType versions of these fonts have always implemented
+#   the full character set, as with the bitmap and TrueType versions
+#   of the other standard Roman fonts.
+#
+#   In all Mac OS encodings, fonts such as Chicago which are used
+#   as "system" fonts (for menus, dialogs, etc.) have four glyphs
+#   at code points 0x11-0x14 for transient use by the Menu Manager.
+#   These glyphs are not intended as characters for use in normal
+#   text, and the associated code points are not generally
+#   interpreted as associated with these glyphs; they are usually
+#   interpreted (if at all) as the control codes DC1-DC4.
+#
+# Unicode mapping issues and notes:
+# ---------------------------------
+#
+#   The following corporate zone Unicode character is used in this
+#   mapping:
+#
+#     0xF8FF  Apple logo
+#
+#   NOTE: The graphic image associated with the Apple logo character
+#   is not authorized for use without permission of Apple, and
+#   unauthorized use might constitute trademark infringement.
+#
+# Details of mapping changes in each version:
+# -------------------------------------------
+#
+#   Changes from version n08 to version b02:
+#
+#   - Encoding changed for Mac OS 8.5; change mapping of 0xDB from
+#   CURRENCY SIGN (U+00A4) to EURO SIGN (U+20AC).
+#
+#   Changes from version n03 to version n04:
+#
+#   - Change mapping of 0xBD from U+2126 to its canonical
+#     decomposition, U+03A9.
+#
+##################
+
+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
+#
+0x80   0x00C4  # LATIN CAPITAL LETTER A WITH DIAERESIS
+0x81   0x00C5  # LATIN CAPITAL LETTER A WITH RING ABOVE
+0x82   0x00C7  # LATIN CAPITAL LETTER C WITH CEDILLA
+0x83   0x00C9  # LATIN CAPITAL LETTER E WITH ACUTE
+0x84   0x00D1  # LATIN CAPITAL LETTER N WITH TILDE
+0x85   0x00D6  # LATIN CAPITAL LETTER O WITH DIAERESIS
+0x86   0x00DC  # LATIN CAPITAL LETTER U WITH DIAERESIS
+0x87   0x00E1  # LATIN SMALL LETTER A WITH ACUTE
+0x88   0x00E0  # LATIN SMALL LETTER A WITH GRAVE
+0x89   0x00E2  # LATIN SMALL LETTER A WITH CIRCUMFLEX
+0x8A   0x00E4  # LATIN SMALL LETTER A WITH DIAERESIS
+0x8B   0x00E3  # LATIN SMALL LETTER A WITH TILDE
+0x8C   0x00E5  # LATIN SMALL LETTER A WITH RING ABOVE
+0x8D   0x00E7  # LATIN SMALL LETTER C WITH CEDILLA
+0x8E   0x00E9  # LATIN SMALL LETTER E WITH ACUTE
+0x8F   0x00E8  # LATIN SMALL LETTER E WITH GRAVE
+0x90   0x00EA  # LATIN SMALL LETTER E WITH CIRCUMFLEX
+0x91   0x00EB  # LATIN SMALL LETTER E WITH DIAERESIS
+0x92   0x00ED  # LATIN SMALL LETTER I WITH ACUTE
+0x93   0x00EC  # LATIN SMALL LETTER I WITH GRAVE
+0x94   0x00EE  # LATIN SMALL LETTER I WITH CIRCUMFLEX
+0x95   0x00EF  # LATIN SMALL LETTER I WITH DIAERESIS
+0x96   0x00F1  # LATIN SMALL LETTER N WITH TILDE
+0x97   0x00F3  # LATIN SMALL LETTER O WITH ACUTE
+0x98   0x00F2  # LATIN SMALL LETTER O WITH GRAVE
+0x99   0x00F4  # LATIN SMALL LETTER O WITH CIRCUMFLEX
+0x9A   0x00F6  # LATIN SMALL LETTER O WITH DIAERESIS
+0x9B   0x00F5  # LATIN SMALL LETTER O WITH TILDE
+0x9C   0x00FA  # LATIN SMALL LETTER U WITH ACUTE
+0x9D   0x00F9  # LATIN SMALL LETTER U WITH GRAVE
+0x9E   0x00FB  # LATIN SMALL LETTER U WITH CIRCUMFLEX
+0x9F   0x00FC  # LATIN SMALL LETTER U WITH DIAERESIS
+0xA0   0x2020  # DAGGER
+0xA1   0x00B0  # DEGREE SIGN
+0xA2   0x00A2  # CENT SIGN
+0xA3   0x00A3  # POUND SIGN
+0xA4   0x00A7  # SECTION SIGN
+0xA5   0x2022  # BULLET
+0xA6   0x00B6  # PILCROW SIGN
+0xA7   0x00DF  # LATIN SMALL LETTER SHARP S
+0xA8   0x00AE  # REGISTERED SIGN
+0xA9   0x00A9  # COPYRIGHT SIGN
+0xAA   0x2122  # TRADE MARK SIGN
+0xAB   0x00B4  # ACUTE ACCENT
+0xAC   0x00A8  # DIAERESIS
+0xAD   0x2260  # NOT EQUAL TO
+0xAE   0x00C6  # LATIN CAPITAL LETTER AE
+0xAF   0x00D8  # LATIN CAPITAL LETTER O WITH STROKE
+0xB0   0x221E  # INFINITY
+0xB1   0x00B1  # PLUS-MINUS SIGN
+0xB2   0x2264  # LESS-THAN OR EQUAL TO
+0xB3   0x2265  # GREATER-THAN OR EQUAL TO
+0xB4   0x00A5  # YEN SIGN
+0xB5   0x00B5  # MICRO SIGN
+0xB6   0x2202  # PARTIAL DIFFERENTIAL
+0xB7   0x2211  # N-ARY SUMMATION
+0xB8   0x220F  # N-ARY PRODUCT
+0xB9   0x03C0  # GREEK SMALL LETTER PI
+0xBA   0x222B  # INTEGRAL
+0xBB   0x00AA  # FEMININE ORDINAL INDICATOR
+0xBC   0x00BA  # MASCULINE ORDINAL INDICATOR
+0xBD   0x03A9  # GREEK CAPITAL LETTER OMEGA
+0xBE   0x00E6  # LATIN SMALL LETTER AE
+0xBF   0x00F8  # LATIN SMALL LETTER O WITH STROKE
+0xC0   0x00BF  # INVERTED QUESTION MARK
+0xC1   0x00A1  # INVERTED EXCLAMATION MARK
+0xC2   0x00AC  # NOT SIGN
+0xC3   0x221A  # SQUARE ROOT
+0xC4   0x0192  # LATIN SMALL LETTER F WITH HOOK
+0xC5   0x2248  # ALMOST EQUAL TO
+0xC6   0x2206  # INCREMENT
+0xC7   0x00AB  # LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+0xC8   0x00BB  # RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
+0xC9   0x2026  # HORIZONTAL ELLIPSIS
+0xCA   0x00A0  # NO-BREAK SPACE
+0xCB   0x00C0  # LATIN CAPITAL LETTER A WITH GRAVE
+0xCC   0x00C3  # LATIN CAPITAL LETTER A WITH TILDE
+0xCD   0x00D5  # LATIN CAPITAL LETTER O WITH TILDE
+0xCE   0x0152  # LATIN CAPITAL LIGATURE OE
+0xCF   0x0153  # LATIN SMALL LIGATURE OE
+0xD0   0x2013  # EN DASH
+0xD1   0x2014  # EM DASH
+0xD2   0x201C  # LEFT DOUBLE QUOTATION MARK
+0xD3   0x201D  # RIGHT DOUBLE QUOTATION MARK
+0xD4   0x2018  # LEFT SINGLE QUOTATION MARK
+0xD5   0x2019  # RIGHT SINGLE QUOTATION MARK
+0xD6   0x00F7  # DIVISION SIGN
+0xD7   0x25CA  # LOZENGE
+0xD8   0x00FF  # LATIN SMALL LETTER Y WITH DIAERESIS
+0xD9   0x0178  # LATIN CAPITAL LETTER Y WITH DIAERESIS
+0xDA   0x2044  # FRACTION SLASH
+0xDB   0x20AC  # EURO SIGN
+0xDC   0x2039  # SINGLE LEFT-POINTING ANGLE QUOTATION MARK
+0xDD   0x203A  # SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
+0xDE   0xFB01  # LATIN SMALL LIGATURE FI
+0xDF   0xFB02  # LATIN SMALL LIGATURE FL
+0xE0   0x2021  # DOUBLE DAGGER
+0xE1   0x00B7  # MIDDLE DOT
+0xE2   0x201A  # SINGLE LOW-9 QUOTATION MARK
+0xE3   0x201E  # DOUBLE LOW-9 QUOTATION MARK
+0xE4   0x2030  # PER MILLE SIGN
+0xE5   0x00C2  # LATIN CAPITAL LETTER A WITH CIRCUMFLEX
+0xE6   0x00CA  # LATIN CAPITAL LETTER E WITH CIRCUMFLEX
+0xE7   0x00C1  # LATIN CAPITAL LETTER A WITH ACUTE
+0xE8   0x00CB  # LATIN CAPITAL LETTER E WITH DIAERESIS
+0xE9   0x00C8  # LATIN CAPITAL LETTER E WITH GRAVE
+0xEA   0x00CD  # LATIN CAPITAL LETTER I WITH ACUTE
+0xEB   0x00CE  # LATIN CAPITAL LETTER I WITH CIRCUMFLEX
+0xEC   0x00CF  # LATIN CAPITAL LETTER I WITH DIAERESIS
+0xED   0x00CC  # LATIN CAPITAL LETTER I WITH GRAVE
+0xEE   0x00D3  # LATIN CAPITAL LETTER O WITH ACUTE
+0xEF   0x00D4  # LATIN CAPITAL LETTER O WITH CIRCUMFLEX
+0xF0   0xF8FF  # Apple logo
+0xF1   0x00D2  # LATIN CAPITAL LETTER O WITH GRAVE
+0xF2   0x00DA  # LATIN CAPITAL LETTER U WITH ACUTE
+0xF3   0x00DB  # LATIN CAPITAL LETTER U WITH CIRCUMFLEX
+0xF4   0x00D9  # LATIN CAPITAL LETTER U WITH GRAVE
+0xF5   0x0131  # LATIN SMALL LETTER DOTLESS I
+0xF6   0x02C6  # MODIFIER LETTER CIRCUMFLEX ACCENT
+0xF7   0x02DC  # SMALL TILDE
+0xF8   0x00AF  # MACRON
+0xF9   0x02D8  # BREVE
+0xFA   0x02D9  # DOT ABOVE
+0xFB   0x02DA  # RING ABOVE
+0xFC   0x00B8  # CEDILLA
+0xFD   0x02DD  # DOUBLE ACUTE ACCENT
+0xFE   0x02DB  # OGONEK
+0xFF   0x02C7  # CARON
diff --git a/extra/io/encodings/8-bit/authors.txt b/extra/io/encodings/8-bit/authors.txt
new file mode 100644 (file)
index 0000000..f990dd0
--- /dev/null
@@ -0,0 +1 @@
+Daniel Ehrenberg
diff --git a/extra/io/encodings/8-bit/summary.txt b/extra/io/encodings/8-bit/summary.txt
new file mode 100644 (file)
index 0000000..7fe8064
--- /dev/null
@@ -0,0 +1 @@
+Definitions of 8-bit encodings like ISO 8859 and Windows 1252
diff --git a/extra/io/encodings/8-bit/tags.txt b/extra/io/encodings/8-bit/tags.txt
new file mode 100644 (file)
index 0000000..8e27be7
--- /dev/null
@@ -0,0 +1 @@
+text
diff --git a/extra/io/encodings/ascii/ascii-docs.factor b/extra/io/encodings/ascii/ascii-docs.factor
new file mode 100644 (file)
index 0000000..0b54a34
--- /dev/null
@@ -0,0 +1,8 @@
+USING: help.markup help.syntax ;
+IN: io.encodings.ascii
+
+HELP: ascii
+{ $class-description "This is the encoding descriptor which denotes an ASCII encoding. By default, if there's a non-ASCII character in an input stream, it will be replaced with a replacement character (U+FFFD), and if a non-ASCII character is used in output, an exception is thrown." }
+{ $see-also "encodings-introduction" } ;
+
+ABOUT: ascii
diff --git a/extra/io/encodings/latin1/authors.txt b/extra/io/encodings/latin1/authors.txt
deleted file mode 100644 (file)
index f990dd0..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Daniel Ehrenberg
diff --git a/extra/io/encodings/latin1/latin1-docs.factor b/extra/io/encodings/latin1/latin1-docs.factor
deleted file mode 100644 (file)
index 5872b2b..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-USING: help.syntax help.markup ;
-IN: io.encodings.latin1
-
-HELP: latin1
-{ $class-description "This class is used for Latin 1 (ISO 8859-1) encoding and decoding" } ;
diff --git a/extra/io/encodings/latin1/latin1-tests.factor b/extra/io/encodings/latin1/latin1-tests.factor
deleted file mode 100644 (file)
index a89bfe0..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-USING: io.encodings.string io.encodings.latin1 tools.test strings arrays ;
-IN: io.encodings.latin1.tests
-
-[ B{ CHAR: f CHAR: o CHAR: o } ] [ "foo" latin1 encode ] unit-test
-[ { 256 } >string latin1 encode ] must-fail
-[ B{ 255 } ] [ { 255 } latin1 encode ] unit-test
-
-[ "bar" ] [ "bar" latin1 decode ] unit-test
-[ { CHAR: b 233 CHAR: r } ] [ { CHAR: b 233 CHAR: r } latin1 decode >array ] unit-test
diff --git a/extra/io/encodings/latin1/latin1.factor b/extra/io/encodings/latin1/latin1.factor
deleted file mode 100755 (executable)
index 2b82318..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-! Copyright (C) 2008 Daniel Ehrenberg.
-! See http://factorcode.org/license.txt for BSD license.
-USING: io io.encodings kernel io.encodings.ascii.private ;
-IN: io.encodings.latin1
-
-TUPLE: latin1 ;
-
-M: latin1 encode-char 
-    256 encode-if< ;
-
-M: latin1 decode-char
-    drop stream-read1 ;
diff --git a/extra/io/encodings/latin1/summary.txt b/extra/io/encodings/latin1/summary.txt
deleted file mode 100644 (file)
index d40d628..0000000
+++ /dev/null
@@ -1 +0,0 @@
-ISO 8859-1 encoding/decoding
diff --git a/extra/io/encodings/latin1/tags.txt b/extra/io/encodings/latin1/tags.txt
deleted file mode 100644 (file)
index 8e27be7..0000000
+++ /dev/null
@@ -1 +0,0 @@
-text
diff --git a/extra/io/encodings/strict/authors.txt b/extra/io/encodings/strict/authors.txt
new file mode 100644 (file)
index 0000000..f990dd0
--- /dev/null
@@ -0,0 +1 @@
+Daniel Ehrenberg
diff --git a/extra/io/encodings/strict/strict-docs.factor b/extra/io/encodings/strict/strict-docs.factor
new file mode 100644 (file)
index 0000000..e8a4f18
--- /dev/null
@@ -0,0 +1,10 @@
+! Copyright (C) 2008 Daniel Ehrenberg
+! See http://factorcode.org/license.txt for BSD license.
+USING: help.syntax help.markup ;
+IN: io.encodings.strict
+
+HELP: strict ( encoding -- strict-encoding )
+{ $values { "encoding" "an encoding descriptor" } { "strict-encoding" "a strict encoding descriptor" } }
+{ $description "Makes an encoding strict, that is, in the presence of a malformed code point, an error is thrown. Note that the existence of a replacement character in a file (U+FFFD) also throws an error." } ;
+
+ABOUT: strict
diff --git a/extra/io/encodings/strict/strict-tests.factor b/extra/io/encodings/strict/strict-tests.factor
new file mode 100644 (file)
index 0000000..aebb58c
--- /dev/null
@@ -0,0 +1,6 @@
+USING: io.encodings.strict io.encodings.ascii tools.test
+arrays io.encodings.string ;
+IN: io.encodings.strict.test
+
+[ { HEX: fffd } ] [ { 128 } ascii decode >array ] unit-test
+[ { 128 } ascii strict decode ] must-fail
diff --git a/extra/io/encodings/strict/strict.factor b/extra/io/encodings/strict/strict.factor
new file mode 100644 (file)
index 0000000..89c10d8
--- /dev/null
@@ -0,0 +1,18 @@
+! Copyright (C) 2008 Daniel Ehrenberg
+! See http://factorcode.org/license.txt for BSD license.
+USING: io.encodings kernel accessors inspector ;
+IN: io.encodings.strict
+
+TUPLE: strict code ;
+C: strict strict
+
+TUPLE: decode-error ;
+: decode-error ( -- * ) \ decode-error construct-empty throw ;
+M: decode-error summary
+    drop "Error in decoding input stream" ;
+
+M: strict <decoder>
+    code>> <decoder> [ strict ] change-code ;
+
+M: strict decode-char
+    code>> decode-char dup replacement-char = [ decode-error ] when ;
diff --git a/extra/io/encodings/strict/summary.txt b/extra/io/encodings/strict/summary.txt
new file mode 100644 (file)
index 0000000..9fd0fe3
--- /dev/null
@@ -0,0 +1 @@
+Strict wrapper for encodings
diff --git a/extra/io/encodings/strict/tags.txt b/extra/io/encodings/strict/tags.txt
new file mode 100644 (file)
index 0000000..8e27be7
--- /dev/null
@@ -0,0 +1 @@
+text
index 018a15a534df0e5f7d0c81c6a68e9a472f727b07..bc0e9434156872e5691de1666ab5ac74bf424048 100644 (file)
@@ -1,22 +1,29 @@
 USING: help.markup help.syntax io.encodings strings ;
 IN: io.encodings.utf16
 
-ARTICLE: "utf16" "Working with UTF-16-encoded data"
+ARTICLE: "io.encodings.utf16" "UTF-16"
 "The UTF-16 encoding is a variable-width encoding. Unicode code points are encoded as 2 or 4 byte sequences. There are three encoding descriptor classes for working with UTF-16, depending on endianness or the presence of a BOM:"
+{ $subsection utf16 }
 { $subsection utf16le }
 { $subsection utf16be }
-{ $subsection utf16 }
-"All of these conform to the " { $link "encodings-protocol" } "." ;
+{ $subsection utf16n } ;
 
-ABOUT: "utf16"
+ABOUT: "io.encodings.utf16"
 
 HELP: utf16le
-{ $class-description "The encoding protocol for UTF-16LE, that is, UTF-16 in little endian, without a byte order mark. Streams can be made which read or write wth this encoding." } ;
+{ $class-description "The encoding descriptor for UTF-16LE, that is, UTF-16 in little endian, without a byte order mark. Streams can be made which read or write wth this encoding." }
+{ $see-also "encodings-introduction" } ;
 
 HELP: utf16be
-{ $class-description "The encoding protocol for UTF-16BE, that is, UTF-16 in big endian, without a byte order mark. Streams can be made which read or write wth this encoding." } ;
+{ $class-description "The encoding descriptor for UTF-16BE, that is, UTF-16 in big endian, without a byte order mark. Streams can be made which read or write wth this encoding." }
+{ $see-also "encodings-introduction" } ;
 
 HELP: utf16
-{ $class-description "The encoding protocol for UTF-16, that is, UTF-16 with a byte order mark. This is the most useful for general input and output in UTF-16. Streams can be made which read or write wth this encoding." } ;
+{ $class-description "The encoding descriptor for UTF-16, that is, UTF-16 with a byte order mark. This is the most useful for general input and output in UTF-16. Streams can be made which read or write wth this encoding." }
+{ $see-also "encodings-introduction" } ;
+
+HELP: utf16n
+{ $class-description "The encoding descriptor for UTF-16 without a byte order mark in native endian order. This is useful mostly for FFI calls which take input of strings in of wide_t*." }
+{ $see-also "encodings-introduction" } ;
 
-{ utf16 utf16le utf16be } related-words
+{ utf16 utf16le utf16be utf16n } related-words
index 89b61a3e3719b5ccb54edc43f2e41f79fa01dd58..698598391744df7d21c015779f324d419251f402 100755 (executable)
@@ -1,5 +1,7 @@
 USING: kernel tools.test io.encodings.utf16 arrays sbufs
-sequences io.encodings io unicode io.encodings.string ;
+io.streams.byte-array sequences io.encodings io unicode
+io.encodings.string alien.c-types accessors classes ;
+IN: io.encodings.utf16.tests
 
 [ { CHAR: x } ] [ { 0 CHAR: x } utf16be decode >array ] unit-test
 [ { HEX: 1D11E } ] [ { HEX: D8 HEX: 34 HEX: DD HEX: 1E } utf16be decode >array ] unit-test
@@ -20,3 +22,9 @@ sequences io.encodings io unicode io.encodings.string ;
 [ { CHAR: x } ] [ { HEX: fe HEX: ff 0 CHAR: x } utf16 decode >array ] unit-test
 
 [ { HEX: ff HEX: fe 120 0 52 216 30 221 } ] [ { CHAR: x HEX: 1d11e } utf16 encode >array ] unit-test
+
+: correct-endian
+    code>> class little-endian? [ utf16le = ] [ utf16be = ] if ;
+
+[ t ] [ B{ } utf16n <byte-reader> correct-endian ] unit-test
+[ t ] [ utf16n <byte-writer> correct-endian ] unit-test
index 290761ec91e7985752708bf841d52f34db0cd82e..fbc296e57cb2f6b891278462d78a39c1022b570e 100755 (executable)
@@ -1,7 +1,8 @@
 ! Copyright (C) 2006, 2008 Daniel Ehrenberg.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: math kernel sequences sbufs vectors namespaces io.binary
-io.encodings combinators splitting io byte-arrays inspector ;
+io.encodings combinators splitting io byte-arrays inspector
+alien.c-types ;
 IN: io.encodings.utf16
 
 TUPLE: utf16be ;
@@ -10,6 +11,8 @@ TUPLE: utf16le ;
 
 TUPLE: utf16 ;
 
+TUPLE: utf16n ;
+
 <PRIVATE
 
 ! UTF-16BE decoding
@@ -75,7 +78,7 @@ M: utf16le decode-char
     swap BIN: 11111111 bitand ;
 
 : stream-write2 ( stream char1 char2 -- )
-    rot [ stream-write1 ] curry 2apply ;
+    rot [ stream-write1 ] curry bi@ ;
 
 : char>utf16be ( stream char -- )
     dup HEX: FFFF > [
@@ -121,4 +124,13 @@ M: utf16 <decoder> ( stream utf16 -- decoder )
 M: utf16 <encoder> ( stream utf16 -- encoder )
     drop bom-le over stream-write utf16le <encoder> ;
 
+! Native-order UTF-16
+
+: native-utf16 ( -- descriptor )
+    little-endian? utf16le utf16be ? ;
+
+M: utf16n <decoder> drop native-utf16 <decoder> ;
+
+M: utf16n <encoder> drop native-utf16 <encoder> ;
+
 PRIVATE>
index 7fdd22c8a5e037475f946b59203aea05a1125cd3..0f6ca3a2c91f171cee5338ca5ffabb30043a39ba 100755 (executable)
@@ -33,6 +33,17 @@ $nl
     { "a file stream or a socket - the stream is connected to the given Factor stream, which cannot be used again from within Factor and must be closed after the process has been started" }
 } ;
 
+ARTICLE: "io.launcher.priority" "Setting process priority"
+"The priority of the child process can be set by storing one of the below symbols in the " { $snippet "priority" } " slot of a " { $link process } " tuple:"
+{ $list
+    { $link +lowest-priority+ }
+    { $link +low-priority+ }
+    { $link +normal-priority+ }
+    { $link +high-priority+ }
+    { $link +highest-priority+ }
+}
+"The default value is " { $link f } ", which denotes that the child process should inherit the current process priority." ;
+
 HELP: +closed+
 { $description "Possible value for the " { $snippet "stdin" } ", " { $snippet "stdout" } ", and " { $snippet "stderr" } " slots of a " { $link process } "." } ;
 
@@ -216,6 +227,7 @@ ARTICLE: "io.launcher" "Operating system processes"
 { $subsection "io.launcher.detached" }
 { $subsection "io.launcher.environment" }
 { $subsection "io.launcher.redirection" }
+{ $subsection "io.launcher.priority" }
 { $subsection "io.launcher.timeouts" } ;
 
 ABOUT: "io.launcher"
index 9c7d64934e947d50032b4bc2b0b54741f23bbe30..79382091ab6304444dfdd075bdcb76f34b3a4067 100755 (executable)
@@ -6,7 +6,6 @@ init threads continuations math io.encodings io.streams.duplex
 io.nonblocking accessors ;
 IN: io.launcher
 
-
 TUPLE: process
 
 command
@@ -19,6 +18,8 @@ stdin
 stdout
 stderr
 
+priority
+
 timeout
 
 handle status
@@ -32,6 +33,13 @@ SYMBOL: +prepend-environment+
 SYMBOL: +replace-environment+
 SYMBOL: +append-environment+
 
+SYMBOL: +lowest-priority+
+SYMBOL: +low-priority+
+SYMBOL: +normal-priority+
+SYMBOL: +high-priority+
+SYMBOL: +highest-priority+
+SYMBOL: +realtime-priority+
+
 : <process> ( -- process )
     process construct-empty
     H{ } clone >>environment
index ae69553b536b76ad8d408a80b9596ede4bd191c7..ee9978f2c89a7bc8a106c79a30acd8eb028bdb8a 100755 (executable)
@@ -92,14 +92,6 @@ HELP: unless-eof
 { $values { "port" input-port } { "quot" "a quotation with stack effect " { $snippet "( port -- value )" } } { "value" object } }
 { $description "If the port has reached end of file, outputs " { $link f } ", otherwise applies the quotation to the port." } ;
 
-HELP: read-until-step
-{ $values { "separators" "a sequence of bytes" } { "port" input-port } { "byte-array/f" "a byte array or " { $link f } } { "separator/f" "a byte or " { $link f } } }
-{ $description "If the port has reached end of file, outputs " { $link f } { $link f } ", otherwise scans the buffer for a separator and outputs a string up to but not including the separator." } ;
-
-HELP: read-until-loop
-{ $values { "seps" "a sequence of bytes" } { "port" input-port } { "accum" byte-vector } { "separator/f" "a byte or " { $link f } } }
-{ $description "Accumulates data in the byte vector, calling " { $link (wait-to-read) } " as many times as necessary, until either an occurrence of a separator is read, or end of file is reached." } ;
-
 HELP: can-write?
 { $values { "len" "a positive integer" } { "writer" output-port } { "?" "a boolean" } }
 { $description "Tests if the port's output buffer can accomodate " { $snippet "len" } " bytes. If the buffer is empty, this always outputs " { $link t } ", since in that case the buffer will be grown automatically." } ;
index 8f5babeff76168d194af2300284ad99bd3906f91..85319ad8ef155726dec78c1fccc453e21341975e 100755 (executable)
@@ -22,8 +22,8 @@ M: port set-timeout set-port-timeout ;
 
 SYMBOL: closed
 
-PREDICATE: port input-port port-type input-port eq? ;
-PREDICATE: port output-port port-type output-port eq? ;
+PREDICATE: input-port < port port-type input-port eq? ;
+PREDICATE: output-port < port port-type output-port eq? ;
 
 GENERIC: init-handle ( handle -- )
 GENERIC: close-handle ( handle -- )
@@ -73,7 +73,7 @@ M: input-port stream-read1
 
 : read-step ( count port -- byte-array/f )
     [ wait-to-read ] 2keep
-    [ dupd buffer> ] unless-eof nip ;
+    [ dupd buffer-read ] unless-eof nip ;
 
 : read-loop ( count port accum -- )
     pick over length - dup 0 > [
@@ -101,38 +101,6 @@ M: input-port stream-read
         2nip
     ] if ;
 
-: read-until-step ( separators port -- byte-array/f separator/f )
-    dup wait-to-read1
-    dup port-eof? [
-        f swap set-port-eof? drop f f
-    ] [
-        buffer-until
-    ] if ;
-
-: read-until-loop ( seps port accum -- separator/f )
-    2over read-until-step over [
-        >r over push-all r> dup [
-            >r 3drop r>
-        ] [
-            drop read-until-loop
-        ] if
-    ] [
-        >r 2drop 2drop r>
-    ] if ;
-
-M: input-port stream-read-until ( seps port -- byte-array/f sep/f )
-    2dup read-until-step dup [
-        >r 2nip r>
-    ] [
-        over [
-            drop BV{ } like
-            [ read-until-loop ] keep
-            B{ } like swap
-        ] [
-            >r 2nip r>
-        ] if
-    ] if ;
-
 M: input-port stream-read-partial ( max stream -- byte-array/f )
     >r 0 max >fixnum r> read-step ;
 
@@ -193,5 +161,5 @@ TUPLE: datagram-port addr packet packet-addr ;
 
 : check-datagram-send ( packet addrspec port -- )
     dup check-datagram-port
-    datagram-port-addr [ class ] 2apply assert=
+    datagram-port-addr [ class ] bi@ assert=
     class byte-array assert= ;
index 6c73669e9fda5fbf9723a5fb03e39c71cbfc0ac7..dad1087022b30afbde42554c668119223953eb90 100755 (executable)
@@ -44,7 +44,7 @@ TUPLE: directory-iterator path bfs queue ;
 
 : find-all-files ( path bfs? quot -- paths )
     >r <directory-iterator> r>
-    pusher >r iterate-directory drop r> ; inline
+    pusher >r [ f ] compose iterate-directory drop r> ; inline
 
 : recursive-directory ( path bfs? -- paths )
     [ ] accumulator >r each-file r> ;
diff --git a/extra/io/priority/priority.factor b/extra/io/priority/priority.factor
deleted file mode 100644 (file)
index 0790563..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-USING: io.backend kernel ;
-IN: io.priority
-
-HOOK: get-priority io-backend ( -- n )
-HOOK: set-priority io-backend ( n -- )
index 77e8e098b1d4e96c499654200f8a9d94181626c3..8480fcd85642baac9e7e734f178a92c715a20419 100755 (executable)
@@ -64,8 +64,8 @@ M: inet6 inet-ntop ( data addrspec -- str )
 
 M: inet6 inet-pton ( str addrspec -- data )
     drop "::" split1
-    [ [ ":" split [ hex> dup 0 ? ] map ] [ f ] if* ] 2apply
-    2dup [ length ] 2apply + 8 swap - 0 <array> swap 3append
+    [ [ ":" split [ hex> dup 0 ? ] map ] [ f ] if* ] bi@
+    2dup [ length ] bi@ + 8 swap - 0 <array> swap 3append
     [ 2 >be ] map concat >byte-array ;
 
 M: inet6 address-size drop 16 ;
index c9bd331bcd489fc88ccd22ac8b992503f8142b3c..63d2adbdf70aa2d7a03e7d7fa92c7a677fdc038e 100755 (executable)
@@ -4,7 +4,7 @@ USING: alien generic assocs kernel kernel.private math
 io.nonblocking sequences strings structs sbufs
 threads unix vectors io.buffers io.backend io.encodings
 io.streams.duplex math.parser continuations system libc
-qualified namespaces io.timeouts io.encodings.utf8 ;
+qualified namespaces io.timeouts io.encodings.utf8 accessors ;
 QUALIFIED: io
 IN: io.unix.backend
 
@@ -13,7 +13,7 @@ MIXIN: unix-io
 ! I/O tasks
 TUPLE: io-task port callbacks ;
 
-: io-task-fd io-task-port port-handle ;
+: io-task-fd port>> handle>> ;
 
 : <io-task> ( port continuation/f class -- task )
     >r [ 1vector ] [ V{ } clone ] if* io-task construct-boa
@@ -35,9 +35,9 @@ GENERIC: io-task-container ( mx task -- hashtable )
 ! I/O multiplexers
 TUPLE: mx fd reads writes ;
 
-M: input-task io-task-container drop mx-reads ;
+M: input-task io-task-container drop reads>> ;
 
-M: output-task io-task-container drop mx-writes ;
+M: output-task io-task-container drop writes>> ;
 
 : <mx> ( -- mx ) f H{ } clone H{ } clone mx construct-boa ;
 
@@ -90,11 +90,11 @@ M: integer close-handle ( fd -- )
     close ;
 
 : report-error ( error port -- )
-    [ "Error on fd " % dup port-handle # ": " % swap % ] "" make
-    swap set-port-error ;
+    [ "Error on fd " % dup handle>> # ": " % swap % ] "" make
+    >>error drop ;
 
 : ignorable-error? ( n -- ? )
-    dup EAGAIN number= swap EINTR number= or ;
+    [ EAGAIN number= ] [ EINTR number= ] bi or ;
 
 : defer-error ( port -- ? )
     #! Return t if it is an unrecoverable error.
@@ -110,26 +110,25 @@ M: integer close-handle ( fd -- )
 
 : handle-timeout ( port mx assoc -- )
     >r swap port-handle r> delete-at* [
-        "I/O operation cancelled" over io-task-port report-error
+        "I/O operation cancelled" over port>> report-error
         pop-callbacks
     ] [
         2drop
     ] if ;
 
 : cancel-io-tasks ( port mx -- )
-    2dup
-    dup mx-reads handle-timeout
-    dup mx-writes handle-timeout ;
+    [ dup reads>> handle-timeout ]
+    [ dup writes>> handle-timeout ] 2bi ;
 
 M: unix-io cancel-io ( port -- )
     mx get-global cancel-io-tasks ;
 
 ! Readers
 : reader-eof ( reader -- )
-    dup buffer-empty? [ t over set-port-eof? ] when drop ;
+    dup buffer-empty? [ t >>eof? ] when drop ;
 
 : (refill) ( port -- n )
-    dup port-handle over buffer-end rot buffer-capacity read ;
+    [ handle>> ] [ buffer-end ] [ buffer-capacity ] tri read ;
 
 : refill ( port -- ? )
     #! Return f if there is a recoverable error
@@ -158,7 +157,7 @@ M: input-port (wait-to-read)
 
 ! Writers
 : write-step ( port -- ? )
-    dup port-handle over buffer@ pick buffer-length write
+    dup [ handle>> ] [ buffer@ ] [ buffer-length ] tri write
     dup 0 >= [ swap buffer-consume f ] [ drop defer-error ] if ;
 
 TUPLE: write-task ;
@@ -167,7 +166,7 @@ TUPLE: write-task ;
     write-task <output-task> ;
 
 M: write-task do-io-task
-    io-task-port dup buffer-empty? over port-error or
+    io-task-port dup [ buffer-empty? ] [ port-error ] bi or
     [ 0 swap buffer-reset t ] [ write-step ] if ;
 
 : add-write-io-task ( port continuation -- )
@@ -193,7 +192,7 @@ M: unix-io (init-stdio) ( -- )
 TUPLE: mx-port mx ;
 
 : <mx-port> ( mx -- port )
-    dup mx-fd f mx-port <port>
+    dup fd>> f mx-port <port>
     { set-mx-port-mx set-delegate } mx-port construct ;
 
 TUPLE: mx-task ;
@@ -202,7 +201,7 @@ TUPLE: mx-task ;
     f mx-task <io-task> ;
 
 M: mx-task do-io-task
-    io-task-port mx-port-mx 0 swap wait-for-events f ;
+    port>> mx>> 0 swap wait-for-events f ;
 
 : multiplexer-error ( n -- )
     0 < [ err_no ignorable-error? [ (io-error) ] unless ] when ;
index f5366d32ae287f926f8db6680f6639460ee45739..bb2039adfb4f004a986667c6182b568a79bc4c2b 100755 (executable)
@@ -6,3 +6,18 @@ IN: io.unix.files.tests
 [ "/" ] [ "/etc/" parent-directory ] unit-test
 [ "/" ] [ "/etc" parent-directory ] unit-test
 [ "/" ] [ "/" parent-directory ] unit-test
+
+[ f ] [ "" root-directory? ] unit-test
+[ t ] [ "/" root-directory? ] unit-test
+[ t ] [ "//" root-directory? ] unit-test
+[ t ] [ "///////" root-directory? ] unit-test
+
+[ "/" ] [ "/" file-name ] unit-test
+[ "///" ] [ "///" file-name ] unit-test
+
+[ "/" ] [ "/" "../.." append-path ] unit-test
+[ "/" ] [ "/" "../../" append-path ] unit-test
+[ "/lib" ] [ "/" "../lib" append-path ] unit-test
+[ "/lib/" ] [ "/" "../lib/" append-path ] unit-test
+[ "/lib" ] [ "/" "../../lib" append-path ] unit-test
+[ "/lib/" ] [ "/" "../../lib/" append-path ] unit-test
index 1e7d6823140c9e14fad5f8f0a30eaeef58b0d323..b0b0ba456a5ecd6f200def41a547a0639afeb693 100755 (executable)
@@ -2,16 +2,16 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: io.backend io.nonblocking io.unix.backend io.files io
 unix unix.stat unix.time kernel math continuations
-math.bitfields byte-arrays alien combinators combinators.cleave
-calendar io.encodings.binary ;
+math.bitfields byte-arrays alien combinators calendar
+io.encodings.binary ;
 
 IN: io.unix.files
 
-M: unix-io cwd
+M: unix-io cwd ( -- path )
     MAXPATHLEN [ <byte-array> ] [ ] bi getcwd
     [ (io-error) ] unless* ;
 
-M: unix-io cd
+M: unix-io cd ( path -- )
     chdir io-error ;
 
 : read-flags O_RDONLY ; inline
@@ -39,25 +39,26 @@ M: unix-io (file-writer) ( path -- stream )
 M: unix-io (file-appender) ( path -- stream )
     open-append <writer> ;
 
-: touch-mode
+: touch-mode ( -- n )
     { O_WRONLY O_APPEND O_CREAT O_EXCL } flags ; foldable
 
 M: unix-io touch-file ( path -- )
+    normalize-pathname
     touch-mode file-mode open
     dup 0 < [ err_no EEXIST = [ err_no io-error ] unless ] when
     close ;
 
 M: unix-io move-file ( from to -- )
-    rename io-error ;
+    [ normalize-pathname ] bi@ rename io-error ;
 
 M: unix-io delete-file ( path -- )
-    unlink io-error ;
+    normalize-pathname unlink io-error ;
 
 M: unix-io make-directory ( path -- )
-    OCT: 777 mkdir io-error ;
+    normalize-pathname OCT: 777 mkdir io-error ;
 
 M: unix-io delete-directory ( path -- )
-    rmdir io-error ;
+    normalize-pathname rmdir io-error ;
 
 : (copy-file) ( from to -- )
     dup parent-directory make-directories
@@ -68,8 +69,9 @@ M: unix-io delete-directory ( path -- )
     ] with-disposal ;
 
 M: unix-io copy-file ( from to -- )
+    [ normalize-pathname ] bi@
     [ (copy-file) ]
-    [ swap file-info file-info-permissions chmod  io-error ]
+    [ swap file-info file-info-permissions chmod io-error ]
     2bi ;
 
 : stat>type ( stat -- type )
@@ -94,7 +96,7 @@ M: unix-io copy-file ( from to -- )
     \ file-info construct-boa ;
 
 M: unix-io file-info ( path -- info )
-    stat* stat>file-info ;
+    normalize-pathname stat* stat>file-info ;
 
 M: unix-io link-info ( path -- info )
-    lstat* stat>file-info ;
+    normalize-pathname lstat* stat>file-info ;
index 9e19245d010d364c7446083d6fe2e6563f52a61f..7e527196be012b579b8ab2fb9ecee12a2afe5fc3 100755 (executable)
@@ -1,7 +1,7 @@
 IN: io.unix.launcher.tests
 USING: io.files tools.test io.launcher arrays io namespaces
 continuations math io.encodings.binary io.encodings.ascii
-accessors kernel sequences ;
+accessors kernel sequences io.encodings.utf8 ;
 
 [ ] [
     [ "launcher-test-1" temp-file delete-file ] ignore-errors
@@ -95,3 +95,15 @@ accessors kernel sequences ;
         +replace-environment+ >>environment-mode
     ascii <process-stream> lines
 ] unit-test
+
+[ "hi\n" ] [
+    temp-directory [
+        [ "aloha" delete-file ] ignore-errors
+        <process>
+            { "echo" "hi" } >>command
+            "aloha" >>stdout
+        try-process
+    ] with-directory
+    temp-directory "aloha" append-path
+    utf8 file-contents
+] unit-test
index a1e42fddf225ab818618cb59fa16a505daebf0d4..f738bd42c22a4c7f15e42d0daa0717993fc8d2d9 100755 (executable)
@@ -4,7 +4,7 @@ USING: io io.backend io.launcher io.nonblocking io.unix.backend
 io.unix.files io.nonblocking sequences kernel namespaces math
 system alien.c-types debugger continuations arrays assocs
 combinators unix.process strings threads unix
-io.unix.launcher.parser io.encodings.latin1 accessors ;
+io.unix.launcher.parser accessors io.files ;
 IN: io.unix.launcher
 
 ! Search unix first
@@ -16,6 +16,18 @@ USE: unix
 : assoc>env ( assoc -- env )
     [ "=" swap 3append ] { } assoc>map ;
 
+: setup-priority ( process -- process )
+    dup priority>> [
+        H{
+            { +lowest-priority+ 20 }
+            { +low-priority+ 10 }
+            { +normal-priority+ 0 }
+            { +high-priority+ -10 }
+            { +highest-priority+ -20 }
+            { +realtime-priority+ -20 }
+        } at set-priority
+    ] when* ;
+
 : redirect-fd ( oldfd fd -- )
     2dup = [ 2drop ] [ dupd dup2 io-error close ] if ;
 
@@ -25,7 +37,8 @@ USE: unix
     2nip reset-fd ;
 
 : redirect-file ( obj mode fd -- )
-    >r file-mode open dup io-error r> redirect-fd ;
+    >r >r normalize-pathname r> file-mode
+    open dup io-error r> redirect-fd ;
 
 : redirect-closed ( obj mode fd -- )
     >r >r drop "/dev/null" r> r> redirect-file ;
@@ -47,12 +60,17 @@ USE: unix
 : setup-redirection ( process -- process )
     dup stdin>> ?closed read-flags 0 redirect
     dup stdout>> ?closed write-flags 1 redirect
-    dup stderr>> dup +stdout+ eq?
-    [ drop 1 2 dup2 io-error ] [ ?closed write-flags 2 redirect ] if ;
+    dup stderr>> dup +stdout+ eq? [
+        drop 1 2 dup2 io-error
+    ] [
+        ?closed write-flags 2 redirect
+    ] if ;
 
 : spawn-process ( process -- * )
     [
+        setup-priority
         setup-redirection
+        current-directory get resource-path cd
         dup pass-environment? [
             dup get-environment set-os-envs
         ] when
diff --git a/extra/io/unix/priority/priority.factor b/extra/io/unix/priority/priority.factor
deleted file mode 100644 (file)
index deb801e..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-USING: alien.syntax kernel io.priority io.unix.backend
-unix ;
-IN: io.unix.priority
-
-: PRIO_PROCESS 0 ; inline
-: PRIO_PGRP 1 ; inline
-: PRIO_USER 2 ; inline
-
-: PRIO_MIN -20 ; inline
-: PRIO_MAX 20 ; inline
-
-! which/who = 0 for current process
-FUNCTION: int getpriority ( int which, int who ) ;
-FUNCTION: int setpriority ( int which, int who, int prio ) ;
-
-M: unix-io get-priority ( -- n )
-    clear_err_no
-    0 0 getpriority dup -1 = [ check-errno ] when ;
-
-M: unix-io set-priority ( n -- )
-    0 0 rot setpriority io-error ;
index 77a20beb42ca7e34ddfd852d752a98ef8ab6cc5a..aceee0f31114e48e21bbbac4d9a8a0ffe9d12bf2 100755 (executable)
@@ -1,7 +1,8 @@
 ! Copyright (C) 2004, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: alien.c-types kernel io.nonblocking io.unix.backend
-bit-arrays sequences assocs unix math namespaces structs ;
+bit-arrays sequences assocs unix math namespaces structs
+accessors ;
 IN: io.unix.select
 
 TUPLE: select-mx read-fdset write-fdset ;
@@ -14,11 +15,11 @@ TUPLE: select-mx read-fdset write-fdset ;
 
 : <select-mx> ( -- mx )
     select-mx construct-mx
-    FD_SETSIZE 8 * <bit-array> over set-select-mx-read-fdset
-    FD_SETSIZE 8 * <bit-array> over set-select-mx-write-fdset ;
+    FD_SETSIZE 8 * <bit-array> >>read-fdset
+    FD_SETSIZE 8 * <bit-array> >>write-fdset ;
 
 : clear-nth ( n seq -- ? )
-    [ nth ] 2keep f -rot set-nth ;
+    [ nth ] [ f -rot set-nth ] 2bi ;
 
 : handle-fd ( fd task fdset mx -- )
     roll munge rot clear-nth
@@ -32,15 +33,16 @@ TUPLE: select-mx read-fdset write-fdset ;
     [ >r drop t swap munge r> set-nth ] curry assoc-each ;
 
 : read-fdset/tasks
-    { mx-reads select-mx-read-fdset } get-slots ;
+    [ reads>> ] [ read-fdset>> ] bi ;
 
 : write-fdset/tasks
-    { mx-writes select-mx-write-fdset } get-slots ;
+    [ writes>> ] [ write-fdset>> ] bi ;
 
-: max-fd dup assoc-empty? [ drop 0 ] [ keys supremum ] if ;
+: max-fd ( assoc -- n )
+    dup assoc-empty? [ drop 0 ] [ keys supremum ] if ;
 
 : num-fds ( mx -- n )
-    dup mx-reads max-fd swap mx-writes max-fd max 1+ ;
+    [ reads>> max-fd ] [ writes>> max-fd ] bi max 1+ ;
 
 : init-fdsets ( mx -- nfds read write except )
     [ num-fds ] keep
index bd58761a5b9e08078ba285f550733e293cd2cb99..0a7fc72662cc7ee9580595bf655d8ed4acfd3398 100755 (executable)
@@ -1,5 +1,5 @@
 USING: io.unix.backend io.unix.files io.unix.sockets io.timeouts
-io.unix.launcher io.unix.mmap io.backend io.unix.priority
-combinators namespaces system vocabs.loader sequences ;
+io.unix.launcher io.unix.mmap io.backend combinators namespaces
+system vocabs.loader sequences ;
 
 "io.unix." os append require
index f51521dfcc273964b162ad2207bad51e312b9362..152e76a6c7d31530f1aa32c1356e897a3fb6c64e 100755 (executable)
@@ -46,5 +46,5 @@ M: windows-ce-io (init-stdio) ( -- )
             1 _getstdfilex _fileno
             2 _getstdfilex _fileno
         ] if [ f <win32-file> ] 3apply
-        rot <reader> -rot [ <writer> ] 2apply
+        rot <reader> -rot [ <writer> ] bi@
     ] with-variable ;
index 35aaf456a39b6bbe87e37c1403fcbc2d1948332a..295b3ab00651e458df1e077b73ab608c4977356a 100755 (executable)
@@ -1,9 +1,9 @@
 ! Copyright (C) 2008 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: alien.c-types io.files io.windows kernel
-math windows windows.kernel32 combinators.cleave
-windows.time calendar combinators math.functions
-sequences namespaces words symbols ;
+USING: alien.c-types io.backend io.files io.windows kernel math
+windows windows.kernel32 windows.time calendar combinators
+math.functions sequences namespaces words symbols
+combinators.lib io.nonblocking destructors ;
 IN: io.windows.files
 
 SYMBOLS: +read-only+ +hidden+ +system+
@@ -89,5 +89,45 @@ SYMBOLS: +read-only+ +hidden+ +system+
     ] if ;
 
 M: windows-nt-io file-info ( path -- info )
-    get-file-information-stat ;
+    normalize-pathname get-file-information-stat ;
 
+M: windows-nt-io link-info ( path -- info )
+    file-info ;
+
+: file-times ( path -- timestamp timestamp timestamp )
+    [
+        normalize-pathname open-existing dup close-always
+        "FILETIME" <c-object>
+        "FILETIME" <c-object>
+        "FILETIME" <c-object>
+        [ GetFileTime win32-error=0/f ] 3keep
+        [ FILETIME>timestamp >local-time ] 3apply
+    ] with-destructors ;
+
+: (set-file-times) ( handle timestamp/f timestamp/f timestamp/f -- )
+    [ timestamp>FILETIME ] 3apply
+    SetFileTime win32-error=0/f ;
+
+: set-file-times ( path timestamp/f timestamp/f timestamp/f -- )
+    #! timestamp order: creation access write
+    [
+        >r >r >r
+            normalize-pathname open-existing dup close-always
+        r> r> r> (set-file-times)
+    ] with-destructors ;
+
+: set-file-create-time ( path timestamp -- )
+    f f set-file-times ;
+
+: set-file-access-time ( path timestamp -- )
+    >r f r> f set-file-times ;
+
+: set-file-write-time ( path timestamp -- )
+    >r f f r> set-file-times ;
+
+M: windows-nt-io touch-file ( path -- )
+    [
+        normalize-pathname
+        maybe-create-file over close-always
+        [ drop ] [ f now dup (set-file-times) ] if
+    ] with-destructors ;
index ca8f5f3e59ad25c81cef586162cc1afef66b2409..31247e43c38e493fc4d8568f821a53e4ff5f3e9f 100755 (executable)
@@ -5,7 +5,7 @@ io.windows io.windows.nt.pipes libc io.nonblocking
 io.streams.duplex windows.types math windows.kernel32 windows
 namespaces io.launcher kernel sequences windows.errors assocs
 splitting system threads init strings combinators
-io.backend accessors concurrency.flags ;
+io.backend accessors concurrency.flags io.files ;
 IN: io.windows.launcher
 
 TUPLE: CreateProcess-args
@@ -23,11 +23,12 @@ TUPLE: CreateProcess-args
 
 : default-CreateProcess-args ( -- obj )
     CreateProcess-args construct-empty
-    0 >>dwCreateFlags
     "STARTUPINFO" <c-object>
     "STARTUPINFO" heap-size over set-STARTUPINFO-cb >>lpStartupInfo
     "PROCESS_INFORMATION" <c-object> >>lpProcessInformation
-    TRUE >>bInheritHandles ;
+    TRUE >>bInheritHandles
+    0 >>dwCreateFlags
+    current-directory get normalize-pathname >>lpCurrentDirectory ;
 
 : call-CreateProcess ( CreateProcess-args -- )
     {
@@ -49,6 +50,17 @@ TUPLE: CreateProcess-args
 : join-arguments ( args -- cmd-line )
     [ escape-argument ] map " " join ;
 
+: lookup-priority ( process -- n )
+    priority>> {
+        { +lowest-priority+ [ IDLE_PRIORITY_CLASS ] }
+        { +low-priority+ [ BELOW_NORMAL_PRIORITY_CLASS ] }
+        { +normal-priority+ [ NORMAL_PRIORITY_CLASS ] }
+        { +high-priority+ [ ABOVE_NORMAL_PRIORITY_CLASS ] }
+        { +highest-priority+ [ HIGH_PRIORITY_CLASS ] }
+        { +realtime-priority+ [ REALTIME_PRIORITY_CLASS ] }
+        [ drop f ]
+    } case ;
+
 : app-name/cmd-line ( process -- app-name cmd-line )
     command>> dup string? [
         " " split1
@@ -71,6 +83,7 @@ TUPLE: CreateProcess-args
     0
     pick pass-environment? [ CREATE_UNICODE_ENVIRONMENT bitor ] when
     pick detached>> winnt? and [ DETACHED_PROCESS bitor ] when
+    pick lookup-priority [ bitor ] when*
     >>dwCreateFlags ;
 
 : fill-lpEnvironment ( process args -- process args )
index 10e55ed5f2ba77a8965c713d494f802c5717b2da..dcd13895b2b1831c0519250f869c05f1d69d3fd8 100755 (executable)
@@ -1,7 +1,7 @@
 USING: alien alien.c-types arrays assocs combinators
 continuations destructors io io.backend io.nonblocking
 io.windows libc kernel math namespaces sequences
-threads tuples.lib windows windows.errors
+threads classes.tuple.lib windows windows.errors
 windows.kernel32 strings splitting io.files qualified ascii
 combinators.lib ;
 QUALIFIED: windows.winsock
diff --git a/extra/io/windows/nt/files/files-tests.factor b/extra/io/windows/nt/files/files-tests.factor
new file mode 100644 (file)
index 0000000..73d6a0b
--- /dev/null
@@ -0,0 +1,47 @@
+USING: io.files kernel tools.test io.backend
+io.windows.nt.files splitting ;
+IN: io.windows.nt.files.tests
+
+[ t ] [ "\\foo" absolute-path? ] unit-test
+[ t ] [ "\\\\?\\foo" absolute-path? ] unit-test
+[ t ] [ "c:\\foo" absolute-path? ] unit-test
+[ t ] [ "c:" absolute-path? ] unit-test
+
+[ "c:\\foo\\" ] [ "c:\\foo\\bar" parent-directory ] unit-test
+[ "c:\\" ] [ "c:\\foo\\" parent-directory ] unit-test
+[ "c:\\" ] [ "c:\\foo" parent-directory ] unit-test
+! { "c:" "c:\\" "c:/" } [ directory ] each -- all do the same thing
+[ "c:\\" ] [ "c:\\" parent-directory ] unit-test
+[ "Z:\\" ] [ "Z:\\" parent-directory ] unit-test
+[ "c:" ] [ "c:" parent-directory ] unit-test
+[ "Z:" ] [ "Z:" parent-directory ] unit-test
+
+[ f ] [ "" root-directory? ] unit-test
+[ t ] [ "\\" root-directory? ] unit-test
+[ t ] [ "\\\\" root-directory? ] unit-test
+[ t ] [ "/" root-directory? ] unit-test
+[ t ] [ "//" root-directory? ] unit-test
+[ t ] [ "c:\\" right-trim-separators root-directory? ] unit-test
+[ t ] [ "Z:\\" right-trim-separators root-directory? ] unit-test
+[ f ] [ "c:\\foo" root-directory? ] unit-test
+[ f ] [ "." root-directory? ] unit-test
+[ f ] [ ".." root-directory? ] unit-test
+
+[ ] [ "" resource-path cd ] unit-test
+
+[ "\\foo\\bar" ] [ "/foo/bar" normalize-pathname ":" split1 nip ] unit-test
+
+[ "\\\\?\\C:\\builds\\factor\\log.txt" ] [
+    "C:\\builds\\factor\\12345\\"
+    "..\\log.txt" append-path normalize-pathname
+] unit-test
+
+[ "\\\\?\\C:\\builds\\" ] [
+    "C:\\builds\\factor\\12345\\"
+    "..\\.." append-path normalize-pathname
+] unit-test
+
+[ "\\\\?\\C:\\builds\\" ] [
+    "C:\\builds\\factor\\12345\\"
+    "..\\.." append-path normalize-pathname
+] unit-test
index 7cf056674f7f45133173e4eb6d995bbd6b8197b4..81112a89c0c132180212e65850c40e43b789ddec 100755 (executable)
@@ -2,7 +2,7 @@ USING: continuations destructors io.buffers io.files io.backend
 io.timeouts io.nonblocking io.windows io.windows.nt.backend
 kernel libc math threads windows windows.kernel32
 alien.c-types alien.arrays sequences combinators combinators.lib
-sequences.lib ascii splitting alien strings assocs ;
+sequences.lib ascii splitting alien strings assocs namespaces ;
 IN: io.windows.nt.files
 
 M: windows-nt-io cwd
@@ -17,54 +17,47 @@ M: windows-nt-io cd
     "\\\\?\\" ; inline
 
 M: windows-nt-io root-directory? ( path -- ? )
-    dup length 2 = [
-        dup first Letter?
-        swap second CHAR: : = and
-    ] [
-        drop f
-    ] if ;
+    {
+        { [ dup empty? ] [ f ] }
+        { [ dup [ path-separator? ] all? ] [ t ] }
+        { [ dup right-trim-separators
+          { [ dup length 2 = ] [ dup second CHAR: : = ] } && nip ] [
+            t
+        ] }
+        { [ t ] [ f ] }
+    } cond nip ;
 
+ERROR: not-absolute-path ;
 : root-directory ( string -- string' )
     {
         [ dup length 2 >= ]
         [ dup second CHAR: : = ]
         [ dup first Letter? ]
-    } && [ 2 head ] [ "Not an absolute path" throw ] if ;
+    } && [ 2 head ] [ not-absolute-path ] if ;
 
 : prepend-prefix ( string -- string' )
     unicode-prefix prepend ;
 
-: windows-append-path ( cwd path -- newpath )
-    {
-        ! empty
-        { [ dup empty? ] [ drop ] }
-        ! ..
-        { [ dup ".." = ] [ drop parent-directory prepend-prefix ] }
-        ! \\\\?\\c:\\foo
-        { [ dup unicode-prefix head? ] [ nip ] }
-        ! ..\\foo
-        { [ dup "..\\" head? ] [ >r parent-directory r> 3 tail windows-append-path ] }
-        ! .\\foo
-        { [ dup ".\\" head? ] [ 1 tail append prepend-prefix ] }
-        ! \\foo
-        { [ dup "\\" head? ] [ >r root-directory r> append prepend-prefix ] }
-        ! c:\\foo
-        { [ dup ?second CHAR: : = ] [ nip prepend-prefix ] }
-        ! foo.txt
-        { [ t ] [
-            >r right-trim-separators "\\" r>
-            left-trim-separators
-            3append prepend-prefix
-        ] }
-    } cond ;
+ERROR: nonstring-pathname ;
+ERROR: empty-pathname ;
 
 M: windows-nt-io normalize-pathname ( string -- string )
-    dup string? [ "Pathname must be a string" throw ] unless
-    dup empty? [ "Empty pathname" throw ] when
-    { { CHAR: / CHAR: \\ } } substitute
-    cwd swap windows-append-path
-    [ "/\\." member? ] right-trim
-    dup peek CHAR: : = [ "\\" append ] when ;
+    "resource:" ?head [
+        left-trim-separators resource-path
+        normalize-pathname
+    ] [
+        dup empty? [ empty-pathname ] when
+        current-directory get prepend-path
+        dup unicode-prefix head? [
+            dup first path-separator? [
+                left-trim-separators
+                current-directory get 2 head
+                prepend-path
+            ] when
+            unicode-prefix prepend
+        ] unless
+        { { CHAR: / CHAR: \\ } } substitute ! necessary
+    ] if ;
 
 M: windows-nt-io CreateFile-flags ( DWORD -- DWORD )
     FILE_FLAG_OVERLAPPED bitor ;
diff --git a/extra/io/windows/nt/nt-tests.factor b/extra/io/windows/nt/nt-tests.factor
deleted file mode 100755 (executable)
index 6353bfe..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-USING: io.files kernel tools.test io.backend
-io.windows.nt.files splitting ;
-IN: io.windows.nt.tests
-
-[ "c:\\foo\\" ] [ "c:\\foo\\bar" parent-directory ] unit-test
-[ "c:\\" ] [ "c:\\foo\\" parent-directory ] unit-test
-[ "c:\\" ] [ "c:\\foo" parent-directory ] unit-test
-! { "c:" "c:\\" "c:/" } [ directory ] each -- all do the same thing
-[ "c:" ] [ "c:\\" parent-directory ] unit-test
-[ "Z:" ] [ "Z:\\" parent-directory ] unit-test
-[ "c:" ] [ "c:" parent-directory ] unit-test
-[ "Z:" ] [ "Z:" parent-directory ] unit-test
-[ t ] [ "c:\\" right-trim-separators root-directory? ] unit-test
-[ t ] [ "Z:\\" right-trim-separators root-directory? ] unit-test
-[ f ] [ "c:\\foo" root-directory? ] unit-test
-[ f ] [ "." root-directory? ] unit-test
-[ f ] [ ".." root-directory? ] unit-test
-
-[ ] [ "" resource-path cd ] unit-test
-
-[ "\\foo\\bar" ] [ "/foo/bar" normalize-pathname ":" split1 nip ] unit-test
-
-[ "\\\\?\\C:\\builds\\factor\\log.txt" ] [
-    "C:\\builds\\factor\\12345\\"
-    "..\\log.txt" windows-append-path
-] unit-test
-
-[ "\\\\?\\C:\\builds\\" ] [
-    "C:\\builds\\factor\\12345\\"
-    "..\\.." windows-append-path
-] unit-test
-
-[ "\\\\?\\C:\\builds\\" ] [
-    "C:\\builds\\factor\\12345\\"
-    "..\\.." windows-append-path
-] unit-test
index a63a533ba12c6b27a30a0598ea245016254f1538..85bb34b2251afcc3eda3ed2a49922734905beae8 100755 (executable)
@@ -2,7 +2,7 @@ USING: alien alien.accessors alien.c-types byte-arrays
 continuations destructors io.nonblocking io.timeouts io.sockets
 io.sockets.impl io namespaces io.streams.duplex io.windows
 io.windows.nt.backend windows.winsock kernel libc math sequences
-threads tuples.lib ;
+threads classes.tuple.lib ;
 IN: io.windows.nt.sockets
 
 : malloc-int ( object -- object )
index dac55664a4a63c6cfdfb363947323bfe49d7b4b3..27917cedfa76a61d4d6f28340272adc70c52c25f 100755 (executable)
@@ -51,14 +51,15 @@ M: win32-file close-handle ( handle -- )
 ! Clean up resources (open handle) if add-completion fails
 : open-file ( path access-mode create-mode flags -- handle )
     [
-        >r >r >r normalize-pathname r>
+        >r >r
         share-mode security-attributes-inherit r> r> CreateFile-flags f CreateFile
         dup invalid-handle? dup close-later
         dup add-completion
     ] with-destructors ;
 
 : open-pipe-r/w ( path -- handle )
-    GENERIC_READ GENERIC_WRITE bitor OPEN_EXISTING 0 open-file ;
+    { GENERIC_READ GENERIC_WRITE } flags
+    OPEN_EXISTING 0 open-file ;
 
 : open-read ( path -- handle length )
     GENERIC_READ OPEN_EXISTING 0 open-file 0 ;
@@ -69,6 +70,24 @@ M: win32-file close-handle ( handle -- )
 : (open-append) ( path -- handle )
     GENERIC_WRITE OPEN_ALWAYS 0 open-file ;
 
+: open-existing ( path -- handle )
+    { GENERIC_READ GENERIC_WRITE } flags
+    share-mode
+    f
+    OPEN_EXISTING
+    FILE_FLAG_BACKUP_SEMANTICS
+    f CreateFileW dup win32-error=0/f ;
+
+: maybe-create-file ( path -- handle ? )
+    #! return true if file was just created
+    { GENERIC_READ GENERIC_WRITE } flags
+    share-mode
+    f
+    OPEN_ALWAYS
+    0 CreateFile-flags
+    f CreateFileW dup win32-error=0/f
+    GetLastError ERROR_ALREADY_EXISTS = not ;
+
 : set-file-pointer ( handle length -- )
     dupd d>w/w <uint> FILE_BEGIN SetFilePointer
     INVALID_SET_FILE_POINTER = [
@@ -116,14 +135,14 @@ M: windows-io (file-appender) ( path -- stream )
     open-append <win32-file> <writer> ;
 
 M: windows-io move-file ( from to -- )
-    [ normalize-pathname ] 2apply MoveFile win32-error=0/f ;
+    [ normalize-pathname ] bi@ MoveFile win32-error=0/f ;
 
 M: windows-io delete-file ( path -- )
     normalize-pathname DeleteFile win32-error=0/f ;
 
 M: windows-io copy-file ( from to -- )
     dup parent-directory make-directories
-    [ normalize-pathname ] 2apply 0 CopyFile win32-error=0/f ;
+    [ normalize-pathname ] bi@ 0 CopyFile win32-error=0/f ;
 
 M: windows-io make-directory ( path -- )
     normalize-pathname
index 61fef7959cecb66de74a3b3268fa9cafe6bfc8c7..7be406d37ae298cea3dbeb36282d0ea5e08e26a1 100755 (executable)
@@ -72,7 +72,7 @@ TUPLE: segment number color radius ;
 : sub-tunnel ( from to sements -- segments )
     #! return segments between from and to, after clamping from and to to
     #! valid values
-    [ sequence-index-range [ clamp-to-range ] curry 2apply ] keep <slice> ;
+    [ sequence-index-range [ clamp-to-range ] curry bi@ ] keep <slice> ;
 
 : nearer-segment ( segment segment oint -- segment )
     #! return whichever of the two segments is nearer to the oint
index 4f3bd096135d7b013cabdbb52ea64e854a108de6..1741b96e75d0467ec3d4b7fc59975d2b2f2b3473 100644 (file)
@@ -1,8 +1,8 @@
 ! Copyright (C) 2006 Chris Double.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel io.streams.string io strings splitting sequences math 
-       math.parser assocs tuples classes words namespaces 
-       hashtables ;
+       math.parser assocs classes words namespaces prettyprint
+       hashtables mirrors ;
 IN: json.writer
 
 #! Writes the object out to a stream in JSON format
@@ -39,25 +39,19 @@ M: sequence json-print ( array -- string )
   #! javascript variable names.
   [ (jsvar-encode) ] map ;
   
-: slots ( object -- values names )
-  #! Given an object return an array of slots names and a sequence of slot values
-  #! the slot name and the slot value. 
-  [ tuple-slots ] keep class "slot-names" word-prop ;
-
-: slots>fields ( values names -- array )
-  #! Convert the arrays containing the slot names and values
-  #! to an array of strings suitable for describing that slot
-  #! as a field in a javascript object.
-  [ 
-    [ jsvar-encode >json % " : " % >json % ] "" make 
-  ] 2map ;
+: tuple>fields ( object -- string )
+  <mirror> [
+    [ swap jsvar-encode >json % " : " % >json % ] "" make
+  ] { } assoc>map ;
 
-M: object json-print ( object -- string )
-  CHAR: { write1 slots slots>fields "," join write CHAR: } write1 ;
+M: tuple json-print ( tuple -- string )
+  CHAR: { write1 tuple>fields "," join write CHAR: } write1 ;
 
 M: hashtable json-print ( hashtable -- string )
   CHAR: { write1 
   [ [ swap jsvar-encode >json % CHAR: : , >json % ] "" make ]
   { } assoc>map "," join write 
   CHAR: } write1 ;
-  
+
+M: object json-print ( object -- string )
+    unparse json-print ;
index 71cbb1d951242c8417930855205f177f5fcaed50..f286690d37254fbd133b90da4b2646fdb86c6dc5 100755 (executable)
@@ -57,7 +57,7 @@ SYMBOL: terms
     terms get [ [ swap +@ ] assoc-each ] bind ;
 
 : alt+ ( x y -- x+y )
-    [ >alt ] 2apply [ (alt+) (alt+) ] with-terms ;
+    [ >alt ] bi@ [ (alt+) (alt+) ] with-terms ;
 
 ! Multiplication
 : alt*n ( vec n -- vec )
@@ -79,7 +79,7 @@ SYMBOL: terms
     ] curry each ;
 
 : duplicates? ( seq -- ? )
-    dup prune [ length ] 2apply > ;
+    dup prune [ length ] bi@ > ;
 
 : (wedge) ( n basis1 basis2 -- n basis )
     append dup duplicates? [
@@ -90,7 +90,7 @@ SYMBOL: terms
     ] if ;
 
 : wedge ( x y -- x.y )
-    [ >alt ] 2apply [
+    [ >alt ] bi@ [
         swap [
             [
                 2swap [
@@ -200,7 +200,7 @@ DEFER: (d)
     ] with map ;
 
 : bigraded-betti ( u-generators z-generators -- seq )
-    [ basis graded ] 2apply tensor bigraded-ker/im-d
+    [ basis graded ] bi@ tensor bigraded-ker/im-d
     [ [ [ first ] map ] map ] keep
     [ [ second ] map 2 head* { 0 0 } prepend ] map
     1 tail dup first length 0 <array> add
@@ -278,7 +278,7 @@ DEFER: (d)
     ] with map ;
 
 : bigraded-laplacian ( u-generators z-generators quot -- seq )
-    >r [ basis graded ] 2apply tensor bigraded-triples r>
+    >r [ basis graded ] bi@ tensor bigraded-triples r>
     [ [ first3 ] swap compose map ] curry map ; inline
 
 : bigraded-laplacian-betti ( u-generators z-generators -- seq )
index 07cd34b4df1a8b150e802c520439c3c69c06f675..52cca64b2f3ab1bb2a3adc55b7d1353247428376 100644 (file)
@@ -52,7 +52,7 @@ M: cons nil? ( cons -- bool )
 TUPLE: lazy-cons car cdr ;
 
 : lazy-cons ( car cdr -- promise )
-    [ promise ] 2apply \ lazy-cons construct-boa
+    [ promise ] bi@ \ lazy-cons construct-boa
     T{ promise f f t f } clone
     [ set-promise-value ] keep ;
 
index 07e16fb8628da826e7976e1c0353bb6884597753..98b376593c917f76a58056920df64e126beaeeb8 100644 (file)
@@ -17,7 +17,7 @@ SYMBOL: d
 SYMBOL: costs
 
 : init-d ( str1 str2 -- )
-    [ length 1+ ] 2apply 2dup <matrix> d set
+    [ length 1+ ] bi@ 2dup <matrix> d set
     [ 0 over ->d ] each
     [ dup 0 ->d ] each ; inline
 
@@ -39,7 +39,7 @@ SYMBOL: costs
     [
         2dup init-d
         2dup compute-costs
-        [ length ] 2apply [
+        [ length ] bi@ [
             [ levenshtein-step ] curry each
         ] with each
         levenshtein-result
index a220eece01a42ed06cc28073f9085357ba33864c..dcf52f723a341e31b349a30cfb6d5ae28161e63a 100644 (file)
@@ -71,7 +71,7 @@ def-hash get-global [
 
 ! Remove set-alien-cell, etc.
 [
-    drop [ accessor-words swap seq-diff ] keep [ length ] 2apply =
+    drop [ accessor-words swap seq-diff ] keep [ length ] bi@ =
 ] assoc-subset
 
 ! Remove trivial defs
@@ -148,7 +148,7 @@ GENERIC: run-lint ( obj -- obj )
 : filter-symbols ( alist -- alist )
     [
         nip first dup def-hash get at
-        [ first ] 2apply literalize = not
+        [ first ] bi@ literalize = not
     ] assoc-subset ;
 
 M: sequence run-lint ( seq -- seq )
index 640ae0c9ea25eadb958b65d5b47f4a133b82897e..5da0225be9e83cd2be6dd45de85d78322cf0fe9b 100755 (executable)
@@ -5,7 +5,7 @@ inference.transforms parser words quotations debugger macros
 arrays macros splitting combinators prettyprint.backend
 definitions prettyprint hashtables combinators.lib
 prettyprint.sections sequences.private effects generic
-compiler.units combinators.cleave accessors ;
+compiler.units accessors ;
 IN: locals
 
 ! Inspired by
@@ -29,23 +29,23 @@ TUPLE: wlet bindings body ;
 
 C: <wlet> wlet
 
-PREDICATE: word local "local?" word-prop ;
+PREDICATE: local < word "local?" word-prop ;
 
 : <local> ( name -- word )
     #! Create a local variable identifier
     f <word> dup t "local?" set-word-prop ;
 
-PREDICATE: word local-word "local-word?" word-prop ;
+PREDICATE: local-word < word "local-word?" word-prop ;
 
 : <local-word> ( name -- word )
     f <word> dup t "local-word?" set-word-prop ;
 
-PREDICATE: word local-reader "local-reader?" word-prop ;
+PREDICATE: local-reader < word "local-reader?" word-prop ;
 
 : <local-reader> ( name -- word )
     f <word> dup t "local-reader?" set-word-prop ;
 
-PREDICATE: word local-writer "local-writer?" word-prop ;
+PREDICATE: local-writer < word "local-writer?" word-prop ;
 
 : <local-writer> ( reader -- word )
     dup word-name "!" append f <word>
@@ -266,13 +266,13 @@ M: object local-rewrite* , ;
     ] assoc-each local-rewrite* \ call , ;
 
 M: let local-rewrite*
-    { body>> bindings>> } get-slots let-rewrite ;
+    [ body>> ] [ bindings>> ] bi let-rewrite ;
 
 M: let* local-rewrite*
-    { body>> bindings>> } get-slots let-rewrite ;
+    [ body>> ] [ bindings>> ] bi let-rewrite ;
 
 M: wlet local-rewrite*
-    { body>> bindings>> } get-slots
+    [ body>> ] [ bindings>> ] bi
     [ [ ] curry ] assoc-map
     let-rewrite ;
 
@@ -340,7 +340,7 @@ M: lambda pprint*
 
 : pprint-let ( let word -- )
     pprint-word
-    { body>> bindings>> } get-slots
+    [ body>> ] [ bindings>> ] bi
     \ | pprint-word
     t <inset
     <block
@@ -357,7 +357,7 @@ M: wlet pprint* \ [wlet pprint-let ;
 
 M: let* pprint* \ [let* pprint-let ;
 
-PREDICATE: word lambda-word
+PREDICATE: lambda-word < word
     "lambda" word-prop >boolean ;
 
 M: lambda-word definer drop \ :: \ ; ;
@@ -373,7 +373,7 @@ M: lambda-word definition
 
 M: lambda-word synopsis* lambda-word-synopsis ;
 
-PREDICATE: macro lambda-macro
+PREDICATE: lambda-macro < macro
     "lambda" word-prop >boolean ;
 
 M: lambda-macro definer drop \ MACRO:: \ ; ;
@@ -383,7 +383,7 @@ M: lambda-macro definition
 
 M: lambda-macro synopsis* lambda-word-synopsis ;
 
-PREDICATE: method-body lambda-method
+PREDICATE: lambda-method < method-body
     "lambda" word-prop >boolean ;
 
 M: lambda-method definer drop \ M:: \ ; ;
index b87f30afa3a85f9a4b79a7c75b6bac207ed534be..bcd87ca137a29d97a3505c8d969ea5b7824dba6b 100644 (file)
@@ -1,6 +1,6 @@
 
 USING: kernel sequences quotations assocs math math.parser
-       combinators.cleave combinators.lib vars lsys.strings ;
+       combinators.lib vars lsys.strings ;
 
 IN: lsys.strings.interpret
 
index 8e45e5f49909e0da35003d7e4a2a1990b8c60e33..eb76dbd75154842bcb3bef1a3c995f219c4041ac 100644 (file)
@@ -1,6 +1,6 @@
 
 USING: kernel sbufs strings sequences assocs math
-       combinators.cleave combinators.lib vars lsys.strings ;
+       combinators.lib vars lsys.strings ;
 
 IN: lsys.strings.rewrite
 
index 629bcc89c9fefd2905914598a5bd75a6bce08b88..3c9dfcab6c4d27a2f2df41897e2808934d3abbd7 100644 (file)
@@ -1,5 +1,5 @@
 
-USING: kernel sequences math combinators.cleave combinators.lib ;
+USING: kernel sequences math combinators.lib ;
 
 IN: lsys.strings
 
index 45372aec6c01a6a91d5a25e5d4d0151626501a09..c8d103a084252d31126d5abe8df5a6ba036fb552 100644 (file)
@@ -196,6 +196,8 @@ slate> handler> set-gadget-delegate
 
 handler> "L-system view" open-window
 
+500 sleep
+
 slate> find-gl-context
 1 glGenLists >model
 
index 87b3acd47c15efe643826bf76af997607d150729..b242f91d3bc6fb5a1dd06314cd2ac02fd7ca896c 100755 (executable)
@@ -17,7 +17,7 @@ IN: macros
 : MACRO:
     (:) define-macro ; parsing
 
-PREDICATE: word macro "macro" word-prop >boolean ;
+PREDICATE: macro < word "macro" word-prop >boolean ;
 
 M: macro definer drop \ MACRO: \ ; ;
 
index 36af5c990a0417b8adc9a1f11f68d62328acb11e..dbc42f53e3f0c40b77f7e77973ea2b5e100cf746 100755 (executable)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 !
 ! Based on pattern matching code from Paul Graham's book 'On Lisp'.
-USING: parser kernel words namespaces sequences tuples
+USING: parser kernel words namespaces sequences classes.tuple
 combinators macros assocs math ;
 IN: match
 
@@ -32,10 +32,10 @@ SYMBOL: _
         { [ 2dup = ] [ 2drop t ] }
         { [ 2dup [ _ eq? ] either? ] [ 2drop t ] }
         { [ 2dup [ sequence? ] both? ] [
-            2dup [ length ] 2apply =
+            2dup [ length ] bi@ =
             [ [ (match) ] 2all? ] [ 2drop f ] if ] }
         { [ 2dup [ tuple? ] both? ]
-          [ [ tuple>array ] 2apply [ (match) ] 2all? ] }
+          [ [ tuple>array ] bi@ [ (match) ] 2all? ] }
         { [ t ] [ 2drop f ] }
     } cond ;
 
index 0b4b14ce54e3181752f5ec494a7642cb43f45b80..a41281d7795d431f9a6a069e7cc1eb1b6616c85f 100755 (executable)
@@ -1,5 +1,5 @@
 USING: kernel math math.constants math.functions math.intervals
-math.vectors namespaces sequences combinators.cleave ;
+math.vectors namespaces sequences ;
 IN: math.analysis
 
 <PRIVATE
index 236d9df7a06e5ab7e4010be0028a72a7de4741b7..588f34d3fcc3166f4fa40ad3abf6b9f2cc088c79 100755 (executable)
@@ -8,11 +8,11 @@ math.functions.private sequences parser ;
 M: real real-part ;
 M: real imaginary-part drop 0 ;
 
-M: complex absq >rect [ sq ] 2apply + ;
+M: complex absq >rect [ sq ] bi@ + ;
 
 : 2>rect ( x y -- xr yr xi yi )
-    [ [ real-part ] 2apply ] 2keep
-    [ imaginary-part ] 2apply ; inline
+    [ [ real-part ] bi@ ] 2keep
+    [ imaginary-part ] bi@ ; inline
 
 M: complex number=
     2>rect number= [ number= ] [ 2drop f ] if ;
index 85e07fe73fac964d719d848bdf09fc7f07c54d76..dcbccb43163eef37526242fa0a5b9abdc0996a3c 100755 (executable)
@@ -101,7 +101,7 @@ M: real absq sq ;
     >r - abs r> < ;
 
 : ~rel ( x y epsilon -- ? )
-    >r [ - abs ] 2keep [ abs ] 2apply + r> * < ;
+    >r [ - abs ] 2keep [ abs ] bi@ + r> * < ;
 
 : ~ ( x y epsilon -- ? )
     {
@@ -124,7 +124,7 @@ M: real absq sq ;
 : arg ( z -- arg ) >float-rect swap fatan2 ; inline
 
 : >polar ( z -- abs arg )
-    >float-rect [ [ sq ] 2apply + fsqrt ] 2keep swap fatan2 ;
+    >float-rect [ [ sq ] bi@ + fsqrt ] 2keep swap fatan2 ;
     inline
 
 : cis ( arg -- z ) dup fcos swap fsin rect> ; inline
index e74ffc64d24f1d10a125431fa36add9c4b674df4..327bf76552a4440c00550353cd8d56d3f248e80c 100755 (executable)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2005, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: arrays kernel sequences math math.functions
-math.vectors combinators.cleave ;
+math.vectors ;
 IN: math.matrices
 
 ! Matrices
index 000d97f2a611a1549516a6388996be35eef2fdaa..d6ac71e629a4a6c31570181e43eb44c53f4853aa 100644 (file)
@@ -13,10 +13,10 @@ IN: math.polynomials
 <PRIVATE
 : 2pad-left ( p p n -- p p ) 0 [ pad-left swap ] 2keep pad-left swap ;
 : 2pad-right ( p p n -- p p ) 0 [ pad-right swap ] 2keep pad-right swap ;
-: pextend ( p p -- p p ) 2dup [ length ] 2apply max 2pad-right ;
-: pextend-left ( p p -- p p ) 2dup [ length ] 2apply max 2pad-left ;
+: pextend ( p p -- p p ) 2dup [ length ] bi@ max 2pad-right ;
+: pextend-left ( p p -- p p ) 2dup [ length ] bi@ max 2pad-left ;
 : unempty ( seq -- seq ) dup empty? [ drop { 0 } ] when ;
-: 2unempty ( seq seq -- seq seq ) [ unempty ] 2apply ;
+: 2unempty ( seq seq -- seq seq ) [ unempty ] bi@ ;
 
 PRIVATE>
 : p= ( p p -- ? ) pextend = ;
@@ -24,7 +24,7 @@ PRIVATE>
 : ptrim ( p -- p )
     dup singleton? [ [ zero? ] right-trim ] unless ;
 
-: 2ptrim ( p p -- p p ) [ ptrim ] 2apply ;
+: 2ptrim ( p p -- p p ) [ ptrim ] bi@ ;
 : p+ ( p p -- p ) pextend v+ ;
 : p- ( p p -- p ) pextend v- ;
 : n*p ( n p -- n*p ) n*v ;
@@ -32,7 +32,7 @@ PRIVATE>
 ! convolution
 : pextend-conv ( p p -- p p )
     #! extend to: p_m + p_n - 1 
-    2dup [ length ] 2apply + 1- 2pad-right [ >vector ] 2apply ;
+    2dup [ length ] bi@ + 1- 2pad-right [ >vector ] bi@ ;
 
 : p* ( p p -- p )
     #! Multiply two polynomials.
@@ -46,13 +46,13 @@ PRIVATE>
 
 : p/mod-setup ( p p -- p p n )
     2ptrim
-    2dup [ length ] 2apply -
+    2dup [ length ] bi@ -
     dup 1 < [ drop 1 ] when
     [ over length + 0 pad-left pextend ] keep 1+ ;
 
 : /-last ( seq seq -- a )
     #! divide the last two numbers in the sequences
-    [ peek ] 2apply / ;
+    [ peek ] bi@ / ;
 
 : (p/mod)
     2dup /-last
@@ -74,7 +74,7 @@ PRIVATE>
     ] if ;
 
 : pgcd ( p p -- p q )
-    swap V{ 0 } clone V{ 1 } clone 2swap (pgcd) [ >array ] 2apply ;
+    swap V{ 0 } clone V{ 1 } clone 2swap (pgcd) [ >array ] bi@ ;
 
 : pdiff ( p -- p' )
     #! Polynomial derivative.
index d61afd17c368010d3dabcb83d83729eb7db12d29..f121e4a0d1f4a4037c170938f8854a0e900e0411 100755 (executable)
@@ -14,7 +14,7 @@ IN: math.quaternions
 
 : ** conjugate * ; inline
 
-: 2q ( u v -- u' u'' v' v'' ) [ first2 ] 2apply ; inline
+: 2q ( u v -- u' u'' v' v'' ) [ first2 ] bi@ ; inline
 
 : q*a ( u v -- a ) 2q swapd ** >r * r> - ; inline
 
index 5d07bd046f5e91e68f5746a02e764b9999b051c6..3c430111ffcb9c0c5bc6f6eae8e82f6b60fa71f4 100755 (executable)
@@ -7,7 +7,7 @@ USING: kernel kernel.private math math.functions math.private ;
     dup numerator swap denominator ; inline
 
 : 2>fraction ( a/b c/d -- a c b d )
-    [ >fraction ] 2apply swapd ; inline
+    [ >fraction ] bi@ swapd ; inline
 
 <PRIVATE
 
@@ -26,7 +26,7 @@ M: integer /
     dup zero? [
         "Division by zero" throw
     ] [
-        dup 0 < [ [ neg ] 2apply ] when
+        dup 0 < [ [ neg ] bi@ ] when
         2dup gcd nip tuck /i >r /i r> fraction>
     ] if ;
 
index 4c60363be05df44aeaa6f5ef34071a26401c9c46..f7295604cd9430031e5fa4d394d1ccd19783f24d 100644 (file)
@@ -46,13 +46,13 @@ IN: math.statistics
 
 : ((r)) ( mean(x) mean(y) {x} {y} -- (r) )
     ! finds sigma((xi-mean(x))(yi-mean(y))
-    0 [ [ >r pick r> swap - ] 2apply * + ] 2reduce 2nip ;
+    0 [ [ >r pick r> swap - ] bi@ * + ] 2reduce 2nip ;
 
 : (r) ( mean(x) mean(y) {x} {y} sx sy -- r )
     * recip >r [ ((r)) ] keep length 1- / r> * ;
 
 : [r] ( {{x,y}...} -- mean(x) mean(y) {x} {y} sx sy )
-    first2 [ [ [ mean ] 2apply ] 2keep ] 2keep [ std ] 2apply ;
+    first2 [ [ [ mean ] bi@ ] 2keep ] 2keep [ std ] bi@ ;
 
 : r ( {{x,y}...} -- r )
     [r] (r) ;
index 14a493cec5744e3d0ed6d90dc8bc76d719e4ea3b..5d7bb9a1a22983fef8bd77a37bd8c1c11bbeb918 100644 (file)
@@ -22,7 +22,7 @@ SYMBOL: visited
 : random-neighbour ( cell -- newcell ) choices random ;
 
 : vertex ( pair -- )
-    first2 [ 0.5 + line-width * ] 2apply glVertex2d ;
+    first2 [ 0.5 + line-width * ] bi@ glVertex2d ;
 
 : (draw-maze) ( cell -- )
     dup vertex
index ab915ae7d5d7d2555deade4ba3e35e8f3cbd4128..45ae2cc9595f4d1bf459e29c3b86a292b37c1c9b 100755 (executable)
@@ -42,7 +42,7 @@ IN: memoize
 : MEMO:
     CREATE-WORD parse-definition define-memoized ; parsing
 
-PREDICATE: word memoized "memoize" word-prop ;
+PREDICATE: memoized < word "memoize" word-prop ;
 
 M: memoized definer drop \ MEMO: \ ; ;
 M: memoized definition "memo-quot" word-prop ;
index d514a539aa580f77d2af52beec81e01f17e7874a..8cccb1c634d4c7404b822dbed6f41a9c76b23b97 100755 (executable)
@@ -1,4 +1,4 @@
-USING: help.syntax help.markup kernel math classes tuples
+USING: help.syntax help.markup kernel math classes classes.tuple
 calendar ;
 IN: models
 
index 4058ee9e6a9010b859150373c7400c9167e963e4..4584daf592e4d16fb5db252596a676da002290c2 100644 (file)
@@ -23,9 +23,9 @@ TUPLE: not-a-decimal ;
 : parse-decimal ( str -- ratio )
     "." split1
     >r dup "-" head? [ drop t "0" ] [ f swap ] if r>
-    [ dup empty? [ drop "0" ] when ] 2apply
+    [ dup empty? [ drop "0" ] when ] bi@
     dup length
-    >r [ string>number dup [ not-a-decimal ] unless ] 2apply r>
+    >r [ string>number dup [ not-a-decimal ] unless ] bi@ r>
     10 swap ^ / + swap [ neg ] when ;
 
 : DECIMAL:
index 9a74cc65e8d6a364d1126e38d57a704dff515b80..ac62fb08f98f553d5f4257e16f170a4144ca59b5 100755 (executable)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel math sequences vectors classes combinators
-arrays words assocs parser namespaces definitions
+USING: kernel math sequences vectors classes classes.algebra
+combinators arrays words assocs parser namespaces definitions
 prettyprint prettyprint.backend quotations arrays.lib
 debugger io compiler.units kernel.private effects ;
 IN: multi-methods
@@ -64,7 +64,8 @@ GENERIC: method-prologue ( combination -- quot )
 
 TUPLE: method word def classes generic loc ;
 
-PREDICATE: word method-body "multi-method" word-prop >boolean ;
+PREDICATE: method-body < word
+    "multi-method" word-prop >boolean ;
 
 M: method-body stack-effect
     "multi-method" word-prop method-generic stack-effect ;
@@ -112,7 +113,7 @@ TUPLE: no-method arguments generic ;
     ] curry assoc-map ;
 
 : sorted-methods ( alist -- alist' )
-    [ [ first ] 2apply classes< ] topological-sort ;
+    [ [ first ] bi@ classes< ] topological-sort ;
 
 : niceify-method [ dup \ f eq? [ drop f ] when ] map ;
 
@@ -209,13 +210,13 @@ M: hook-combination generic-prologue
 USE: qualified
 QUALIFIED: syntax
 
-PREDICATE: word generic
+PREDICATE: generic < word
     "multi-combination" word-prop >boolean ;
 
-PREDICATE: word standard-generic
+PREDICATE: standard-generic < word
     "multi-combination" word-prop standard-combination? ;
 
-PREDICATE: word hook-generic
+PREDICATE: hook-generic < word
     "multi-combination" word-prop hook-combination? ;
 
 syntax:M: standard-generic definer drop \ GENERIC: f ;
@@ -233,7 +234,7 @@ syntax:M: hook-generic synopsis*
     dup "multi-combination" word-prop
     hook-combination-var pprint-word stack-effect. ;
 
-PREDICATE: array method-spec
+PREDICATE: method-spec < array
     unclip generic? >r [ class? ] all? r> and ;
 
 syntax:M: method-spec where
diff --git a/extra/new-effects/new-effects.factor b/extra/new-effects/new-effects.factor
new file mode 100644 (file)
index 0000000..f073cca
--- /dev/null
@@ -0,0 +1,17 @@
+USING: assocs kernel sequences ;
+IN: new-effects
+
+: new-nth ( seq n -- elt )
+    swap nth ; inline
+
+: new-set-nth ( seq obj n -- seq )
+    pick set-nth ; inline
+
+: new-at ( assoc key -- elt )
+    swap at ; inline
+
+: new-at* ( assoc key -- elt ? )
+    swap at* ; inline
+
+: new-set-at ( assoc value key -- assoc )
+    pick set-at ; inline
index 8fee55962fb0ebc841d8fa84cce7d6ecc8915ab1..84515305c8193ea8e3034bf97a1509017651901d 100755 (executable)
@@ -1,5 +1,5 @@
 USING: arrays combinators.lib kernel math math.functions math.vectors namespaces
-       opengl opengl.gl sequences ui ui.gadgets ui.gestures ui.render combinators.cleave ;
+       opengl opengl.gl sequences ui ui.gadgets ui.gestures ui.render ;
 IN: opengl.demo-support
 
 : NEAR-PLANE 1.0 64.0 / ; inline
@@ -38,7 +38,7 @@ M: demo-gadget pref-dim* ( gadget -- dim )
 
 : demo-gadget-frustum ( -- -x x -y y near far )
     FOV-RATIO NEAR-PLANE FOV / v*n
-    first2 [ -+ ] 2apply NEAR-PLANE FAR-PLANE ;
+    first2 [ -+ ] bi@ NEAR-PLANE FAR-PLANE ;
 
 : demo-gadget-set-matrices ( gadget -- )
     GL_PROJECTION glMatrixMode
index 08e3cb204b35a193e95681150f7d3213610a760e..36d24e13002210cec85eff3152a967f64aa1b41b 100755 (executable)
@@ -8,9 +8,9 @@ math.parser opengl.gl opengl.glu combinators arrays sequences
 splitting words byte-arrays assocs combinators.lib ;
 IN: opengl
 
-: coordinates [ first2 ] 2apply ;
+: coordinates [ first2 ] bi@ ;
 
-: fix-coordinates [ first2 [ >fixnum ] 2apply ] 2apply ;
+: fix-coordinates [ first2 [ >fixnum ] bi@ ] bi@ ;
 
 : gl-color ( color -- ) first4 glColor4d ; inline
 
@@ -85,7 +85,7 @@ MACRO: all-enabled-client-state ( seq quot -- )
 
 : unit-circle dup [ sin ] map swap [ cos ] map ;
 
-: adjust-points [ [ 1 + 0.5 * ] map ] 2apply ;
+: adjust-points [ [ 1 + 0.5 * ] map ] bi@ ;
 
 : scale-points 2array flip [ v* ] with map [ v+ ] with map ;
 
index 7403b7cb0589887cde74a0c2c137b94546c0d3a0..e352eabc10717bb5217b9d86dc7324b3b2c998a1 100755 (executable)
@@ -1,8 +1,8 @@
 ! Copyright (C) 2008 Joe Groff.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel opengl.gl alien.c-types continuations namespaces
-assocs alien libc opengl math sequences combinators.lib 
-combinators.cleave macros arrays ;
+assocs alien libc opengl math sequences combinators
+combinators.lib macros arrays ;
 IN: opengl.shaders
 
 : with-gl-shader-source-ptr ( string quot -- )
@@ -55,9 +55,9 @@ IN: opengl.shaders
 
 : delete-gl-shader ( shader -- ) glDeleteShader ; inline
 
-PREDICATE: integer gl-shader (gl-shader?) ;
-PREDICATE: gl-shader vertex-shader (vertex-shader?) ;
-PREDICATE: gl-shader fragment-shader (fragment-shader?) ;
+PREDICATE: gl-shader < integer (gl-shader?) ;
+PREDICATE: vertex-shader < gl-shader (vertex-shader?) ;
+PREDICATE: fragment-shader < gl-shader (fragment-shader?) ;
 
 ! Programs
 
@@ -126,7 +126,7 @@ PREDICATE: gl-shader fragment-shader (fragment-shader?) ;
 MACRO: with-gl-program ( uniforms quot -- )
     (make-with-gl-program) ;
 
-PREDICATE: integer gl-program (gl-program?) ;
+PREDICATE: gl-program < integer (gl-program?) ;
 
 : <simple-gl-program> ( vertex-shader-source fragment-shader-source -- program )
     >r <vertex-shader> check-gl-shader
diff --git a/extra/openssl/openssl-docs.factor b/extra/openssl/openssl-docs.factor
new file mode 100644 (file)
index 0000000..dd31bfd
--- /dev/null
@@ -0,0 +1,10 @@
+
+USING: help.syntax help.markup ;
+
+IN: openssl
+
+ARTICLE: "openssl" "OpenSSL"
+
+"Factor on Windows has been tested with this version of OpenSSL: "
+
+{ $url "http://www.openssl.org/related/binaries.html" } ;
\ No newline at end of file
index 2d0f5bb5d0da62e6dff3fa3ad702529ca0f52a4d..c689f729d1b0faa9cbab4c06495d4fa27ea2e735 100755 (executable)
@@ -25,7 +25,7 @@ namespaces math math.parser openssl prettyprint sequences tools.test ;
 
 [ ] [ ssl-v23 new-ctx ] unit-test
 
-[ ] [ get-ctx "/extra/openssl/test/server.pem" resource-path use-cert-chain ] unit-test
+[ ] [ get-ctx "extra/openssl/test/server.pem" resource-path use-cert-chain ] unit-test
 
 ! TODO: debug 'Memory protection fault at address 6c'
 ! get-ctx 1024 "char" malloc-array 1024 0 f password-cb set-default-passwd
@@ -33,10 +33,10 @@ namespaces math math.parser openssl prettyprint sequences tools.test ;
 [ ] [ get-ctx "password" string>char-alien set-default-passwd-userdata ] unit-test
 
 ! Enter PEM pass phrase: password
-[ ] [ get-ctx "/extra/openssl/test/server.pem" resource-path
+[ ] [ get-ctx "extra/openssl/test/server.pem" resource-path
 SSL_FILETYPE_PEM use-private-key ] unit-test
 
-[ ] [ get-ctx "/extra/openssl/test/root.pem" resource-path f
+[ ] [ get-ctx "extra/openssl/test/root.pem" resource-path f
 verify-load-locations ] unit-test
 
 [ ] [ get-ctx 1 set-verify-depth ] unit-test
@@ -45,7 +45,7 @@ verify-load-locations ] unit-test
 ! Load Diffie-Hellman parameters
 ! =========================================================
 
-[ ] [ "/extra/openssl/test/dh1024.pem" resource-path "r" bio-new-file ] unit-test
+[ ] [ "extra/openssl/test/dh1024.pem" resource-path "r" bio-new-file ] unit-test
 
 [ ] [ get-bio f f f read-pem-dh-params ] unit-test
 
@@ -129,7 +129,7 @@ verify-load-locations ] unit-test
 ! Dump errors to file
 ! =========================================================
 
-[ ] [ "/extra/openssl/test/errors.txt" resource-path "w" bio-new-file ] unit-test
+[ ] [ "extra/openssl/test/errors.txt" resource-path "w" bio-new-file ] unit-test
 
 [ 6 ] [ get-bio "Hello\n" bio-print ] unit-test
 
index bf06708e09a3341e5b99a1b92b6d077c62920374..d6aacf9645f110346c105d4bf3c9d2f491487230 100755 (executable)
@@ -35,7 +35,7 @@ C: <parse-result> parse-result
     ] if ;
 
 : string= ( str1 str2 ignore-case -- ? )
-    [ [ >upper ] 2apply ] when sequence= ;
+    [ [ >upper ] bi@ ] when sequence= ;
 
 : string-head? ( str head ignore-case -- ? )
     2over shorter? [
@@ -327,7 +327,7 @@ LAZY: <(+)> ( parser -- parser )
     nonempty-list-of { } succeed <|> ;
 
 LAZY: surrounded-by ( parser start end -- parser' )
-    [ token ] 2apply swapd pack ;
+    [ token ] bi@ swapd pack ;
 
 : exactly-n ( parser n -- parser' )
     swap <repetition> <and-parser> [ flatten ] <@ ;
index 54639431a4cf9454d64cff9a3e5f12bc18d045b3..7aa61e84daf49c3ab2427001ba0e205de8b1a63e 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2007 Chris Double.
 ! See http://factorcode.org/license.txt for BSD license.
 !
-USING: kernel tools.test peg peg.ebnf ;
+USING: kernel tools.test peg peg.ebnf words ;
 IN: peg.ebnf.tests
 
 { T{ ebnf-non-terminal f "abc" } } [
@@ -142,4 +142,84 @@ IN: peg.ebnf.tests
 
 { f } [
   "Z" [EBNF foo=[^A-Z] EBNF] call  
-] unit-test
\ No newline at end of file
+] unit-test
+
+{ V{ "1" "+" "foo" } } [
+  "1+1" [EBNF foo='1' '+' '1' [[ drop "foo" ]] EBNF] call parse-result-ast
+] unit-test
+
+{ "foo" } [
+  "1+1" [EBNF foo='1' '+' '1' => [[ drop "foo" ]] EBNF] call parse-result-ast
+] unit-test
+
+{ "foo" } [
+  "1+1" [EBNF foo='1' '+' '1' => [[ drop "foo" ]] | '1' '-' '1' => [[ drop "bar" ]] EBNF] call parse-result-ast
+] unit-test
+
+{ "bar" } [
+  "1-1" [EBNF foo='1' '+' '1' => [[ drop "foo" ]] | '1' '-' '1' => [[ drop "bar" ]] EBNF] call parse-result-ast
+] unit-test
+
+
+{ V{ V{ 49 } "+" V{ 49 } } } [ 
+  #! Test direct left recursion. 
+  #! Using packrat, so first part of expr fails, causing 2nd choice to be used  
+  "1+1" [EBNF num=([0-9])+ expr=expr "+" num | num EBNF] call parse-result-ast
+] unit-test
+
+{ V{ V{ V{ 49 } "+" V{ 49 } } "+" V{ 49 } } } [ 
+  #! Test direct left recursion. 
+  #! Using packrat, so first part of expr fails, causing 2nd choice to be used  
+  "1+1+1" [EBNF num=([0-9])+ expr=expr "+" num | num EBNF] call parse-result-ast
+] unit-test
+
+{ V{ V{ V{ 49 } "+" V{ 49 } } "+" V{ 49 } } } [ 
+  #! Test indirect left recursion. 
+  #! Using packrat, so first part of expr fails, causing 2nd choice to be used  
+  "1+1+1" [EBNF num=([0-9])+ x=expr expr=x "+" num | num EBNF] call parse-result-ast
+] unit-test
+
+EBNF: primary 
+Primary = PrimaryNoNewArray
+PrimaryNoNewArray =  ClassInstanceCreationExpression 
+                   | MethodInvocation
+                   | FieldAccess
+                   | ArrayAccess
+                   | "this"
+ClassInstanceCreationExpression =  "new" ClassOrInterfaceType "(" ")"
+                                 | Primary "." "new" Identifier "(" ")"
+MethodInvocation =  Primary "." MethodName "(" ")"
+                  | MethodName "(" ")"
+FieldAccess =  Primary "." Identifier
+             | "super" "." Identifier  
+ArrayAccess =  Primary "[" Expression "]"
+             | ExpressionName "[" Expression "]"
+ClassOrInterfaceType = ClassName | InterfaceTypeName
+ClassName = "C" | "D"
+InterfaceTypeName = "I" | "J"
+Identifier = "x" | "y" | ClassOrInterfaceType
+MethodName = "m" | "n"
+ExpressionName = Identifier
+Expression = "i" | "j"
+main = Primary
+;EBNF 
+
+{ "this" } [
+  "this" primary parse-result-ast
+] unit-test
+
+{ V{ "this" "." "x" } } [
+  "this.x" primary parse-result-ast
+] unit-test
+
+{ V{ V{ "this" "." "x" } "." "y" } } [
+  "this.x.y" primary parse-result-ast
+] unit-test
+
+{ V{ V{ "this" "." "x" } "." "m" "(" ")" } } [
+  "this.x.m()" primary parse-result-ast
+] unit-test
+
+{ V{ V{ V{ "x" "[" "i" "]" } "[" "j" "]" } "." "y" } } [
+  "x[i][j].y" primary parse-result-ast
+] unit-test
index ab7baa547e1a90661a457b34a29ee057b8e751bd..af61c3aae0435a224531d6e6149da6c87578a583 100644 (file)
@@ -3,7 +3,7 @@
 USING: kernel compiler.units parser words arrays strings math.parser sequences \r
        quotations vectors namespaces math assocs continuations peg\r
        peg.parsers unicode.categories multiline combinators.lib \r
-       splitting ;\r
+       splitting accessors ;\r
 IN: peg.ebnf\r
 \r
 TUPLE: ebnf-non-terminal symbol ;\r
@@ -16,7 +16,7 @@ TUPLE: ebnf-choice options ;
 TUPLE: ebnf-sequence elements ;\r
 TUPLE: ebnf-repeat0 group ;\r
 TUPLE: ebnf-repeat1 group ;\r
-TUPLE: ebnf-optional elements ;\r
+TUPLE: ebnf-optional group ;\r
 TUPLE: ebnf-rule symbol elements ;\r
 TUPLE: ebnf-action parser code ;\r
 TUPLE: ebnf rules ;\r
@@ -111,7 +111,10 @@ C: <ebnf> ebnf
       'range-parser' ,\r
       'any-character' ,\r
     ] choice* ,\r
-    "=" syntax ensure-not ,\r
+    [\r
+      "=" syntax ensure-not ,\r
+      "=>" syntax ensure ,\r
+    ] choice* ,\r
   ] seq* [ first ] action ;\r
 \r
 DEFER: 'choice'\r
@@ -176,7 +179,10 @@ DEFER: 'choice'
     'repeat0' sp ,\r
     'repeat1' sp ,\r
     'optional' sp , \r
-  ] choice* ;  \r
+  ] choice* ;\r
+\r
+: 'action' ( -- parser )\r
+   "[[" 'factor-code' "]]" syntax-pack ;\r
 \r
 : 'sequence' ( -- parser )\r
   #! A sequence of terminals and non-terminals, including\r
@@ -184,23 +190,30 @@ DEFER: 'choice'
   [\r
     [ \r
       ('sequence') ,\r
-      "[[" 'factor-code' "]]" syntax-pack ,\r
+      'action' ,\r
     ] seq* [ first2 <ebnf-action> ] action ,\r
     ('sequence') ,\r
   ] choice* repeat1 [ \r
      dup length 1 = [ first ] [ <ebnf-sequence> ] if\r
   ] action ;\r
+\r
+: 'actioned-sequence' ( -- parser )\r
+  [\r
+    [ 'sequence' , "=>" syntax , 'action' , ] seq* [ first2 <ebnf-action> ] action ,\r
+    'sequence' ,\r
+  ] choice* ;\r
   \r
 : 'choice' ( -- parser )\r
-  'sequence' sp "|" token sp list-of [ \r
+  'actioned-sequence' sp "|" token sp list-of [ \r
     dup length 1 = [ first ] [ <ebnf-choice> ] if\r
   ] action ;\r
  \r
 : 'rule' ( -- parser )\r
   [\r
-    'non-terminal' [ ebnf-non-terminal-symbol ] action  ,\r
+    'non-terminal' [ symbol>> ] action  ,\r
     "=" syntax  ,\r
-    'choice'  ,\r
+    ">" token ensure-not ,\r
+    'choice' ,\r
   ] seq* [ first2 <ebnf-rule> ] action ;\r
 \r
 : 'ebnf' ( -- parser )\r
@@ -215,51 +228,55 @@ SYMBOL: main
   H{ } clone dup dup [ parser set swap (transform) main set ] bind ;\r
 \r
 M: ebnf (transform) ( ast -- parser )\r
-  ebnf-rules [ (transform) ] map peek ;\r
+  rules>> [ (transform) ] map peek ;\r
   \r
 M: ebnf-rule (transform) ( ast -- parser )\r
-  dup ebnf-rule-elements (transform) [\r
-    swap ebnf-rule-symbol set\r
+  dup elements>> (transform) [\r
+    swap symbol>> set\r
   ] keep ;\r
 \r
 M: ebnf-sequence (transform) ( ast -- parser )\r
-  ebnf-sequence-elements [ (transform) ] map seq ;\r
+  elements>> [ (transform) ] map seq ;\r
 \r
 M: ebnf-choice (transform) ( ast -- parser )\r
-  ebnf-choice-options [ (transform) ] map choice ;\r
+  options>> [ (transform) ] map choice ;\r
 \r
 M: ebnf-any-character (transform) ( ast -- parser )\r
   drop any-char ;\r
 \r
 M: ebnf-range (transform) ( ast -- parser )\r
-  ebnf-range-pattern range-pattern ;\r
+  pattern>> range-pattern ;\r
+\r
+: transform-group ( ast -- parser ) \r
+  #! convert a ast node with groups to a parser for that group\r
+  group>> (transform) ;\r
 \r
 M: ebnf-ensure (transform) ( ast -- parser )\r
-  ebnf-ensure-group (transform) ensure ;\r
+  transform-group ensure ;\r
 \r
 M: ebnf-ensure-not (transform) ( ast -- parser )\r
-  ebnf-ensure-not-group (transform) ensure-not ;\r
+  transform-group ensure-not ;\r
 \r
 M: ebnf-repeat0 (transform) ( ast -- parser )\r
-  ebnf-repeat0-group (transform) repeat0 ;\r
+  transform-group repeat0 ;\r
 \r
 M: ebnf-repeat1 (transform) ( ast -- parser )\r
-  ebnf-repeat1-group (transform) repeat1 ;\r
+  transform-group repeat1 ;\r
 \r
 M: ebnf-optional (transform) ( ast -- parser )\r
-  ebnf-optional-elements (transform) optional ;\r
+  transform-group optional ;\r
 \r
 M: ebnf-action (transform) ( ast -- parser )\r
-  [ ebnf-action-parser (transform) ] keep\r
-  ebnf-action-code string-lines [ parse-lines ] with-compilation-unit action ;\r
+  [ parser>> (transform) ] keep\r
+  code>> string-lines [ parse-lines ] with-compilation-unit action ;\r
 \r
 M: ebnf-terminal (transform) ( ast -- parser )\r
-  ebnf-terminal-symbol token sp ;\r
+  symbol>> token sp ;\r
 \r
 M: ebnf-non-terminal (transform) ( ast -- parser )\r
-  ebnf-non-terminal-symbol  [\r
-    , parser get , \ at ,  \r
-  ] [ ] make delay sp ;\r
+  symbol>>  [\r
+    , parser get , \ at , \ sp ,   \r
+  ] [ ] make box ;\r
 \r
 : transform-ebnf ( string -- object )\r
   'ebnf' parse parse-result-ast transform ;\r
@@ -278,7 +295,8 @@ M: ebnf-non-terminal (transform) ( ast -- parser )
 \r
 : ebnf>quot ( string -- hashtable quot )\r
   'ebnf' parse check-parse-result \r
-  parse-result-ast transform dup main swap at compile ;\r
+  parse-result-ast transform dup dup parser [ main swap at compile ] with-variable\r
+  [ compiled-parse ] curry ;\r
 \r
 : [EBNF "EBNF]" parse-multiline-string ebnf>quot nip parsed ; parsing\r
 \r
index 6b690cb5ee4e5de170255c18d4f74b9edc95ecbf..e16d9db0a7827178071b77eb50c96c9f02d23069 100644 (file)
@@ -4,24 +4,19 @@ USING: kernel arrays strings math.parser sequences
 peg peg.ebnf peg.parsers memoize math ;
 IN: peg.expr
 
-: operator-fold ( lhs seq -- value )
- #! Perform a fold of a lhs, followed by a sequence of pairs being
- #! { operator rhs } in to a tree structure of the correct precedence.
- swap [ first2 swap call ] reduce ;
-
 EBNF: expr 
-times    = "*" [[ drop [ * ] ]]
-divide   = "/" [[ drop [ / ] ]]
-add      = "+" [[ drop [ + ] ]]
-subtract = "-" [[ drop [ - ] ]]
+digit    = [0-9]            => [[ digit> ]]
+number   = (digit)+         => [[ 10 digits>integer ]]
+value    =   number 
+           | ("(" exp ")")  => [[ second ]]
 
-digit    = [0-9] [[ digit> ]]
-number   = (digit)+ [[ unclip [ swap 10 * + ] reduce ]]
+fac      =   fac "*" value  => [[ first3 nip * ]]
+           | fac "/" value  => [[ first3 nip / ]]
+           | number
 
-value    = number | ("(" expr ")") [[ second ]] 
-product = (value ((times | divide) value)*) [[ first2 operator-fold ]]
-sum = (product ((add | subtract) product)*) [[ first2 operator-fold ]]
-expr = sum
+exp      =   exp "+" fac    => [[ first3 nip + ]]
+           | exp "-" fac    => [[ first3 nip - ]]
+           | fac
 ;EBNF
 
 : eval-expr ( string -- number )
index 08bde98419c013c3595d69d11f5963f341a0129c..e80baf3c4f31f6fc8f332cca1cb69774351924e3 100644 (file)
@@ -48,3 +48,7 @@ IN: peg.parsers.tests
 
 [ V{ } ]
 [ "" epsilon parse parse-result-ast ] unit-test
+
+{ "a" } [
+  "a" "a" token just parse parse-result-ast
+] unit-test
\ No newline at end of file
index 3ccb1e7d10603ac3f3b4cadc807a59c7250ba84a..49035ea43c48f4147eb1cfde64c7add34845d699 100755 (executable)
@@ -3,24 +3,24 @@
 USING: kernel sequences strings namespaces math assocs shuffle 
      vectors arrays combinators.lib math.parser match
      unicode.categories sequences.deep peg peg.private 
-     peg.search math.ranges ;
+     peg.search math.ranges words memoize ;
 IN: peg.parsers
 
 TUPLE: just-parser p1 ;
 
 : just-pattern
   [
-    dup [
+    execute dup [
       dup parse-result-remaining empty? [ drop f ] unless
     ] when
   ] ;
 
 
-M: just-parser compile ( parser -- quot )
-  just-parser-p1 compile just-pattern append ;
+M: just-parser (compile) ( parser -- quot )
+  just-parser-p1 compiled-parser just-pattern curry ;
 
-: just ( parser -- parser )
-  just-parser construct-boa ;
+MEMO: just ( parser -- parser )
+  just-parser construct-boa init-parser ;
 
 : 1token ( ch -- parser ) 1string token ;
 
@@ -47,10 +47,10 @@ PRIVATE>
 
 PRIVATE>
 
-: exactly-n ( parser n -- parser' )
+MEMO: exactly-n ( parser n -- parser' )
   swap <repetition> seq ;
 
-: at-most-n ( parser n -- parser' )
+MEMO: at-most-n ( parser n -- parser' )
   dup zero? [
     2drop epsilon
   ] [
@@ -58,19 +58,19 @@ PRIVATE>
     -rot 1- at-most-n 2choice
   ] if ;
 
-: at-least-n ( parser n -- parser' )
+MEMO: at-least-n ( parser n -- parser' )
   dupd exactly-n swap repeat0 2seq
   [ flatten-vectors ] action ;
 
-: from-m-to-n ( parser m n -- parser' )
+MEMO: from-m-to-n ( parser m n -- parser' )
   >r [ exactly-n ] 2keep r> swap - at-most-n 2seq
   [ flatten-vectors ] action ;
 
-: pack ( begin body end -- parser )
+MEMO: pack ( begin body end -- parser )
   >r >r hide r> r> hide 3seq [ first ] action ;
 
 : surrounded-by ( parser begin end -- parser' )
-  [ token ] 2apply swapd pack ;
+  [ token ] bi@ swapd pack ;
 
 : 'digit' ( -- parser )
   [ digit? ] satisfy [ digit> ] action ;
@@ -83,7 +83,7 @@ PRIVATE>
     [ CHAR: " = ] satisfy hide ,
     [ CHAR: " = not ] satisfy repeat0 ,
     [ CHAR: " = ] satisfy hide ,
-  ] { } make seq [ first >string ] action ;
+  ] seq* [ first >string ] action ;
 
 : (range-pattern) ( pattern -- string )
   #! Given a range pattern, produce a string containing
index 9ad375ea042912373ea8770ca1dd575d175c4a60..e7bd2555690ef10923d78039c5beb329aa194d17 100644 (file)
@@ -11,7 +11,18 @@ HELP: parse
 }\r
 { $description \r
     "Given the input string, parse it using the given parser. The result is a <parse-result> object if "\r
-    "the parse was successful, otherwise it is f." } ;\r
+    "the parse was successful, otherwise it is f." } \r
+{ $see-also compile } ;\r
+\r
+HELP: compile\r
+{ $values \r
+  { "parser" "a parser" } \r
+  { "word" "a word" } \r
+}\r
+{ $description \r
+    "Compile the parser to a word. The word will have stack effect ( -- result )."\r
+} \r
+{ $see-also parse } ;\r
 \r
 HELP: token\r
 { $values \r
@@ -141,4 +152,17 @@ HELP: delay
 { $description \r
     "Delays the construction of a parser until it is actually required to parse. This " \r
     "allows for calling a parser that results in a recursive call to itself. The quotation "\r
-    "should return the constructed parser." } ;\r
+    "should return the constructed parser and is called the first time the parser is run."\r
+    "The compiled result is memoized for future runs. See " { $link box } " for a word "\r
+    "that calls the quotation at compile time." } ;\r
+\r
+HELP: box\r
+{ $values \r
+  { "quot" "a quotation" } \r
+  { "parser" "a parser" } \r
+}\r
+{ $description \r
+    "Delays the construction of a parser until the parser is compiled. The quotation "\r
+    "should return the constructed parser and is called when the parser is compiled."\r
+    "The compiled result is memoized for future runs. See " { $link delay } " for a word "\r
+    "that calls the quotation at runtime." } ;\r
index 89cc243863bcb9c114455358352a9b4e2ea41f3c..f57fe83220222e2d7846fa84fbf5be0914a96035 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2007 Chris Double.
 ! See http://factorcode.org/license.txt for BSD license.
 !
-USING: kernel tools.test strings namespaces arrays sequences peg peg.private ;
+USING: kernel tools.test strings namespaces arrays sequences peg peg.private accessors words ;
 IN: peg.tests
 
 { f } [
@@ -158,3 +158,28 @@ IN: peg.tests
   "a]" "[" token hide "a" token "]" token hide 3array seq parse 
 ] unit-test
 
+
+{ V{ "1" "-" "1" } V{ "1" "+" "1" } } [
+  [
+    [ "1" token , "-" token , "1" token , ] seq* ,
+    [ "1" token , "+" token , "1" token , ] seq* ,
+  ] choice* 
+  "1-1" over parse parse-result-ast swap
+  "1+1" swap parse parse-result-ast
+] unit-test
+
+: expr ( -- parser ) 
+  #! Test direct left recursion. Currently left recursion should cause a
+  #! failure of that parser.
+  [ expr ] delay "+" token "1" token 3seq "1" token 2choice ;
+
+{ V{ V{ "1" "+" "1" } "+" "1" } } [
+  "1+1+1" expr parse parse-result-ast   
+] unit-test
+
+{ t } [
+  #! Ensure a circular parser doesn't loop infinitely
+  [ f , "a" token , ] seq*
+  dup parsers>>
+  dupd 0 swap set-nth compile word?
+] unit-test
\ No newline at end of file
index b3200ec5eb2ce800807699744c6ff34198fd3129..68aab7d82043fc49f534df3ba83b93443584a990 100755 (executable)
-! Copyright (C) 2007 Chris Double.
+! Copyright (C) 2007, 2008 Chris Double.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel sequences strings namespaces math assocs shuffle 
        vectors arrays combinators.lib math.parser match
        unicode.categories sequences.lib compiler.units parser
-       words ;
+       words quotations effects memoize accessors locals ;
 IN: peg
 
+USE: prettyprint
+
 TUPLE: parse-result remaining ast ;
 
-GENERIC: compile ( parser -- quot )
+TUPLE: parser id compiled ;
 
-: parse ( state parser -- result )
-  compile call ;
+M: parser equal? [ id>> ] bi@ = ;
+
+M: parser hashcode* id>> hashcode* ;
+
+C: <parser> parser
 
 SYMBOL: ignore 
 
 : <parse-result> ( remaining ast -- parse-result )
   parse-result construct-boa ;
 
+SYMBOL: packrat
+SYMBOL: pos
+SYMBOL: input
+SYMBOL: fail
+SYMBOL: lrstack
+SYMBOL: heads
+
+TUPLE: memo-entry ans pos ;
+C: <memo-entry> memo-entry
+
+TUPLE: left-recursion seed rule head next ;
+C: <left-recursion> left-recursion
+TUPLE: peg-head rule involved-set eval-set ;
+C: <head> peg-head
+
+: rule-parser ( rule -- parser ) 
+  #! A rule is the parser compiled down to a word. It has
+  #! a "peg" property containing the original parser.
+  "peg" word-prop ;
+
+: input-slice ( -- slice )
+  #! Return a slice of the input from the current parse position
+  input get pos get tail-slice ;
+
+: input-from ( input -- n )
+  #! Return the index from the original string that the
+  #! input slice is based on.
+  dup slice? [ slice-from ] [ drop 0 ] if ;
+
+: input-cache ( parser -- cache )
+  #! From the packrat cache, obtain the cache for the parser 
+  #! that maps the position to the parser result.
+  id>> packrat get [ drop H{ } clone ] cache ;
+
+: eval-rule ( rule -- ast )
+  #! Evaluate a rule, return an ast resulting from it.
+  #! Return fail if the rule failed. The rule has
+  #! stack effect ( input -- parse-result )
+  pos get swap 
+  execute 
+!  drop f f <parse-result>
+  [
+    nip
+    [ ast>> ] [ remaining>> ] bi
+    input-from pos set    
+  ] [ 
+    pos set   
+    fail
+  ] if* ; inline
+
+: memo ( pos rule -- memo-entry )
+  #! Return the result from the memo cache. 
+  rule-parser input-cache at ;
+
+: set-memo ( memo-entry pos rule -- )
+  #! Store an entry in the cache
+  rule-parser input-cache set-at ;
+
+:: (grow-lr) ( r p m h -- )
+  p pos set
+  h involved-set>> clone h (>>eval-set)
+  r eval-rule
+  dup fail = pos get m pos>> <= or [
+    drop
+  ] [
+    m (>>ans)
+    pos get m (>>pos)
+    r p m h (grow-lr)
+  ] if ; inline
+:: grow-lr ( r p m h -- ast )
+  h p heads get set-at
+  r p m h (grow-lr) 
+  p heads get delete-at
+  m pos>> pos set m ans>>
+  ; inline
+
+:: (setup-lr) ( r l s -- )
+  s head>> l head>> eq? [
+    l head>> s (>>head)
+    l head>> [ s rule>> add ] change-involved-set drop
+    r l s next>> (setup-lr)
+  ] unless ;
+
+:: setup-lr ( r l -- )
+  l head>> [
+    r V{ } clone V{ } clone <head> l (>>head)
+  ] unless
+  r l lrstack get (setup-lr) ;
+
+:: lr-answer ( r p m -- ast )
+  [let* |
+          h [ m ans>> head>> ]
+        |
+    h rule>> r eq? [
+      m ans>> seed>> m (>>ans)
+      m ans>> fail = [
+        fail
+      ] [
+        r p m h grow-lr
+      ] if
+    ] [
+      m ans>> seed>>
+    ] if
+  ] ; inline
+
+:: recall ( r p -- memo-entry )
+  [let* |
+          m [ p r memo ]
+          h [ p heads get at ]
+        |
+    h [
+      m r h involved-set>> h rule>> add member? not and [
+        fail p <memo-entry>
+      ] [
+        r h eval-set>> member? [
+          h [ r swap remove ] change-eval-set drop
+          r eval-rule
+          m (>>ans)
+          pos get m (>>pos)
+          m
+        ] [ 
+          m
+        ] if
+      ] if
+    ] [
+      m
+    ] if
+  ] ; inline
+
+:: apply-non-memo-rule ( r p -- ast )
+  [let* |
+          lr  [ fail r f lrstack get <left-recursion> ]
+          m   [ lr lrstack set lr p <memo-entry> dup p r set-memo ]
+          ans [ r eval-rule ]
+        |
+    lrstack get next>> lrstack set
+    pos get m (>>pos)
+    lr head>> [
+      ans lr (>>seed)
+      r p m lr-answer
+    ] [
+      ans m (>>ans)
+      ans
+    ] if
+  ] ; inline
+
+:: apply-memo-rule ( r m -- ast )
+  m pos>> pos set 
+  m ans>> left-recursion? [ 
+    r m ans>> setup-lr
+    m ans>> seed>>
+  ] [
+    m ans>>
+  ] if ;
+
+:: apply-rule ( r p -- ast )
+  [let* |
+          m [ r p recall ]
+        | 
+    m [
+      r m apply-memo-rule
+    ] [
+      r p apply-non-memo-rule
+    ] if 
+  ] ; inline
+
+: with-packrat ( input quot -- result )
+  #! Run the quotation with a packrat cache active.
+  swap [ 
+    input set
+    0 pos set
+    f lrstack set
+    H{ } clone heads set
+    H{ } clone packrat set
+  ] H{ } make-assoc swap bind ; inline
+
+
+GENERIC: (compile) ( parser -- quot )
+
+
+:: parser-body ( parser -- quot )
+  #! Return the body of the word that is the compiled version
+  #! of the parser.
+  [let* | rule [ parser (compile) define-temp dup parser "peg" set-word-prop ] 
+        |
+    [
+      rule pos get apply-rule dup fail = [ 
+        drop f 
+      ] [
+        input-slice swap <parse-result>
+      ] if
+    ] 
+  ] ;
+: compiled-parser ( parser -- word )
+  #! Look to see if the given parser has been compiled.
+  #! If not, compile it to a temporary word, cache it,
+  #! and return it. Otherwise return the existing one.
+  #! Circular parsers are supported by getting the word
+  #! name and storing it in the cache, before compiling, 
+  #! so it is picked up when re-entered.
+  dup compiled>> [
+    nip
+  ] [
+    gensym tuck >>compiled 2dup parser-body define dupd "peg" set-word-prop
+  ] if* ;
+
+: compile ( parser -- word )
+  [ compiled-parser ] with-compilation-unit ;
+
+: compiled-parse ( state word -- result )
+  swap [ execute ] with-packrat ; inline 
+
+: parse ( state parser -- result )
+  dup word? [ compile ] unless compiled-parse ;
+
 <PRIVATE
 
+SYMBOL: id 
+
+: next-id ( -- n )
+  #! Return the next unique id for a parser
+  id get-global [
+    dup 1+ id set-global
+  ] [
+    1 id set-global 0
+  ] if* ;
+
+: delegates ( -- cache )
+  \ delegates get-global [ H{ } clone dup \ delegates set-global ] unless* ;
+
+: reset-delegates ( -- )
+  H{ } clone \ delegates set-global ;
+
+reset-delegates 
+
+: init-parser ( parser -- parser )
+  #! Set the delegate for the parser. Equivalent parsers
+  #! get a delegate with the same id.
+  dup clone delegates [
+    drop next-id f <parser> 
+  ] cache over set-delegate ;
+
 TUPLE: token-parser symbol ;
 
 MATCH-VARS: ?token ;
 
-: token-pattern ( -- quot )
-  [
-    ?token 2dup head? [
-      dup >r length tail-slice r> <parse-result>
-    ] [
-      2drop f
-    ] if 
-  ] ;
-  
-M: token-parser compile ( parser -- quot )
-  token-parser-symbol \ ?token token-pattern match-replace ;
-      
+: parse-token ( input string -- result )
+  #! Parse the string, returning a parse result
+  2dup head? [
+    dup >r length tail-slice r> <parse-result>
+  ] [
+    2drop f
+  ] if ;
+
+M: token-parser (compile) ( parser -- quot )
+  [ \ input-slice , symbol>> , \ parse-token , ] [ ] make ;
+   
 TUPLE: satisfy-parser quot ;
 
 MATCH-VARS: ?quot ;
 
 : satisfy-pattern ( -- quot )
   [
-    dup empty? [
+    input-slice dup empty? [
       drop f 
     ] [
       unclip-slice dup ?quot call [  
@@ -53,8 +300,8 @@ MATCH-VARS: ?quot ;
     ] if 
   ] ;
 
-M: satisfy-parser compile ( parser -- quot )
-  satisfy-parser-quot \ ?quot satisfy-pattern match-replace ;
+M: satisfy-parser (compile) ( parser -- quot )
+  quot>> \ ?quot satisfy-pattern match-replace ;
 
 TUPLE: range-parser min max ;
 
@@ -62,7 +309,7 @@ MATCH-VARS: ?min ?max ;
 
 : range-pattern ( -- quot )
   [
-    dup empty? [
+    input-slice dup empty? [
       drop f
     ] [
       0 over nth dup 
@@ -74,7 +321,7 @@ MATCH-VARS: ?min ?max ;
     ] if 
   ] ;
 
-M: range-parser compile ( parser -- quot )
+M: range-parser (compile) ( parser -- quot )
   T{ range-parser _ ?min ?max } range-pattern match-replace ;
 
 TUPLE: seq-parser parsers ;
@@ -82,12 +329,12 @@ TUPLE: seq-parser parsers ;
 : seq-pattern ( -- quot )
   [
     dup [
-      dup parse-result-remaining ?quot call [
-        [ parse-result-remaining swap set-parse-result-remaining ] 2keep
-        parse-result-ast dup ignore = [ 
+      ?quot [
+        [ remaining>> swap (>>remaining) ] 2keep
+        ast>> dup ignore = [ 
           drop  
         ] [ 
-          swap [ parse-result-ast push ] keep 
+          swap [ ast>> push ] keep 
         ] if
       ] [
         drop f 
@@ -97,36 +344,31 @@ TUPLE: seq-parser parsers ;
     ] if  
   ] ;
 
-M: seq-parser compile ( parser -- quot )
+M: seq-parser (compile) ( parser -- quot )
   [
-    [ V{ } clone <parse-result> ] %
-    seq-parser-parsers [ compile \ ?quot seq-pattern match-replace % ] each 
+    [ input-slice V{ } clone <parse-result> ] %
+    parsers>> [ compiled-parser \ ?quot seq-pattern match-replace % ] each 
   ] [ ] make ;
 
 TUPLE: choice-parser parsers ;
 
 : choice-pattern ( -- quot )
   [
-    dup [
-          
-    ] [
-      drop dup ?quot call   
-    ] if
+    [ ?quot ] unless* 
   ] ;
 
-M: choice-parser compile ( parser -- quot )
-  [
+M: choice-parser (compile) ( parser -- quot )
+  [ 
     f ,
-    choice-parser-parsers [ compile \ ?quot choice-pattern match-replace % ] each
-    \ nip ,
+    parsers>> [ compiled-parser \ ?quot choice-pattern match-replace % ] each
   ] [ ] make ;
 
 TUPLE: repeat0-parser p1 ;
 
 : (repeat0) ( quot result -- result )
-  2dup parse-result-remaining swap call [
-    [ parse-result-remaining swap set-parse-result-remaining ] 2keep 
-    parse-result-ast swap [ parse-result-ast push ] keep
+  over call [
+    [ remaining>> swap (>>remaining) ] 2keep 
+    ast>> swap [ ast>> push ] keep
     (repeat0) 
  ] [
     nip
@@ -134,21 +376,21 @@ TUPLE: repeat0-parser p1 ;
 
 : repeat0-pattern ( -- quot )
   [
-    ?quot swap (repeat0) 
+    [ ?quot ] swap (repeat0) 
   ] ;
 
-M: repeat0-parser compile ( parser -- quot )
+M: repeat0-parser (compile) ( parser -- quot )
   [
-    [ V{ } clone <parse-result> ] %
-    repeat0-parser-p1 compile \ ?quot repeat0-pattern match-replace %        
+    [ input-slice V{ } clone <parse-result> ] %
+    p1>> compiled-parser \ ?quot repeat0-pattern match-replace %        
   ] [ ] make ;
 
 TUPLE: repeat1-parser p1 ;
 
 : repeat1-pattern ( -- quot )
   [
-    ?quot swap (repeat0) [
-      dup parse-result-ast empty? [
+    [ ?quot ] swap (repeat0) [
+      dup ast>> empty? [
         drop f
       ] when  
     ] [
@@ -156,49 +398,49 @@ TUPLE: repeat1-parser p1 ;
     ] if*
   ] ;
 
-M: repeat1-parser compile ( parser -- quot )
+M: repeat1-parser (compile) ( parser -- quot )
   [
-    [ V{ } clone <parse-result> ] %
-    repeat1-parser-p1 compile \ ?quot repeat1-pattern match-replace % 
+    [ input-slice V{ } clone <parse-result> ] %
+    p1>> compiled-parser \ ?quot repeat1-pattern match-replace % 
   ] [ ] make ;
 
 TUPLE: optional-parser p1 ;
 
 : optional-pattern ( -- quot )
   [
-    dup ?quot call swap f <parse-result> or 
+    ?quot [ input-slice f <parse-result> ] unless* 
   ] ;
 
-M: optional-parser compile ( parser -- quot )
-  optional-parser-p1 compile \ ?quot optional-pattern match-replace ;
+M: optional-parser (compile) ( parser -- quot )
+  p1>> compiled-parser \ ?quot optional-pattern match-replace ;
 
 TUPLE: ensure-parser p1 ;
 
 : ensure-pattern ( -- quot )
   [
-    dup ?quot call [
+    input-slice ?quot [
       ignore <parse-result>
     ] [
       drop f
     ] if
   ] ;
 
-M: ensure-parser compile ( parser -- quot )
-  ensure-parser-p1 compile \ ?quot ensure-pattern match-replace ;
+M: ensure-parser (compile) ( parser -- quot )
+  p1>> compiled-parser \ ?quot ensure-pattern match-replace ;
 
 TUPLE: ensure-not-parser p1 ;
 
 : ensure-not-pattern ( -- quot )
   [
-    dup ?quot call [
+    input-slice ?quot [
       drop f
     ] [
       ignore <parse-result>
     ] if
   ] ;
 
-M: ensure-not-parser compile ( parser -- quot )
-  ensure-not-parser-p1 compile \ ?quot ensure-not-pattern match-replace ;
+M: ensure-not-parser (compile) ( parser -- quot )
+  p1>> compiled-parser \ ?quot ensure-not-pattern match-replace ;
 
 TUPLE: action-parser p1 quot ;
 
@@ -206,14 +448,14 @@ MATCH-VARS: ?action ;
 
 : action-pattern ( -- quot )
   [
-    ?quot call dup [ 
-      dup parse-result-ast ?action call
-      swap [ set-parse-result-ast ] keep
+    ?quot dup [ 
+      dup ast>> ?action call
+      >>ast
     ] when 
   ] ;
 
-M: action-parser compile ( parser -- quot )
-  { action-parser-p1 action-parser-quot } get-slots [ compile ] dip 
+M: action-parser (compile) ( parser -- quot )
+  [ p1>> compiled-parser ] [ quot>> ] bi  
   2array { ?quot ?action } action-pattern match-replace ;
 
 : left-trim-slice ( string -- string )
@@ -225,31 +467,45 @@ M: action-parser compile ( parser -- quot )
 
 TUPLE: sp-parser p1 ;
 
-M: sp-parser compile ( parser -- quot )
+M: sp-parser (compile) ( parser -- quot )
   [
-    \ left-trim-slice , sp-parser-p1 compile % 
+    \ input-slice , \ left-trim-slice , \ input-from , \ pos , \ set , p1>> compiled-parser , 
   ] [ ] make ;
 
 TUPLE: delay-parser quot ;
 
-M: delay-parser compile ( parser -- quot )
+M: delay-parser (compile) ( parser -- quot )
+  #! For efficiency we memoize the quotation.
+  #! This way it is run only once and the 
+  #! parser constructed once at run time.
   [
-    delay-parser-quot % \ compile , \ call ,
-  ] [ ] make ;
+    quot>> % \ compile ,
+  ] [ ] make 
+  { } { "word" } <effect> memoize-quot 
+  [ % \ execute , ] [ ] make ;
+
+TUPLE: box-parser quot ;
+
+M: box-parser (compile) ( parser -- quot )
+  #! Calls the quotation at compile time
+  #! to produce the parser to be compiled.
+  #! This differs from 'delay' which calls
+  #! it at run time.
+  quot>> call compiled-parser 1quotation ;
 
 PRIVATE>
 
 : token ( string -- parser )
-  token-parser construct-boa ;      
+  token-parser construct-boa init-parser ;      
 
 : satisfy ( quot -- parser )
-  satisfy-parser construct-boa ;
+  satisfy-parser construct-boa init-parser ;
 
 : range ( min max -- parser )
-  range-parser construct-boa ;
+  range-parser construct-boa init-parser ;
 
 : seq ( seq -- parser )
-  seq-parser construct-boa ;
+  seq-parser construct-boa init-parser ;
 
 : 2seq ( parser1 parser2 -- parser )
   2array seq ;
@@ -264,7 +520,7 @@ PRIVATE>
   { } make seq ; inline 
 
 : choice ( seq -- parser )
-  choice-parser construct-boa ;
+  choice-parser construct-boa init-parser ;
 
 : 2choice ( parser1 parser2 -- parser )
   2array choice ;
@@ -279,36 +535,39 @@ PRIVATE>
   { } make choice ; inline 
 
 : repeat0 ( parser -- parser )
-  repeat0-parser construct-boa ;
+  repeat0-parser construct-boa init-parser ;
 
 : repeat1 ( parser -- parser )
-  repeat1-parser construct-boa ;
+  repeat1-parser construct-boa init-parser ;
 
 : optional ( parser -- parser )
-  optional-parser construct-boa ;
+  optional-parser construct-boa init-parser ;
 
 : ensure ( parser -- parser )
-  ensure-parser construct-boa ;
+  ensure-parser construct-boa init-parser ;
 
 : ensure-not ( parser -- parser )
-  ensure-not-parser construct-boa ;
+  ensure-not-parser construct-boa init-parser ;
 
 : action ( parser quot -- parser )
-  action-parser construct-boa ;
+  action-parser construct-boa init-parser ;
 
 : sp ( parser -- parser )
-  sp-parser construct-boa ;
+  sp-parser construct-boa init-parser ;
 
 : hide ( parser -- parser )
   [ drop ignore ] action ;
 
 : delay ( quot -- parser )
-  delay-parser construct-boa ;
+  delay-parser construct-boa init-parser ;
+
+: box ( quot -- parser )
+  box-parser construct-boa init-parser ;
 
 : PEG:
   (:) [
     [
-        call compile
+        call compile [ compiled-parse ] curry
         [ dup [ parse-result-ast ] [ "Parse failed" throw ] if ]
         append define
     ] with-compilation-unit
index f09643d290ec7dd64e77840a439994991d34bb7f..690fed9012eba2be2142849ea91bbf6a6da9c4e1 100644 (file)
@@ -31,7 +31,7 @@ IN: project-euler.009
 : abc ( p q -- triplet )
     [
         2dup * ,                    ! a = p * q
-        [ sq ] 2apply 2dup - 2 / ,  ! b = (p² - q²) / 2
+        [ sq ] bi@ 2dup - 2 / ,  ! b = (p² - q²) / 2
         + 2 / ,                     ! c = (p² + q²) / 2
     ] { } make natural-sort ;
 
index 02c5dbb9d36dd10e6b23dbac65df37ac4dc82910..32b1aa55498fbfc16e47e7a1ece2bf1fa8666582 100644 (file)
@@ -39,7 +39,7 @@ IN: project-euler.014
     dup even? [ 2 / ] [ 3 * 1+ ] if ;
 
 : longest ( seq seq -- seq )
-    2dup [ length ] 2apply > [ drop ] [ nip ] if ;
+    2dup [ length ] bi@ > [ drop ] [ nip ] if ;
 
 PRIVATE>
 
index 3ad1908aa69a1cd3158d2acc3cc2ceb6e8f5e12f..f1f546ec1c6036945e771a7b9a4dbcfa5707fcd9 100644 (file)
@@ -58,7 +58,7 @@ PRIVATE>
 
 : max-period ( seq -- elt n )
     dup [ period-length ] map dup supremum
-    over index [ swap nth ] curry 2apply ;
+    over index [ swap nth ] curry bi@ ;
 
 PRIVATE>
 
index 2bc7894684d53f86891a04cef5b20aa5d07d25d2..2d99204bf383454d1831e01260d492c23632911b 100644 (file)
@@ -60,7 +60,7 @@ IN: project-euler.027
 
 : max-consecutive ( seq -- elt n )
     dup [ first2 consecutive-primes ] map dup supremum
-    over index [ swap nth ] curry 2apply ;
+    over index [ swap nth ] curry bi@ ;
 
 PRIVATE>
 
index 6f29c3519e8f5f36c8afd253b5e839d6d0ff427c..35b1c87e7a26a933d3935833e25d3e983a08e5a0 100644 (file)
@@ -33,10 +33,10 @@ IN: project-euler.033
     10 99 [a,b] dup cartesian-product [ first2 < ] subset ;
 
 : safe? ( ax xb -- ? )
-    [ 10 /mod ] 2apply -roll = rot zero? not and nip ;
+    [ 10 /mod ] bi@ -roll = rot zero? not and nip ;
 
 : ax/xb ( ax xb -- z/f )
-    2dup safe? [ [ 10 /mod ] 2apply 2nip / ] [ 2drop f ] if ;
+    2dup safe? [ [ 10 /mod ] bi@ 2nip / ] [ 2drop f ] if ;
 
 : curious? ( m n -- ? )
     2dup / [ ax/xb ] dip = ;
index ed86f5a8c11cc534df00cfbd9ce5786eccf7d12c..9075b193241f91e1ddfa78b3bc8fd0bf22899557 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (c) 2008 Aaron Schaefer.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: arrays combinators.cleave combinators.lib kernel math math.ranges
+USING: arrays combinators.lib kernel math math.ranges
     namespaces project-euler.common sequences ;
 IN: project-euler.039
 
index 62e516e4b0969201a4f8cde2d7bc697a5ac9eb84..bc8aec8bded15a9c37ee02764df5f94c16cea2b3 100644 (file)
@@ -31,7 +31,7 @@ IN: project-euler.044
     dup 3 * 1- * 2 / ;
 
 : sum-and-diff? ( m n -- ? )
-    2dup + -rot - [ pentagonal? ] 2apply and ;
+    2dup + -rot - [ pentagonal? ] bi@ and ;
 
 PRIVATE>
 
index d9113ac67fc5709bfc00988ec043f3514e652859..453ebfa129a992d72952cb85630af2ecdd1a6162 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (c) 2008 Aaron Schaefer.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: arrays combinators.cleave combinators.lib kernel math math.ranges
+USING: arrays combinators.lib kernel math math.ranges
     namespaces project-euler.common sequences sequences.lib ;
 IN: project-euler.075
 
index 30c46de0a06d6bfc778d5b7c2c2ce3e7de7e79fe..b4cbd6dbcbcf45d7580307579e33358a6468fb6c 100644 (file)
@@ -35,7 +35,7 @@ IN: project-euler.079
     ] { } make ;
 
 : find-source ( seq -- elt )
-    dup values swap keys [ prune ] 2apply seq-diff
+    dup values swap keys [ prune ] bi@ seq-diff
     dup empty? [ "Topological sort failed" throw ] [ first ] if ;
 
 : remove-source ( seq elt -- seq )
index 04339ad5b7cff28848367aa1d697d2aebef4227d..9325e74d93f907b92f53b8177acd54f5f510d2ca 100644 (file)
@@ -31,7 +31,7 @@ IN: project-euler
 
 : solution-path ( n -- str/f )
     number>euler "project-euler." prepend
-    vocab where dup [ first ?resource-path ] when ;
+    vocab where dup [ first ] when ;
 
 PRIVATE>
 
index 163de69a59fe5d73b513a4a2f9a4b285464fb4a9..11f2e60d1ab7f64e8054d9bbcb6e9430f02bdb1a 100755 (executable)
@@ -54,7 +54,7 @@ IN: random-tester
     ] if ;
 
 : random-ratio ( -- ratio )
-    1000000000 dup [ random ] 2apply 1+ / 50% [ neg ] when dup [ drop random-ratio ] unless 10% [ drop 0 ] when ;
+    1000000000 dup [ random ] bi@ 1+ / 50% [ neg ] when dup [ drop random-ratio ] unless 10% [ drop 0 ] when ;
 
 : random-float ( -- float )
     50% [ random-ratio ] [ special-floats get random ] if
index 1e9e35d0bf73e63727bd7f317cb86f63a1b1c4af..476fc083a757f96d57f14d834aa64ad1fcbd0aea 100644 (file)
@@ -1,6 +1,6 @@
 
 USING: kernel namespaces arrays quotations sequences assocs combinators
-       mirrors math math.vectors random combinators.cleave macros bake ;
+       mirrors math math.vectors random macros bake ;
 
 IN: random-weighted
 
index 2e59b625b1d6814de3f4b7249c3128cee2b8117c..017ef402c016a5ef12f31d3060299573499bddcf 100755 (executable)
@@ -1,5 +1,5 @@
 USING: kernel math sequences namespaces
-math.miller-rabin combinators.cleave combinators.lib
+math.miller-rabin combinators.lib
 math.functions accessors random ;
 IN: random.blum-blum-shub
 
@@ -32,5 +32,5 @@ IN: crypto
     ! ! #! Cryptographically secure random number using Blum-Blum-Shub 256
     ! [ log2 1+ random-bits ] keep dupd >= [ -1 shift ] when ;
 
-M: blum-blum-shub random-32 ( bbs -- r )
+M: blum-blum-shub random-32* ( bbs -- r )
     ;
index 12607456ec7a49e13b5105a8296fbc9b4c45e26a..e0cb83c33030bec8d896f94f798ec904fa2409a2 100755 (executable)
@@ -1,4 +1,4 @@
-USING: kernel random math accessors  ;
+USING: kernel random math accessors random ;
 IN: random.dummy
 
 TUPLE: random-dummy i ;
@@ -7,5 +7,5 @@ C: <random-dummy> random-dummy
 M: random-dummy seed-random ( seed obj -- )
     (>>i) ;
 
-M: random-dummy random-32 ( obj -- r )
+M: random-dummy random-32* ( obj -- r )
     [ dup 1+ ] change-i drop ;
index 49bf4ad3f3297b0159515de1a37eb2ddcd3d72c8..703a0c16e4e1d5e6332b94e74f25e0afaf90f56f 100755 (executable)
@@ -16,11 +16,11 @@ IN: random.mersenne-twister.tests
 [ f ] [ 1234 [ make-100-randoms make-100-randoms = ] test-rng ] unit-test
 
 [ 1333075495 ] [
-    0 [ 1000 [ drop random-generator get random-32 drop ] each random-generator get random-32 ] test-rng
+    0 [ 1000 [ drop random-generator get random-32* drop ] each random-generator get random-32* ] test-rng
 ] unit-test
 
 [ 1575309035 ] [
-    0 [ 10000 [ drop random-generator get random-32 drop ] each random-generator get random-32 ] test-rng
+    0 [ 10000 [ drop random-generator get random-32* drop ] each random-generator get random-32* ] test-rng
 ] unit-test
 
 
index bf2ff78f2defce679c98c2fbd4ab763b5aac8073..ad9dae51ae6feb1506e589832fa4ea4ce36e7f69 100755 (executable)
@@ -4,14 +4,11 @@
 ! http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/MT2002/CODES/mt19937ar.c
 
 USING: arrays kernel math namespaces sequences system init
-accessors math.ranges combinators.cleave random ;
+accessors math.ranges new-effects random ;
 IN: random.mersenne-twister
 
 <PRIVATE
 
-: new-nth ( seq i -- elt ) swap nth ; inline
-: new-set-nth ( seq obj n -- seq ) pick set-nth ; inline
-
 TUPLE: mersenne-twister seq i ;
 
 : mt-n 624 ; inline
@@ -70,7 +67,7 @@ PRIVATE>
 M: mersenne-twister seed-random ( mt seed -- )
     init-mt-seq >>seq drop ;
 
-M: mersenne-twister random-32 ( mt -- r )
+M: mersenne-twister random-32* ( mt -- r )
     dup [ seq>> ] [ i>> ] bi
     dup mt-n < [ drop 0 pick mt-generate ] unless
     new-nth mt-temper
diff --git a/extra/random/random-docs.factor b/extra/random/random-docs.factor
new file mode 100644 (file)
index 0000000..a8a214d
--- /dev/null
@@ -0,0 +1,44 @@
+USING: help.markup help.syntax math ;
+IN: random
+
+ARTICLE: "random-numbers" "Generating random integers"
+"The " { $vocab-link "random" } " vocabulary implements the ``Mersenne Twister'' pseudo-random number generator algorithm."
+{ $subsection random } ;
+
+ABOUT: "random-numbers"
+
+HELP: seed-random
+{ $values { "tuple" "a random number generator" } { "seed" "an integer between 0 and 2^32-1" } }
+{ $description "Seed the random number generator." }
+{ $notes "Not supported on all random number generators." } ;
+
+HELP: random-32*
+{ $values { "tuple" "a random number generator" } { "r" "an integer between 0 and 2^32-1" } }
+{ $description "Generates a random 32-bit unsigned integer." } ;
+
+HELP: random-bytes*
+{ $values { "n" "an integer" } { "tuple" "a random number generator" } { "byte-array" "a sequence of random bytes" } }
+{ $description "Generates a byte-array of random bytes." } ;
+
+HELP: random
+{ $values { "seq" "a sequence" } { "elt" "a random element" } }
+{ $description "Outputs a random element of the sequence. If the sequence is empty, always outputs " { $link f } "." }
+{ $notes "Since integers are sequences, passing an integer " { $snippet "n" } " yields a random integer in the interval " { $snippet "[0,n)" } "." } ;
+
+HELP: random-bytes
+{ $values { "n" "an integer" } { "byte-array" "a random integer" } }
+{ $description "Outputs an integer with n bytes worth of bits." } ;
+
+HELP: random-bits
+{ $values { "n" "an integer" } { "r" "a random integer" } }
+{ $description "Outputs an random integer n bits in length." } ;
+
+HELP: with-random
+{ $values { "tuple" "a random generator" } { "quot" "a quotation" } }
+{ $description "Calls the quotation with the random generator in a dynamic variable.  All random numbers will be generated using this random generator." } ;
+
+HELP: with-secure-random
+{ $values { "quot" "a quotation" } }
+{ $description "Calls the quotation with the secure random generator in a dynamic variable.  All random numbers will be generated using this random generator." } ;
+
+{ with-random with-secure-random } related-words
diff --git a/extra/random/random-tests.factor b/extra/random/random-tests.factor
new file mode 100644 (file)
index 0000000..d85df3e
--- /dev/null
@@ -0,0 +1,8 @@
+USING: random sequences tools.test ;
+IN: random.tests
+
+[ 4 ] [ 4 random-bytes length ] unit-test
+[ 7 ] [ 7 random-bytes length ] unit-test
+
+[ 4 ] [ [ 4 random-bytes length ] with-secure-random ] unit-test
+[ 7 ] [ [ 7 random-bytes length ] with-secure-random ] unit-test
index 0d8b137fc5032674951815bac9d6672da823adb7..b1c57ede6008238932bde07c8aff91ad1818eb3d 100755 (executable)
@@ -1,26 +1,36 @@
 ! Copyright (C) 2008 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: alien.c-types kernel math namespaces sequences
-io.backend ;
+io.backend io.binary combinators system vocabs.loader
+inspector ;
 IN: random
 
-HOOK: os-crypto-random-bytes io-backend ( n -- byte-array )
-HOOK: os-random-bytes io-backend ( n -- byte-array )
-HOOK: os-crypto-random-32 io-backend ( -- r )
-HOOK: os-random-32 io-backend ( -- r )
+SYMBOL: insecure-random-generator
+SYMBOL: secure-random-generator
+SYMBOL: random-generator
 
 GENERIC: seed-random ( tuple seed -- )
-GENERIC: random-32 ( tuple -- r )
+GENERIC: random-32* ( tuple -- r )
+GENERIC: random-bytes* ( n tuple -- byte-array )
 
-: (random-bytes) ( tuple n -- byte-array )
-    [ drop random-32 ] with map >c-uint-array ;
+M: object random-bytes* ( n tuple -- byte-array )
+    swap [ drop random-32* ] with map >c-uint-array ;
 
-SYMBOL: random-generator
+M: object random-32* ( tuple -- r ) 4 random-bytes* le> ;
+
+ERROR: no-random-number-generator ;
+
+M: no-random-number-generator summary
+    drop "Random number generator is not defined." ;
 
-: random-bytes ( n -- r )
+M: f random-bytes* ( n obj -- * ) no-random-number-generator ;
+
+M: f random-32* ( obj -- * ) no-random-number-generator ;
+
+: random-bytes ( n -- byte-array )
     [
-        4 /mod zero? [ 1+ ] unless
-        random-generator get swap (random-bytes)
+        dup 4 rem zero? [ 1+ ] unless
+        random-generator get random-bytes*
     ] keep head ;
 
 : random ( seq -- elt )
@@ -37,3 +47,6 @@ SYMBOL: random-generator
 
 : with-random ( tuple quot -- )
     random-generator swap with-variable ; inline
+
+: with-secure-random ( quot -- )
+    >r secure-random-generator get r> with-random ; inline
index f41a3ae0e82cab429536e9f885b4aea0b68d54f9..51574887e3655d826810178eb7aaafd7f97fc689 100644 (file)
@@ -1,22 +1,21 @@
 USING: alien.c-types io io.files io.nonblocking kernel
-namespaces random io.encodings.binary singleton ;
+namespaces random io.encodings.binary singleton init
+accessors ;
 IN: random.unix
 
-SINGLETON: unix-random
+TUPLE: unix-random path ;
+
+C: <unix-random> unix-random
 
 : file-read-unbuffered ( n path -- bytes )
     over default-buffer-size [
         binary <file-reader> [ read ] with-stream
     ] with-variable ;
 
-M: unix-random os-crypto-random-bytes ( n -- byte-array )
-    "/dev/random" file-read-unbuffered ;
-
-M: unix-random os-random-bytes ( n -- byte-array )
-    "/dev/urandom" file-read-unbuffered ;
-
-M: unix-random os-crypto-random-32 ( -- r )
-    4 os-crypto-random-bytes *uint ;
+M: unix-random random-bytes* ( n tuple -- byte-array )
+    path>> file-read-unbuffered ;
 
-M: unix-random os-random-32 ( -- r )
-     4 os-random-bytes *uint ;
+[
+    "/dev/random" <unix-random> secure-random-generator set-global
+    "/dev/urandom" <unix-random> insecure-random-generator set-global
+] "random.unix" add-init-hook
index 8b3c1012c82e44111498557f994cbba9d116f257..65426d4277eddde6490d4c2fe1ac87e00e3719f3 100644 (file)
@@ -1,3 +1,54 @@
+USING: accessors alien.c-types byte-arrays continuations
+kernel windows windows.advapi32 init namespaces random
+destructors locals ;
+USE: tools.walker
 IN: random.windows
 
-! M: windows-io
+TUPLE: windows-rng provider type ;
+C: <windows-rng> windows-rng
+
+TUPLE: windows-crypto-context handle ;
+C: <windows-crypto-context> windows-crypto-context
+
+M: windows-crypto-context dispose ( tuple -- )
+    handle>> 0 CryptReleaseContext win32-error=0/f ;
+
+: factor-crypto-container ( -- string ) "FactorCryptoContainer" ; inline
+
+:: (acquire-crypto-context) ( provider type flags -- handle )
+    [let | handle [ "HCRYPTPROV" <c-object> ] |
+        handle
+        factor-crypto-container
+        provider
+        type
+        flags
+        CryptAcquireContextW win32-error=0/f
+        handle *void* ] ;
+
+: acquire-crypto-context ( provider type -- handle )
+    [ 0 (acquire-crypto-context) ]
+    [ drop CRYPT_NEWKEYSET (acquire-crypto-context) ] recover ;
+
+
+: windows-crypto-context ( provider type -- context )
+    acquire-crypto-context <windows-crypto-context> ;
+
+M: windows-rng random-bytes* ( n tuple -- bytes )
+    [
+        [ provider>> ] [ type>> ] bi
+        windows-crypto-context
+        dup add-always-destructor handle>>
+        swap dup <byte-array>
+        [ CryptGenRandom win32-error=0/f ] keep
+    ] with-destructors ;
+
+[
+    MS_DEF_PROV
+    PROV_RSA_FULL <windows-rng> insecure-random-generator set-global
+
+    MS_STRONG_PROV
+    PROV_RSA_FULL <windows-rng> secure-random-generator set-global
+
+    ! MS_ENH_RSA_AES_PROV
+    ! PROV_RSA_AES <windows-rng> secure-random-generator set-global
+] "random.windows" add-init-hook
index e20598d2eb41d8645963b1febea3f969268e097f..d818fb487ddd12248c06ad0c3e11c89673dbe4c1 100755 (executable)
@@ -1,6 +1,6 @@
 
 USING: kernel namespaces threads sequences calendar
-       combinators.cleave combinators.lib debugger ;
+       combinators.lib debugger ;
 
 IN: raptor.cron
 
index 684fecc6b8e4e515ec201ecff211d5ae137d29b8..436fb8580f632966e82254c0d43106ed923fc4be 100644 (file)
@@ -1,5 +1,5 @@
 
-USING: kernel namespaces threads arrays sequences combinators.cleave
+USING: kernel namespaces threads arrays sequences
        raptor raptor.cron ;
 
 IN: raptor
index 1bf9b2d4c740a305d82f68dc4d2b7a986ca5be43..d58e242d868f7c03ba8e406e95a48bae30cbfb08 100755 (executable)
@@ -1,6 +1,5 @@
 
-USING: kernel parser namespaces threads arrays sequences unix unix.process
-       combinators.cleave bake ;
+USING: kernel parser namespaces threads arrays sequences unix unix.process bake ;
 
 IN: raptor
 
index b57724d1dba64934cbbdfd74184c9d5738c4d78b..fa36a7c6f84751baabbcc5766e7d5462a2e48e68 100755 (executable)
@@ -16,7 +16,7 @@ SYMBOL: ignore-case?
 
 : char-between?-quot ( ch1 ch2 -- quot )
     ignore-case? get
-    [ [ ch>upper ] 2apply [ >r >r ch>upper r> r> between? ] ]
+    [ [ ch>upper ] bi@ [ >r >r ch>upper r> r> between? ] ]
     [ [ between? ] ]
     if 2curry ;
 
index e62eb76cb1e02d82ad8e517dacb5b0195710ba42..1f2bbde1712ee114b641dca74f6629f455c63c96 100644 (file)
@@ -16,7 +16,7 @@ SYMBOL: ignore-case?
     
 : char-between?-quot ( ch1 ch2 -- quot )
     ignore-case? get
-    [ [ ch>upper ] 2apply [ >r >r ch>upper r> r> between? ] ]
+    [ [ ch>upper ] bi@ [ >r >r ch>upper r> r> between? ] ]
     [ [ between? ] ]
     if 2curry ;
     
index f4b10a7d8166635333cad17585dbc39a2fcd2c37..7e9496c90d8298b45ed4d644dab3406dbf11c686 100755 (executable)
@@ -1,7 +1,7 @@
 USING: assocs math kernel shuffle combinators.lib\r
 words quotations arrays combinators sequences math.vectors\r
-io.styles combinators.cleave prettyprint vocabs sorting io\r
-generic locals.private math.statistics ;\r
+io.styles prettyprint vocabs sorting io generic locals.private\r
+math.statistics ;\r
 IN: reports.noise\r
 \r
 : badness ( word -- n )\r
@@ -9,7 +9,7 @@ IN: reports.noise
         { -nrot 5 }\r
         { -roll 4 }\r
         { -rot 3 }\r
-        { 2apply 1 }\r
+        { bi@ 1 }\r
         { 2curry 1 }\r
         { 2drop 1 }\r
         { 2dup 1 }\r
index 42e72dee456262a26e2e2ce01260860ae34ccdba..f38d1d808b6074345abefcdc9497ba25dc2475b4 100755 (executable)
@@ -1,6 +1,6 @@
 USING: assocs words sequences arrays compiler tools.time\r
 io.styles io prettyprint vocabs kernel sorting generator\r
-optimizer math combinators.cleave ;\r
+optimizer math ;\r
 IN: report.optimizer\r
 \r
 : count-optimization-passes ( nodes n -- n )\r
index 7466883c5f6dfc4cba771c828ab84519bc4954c6..a3e61dd8892eb1f8a768074c6e8a35993c606981 100644 (file)
@@ -23,7 +23,7 @@ TUPLE: roman-range-error n ;
     ] if ;
 
 : roman<= ( ch1 ch2 -- ? )
-    [ 1string roman-digits index ] 2apply >= ;
+    [ 1string roman-digits index ] bi@ >= ;
 
 : roman>n ( ch -- n )
     1string roman-digits index roman-values nth ;
@@ -57,7 +57,7 @@ PRIVATE>
 <PRIVATE
 
 : 2roman> ( str1 str2 -- m n )
-    [ roman> ] 2apply ;
+    [ roman> ] bi@ ;
 
 : binary-roman-op ( str1 str2 quot -- str3 )
     >r 2roman> r> call >roman ; inline
index 257133c67ff72e190978da421f0fdcb03053c3bf..c523053740e19e1ff85481eb72a1dff32c62da96 100644 (file)
@@ -60,7 +60,7 @@ test-db [
         "charlie" create-node* "charlie" set
         "gertrude" create-node* "gertrude" set
         [ t ] [ "adam" get "bob" get parent-child* integer? ] unit-test
-        { { "eve" "bob" } { "eve" "fran" } { "bob" "gertrude" } { "bob" "fran" } { "fran" "charlie" } } [ first2 [ get ] 2apply parent-child ] each
+        { { "eve" "bob" } { "eve" "fran" } { "bob" "gertrude" } { "bob" "fran" } { "fran" "charlie" } } [ first2 [ get ] bi@ parent-child ] each
         [ { "bob" "fran" } ] [ "eve" get children [ node-content ] map ] unit-test
         [ { "adam" "eve" } ] [ "bob" get parents [ node-content ] map ] unit-test
         [ "fran" { "charlie" } ] [ "fran" get get-node-hierarchy dup tree-id node-content swap tree-children [ tree-id node-content ] map ] unit-test
index 7bcc3369627b9e7a51534ea7e83cd47c19d4bc9b..ac247057f4fce9b07c6c060dbb9b306a9a15c709 100755 (executable)
@@ -7,12 +7,12 @@
 ! See http://factorcode.org/license.txt for BSD license.
 !
 USING: namespaces sequences kernel math io math.functions
-io.binary strings classes words sbufs tuples arrays vectors
-byte-arrays bit-arrays quotations hashtables assocs help.syntax
-help.markup float-arrays splitting io.streams.byte-array
-io.encodings.string io.encodings.utf8 io.encodings.binary
-combinators combinators.cleave accessors locals
-prettyprint compiler.units sequences.private tuples.private ;
+io.binary strings classes words sbufs classes.tuple arrays
+vectors byte-arrays bit-arrays quotations hashtables assocs
+help.syntax help.markup float-arrays splitting
+io.streams.byte-array io.encodings.string io.encodings.utf8
+io.encodings.binary combinators accessors locals prettyprint
+compiler.units sequences.private classes.tuple.private ;
 IN: serialize
 
 ! Variable holding a assoc of objects already serialized
@@ -24,7 +24,7 @@ C: <id> id
 
 M: id hashcode* obj>> hashcode* ;
 
-M: id equal? over id? [ [ obj>> ] 2apply eq? ] [ 2drop f ] if ;
+M: id equal? over id? [ [ obj>> ] bi@ eq? ] [ 2drop f ] if ;
 
 : add-object ( obj -- )
     #! Add an object to the sequence of already serialized
@@ -269,7 +269,7 @@ SYMBOL: deserialized
     [ ] tri ;
 
 : copy-seq-to-tuple ( seq tuple -- )
-    >r dup length [ 1+ ] map r> [ set-array-nth ] curry 2each ;
+    >r dup length r> [ set-array-nth ] curry 2each ;
 
 : deserialize-tuple ( -- array )
     #! Ugly because we have to intern the tuple before reading
index 172db1def137e57a6e693822e949bc0a00a0373c..b11668a53e541078ddca0c160dc314d5a3cc9142 100644 (file)
@@ -20,7 +20,7 @@ IN: shufflers
 
 : put-effect ( word -- )
     dup word-name "-" split1
-    [ >array [ 1string ] map ] 2apply
+    [ >array [ 1string ] map ] bi@
     <effect> "declared-effect" set-word-prop ;
 
 : in-shuffle ( -- ) in get ".shuffle" append set-in ;
index 0b77443a50745a1fe9f63ef88c182d2791289a64..9ec9f2f4a32c719f000f8964a38e024c4451d740 100755 (executable)
@@ -5,8 +5,9 @@ sequences words ;
 IN: singleton
 
 : define-singleton ( token -- )
-    \ word swap create-class-in
-    dup [ eq? ] curry define-predicate-class ;
+    create-class-in
+    \ word
+    over [ eq? ] curry define-predicate-class ;
 
 : SINGLETON:
     scan define-singleton ; parsing
index bc50ecb1d460d726adf801c9f900c65761bb0ea1..3a1af786e220ff643e12f41665d778707f567be9 100644 (file)
@@ -1,6 +1,6 @@
 
 USING: kernel combinators sequences arrays math math.vectors
-       combinators.cleave shuffle vars ;
+       shuffle vars ;
 
 IN: springies
 
index fc5fee5c0159f4a37996b335dbf9f684bfd413b6..bebe813925831245de54d727daf8e5ad76bab54f 100644 (file)
@@ -1,5 +1,5 @@
 
-USING: kernel namespaces threads sequences math math.vectors combinators.cleave
+USING: kernel namespaces threads sequences math math.vectors
        opengl.gl opengl colors ui ui.gadgets ui.gadgets.slate
        bake rewrite-closures vars springies ;
 
index db5fb75617693ae3588020472e6d2e962191e40b..764c4d92f0271f0d3e1ffa0b25026fddee79347e 100644 (file)
@@ -18,7 +18,7 @@ SYMBOL: board
 : cell-contains? ( n x y i -- ? ) 3 /mod pair+ board> = ;
 
 : box-contains? ( n x y -- ? )
-    [ 3 /i 3 * ] 2apply
+    [ 3 /i 3 * ] bi@
     9 [ >r 3dup r> cell-contains? ] contains?
     >r 3drop r> ;
 
index d1c4b148a5e606dcf3e9a0eb35296f3f48809ce9..99af06b80ff5a42a2567c6f15c049b19b90a51fd 100755 (executable)
@@ -35,7 +35,7 @@ linkname magic version uname gname devmajor devminor prefix ;
 
 : header-checksum ( seq -- x )
     148 cut-slice 8 tail-slice
-    [ sum ] 2apply + 256 + ;
+    [ sum ] bi@ + 256 + ;
 
 TUPLE: checksum-error ;
 TUPLE: malformed-block-error ;
index e44c3c401e554723caef6f0f98851bc23e184eaa..16bde2100f059fe693eee31bf653e0a98ab7784a 100755 (executable)
@@ -40,7 +40,7 @@ unicode.categories ;
 
 : score ( full fuzzy -- n )
     dup [
-        [ [ length ] 2apply - 15 swap [-] 3 /f ] 2keep
+        [ [ length ] bi@ - 15 swap [-] 3 /f ] 2keep
         runs [
             [ 0 [ pick score-1 max ] reduce nip ] keep
             length * +
@@ -57,7 +57,7 @@ unicode.categories ;
 
 : complete ( full short -- score )
     [ dupd fuzzy score ] 2keep
-    [ <reversed> ] 2apply
+    [ <reversed> ] bi@
     dupd fuzzy score max ;
 
 : completion ( short candidate -- result )
index 172a80b612abdcec46e98abe3b9ba142f6887105..b019326ed5dbc1bac60fe60eed960a17768db18d 100755 (executable)
@@ -21,6 +21,7 @@ IN: tools.deploy.backend
         swap >>command
         +stdout+ >>stderr
         +closed+ >>stdin
+        +low-priority+ >>priority
     utf8 <process-stream>
     dup copy-lines
     process>> wait-for-process zero? [
index 8db34320de91afe06d815ef22c60d96fab96db9a..f104fb0210310e3b79bb6ac625f7e51ffa55123d 100755 (executable)
@@ -1,10 +1,11 @@
 IN: tools.deploy.tests\r
 USING: tools.test system io.files kernel tools.deploy.config\r
 tools.deploy.backend math sequences io.launcher arrays\r
-namespaces ;\r
+namespaces continuations layouts ;\r
 \r
 : shake-and-bake ( vocab -- )\r
-    "." resource-path [\r
+    [ "test.image" temp-file delete-file ] ignore-errors\r
+    "resource:" [\r
         >r vm\r
         "test.image" temp-file\r
         r> dup deploy-config make-deploy-image\r
@@ -16,7 +17,7 @@ namespaces ;
 [ ] [ "hello-world" shake-and-bake ] unit-test\r
 \r
 [ t ] [\r
-    500000 small-enough?\r
+    cell 8 = 8 5 ? 100000 * small-enough?\r
 ] unit-test\r
 \r
 [ ] [ "sudoku" shake-and-bake ] unit-test\r
index 9fe35647fe1a7034d1e19c243f9e6bb38b21a121..6d9c8e9d8abf8f205324a5dd785a537455e96856 100755 (executable)
@@ -62,11 +62,12 @@ T{ macosx-deploy-implementation } deploy-implementation set-global
 
 M: macosx-deploy-implementation deploy* ( vocab -- )
     ".app deploy tool" assert.app
-    "." resource-path cd
-    dup deploy-config [
-        bundle-name dup exists? [ delete-tree ] [ drop ] if
-        [ bundle-name create-app-dir ] keep
-        [ bundle-name deploy.app-image ] keep
-        namespace make-deploy-image
-        bundle-name show-in-finder
-    ] bind ;
+    "resource:" [
+        dup deploy-config [
+            bundle-name dup exists? [ delete-tree ] [ drop ] if
+            [ bundle-name create-app-dir ] keep
+            [ bundle-name deploy.app-image ] keep
+            namespace make-deploy-image
+            bundle-name show-in-finder
+        ] bind
+    ] with-directory ;
index 76e4a212b209a0d62ac0e007a346ce9f0ee14a76..ee9c2b9fab1cb21f95db282c336aa73ad2e89374 100755 (executable)
@@ -81,7 +81,7 @@ IN: tools.deploy.shaker
     [
         "class" ,
         "metaclass" ,
-        "slot-names" ,
+        "layout" ,
         deploy-ui? get [
             "gestures" ,
             "commands" ,
@@ -139,27 +139,28 @@ IN: tools.deploy.shaker
             { } { "cpu" } strip-vocab-globals %
 
             {
-                vocabs:dictionary
-                lexer-factory
-                vocabs:load-vocab-hook
-                root-cache
+                classes:class-and-cache
+                classes:class-not-cache
+                classes:class-or-cache
+                classes:class<-cache
+                classes:classes-intersect-cache
+                classes:update-map
+                compiled-crossref
+                compiler.units:recompile-hook
+                definitions:crossref
+                interactive-vocabs
                 layouts:num-tags
                 layouts:num-types
                 layouts:tag-mask
                 layouts:tag-numbers
                 layouts:type-numbers
-                classes:typemap
-                classes:class-map
+                lexer-factory
+                listener:listener-hook
+                root-cache
                 vocab-roots
-                definitions:crossref
-                compiled-crossref
-                interactive-vocabs
+                vocabs:dictionary
+                vocabs:load-vocab-hook
                 word
-                compiler.units:recompile-hook
-                listener:listener-hook
-                lexer-factory
-                classes:update-map
-                classes:class<map
             } %
         ] when
 
index b37e42f323943c29ecc78d2aaca598e457ea6e3b..de8f8740f06f4e8b4798fbd3d76bff72762da31f 100755 (executable)
@@ -14,7 +14,7 @@ global [
 
     sent-messages get
     super-sent-messages get
-    [ keys [ objc-methods get at dup ] H{ } map>assoc ] 2apply
+    [ keys [ objc-methods get at dup ] H{ } map>assoc ] bi@
     super-message-senders [ intersect ] change
     message-senders [ intersect ] change
 
index 443e82f7d903d6af6ea8b322ee5bd81bac93eeb3..2f07f4ede519c641214c162bb8c208fa67940fde 100755 (executable)
@@ -3,6 +3,6 @@ USING: io.encodings.ascii io.files kernel ;
 \r
 : deploy-test-3\r
     "resource:extra/tools/deploy/test/3/3.factor"\r
-    ?resource-path ascii file-contents drop ;\r
+    ascii file-contents drop ;\r
 \r
 MAIN: deploy-test-3\r
index 9983db7d00053432803f7ad9bd172ba126f1d3be..782f244c6874d9560755f5b0787461a45dc6738a 100755 (executable)
@@ -1,5 +1,5 @@
 IN: tools.disassembler.tests\r
-USING: math tuples prettyprint.backend tools.disassembler\r
+USING: math classes.tuple prettyprint.backend tools.disassembler\r
 tools.test strings ;\r
 \r
 [ ] [ \ + disassemble ] unit-test\r
index b086b30a5edcf5433cdb066845939bcab4e24c93..d7610c21c8940adb9b1254c5f135e58771837697 100755 (executable)
@@ -8,12 +8,12 @@ IN: tools.vocabs
 \r
 : vocab-tests-file ( vocab -- path )\r
     dup "-tests.factor" vocab-dir+ vocab-append-path dup\r
-    [ dup resource-exists? [ drop f ] unless ] [ drop f ] if ;\r
+    [ dup exists? [ drop f ] unless ] [ drop f ] if ;\r
 \r
 : vocab-tests-dir ( vocab -- paths )\r
     dup vocab-dir "tests" append-path vocab-append-path dup [\r
-        dup resource-exists? [\r
-            dup ?resource-path directory keys\r
+        dup exists? [\r
+            dup directory keys\r
             [ ".factor" tail? ] subset\r
             [ append-path ] with map\r
         ] [ drop f ] if\r
@@ -34,7 +34,7 @@ IN: tools.vocabs
 \r
 : source-modified? ( path -- ? )\r
     dup source-files get at [\r
-        dup source-file-path ?resource-path\r
+        dup source-file-path\r
         dup exists? [\r
             utf8 file-lines lines-crc32\r
             swap source-file-checksum = not\r
@@ -42,7 +42,7 @@ IN: tools.vocabs
             2drop f\r
         ] if\r
     ] [\r
-        resource-exists?\r
+        exists?\r
     ] ?if ;\r
 \r
 : modified ( seq quot -- seq )\r
@@ -104,15 +104,14 @@ SYMBOL: sources-changed?
     "" refresh f sources-changed? set-global ;\r
 \r
 MEMO: (vocab-file-contents) ( path -- lines )\r
-    ?resource-path dup exists?\r
-    [ utf8 file-lines ] [ drop f ] if ;\r
+    dup exists? [ utf8 file-lines ] [ drop f ] if ;\r
 \r
 : vocab-file-contents ( vocab name -- seq )\r
     vocab-append-path dup [ (vocab-file-contents) ] when ;\r
 \r
 : set-vocab-file-contents ( seq vocab name -- )\r
     dupd vocab-append-path [\r
-        ?resource-path utf8 set-file-lines\r
+        utf8 set-file-lines\r
         \ (vocab-file-contents) reset-memoized\r
     ] [\r
         "The " swap vocab-name\r
@@ -171,7 +170,7 @@ M: vocab-link summary vocab-summary ;
     directory [ second ] subset keys natural-sort ;\r
 \r
 : (all-child-vocabs) ( root name -- vocabs )\r
-    [ vocab-dir append-path ?resource-path subdirs ] keep\r
+    [ vocab-dir append-path subdirs ] keep\r
     dup empty? [\r
         drop\r
     ] [\r
@@ -207,7 +206,7 @@ MEMO: all-vocabs-seq ( -- seq )
         { [ "editors." ?head ] [ t ] }\r
         { [ ".windows" ?tail ] [ t ] }\r
         { [ ".unix" ?tail ] [ t ] }\r
-        { [ "unix." ?head ] [ t ] }\r
+        { [ "unix" ?head ] [ t ] }\r
         { [ ".linux" ?tail ] [ t ] }\r
         { [ ".bsd" ?tail ] [ t ] }\r
         { [ ".macosx" ?tail ] [ t ] }\r
index 6ef530921475246226b5bc14cfe8e1c11b0a357c..2aed793a593b3ca2df50220e47309e41d83596ad 100755 (executable)
@@ -3,7 +3,7 @@
 USING: threads kernel namespaces continuations combinators
 sequences math namespaces.private continuations.private
 concurrency.messaging quotations kernel.private words
-sequences.private assocs models combinators.cleave ;
+sequences.private assocs models ;
 IN: tools.walker
 
 SYMBOL: show-walker-hook ! ( status continuation thread -- )
index 061deec6ecf5fba82a70476fc173df88e3b519b9..b9593af23918db273b529355092bf8db36db2cbe 100644 (file)
@@ -1,6 +1,7 @@
 ! Copyright (C) 2007 Daniel Ehrenberg.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: splitting tuples classes math kernel sequences arrays ;
+USING: splitting classes.tuple classes math kernel sequences
+arrays ;
 IN: tuple-arrays
 
 TUPLE: tuple-array example ;
index 2f0ba6bde548b685d1df1240e266990750368a01..2419b8febb8e70a1d55644e67e41a596b62fa371 100755 (executable)
@@ -1,22 +1,18 @@
 USING: kernel sequences slots parser words classes
-slots.private ;
+slots.private mirrors ;
 IN: tuple-syntax
 
 ! TUPLE: foo bar baz ;
 ! TUPLE{ foo bar: 1 baz: 2 }
 
-: parse-object ( -- object )
-    scan-word dup parsing? [ V{ } clone swap execute first ] when ;
-
 : parse-slot-writer ( tuple -- slot# )
     scan dup "}" = [ 2drop f ] [
-        1 head* swap class "slots" word-prop
-        [ slot-spec-name = ] with find nip slot-spec-offset
+        1 head* swap object-slots slot-named slot-spec-offset
     ] if ;
 
 : parse-slots ( accum tuple -- accum tuple )
     dup parse-slot-writer
-    [ parse-object pick rot set-slot parse-slots ] when* ;
+    [ scan-object pick rot set-slot parse-slots ] when* ;
 
 : TUPLE{
     scan-word construct-empty parse-slots parsed ; parsing
diff --git a/extra/tuples/lib/authors.txt b/extra/tuples/lib/authors.txt
deleted file mode 100644 (file)
index 7c1b2f2..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Doug Coleman
diff --git a/extra/tuples/lib/lib-docs.factor b/extra/tuples/lib/lib-docs.factor
deleted file mode 100644 (file)
index 75df155..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-USING: help.syntax help.markup kernel prettyprint sequences ;
-IN: tuples.lib
-
-HELP: >tuple<
-{ $values { "class" "a tuple class" } }
-{ $description "Explodes the tuple so that tuple slots are on the stack in the order listed in the tuple." }
-{ $example
-    "USING: kernel prettyprint tuples.lib ;"
-    "TUPLE: foo a b c ;"
-    "1 2 3 \\ foo construct-boa \\ foo >tuple< .s"
-    "1\n2\n3"
-}
-{ $notes "Words using " { $snippet ">tuple<" } " may be compiled." }
-{ $see-also >tuple*< } ;
-
-HELP: >tuple*<
-{ $values { "class" "a tuple class" } }
-{ $description "Explodes the tuple so that tuple slots ending with '*' are on the stack in the order listed in the tuple." }
-{ $example
-    "USING: kernel prettyprint tuples.lib ;"
-    "TUPLE: foo a bb* ccc dddd* ;"
-    "1 2 3 4 \\ foo construct-boa \\ foo >tuple*< .s"
-    "2\n4"
-}
-{ $notes "Words using " { $snippet ">tuple*<" } " may be compiled." }
-{ $see-also >tuple< } ;
-
diff --git a/extra/tuples/lib/lib-tests.factor b/extra/tuples/lib/lib-tests.factor
deleted file mode 100644 (file)
index 5d90f25..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-USING: kernel tools.test tuples.lib ;
-IN: tuples.lib.tests
-
-TUPLE: foo a b* c d* e f* ;
-
-[ 1 2 3 4 5 6 ] [ 1 2 3 4 5 6 \ foo construct-boa \ foo >tuple< ] unit-test
-[ 2 4 6 ] [ 1 2 3 4 5 6 \ foo construct-boa \ foo >tuple*< ] unit-test
-
diff --git a/extra/tuples/lib/lib.factor b/extra/tuples/lib/lib.factor
deleted file mode 100644 (file)
index 5075c1d..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-! Copyright (C) 2007 Doug Coleman.
-! See http://factorcode.org/license.txt for BSD license.
-USING: kernel macros sequences slots words ;
-IN: tuples.lib
-
-: reader-slots ( seq -- quot )
-    [ slot-spec-reader ] map [ get-slots ] curry ;
-
-MACRO: >tuple< ( class -- )
-    "slots" word-prop 1 tail-slice reader-slots ;
-
-MACRO: >tuple*< ( class -- )
-    "slots" word-prop
-    [ slot-spec-name "*" tail? ] subset
-    reader-slots ;
-
-
index dbb838a5c5ae88a5cf1f9e309b34a777492277e7..f73276bbe6de5dfba6c79403a3a076e94e614270 100755 (executable)
@@ -9,7 +9,7 @@ SYMBOL: +nullary+
 SYMBOL: +listener+
 SYMBOL: +description+
 
-PREDICATE: word listener-command +listener+ word-prop ;
+PREDICATE: listener-command < word +listener+ word-prop ;
 
 GENERIC: invoke-command ( target command -- )
 
index e9527e6f9a7dfe8e4fc94990f95a3b02b6151f00..1963f5670a171ebfe5fe174c84e41f6dd7536294 100755 (executable)
@@ -62,7 +62,7 @@ M: freetype-renderer free-fonts ( world -- )
     } at ;
 
 : ttf-path ( name -- string )
-    "/fonts/" swap ".ttf" 3append resource-path ;
+    "resource:fonts/" swap ".ttf" 3append ;
 
 : (open-face) ( path length -- face )
     #! We use FT_New_Memory_Face, not FT_New_Face, since
index e58ba343c7b62a3050ff8aa843910f5571c89ed4..6b548aaf68982f37ea5adc59214a1511050decb9 100644 (file)
@@ -24,7 +24,7 @@ M: border pref-dim*
     <rect> ;
 
 : scale-rect ( rect vec -- loc dim )
-    [ v* ] curry >r rect-bounds r> 2apply ;
+    [ v* ] curry >r rect-bounds r> bi@ ;
 
 : average-rects ( rect1 rect2 weight -- rect )
     tuck >r >r scale-rect r> r> { 1 1 } swap v- scale-rect
index defd5aa38ab44ec27a84e8352f6b32a4269a993a..7e649b7ff7969e6088bb427720b5a17435f772b9 100755 (executable)
@@ -4,8 +4,8 @@ USING: arrays ui.commands ui.gadgets ui.gadgets.borders
 ui.gadgets.labels ui.gadgets.theme
 ui.gadgets.tracks ui.gadgets.packs ui.gadgets.worlds ui.gestures
 ui.render kernel math models namespaces sequences strings
-quotations assocs combinators classes colors tuples opengl
-math.vectors ;
+quotations assocs combinators classes colors classes.tuple
+opengl math.vectors ;
 IN: ui.gadgets.buttons
 
 TUPLE: button pressed? selected? quot ;
index a1fb95cdbff84df6b5c6a6e1ade5058952321fb9..15df44fda4fdf0a5834ac8ddd6359c8ad4f1c549 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: ui.backend ui.gadgets ui.gadgets.theme ui.gadgets.lib
 ui.gadgets.worlds ui.render opengl opengl.gl kernel namespaces
-tuples colors ;
+classes.tuple colors ;
 IN: ui.gadgets.canvas
 
 TUPLE: canvas dlist ;
index def6b99b0547274fd41a13fcc1702dcae67e9367..b3ecad6aedb22ad3b1c4c3dcb0454e23fb0378d3 100755 (executable)
@@ -135,7 +135,7 @@ M: editor ungraft*
         dup editor-caret-color gl-color
         dup caret-loc origin get v+
         swap caret-dim over v+
-        [ { 0.5 -0.5 } v+ ] 2apply gl-line
+        [ { 0.5 -0.5 } v+ ] bi@ gl-line
     ] when ;
 
 : line-translation ( n -- loc )
index 6005b35cb932cd967d3c49f36d54d23e3fa8e9ca..c593358841c5698067a21c03cdc55d1d0150dbaf 100755 (executable)
@@ -1,5 +1,5 @@
 USING: help.syntax help.markup ui.gadgets kernel arrays
-quotations tuples ui.gadgets.grids ;
+quotations classes.tuple ui.gadgets.grids ;
 IN: ui.gadgets.frames
 
 : $ui-frame-constant ( element -- )
index 30f6a26d008909ebe455a262fabcd5e44ae07e38..018d1f1f861d3e959ecb160374dba1d6b6233f5e 100755 (executable)
@@ -1,5 +1,5 @@
 USING: help.markup help.syntax opengl kernel strings
-tuples classes quotations models ;
+classes.tuple classes quotations models ;
 IN: ui.gadgets
 
 HELP: rect
index 267f6f0f0f615cca2358feb416004232f5c6c917..ddcaa4b979554012ec11a147a2bb36070c64053d 100755 (executable)
@@ -22,7 +22,7 @@ M: array rect-dim drop { 0 0 } ;
 : rect-extent ( rect -- loc ext ) rect-bounds over v+ ;
 
 : 2rect-extent ( rect rect -- loc1 loc2 ext1 ext2 )
-    [ rect-extent ] 2apply swapd ;
+    [ rect-extent ] bi@ swapd ;
 
 : <extent-rect> ( loc ext -- rect ) over [v-] <rect> ;
 
index 0792d55135f7b40d3b062976cb08fc28e1a8c2c2..f20275ff2581bc2c293d976f7ebe33aff8beaaf8 100644 (file)
@@ -25,13 +25,13 @@ IN: ui.gadgets.grids.tests
 [ { 100 200 } ] [
     100x100
     100x100
-    [ 1array ] 2apply 2array <grid> pref-dim
+    [ 1array ] bi@ 2array <grid> pref-dim
 ] unit-test
 
 [ ] [
     100x100
     100x100
-    [ 1array ] 2apply 2array <grid> layout
+    [ 1array ] bi@ 2array <grid> layout
 ] unit-test
 
 [ { 230 120 } { 100 100 } { 100 100 } ] [
index 0231aef4d03c424fc84dd52305c9e21a83353286..d3f4339a87d0bacbdc9d782fd9796f82edb52f8c 100755 (executable)
@@ -4,7 +4,8 @@ USING: arrays ui.gadgets.buttons ui.gadgets.borders
 ui.gadgets.labels ui.gadgets.panes ui.gadgets.scrollers
 ui.gadgets.tracks ui.gadgets.theme ui.gadgets.frames
 ui.gadgets.grids io kernel math models namespaces prettyprint
-sequences sequences words tuples ui.gadgets ui.render colors ;
+sequences sequences words classes.tuple ui.gadgets ui.render
+colors ;
 IN: ui.gadgets.labelled
 
 TUPLE: labelled-gadget content ;
index 3bac7969c506789d6271fb8440fd6968f845230f..9213c3886ff060d49e288d43a8f093784e9bded8 100755 (executable)
@@ -4,7 +4,7 @@ USING: ui.commands ui.gestures ui.render ui.gadgets
 ui.gadgets.labels ui.gadgets.scrollers
 kernel sequences models opengl math namespaces
 ui.gadgets.presentations ui.gadgets.viewports ui.gadgets.packs
-math.vectors tuples ;
+math.vectors classes.tuple ;
 IN: ui.gadgets.lists
 
 TUPLE: list index presenter color hook ;
index 55404c0eceeb11833bbb2c21c10bed08cc4d07e6..e80e5b58894937f0fc97be31512533bfbe01a792 100755 (executable)
@@ -1,5 +1,5 @@
-USING: ui.gadgets help.markup help.syntax generic kernel tuples
-quotations ;
+USING: ui.gadgets help.markup help.syntax generic kernel
+classes.tuple quotations ;
 IN: ui.gadgets.packs
 
 HELP: pack
index dde312b34dcf10a6180b64f18f34561b266dfd86..52c5ca8a026de990685befd4cb3431b8143e396d 100755 (executable)
@@ -8,7 +8,7 @@ hashtables io kernel namespaces sequences io.styles strings
 quotations math opengl combinators math.vectors
 io.streams.duplex sorting splitting io.streams.nested assocs
 ui.gadgets.presentations ui.gadgets.slots ui.gadgets.grids
-ui.gadgets.grid-lines tuples models continuations ;
+ui.gadgets.grid-lines classes.tuple models continuations ;
 IN: ui.gadgets.panes
 
 TUPLE: pane output current prototype scrolls?
index 46f274d53a6f7977f11912cf63ff43289f5411f0..55ba2604e859b1e5113fd3683018bf0ed9d6f80e 100644 (file)
@@ -1,7 +1,7 @@
 IN: ui.gadgets.presentations.tests
 USING: math ui.gadgets.presentations ui.gadgets tools.test
 prettyprint ui.gadgets.buttons io io.streams.string kernel
-tuples ;
+classes.tuple ;
 
 [ t ] [
     "Hi" \ + <presentation> [ gadget? ] is?
index 98951b74e34db351aa4a11c7fb9792d5a26553ea..d4a189589438e520b91bc81f138ca04505af5a1e 100755 (executable)
@@ -3,13 +3,14 @@
 USING: arrays ui.gadgets
 ui.gadgets.viewports ui.gadgets.frames ui.gadgets.grids
 ui.gadgets.theme ui.gadgets.sliders ui.gestures kernel math
-namespaces sequences models combinators math.vectors ;
+namespaces sequences models combinators math.vectors
+classes.tuple ;
 IN: ui.gadgets.scrollers
 
 TUPLE: scroller viewport x y follows ;
 
 : find-scroller ( gadget -- scroller/f )
-    [ scroller? ] find-parent ;
+    [ [ scroller? ] is? ] find-parent ;
 
 : scroll-up-page scroller-y -1 swap slide-by-page ;
 
@@ -56,7 +57,7 @@ scroller H{
     2dup control-value = [ 2drop ] [ set-control-value ] if ;
 
 : rect-min ( rect1 rect2 -- rect )
-    >r [ rect-loc ] keep r> [ rect-dim ] 2apply vmin <rect> ;
+    >r [ rect-loc ] keep r> [ rect-dim ] bi@ vmin <rect> ;
 
 : (scroll>rect) ( rect scroller -- )
     [
index 967e8a29a107b3a086ea0f4ed754475e62f4d365..f10996135d230c6dd01ec3b305c7cd11aa153439 100755 (executable)
@@ -1,5 +1,5 @@
 USING: ui.gadgets.packs help.markup help.syntax ui.gadgets
-arrays kernel quotations tuples ;
+arrays kernel quotations classes.tuple ;
 IN: ui.gadgets.tracks
 
 HELP: track
index 574b71c44dd66164828dcd3897e8a727d18d75ac..412a61bcb55a690294e58cf8bd12566d35eb0ddc 100755 (executable)
@@ -2,7 +2,8 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: arrays assocs kernel math models namespaces
 sequences words strings system hashtables math.parser
-math.vectors tuples classes ui.gadgets combinators.lib boxes
+math.vectors classes.tuple classes ui.gadgets combinators.lib
+boxes
 calendar alarms symbols ;
 IN: ui.gestures
 
old mode 100644 (file)
new mode 100755 (executable)
index 45cd773..a9009e3
@@ -19,7 +19,7 @@ TUPLE: operation predicate command translator hook listener? ;
         set-operation-hook
     } operation construct ;
 
-PREDICATE: operation listener-operation
+PREDICATE: listener-operation < operation
     dup operation-command listener-command?
     swap operation-listener? or ;
 
index 9e43460aa9bc26392151659021e18e0a9109a2a8..06fc3c87a0c2778254ba87d76d121dac0a6761b6 100755 (executable)
@@ -4,7 +4,7 @@ USING: arrays assocs combinators continuations documents
  hashtables io io.styles kernel math
 math.vectors models namespaces parser prettyprint quotations
 sequences sequences.lib strings threads listener
-tuples ui.commands ui.gadgets ui.gadgets.editors
+classes.tuple ui.commands ui.gadgets ui.gadgets.editors
 ui.gadgets.presentations ui.gadgets.worlds ui.gestures
 definitions boxes calendar concurrency.flags ui.tools.workspace ;
 IN: ui.tools.interactor
index 75401b3861052aa50b054cec79d2eb58b0e829dc..7db0d63f45da367723fdcb8c622d91c06ca2b159 100755 (executable)
@@ -6,7 +6,8 @@ kernel models namespaces parser quotations sequences ui.commands
 ui.gadgets ui.gadgets.editors ui.gadgets.labelled
 ui.gadgets.panes ui.gadgets.buttons ui.gadgets.scrollers
 ui.gadgets.tracks ui.gestures ui.operations vocabs words
-prettyprint listener debugger threads boxes concurrency.flags ;
+prettyprint listener debugger threads boxes concurrency.flags
+math arrays ;
 IN: ui.tools.listener
 
 TUPLE: listener-gadget input output stack ;
@@ -23,9 +24,19 @@ TUPLE: listener-gadget input output stack ;
 : <listener-input> ( listener -- gadget )
     listener-gadget-output <pane-stream> <interactor> ;
 
+TUPLE: input-scroller ;
+
+: <input-scroller> ( interactor -- scroller )
+    <scroller>
+    input-scroller construct-empty
+    [ set-gadget-delegate ] keep ;
+
+M: input-scroller pref-dim*
+    drop { 0 100 } ;
+
 : listener-input, ( -- )
     g <listener-input> g-> set-listener-gadget-input
-    <scroller> "Input" <labelled-gadget> f track, ;
+    <input-scroller> "Input" <labelled-gadget> f track, ;
 
 : welcome. ( -- )
    "If this is your first time with Factor, please read the " print
index 45ac64539262e6b684cf2bbcd86b143605d5d2c4..23697bbf3facb299834b30afcfdf713a2bb4f6bc 100755 (executable)
@@ -4,7 +4,7 @@ USING: assocs ui.tools.interactor ui.tools.listener
 ui.tools.workspace help help.topics io.files io.styles kernel
 models namespaces prettyprint quotations sequences sorting
 source-files definitions strings tools.completion tools.crossref
-tuples ui.commands ui.gadgets ui.gadgets.editors
+classes.tuple ui.commands ui.gadgets ui.gadgets.editors
 ui.gadgets.lists ui.gadgets.scrollers ui.gadgets.tracks
 ui.gestures ui.operations vocabs words vocabs.loader
 tools.vocabs unicode.case calendar ui ;
index a9fe38a14c558307eb274c0243429d94150ffdbc..dbd2ce15ac2299aecc6bc4c4055e83779ca43a56 100755 (executable)
@@ -4,7 +4,7 @@ USING: kernel concurrency.messaging inspector ui.tools.listener
 ui.tools.traceback ui.gadgets.buttons ui.gadgets.status-bar
 ui.gadgets.tracks ui.commands ui.gadgets models
 ui.tools.workspace ui.gestures ui.gadgets.labels ui threads
-namespaces tools.walker assocs combinators combinators.cleave ;
+namespaces tools.walker assocs combinators ;
 IN: ui.tools.walker
 
 TUPLE: walker-gadget
index 158a48a1c098d0a275918ba3978779fd94584544..eaf87acaceb71d323f85f02f9b23c0e0c36810c7 100755 (executable)
@@ -5,7 +5,7 @@ ui.backend ui.clipboards ui.gadgets.worlds assocs kernel math
 namespaces opengl sequences strings x11.xlib x11.events x11.xim
 x11.glx x11.clipboard x11.constants x11.windows io.encodings.string
 io.encodings.utf8 combinators debugger system command-line
-ui.render math.vectors tuples opengl.gl threads ;
+ui.render math.vectors classes.tuple opengl.gl threads ;
 IN: ui.x11
 
 TUPLE: x11-ui-backend ;
index dfc7bf2264eb1f1d9eb6327d3b27a7fa8d2ed85f..4c8c6491cabd6c32e66da124ba702b97da683b40 100644 (file)
@@ -26,7 +26,7 @@ CATEGORY: grapheme-control Zl Zp Cc Cf ;
 : process-other-extend ( lines -- set )
     [ "#" split1 drop ";" split1 drop trim-blank ] map
     [ empty? not ] subset
-    [ ".." split1 [ dup ] unless* [ hex> ] 2apply [a,b] ] map
+    [ ".." split1 [ dup ] unless* [ hex> ] bi@ [a,b] ] map
     concat >set ;
 
 : other-extend-lines ( -- lines )
@@ -83,7 +83,7 @@ VALUE: grapheme-table
     grapheme-table nth nth not ;
 
 : chars ( i str n -- str[i] str[i+n] )
-    swap >r dupd + r> [ ?nth ] curry 2apply ;
+    swap >r dupd + r> [ ?nth ] curry bi@ ;
 
 : find-index ( seq quot -- i ) find drop ; inline
 : find-last-index ( seq quot -- i ) find-last drop ; inline
index 8129ec17f81071f7e0b1dbbfefb576e617edc259..092a2472048d3e611f75713761cf79120b4dd0cf 100755 (executable)
@@ -100,7 +100,7 @@ SYMBOL: locale ! Just casing locale, or overall?
     >upper >lower ;
 
 : insensitive= ( str1 str2 -- ? )
-    [ >case-fold ] 2apply = ;
+    [ >case-fold ] bi@ = ;
 
 : lower? ( string -- ? )
     dup >lower = ;
index 47637e83301c3a235a98da2813ba70fd09a7cd7b..d62beb1a2cc0498c7680cb74978ebe0dad7b6627 100644 (file)
@@ -38,7 +38,7 @@ IN: unicode.normalize
 
 : (insert) ( seq n quot -- )
     over 0 = [ 3drop ] [
-        [ >r dup 1- rot [ nth ] curry 2apply r> 2apply > ] 3keep
+        [ >r dup 1- rot [ nth ] curry bi@ r> bi@ > ] 3keep
         roll [ 3drop ]
         [ >r [ dup 1- rot exchange ] 2keep 1- r> (insert) ] if
     ] if ; inline
index bd3fd4ae2af60dbda71d1d127049d62ab37c79d5..4dc91a73c2327c5d48313223d860e6932bae3518 100755 (executable)
@@ -35,7 +35,7 @@ IN: unicode.syntax
     ] [ ] make ;
 
 : define-category ( word categories -- )
-    [category] fixnum -rot define-predicate-class ;
+    [category] integer swap define-predicate-class ;
 
 : CATEGORY:
     CREATE ";" parse-tokens define-category ; parsing
index 9f0e70415761711a4412355897acf3b2fb777605..9b450ed18bd7f1d4750f4b0feb36beda9f4f0838 100755 (executable)
@@ -15,9 +15,7 @@ IN: units.tests
 [ t ] [ 1 m 2 m 3 m 3array d-product 6 m^3 = ] unit-test
 [ t ] [ 3 m d-recip 1/3 { } { m } <dimensioned> = ] unit-test
 
-! I want these to work, Dan
-
 : km/L km 1 L d/ ;
 : mpg miles 1 gallons d/ ;
 
-[ t ] [ 100 10 / km/L [ mpg ] undo 23 1 ~ ] unit-test
+[ t ] [ 100 10 / km/L [ mpg ] undo 23 1 ~ ] unit-test
index 13d0a5d1cf6318ac588eba71dd17d7b203320c51..cf53ceaee3dde0bb4208c8bb7ab5a89cf770ab78 100755 (executable)
@@ -16,7 +16,7 @@ M: dimensions-not-equal summary drop "Dimensions do not match" ;
     1array split1 append ;
 
 : 2remove-one ( seq seq obj -- seq seq )
-    [ remove-one ] curry 2apply ;
+    [ remove-one ] curry bi@ ;
 
 : symbolic-reduce ( seq seq -- seq seq )
     2dup seq-intersect dup empty?
@@ -24,7 +24,7 @@ M: dimensions-not-equal summary drop "Dimensions do not match" ;
 
 : <dimensioned> ( n top bot -- obj )
     symbolic-reduce
-    [ natural-sort ] 2apply
+    [ natural-sort ] bi@
     dimensioned construct-boa ;
 
 : >dimensioned< ( d -- n top bot )
@@ -37,10 +37,10 @@ M: dimensions-not-equal summary drop "Dimensions do not match" ;
     { dimensioned-top dimensioned-bot } get-slots ;
 
 : check-dimensions ( d d -- )
-    [ dimensions 2array ] 2apply =
+    [ dimensions 2array ] bi@ =
     [ dimensions-not-equal ] unless ;
 
-: 2values [ dimensioned-value ] 2apply ;
+: 2values [ dimensioned-value ] bi@ ;
 
 : <dimension-op
     2dup check-dimensions dup dimensions 2swap 2values ;
@@ -56,9 +56,9 @@ M: dimensions-not-equal summary drop "Dimensions do not match" ;
     { } { } <dimensioned> ;
 
 : d* ( d d -- d )
-    [ dup number? [ scalar ] when ] 2apply
-    [ [ dimensioned-top ] 2apply append ] 2keep
-    [ [ dimensioned-bot ] 2apply append ] 2keep
+    [ dup number? [ scalar ] when ] bi@
+    [ [ dimensioned-top ] bi@ append ] 2keep
+    [ [ dimensioned-bot ] bi@ append ] 2keep
     2values * dimension-op> ;
 
 : d-neg ( d -- d ) -1 d* ;
@@ -95,3 +95,9 @@ M: dimensions-not-equal summary drop "Dimensions do not match" ;
 : d-infimum ( v -- d ) unclip-slice [ d-min ] reduce ;
 
 : d-supremum ( v -- d ) unclip-slice [ d-max ] reduce ;
+
+\ d+ [ d- ] [ d- ] define-math-inverse
+\ d- [ d+ ] [ d- ] define-math-inverse
+\ d* [ d/ ] [ d/ ] define-math-inverse
+\ d/ [ d* ] [ d/ ] define-math-inverse
+\ d-recip [ d-recip ] define-inverse
index e652f1b9f9ad5a9c61ae9225e1e166601dbe213d..cb7b347c20487407855a2aa5b515a33dd2a7ea0e 100755 (executable)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2005, 2006 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
+USING: alien.syntax combinators system vocabs.loader ;
 IN: unix
-USING: alien.syntax ;
 
 ! FreeBSD
 
@@ -15,8 +15,6 @@ USING: alien.syntax ;
 : O_TRUNC   HEX: 0400 ; inline
 : O_EXCL    HEX: 0800 ; inline
 
-: FD_SETSIZE 1024 ; inline
-
 : SOL_SOCKET HEX: ffff ; inline
 : SO_REUSEADDR HEX: 4 ; inline
 : SO_OOBINLINE HEX: 100 ; inline
@@ -83,3 +81,10 @@ C-STRUCT: sockaddr-un
 : SEEK_SET 0 ; inline
 : SEEK_CUR 1 ; inline
 : SEEK_END 2 ; inline
+
+os {
+    { "macosx"  [ "unix.bsd.macosx"  require ] }
+    { "freebsd" [ "unix.bsd.freebsd" require ] }
+    { "openbsd" [ "unix.bsd.openbsd" require ] }
+    { "netbsd"  [ "unix.bsd.netbsd"  require ] }
+} case
diff --git a/extra/unix/bsd/freebsd/freebsd.factor b/extra/unix/bsd/freebsd/freebsd.factor
new file mode 100644 (file)
index 0000000..94bb708
--- /dev/null
@@ -0,0 +1,3 @@
+IN: unix
+
+: FD_SETSIZE 1024 ;
diff --git a/extra/unix/bsd/macosx/macosx.factor b/extra/unix/bsd/macosx/macosx.factor
new file mode 100644 (file)
index 0000000..3c0617a
--- /dev/null
@@ -0,0 +1,3 @@
+IN: unix
+
+: FD_SETSIZE 1024 ; inline
diff --git a/extra/unix/bsd/netbsd/netbsd.factor b/extra/unix/bsd/netbsd/netbsd.factor
new file mode 100644 (file)
index 0000000..ac18749
--- /dev/null
@@ -0,0 +1,3 @@
+IN: unix
+
+: FD_SETSIZE 256 ; inline
diff --git a/extra/unix/bsd/openbsd/openbsd.factor b/extra/unix/bsd/openbsd/openbsd.factor
new file mode 100644 (file)
index 0000000..3c0617a
--- /dev/null
@@ -0,0 +1,3 @@
+IN: unix
+
+: FD_SETSIZE 1024 ; inline
diff --git a/extra/unix/kqueue/freebsd/freebsd.factor b/extra/unix/kqueue/freebsd/freebsd.factor
new file mode 100644 (file)
index 0000000..edddae2
--- /dev/null
@@ -0,0 +1,23 @@
+USE: alien.syntax
+IN: unix.kqueue
+
+C-STRUCT: kevent
+    { "ulong"  "ident"  } ! identifier for this event
+    { "short"  "filter" } ! filter for event
+    { "ushort" "flags"  } ! action flags for kqueue
+    { "uint"   "fflags" } ! filter flag value
+    { "long"   "data"   } ! filter data value
+    { "void*"  "udata"  } ! opaque user data identifier
+;
+
+FUNCTION: int kevent ( int kq, kevent* changelist, int nchanges, kevent* eventlist, int nevents, timespec* timeout ) ;
+
+: EVFILT_READ     -1 ; inline
+: EVFILT_WRITE    -2 ; inline
+: EVFILT_AIO      -3 ; inline ! attached to aio requests
+: EVFILT_VNODE    -4 ; inline ! attached to vnodes
+: EVFILT_PROC     -5 ; inline ! attached to struct proc
+: EVFILT_SIGNAL   -6 ; inline ! attached to struct proc
+: EVFILT_TIMER    -7 ; inline ! timers
+: EVFILT_NETDEV   -8 ; inline ! Mach ports
+: EVFILT_FS       -9 ; inline ! Filesystem events
index 4e6504470d8c1dd2bf62038abdb79a94c0fde6f8..55b53bd6d0105411d0335b677607369c6df02a9a 100644 (file)
@@ -1,30 +1,11 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: alien.syntax ;
+USING: alien.syntax system sequences vocabs.loader ;
 IN: unix.kqueue
 
-FUNCTION: int kqueue ( ) ;
-
-FUNCTION: int kevent ( int kq, kevent* changelist, int nchanges, kevent* eventlist, int nevents, timespec* timeout ) ;
+<< "unix.kqueue." os append require >>
 
-C-STRUCT: kevent
-    { "ulong"  "ident"  } ! identifier for this event
-    { "short"  "filter" } ! filter for event
-    { "ushort" "flags"  } ! action flags for kqueue
-    { "uint"   "fflags" } ! filter flag value
-    { "long"   "data"   } ! filter data value
-    { "void*"  "udata"  } ! opaque user data identifier
-;
-
-: EVFILT_READ     -1 ; inline
-: EVFILT_WRITE    -2 ; inline
-: EVFILT_AIO      -3 ; inline ! attached to aio requests
-: EVFILT_VNODE    -4 ; inline ! attached to vnodes
-: EVFILT_PROC     -5 ; inline ! attached to struct proc
-: EVFILT_SIGNAL   -6 ; inline ! attached to struct proc
-: EVFILT_TIMER    -7 ; inline ! timers
-: EVFILT_MACHPORT -8 ; inline ! Mach ports
-: EVFILT_FS       -9 ; inline ! Filesystem events
+FUNCTION: int kqueue ( ) ;
 
 ! actions
 : EV_ADD     HEX: 1 ; inline ! add event to kq (implies enable)
diff --git a/extra/unix/kqueue/macosx/macosx.factor b/extra/unix/kqueue/macosx/macosx.factor
new file mode 100644 (file)
index 0000000..7dc2a79
--- /dev/null
@@ -0,0 +1,23 @@
+USE: alien.syntax
+IN: unix.kqueue
+
+C-STRUCT: kevent
+    { "ulong"  "ident"  } ! identifier for this event
+    { "short"  "filter" } ! filter for event
+    { "ushort" "flags"  } ! action flags for kqueue
+    { "uint"   "fflags" } ! filter flag value
+    { "long"   "data"   } ! filter data value
+    { "void*"  "udata"  } ! opaque user data identifier
+;
+
+FUNCTION: int kevent ( int kq, kevent* changelist, int nchanges, kevent* eventlist, int nevents, timespec* timeout ) ;
+
+: EVFILT_READ     -1 ; inline
+: EVFILT_WRITE    -2 ; inline
+: EVFILT_AIO      -3 ; inline ! attached to aio requests
+: EVFILT_VNODE    -4 ; inline ! attached to vnodes
+: EVFILT_PROC     -5 ; inline ! attached to struct proc
+: EVFILT_SIGNAL   -6 ; inline ! attached to struct proc
+: EVFILT_TIMER    -7 ; inline ! timers
+: EVFILT_MACHPORT -8 ; inline ! Mach ports
+: EVFILT_FS       -9 ; inline ! Filesystem events
diff --git a/extra/unix/kqueue/netbsd/netbsd.factor b/extra/unix/kqueue/netbsd/netbsd.factor
new file mode 100644 (file)
index 0000000..e3fc11a
--- /dev/null
@@ -0,0 +1,22 @@
+USE: alien.syntax
+IN: unix.kqueue
+
+C-STRUCT: kevent
+    { "ulong"    "ident"  } ! identifier for this event
+    { "uint"     "filter" } ! filter for event
+    { "uint"     "flags"  } ! action flags for kqueue
+    { "uint"     "fflags" } ! filter flag value
+    { "longlong" "data"   } ! filter data value
+    { "void*"    "udata"  } ! opaque user data identifier
+;
+
+FUNCTION: int kevent ( int kq, kevent* changelist, size_t nchanges, kevent* eventlist, size_t nevents, timespec* timeout ) ;
+
+: EVFILT_READ     0 ; inline
+: EVFILT_WRITE    1 ; inline
+: EVFILT_AIO      2 ; inline ! attached to aio requests
+: EVFILT_VNODE    3 ; inline ! attached to vnodes
+: EVFILT_PROC     4 ; inline ! attached to struct proc
+: EVFILT_SIGNAL   5 ; inline ! attached to struct proc
+: EVFILT_TIMER    6 ; inline ! timers
+: EVFILT_SYSCOUNT 7 ; inline ! Filesystem events
diff --git a/extra/unix/kqueue/openbsd/openbsd.factor b/extra/unix/kqueue/openbsd/openbsd.factor
new file mode 100644 (file)
index 0000000..bc4be88
--- /dev/null
@@ -0,0 +1,21 @@
+USE: alien.syntax
+IN: unix.kqueue
+
+C-STRUCT: kevent
+    { "uint"   "ident"  } ! identifier for this event
+    { "short"  "filter" } ! filter for event
+    { "ushort" "flags"  } ! action flags for kqueue
+    { "uint"   "fflags" } ! filter flag value
+    { "int"    "data"   } ! filter data value
+    { "void*"  "udata"  } ! opaque user data identifier
+;
+
+FUNCTION: int kevent ( int kq, kevent* changelist, int nchanges, kevent* eventlist, int nevents, timespec* timeout ) ;
+
+: EVFILT_READ     -1 ; inline
+: EVFILT_WRITE    -2 ; inline
+: EVFILT_AIO      -3 ; inline ! attached to aio requests
+: EVFILT_VNODE    -4 ; inline ! attached to vnodes
+: EVFILT_PROC     -5 ; inline ! attached to struct proc
+: EVFILT_SIGNAL   -6 ; inline ! attached to struct proc
+: EVFILT_TIMER    -7 ; inline ! timers
index 6fdc8e358bb67c282de67e8d9f9bdbe2b7f0b9ff..fc8103b6568b46a3c3b42c77fecff92b73c0d4a1 100755 (executable)
@@ -1,5 +1,5 @@
 USING: kernel alien.c-types sequences math unix
-combinators.cleave vectors kernel namespaces continuations
+vectors kernel namespaces continuations
 threads assocs vectors io.unix.backend ;
 
 IN: unix.process
@@ -33,4 +33,7 @@ IN: unix.process
     fork dup io-error dup zero? -roll swap curry if ; inline
 
 : wait-for-pid ( pid -- status )
-    0 <int> [ 0 waitpid drop ] keep *int WEXITSTATUS ;
\ No newline at end of file
+    0 <int> [ 0 waitpid drop ] keep *int WEXITSTATUS ;
+
+: set-priority ( n -- )
+    0 0 rot setpriority io-error ;
\ No newline at end of file
index be6ad1e3fc8d85a94d176e95d119e727aa2688f8..a374551385f025a0ccc1c7e350a4a8e4637cb837 100644 (file)
@@ -27,5 +27,5 @@ C-STRUCT: stat
 FUNCTION: int __xstat  ( int ver, char* pathname, stat* buf ) ;
 FUNCTION: int __lxstat ( int ver, char* pathname, stat* buf ) ;
 
-:  stat ( pathname buf -- int ) 3 -rot __xstat ;
-: lstat ( pathname buf -- int ) 3 -rot __lxstat ;
\ No newline at end of file
+:  stat ( pathname buf -- int ) 1 -rot __xstat ;
+: lstat ( pathname buf -- int ) 1 -rot __lxstat ;
diff --git a/extra/unix/stat/netbsd/32/32.factor b/extra/unix/stat/netbsd/32/32.factor
new file mode 100644 (file)
index 0000000..d4b39a9
--- /dev/null
@@ -0,0 +1,29 @@
+USING: kernel alien.syntax math ;
+IN: unix.stat
+
+! NetBSD 4.0
+
+C-STRUCT: stat
+    { "dev_t" "st_dev" }
+    { "mode_t" "st_mode" }
+    { "ino_t" "st_ino" }
+    { "nlink_t" "st_nlink" }
+    { "uid_t" "st_uid" }
+    { "gid_t" "st_gid" }
+    { "dev_t" "st_rdev" }
+    { "timespec" "st_atim" }
+    { "timespec" "st_mtim" }
+    { "timespec" "st_ctim" }
+    { "timespec" "st_birthtim" }
+    { "off_t" "st_size" }
+    { "blkcnt_t" "st_blocks" }
+    { "blksize_t" "st_blksize" }
+    { "uint32_t" "st_flags" }
+    { "uint32_t" "st_gen" }
+    { { "uint32_t" 2 } "st_qspare" } ;
+
+FUNCTION: int __stat30  ( char* pathname, stat* buf ) ;
+FUNCTION: int __lstat30 ( char* pathname, stat* buf ) ;
+
+: stat __stat30 ;
+: lstat __lstat30 ;
diff --git a/extra/unix/stat/netbsd/64/64.factor b/extra/unix/stat/netbsd/64/64.factor
new file mode 100644 (file)
index 0000000..46ab43e
--- /dev/null
@@ -0,0 +1,29 @@
+USING: kernel alien.syntax math ;
+IN: unix.stat
+
+! NetBSD 4.0
+
+C-STRUCT: stat
+    { "dev_t" "st_dev" }
+    { "ino_t" "st_ino" }
+    { "mode_t" "st_mode" }
+    { "nlink_t" "st_nlink" }
+    { "uid_t" "st_uid" }
+    { "gid_t" "st_gid" }
+    { "dev_t" "st_rdev" }
+    { "timespec" "st_atim" }
+    { "timespec" "st_mtim" }
+    { "timespec" "st_ctim" }
+    { "off_t" "st_size" }
+    { "blkcnt_t" "st_blocks" }
+    { "blksize_t" "st_blksize" }
+    { "uint32_t" "st_flags" }
+    { "uint32_t" "st_gen" }
+    { "uint32_t" "st_spare0" }
+    { "timespec" "st_birthtim" } ;
+
+FUNCTION: int __stat13 ( char* pathname, stat* buf ) ;
+FUNCTION: int __lstat13 ( char* pathname, stat* buf ) ;
+
+: stat __stat13 ; inline
+: lstat __lstat13 ; inline
index bb2df6d6d35a58841e42a6b4d780100ee8a6ae0f..8057e5939b587d27e56eb24615a34113bf9b74dd 100644 (file)
@@ -1,26 +1,7 @@
-USING: kernel alien.syntax math ;
+USING: layouts combinators vocabs.loader ;
 IN: unix.stat
 
-! NetBSD 4.0
-
-C-STRUCT: stat
-    { "dev_t" "st_dev" }
-    { "mode_t" "st_mode" }
-    { "ino_t" "st_ino" }
-    { "nlink_t" "st_nlink" }
-    { "uid_t" "st_uid" }
-    { "gid_t" "st_gid" }
-    { "dev_t" "st_rdev" }
-    { "timespec" "st_atim" }
-    { "timespec" "st_mtim" }
-    { "timespec" "st_ctim" }
-    { "timespec" "st_birthtim" }
-    { "off_t" "st_size" }
-    { "blkcnt_t" "st_blocks" }
-    { "blksize_t" "st_blksize" }
-    { "uint32_t" "st_flags" }
-    { "uint32_t" "st_gen" }
-    { { "uint32_t" 2 } "st_qspare" } ;
-
-FUNCTION: int stat  ( char* pathname, stat* buf ) ;
-FUNCTION: int lstat ( char* pathname, stat* buf ) ;
+cell-bits {
+    { 32 [ "unix.stat.netbsd.32" require ] }
+    { 64 [ "unix.stat.netbsd.64" require ] }
+} case
diff --git a/extra/unix/types/netbsd/32/32.factor b/extra/unix/types/netbsd/32/32.factor
new file mode 100755 (executable)
index 0000000..892626c
--- /dev/null
@@ -0,0 +1,6 @@
+USING: alien.syntax ;
+IN: unix.types
+
+! NetBSD 4.0
+
+TYPEDEF: __uint64_t     ino_t
diff --git a/extra/unix/types/netbsd/64/64.factor b/extra/unix/types/netbsd/64/64.factor
new file mode 100755 (executable)
index 0000000..e475bd4
--- /dev/null
@@ -0,0 +1,6 @@
+USING: alien.syntax ;
+IN: unix.types
+
+! NetBSD 4.0
+
+TYPEDEF: __uint32_t     ino_t
index 77636a6d6dd3cec1c032cc10be3a883d16c0a383..5b54928d95a32b04a58eb6304bbf9c7931abeb29 100755 (executable)
@@ -1,4 +1,4 @@
-USING: alien.syntax ;
+USING: alien.syntax combinators layouts vocabs.loader ;
 IN: unix.types
 
 ! NetBSD 4.0
@@ -18,7 +18,6 @@ TYPEDEF: ulonglong      u_int64_t
 
 TYPEDEF: __uint32_t     __dev_t
 TYPEDEF: __uint32_t     dev_t
-TYPEDEF: __uint64_t     ino_t
 TYPEDEF: __uint32_t     mode_t
 TYPEDEF: __uint32_t     nlink_t
 TYPEDEF: __uint32_t     uid_t
@@ -26,7 +25,12 @@ TYPEDEF: __uint32_t     gid_t
 TYPEDEF: __int64_t      off_t
 TYPEDEF: __int64_t      blkcnt_t
 TYPEDEF: __uint32_t     blksize_t
-TYPEDEF: __uint32_t     fflags_t
-TYPEDEF: int            ssize_t
+TYPEDEF: long           ssize_t
 TYPEDEF: int            pid_t
 TYPEDEF: int            time_t
+
+cell-bits {
+    { 32 [ "unix.types.netbsd.32" require ] }
+    { 64 [ "unix.types.netbsd.64" require ] }
+} case
+
index 09d77fee1121797c23022d33b124a07d2ea99e86..bed87ebd0fb9aa78b6c6582df7ed873c221d38c6 100755 (executable)
@@ -102,6 +102,17 @@ FUNCTION: int utimes ( char* path, timeval[2] times ) ;
 
 FUNCTION: int kill ( pid_t pid, int sig ) ;
 
+: PRIO_PROCESS 0 ; inline
+: PRIO_PGRP 1 ; inline
+: PRIO_USER 2 ; inline
+
+: PRIO_MIN -20 ; inline
+: PRIO_MAX 20 ; inline
+
+! which/who = 0 for current process
+FUNCTION: int getpriority ( int which, int who ) ;
+FUNCTION: int setpriority ( int which, int who, int prio ) ;
+
 ! Flags for waitpid
 
 : WNOHANG   1 ; inline
@@ -149,6 +160,5 @@ FUNCTION: ssize_t write ( int fd, void* buf, size_t nbytes ) ;
     { [ linux? ] [ "unix.linux" require ] }
     { [ bsd? ] [ "unix.bsd" require ] }
     { [ solaris? ] [ "unix.solaris" require ] }
-    { [ t ] [ ] }
 } cond
 
index d3413b5695e2792824a341b8a6994a98921d52dc..28091d3d9db64feb7d578fe7fb12084d2f23915c 100644 (file)
-USING: alien.syntax kernel math windows.types math.bitfields ;\r
-IN: windows.advapi32\r
-LIBRARY: advapi32\r
-\r
-! : I_ScGetCurrentGroupStateW ;\r
-! : A_SHAFinal ;\r
-! : A_SHAInit ;\r
-! : A_SHAUpdate ;\r
-! : AbortSystemShutdownA ;\r
-! : AbortSystemShutdownW ;\r
-! : AccessCheck ;\r
-! : AccessCheckAndAuditAlarmA ;\r
-! : AccessCheckAndAuditAlarmW ;\r
-! : AccessCheckByType ;\r
-! : AccessCheckByTypeAndAuditAlarmA ;\r
-! : AccessCheckByTypeAndAuditAlarmW ;\r
-! : AccessCheckByTypeResultList ;\r
-! : AccessCheckByTypeResultListAndAuditAlarmA ;\r
-! : AccessCheckByTypeResultListAndAuditAlarmByHandleA ;\r
-! : AccessCheckByTypeResultListAndAuditAlarmByHandleW ;\r
-! : AccessCheckByTypeResultListAndAuditAlarmW ;\r
-! : AddAccessAllowedAce ;\r
-! : AddAccessAllowedAceEx ;\r
-! : AddAccessAllowedObjectAce ;\r
-! : AddAccessDeniedAce ;\r
-! : AddAccessDeniedAceEx ;\r
-! : AddAccessDeniedObjectAce ;\r
-! : AddAce ;\r
-! : AddAuditAccessAce ;\r
-! : AddAuditAccessAceEx ;\r
-! : AddAuditAccessObjectAce ;\r
-! : AddUsersToEncryptedFile ;\r
-! : AdjustTokenGroups ;\r
-FUNCTION: BOOL AdjustTokenPrivileges ( HANDLE TokenHandle,\r
-                               BOOL DisableAllPrivileges,\r
-                               PTOKEN_PRIVILEGES NewState,\r
-                               DWORD BufferLength,\r
-                               PTOKEN_PRIVILEGES PreviousState,\r
-                               PDWORD ReturnLength ) ;\r
-\r
-! : AllocateAndInitializeSid ;\r
-! : AllocateLocallyUniqueId ;\r
-! : AreAllAccessesGranted ;\r
-! : AreAnyAccessesGranted ;\r
-! : BackupEventLogA ;\r
-! : BackupEventLogW ;\r
-! : BuildExplicitAccessWithNameA ;\r
-! : BuildExplicitAccessWithNameW ;\r
-! : BuildImpersonateExplicitAccessWithNameA ;\r
-! : BuildImpersonateExplicitAccessWithNameW ;\r
-! : BuildImpersonateTrusteeA ;\r
-! : BuildImpersonateTrusteeW ;\r
-! : BuildSecurityDescriptorA ;\r
-! : BuildSecurityDescriptorW ;\r
-! : BuildTrusteeWithNameA ;\r
-! : BuildTrusteeWithNameW ;\r
-! : BuildTrusteeWithObjectsAndNameA ;\r
-! : BuildTrusteeWithObjectsAndNameW ;\r
-! : BuildTrusteeWithObjectsAndSidA ;\r
-! : BuildTrusteeWithObjectsAndSidW ;\r
-! : BuildTrusteeWithSidA ;\r
-! : BuildTrusteeWithSidW ;\r
-! : CancelOverlappedAccess ;\r
-! : ChangeServiceConfig2A ;\r
-! : ChangeServiceConfig2W ;\r
-! : ChangeServiceConfigA ;\r
-! : ChangeServiceConfigW ;\r
-! : CheckTokenMembership ;\r
-! : ClearEventLogA ;\r
-! : ClearEventLogW ;\r
-! : CloseCodeAuthzLevel ;\r
-! : CloseEncryptedFileRaw ;\r
-! : CloseEventLog ;\r
-! : CloseServiceHandle ;\r
-! : CloseTrace ;\r
-! : CommandLineFromMsiDescriptor ;\r
-! : ComputeAccessTokenFromCodeAuthzLevel ;\r
-! : ControlService ;\r
-! : ControlTraceA ;\r
-! : ControlTraceW ;\r
-! : ConvertAccessToSecurityDescriptorA ;\r
-! : ConvertAccessToSecurityDescriptorW ;\r
-! : ConvertSDToStringSDRootDomainA ;\r
-! : ConvertSDToStringSDRootDomainW ;\r
-! : ConvertSecurityDescriptorToAccessA ;\r
-! : ConvertSecurityDescriptorToAccessNamedA ;\r
-! : ConvertSecurityDescriptorToAccessNamedW ;\r
-! : ConvertSecurityDescriptorToAccessW ;\r
-! : ConvertSecurityDescriptorToStringSecurityDescriptorA ;\r
-! : ConvertSecurityDescriptorToStringSecurityDescriptorW ;\r
-! : ConvertSidToStringSidA ;\r
-! : ConvertSidToStringSidW ;\r
-! : ConvertStringSDToSDDomainA ;\r
-! : ConvertStringSDToSDDomainW ;\r
-! : ConvertStringSDToSDRootDomainA ;\r
-! : ConvertStringSDToSDRootDomainW ;\r
-! : ConvertStringSecurityDescriptorToSecurityDescriptorA ;\r
-! : ConvertStringSecurityDescriptorToSecurityDescriptorW ;\r
-! : ConvertStringSidToSidA ;\r
-! : ConvertStringSidToSidW ;\r
-! : ConvertToAutoInheritPrivateObjectSecurity ;\r
-! : CopySid ;\r
-! : CreateCodeAuthzLevel ;\r
-! : CreatePrivateObjectSecurity ;\r
-! : CreatePrivateObjectSecurityEx ;\r
-! : CreatePrivateObjectSecurityWithMultipleInheritance ;\r
-! : CreateProcessAsUserA ;\r
-! : CreateProcessAsUserSecure ;\r
-! : CreateProcessAsUserW ;\r
-! : CreateProcessWithLogonW ;\r
-! : CreateRestrictedToken ;\r
-! : CreateServiceA ;\r
-! : CreateServiceW ;\r
-! : CreateTraceInstanceId ;\r
-! : CreateWellKnownSid ;\r
-! : CredDeleteA ;\r
-! : CredDeleteW ;\r
-! : CredEnumerateA ;\r
-! : CredEnumerateW ;\r
-! : CredFree ;\r
-! : CredGetSessionTypes ;\r
-! : CredGetTargetInfoA ;\r
-! : CredGetTargetInfoW ;\r
-! : CredIsMarshaledCredentialA ;\r
-! : CredIsMarshaledCredentialW ;\r
-! : CredMarshalCredentialA ;\r
-! : CredMarshalCredentialW ;\r
-! : CredProfileLoaded ;\r
-! : CredReadA ;\r
-! : CredReadDomainCredentialsA ;\r
-! : CredReadDomainCredentialsW ;\r
-! : CredReadW ;\r
-! : CredRenameA ;\r
-! : CredRenameW ;\r
-! : CredUnmarshalCredentialA ;\r
-! : CredUnmarshalCredentialW ;\r
-! : CredWriteA ;\r
-! : CredWriteDomainCredentialsA ;\r
-! : CredWriteDomainCredentialsW ;\r
-! : CredWriteW ;\r
-! : CredpConvertCredential ;\r
-! : CredpConvertTargetInfo ;\r
-! : CredpDecodeCredential ;\r
-! : CredpEncodeCredential ;\r
-! : CryptAcquireContextA ;\r
-! : CryptAcquireContextW ;\r
-! : CryptContextAddRef ;\r
-! : CryptCreateHash ;\r
-! : CryptDecrypt ;\r
-! : CryptDeriveKey ;\r
-! : CryptDestroyHash ;\r
-! : CryptDestroyKey ;\r
-! : CryptDuplicateHash ;\r
-! : CryptDuplicateKey ;\r
-! : CryptEncrypt ;\r
-! : CryptEnumProviderTypesA ;\r
-! : CryptEnumProviderTypesW ;\r
-! : CryptEnumProvidersA ;\r
-! : CryptEnumProvidersW ;\r
-! : CryptExportKey ;\r
-! : CryptGenKey ;\r
-! : CryptGenRandom ;\r
-! : CryptGetDefaultProviderA ;\r
-! : CryptGetDefaultProviderW ;\r
-! : CryptGetHashParam ;\r
-! : CryptGetKeyParam ;\r
-! : CryptGetProvParam ;\r
-! : CryptGetUserKey ;\r
-! : CryptHashData ;\r
-! : CryptHashSessionKey ;\r
-! : CryptImportKey ;\r
-! : CryptReleaseContext ;\r
-! : CryptSetHashParam ;\r
-! : CryptSetKeyParam ;\r
-! : CryptSetProvParam ;\r
-! : CryptSetProviderA ;\r
-! : CryptSetProviderExA ;\r
-! : CryptSetProviderExW ;\r
-! : CryptSetProviderW ;\r
-! : CryptSignHashA ;\r
-! : CryptSignHashW ;\r
-! : CryptVerifySignatureA ;\r
-! : CryptVerifySignatureW ;\r
-! : DecryptFileA ;\r
-! : DecryptFileW ;\r
-! : DeleteAce ;\r
-! : DeleteService ;\r
-! : DeregisterEventSource ;\r
-! : DestroyPrivateObjectSecurity ;\r
-! : DuplicateEncryptionInfoFile ;\r
-! : DuplicateToken ;\r
-! : DuplicateTokenEx ;\r
-! : ElfBackupEventLogFileA ;\r
-! : ElfBackupEventLogFileW ;\r
-! : ElfChangeNotify ;\r
-! : ElfClearEventLogFileA ;\r
-! : ElfClearEventLogFileW ;\r
-! : ElfCloseEventLog ;\r
-! : ElfDeregisterEventSource ;\r
-! : ElfFlushEventLog ;\r
-! : ElfNumberOfRecords ;\r
-! : ElfOldestRecord ;\r
-! : ElfOpenBackupEventLogA ;\r
-! : ElfOpenBackupEventLogW ;\r
-! : ElfOpenEventLogA ;\r
-! : ElfOpenEventLogW ;\r
-! : ElfReadEventLogA ;\r
-! : ElfReadEventLogW ;\r
-! : ElfRegisterEventSourceA ;\r
-! : ElfRegisterEventSourceW ;\r
-! : ElfReportEventA ;\r
-! : ElfReportEventW ;\r
-! : EnableTrace ;\r
-! : EncryptFileA ;\r
-! : EncryptFileW ;\r
-! : EncryptedFileKeyInfo ;\r
-! : EncryptionDisable ;\r
-! : EnumDependentServicesA ;\r
-! : EnumDependentServicesW ;\r
-! : EnumServiceGroupW ;\r
-! : EnumServicesStatusA ;\r
-! : EnumServicesStatusExA ;\r
-! : EnumServicesStatusExW ;\r
-! : EnumServicesStatusW ;\r
-! : EnumerateTraceGuids ;\r
-! : EqualDomainSid ;\r
-! : EqualPrefixSid ;\r
-! : EqualSid ;\r
-! : FileEncryptionStatusA ;\r
-! : FileEncryptionStatusW ;\r
-! : FindFirstFreeAce ;\r
-! : FlushTraceA ;\r
-! : FlushTraceW ;\r
-! : FreeEncryptedFileKeyInfo ;\r
-! : FreeEncryptionCertificateHashList ;\r
-! : FreeInheritedFromArray ;\r
-! : FreeSid ;\r
-! : GetAccessPermissionsForObjectA ;\r
-! : GetAccessPermissionsForObjectW ;\r
-! : GetAce ;\r
-! : GetAclInformation ;\r
-! : GetAuditedPermissionsFromAclA ;\r
-! : GetAuditedPermissionsFromAclW ;\r
-! : GetCurrentHwProfileA ;\r
-! : GetCurrentHwProfileW ;\r
-! : GetEffectiveRightsFromAclA ;\r
-! : GetEffectiveRightsFromAclW ;\r
-! : GetEventLogInformation ;\r
-! : GetExplicitEntriesFromAclA ;\r
-! : GetExplicitEntriesFromAclW ;\r
-! : GetFileSecurityA ;\r
-! : GetFileSecurityW ;\r
-! : GetInformationCodeAuthzLevelW ;\r
-! : GetInformationCodeAuthzPolicyW ;\r
-! : GetInheritanceSourceA ;\r
-! : GetInheritanceSourceW ;\r
-! : GetKernelObjectSecurity ;\r
-! : GetLengthSid ;\r
-! : GetLocalManagedApplicationData ;\r
-! : GetLocalManagedApplications ;\r
-! : GetManagedApplicationCategories ;\r
-! : GetManagedApplications ;\r
-! : GetMultipleTrusteeA ;\r
-! : GetMultipleTrusteeOperationA ;\r
-! : GetMultipleTrusteeOperationW ;\r
-! : GetMultipleTrusteeW ;\r
-! : GetNamedSecurityInfoA ;\r
-! : GetNamedSecurityInfoExA ;\r
-! : GetNamedSecurityInfoExW ;\r
-! : GetNamedSecurityInfoW ;\r
-! : GetNumberOfEventLogRecords ;\r
-! : GetOldestEventLogRecord ;\r
-! : GetOverlappedAccessResults ;\r
-! : GetPrivateObjectSecurity ;\r
-! : GetSecurityDescriptorControl ;\r
-! : GetSecurityDescriptorDacl ;\r
-! : GetSecurityDescriptorGroup ;\r
-! : GetSecurityDescriptorLength ;\r
-! : GetSecurityDescriptorOwner ;\r
-! : GetSecurityDescriptorRMControl ;\r
-! : GetSecurityDescriptorSacl ;\r
-! : GetSecurityInfo ;\r
-! : GetSecurityInfoExA ;\r
-! : GetSecurityInfoExW ;\r
-! : GetServiceDisplayNameA ;\r
-! : GetServiceDisplayNameW ;\r
-! : GetServiceKeyNameA ;\r
-! : GetServiceKeyNameW ;\r
-! : GetSidIdentifierAuthority ;\r
-! : GetSidLengthRequired ;\r
-! : GetSidSubAuthority ;\r
-! : GetSidSubAuthorityCount ;\r
-! : GetTokenInformation ;\r
-! : GetTraceEnableFlags ;\r
-! : GetTraceEnableLevel ;\r
-! : GetTraceLoggerHandle ;\r
-! : GetTrusteeFormA ;\r
-! : GetTrusteeFormW ;\r
-! : GetTrusteeNameA ;\r
-! : GetTrusteeNameW ;\r
-! : GetTrusteeTypeA ;\r
-! : GetTrusteeTypeW ;\r
-\r
-! : GetUserNameA ;\r
-FUNCTION: BOOL GetUserNameW ( LPCTSTR lpBuffer, LPDWORD lpnSize ) ;\r
-: GetUserName GetUserNameW ;\r
-\r
-! : GetWindowsAccountDomainSid ;\r
-! : I_ScIsSecurityProcess ;\r
-! : I_ScPnPGetServiceName ;\r
-! : I_ScSendTSMessage ;\r
-! : I_ScSetServiceBitsA ;\r
-! : I_ScSetServiceBitsW ;\r
-! : IdentifyCodeAuthzLevelW ;\r
-! : ImpersonateAnonymousToken ;\r
-! : ImpersonateLoggedOnUser ;\r
-! : ImpersonateNamedPipeClient ;\r
-! : ImpersonateSelf ;\r
-! : InitializeAcl ;\r
-! : InitializeSecurityDescriptor ;\r
-! : InitializeSid ;\r
-! : InitiateSystemShutdownA ;\r
-! : InitiateSystemShutdownExA ;\r
-! : InitiateSystemShutdownExW ;\r
-! : InitiateSystemShutdownW ;\r
-! : InstallApplication ;\r
-! : IsTextUnicode ;\r
-! : IsTokenRestricted ;\r
-! : IsTokenUntrusted ;\r
-! : IsValidAcl ;\r
-! : IsValidSecurityDescriptor ;\r
-! : IsValidSid ;\r
-! : IsWellKnownSid ;\r
-! : LockServiceDatabase ;\r
-! : LogonUserA ;\r
-! : LogonUserExA ;\r
-! : LogonUserExW ;\r
-! : LogonUserW ;\r
-! : LookupAccountNameA ;\r
-! : LookupAccountNameW ;\r
-! : LookupAccountSidA ;\r
-! : LookupAccountSidW ;\r
-! : LookupPrivilegeDisplayNameA ;\r
-! : LookupPrivilegeDisplayNameW ;\r
-! : LookupPrivilegeNameA ;\r
-! : LookupPrivilegeNameW ;\r
-! : LookupPrivilegeValueA ;\r
-FUNCTION: BOOL LookupPrivilegeValueW ( LPCTSTR lpSystemName,\r
-                               LPCTSTR lpName,\r
-                               PLUID lpLuid ) ;\r
-: LookupPrivilegeValue LookupPrivilegeValueW ;\r
-\r
-! : LookupSecurityDescriptorPartsA ;\r
-! : LookupSecurityDescriptorPartsW ;\r
-! : LsaAddAccountRights ;\r
-! : LsaAddPrivilegesToAccount ;\r
-! : LsaClearAuditLog ;\r
-! : LsaClose ;\r
-! : LsaCreateAccount ;\r
-! : LsaCreateSecret ;\r
-! : LsaCreateTrustedDomain ;\r
-! : LsaCreateTrustedDomainEx ;\r
-! : LsaDelete ;\r
-! : LsaDeleteTrustedDomain ;\r
-! : LsaEnumerateAccountRights ;\r
-! : LsaEnumerateAccounts ;\r
-! : LsaEnumerateAccountsWithUserRight ;\r
-! : LsaEnumeratePrivileges ;\r
-! : LsaEnumeratePrivilegesOfAccount ;\r
-! : LsaEnumerateTrustedDomains ;\r
-! : LsaEnumerateTrustedDomainsEx ;\r
-! : LsaFreeMemory ;\r
-! : LsaGetQuotasForAccount ;\r
-! : LsaGetRemoteUserName ;\r
-! : LsaGetSystemAccessAccount ;\r
-! : LsaGetUserName ;\r
-! : LsaICLookupNames ;\r
-! : LsaICLookupNamesWithCreds ;\r
-! : LsaICLookupSids ;\r
-! : LsaICLookupSidsWithCreds ;\r
-! : LsaLookupNames2 ;\r
-! : LsaLookupNames ;\r
-! : LsaLookupPrivilegeDisplayName ;\r
-! : LsaLookupPrivilegeName ;\r
-! : LsaLookupPrivilegeValue ;\r
-! : LsaLookupSids ;\r
-! : LsaNtStatusToWinError ;\r
-! : LsaOpenAccount ;\r
-! : LsaOpenPolicy ;\r
-! : LsaOpenPolicySce ;\r
-! : LsaOpenSecret ;\r
-! : LsaOpenTrustedDomain ;\r
-! : LsaOpenTrustedDomainByName ;\r
-! : LsaQueryDomainInformationPolicy ;\r
-! : LsaQueryForestTrustInformation ;\r
-! : LsaQueryInfoTrustedDomain ;\r
-! : LsaQueryInformationPolicy ;\r
-! : LsaQuerySecret ;\r
-! : LsaQuerySecurityObject ;\r
-! : LsaQueryTrustedDomainInfo ;\r
-! : LsaQueryTrustedDomainInfoByName ;\r
-! : LsaRemoveAccountRights ;\r
-! : LsaRemovePrivilegesFromAccount ;\r
-! : LsaRetrievePrivateData ;\r
-! : LsaSetDomainInformationPolicy ;\r
-! : LsaSetForestTrustInformation ;\r
-! : LsaSetInformationPolicy ;\r
-! : LsaSetInformationTrustedDomain ;\r
-! : LsaSetQuotasForAccount ;\r
-! : LsaSetSecret ;\r
-! : LsaSetSecurityObject ;\r
-! : LsaSetSystemAccessAccount ;\r
-! : LsaSetTrustedDomainInfoByName ;\r
-! : LsaSetTrustedDomainInformation ;\r
-! : LsaStorePrivateData ;\r
-! : MD4Final ;\r
-! : MD4Init ;\r
-! : MD4Update ;\r
-! : MD5Final ;\r
-! : MD5Init ;\r
-! : MD5Update ;\r
-! : MSChapSrvChangePassword2 ;\r
-! : MSChapSrvChangePassword ;\r
-! : MakeAbsoluteSD2 ;\r
-! : MakeAbsoluteSD ;\r
-! : MakeSelfRelativeSD ;\r
-! : MapGenericMask ;\r
-! : NotifyBootConfigStatus ;\r
-! : NotifyChangeEventLog ;\r
-! : ObjectCloseAuditAlarmA ;\r
-! : ObjectCloseAuditAlarmW ;\r
-! : ObjectDeleteAuditAlarmA ;\r
-! : ObjectDeleteAuditAlarmW ;\r
-! : ObjectOpenAuditAlarmA ;\r
-! : ObjectOpenAuditAlarmW ;\r
-! : ObjectPrivilegeAuditAlarmA ;\r
-! : ObjectPrivilegeAuditAlarmW ;\r
-! : OpenBackupEventLogA ;\r
-! : OpenBackupEventLogW ;\r
-! : OpenEncryptedFileRawA ;\r
-! : OpenEncryptedFileRawW ;\r
-! : OpenEventLogA ;\r
-! : OpenEventLogW ;\r
-\r
-! typedef enum _TOKEN_INFORMATION_CLASS {\r
-: TokenUser 1 ;\r
-: TokenGroups 2 ;\r
-: TokenPrivileges 3 ;\r
-: TokenOwner 4 ;\r
-: TokenPrimaryGroup 5 ;\r
-: TokenDefaultDacl 6 ;\r
-: TokenSource 7 ;\r
-: TokenType 8 ;\r
-: TokenImpersonationLevel 9 ;\r
-: TokenStatistics 10 ;\r
-: TokenRestrictedSids 11 ;\r
-: TokenSessionId 12 ;\r
-: TokenGroupsAndPrivileges 13 ;\r
-: TokenSessionReference 14 ;\r
-: TokenSandBoxInert 15 ;\r
-! } TOKEN_INFORMATION_CLASS;\r
-\r
-: DELETE                     HEX: 00010000 ; inline\r
-: READ_CONTROL               HEX: 00020000 ; inline\r
-: WRITE_DAC                  HEX: 00040000 ; inline\r
-: WRITE_OWNER                HEX: 00080000 ; inline\r
-: SYNCHRONIZE                HEX: 00100000 ; inline\r
-: STANDARD_RIGHTS_REQUIRED   HEX: 000f0000 ; inline\r
-\r
-: STANDARD_RIGHTS_READ       READ_CONTROL ; inline\r
-: STANDARD_RIGHTS_WRITE      READ_CONTROL ; inline\r
-: STANDARD_RIGHTS_EXECUTE    READ_CONTROL ; inline\r
-\r
-: TOKEN_TOKEN_ADJUST_DEFAULT   HEX: 0080 ; inline\r
-: TOKEN_ADJUST_GROUPS          HEX: 0040 ; inline\r
-: TOKEN_ADJUST_PRIVILEGES      HEX: 0020 ; inline\r
-: TOKEN_ADJUST_SESSIONID       HEX: 0100 ; inline\r
-: TOKEN_ASSIGN_PRIMARY         HEX: 0001 ; inline\r
-: TOKEN_DUPLICATE              HEX: 0002 ; inline\r
-: TOKEN_EXECUTE                STANDARD_RIGHTS_EXECUTE ; inline\r
-: TOKEN_IMPERSONATE            HEX: 0004 ; inline\r
-: TOKEN_QUERY                  HEX: 0008 ; inline\r
-: TOKEN_QUERY_SOURCE           HEX: 0010 ; inline\r
-: TOKEN_ADJUST_DEFAULT         HEX: 0080 ; inline\r
-: TOKEN_READ STANDARD_RIGHTS_READ TOKEN_QUERY bitor ;\r
-\r
-: TOKEN_WRITE\r
-    {\r
-        STANDARD_RIGHTS_WRITE\r
-        TOKEN_ADJUST_PRIVILEGES\r
-        TOKEN_ADJUST_GROUPS\r
-        TOKEN_ADJUST_DEFAULT\r
-    } flags ; foldable\r
-\r
-: TOKEN_ALL_ACCESS\r
-    {\r
-        STANDARD_RIGHTS_REQUIRED\r
-        TOKEN_ASSIGN_PRIMARY\r
-        TOKEN_DUPLICATE\r
-        TOKEN_IMPERSONATE\r
-        TOKEN_QUERY\r
-        TOKEN_QUERY_SOURCE\r
-        TOKEN_ADJUST_PRIVILEGES\r
-        TOKEN_ADJUST_GROUPS\r
-        TOKEN_ADJUST_SESSIONID\r
-        TOKEN_ADJUST_DEFAULT\r
-    } flags ; foldable\r
-\r
-FUNCTION: BOOL OpenProcessToken ( HANDLE ProcessHandle,\r
-                                  DWORD DesiredAccess,\r
-                                  PHANDLE TokenHandle ) ;\r
-! : OpenSCManagerA ;\r
-! : OpenSCManagerW ;\r
-! : OpenServiceA ;\r
-! : OpenServiceW ;\r
-FUNCTION: BOOL OpenThreadToken ( HANDLE ThreadHandle, DWORD DesiredAccess, BOOL OpenAsSelf, PHANDLE TokenHandle ) ;\r
-! : OpenTraceA ;\r
-! : OpenTraceW ;\r
-! : PrivilegeCheck ;\r
-! : PrivilegedServiceAuditAlarmA ;\r
-! : PrivilegedServiceAuditAlarmW ;\r
-! : ProcessIdleTasks ;\r
-! : ProcessTrace ;\r
-! : QueryAllTracesA ;\r
-! : QueryAllTracesW ;\r
-! : QueryRecoveryAgentsOnEncryptedFile ;\r
-! : QueryServiceConfig2A ;\r
-! : QueryServiceConfig2W ;\r
-! : QueryServiceConfigA ;\r
-! : QueryServiceConfigW ;\r
-! : QueryServiceLockStatusA ;\r
-! : QueryServiceLockStatusW ;\r
-! : QueryServiceObjectSecurity ;\r
-! : QueryServiceStatus ;\r
-! : QueryServiceStatusEx ;\r
-! : QueryTraceA ;\r
-! : QueryTraceW ;\r
-! : QueryUsersOnEncryptedFile ;\r
-! : QueryWindows31FilesMigration ;\r
-! : ReadEncryptedFileRaw ;\r
-! : ReadEventLogA ;\r
-! : ReadEventLogW ;\r
-! : RegCloseKey ;\r
-! : RegConnectRegistryA ;\r
-! : RegConnectRegistryW ;\r
-! : RegCreateKeyA ;\r
-! : RegCreateKeyExA ;\r
-! : RegCreateKeyExW ;\r
-! : RegCreateKeyW ;\r
-! : RegDeleteKeyA ;\r
-! : RegDeleteKeyW ;\r
-! : RegDeleteValueA ;\r
-! : RegDeleteValueW ;\r
-! : RegDisablePredefinedCache ;\r
-! : RegEnumKeyA ;\r
-! : RegEnumKeyExA ;\r
-! : RegEnumKeyExW ;\r
-! : RegEnumKeyW ;\r
-! : RegEnumValueA ;\r
-! : RegEnumValueW ;\r
-! : RegFlushKey ;\r
-! : RegGetKeySecurity ;\r
-! : RegLoadKeyA ;\r
-! : RegLoadKeyW ;\r
-! : RegNotifyChangeKeyValue ;\r
-! : RegOpenCurrentUser ;\r
-! : RegOpenKeyA ;\r
-! : RegOpenKeyExA ;\r
-! : RegOpenKeyExW ;\r
-! : RegOpenKeyW ;\r
-! : RegOpenUserClassesRoot ;\r
-! : RegOverridePredefKey ;\r
-! : RegQueryInfoKeyA ;\r
-! : RegQueryInfoKeyW ;\r
-! : RegQueryMultipleValuesA ;\r
-! : RegQueryMultipleValuesW ;\r
-! : RegQueryValueA ;\r
-! : RegQueryValueExA ;\r
-! : RegQueryValueExW ;\r
-! : RegQueryValueW ;\r
-! : RegReplaceKeyA ;\r
-! : RegReplaceKeyW ;\r
-! : RegRestoreKeyA ;\r
-! : RegRestoreKeyW ;\r
-! : RegSaveKeyA ;\r
-! : RegSaveKeyExA ;\r
-! : RegSaveKeyExW ;\r
-! : RegSaveKeyW ;\r
-! : RegSetKeySecurity ;\r
-! : RegSetValueA ;\r
-! : RegSetValueExA ;\r
-! : RegSetValueExW ;\r
-! : RegSetValueW ;\r
-! : RegUnLoadKeyA ;\r
-! : RegUnLoadKeyW ;\r
-! : RegisterEventSourceA ;\r
-! : RegisterEventSourceW ;\r
-! : RegisterIdleTask ;\r
-! : RegisterServiceCtrlHandlerA ;\r
-! : RegisterServiceCtrlHandlerExA ;\r
-! : RegisterServiceCtrlHandlerExW ;\r
-! : RegisterServiceCtrlHandlerW ;\r
-! : RegisterTraceGuidsA ;\r
-! : RegisterTraceGuidsW ;\r
-! : RemoveTraceCallback ;\r
-! : RemoveUsersFromEncryptedFile ;\r
-! : ReportEventA ;\r
-! : ReportEventW ;\r
-! : RevertToSelf ;\r
-! : SaferCloseLevel ;\r
-! : SaferComputeTokenFromLevel ;\r
-! : SaferCreateLevel ;\r
-! : SaferGetLevelInformation ;\r
-! : SaferGetPolicyInformation ;\r
-! : SaferIdentifyLevel ;\r
-! : SaferRecordEventLogEntry ;\r
-! : SaferSetLevelInformation ;\r
-! : SaferSetPolicyInformation ;\r
-! : SaferiChangeRegistryScope ;\r
-! : SaferiCompareTokenLevels ;\r
-! : SaferiIsExecutableFileType ;\r
-! : SaferiPopulateDefaultsInRegistry ;\r
-! : SaferiRecordEventLogEntry ;\r
-! : SaferiReplaceProcessThreadTokens ;\r
-! : SaferiSearchMatchingHashRules ;\r
-! : SetAclInformation ;\r
-! : SetEntriesInAccessListA ;\r
-! : SetEntriesInAccessListW ;\r
-! : SetEntriesInAclA ;\r
-! : SetEntriesInAclW ;\r
-! : SetEntriesInAuditListA ;\r
-! : SetEntriesInAuditListW ;\r
-! : SetFileSecurityA ;\r
-! : SetFileSecurityW ;\r
-! : SetInformationCodeAuthzLevelW ;\r
-! : SetInformationCodeAuthzPolicyW ;\r
-! : SetKernelObjectSecurity ;\r
-! : SetNamedSecurityInfoA ;\r
-! : SetNamedSecurityInfoExA ;\r
-! : SetNamedSecurityInfoExW ;\r
-! : SetNamedSecurityInfoW ;\r
-! : SetPrivateObjectSecurity ;\r
-! : SetPrivateObjectSecurityEx ;\r
-! : SetSecurityDescriptorControl ;\r
-! : SetSecurityDescriptorDacl ;\r
-! : SetSecurityDescriptorGroup ;\r
-! : SetSecurityDescriptorOwner ;\r
-! : SetSecurityDescriptorRMControl ;\r
-! : SetSecurityDescriptorSacl ;\r
-! : SetSecurityInfo ;\r
-! : SetSecurityInfoExA ;\r
-! : SetSecurityInfoExW ;\r
-! : SetServiceBits ;\r
-! : SetServiceObjectSecurity ;\r
-! : SetServiceStatus ;\r
-! : SetThreadToken ;\r
-! : SetTokenInformation ;\r
-! : SetTraceCallback ;\r
-! : SetUserFileEncryptionKey ;\r
-! : StartServiceA ;\r
-! : StartServiceCtrlDispatcherA ;\r
-! : StartServiceCtrlDispatcherW ;\r
-! : StartServiceW ;\r
-! : StartTraceA ;\r
-! : StartTraceW ;\r
-! : StopTraceA ;\r
-! : StopTraceW ;\r
-! : SynchronizeWindows31FilesAndWindowsNTRegistry ;\r
-! : SystemFunction001 ;\r
-! : SystemFunction002 ;\r
-! : SystemFunction003 ;\r
-! : SystemFunction004 ;\r
-! : SystemFunction005 ;\r
-! : SystemFunction006 ;\r
-! : SystemFunction007 ;\r
-! : SystemFunction008 ;\r
-! : SystemFunction009 ;\r
-! : SystemFunction010 ;\r
-! : SystemFunction011 ;\r
-! : SystemFunction012 ;\r
-! : SystemFunction013 ;\r
-! : SystemFunction014 ;\r
-! : SystemFunction015 ;\r
-! : SystemFunction016 ;\r
-! : SystemFunction017 ;\r
-! : SystemFunction018 ;\r
-! : SystemFunction019 ;\r
-! : SystemFunction020 ;\r
-! : SystemFunction021 ;\r
-! : SystemFunction022 ;\r
-! : SystemFunction023 ;\r
-! : SystemFunction024 ;\r
-! : SystemFunction025 ;\r
-! : SystemFunction026 ;\r
-! : SystemFunction027 ;\r
-! : SystemFunction028 ;\r
-! : SystemFunction029 ;\r
-! : SystemFunction030 ;\r
-! : SystemFunction031 ;\r
-! : SystemFunction032 ;\r
-! : SystemFunction033 ;\r
-! : SystemFunction034 ;\r
-! : SystemFunction035 ;\r
-! : SystemFunction036 ;\r
-! : SystemFunction040 ;\r
-! : SystemFunction041 ;\r
-! : TraceEvent ;\r
-! : TraceEventInstance ;\r
-! : TraceMessage ;\r
-! : TraceMessageVa ;\r
-! : TreeResetNamedSecurityInfoA ;\r
-! : TreeResetNamedSecurityInfoW ;\r
-! : TrusteeAccessToObjectA ;\r
-! : TrusteeAccessToObjectW ;\r
-! : UninstallApplication ;\r
-! : UnlockServiceDatabase ;\r
-! : UnregisterIdleTask ;\r
-! : UnregisterTraceGuids ;\r
-! : UpdateTraceA ;\r
-! : UpdateTraceW ;\r
-! : WdmWmiServiceMain ;\r
-! : WmiCloseBlock ;\r
-! : WmiCloseTraceWithCursor ;\r
-! : WmiConvertTimestamp ;\r
-! : WmiDevInstToInstanceNameA ;\r
-! : WmiDevInstToInstanceNameW ;\r
-! : WmiEnumerateGuids ;\r
-! : WmiExecuteMethodA ;\r
-! : WmiExecuteMethodW ;\r
-! : WmiFileHandleToInstanceNameA ;\r
-! : WmiFileHandleToInstanceNameW ;\r
-! : WmiFreeBuffer ;\r
-! : WmiGetFirstTraceOffset ;\r
-! : WmiGetNextEvent ;\r
-! : WmiGetTraceHeader ;\r
-! : WmiMofEnumerateResourcesA ;\r
-! : WmiMofEnumerateResourcesW ;\r
-! : WmiNotificationRegistrationA ;\r
-! : WmiNotificationRegistrationW ;\r
-! : WmiOpenBlock ;\r
-! : WmiOpenTraceWithCursor ;\r
-! : WmiParseTraceEvent ;\r
-! : WmiQueryAllDataA ;\r
-! : WmiQueryAllDataMultipleA ;\r
-! : WmiQueryAllDataMultipleW ;\r
-! : WmiQueryAllDataW ;\r
-! : WmiQueryGuidInformation ;\r
-! : WmiQuerySingleInstanceA ;\r
-! : WmiQuerySingleInstanceMultipleA ;\r
-! : WmiQuerySingleInstanceMultipleW ;\r
-! : WmiQuerySingleInstanceW ;\r
-! : WmiReceiveNotificationsA ;\r
-! : WmiReceiveNotificationsW ;\r
-! : WmiSetSingleInstanceA ;\r
-! : WmiSetSingleInstanceW ;\r
-! : WmiSetSingleItemA ;\r
-! : WmiSetSingleItemW ;\r
-! : Wow64Win32ApiEntry ;\r
-! : WriteEncryptedFileRaw ;\r
-\r
-\r
+USING: alien.syntax kernel math windows.types math.bitfields ;
+IN: windows.advapi32
+LIBRARY: advapi32
+
+: PROV_RSA_FULL       1 ; inline
+: PROV_RSA_SIG        2 ; inline
+: PROV_DSS            3 ; inline
+: PROV_FORTEZZA       4 ; inline
+: PROV_MS_EXCHANGE    5 ; inline
+: PROV_SSL            6 ; inline
+: PROV_RSA_SCHANNEL  12 ; inline
+: PROV_DSS_DH        13 ; inline
+: PROV_EC_ECDSA_SIG  14 ; inline
+: PROV_EC_ECNRA_SIG  15 ; inline
+: PROV_EC_ECDSA_FULL 16 ; inline
+: PROV_EC_ECNRA_FULL 17 ; inline
+: PROV_DH_SCHANNEL   18 ; inline
+: PROV_SPYRUS_LYNKS  20 ; inline
+: PROV_RNG           21 ; inline
+: PROV_INTEL_SEC     22 ; inline
+: PROV_REPLACE_OWF   23 ; inline
+: PROV_RSA_AES       24 ; inline
+
+: MS_DEF_DH_SCHANNEL_PROV
+    "Microsoft DH Schannel Cryptographic Provider" ; inline
+
+: MS_DEF_DSS_DH_PROV
+    "Microsoft Base DSS and Diffie-Hellman Cryptographic Provider" ; inline
+
+: MS_DEF_DSS_PROV
+    "Microsoft Base DSS Cryptographic Provider" ; inline
+
+: MS_DEF_PROV
+    "Microsoft Base Cryptographic Provider v1.0" ; inline
+
+: MS_DEF_RSA_SCHANNEL_PROV
+    "Microsoft RSA Schannel Cryptographic Provider" ; inline
+
+! Unsupported (!)
+: MS_DEF_RSA_SIG_PROV
+    "Microsoft RSA Signature Cryptographic Provider" ; inline
+
+: MS_ENH_DSS_DH_PROV
+    "Microsoft Enhanced DSS and Diffie-Hellman Cryptographic Provider" ; inline
+
+: MS_ENH_RSA_AES_PROV
+    "Microsoft Enhanced RSA and AES Cryptographic Provider" ; inline
+
+: MS_ENHANCED_PROV
+    "Microsoft Enhanced Cryptographic Provider v1.0" ; inline
+
+: MS_SCARD_PROV
+    "Microsoft Base Smart Card Crypto Provider" ; inline
+
+: MS_STRONG_PROV
+    "Microsoft Strong Cryptographic Provider" ; inline
+
+: CRYPT_VERIFYCONTEXT  HEX: F0000000 ; inline
+: CRYPT_NEWKEYSET      HEX: 8 ; inline
+: CRYPT_DELETEKEYSET   HEX: 10 ; inline
+: CRYPT_MACHINE_KEYSET HEX: 20 ; inline
+: CRYPT_SILENT         HEX: 40 ; inline
+
+
+! : I_ScGetCurrentGroupStateW ;
+! : A_SHAFinal ;
+! : A_SHAInit ;
+! : A_SHAUpdate ;
+! : AbortSystemShutdownA ;
+! : AbortSystemShutdownW ;
+! : AccessCheck ;
+! : AccessCheckAndAuditAlarmA ;
+! : AccessCheckAndAuditAlarmW ;
+! : AccessCheckByType ;
+! : AccessCheckByTypeAndAuditAlarmA ;
+! : AccessCheckByTypeAndAuditAlarmW ;
+! : AccessCheckByTypeResultList ;
+! : AccessCheckByTypeResultListAndAuditAlarmA ;
+! : AccessCheckByTypeResultListAndAuditAlarmByHandleA ;
+! : AccessCheckByTypeResultListAndAuditAlarmByHandleW ;
+! : AccessCheckByTypeResultListAndAuditAlarmW ;
+! : AddAccessAllowedAce ;
+! : AddAccessAllowedAceEx ;
+! : AddAccessAllowedObjectAce ;
+! : AddAccessDeniedAce ;
+! : AddAccessDeniedAceEx ;
+! : AddAccessDeniedObjectAce ;
+! : AddAce ;
+! : AddAuditAccessAce ;
+! : AddAuditAccessAceEx ;
+! : AddAuditAccessObjectAce ;
+! : AddUsersToEncryptedFile ;
+! : AdjustTokenGroups ;
+FUNCTION: BOOL AdjustTokenPrivileges ( HANDLE TokenHandle,
+                               BOOL DisableAllPrivileges,
+                               PTOKEN_PRIVILEGES NewState,
+                               DWORD BufferLength,
+                               PTOKEN_PRIVILEGES PreviousState,
+                               PDWORD ReturnLength ) ;
+
+! : AllocateAndInitializeSid ;
+! : AllocateLocallyUniqueId ;
+! : AreAllAccessesGranted ;
+! : AreAnyAccessesGranted ;
+! : BackupEventLogA ;
+! : BackupEventLogW ;
+! : BuildExplicitAccessWithNameA ;
+! : BuildExplicitAccessWithNameW ;
+! : BuildImpersonateExplicitAccessWithNameA ;
+! : BuildImpersonateExplicitAccessWithNameW ;
+! : BuildImpersonateTrusteeA ;
+! : BuildImpersonateTrusteeW ;
+! : BuildSecurityDescriptorA ;
+! : BuildSecurityDescriptorW ;
+! : BuildTrusteeWithNameA ;
+! : BuildTrusteeWithNameW ;
+! : BuildTrusteeWithObjectsAndNameA ;
+! : BuildTrusteeWithObjectsAndNameW ;
+! : BuildTrusteeWithObjectsAndSidA ;
+! : BuildTrusteeWithObjectsAndSidW ;
+! : BuildTrusteeWithSidA ;
+! : BuildTrusteeWithSidW ;
+! : CancelOverlappedAccess ;
+! : ChangeServiceConfig2A ;
+! : ChangeServiceConfig2W ;
+! : ChangeServiceConfigA ;
+! : ChangeServiceConfigW ;
+! : CheckTokenMembership ;
+! : ClearEventLogA ;
+! : ClearEventLogW ;
+! : CloseCodeAuthzLevel ;
+! : CloseEncryptedFileRaw ;
+! : CloseEventLog ;
+! : CloseServiceHandle ;
+! : CloseTrace ;
+! : CommandLineFromMsiDescriptor ;
+! : ComputeAccessTokenFromCodeAuthzLevel ;
+! : ControlService ;
+! : ControlTraceA ;
+! : ControlTraceW ;
+! : ConvertAccessToSecurityDescriptorA ;
+! : ConvertAccessToSecurityDescriptorW ;
+! : ConvertSDToStringSDRootDomainA ;
+! : ConvertSDToStringSDRootDomainW ;
+! : ConvertSecurityDescriptorToAccessA ;
+! : ConvertSecurityDescriptorToAccessNamedA ;
+! : ConvertSecurityDescriptorToAccessNamedW ;
+! : ConvertSecurityDescriptorToAccessW ;
+! : ConvertSecurityDescriptorToStringSecurityDescriptorA ;
+! : ConvertSecurityDescriptorToStringSecurityDescriptorW ;
+! : ConvertSidToStringSidA ;
+! : ConvertSidToStringSidW ;
+! : ConvertStringSDToSDDomainA ;
+! : ConvertStringSDToSDDomainW ;
+! : ConvertStringSDToSDRootDomainA ;
+! : ConvertStringSDToSDRootDomainW ;
+! : ConvertStringSecurityDescriptorToSecurityDescriptorA ;
+! : ConvertStringSecurityDescriptorToSecurityDescriptorW ;
+! : ConvertStringSidToSidA ;
+! : ConvertStringSidToSidW ;
+! : ConvertToAutoInheritPrivateObjectSecurity ;
+! : CopySid ;
+! : CreateCodeAuthzLevel ;
+! : CreatePrivateObjectSecurity ;
+! : CreatePrivateObjectSecurityEx ;
+! : CreatePrivateObjectSecurityWithMultipleInheritance ;
+! : CreateProcessAsUserA ;
+! : CreateProcessAsUserSecure ;
+! : CreateProcessAsUserW ;
+! : CreateProcessWithLogonW ;
+! : CreateRestrictedToken ;
+! : CreateServiceA ;
+! : CreateServiceW ;
+! : CreateTraceInstanceId ;
+! : CreateWellKnownSid ;
+! : CredDeleteA ;
+! : CredDeleteW ;
+! : CredEnumerateA ;
+! : CredEnumerateW ;
+! : CredFree ;
+! : CredGetSessionTypes ;
+! : CredGetTargetInfoA ;
+! : CredGetTargetInfoW ;
+! : CredIsMarshaledCredentialA ;
+! : CredIsMarshaledCredentialW ;
+! : CredMarshalCredentialA ;
+! : CredMarshalCredentialW ;
+! : CredProfileLoaded ;
+! : CredReadA ;
+! : CredReadDomainCredentialsA ;
+! : CredReadDomainCredentialsW ;
+! : CredReadW ;
+! : CredRenameA ;
+! : CredRenameW ;
+! : CredUnmarshalCredentialA ;
+! : CredUnmarshalCredentialW ;
+! : CredWriteA ;
+! : CredWriteDomainCredentialsA ;
+! : CredWriteDomainCredentialsW ;
+! : CredWriteW ;
+! : CredpConvertCredential ;
+! : CredpConvertTargetInfo ;
+! : CredpDecodeCredential ;
+! : CredpEncodeCredential ;
+! : CryptAcquireContextA ;
+FUNCTION: BOOL CryptAcquireContextW ( HCRYPTPROV* phProv,
+                                      LPCTSTR pszContainer,
+                                      LPCTSTR pszProvider,
+                                      DWORD dwProvType,
+                                      DWORD dwFlags ) ;
+
+: CryptAcquireContext CryptAcquireContextW ;
+! : CryptContextAddRef ;
+! : CryptCreateHash ;
+! : CryptDecrypt ;
+! : CryptDeriveKey ;
+! : CryptDestroyHash ;
+! : CryptDestroyKey ;
+! : CryptDuplicateHash ;
+! : CryptDuplicateKey ;
+! : CryptEncrypt ;
+! : CryptEnumProviderTypesA ;
+! : CryptEnumProviderTypesW ;
+! : CryptEnumProvidersA ;
+! : CryptEnumProvidersW ;
+! : CryptExportKey ;
+! : CryptGenKey ;
+FUNCTION: BOOL CryptGenRandom ( HCRYPTPROV hProv, DWORD dwLen, BYTE* pbBuffer ) ;
+! : CryptGetDefaultProviderA ;
+! : CryptGetDefaultProviderW ;
+! : CryptGetHashParam ;
+! : CryptGetKeyParam ;
+! : CryptGetProvParam ;
+! : CryptGetUserKey ;
+! : CryptHashData ;
+! : CryptHashSessionKey ;
+! : CryptImportKey ;
+FUNCTION: BOOL CryptReleaseContext ( HCRYPTPROV hProv, DWORD dwFlags ) ;
+! : CryptSetHashParam ;
+! : CryptSetKeyParam ;
+! : CryptSetProvParam ;
+! : CryptSetProviderA ;
+! : CryptSetProviderExA ;
+! : CryptSetProviderExW ;
+! : CryptSetProviderW ;
+! : CryptSignHashA ;
+! : CryptSignHashW ;
+! : CryptVerifySignatureA ;
+! : CryptVerifySignatureW ;
+! : DecryptFileA ;
+! : DecryptFileW ;
+! : DeleteAce ;
+! : DeleteService ;
+! : DeregisterEventSource ;
+! : DestroyPrivateObjectSecurity ;
+! : DuplicateEncryptionInfoFile ;
+! : DuplicateToken ;
+! : DuplicateTokenEx ;
+! : ElfBackupEventLogFileA ;
+! : ElfBackupEventLogFileW ;
+! : ElfChangeNotify ;
+! : ElfClearEventLogFileA ;
+! : ElfClearEventLogFileW ;
+! : ElfCloseEventLog ;
+! : ElfDeregisterEventSource ;
+! : ElfFlushEventLog ;
+! : ElfNumberOfRecords ;
+! : ElfOldestRecord ;
+! : ElfOpenBackupEventLogA ;
+! : ElfOpenBackupEventLogW ;
+! : ElfOpenEventLogA ;
+! : ElfOpenEventLogW ;
+! : ElfReadEventLogA ;
+! : ElfReadEventLogW ;
+! : ElfRegisterEventSourceA ;
+! : ElfRegisterEventSourceW ;
+! : ElfReportEventA ;
+! : ElfReportEventW ;
+! : EnableTrace ;
+! : EncryptFileA ;
+! : EncryptFileW ;
+! : EncryptedFileKeyInfo ;
+! : EncryptionDisable ;
+! : EnumDependentServicesA ;
+! : EnumDependentServicesW ;
+! : EnumServiceGroupW ;
+! : EnumServicesStatusA ;
+! : EnumServicesStatusExA ;
+! : EnumServicesStatusExW ;
+! : EnumServicesStatusW ;
+! : EnumerateTraceGuids ;
+! : EqualDomainSid ;
+! : EqualPrefixSid ;
+! : EqualSid ;
+! : FileEncryptionStatusA ;
+! : FileEncryptionStatusW ;
+! : FindFirstFreeAce ;
+! : FlushTraceA ;
+! : FlushTraceW ;
+! : FreeEncryptedFileKeyInfo ;
+! : FreeEncryptionCertificateHashList ;
+! : FreeInheritedFromArray ;
+! : FreeSid ;
+! : GetAccessPermissionsForObjectA ;
+! : GetAccessPermissionsForObjectW ;
+! : GetAce ;
+! : GetAclInformation ;
+! : GetAuditedPermissionsFromAclA ;
+! : GetAuditedPermissionsFromAclW ;
+! : GetCurrentHwProfileA ;
+! : GetCurrentHwProfileW ;
+! : GetEffectiveRightsFromAclA ;
+! : GetEffectiveRightsFromAclW ;
+! : GetEventLogInformation ;
+! : GetExplicitEntriesFromAclA ;
+! : GetExplicitEntriesFromAclW ;
+! : GetFileSecurityA ;
+! : GetFileSecurityW ;
+! : GetInformationCodeAuthzLevelW ;
+! : GetInformationCodeAuthzPolicyW ;
+! : GetInheritanceSourceA ;
+! : GetInheritanceSourceW ;
+! : GetKernelObjectSecurity ;
+! : GetLengthSid ;
+! : GetLocalManagedApplicationData ;
+! : GetLocalManagedApplications ;
+! : GetManagedApplicationCategories ;
+! : GetManagedApplications ;
+! : GetMultipleTrusteeA ;
+! : GetMultipleTrusteeOperationA ;
+! : GetMultipleTrusteeOperationW ;
+! : GetMultipleTrusteeW ;
+! : GetNamedSecurityInfoA ;
+! : GetNamedSecurityInfoExA ;
+! : GetNamedSecurityInfoExW ;
+! : GetNamedSecurityInfoW ;
+! : GetNumberOfEventLogRecords ;
+! : GetOldestEventLogRecord ;
+! : GetOverlappedAccessResults ;
+! : GetPrivateObjectSecurity ;
+! : GetSecurityDescriptorControl ;
+! : GetSecurityDescriptorDacl ;
+! : GetSecurityDescriptorGroup ;
+! : GetSecurityDescriptorLength ;
+! : GetSecurityDescriptorOwner ;
+! : GetSecurityDescriptorRMControl ;
+! : GetSecurityDescriptorSacl ;
+! : GetSecurityInfo ;
+! : GetSecurityInfoExA ;
+! : GetSecurityInfoExW ;
+! : GetServiceDisplayNameA ;
+! : GetServiceDisplayNameW ;
+! : GetServiceKeyNameA ;
+! : GetServiceKeyNameW ;
+! : GetSidIdentifierAuthority ;
+! : GetSidLengthRequired ;
+! : GetSidSubAuthority ;
+! : GetSidSubAuthorityCount ;
+! : GetTokenInformation ;
+! : GetTraceEnableFlags ;
+! : GetTraceEnableLevel ;
+! : GetTraceLoggerHandle ;
+! : GetTrusteeFormA ;
+! : GetTrusteeFormW ;
+! : GetTrusteeNameA ;
+! : GetTrusteeNameW ;
+! : GetTrusteeTypeA ;
+! : GetTrusteeTypeW ;
+
+! : GetUserNameA ;
+FUNCTION: BOOL GetUserNameW ( LPCTSTR lpBuffer, LPDWORD lpnSize ) ;
+: GetUserName GetUserNameW ;
+
+! : GetWindowsAccountDomainSid ;
+! : I_ScIsSecurityProcess ;
+! : I_ScPnPGetServiceName ;
+! : I_ScSendTSMessage ;
+! : I_ScSetServiceBitsA ;
+! : I_ScSetServiceBitsW ;
+! : IdentifyCodeAuthzLevelW ;
+! : ImpersonateAnonymousToken ;
+! : ImpersonateLoggedOnUser ;
+! : ImpersonateNamedPipeClient ;
+! : ImpersonateSelf ;
+! : InitializeAcl ;
+! : InitializeSecurityDescriptor ;
+! : InitializeSid ;
+! : InitiateSystemShutdownA ;
+! : InitiateSystemShutdownExA ;
+! : InitiateSystemShutdownExW ;
+! : InitiateSystemShutdownW ;
+! : InstallApplication ;
+! : IsTextUnicode ;
+! : IsTokenRestricted ;
+! : IsTokenUntrusted ;
+! : IsValidAcl ;
+! : IsValidSecurityDescriptor ;
+! : IsValidSid ;
+! : IsWellKnownSid ;
+! : LockServiceDatabase ;
+! : LogonUserA ;
+! : LogonUserExA ;
+! : LogonUserExW ;
+! : LogonUserW ;
+! : LookupAccountNameA ;
+! : LookupAccountNameW ;
+! : LookupAccountSidA ;
+! : LookupAccountSidW ;
+! : LookupPrivilegeDisplayNameA ;
+! : LookupPrivilegeDisplayNameW ;
+! : LookupPrivilegeNameA ;
+! : LookupPrivilegeNameW ;
+! : LookupPrivilegeValueA ;
+FUNCTION: BOOL LookupPrivilegeValueW ( LPCTSTR lpSystemName,
+                               LPCTSTR lpName,
+                               PLUID lpLuid ) ;
+: LookupPrivilegeValue LookupPrivilegeValueW ;
+
+! : LookupSecurityDescriptorPartsA ;
+! : LookupSecurityDescriptorPartsW ;
+! : LsaAddAccountRights ;
+! : LsaAddPrivilegesToAccount ;
+! : LsaClearAuditLog ;
+! : LsaClose ;
+! : LsaCreateAccount ;
+! : LsaCreateSecret ;
+! : LsaCreateTrustedDomain ;
+! : LsaCreateTrustedDomainEx ;
+! : LsaDelete ;
+! : LsaDeleteTrustedDomain ;
+! : LsaEnumerateAccountRights ;
+! : LsaEnumerateAccounts ;
+! : LsaEnumerateAccountsWithUserRight ;
+! : LsaEnumeratePrivileges ;
+! : LsaEnumeratePrivilegesOfAccount ;
+! : LsaEnumerateTrustedDomains ;
+! : LsaEnumerateTrustedDomainsEx ;
+! : LsaFreeMemory ;
+! : LsaGetQuotasForAccount ;
+! : LsaGetRemoteUserName ;
+! : LsaGetSystemAccessAccount ;
+! : LsaGetUserName ;
+! : LsaICLookupNames ;
+! : LsaICLookupNamesWithCreds ;
+! : LsaICLookupSids ;
+! : LsaICLookupSidsWithCreds ;
+! : LsaLookupNames2 ;
+! : LsaLookupNames ;
+! : LsaLookupPrivilegeDisplayName ;
+! : LsaLookupPrivilegeName ;
+! : LsaLookupPrivilegeValue ;
+! : LsaLookupSids ;
+! : LsaNtStatusToWinError ;
+! : LsaOpenAccount ;
+! : LsaOpenPolicy ;
+! : LsaOpenPolicySce ;
+! : LsaOpenSecret ;
+! : LsaOpenTrustedDomain ;
+! : LsaOpenTrustedDomainByName ;
+! : LsaQueryDomainInformationPolicy ;
+! : LsaQueryForestTrustInformation ;
+! : LsaQueryInfoTrustedDomain ;
+! : LsaQueryInformationPolicy ;
+! : LsaQuerySecret ;
+! : LsaQuerySecurityObject ;
+! : LsaQueryTrustedDomainInfo ;
+! : LsaQueryTrustedDomainInfoByName ;
+! : LsaRemoveAccountRights ;
+! : LsaRemovePrivilegesFromAccount ;
+! : LsaRetrievePrivateData ;
+! : LsaSetDomainInformationPolicy ;
+! : LsaSetForestTrustInformation ;
+! : LsaSetInformationPolicy ;
+! : LsaSetInformationTrustedDomain ;
+! : LsaSetQuotasForAccount ;
+! : LsaSetSecret ;
+! : LsaSetSecurityObject ;
+! : LsaSetSystemAccessAccount ;
+! : LsaSetTrustedDomainInfoByName ;
+! : LsaSetTrustedDomainInformation ;
+! : LsaStorePrivateData ;
+! : MD4Final ;
+! : MD4Init ;
+! : MD4Update ;
+! : MD5Final ;
+! : MD5Init ;
+! : MD5Update ;
+! : MSChapSrvChangePassword2 ;
+! : MSChapSrvChangePassword ;
+! : MakeAbsoluteSD2 ;
+! : MakeAbsoluteSD ;
+! : MakeSelfRelativeSD ;
+! : MapGenericMask ;
+! : NotifyBootConfigStatus ;
+! : NotifyChangeEventLog ;
+! : ObjectCloseAuditAlarmA ;
+! : ObjectCloseAuditAlarmW ;
+! : ObjectDeleteAuditAlarmA ;
+! : ObjectDeleteAuditAlarmW ;
+! : ObjectOpenAuditAlarmA ;
+! : ObjectOpenAuditAlarmW ;
+! : ObjectPrivilegeAuditAlarmA ;
+! : ObjectPrivilegeAuditAlarmW ;
+! : OpenBackupEventLogA ;
+! : OpenBackupEventLogW ;
+! : OpenEncryptedFileRawA ;
+! : OpenEncryptedFileRawW ;
+! : OpenEventLogA ;
+! : OpenEventLogW ;
+
+! typedef enum _TOKEN_INFORMATION_CLASS {
+: TokenUser 1 ;
+: TokenGroups 2 ;
+: TokenPrivileges 3 ;
+: TokenOwner 4 ;
+: TokenPrimaryGroup 5 ;
+: TokenDefaultDacl 6 ;
+: TokenSource 7 ;
+: TokenType 8 ;
+: TokenImpersonationLevel 9 ;
+: TokenStatistics 10 ;
+: TokenRestrictedSids 11 ;
+: TokenSessionId 12 ;
+: TokenGroupsAndPrivileges 13 ;
+: TokenSessionReference 14 ;
+: TokenSandBoxInert 15 ;
+! } TOKEN_INFORMATION_CLASS;
+
+: DELETE                     HEX: 00010000 ; inline
+: READ_CONTROL               HEX: 00020000 ; inline
+: WRITE_DAC                  HEX: 00040000 ; inline
+: WRITE_OWNER                HEX: 00080000 ; inline
+: SYNCHRONIZE                HEX: 00100000 ; inline
+: STANDARD_RIGHTS_REQUIRED   HEX: 000f0000 ; inline
+
+: STANDARD_RIGHTS_READ       READ_CONTROL ; inline
+: STANDARD_RIGHTS_WRITE      READ_CONTROL ; inline
+: STANDARD_RIGHTS_EXECUTE    READ_CONTROL ; inline
+
+: TOKEN_TOKEN_ADJUST_DEFAULT   HEX: 0080 ; inline
+: TOKEN_ADJUST_GROUPS          HEX: 0040 ; inline
+: TOKEN_ADJUST_PRIVILEGES      HEX: 0020 ; inline
+: TOKEN_ADJUST_SESSIONID       HEX: 0100 ; inline
+: TOKEN_ASSIGN_PRIMARY         HEX: 0001 ; inline
+: TOKEN_DUPLICATE              HEX: 0002 ; inline
+: TOKEN_EXECUTE                STANDARD_RIGHTS_EXECUTE ; inline
+: TOKEN_IMPERSONATE            HEX: 0004 ; inline
+: TOKEN_QUERY                  HEX: 0008 ; inline
+: TOKEN_QUERY_SOURCE           HEX: 0010 ; inline
+: TOKEN_ADJUST_DEFAULT         HEX: 0080 ; inline
+: TOKEN_READ STANDARD_RIGHTS_READ TOKEN_QUERY bitor ;
+
+: TOKEN_WRITE
+    {
+        STANDARD_RIGHTS_WRITE
+        TOKEN_ADJUST_PRIVILEGES
+        TOKEN_ADJUST_GROUPS
+        TOKEN_ADJUST_DEFAULT
+    } flags ; foldable
+
+: TOKEN_ALL_ACCESS
+    {
+        STANDARD_RIGHTS_REQUIRED
+        TOKEN_ASSIGN_PRIMARY
+        TOKEN_DUPLICATE
+        TOKEN_IMPERSONATE
+        TOKEN_QUERY
+        TOKEN_QUERY_SOURCE
+        TOKEN_ADJUST_PRIVILEGES
+        TOKEN_ADJUST_GROUPS
+        TOKEN_ADJUST_SESSIONID
+        TOKEN_ADJUST_DEFAULT
+    } flags ; foldable
+
+FUNCTION: BOOL OpenProcessToken ( HANDLE ProcessHandle,
+                                  DWORD DesiredAccess,
+                                  PHANDLE TokenHandle ) ;
+! : OpenSCManagerA ;
+! : OpenSCManagerW ;
+! : OpenServiceA ;
+! : OpenServiceW ;
+FUNCTION: BOOL OpenThreadToken ( HANDLE ThreadHandle, DWORD DesiredAccess, BOOL OpenAsSelf, PHANDLE TokenHandle ) ;
+! : OpenTraceA ;
+! : OpenTraceW ;
+! : PrivilegeCheck ;
+! : PrivilegedServiceAuditAlarmA ;
+! : PrivilegedServiceAuditAlarmW ;
+! : ProcessIdleTasks ;
+! : ProcessTrace ;
+! : QueryAllTracesA ;
+! : QueryAllTracesW ;
+! : QueryRecoveryAgentsOnEncryptedFile ;
+! : QueryServiceConfig2A ;
+! : QueryServiceConfig2W ;
+! : QueryServiceConfigA ;
+! : QueryServiceConfigW ;
+! : QueryServiceLockStatusA ;
+! : QueryServiceLockStatusW ;
+! : QueryServiceObjectSecurity ;
+! : QueryServiceStatus ;
+! : QueryServiceStatusEx ;
+! : QueryTraceA ;
+! : QueryTraceW ;
+! : QueryUsersOnEncryptedFile ;
+! : QueryWindows31FilesMigration ;
+! : ReadEncryptedFileRaw ;
+! : ReadEventLogA ;
+! : ReadEventLogW ;
+! : RegCloseKey ;
+! : RegConnectRegistryA ;
+! : RegConnectRegistryW ;
+! : RegCreateKeyA ;
+! : RegCreateKeyExA ;
+! : RegCreateKeyExW ;
+! : RegCreateKeyW ;
+! : RegDeleteKeyA ;
+! : RegDeleteKeyW ;
+! : RegDeleteValueA ;
+! : RegDeleteValueW ;
+! : RegDisablePredefinedCache ;
+! : RegEnumKeyA ;
+! : RegEnumKeyExA ;
+! : RegEnumKeyExW ;
+! : RegEnumKeyW ;
+! : RegEnumValueA ;
+! : RegEnumValueW ;
+! : RegFlushKey ;
+! : RegGetKeySecurity ;
+! : RegLoadKeyA ;
+! : RegLoadKeyW ;
+! : RegNotifyChangeKeyValue ;
+! : RegOpenCurrentUser ;
+! : RegOpenKeyA ;
+! : RegOpenKeyExA ;
+! : RegOpenKeyExW ;
+! : RegOpenKeyW ;
+! : RegOpenUserClassesRoot ;
+! : RegOverridePredefKey ;
+! : RegQueryInfoKeyA ;
+! : RegQueryInfoKeyW ;
+! : RegQueryMultipleValuesA ;
+! : RegQueryMultipleValuesW ;
+! : RegQueryValueA ;
+! : RegQueryValueExA ;
+! : RegQueryValueExW ;
+! : RegQueryValueW ;
+! : RegReplaceKeyA ;
+! : RegReplaceKeyW ;
+! : RegRestoreKeyA ;
+! : RegRestoreKeyW ;
+! : RegSaveKeyA ;
+! : RegSaveKeyExA ;
+! : RegSaveKeyExW ;
+! : RegSaveKeyW ;
+! : RegSetKeySecurity ;
+! : RegSetValueA ;
+! : RegSetValueExA ;
+! : RegSetValueExW ;
+! : RegSetValueW ;
+! : RegUnLoadKeyA ;
+! : RegUnLoadKeyW ;
+! : RegisterEventSourceA ;
+! : RegisterEventSourceW ;
+! : RegisterIdleTask ;
+! : RegisterServiceCtrlHandlerA ;
+! : RegisterServiceCtrlHandlerExA ;
+! : RegisterServiceCtrlHandlerExW ;
+! : RegisterServiceCtrlHandlerW ;
+! : RegisterTraceGuidsA ;
+! : RegisterTraceGuidsW ;
+! : RemoveTraceCallback ;
+! : RemoveUsersFromEncryptedFile ;
+! : ReportEventA ;
+! : ReportEventW ;
+! : RevertToSelf ;
+! : SaferCloseLevel ;
+! : SaferComputeTokenFromLevel ;
+! : SaferCreateLevel ;
+! : SaferGetLevelInformation ;
+! : SaferGetPolicyInformation ;
+! : SaferIdentifyLevel ;
+! : SaferRecordEventLogEntry ;
+! : SaferSetLevelInformation ;
+! : SaferSetPolicyInformation ;
+! : SaferiChangeRegistryScope ;
+! : SaferiCompareTokenLevels ;
+! : SaferiIsExecutableFileType ;
+! : SaferiPopulateDefaultsInRegistry ;
+! : SaferiRecordEventLogEntry ;
+! : SaferiReplaceProcessThreadTokens ;
+! : SaferiSearchMatchingHashRules ;
+! : SetAclInformation ;
+! : SetEntriesInAccessListA ;
+! : SetEntriesInAccessListW ;
+! : SetEntriesInAclA ;
+! : SetEntriesInAclW ;
+! : SetEntriesInAuditListA ;
+! : SetEntriesInAuditListW ;
+! : SetFileSecurityA ;
+! : SetFileSecurityW ;
+! : SetInformationCodeAuthzLevelW ;
+! : SetInformationCodeAuthzPolicyW ;
+! : SetKernelObjectSecurity ;
+! : SetNamedSecurityInfoA ;
+! : SetNamedSecurityInfoExA ;
+! : SetNamedSecurityInfoExW ;
+! : SetNamedSecurityInfoW ;
+! : SetPrivateObjectSecurity ;
+! : SetPrivateObjectSecurityEx ;
+! : SetSecurityDescriptorControl ;
+! : SetSecurityDescriptorDacl ;
+! : SetSecurityDescriptorGroup ;
+! : SetSecurityDescriptorOwner ;
+! : SetSecurityDescriptorRMControl ;
+! : SetSecurityDescriptorSacl ;
+! : SetSecurityInfo ;
+! : SetSecurityInfoExA ;
+! : SetSecurityInfoExW ;
+! : SetServiceBits ;
+! : SetServiceObjectSecurity ;
+! : SetServiceStatus ;
+! : SetThreadToken ;
+! : SetTokenInformation ;
+! : SetTraceCallback ;
+! : SetUserFileEncryptionKey ;
+! : StartServiceA ;
+! : StartServiceCtrlDispatcherA ;
+! : StartServiceCtrlDispatcherW ;
+! : StartServiceW ;
+! : StartTraceA ;
+! : StartTraceW ;
+! : StopTraceA ;
+! : StopTraceW ;
+! : SynchronizeWindows31FilesAndWindowsNTRegistry ;
+! : SystemFunction001 ;
+! : SystemFunction002 ;
+! : SystemFunction003 ;
+! : SystemFunction004 ;
+! : SystemFunction005 ;
+! : SystemFunction006 ;
+! : SystemFunction007 ;
+! : SystemFunction008 ;
+! : SystemFunction009 ;
+! : SystemFunction010 ;
+! : SystemFunction011 ;
+! : SystemFunction012 ;
+! : SystemFunction013 ;
+! : SystemFunction014 ;
+! : SystemFunction015 ;
+! : SystemFunction016 ;
+! : SystemFunction017 ;
+! : SystemFunction018 ;
+! : SystemFunction019 ;
+! : SystemFunction020 ;
+! : SystemFunction021 ;
+! : SystemFunction022 ;
+! : SystemFunction023 ;
+! : SystemFunction024 ;
+! : SystemFunction025 ;
+! : SystemFunction026 ;
+! : SystemFunction027 ;
+! : SystemFunction028 ;
+! : SystemFunction029 ;
+! : SystemFunction030 ;
+! : SystemFunction031 ;
+! : SystemFunction032 ;
+! : SystemFunction033 ;
+! : SystemFunction034 ;
+! : SystemFunction035 ;
+! : SystemFunction036 ;
+! : SystemFunction040 ;
+! : SystemFunction041 ;
+! : TraceEvent ;
+! : TraceEventInstance ;
+! : TraceMessage ;
+! : TraceMessageVa ;
+! : TreeResetNamedSecurityInfoA ;
+! : TreeResetNamedSecurityInfoW ;
+! : TrusteeAccessToObjectA ;
+! : TrusteeAccessToObjectW ;
+! : UninstallApplication ;
+! : UnlockServiceDatabase ;
+! : UnregisterIdleTask ;
+! : UnregisterTraceGuids ;
+! : UpdateTraceA ;
+! : UpdateTraceW ;
+! : WdmWmiServiceMain ;
+! : WmiCloseBlock ;
+! : WmiCloseTraceWithCursor ;
+! : WmiConvertTimestamp ;
+! : WmiDevInstToInstanceNameA ;
+! : WmiDevInstToInstanceNameW ;
+! : WmiEnumerateGuids ;
+! : WmiExecuteMethodA ;
+! : WmiExecuteMethodW ;
+! : WmiFileHandleToInstanceNameA ;
+! : WmiFileHandleToInstanceNameW ;
+! : WmiFreeBuffer ;
+! : WmiGetFirstTraceOffset ;
+! : WmiGetNextEvent ;
+! : WmiGetTraceHeader ;
+! : WmiMofEnumerateResourcesA ;
+! : WmiMofEnumerateResourcesW ;
+! : WmiNotificationRegistrationA ;
+! : WmiNotificationRegistrationW ;
+! : WmiOpenBlock ;
+! : WmiOpenTraceWithCursor ;
+! : WmiParseTraceEvent ;
+! : WmiQueryAllDataA ;
+! : WmiQueryAllDataMultipleA ;
+! : WmiQueryAllDataMultipleW ;
+! : WmiQueryAllDataW ;
+! : WmiQueryGuidInformation ;
+! : WmiQuerySingleInstanceA ;
+! : WmiQuerySingleInstanceMultipleA ;
+! : WmiQuerySingleInstanceMultipleW ;
+! : WmiQuerySingleInstanceW ;
+! : WmiReceiveNotificationsA ;
+! : WmiReceiveNotificationsW ;
+! : WmiSetSingleInstanceA ;
+! : WmiSetSingleInstanceW ;
+! : WmiSetSingleItemA ;
+! : WmiSetSingleItemW ;
+! : Wow64Win32ApiEntry ;
+! : WriteEncryptedFileRaw ;
+
+
index 5884c18aee55264d8ceeac361b6c69ac0e82614c..238ff18c39d3a8cb7f92692620411b805755d7f3 100755 (executable)
@@ -1,8 +1,6 @@
-USING: alien alien.c-types kernel windows.ole32\r
-combinators.lib parser splitting sequences.lib\r
-sequences namespaces combinators.cleave\r
-assocs quotations shuffle accessors words macros\r
-alien.syntax fry ;\r
+USING: alien alien.c-types kernel windows.ole32 combinators.lib\r
+parser splitting sequences.lib sequences namespaces assocs\r
+quotations shuffle accessors words macros alien.syntax fry ;\r
 IN: windows.com.syntax\r
 \r
 <PRIVATE\r
index 37b833cae16701d5c23d57c57ba4839c528918a2..ec70b14e684b1c83254d22d7a486925f2a4a3d31 100644 (file)
@@ -125,7 +125,6 @@ TYPEDEF: FILE_NOTIFY_INFORMATION* PFILE_NOTIFY_INFORMATION
 : OF_REOPEN    32768 ;
 : OF_VERIFY    1024 ;
 
-
 : INFINITE HEX: FFFFFFFF ; inline
 
 ! From C:\cygwin\usr\include\w32api\winbase.h
@@ -189,6 +188,16 @@ TYPEDEF: FILE_NOTIFY_INFORMATION* PFILE_NOTIFY_INFORMATION
 : FILE_MAP_WRITE  2 ;
 : FILE_MAP_COPY   1 ;
 
+: THREAD_MODE_BACKGROUND_BEGIN HEX: 10000 ; inline
+: THREAD_MODE_BACKGROUND_END   HEX: 20000 ; inline
+: THREAD_PRIORITY_ABOVE_NORMAL 1 ; inline
+: THREAD_PRIORITY_BELOW_NORMAL -1 ; inline
+: THREAD_PRIORITY_HIGHEST 2 ; inline
+: THREAD_PRIORITY_IDLE -15 ; inline
+: THREAD_PRIORITY_LOWEST -2 ; inline
+: THREAD_PRIORITY_NORMAL 0 ; inline
+: THREAD_PRIORITY_TIME_CRITICAL 15 ; inline
+
 C-STRUCT: OVERLAPPED
     { "int" "internal" }
     { "int" "internal-high" }
@@ -998,7 +1007,7 @@ FUNCTION: HMODULE GetModuleHandleW ( LPCWSTR lpModuleName ) ;
 ! FUNCTION: GetNumberOfConsoleMouseButtons
 ! FUNCTION: GetOEMCP
 FUNCTION: BOOL GetOverlappedResult ( HANDLE hFile, LPOVERLAPPED lpOverlapped, LPDWORD lpNumberOfBytesTransferred, BOOL bWait ) ;
-! FUNCTION: GetPriorityClass
+FUNCTION: DWORD GetPriorityClass ( HANDLE hProcess ) ;
 ! FUNCTION: GetPrivateProfileIntA
 ! FUNCTION: GetPrivateProfileIntW
 ! FUNCTION: GetPrivateProfileSectionA
@@ -1065,8 +1074,8 @@ FUNCTION: UINT GetSystemWindowsDirectoryW ( LPTSTR lpBuffer, UINT uSize ) ;
 ! FUNCTION: GetThreadContext
 ! FUNCTION: GetThreadIOPendingFlag
 ! FUNCTION: GetThreadLocale
-! FUNCTION: GetThreadPriority
-! FUNCTION: GetThreadPriorityBoost
+FUNCTION: int GetThreadPriority ( HANDLE hThread ) ;
+FUNCTION: BOOL GetThreadPriorityBoost ( HANDLE hThread, PBOOL pDisablePriorityBoost ) ;
 ! FUNCTION: GetThreadSelectorEntry
 ! FUNCTION: GetThreadTimes
 ! FUNCTION: GetTickCount
@@ -1437,9 +1446,9 @@ FUNCTION: BOOL SetHandleInformation ( HANDLE hObject, DWORD dwMask, DWORD dwFlag
 ! FUNCTION: SetMailslotInfo
 ! FUNCTION: SetMessageWaitingIndicator
 ! FUNCTION: SetNamedPipeHandleState
-! FUNCTION: SetPriorityClass
+FUNCTION: BOOL SetPriorityClass ( HANDLE hProcess, DWORD dwPriorityClass ) ;
 ! FUNCTION: SetProcessAffinityMask
-! FUNCTION: SetProcessPriorityBoost
+FUNCTION: BOOL SetProcessPriorityBoost ( HANDLE hProcess, BOOL disablePriorityBoost ) ;
 ! FUNCTION: SetProcessShutdownParameters
 ! FUNCTION: SetProcessWorkingSetSize
 ! FUNCTION: SetStdHandle
@@ -1454,8 +1463,8 @@ FUNCTION: BOOL SetHandleInformation ( HANDLE hObject, DWORD dwMask, DWORD dwFlag
 ! FUNCTION: SetThreadExecutionState
 ! FUNCTION: SetThreadIdealProcessor
 ! FUNCTION: SetThreadLocale
-! FUNCTION: SetThreadPriority
-! FUNCTION: SetThreadPriorityBoost
+FUNCTION: BOOL SetThreadPriority ( HANDLE hThread, int nPriority ) ;
+FUNCTION: BOOL SetThreadPriorityBoost ( HANDLE hThread, BOOL disablePriorityBoost ) ;
 ! FUNCTION: SetThreadUILanguage
 ! FUNCTION: SetTimerQueueTimer
 ! FUNCTION: SetTimeZoneInformation
index 7be8d98e61b80676f228fb6deedfd1716da2fe1c..61b409e8e14af32fc3cf671f99e82b4282ed5e3c 100644 (file)
@@ -113,6 +113,7 @@ TYPEDEF: HANDLE              HSZ
 TYPEDEF: HANDLE              WINSTA   ! MS docs say  typedef HANDLE WINSTA ;
 TYPEDEF: HANDLE              HWINSTA  ! typo??
 TYPEDEF: HANDLE              HWND
+TYPEDEF: HANDLE              HCRYPTPROV
 TYPEDEF: WORD                LANGID
 TYPEDEF: DWORD               LCID
 TYPEDEF: DWORD               LCTYPE
old mode 100644 (file)
new mode 100755 (executable)
index ffccb5e..1194ff4
@@ -17,7 +17,7 @@ M: integer item>xml
     [ "Integers must fit in 32 bits" throw ] unless
     number>string "i4" build-tag ;
 
-PREDICATE: object boolean { t f } member? ;
+PREDICATE: boolean < object { t f } member? ;
 
 M: boolean item>xml
     "1" "0" ? "boolean" build-tag ;
old mode 100644 (file)
new mode 100755 (executable)
index 9d73a46..a7c8bf7
@@ -139,5 +139,5 @@ M: xml like
 : <contained-tag> ( name attrs -- tag )
     f <tag> ;
 
-PREDICATE: tag contained-tag tag-children not ;
-PREDICATE: tag open-tag tag-children ;
+PREDICATE: contained-tag < tag tag-children not ;
+PREDICATE: open-tag < tag tag-children ;
index b421ae011a588a8bef09cf6b92fedcecdaaf2dc2..6ba0b0d5605463625ce10368c9251fa0a10ba2dc 100755 (executable)
@@ -16,7 +16,7 @@ T{ extra-attrs T{ parsing-error f 1 32 } V{ T{ name f "" "foo" f } }
 T{ bad-version T{ parsing-error f 1 28 } "5 million" } "<?xml version='5 million'?><x/>" xml-error-test
 T{ notags f } "" xml-error-test
 T{ multitags f } "<x/><y/>" xml-error-test
-T{ bad-prolog T{ parsing-error f 1 26 } T{ prolog f "1.0" "iso-8859-1" f }
+T{ bad-prolog T{ parsing-error f 1 26 } T{ prolog f "1.0" "UTF-8" f }
 } "<x/><?xml version='1.0'?>" xml-error-test
 T{ capitalized-prolog T{ parsing-error f 1 6 } "XmL" } "<?XmL version='1.0'?><x/>"
 xml-error-test
index 6db98ec848e9333d3693956759f8bb03d79e5011..d81e807fe51c488012464f9c3445499c50068e5e 100644 (file)
@@ -40,4 +40,4 @@ M: object (r-ref) drop ;
         sample-doc string>xml dup template xml>string
     ] with-scope ;
 
-[ "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?><html xmlns:f=\"http://littledan.onigirihouse.com/namespaces/replace\"><body><span f:sub=\"foo\">foo</span><div f:sub=\"bar\">blah<a/></div><p f:sub=\"baz\"/></body></html>" ] [ test-refs ] unit-test
+[ "<?xml version=\"1.0\" encoding=\"UTF-8\"?><html xmlns:f=\"http://littledan.onigirihouse.com/namespaces/replace\"><body><span f:sub=\"foo\">foo</span><div f:sub=\"bar\">blah<a/></div><p f:sub=\"baz\"/></body></html>" ] [ test-refs ] unit-test
index 02c7aecb131f5d9eb029419a1555b4d47222e4e6..98146136e6d9e3e1099c2eccadf6c522a346e8d1 100644 (file)
@@ -26,7 +26,7 @@ SYMBOL: xml-file
 ] unit-test
 [ V{ "fa&g" } ] [ xml-file get "x" get-id tag-children ] unit-test
 [ "that" ] [ xml-file get "this" swap at ] unit-test
-[ "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?><a b=\"c\"/>" ]
+[ "<?xml version=\"1.0\" encoding=\"UTF-8\"?><a b=\"c\"/>" ]
     [ "<a b='c'/>" string>xml xml>string ] unit-test
 [ "abcd" ] [
     "<main>a<sub>bc</sub>d<nothing/></main>" string>xml
@@ -44,7 +44,7 @@ SYMBOL: xml-file
     at swap "z" >r tuck r> swap set-at
     T{ name f "blah" "z" f } swap at ] unit-test
 [ "foo" ] [ "<boo><![CDATA[foo]]></boo>" string>xml children>string ] unit-test
-[ "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?><foo>bar baz</foo>" ]
+[ "<?xml version=\"1.0\" encoding=\"UTF-8\"?><foo>bar baz</foo>" ]
 [ "<foo>bar</foo>" string>xml [ " baz" append ] map xml>string ] unit-test
-[ "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n<foo>\n  bar\n</foo>" ]
+[ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<foo>\n  bar\n</foo>" ]
 [ "<foo>         bar            </foo>" string>xml pprint-xml>string ] unit-test
index d99c306b2bd531680b8f7519c6b21e2265e5049f..b2b7d78b3e353557b7ab8fbf8f74745a64bcbcd9 100644 (file)
@@ -172,7 +172,7 @@ SYMBOL: ns-stack
     [ T{ name f "" "version" f } swap at
       [ good-version ] [ <versionless-prolog> throw ] if* ] keep
     [ T{ name f "" "encoding" f } swap at
-      "iso-8859-1" or ] keep
+      "UTF-8" or ] keep
     T{ name f "" "standalone" f } swap at
     [ yes/no>bool ] [ f ] if*
     <prolog> ;
index d6814851eecd826fc42f1a3008617564466b4402..b397e3c7b157f0fddf4ea7048254de24985c9af6 100755 (executable)
@@ -42,7 +42,7 @@ M: process-missing error.
     >r 1array r> build-tag* ;
 
 : standard-prolog ( -- prolog )
-    T{ prolog f "1.0" "iso-8859-1" f } ;
+    T{ prolog f "1.0" "UTF-8" f } ;
 
 : build-xml ( tag -- xml )
     standard-prolog { } rot { } <xml> ;
index 970ff39cf1dca0b6f31dccdfb39c24622b1bf6b7..61ef27b72ef67a7f94fbf84207e3c8af3c03d461 100644 (file)
@@ -63,7 +63,7 @@ M: closer process
     V{ } clone xml-stack set f push-xml ;
 
 : default-prolog ( -- prolog )
-    "1.0" "iso-8859-1" f <prolog> ;
+    "1.0" "UTF-8" f <prolog> ;
 
 : reset-prolog ( -- )
     default-prolog prolog-data set ;
index c7eaafe88769a23f79de24733ebcc7a5e4215bb9..822b290f88438951af6c6fac33707a8e8b476c94 100755 (executable)
@@ -63,7 +63,7 @@ SYMBOL: rule-sets
     over [ dupd update ] [ nip clone ] if ;
 
 : import-keywords ( parent child -- )
-    over >r [ rule-set-keywords ] 2apply ?update
+    over >r [ rule-set-keywords ] bi@ ?update
     r> set-rule-set-keywords ;
 
 : import-rules ( parent child -- )
index 379f6d6c9457d1441adffe24e4b982f6cd1e917a..5fabe2b17dc52927e4821930b6850d297320e828 100755 (executable)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.\r
 USING: io.files io.encodings.utf8 namespaces http.server\r
 http.server.static http xmode.code2html kernel html sequences\r
-accessors fry combinators.cleave ;\r
+accessors fry ;\r
 IN: xmode.code2html.responder\r
 \r
 : <sources> ( root -- responder )\r
diff --git a/misc/factor.sh b/misc/factor.sh
deleted file mode 100755 (executable)
index 9d4f26f..0000000
+++ /dev/null
@@ -1,438 +0,0 @@
-#!/usr/bin/env bash
-
-# Programs returning != 0 will not cause script to exit
-set +e
-
-# Case insensitive string comparison
-shopt -s nocaseglob
-#shopt -s nocasematch
-
-OS=
-ARCH=
-WORD=
-NO_UI=
-GIT_PROTOCOL=${GIT_PROTOCOL:="git"}
-GIT_URL=${GIT_URL:=$GIT_PROTOCOL"://factorcode.org/git/factor.git"}
-
-test_program_installed() {
-    if ! [[ -n `type -p $1` ]] ; then
-        return 0;
-    fi
-    return 1;
-}
-
-ensure_program_installed() {
-    installed=0;
-    for i in $* ;
-    do
-        echo -n "Checking for $i..."
-        test_program_installed $i
-        if [[ $? -eq 0 ]]; then
-            echo -n "not "
-        else    
-            installed=$(( $installed + 1 ))
-        fi
-        echo "found!"
-    done
-    if [[ $installed -eq 0 ]] ; then
-        echo -n "Install "
-        if [[ $# -eq 1 ]] ; then
-            echo -n $1
-        else
-            echo -n "any of [ $* ]"
-        fi
-        echo " and try again."
-        exit 1
-    fi
-}
-
-check_ret() {
-    RET=$?
-    if [[ $RET -ne 0 ]] ; then
-       echo $1 failed
-       exit 2
-    fi
-}
-
-check_gcc_version() {
-    echo -n "Checking gcc version..."
-    GCC_VERSION=`$CC --version`
-    check_ret gcc
-    if [[ $GCC_VERSION == *3.3.* ]] ; then
-        echo "bad!"
-        echo "You have a known buggy version of gcc (3.3)"
-        echo "Install gcc 3.4 or higher and try again."
-        exit 3
-    fi
-    echo "ok."
-}
-
-set_downloader() {
-    test_program_installed wget curl
-    if [[ $? -ne 0 ]] ; then
-        DOWNLOADER=wget
-    else
-        DOWNLOADER="curl -O"
-    fi
-}
-
-set_md5sum() {
-    test_program_installed md5sum
-    if [[ $? -ne 0 ]] ; then
-        MD5SUM=md5sum
-    else
-        MD5SUM="md5 -r"
-    fi
-}
-
-set_gcc() {
-    case $OS in
-        openbsd) ensure_program_installed egcc; CC=egcc;;
-       netbsd) if [[ $WORD -eq 64 ]] ; then
-                       CC=/usr/pkg/gcc34/bin/gcc
-               fi ;;
-        *) CC=gcc;;
-    esac
-}
-
-set_make() {
-    case $OS in
-        netbsd) MAKE='gmake';;
-        freebsd) MAKE='gmake';;
-        openbsd) MAKE='gmake';;
-        dragonflybsd) MAKE='gmake';;
-        *) MAKE='make';;
-    esac
-    if ! [[ $MAKE -eq 'gmake' ]] ; then
-       ensure_program_installed gmake
-    fi
-}
-
-check_installed_programs() {
-    ensure_program_installed chmod
-    ensure_program_installed uname
-    ensure_program_installed git
-    ensure_program_installed wget curl
-    ensure_program_installed gcc
-    ensure_program_installed make gmake
-    ensure_program_installed md5sum md5
-    ensure_program_installed cut
-    check_gcc_version
-}
-
-check_library_exists() {
-    GCC_TEST=factor-library-test.c
-    GCC_OUT=factor-library-test.out
-    echo -n "Checking for library $1..."
-    echo "int main(){return 0;}" > $GCC_TEST
-    $CC $GCC_TEST -o $GCC_OUT -l $1
-    if [[ $? -ne 0 ]] ; then
-        echo "not found!"
-        echo "Warning: library $1 not found."
-        echo "***Factor will compile NO_UI=1"
-        NO_UI=1
-    fi
-    rm -f $GCC_TEST
-    check_ret rm
-    rm -f $GCC_OUT
-    check_ret rm
-    echo "found."
-}
-
-check_X11_libraries() {
-    check_library_exists freetype
-    check_library_exists GLU
-    check_library_exists GL
-    check_library_exists X11
-}
-
-check_libraries() {
-    case $OS in
-            linux) check_X11_libraries;;
-    esac
-}
-
-check_factor_exists() {
-    if [[ -d "factor" ]] ; then
-        echo "A directory called 'factor' already exists."
-        echo "Rename or delete it and try again."
-        exit 4
-    fi
-}
-
-find_os() {
-    echo "Finding OS..."
-    uname_s=`uname -s`
-    check_ret uname
-    case $uname_s in
-        CYGWIN_NT-5.2-WOW64) OS=winnt;;
-        *CYGWIN_NT*) OS=winnt;;
-        *CYGWIN*) OS=winnt;;
-        *darwin*) OS=macosx;;
-        *Darwin*) OS=macosx;;
-        *linux*) OS=linux;;
-        *Linux*) OS=linux;;
-        *NetBSD*) OS=netbsd;;
-        *FreeBSD*) OS=freebsd;;
-        *OpenBSD*) OS=openbsd;;
-        *DragonFly*) OS=dragonflybsd;;
-    esac
-}
-
-find_architecture() {
-    echo "Finding ARCH..."
-    uname_m=`uname -m`
-    check_ret uname
-    case $uname_m in
-       i386) ARCH=x86;;
-       i686) ARCH=x86;;
-       amd64) ARCH=x86;;
-       *86) ARCH=x86;;
-       *86_64) ARCH=x86;;
-       "Power Macintosh") ARCH=ppc;;
-    esac
-}
-
-write_test_program() {
-    echo "#include <stdio.h>" > $C_WORD.c
-    echo "int main(){printf(\"%d\", 8*sizeof(void*)); return 0; }" >> $C_WORD.c
-}
-
-find_word_size() {
-    echo "Finding WORD..."
-    C_WORD=factor-word-size
-    write_test_program
-    gcc -o $C_WORD $C_WORD.c
-    WORD=$(./$C_WORD)
-    check_ret $C_WORD
-    rm -f $C_WORD*
-}
-
-set_factor_binary() {
-    case $OS in
-        # winnt) FACTOR_BINARY=factor-nt;;
-        # macosx) FACTOR_BINARY=./Factor.app/Contents/MacOS/factor;;
-        *) FACTOR_BINARY=factor;;
-    esac
-}
-
-echo_build_info() {
-    echo OS=$OS
-    echo ARCH=$ARCH
-    echo WORD=$WORD
-    echo FACTOR_BINARY=$FACTOR_BINARY
-    echo MAKE_TARGET=$MAKE_TARGET
-    echo BOOT_IMAGE=$BOOT_IMAGE
-    echo MAKE_IMAGE_TARGET=$MAKE_IMAGE_TARGET
-    echo GIT_PROTOCOL=$GIT_PROTOCOL
-    echo GIT_URL=$GIT_URL
-    echo DOWNLOADER=$DOWNLOADER
-    echo CC=$CC
-    echo MAKE=$MAKE
-}
-
-set_build_info() {
-    if ! [[ -n $OS && -n $ARCH && -n $WORD ]] ; then
-        echo "OS: $OS"
-        echo "ARCH: $ARCH"
-        echo "WORD: $WORD"
-        echo "OS, ARCH, or WORD is empty.  Please report this"
-        exit 5
-    fi
-
-    MAKE_TARGET=$OS-$ARCH-$WORD
-    MAKE_IMAGE_TARGET=$ARCH.$WORD
-    BOOT_IMAGE=boot.$ARCH.$WORD.image
-    if [[ $OS == macosx && $ARCH == ppc ]] ; then
-        MAKE_IMAGE_TARGET=$OS-$ARCH
-        MAKE_TARGET=$OS-$ARCH
-        BOOT_IMAGE=boot.macosx-ppc.image
-    fi
-    if [[ $OS == linux && $ARCH == ppc ]] ; then
-        MAKE_IMAGE_TARGET=$OS-$ARCH
-        MAKE_TARGET=$OS-$ARCH
-        BOOT_IMAGE=boot.linux-ppc.image
-    fi
-}
-
-find_build_info() {
-    find_os
-    find_architecture
-    find_word_size
-    set_factor_binary
-    set_build_info
-       set_downloader
-       set_gcc
-       set_make
-    echo_build_info
-}
-
-invoke_git() {
-    git $*
-    check_ret git
-}
-
-git_clone() {
-    echo "Downloading the git repository from factorcode.org..."
-    invoke_git clone $GIT_URL
-}
-
-git_pull_factorcode() {
-    echo "Updating the git repository from factorcode.org..."
-    invoke_git pull $GIT_URL master
-}
-
-cd_factor() {
-    cd factor
-    check_ret cd
-}
-
-invoke_make() {
-   $MAKE $*
-   check_ret $MAKE
-}
-
-make_clean() {
-    invoke_make clean
-}
-
-make_factor() {
-    invoke_make NO_UI=$NO_UI $MAKE_TARGET -j5
-}
-
-update_boot_images() {
-    echo "Deleting old images..."
-    rm checksums.txt* > /dev/null 2>&1
-    rm $BOOT_IMAGE.* > /dev/null 2>&1
-    rm staging.*.image > /dev/null 2>&1
-    if [[ -f $BOOT_IMAGE ]] ; then
-        get_url http://factorcode.org/images/latest/checksums.txt
-        factorcode_md5=`cat checksums.txt|grep $BOOT_IMAGE|cut -f2 -d' '`;
-        set_md5sum
-        case $OS in
-             netbsd) disk_md5=`md5 $BOOT_IMAGE | cut -f4 -d' '`;;
-             *) disk_md5=`$MD5SUM $BOOT_IMAGE|cut -f1 -d' '` ;;
-        esac
-        echo "Factorcode md5: $factorcode_md5";
-        echo "Disk md5: $disk_md5";
-        if [[ "$factorcode_md5" == "$disk_md5" ]] ; then
-            echo "Your disk boot image matches the one on factorcode.org."
-        else
-            rm $BOOT_IMAGE > /dev/null 2>&1
-            get_boot_image;
-        fi
-    else
-        get_boot_image
-    fi
-}
-
-get_boot_image() {
-    echo "Downloading boot image $BOOT_IMAGE."
-    get_url http://factorcode.org/images/latest/$BOOT_IMAGE
-}
-
-get_url() {
-    if [[ $DOWNLOADER -eq "" ]] ; then
-        set_downloader;
-    fi
-    echo $DOWNLOADER $1 ;
-    $DOWNLOADER $1
-    check_ret $DOWNLOADER
-}
-
-maybe_download_dlls() {
-    if [[ $OS == winnt ]] ; then
-        get_url http://factorcode.org/dlls/freetype6.dll
-        get_url http://factorcode.org/dlls/zlib1.dll
-        get_url http://factorcode.org/dlls/OpenAL32.dll
-        get_url http://factorcode.org/dlls/alut.dll
-        get_url http://factorcode.org/dlls/ogg.dll
-        get_url http://factorcode.org/dlls/theora.dll
-        get_url http://factorcode.org/dlls/vorbis.dll
-        get_url http://factorcode.org/dlls/sqlite3.dll
-        chmod 777 *.dll
-        check_ret chmod
-    fi
-}
-
-get_config_info() {
-    find_build_info
-    check_installed_programs
-    check_libraries
-}
-
-bootstrap() {
-    ./$FACTOR_BINARY -i=$BOOT_IMAGE
-}
-
-install() {
-    check_factor_exists
-    get_config_info
-    git_clone
-    cd_factor
-    make_factor
-    get_boot_image
-    maybe_download_dlls
-    bootstrap
-}
-
-
-update() {
-    get_config_info
-    git_pull_factorcode
-    make_clean
-    make_factor
-}
-
-update_bootstrap() {
-    update_boot_images
-    bootstrap
-}
-
-refresh_image() {
-    ./$FACTOR_BINARY -script -e="USE: vocabs.loader refresh-all USE: memory save 0 USE: system exit"
-    check_ret factor
-}
-
-make_boot_image() {
-    ./$FACTOR_BINARY -script -e="\"$MAKE_IMAGE_TARGET\" USE: bootstrap.image make-image save 0 USE: system exit"
-    check_ret factor
-
-}
-
-install_build_system_apt() {
-    ensure_program_installed yes
-    yes | sudo apt-get install sudo libc6-dev libfreetype6-dev libx11-dev xorg-dev glutg3-dev wget git-core git-doc rlwrap gcc make
-    check_ret sudo
-}
-
-install_build_system_port() {
-    test_program_installed git
-    if [[ $? -ne 1 ]] ; then
-       ensure_program_installed yes
-               echo "git not found."
-               echo "This script requires either git-core or port."
-               echo "If it fails, install git-core or port and try again."
-       ensure_program_installed port
-               echo "Installing git-core with port...this will take awhile."
-       yes | sudo port install git-core
-    fi
-}
-
-usage() {
-    echo "usage: $0 install|install-x11|install-macosx|self-update|quick-update|update|bootstrap|net-bootstrap"
-    echo "If you are behind a firewall, invoke as:"
-    echo "env GIT_PROTOCOL=http $0 <command>"
-}
-
-case "$1" in
-    install) install ;;
-    install-x11) install_build_system_apt; install ;;
-    install-macosx) install_build_system_port; install ;;
-    self-update) update; make_boot_image; bootstrap;;
-    quick-update) update; refresh_image ;;
-    update) update; update_bootstrap ;;
-    bootstrap) get_config_info; bootstrap ;;
-    net-bootstrap) get_config_info; update_boot_images; bootstrap ;;
-    *) usage ;;
-esac
index 342bbb6af4cdf9543d7d7310ff5ba4b1aa897e03..0a1fad575aa78b5e2535a9d9d45e8478aff5f511 100755 (executable)
@@ -156,10 +156,12 @@ CELL untagged_object_size(CELL pointer)
 /* Size of the data area of an object pointed to by an untagged pointer */
 CELL unaligned_object_size(CELL pointer)
 {
+       F_TUPLE *tuple;
+       F_TUPLE_LAYOUT *layout;
+
        switch(untag_header(get(pointer)))
        {
        case ARRAY_TYPE:
-       case TUPLE_TYPE:
        case BIGNUM_TYPE:
                return array_size(array_capacity((F_ARRAY*)pointer));
        case BYTE_ARRAY_TYPE:
@@ -173,6 +175,10 @@ CELL unaligned_object_size(CELL pointer)
                        float_array_capacity((F_FLOAT_ARRAY*)pointer));
        case STRING_TYPE:
                return string_size(string_capacity((F_STRING*)pointer));
+       case TUPLE_TYPE:
+               tuple = untag_object(pointer);
+               layout = untag_object(tuple->layout);
+               return tuple_size(layout);
        case QUOTATION_TYPE:
                return sizeof(F_QUOTATION);
        case WORD_TYPE:
@@ -192,6 +198,8 @@ CELL unaligned_object_size(CELL pointer)
        case CALLSTACK_TYPE:
                return callstack_size(
                        untag_fixnum_fast(((F_CALLSTACK *)pointer)->length));
+       case TUPLE_LAYOUT_TYPE:
+               return sizeof(F_TUPLE_LAYOUT);
        default:
                critical_error("Invalid header",pointer);
                return -1; /* can't happen */
index 279d925bd75df8808fbd6445ebb524fc9652957b..7e18738afc721e1ca00463fbe714f4ea6ffb79aa 100755 (executable)
@@ -57,6 +57,35 @@ void print_array(F_ARRAY* array, CELL nesting)
                printf("...");
 }
 
+void print_tuple(F_TUPLE* tuple, CELL nesting)
+{
+       F_TUPLE_LAYOUT *layout = untag_object(tuple->layout);
+       CELL length = to_fixnum(layout->size);
+
+       printf(" ");
+       print_nested_obj(layout->class,nesting);
+
+       CELL i;
+       bool trimmed;
+
+       if(length > 10)
+       {
+               trimmed = true;
+               length = 10;
+       }
+       else
+               trimmed = false;
+
+       for(i = 0; i < length; i++)
+       {
+               printf(" ");
+               print_nested_obj(tuple_nth(tuple,i),nesting);
+       }
+
+       if(trimmed)
+               printf("...");
+}
+
 void print_nested_obj(CELL obj, F_FIXNUM nesting)
 {
        if(nesting <= 0)
@@ -83,7 +112,7 @@ void print_nested_obj(CELL obj, F_FIXNUM nesting)
                break;
        case TUPLE_TYPE:
                printf("T{");
-               print_array(untag_object(obj),nesting - 1);
+               print_tuple(untag_object(obj),nesting - 1);
                printf(" }");
                break;
        case ARRAY_TYPE:
index d9f8ac2461585de4bd8113adeac25ea970d7bbd0..28c6c40c1d1379499864a1346813bee3818dc439 100755 (executable)
@@ -216,25 +216,45 @@ void fixup_callstack_object(F_CALLSTACK *stack)
 /* Initialize an object in a newly-loaded image */
 void relocate_object(CELL relocating)
 {
-       do_slots(relocating,data_fixup);
+       /* Tuple relocation is a bit trickier; we have to fix up the
+       fixup object before we can get the tuple size, so do_slots is
+       out of the question */
+       if(untag_header(get(relocating)) == TUPLE_TYPE)
+       {
+               data_fixup((CELL *)relocating + 1);
+
+               CELL scan = relocating + 2 * CELLS;
+               CELL size = untagged_object_size(relocating);
+               CELL end = relocating + size;
 
-       switch(untag_header(get(relocating)))
+               while(scan < end)
+               {
+                       data_fixup((CELL *)scan);
+                       scan += CELLS;
+               }
+       }
+       else
        {
-       case WORD_TYPE:
-               fixup_word((F_WORD *)relocating);
-               break;
-       case QUOTATION_TYPE:
-               fixup_quotation((F_QUOTATION *)relocating);
-               break;
-       case DLL_TYPE:
-               ffi_dlopen((F_DLL *)relocating);
-               break;
-       case ALIEN_TYPE:
-               fixup_alien((F_ALIEN *)relocating);
-               break;
-       case CALLSTACK_TYPE:
-               fixup_callstack_object((F_CALLSTACK *)relocating);
-               break;
+               do_slots(relocating,data_fixup);
+
+               switch(untag_header(get(relocating)))
+               {
+               case WORD_TYPE:
+                       fixup_word((F_WORD *)relocating);
+                       break;
+               case QUOTATION_TYPE:
+                       fixup_quotation((F_QUOTATION *)relocating);
+                       break;
+               case DLL_TYPE:
+                       ffi_dlopen((F_DLL *)relocating);
+                       break;
+               case ALIEN_TYPE:
+                       fixup_alien((F_ALIEN *)relocating);
+                       break;
+               case CALLSTACK_TYPE:
+                       fixup_callstack_object((F_CALLSTACK *)relocating);
+                       break;
+               }
        }
 }
 
index 5ed7c83df2164d4ef013b98d18d97696d1c14449..ff938309e7a3e1ef2286d4a10a67e78d6fcc6d1d 100755 (executable)
@@ -58,8 +58,9 @@ typedef signed long long s64;
 #define ALIEN_TYPE 16
 #define WORD_TYPE 17
 #define BYTE_ARRAY_TYPE 18
+#define TUPLE_LAYOUT_TYPE 19
 
-#define TYPE_COUNT 19
+#define TYPE_COUNT 20
 
 INLINE bool immediate_p(CELL obj)
 {
@@ -224,3 +225,25 @@ typedef struct
        /* Frame size in bytes */
        CELL size;
 } F_STACK_FRAME;
+
+typedef struct
+{
+       CELL header;
+       /* tagged fixnum */
+       CELL hashcode;
+       /* tagged */
+       CELL class;
+       /* tagged fixnum */
+       CELL size;
+       /* tagged array */
+       CELL superclasses;
+       /* tagged fixnum */
+       CELL echelon;
+} F_TUPLE_LAYOUT;
+
+typedef struct
+{
+       CELL header;
+       /* tagged layout */
+       CELL layout;
+} F_TUPLE;
diff --git a/vm/os-linux-x86-32.h b/vm/os-linux-x86-32.h
deleted file mode 100644 (file)
index b458fcb..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <ucontext.h>
-
-INLINE void *ucontext_stack_pointer(void *uap)
-{
-        ucontext_t *ucontext = (ucontext_t *)uap;
-        return (void *)ucontext->uc_mcontext.gregs[7];
-}
-
-#define UAP_PROGRAM_COUNTER(ucontext) \
-       (((ucontext_t *)(ucontext))->uc_mcontext.gregs[14])
diff --git a/vm/os-linux-x86-64.h b/vm/os-linux-x86-64.h
deleted file mode 100644 (file)
index 911c2f1..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <ucontext.h>
-
-INLINE void *ucontext_stack_pointer(void *uap)
-{
-        ucontext_t *ucontext = (ucontext_t *)uap;
-        return (void *)ucontext->uc_mcontext.gregs[15];
-}
-
-#define UAP_PROGRAM_COUNTER(ucontext) \
-       (((ucontext_t *)(ucontext))->uc_mcontext.gregs[16])
diff --git a/vm/os-linux-x86.32.h b/vm/os-linux-x86.32.h
new file mode 100644 (file)
index 0000000..b458fcb
--- /dev/null
@@ -0,0 +1,10 @@
+#include <ucontext.h>
+
+INLINE void *ucontext_stack_pointer(void *uap)
+{
+        ucontext_t *ucontext = (ucontext_t *)uap;
+        return (void *)ucontext->uc_mcontext.gregs[7];
+}
+
+#define UAP_PROGRAM_COUNTER(ucontext) \
+       (((ucontext_t *)(ucontext))->uc_mcontext.gregs[14])
diff --git a/vm/os-linux-x86.64.h b/vm/os-linux-x86.64.h
new file mode 100644 (file)
index 0000000..911c2f1
--- /dev/null
@@ -0,0 +1,10 @@
+#include <ucontext.h>
+
+INLINE void *ucontext_stack_pointer(void *uap)
+{
+        ucontext_t *ucontext = (ucontext_t *)uap;
+        return (void *)ucontext->uc_mcontext.gregs[15];
+}
+
+#define UAP_PROGRAM_COUNTER(ucontext) \
+       (((ucontext_t *)(ucontext))->uc_mcontext.gregs[16])
diff --git a/vm/os-netbsd-x86.32.h b/vm/os-netbsd-x86.32.h
new file mode 100644 (file)
index 0000000..ca4a9f8
--- /dev/null
@@ -0,0 +1,3 @@
+#include <ucontext.h>
+
+#define ucontext_stack_pointer(uap) ((void *)_UC_MACHINE_SP((ucontext_t *)uap))
diff --git a/vm/os-netbsd-x86.64.h b/vm/os-netbsd-x86.64.h
new file mode 100644 (file)
index 0000000..587dc85
--- /dev/null
@@ -0,0 +1,4 @@
+#include <ucontext.h>
+
+#define ucontext_stack_pointer(uap) \
+       ((void *)(((ucontext_t *)(uap))->uc_mcontext.__gregs[_REG_URSP]))
index e282828577419d02c84d53e8395cf1e77c28f566..b42c6b9d7e67ccbb22f233da62b31194a0b5a3ad 100644 (file)
@@ -1,6 +1,5 @@
 #include <ucontext.h>
 
-#define ucontext_stack_pointer(uap) ((void *)_UC_MACHINE_SP((ucontext_t *)uap))
 #define UAP_PROGRAM_COUNTER(uap)    _UC_MACHINE_PC((ucontext_t *)uap)
 
 #define UNKNOWN_TYPE_P(file) ((file)->d_type == DT_UNKNOWN)
diff --git a/vm/os-solaris-x86.32.h b/vm/os-solaris-x86.32.h
new file mode 100644 (file)
index 0000000..1f4ec74
--- /dev/null
@@ -0,0 +1,10 @@
+#include <ucontext.h>
+
+INLINE void *ucontext_stack_pointer(void *uap)
+{
+        ucontext_t *ucontext = (ucontext_t *)uap;
+        return (void *)ucontext->uc_mcontext.gregs[ESP];
+}
+
+#define UAP_PROGRAM_COUNTER(ucontext) \
+       (((ucontext_t *)(ucontext))->uc_mcontext.gregs[EIP])
diff --git a/vm/os-solaris-x86.64.h b/vm/os-solaris-x86.64.h
new file mode 100644 (file)
index 0000000..54d1866
--- /dev/null
@@ -0,0 +1,10 @@
+#include <ucontext.h>
+
+INLINE void *ucontext_stack_pointer(void *uap)
+{
+        ucontext_t *ucontext = (ucontext_t *)uap;
+        return (void *)ucontext->uc_mcontext.gregs[RSP];
+}
+
+#define UAP_PROGRAM_COUNTER(ucontext) \
+       (((ucontext_t *)(ucontext))->uc_mcontext.gregs[RIP])
index 788a78090bfbecd70cd8d3b8b32f461a74f5d563..909cc3f4e9ef23106904d0e3a19dd95838b157b9 100644 (file)
@@ -1,2 +1,4 @@
 #define UNKNOWN_TYPE_P(file) 1
 #define DIRECTORY_P(file) 0
+
+extern char **environ;
index cd2b6e0a0eccd9a9097fe5b3d2625f03b310649d..a8c8ba756f028ea0b21e9fcb1b61a34e053a217b 100644 (file)
                        #endif
                #elif defined(__NetBSD__)
                        #define FACTOR_OS_STRING "netbsd"
+
+                       #if defined(FACTOR_X86)
+                               #include "os-netbsd-x86.32.h"
+                       #elif defined(FACTOR_AMD64)
+                               #include "os-netbsd-x86.64.h"
+                       #else
+                               #error "Unsupported NetBSD flavor"
+                       #endif
+
                        #include "os-netbsd.h"
                #elif defined(linux)
                        #define FACTOR_OS_STRING "linux"
                        #include "os-linux.h"
 
                        #if defined(FACTOR_X86)
-                               #include "os-linux-x86-32.h"
+                               #include "os-linux-x86.32.h"
                        #elif defined(FACTOR_PPC)
                                #include "os-unix-ucontext.h"
                                #include "os-linux-ppc.h"
                        #elif defined(FACTOR_ARM)
                                #include "os-linux-arm.h"
                        #elif defined(FACTOR_AMD64)
-                               #include "os-linux-x86-64.h"
+                               #include "os-linux-x86.64.h"
                        #else
                                #error "Unsupported Linux flavor"
                        #endif
                #elif defined(__SVR4) && defined(sun)
                        #define FACTOR_OS_STRING "solaris"
+
+                       #if defined(FACTOR_X86)
+                               #include "os-solaris-x86.32.h"
+                       #elif defined(FACTOR_AMD64)
+                               #incluide "os-solaris-x86.64.h"
+                       #else
+                               #error "Unsupported Solaris flavor"
+                       #endif
+
                        #include "os-solaris.h"
-                       #include "os-unix-ucontext.h"
                #else
                        #error "Unsupported OS"
                #endif
index ce26c20f63a03c92e11079db4457f5ef474f65df..203ebb7f6b968670ef13612773b19012d0bc6596 100755 (executable)
@@ -169,11 +169,10 @@ void *primitives[] = {
        primitive_wrapper,
        primitive_clone,
        primitive_string,
-       primitive_to_tuple,
        primitive_array_to_quotation,
        primitive_quotation_xt,
        primitive_tuple,
-       primitive_tuple_to_array,
+       primitive_tuple_layout,
        primitive_profiling,
        primitive_become,
        primitive_sleep,
index 2e541a5b6c3ccada6454343bfb23c8346e17279b..d03d999ffdf47f019455d1ca6bf2c8f1f6ca895c 100755 (executable)
--- a/vm/run.c
+++ b/vm/run.c
@@ -320,8 +320,9 @@ DEFINE_PRIMITIVE(class_hash)
        CELL tag = TAG(obj);
        if(tag == TUPLE_TYPE)
        {
-               F_WORD *class = untag_object(get(SLOT(obj,2)));
-               drepl(class->hashcode);
+               F_TUPLE *tuple = untag_object(obj);
+               F_TUPLE_LAYOUT *layout = untag_object(tuple->layout);
+               drepl(layout->hashcode);
        }
        else if(tag == OBJECT_TYPE)
                drepl(get(UNTAG(obj)));
index fb61213385356529b43901afe57e40189a036c33..24bb4cb3ca53a130038d5e33ae7f16fa034a47b1 100755 (executable)
@@ -379,45 +379,61 @@ DEFINE_PRIMITIVE(resize_float_array)
        dpush(tag_object(reallot_float_array(array,capacity)));
 }
 
+/* Tuple layouts */
+DEFINE_PRIMITIVE(tuple_layout)
+{
+       F_TUPLE_LAYOUT *layout = allot_object(TUPLE_LAYOUT_TYPE,sizeof(F_TUPLE_LAYOUT));
+       layout->echelon = dpop();
+       layout->superclasses = dpop();
+       layout->size = dpop();
+       layout->class = dpop();
+       layout->hashcode = untag_word(layout->class)->hashcode;
+       dpush(tag_object(layout));
+}
+
 /* Tuples */
 
 /* push a new tuple on the stack */
+F_TUPLE *allot_tuple(F_TUPLE_LAYOUT *layout)
+{
+       REGISTER_UNTAGGED(layout);
+       F_TUPLE *tuple = allot_object(TUPLE_TYPE,tuple_size(layout));
+       UNREGISTER_UNTAGGED(layout);
+       tuple->layout = tag_object(layout);
+       return tuple;
+}
+
 DEFINE_PRIMITIVE(tuple)
 {
-       CELL size = unbox_array_size();
-       F_ARRAY *array = allot_array(TUPLE_TYPE,size,F);
-       set_array_nth(array,0,dpop());
-       dpush(tag_tuple(array));
+       F_TUPLE_LAYOUT *layout = untag_object(dpop());
+       F_FIXNUM size = to_fixnum(layout->size);
+
+       F_TUPLE *tuple = allot_tuple(layout);
+       F_FIXNUM i;
+       for(i = size - 1; i >= 0; i--)
+               put(AREF(tuple,i),F);
+
+       dpush(tag_tuple(tuple));
 }
 
 /* push a new tuple on the stack, filling its slots from the stack */
 DEFINE_PRIMITIVE(tuple_boa)
 {
-       CELL size = unbox_array_size();
-       F_ARRAY *array = allot_array(TUPLE_TYPE,size,F);
-       set_array_nth(array,0,dpop());
+       F_TUPLE_LAYOUT *layout = untag_object(dpop());
+       F_FIXNUM size = to_fixnum(layout->size);
 
-       CELL i;
-       for(i = size - 1; i >= 2; i--)
-               set_array_nth(array,i,dpop());
+       REGISTER_UNTAGGED(layout);
+       F_TUPLE *tuple = allot_tuple(layout);
+       UNREGISTER_UNTAGGED(layout);
 
-       dpush(tag_tuple(array));
-}
+       /* set delegate slot */
+       put(AREF(tuple,0),F);
 
-DEFINE_PRIMITIVE(tuple_to_array)
-{
-       CELL object = dpeek();
-       type_check(TUPLE_TYPE,object);
-       object = RETAG(clone(object),OBJECT_TYPE);
-       set_slot(object,0,tag_header(ARRAY_TYPE));
-       drepl(object);
-}
+       F_FIXNUM i;
+       for(i = size - 1; i >= 1; i--)
+               put(AREF(tuple,i),dpop());
 
-DEFINE_PRIMITIVE(to_tuple)
-{
-       CELL object = RETAG(clone(dpeek()),TUPLE_TYPE);
-       set_slot(object,0,tag_header(TUPLE_TYPE));
-       drepl(object);
+       dpush(tag_tuple(tuple));
 }
 
 /* Strings */
index 62b2e06dd02bb88fc3983bd09662bb796cd36da7..03ac84d5a5c8c8d1e751f4ff82df308f9b69fbfc 100755 (executable)
@@ -96,11 +96,34 @@ DEFINE_UNTAG(F_QUOTATION,QUOTATION_TYPE,quotation)
 
 DEFINE_UNTAG(F_WORD,WORD_TYPE,word)
 
-INLINE CELL tag_tuple(F_ARRAY *tuple)
+INLINE CELL tag_tuple(F_TUPLE *tuple)
 {
        return RETAG(tuple,TUPLE_TYPE);
 }
 
+INLINE F_TUPLE *untag_tuple(CELL object)
+{
+       type_check(TUPLE_TYPE,object);
+       return untag_object(object);
+}
+
+INLINE CELL tuple_size(F_TUPLE_LAYOUT *layout)
+{
+       CELL size = untag_fixnum_fast(layout->size);
+       return sizeof(F_TUPLE) + size * CELLS;
+}
+
+INLINE CELL tuple_nth(F_TUPLE *tuple, CELL slot)
+{
+       return get(AREF(tuple,slot));
+}
+
+INLINE void set_tuple_nth(F_TUPLE *tuple, CELL slot, CELL value)
+{
+       put(AREF(tuple,slot),value);
+       write_barrier((CELL)tuple);
+}
+
 /* Prototypes */
 DLLEXPORT void box_boolean(bool value);
 DLLEXPORT bool to_boolean(CELL value);
@@ -116,12 +139,11 @@ CELL allot_array_4(CELL v1, CELL v2, CELL v3, CELL v4);
 DECLARE_PRIMITIVE(array);
 DECLARE_PRIMITIVE(tuple);
 DECLARE_PRIMITIVE(tuple_boa);
+DECLARE_PRIMITIVE(tuple_layout);
 DECLARE_PRIMITIVE(byte_array);
 DECLARE_PRIMITIVE(bit_array);
 DECLARE_PRIMITIVE(float_array);
 DECLARE_PRIMITIVE(clone);
-DECLARE_PRIMITIVE(tuple_to_array);
-DECLARE_PRIMITIVE(to_tuple);
 
 F_ARRAY *reallot_array(F_ARRAY* array, CELL capacity, CELL fill);
 DECLARE_PRIMITIVE(resize_array);