temp
logs
work
-buildsupport/wordsize
+build-support/wordsize
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:"
$(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*.*
--- /dev/null
+#!/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
#include <stdio.h>
+#include <sys/event.h>
#if defined(__FreeBSD__)
#define BSD
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() {
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();
+++ /dev/null
-#!/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
+++ /dev/null
-
-#include <stdio.h>
-
-int main ()
-{
- printf("%d", 8*sizeof(void*));
- return 0;
-}
! 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
DEFER: pinned-c-ptr?
-PREDICATE: alien pinned-alien
+PREDICATE: pinned-alien < alien
underlying-alien pinned-c-ptr? ;
UNION: pinned-c-ptr
2dup [ expired? ] either? [
[ expired? ] both?
] [
- [ alien-address ] 2apply =
+ [ alien-address ] bi@ =
] if
] [
2drop f
: 4array ( w x y z -- array ) { } 4sequence ; flushable
-PREDICATE: array pair length 2 number= ;
+PREDICATE: pair < array length 2 number= ;
] [
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
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 )
(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
{ t f t } { f t f }
] [
{ t f t } >bit-array dup clone dup [ not ] change-each
- [ >array ] 2apply
+ [ >array ] bi@
] unit-test
[
! 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
{
roll -roll declare not
- tuple-class-eq? array? hashtable? vector?
+ array? hashtable? vector?
tuple? sbuf? node? tombstone?
array-capacity array-nth set-array-nth
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 )
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" =
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 ;
: 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
! 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 }
{ alien 16 }
{ word 17 }
{ byte-array 18 }
+ { tuple-layout 19 }
} union type-numbers set
! 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
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
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
{
"byte-arrays"
"byte-vectors"
"classes.private"
+ "classes.tuple"
+ "classes.tuple.private"
"compiler.units"
"continuations.private"
"float-arrays"
"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 )
[
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
"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" }
"f" "syntax" lookup { } define-builtin
-! do not word...
-
"array" "arrays" create { } define-builtin
"wrapper" "kernel" create {
"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
! 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
! Some tuple classes
"hashtable" "hashtables" create
+"tuple" "kernel" lookup
{
{
{ "array-capacity" "sequences.private" }
} define-tuple-class
"sbuf" "sbufs" create
+"tuple" "kernel" lookup
{
{
{ "string" "strings" }
} define-tuple-class
"vector" "vectors" create
+"tuple" "kernel" lookup
{
{
{ "array" "arrays" }
} define-tuple-class
"byte-vector" "byte-vectors" create
+"tuple" "kernel" lookup
{
{
{ "byte-array" "byte-arrays" }
} define-tuple-class
"bit-vector" "bit-vectors" create
+"tuple" "kernel" lookup
{
{
{ "bit-array" "bit-arrays" }
} define-tuple-class
"float-vector" "float-vectors" create
+"tuple" "kernel" lookup
{
{
{ "float-array" "float-arrays" }
} define-tuple-class
"curry" "kernel" create
+"tuple" "kernel" lookup
{
{
{ "object" "kernel" }
}
} 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" }
}
} 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>
{ "<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" }
[
"resource:core/bootstrap/stage2.factor"
- dup resource-exists? [
+ dup exists? [
[ run-file ]
[
:c
: load-components ( -- )
"exclude" "include"
- [ get-global " " split [ empty? not ] subset ] 2apply
+ [ get-global " " split [ empty? not ] subset ] bi@
seq-diff
[ "bootstrap." prepend require ] each ;
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+! 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
{ $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
{ $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." } ;
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 ;
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 ;
[ 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
[ 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
[ 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
[ 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
! 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 ;
: 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 -- )
<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 ;
: 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 -- )
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>
! 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 ;
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 }
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" } ;
-! 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 )
"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
--- /dev/null
+Slava Pestov
--- /dev/null
+Object system implementation
--- /dev/null
+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''." } ;
--- /dev/null
+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
--- /dev/null
+! 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> ;
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.
: 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 ;
{ $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." }
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 -- )
: 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 - ;
[ 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
] 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
! 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
: >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
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
M: immediate load-literal
over v>operand small-enough? [
- [ v>operand ] 2apply swap MOV
+ [ v>operand ] bi@ swap MOV
] [
v>operand load-indirect
] if ;
! 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 ;
{ 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 ;
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
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
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
>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 ;
! 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 ;
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
} 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
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.
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 ;
] %allot
"end" get JMP
"f" resolve-label
- f [ v>operand ] 2apply MOV
+ f [ v>operand ] bi@ MOV
"end" resolve-label
] with-scope ;
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 ;
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 ;
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 > ;
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) ;
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
} 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
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 ;
: 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 ;
: 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 ] }
[ 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 ;
{ [ 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 ;
! 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+
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 ;
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 ;
%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 ] }
: 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 ;
: 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.
: 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
swap lazy-load ;
: output-vregs ( -- seq seq )
- +output+ +clobber+ [ get [ get ] map ] 2apply ;
+ +output+ +clobber+ [ get [ get ] map ] bi@ ;
: clash? ( seq -- ? )
phantoms append [
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 -- ? )
{
-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"
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 )
[ 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 ;
! 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
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 ;
: 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 )
: 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
M: class forget* ( class -- )
dup forget-methods
- dup uncache-class
+ dup update-map-
forget-word ;
M: assoc update-methods ( assoc -- )
-! 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
] [
: 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 ;
] 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 ;
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 # ;
: 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 )
{ $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"
: (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
] 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
M: hashtable equal?
over hashtable? [
- 2dup [ assoc-size ] 2apply number=
+ 2dup [ assoc-size ] bi@ number=
[ assoc= ] [ 2drop f ] if
] [ 2drop f ] if ;
[ 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
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
! 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
[ 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< ;
! 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
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 ;
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 ;
: #label ( word label -- node )
\ #label param-node [ set-#label-word ] keep ;
-PREDICATE: #label #loop #label-loop? ;
+PREDICATE: #loop < #label #label-loop? ;
TUPLE: #entry ;
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 ;
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
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
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
! 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
\ 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
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 ;
{ 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
! 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
] 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 )
\ construct-boa [
dup +inlined+ depends-on
- dup tuple-size [ <tuple-boa> ] 2curry
+ tuple-layout [ <tuple-boa> ] curry
] 1 define-transform
\ construct-empty [
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
! 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
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
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
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> } ;
{ $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
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 )
"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
[
! 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
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
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 ;
-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
{ $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 }
{ $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." } ;
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." }
[ ] [ "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
"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
[ 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
] 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
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 )
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 )
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 -- )
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 ;
"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 ;
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 )
{
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
[
"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
}
] [
[
- "/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 ,
"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 }
{ $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."
{ $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"
"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 -- ? )
{ $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 } }
{ { $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:"
{ $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 } }
-! 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
: 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
: dip ( obj quot -- obj ) swap slip ; inline
+! Keepers
: keep ( x quot -- x ) over slip ; inline
: 2keep ( x y quot -- x y ) 2over 2slip ; inline
: 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 ;
M: callstack clone (clone) ;
! Tuple construction
-
GENERIC# get-slots 1 ( tuple slots -- ... )
GENERIC# set-slots 1 ( ... tuple slots -- )
: 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
: 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
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
: 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) ] }
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 ;
: 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
] [
: (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 )
: 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
: interval-union ( i1 i2 -- i3 )
2dup and [
- [ interval>points 2array ] 2apply append points>interval
+ [ interval>points 2array ] bi@ append points>interval
] [
2drop f
] if ;
: 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
[ 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?
: 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< ;
"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 } }"
}
} ;
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
! 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 ;
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
] unit-test
: regression-2 ( x y -- x.y )
- [ p1 ] 2apply [
+ [ p1 ] bi@ [
[
rot
[ 2swap [ swapd * -rot p2 +@ ] 2keep ]
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 -- )
: 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 ;
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
! 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 ] }
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 ] }
: 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 [
] 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 [
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 } } ] [
! 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: @
{ $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 } "." }
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
[
[
"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"
[
"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 ;"
] 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 ] [
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
: <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 ;
ERROR: unexpected want got ;
-PREDICATE: unexpected unexpected-eof
+PREDICATE: unexpected-eof < unexpected
unexpected-got not ;
: unexpected-eof ( word -- * ) f unexpected ;
[ "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+) ;
: 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
: (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" ;
: 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 [
[
[
[ parsing-file ] keep
- [ ?resource-path utf8 <file-reader> ] keep
+ [ utf8 <file-reader> ] keep
parse-stream
] with-compiler-errors
] [
[ 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 ;
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 -- )
] [
pprint-object
] if ;
+
+M: tuple-layout pprint*
+ "( tuple layout )" swap present-text ;
[ "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
-! 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 ;
: remove-breakpoints ( quot pos -- quot' )
over quotation? [
- 1+ cut [ (remove-breakpoints) ] 2apply
+ 1+ cut [ (remove-breakpoints) ] bi@
[ -> ] swap 3append
] [
drop
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> ;
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 ;
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 ;
-! 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 ;
: <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 )
[ 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
#! 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 )
: 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
(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
[ -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 -- )
[ 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
: 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
: 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
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
}
"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."
: 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 ;
] 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
: reset-checksums ( -- )
source-files get [
- swap ?resource-path dup exists? [
+ swap dup exists? [
utf8 file-lines swap record-checksum
] [ 2drop ] if
] assoc-each ;
] if ;
: last-split1 ( seq subseq -- before after )
- [ <reversed> ] 2apply split1 [ reverse ] 2apply
+ [ <reversed> ] bi@ split1 [ reverse ] bi@
dup [ swap ] when ;
: (split) ( separators n seq -- )
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"
{ $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
} ;
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... ;" }
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
] 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:" [
] 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
"(" [
+++ /dev/null
-Slava Pestov
+++ /dev/null
-Object system implementation
+++ /dev/null
-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''." } ;
+++ /dev/null
-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
+++ /dev/null
-! 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> ;
[ f ] [
V{ 1 2 3 4 } dup clone
- [ underlying ] 2apply eq?
+ [ underlying ] bi@ eq?
] unit-test
[ 0 ] [
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...
<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
: vocab-dir? ( root name -- ? )
over [
- ".factor" vocab-dir+ append-path resource-exists?
+ ".factor" vocab-dir+ append-path exists?
] [
2drop f
] if ;
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* ;
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 ] [
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 ;
USING: kernel parser namespaces quotations arrays vectors strings
- sequences assocs tuples math combinators ;
+ sequences assocs classes.tuple math combinators ;
IN: bake
! 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 )
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 ;
: pixel-grid ( -- grid )
size reverse [
size [
- [ size 0.5 * - ] 2apply swap size
+ [ size 0.5 * - ] bi@ swap size
3float-array
] with map
] map ;
[ "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
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 )
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
: fast-truncate >fixnum >float ; inline
: eval-A ( i j -- n )
- [ >float ] 2apply
+ [ >float ] bi@
dupd + dup 1+ * 2 /f fast-truncate + 1+
recip ; inline
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 ;
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 ;
TUPLE: hello n ;
-: hello-n* 4 slot ;
+: hello-n* 3 slot ;
: foo 0 100000000 [ over hello-n* + ] times ;
[ 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 )
[
math.vectors
math.trig
combinators arrays sequences random vars
- combinators.cleave
combinators.lib ;
IN: boids
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-: 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 ;
ui.gadgets.packs
ui.gadgets.grids
ui.gestures
- combinators.cleave
assocs.lib vars rewrite-closures boids ;
IN: boids.ui
USING: vocabs.loader sequences system
random random.mersenne-twister combinators init
-namespaces ;
+namespaces random ;
"random.mersenne-twister" require
{ [ 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
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 ;
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+! : cd ( path -- ) current-directory set ;
+
+: cd ( path -- ) set-current-directory ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
: prepare-build-machine ( -- )
builds make-directory
builds cd
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
"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"
} ;
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
: 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"
[
]
with-directory
make-archive
+ maybe-upload
archive-name releases move-file-into ;
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-: longer? ( seq seq -- ? ) [ length ] 2apply > ;
+: longer? ( seq seq -- ? ) [ length ] bi@ > ;
: maybe-tail* ( seq n -- seq )
2dup longer?
-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 ;
-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 )
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 -- )
-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
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 ;
! 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 ;
! 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 -- )
png>>
[ width>> ]
[ height>> GL_RGBA GL_UNSIGNED_BYTE ]
+ ! [ height>> GL_BGRA GL_UNSIGNED_BYTE ]
[ array>> ] tri
glDrawPixels
] with-translation ;
M: png-gadget ungraft* ( gadget -- )
png>> surface>> cairo_destroy ;
+
+! "resource:misc/icons/Factor_1x16.png" USE: cairo.png <png-gadget> gadget.
! 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 ;
] ;
: >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 ;
[ month>> +month ] keep
[ year>> +year ] keep ; inline
-: +slots [ 2apply + ] curry 2keep ; inline
+: +slots [ bi@ + ] curry 2keep ; inline
PRIVATE>
[ >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
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
[\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
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 ;
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
--- /dev/null
+Doug Coleman
--- /dev/null
+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< } ;
+
--- /dev/null
+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
+
--- /dev/null
+! 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 ;
+
+
[ -> 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
! 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
+++ /dev/null
-
-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
-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
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
[ dup array? ] [ dup vector? ] [ dup float? ]
} || nip
] unit-test
+
+
+{ 1 1 } [
+ [ even? ] [ drop 1 ] [ drop 2 ] ifte
+] must-infer-as
-! 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
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
! 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 ;
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
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
{ [ 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
! 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
: 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
] [
: 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 ;
! 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
! 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 )
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 ;
-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
! 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
! 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 -- )
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
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 )
: =line ( n loc -- newloc ) second 2array ;
-: lines-equal? ( loc1 loc2 -- ? ) [ first ] 2apply number= ;
+: lines-equal? ( loc1 loc2 -- ? ) [ first ] bi@ number= ;
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 )
: (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 -- )
-! 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 ;
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* ;
: :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* ;
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
: 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 -- )
: 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
: 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" [
{ { $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
"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
{ $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" }
{ $subsection "io.mmap" }
{ $subsection "io.monitors" }
{ $heading "Encodings" }
+{ $subsection "encodings-introduction" }
{ $subsection "io.encodings" }
{ $subsection "io.encodings.string" }
{ $heading "Other features" }
! 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 )
: 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 -- ? )
! 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
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
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
[
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
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
: query>assoc ( query -- assoc )
dup [
"&" split [
- "=" split1 [ dup [ url-decode ] when ] 2apply
+ "=" split1 [ dup [ url-decode ] when ] bi@
] H{ } map>assoc
] when ;
! 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
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
! 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
! 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
! 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
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 )
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
! ! ! ! ! !
! 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
! 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
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
[ 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
[
".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
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 ;
! 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?
: 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 ;
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 ;
: 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 ;
[ unclip-slice inverse % (undo) ] if ;
: [undo] ( quot -- undo )
- do-inlining reverse [ (undo) ] [ ] make ;
+ flatten fold reverse [ (undo) ] [ ] make ;
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
"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 ;
"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 }
{ $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" } "." } ;
{ $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" } }
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 } }
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 } "." } ;
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
: 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 ] [
[ "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 ] [
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
! 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 ;
: 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
: 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
--- /dev/null
+! 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" } ;
--- /dev/null
+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
--- /dev/null
+! 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
--- /dev/null
+#
+# 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
--- /dev/null
+#
+# 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
--- /dev/null
+#
+# 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
--- /dev/null
+#
+# 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
--- /dev/null
+#
+# 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
+
--- /dev/null
+#
+# 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
+
--- /dev/null
+#
+# 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
--- /dev/null
+#
+# 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
--- /dev/null
+#
+# 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
--- /dev/null
+#
+# 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
--- /dev/null
+#
+# 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
--- /dev/null
+#
+# 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
--- /dev/null
+#
+# 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
--- /dev/null
+#
+# 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
+
--- /dev/null
+#
+# 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
+
+
--- /dev/null
+#
+# 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
--- /dev/null
+#
+# 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
--- /dev/null
+#
+# 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
--- /dev/null
+#=======================================================================
+# 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
--- /dev/null
+Daniel Ehrenberg
--- /dev/null
+Definitions of 8-bit encodings like ISO 8859 and Windows 1252
--- /dev/null
+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
+++ /dev/null
-Daniel Ehrenberg
+++ /dev/null
-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" } ;
+++ /dev/null
-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
+++ /dev/null
-! 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 ;
+++ /dev/null
-ISO 8859-1 encoding/decoding
--- /dev/null
+Daniel Ehrenberg
--- /dev/null
+! 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
--- /dev/null
+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
--- /dev/null
+! 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 ;
--- /dev/null
+Strict wrapper for encodings
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
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
[ { 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
! 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 ;
TUPLE: utf16 ;
+TUPLE: utf16n ;
+
<PRIVATE
! UTF-16BE decoding
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 > [
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>
{ "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 } "." } ;
{ $subsection "io.launcher.detached" }
{ $subsection "io.launcher.environment" }
{ $subsection "io.launcher.redirection" }
+{ $subsection "io.launcher.priority" }
{ $subsection "io.launcher.timeouts" } ;
ABOUT: "io.launcher"
io.nonblocking accessors ;
IN: io.launcher
-
TUPLE: process
command
stdout
stderr
+priority
+
timeout
handle status
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
{ $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." } ;
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 -- )
: 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 > [
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 ;
: 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= ;
: 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> ;
+++ /dev/null
-USING: io.backend kernel ;
-IN: io.priority
-
-HOOK: get-priority io-backend ( -- n )
-HOOK: set-priority io-backend ( n -- )
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 ;
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
! 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
! 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 ;
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.
: 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
! 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 ;
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 -- )
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 ;
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 ;
[ "/" ] [ "/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
! 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
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
] 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 )
\ 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 ;
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
+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
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
: 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 ;
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 ;
: 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
+++ /dev/null
-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 ;
! 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 ;
: <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
[ >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
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
1 _getstdfilex _fileno
2 _getstdfilex _fileno
] if [ f <win32-file> ] 3apply
- rot <reader> -rot [ <writer> ] 2apply
+ rot <reader> -rot [ <writer> ] bi@
] with-variable ;
! 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+
] 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 ;
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
: 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 -- )
{
: 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
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 )
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
--- /dev/null
+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
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
"\\\\?\\" ; 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 ;
+++ /dev/null
-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
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 )
! 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 ;
: (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 = [
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
: 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
! 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
#! 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 ;
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 )
] curry each ;
: duplicates? ( seq -- ? )
- dup prune [ length ] 2apply > ;
+ dup prune [ length ] bi@ > ;
: (wedge) ( n basis1 basis2 -- n basis )
append dup duplicates? [
] if ;
: wedge ( x y -- x.y )
- [ >alt ] 2apply [
+ [ >alt ] bi@ [
swap [
[
2swap [
] 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
] 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 )
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 ;
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
[
2dup init-d
2dup compute-costs
- [ length ] 2apply [
+ [ length ] bi@ [
[ levenshtein-step ] curry each
] with each
levenshtein-result
! 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
: 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 )
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
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>
] 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 ;
: pprint-let ( let word -- )
pprint-word
- { body>> bindings>> } get-slots
+ [ body>> ] [ bindings>> ] bi
\ | pprint-word
t <inset
<block
M: let* pprint* \ [let* pprint-let ;
-PREDICATE: word lambda-word
+PREDICATE: lambda-word < word
"lambda" word-prop >boolean ;
M: lambda-word definer drop \ :: \ ; ;
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:: \ ; ;
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:: \ ; ;
USING: kernel sequences quotations assocs math math.parser
- combinators.cleave combinators.lib vars lsys.strings ;
+ combinators.lib vars lsys.strings ;
IN: lsys.strings.interpret
USING: kernel sbufs strings sequences assocs math
- combinators.cleave combinators.lib vars lsys.strings ;
+ combinators.lib vars lsys.strings ;
IN: lsys.strings.rewrite
-USING: kernel sequences math combinators.cleave combinators.lib ;
+USING: kernel sequences math combinators.lib ;
IN: lsys.strings
handler> "L-system view" open-window
+500 sleep
+
slate> find-gl-context
1 glGenLists >model
: MACRO:
(:) define-macro ; parsing
-PREDICATE: word macro "macro" word-prop >boolean ;
+PREDICATE: macro < word "macro" word-prop >boolean ;
M: macro definer drop \ MACRO: \ ; ;
! 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
{ [ 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 ;
USING: kernel math math.constants math.functions math.intervals
-math.vectors namespaces sequences combinators.cleave ;
+math.vectors namespaces sequences ;
IN: math.analysis
<PRIVATE
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 ;
>r - abs r> < ;
: ~rel ( x y epsilon -- ? )
- >r [ - abs ] 2keep [ abs ] 2apply + r> * < ;
+ >r [ - abs ] 2keep [ abs ] bi@ + r> * < ;
: ~ ( x y epsilon -- ? )
{
: 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
! 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
<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 = ;
: 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 ;
! 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.
: 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
] 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.
: ** 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
dup numerator swap denominator ; inline
: 2>fraction ( a/b c/d -- a c b d )
- [ >fraction ] 2apply swapd ; inline
+ [ >fraction ] bi@ swapd ; inline
<PRIVATE
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 ;
: ((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) ;
: 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
: 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 ;
-USING: help.syntax help.markup kernel math classes tuples
+USING: help.syntax help.markup kernel math classes classes.tuple
calendar ;
IN: models
: 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:
! 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
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 ;
] 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 ;
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 ;
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
--- /dev/null
+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
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
: 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
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
: 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 ;
! 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 -- )
: 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
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
--- /dev/null
+
+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
[ ] [ 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
[ ] [ 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
! 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
! 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
] if ;
: string= ( str1 str2 ignore-case -- ? )
- [ [ >upper ] 2apply ] when sequence= ;
+ [ [ >upper ] bi@ ] when sequence= ;
: string-head? ( str head ignore-case -- ? )
2over shorter? [
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 ] <@ ;
! 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" } } [
{ 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
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
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
'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
'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
[\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
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
\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
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 )
[ 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
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 ;
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
] [
-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 ;
[ 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
}\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
{ $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
! 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 } [
"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
-! 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 [
] 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 ;
: range-pattern ( -- quot )
[
- dup empty? [
+ input-slice dup empty? [
drop f
] [
0 over nth dup
] 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 ;
: 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
] 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
: 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
] [
] 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 ;
: 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 )
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 ;
{ } make seq ; inline
: choice ( seq -- parser )
- choice-parser construct-boa ;
+ choice-parser construct-boa init-parser ;
: 2choice ( parser1 parser2 -- parser )
2array choice ;
{ } 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
: 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 ;
dup even? [ 2 / ] [ 3 * 1+ ] if ;
: longest ( seq seq -- seq )
- 2dup [ length ] 2apply > [ drop ] [ nip ] if ;
+ 2dup [ length ] bi@ > [ drop ] [ nip ] if ;
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>
: 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>
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 = ;
! 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
dup 3 * 1- * 2 / ;
: sum-and-diff? ( m n -- ? )
- 2dup + -rot - [ pentagonal? ] 2apply and ;
+ 2dup + -rot - [ pentagonal? ] bi@ and ;
PRIVATE>
! 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
] { } 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 )
: solution-path ( n -- str/f )
number>euler "project-euler." prepend
- vocab where dup [ first ?resource-path ] when ;
+ vocab where dup [ first ] when ;
PRIVATE>
] 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
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
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
! ! #! 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 )
;
-USING: kernel random math accessors ;
+USING: kernel random math accessors random ;
IN: random.dummy
TUPLE: random-dummy i ;
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 ;
[ 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
! 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
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
--- /dev/null
+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
--- /dev/null
+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
! 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 )
: with-random ( tuple quot -- )
random-generator swap with-variable ; inline
+
+: with-secure-random ( quot -- )
+ >r secure-random-generator get r> with-random ; inline
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
+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
USING: kernel namespaces threads sequences calendar
- combinators.cleave combinators.lib debugger ;
+ combinators.lib debugger ;
IN: raptor.cron
-USING: kernel namespaces threads arrays sequences combinators.cleave
+USING: kernel namespaces threads arrays sequences
raptor raptor.cron ;
IN: raptor
-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
: 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 ;
: 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 ;
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
{ -nrot 5 }\r
{ -roll 4 }\r
{ -rot 3 }\r
- { 2apply 1 }\r
+ { bi@ 1 }\r
{ 2curry 1 }\r
{ 2drop 1 }\r
{ 2dup 1 }\r
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
] 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 ;
<PRIVATE
: 2roman> ( str1 str2 -- m n )
- [ roman> ] 2apply ;
+ [ roman> ] bi@ ;
: binary-roman-op ( str1 str2 quot -- str3 )
>r 2roman> r> call >roman ; inline
"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
! 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
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
[ ] 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
: 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 ;
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
USING: kernel combinators sequences arrays math math.vectors
- combinators.cleave shuffle vars ;
+ shuffle vars ;
IN: springies
-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 ;
: 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> ;
: header-checksum ( seq -- x )
148 cut-slice 8 tail-slice
- [ sum ] 2apply + 256 + ;
+ [ sum ] bi@ + 256 + ;
TUPLE: checksum-error ;
TUPLE: malformed-block-error ;
: 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 * +
: complete ( full short -- score )
[ dupd fuzzy score ] 2keep
- [ <reversed> ] 2apply
+ [ <reversed> ] bi@
dupd fuzzy score max ;
: completion ( short candidate -- result )
swap >>command
+stdout+ >>stderr
+closed+ >>stdin
+ +low-priority+ >>priority
utf8 <process-stream>
dup copy-lines
process>> wait-for-process zero? [
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
[ ] [ "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
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 ;
[
"class" ,
"metaclass" ,
- "slot-names" ,
+ "layout" ,
deploy-ui? get [
"gestures" ,
"commands" ,
{ } { "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
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
\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
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
\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
\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
2drop f\r
] if\r
] [\r
- resource-exists?\r
+ exists?\r
] ?if ;\r
\r
: modified ( seq quot -- seq )\r
"" 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
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
{ [ "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
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 -- )
! 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 ;
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
+++ /dev/null
-Doug Coleman
+++ /dev/null
-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< } ;
-
+++ /dev/null
-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
-
+++ /dev/null
-! 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 ;
-
-
SYMBOL: +listener+
SYMBOL: +description+
-PREDICATE: word listener-command +listener+ word-prop ;
+PREDICATE: listener-command < word +listener+ word-prop ;
GENERIC: invoke-command ( target command -- )
} 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
<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
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 ;
! 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 ;
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 )
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 -- )
USING: help.markup help.syntax opengl kernel strings
-tuples classes quotations models ;
+classes.tuple classes quotations models ;
IN: ui.gadgets
HELP: rect
: 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> ;
[ { 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 } ] [
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 ;
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 ;
-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
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?
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?
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 ;
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 -- )
[
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
! 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
set-operation-hook
} operation construct ;
-PREDICATE: operation listener-operation
+PREDICATE: listener-operation < operation
dup operation-command listener-command?
swap operation-listener? or ;
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
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 ;
: <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
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 ;
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
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 ;
: 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 )
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
>upper >lower ;
: insensitive= ( str1 str2 -- ? )
- [ >case-fold ] 2apply = ;
+ [ >case-fold ] bi@ = ;
: lower? ( string -- ? )
dup >lower = ;
: (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
] [ ] make ;
: define-category ( word categories -- )
- [category] fixnum -rot define-predicate-class ;
+ [category] integer swap define-predicate-class ;
: CATEGORY:
CREATE ";" parse-tokens define-category ; parsing
[ 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
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?
: <dimensioned> ( n top bot -- obj )
symbolic-reduce
- [ natural-sort ] 2apply
+ [ natural-sort ] bi@
dimensioned construct-boa ;
: >dimensioned< ( d -- n top bot )
{ 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 ;
{ } { } <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* ;
: 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
! 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
: 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
: 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
--- /dev/null
+IN: unix
+
+: FD_SETSIZE 1024 ;
--- /dev/null
+IN: unix
+
+: FD_SETSIZE 1024 ; inline
--- /dev/null
+IN: unix
+
+: FD_SETSIZE 256 ; inline
--- /dev/null
+IN: unix
+
+: FD_SETSIZE 1024 ; inline
--- /dev/null
+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
! 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)
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
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
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
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 ;
--- /dev/null
+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 ;
--- /dev/null
+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
-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
--- /dev/null
+USING: alien.syntax ;
+IN: unix.types
+
+! NetBSD 4.0
+
+TYPEDEF: __uint64_t ino_t
--- /dev/null
+USING: alien.syntax ;
+IN: unix.types
+
+! NetBSD 4.0
+
+TYPEDEF: __uint32_t ino_t
-USING: alien.syntax ;
+USING: alien.syntax combinators layouts vocabs.loader ;
IN: unix.types
! NetBSD 4.0
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
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
+
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
{ [ linux? ] [ "unix.linux" require ] }
{ [ bsd? ] [ "unix.bsd" require ] }
{ [ solaris? ] [ "unix.solaris" require ] }
- { [ t ] [ ] }
} cond
-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 ;
+
+
-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
: OF_REOPEN 32768 ;
: OF_VERIFY 1024 ;
-
: INFINITE HEX: FFFFFFFF ; inline
! From C:\cygwin\usr\include\w32api\winbase.h
: 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" }
! 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
! 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
! 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
! 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
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
[ "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 ;
: <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 ;
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
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
] 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
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
[ 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> ;
>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> ;
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 ;
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 -- )
! 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
+++ /dev/null
-#!/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
/* 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:
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:
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 */
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)
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:
/* 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;
+ }
}
}
#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)
{
/* 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;
+++ /dev/null
-#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])
+++ /dev/null
-#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])
--- /dev/null
+#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])
--- /dev/null
+#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])
--- /dev/null
+#include <ucontext.h>
+
+#define ucontext_stack_pointer(uap) ((void *)_UC_MACHINE_SP((ucontext_t *)uap))
--- /dev/null
+#include <ucontext.h>
+
+#define ucontext_stack_pointer(uap) \
+ ((void *)(((ucontext_t *)(uap))->uc_mcontext.__gregs[_REG_URSP]))
#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)
--- /dev/null
+#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])
--- /dev/null
+#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])
#define UNKNOWN_TYPE_P(file) 1
#define DIRECTORY_P(file) 0
+
+extern char **environ;
#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
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,
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)));
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 */
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);
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);