]> gitweb.factorcode.org Git - factor.git/commitdiff
Merge branch 'master' of git://factorcode.org/git/factor
authorDaniel Ehrenberg <littledan@pool-224-36.res.carleton.edu>
Wed, 20 Jan 2010 06:15:55 +0000 (00:15 -0600)
committerDaniel Ehrenberg <littledan@pool-224-36.res.carleton.edu>
Wed, 20 Jan 2010 06:15:55 +0000 (00:15 -0600)
Conflicts:

basis/compiler/tree/propagation/transforms/transforms.factor

1595 files changed:
.gitignore
GNUmakefile [new file with mode: 0755]
Makefile [deleted file]
Nmakefile [new file with mode: 0755]
basis/alarms/alarms-docs.factor
basis/alarms/alarms.factor
basis/alien/arrays/arrays.factor [changed mode: 0755->0644]
basis/alien/c-types/c-types-docs.factor [changed mode: 0755->0644]
basis/alien/c-types/c-types-tests.factor [changed mode: 0755->0644]
basis/alien/c-types/c-types.factor [changed mode: 0755->0644]
basis/alien/destructors/destructors.factor [changed mode: 0755->0644]
basis/alien/libraries/libraries-docs.factor [changed mode: 0755->0644]
basis/alien/libraries/libraries.factor [changed mode: 0755->0644]
basis/alien/remote-control/remote-control.factor
basis/base64/base64.factor
basis/binary-search/binary-search-tests.factor
basis/bit-arrays/bit-arrays-tests.factor
basis/bit-arrays/bit-arrays.factor
basis/bit-vectors/bit-vectors-tests.factor
basis/bootstrap/bootstrap-error.factor
basis/bootstrap/compiler/compiler.factor [changed mode: 0755->0644]
basis/bootstrap/finish-bootstrap.factor
basis/bootstrap/finish-staging.factor
basis/bootstrap/image/image.factor
basis/bootstrap/image/syntax/syntax.factor
basis/bootstrap/stage2.factor
basis/bootstrap/ui/ui.factor [changed mode: 0755->0644]
basis/cairo/cairo.factor [changed mode: 0755->0644]
basis/calendar/calendar-docs.factor
basis/calendar/calendar-tests.factor
basis/calendar/calendar.factor
basis/calendar/format/format.factor
basis/calendar/model/model.factor
basis/calendar/unix/unix.factor
basis/channels/remote/remote.factor
basis/checksums/hmac/hmac-tests.factor [changed mode: 0755->0644]
basis/checksums/hmac/hmac.factor [changed mode: 0755->0644]
basis/checksums/sha/sha.factor
basis/circular/circular-docs.factor
basis/circular/circular-tests.factor
basis/circular/circular.factor
basis/classes/struct/bit-accessors/bit-accessors-tests.factor
basis/classes/struct/struct-tests.factor [changed mode: 0755->0644]
basis/classes/struct/struct.factor [changed mode: 0755->0644]
basis/cocoa/application/application.factor
basis/cocoa/cocoa.factor
basis/cocoa/enumeration/enumeration.factor [changed mode: 0755->0644]
basis/cocoa/messages/messages.factor [changed mode: 0755->0644]
basis/columns/columns-tests.factor
basis/columns/columns.factor
basis/combinators/smart/smart-tests.factor
basis/combinators/smart/smart.factor
basis/command-line/command-line.factor
basis/compiler/cfg/build-stack-frame/build-stack-frame.factor
basis/compiler/cfg/builder/builder.factor [changed mode: 0755->0644]
basis/compiler/cfg/cfg.factor
basis/compiler/cfg/checker/checker.factor
basis/compiler/cfg/instructions/instructions.factor
basis/compiler/cfg/instructions/syntax/syntax.factor
basis/compiler/cfg/intrinsics/allot/allot.factor
basis/compiler/cfg/intrinsics/intrinsics.factor
basis/compiler/cfg/intrinsics/misc/misc.factor
basis/compiler/cfg/intrinsics/simd/backend/backend.factor [new file with mode: 0644]
basis/compiler/cfg/intrinsics/simd/simd-tests.factor [new file with mode: 0644]
basis/compiler/cfg/intrinsics/simd/simd.factor
basis/compiler/cfg/intrinsics/slots/slots.factor
basis/compiler/cfg/linearization/linearization.factor [changed mode: 0755->0644]
basis/compiler/cfg/save-contexts/save-contexts-tests.factor
basis/compiler/cfg/save-contexts/save-contexts.factor
basis/compiler/cfg/stacks/stacks.factor [changed mode: 0755->0644]
basis/compiler/cfg/stacks/uninitialized/uninitialized.factor
basis/compiler/cfg/value-numbering/expressions/expressions.factor
basis/compiler/cfg/value-numbering/rewrite/rewrite.factor [changed mode: 0755->0644]
basis/compiler/cfg/value-numbering/simd/simd.factor [new file with mode: 0644]
basis/compiler/cfg/value-numbering/simplify/simplify.factor
basis/compiler/cfg/value-numbering/value-numbering-tests.factor
basis/compiler/codegen/codegen.factor [changed mode: 0755->0644]
basis/compiler/codegen/fixup/fixup.factor [changed mode: 0755->0644]
basis/compiler/compiler.factor [changed mode: 0755->0644]
basis/compiler/constants/constants.factor
basis/compiler/crossref/authors.txt [new file with mode: 0644]
basis/compiler/crossref/crossref.factor [new file with mode: 0644]
basis/compiler/tests/alien.factor [changed mode: 0755->0644]
basis/compiler/tests/codegen.factor
basis/compiler/tests/float.factor
basis/compiler/tests/intrinsics.factor [changed mode: 0755->0644]
basis/compiler/tests/optimizer.factor
basis/compiler/tests/redefine3.factor
basis/compiler/tests/stack-trace.factor [changed mode: 0755->0644]
basis/compiler/tree/builder/builder-tests.factor [changed mode: 0755->0644]
basis/compiler/tree/builder/builder.factor
basis/compiler/tree/checker/checker.factor [changed mode: 0755->0644]
basis/compiler/tree/cleanup/cleanup-tests.factor [changed mode: 0755->0644]
basis/compiler/tree/cleanup/cleanup.factor
basis/compiler/tree/combinators/combinators.factor [changed mode: 0755->0644]
basis/compiler/tree/dead-code/branches/branches.factor
basis/compiler/tree/dead-code/recursive/recursive.factor
basis/compiler/tree/dead-code/simple/simple.factor [changed mode: 0755->0644]
basis/compiler/tree/debugger/debugger.factor
basis/compiler/tree/escape-analysis/escape-analysis-tests.factor
basis/compiler/tree/escape-analysis/recursive/recursive-tests.factor
basis/compiler/tree/escape-analysis/simple/simple.factor
basis/compiler/tree/finalization/finalization.factor [changed mode: 0755->0644]
basis/compiler/tree/modular-arithmetic/modular-arithmetic-tests.factor
basis/compiler/tree/normalization/normalization.factor
basis/compiler/tree/propagation/branches/branches.factor [changed mode: 0755->0644]
basis/compiler/tree/propagation/call-effect/call-effect-tests.factor
basis/compiler/tree/propagation/call-effect/call-effect.factor
basis/compiler/tree/propagation/constraints/constraints.factor
basis/compiler/tree/propagation/info/info-tests.factor
basis/compiler/tree/propagation/info/info.factor
basis/compiler/tree/propagation/inlining/inlining.factor [changed mode: 0755->0644]
basis/compiler/tree/propagation/known-words/known-words.factor
basis/compiler/tree/propagation/propagation-tests.factor
basis/compiler/tree/propagation/recursive/recursive-tests.factor
basis/compiler/tree/propagation/simd/simd.factor
basis/compiler/tree/propagation/simple/simple.factor
basis/compiler/tree/propagation/transforms/transforms.factor
basis/compiler/tree/tree.factor
basis/compiler/tree/tuple-unboxing/tuple-unboxing.factor [changed mode: 0755->0644]
basis/compression/huffman/huffman.factor [changed mode: 0755->0644]
basis/compression/inflate/inflate.factor
basis/compression/run-length/run-length.factor
basis/compression/zlib/ffi/ffi.factor [changed mode: 0755->0644]
basis/compression/zlib/zlib-tests.factor [changed mode: 0755->0644]
basis/compression/zlib/zlib.factor [changed mode: 0755->0644]
basis/concurrency/combinators/combinators-tests.factor
basis/concurrency/combinators/combinators.factor [changed mode: 0755->0644]
basis/concurrency/distributed/distributed.factor
basis/concurrency/mailboxes/mailboxes.factor [changed mode: 0755->0644]
basis/cords/authors.txt [deleted file]
basis/cords/cords-tests.factor [deleted file]
basis/cords/cords.factor [deleted file]
basis/cords/summary.txt [deleted file]
basis/cords/tags.txt [deleted file]
basis/core-foundation/fsevents/fsevents.factor [changed mode: 0755->0644]
basis/core-foundation/run-loop/run-loop.factor
basis/core-text/core-text-tests.factor
basis/core-text/core-text.factor
basis/core-text/fonts/fonts.factor
basis/cpu/architecture/architecture.factor
basis/cpu/arm/assembler/assembler.factor [changed mode: 0755->0644]
basis/cpu/ppc/bootstrap.factor
basis/cpu/ppc/linux/bootstrap.factor
basis/cpu/ppc/macosx/bootstrap.factor
basis/cpu/ppc/macosx/macosx.factor
basis/cpu/ppc/ppc.factor
basis/cpu/x86/32/32-tests.factor [new file with mode: 0644]
basis/cpu/x86/32/32.factor [changed mode: 0755->0644]
basis/cpu/x86/32/bootstrap.factor
basis/cpu/x86/64/64-tests.factor [new file with mode: 0644]
basis/cpu/x86/64/64.factor
basis/cpu/x86/64/bootstrap.factor
basis/cpu/x86/64/unix/bootstrap.factor
basis/cpu/x86/64/winnt/bootstrap.factor
basis/cpu/x86/assembler/assembler.factor
basis/cpu/x86/bootstrap.factor
basis/cpu/x86/features/features.factor
basis/cpu/x86/x86.factor
basis/csv/csv-tests.factor
basis/csv/csv.factor [changed mode: 0755->0644]
basis/db/db.factor
basis/db/queries/queries.factor [changed mode: 0755->0644]
basis/db/sqlite/lib/lib.factor
basis/db/sqlite/sqlite.factor [changed mode: 0755->0644]
basis/db/tester/tester.factor
basis/db/types/types.factor [changed mode: 0755->0644]
basis/debugger/debugger-docs.factor
basis/debugger/debugger.factor
basis/debugger/windows/tags.txt [new file with mode: 0644]
basis/debugger/windows/windows.factor [changed mode: 0755->0644]
basis/dlists/dlists-docs.factor [changed mode: 0755->0644]
basis/dlists/dlists-tests.factor [changed mode: 0755->0644]
basis/dlists/dlists.factor [changed mode: 0755->0644]
basis/editors/editors.factor
basis/editors/emacs/windows/windows.factor [changed mode: 0755->0644]
basis/editors/etexteditor/etexteditor.factor [changed mode: 0755->0644]
basis/editors/notepad/notepad.factor [changed mode: 0755->0644]
basis/endian/endian-tests.factor [changed mode: 0755->0644]
basis/endian/endian.factor [changed mode: 0755->0644]
basis/environment/environment.factor
basis/environment/winnt/winnt.factor [changed mode: 0755->0644]
basis/farkup/farkup-tests.factor
basis/fry/fry-docs.factor
basis/fry/fry-tests.factor
basis/fry/fry.factor
basis/ftp/server/server.factor
basis/furnace/auth/features/edit-profile/edit-profile.factor [changed mode: 0755->0644]
basis/furnace/cache/cache.factor
basis/furnace/utilities/utilities.factor [changed mode: 0755->0644]
basis/game/input/dinput/dinput.factor [changed mode: 0755->0644]
basis/game/input/dinput/keys-array/keys-array.factor [changed mode: 0755->0644]
basis/game/input/input-docs.factor [changed mode: 0755->0644]
basis/game/input/input.factor [changed mode: 0755->0644]
basis/game/input/iokit/iokit.factor [changed mode: 0755->0644]
basis/generalizations/generalizations-docs.factor
basis/generalizations/generalizations-tests.factor
basis/generalizations/generalizations.factor
basis/glib/glib.factor [changed mode: 0755->0644]
basis/grouping/grouping-docs.factor
basis/half-floats/half-floats.factor [changed mode: 0755->0644]
basis/heaps/heaps-tests.factor
basis/help/apropos/apropos.factor
basis/help/help.factor
basis/help/lint/lint.factor [changed mode: 0755->0644]
basis/hints/hints-docs.factor
basis/hints/hints.factor
basis/http/client/client-docs.factor
basis/http/client/client.factor
basis/http/http-docs.factor
basis/http/http-tests.factor
basis/http/http.factor [changed mode: 0755->0644]
basis/http/server/server.factor [changed mode: 0755->0644]
basis/images/bitmap/bitmap.factor [changed mode: 0755->0644]
basis/images/bitmap/loading/loading.factor
basis/images/images.factor [changed mode: 0755->0644]
basis/images/jpeg/jpeg.factor
basis/images/memory/memory.factor
basis/images/normalization/normalization.factor [changed mode: 0755->0644]
basis/images/png/png-tests.factor [changed mode: 0755->0644]
basis/images/png/png.factor [changed mode: 0755->0644]
basis/images/processing/processing.factor [changed mode: 0755->0644]
basis/images/tiff/tiff-tests.factor [changed mode: 0755->0644]
basis/images/tiff/tiff.factor [changed mode: 0755->0644]
basis/inspector/inspector.factor
basis/inverse/inverse.factor [changed mode: 0755->0644]
basis/io/backend/unix/macosx/macosx.factor
basis/io/backend/unix/multiplexers/epoll/epoll.factor
basis/io/backend/unix/multiplexers/kqueue/kqueue.factor
basis/io/backend/unix/multiplexers/multiplexers.factor
basis/io/backend/unix/multiplexers/run-loop/run-loop.factor
basis/io/backend/unix/multiplexers/select/select.factor
basis/io/backend/unix/unix.factor
basis/io/backend/windows/nt/nt.factor [changed mode: 0755->0644]
basis/io/backend/windows/nt/privileges/privileges.factor [changed mode: 0755->0644]
basis/io/backend/windows/privileges/privileges-tests.factor [changed mode: 0755->0644]
basis/io/backend/windows/privileges/privileges.factor [changed mode: 0755->0644]
basis/io/backend/windows/windows.factor [changed mode: 0755->0644]
basis/io/buffers/buffers-tests.factor
basis/io/buffers/buffers.factor
basis/io/directories/directories.factor [changed mode: 0755->0644]
basis/io/directories/search/search.factor [changed mode: 0755->0644]
basis/io/directories/windows/windows.factor [changed mode: 0755->0644]
basis/io/encodings/8-bit/8-bit-docs.factor
basis/io/encodings/8-bit/8-bit-tests.factor
basis/io/encodings/8-bit/8-bit.factor
basis/io/encodings/8-bit/CP1251.TXT [new file with mode: 0644]
basis/io/encodings/8-bit/CP1253.TXT [new file with mode: 0644]
basis/io/encodings/8-bit/CP1254.TXT [new file with mode: 0644]
basis/io/encodings/8-bit/CP1255.TXT [new file with mode: 0644]
basis/io/encodings/8-bit/CP1256.TXT [new file with mode: 0644]
basis/io/encodings/8-bit/CP1257.TXT [new file with mode: 0644]
basis/io/encodings/8-bit/CP1258.TXT [new file with mode: 0644]
basis/io/encodings/8-bit/arabic/arabic-docs.factor [new file with mode: 0644]
basis/io/encodings/8-bit/arabic/arabic.factor [new file with mode: 0644]
basis/io/encodings/8-bit/arabic/authors.txt [new file with mode: 0644]
basis/io/encodings/8-bit/cyrillic/authors.txt [new file with mode: 0644]
basis/io/encodings/8-bit/cyrillic/cyrillic-docs.factor [new file with mode: 0644]
basis/io/encodings/8-bit/cyrillic/cyrillic.factor [new file with mode: 0644]
basis/io/encodings/8-bit/ebcdic/authors.txt [new file with mode: 0644]
basis/io/encodings/8-bit/ebcdic/ebcdic-docs.factor [new file with mode: 0644]
basis/io/encodings/8-bit/ebcdic/ebcdic.factor [new file with mode: 0644]
basis/io/encodings/8-bit/greek/authors.txt [new file with mode: 0644]
basis/io/encodings/8-bit/greek/greek-docs.factor [new file with mode: 0644]
basis/io/encodings/8-bit/greek/greek.factor [new file with mode: 0644]
basis/io/encodings/8-bit/hebrew/authors.txt [new file with mode: 0644]
basis/io/encodings/8-bit/hebrew/hebrew-docs.factor [new file with mode: 0644]
basis/io/encodings/8-bit/hebrew/hebrew.factor [new file with mode: 0644]
basis/io/encodings/8-bit/koi8-r/authors.txt [new file with mode: 0644]
basis/io/encodings/8-bit/koi8-r/koi8-r-docs.factor [new file with mode: 0644]
basis/io/encodings/8-bit/koi8-r/koi8-r.factor [new file with mode: 0644]
basis/io/encodings/8-bit/latin1/authors.txt [new file with mode: 0644]
basis/io/encodings/8-bit/latin1/latin1-docs.factor [new file with mode: 0644]
basis/io/encodings/8-bit/latin1/latin1.factor [new file with mode: 0644]
basis/io/encodings/8-bit/latin10/authors.txt [new file with mode: 0644]
basis/io/encodings/8-bit/latin10/latin10-docs.factor [new file with mode: 0644]
basis/io/encodings/8-bit/latin10/latin10.factor [new file with mode: 0644]
basis/io/encodings/8-bit/latin2/authors.txt [new file with mode: 0644]
basis/io/encodings/8-bit/latin2/latin2-docs.factor [new file with mode: 0644]
basis/io/encodings/8-bit/latin2/latin2.factor [new file with mode: 0644]
basis/io/encodings/8-bit/latin3/authors.txt [new file with mode: 0644]
basis/io/encodings/8-bit/latin3/latin3-docs.factor [new file with mode: 0644]
basis/io/encodings/8-bit/latin3/latin3.factor [new file with mode: 0644]
basis/io/encodings/8-bit/latin4/authors.txt [new file with mode: 0644]
basis/io/encodings/8-bit/latin4/latin4-docs.factor [new file with mode: 0644]
basis/io/encodings/8-bit/latin4/latin4.factor [new file with mode: 0644]
basis/io/encodings/8-bit/latin5/authors.txt [new file with mode: 0644]
basis/io/encodings/8-bit/latin5/latin5-docs.factor [new file with mode: 0644]
basis/io/encodings/8-bit/latin5/latin5.factor [new file with mode: 0644]
basis/io/encodings/8-bit/latin6/authors.txt [new file with mode: 0644]
basis/io/encodings/8-bit/latin6/latin6-docs.factor [new file with mode: 0644]
basis/io/encodings/8-bit/latin6/latin6.factor [new file with mode: 0644]
basis/io/encodings/8-bit/latin7/authors.txt [new file with mode: 0644]
basis/io/encodings/8-bit/latin7/latin7-docs.factor [new file with mode: 0644]
basis/io/encodings/8-bit/latin7/latin7.factor [new file with mode: 0644]
basis/io/encodings/8-bit/latin8/authors.txt [new file with mode: 0644]
basis/io/encodings/8-bit/latin8/latin8-docs.factor [new file with mode: 0644]
basis/io/encodings/8-bit/latin8/latin8.factor [new file with mode: 0644]
basis/io/encodings/8-bit/latin9/authors.txt [new file with mode: 0644]
basis/io/encodings/8-bit/latin9/latin9-docs.factor [new file with mode: 0644]
basis/io/encodings/8-bit/latin9/latin9.factor [new file with mode: 0644]
basis/io/encodings/8-bit/mac-roman/authors.txt [new file with mode: 0644]
basis/io/encodings/8-bit/mac-roman/mac-roman-docs.factor [new file with mode: 0644]
basis/io/encodings/8-bit/mac-roman/mac-roman.factor [new file with mode: 0644]
basis/io/encodings/8-bit/thai/authors.txt [new file with mode: 0644]
basis/io/encodings/8-bit/thai/thai-docs.factor [new file with mode: 0644]
basis/io/encodings/8-bit/thai/thai.factor [new file with mode: 0644]
basis/io/encodings/8-bit/windows-1250/authors.txt [new file with mode: 0644]
basis/io/encodings/8-bit/windows-1250/windows-1250.factor [new file with mode: 0644]
basis/io/encodings/8-bit/windows-1251/authors.txt [new file with mode: 0644]
basis/io/encodings/8-bit/windows-1251/windows-1251.factor [new file with mode: 0644]
basis/io/encodings/8-bit/windows-1252/authors.txt [new file with mode: 0644]
basis/io/encodings/8-bit/windows-1252/windows-1252-docs.factor [new file with mode: 0644]
basis/io/encodings/8-bit/windows-1252/windows-1252.factor [new file with mode: 0644]
basis/io/encodings/8-bit/windows-1253/authors.txt [new file with mode: 0644]
basis/io/encodings/8-bit/windows-1253/windows-1253.factor [new file with mode: 0644]
basis/io/encodings/8-bit/windows-1254/authors.txt [new file with mode: 0644]
basis/io/encodings/8-bit/windows-1254/windows-1254.factor [new file with mode: 0644]
basis/io/encodings/8-bit/windows-1255/authors.txt [new file with mode: 0644]
basis/io/encodings/8-bit/windows-1255/windows-1255.factor [new file with mode: 0644]
basis/io/encodings/8-bit/windows-1256/authors.txt [new file with mode: 0644]
basis/io/encodings/8-bit/windows-1256/windows-1256.factor [new file with mode: 0644]
basis/io/encodings/8-bit/windows-1257/authors.txt [new file with mode: 0644]
basis/io/encodings/8-bit/windows-1257/windows-1257.factor [new file with mode: 0644]
basis/io/encodings/8-bit/windows-1258/authors.txt [new file with mode: 0644]
basis/io/encodings/8-bit/windows-1258/windows-1258.factor [new file with mode: 0644]
basis/io/encodings/iana/iana.factor
basis/io/encodings/iso2022/iso2022.factor
basis/io/files/info/unix/macosx/macosx.factor [changed mode: 0755->0644]
basis/io/files/info/unix/netbsd/netbsd.factor [changed mode: 0755->0644]
basis/io/files/info/unix/openbsd/openbsd.factor [changed mode: 0755->0644]
basis/io/files/info/unix/unix-docs.factor
basis/io/files/info/unix/unix.factor
basis/io/files/info/windows/windows-tests.factor [changed mode: 0755->0644]
basis/io/files/info/windows/windows.factor [changed mode: 0755->0644]
basis/io/files/links/unix/unix-tests.factor
basis/io/files/unique/unique.factor
basis/io/files/windows/nt/nt.factor [changed mode: 0755->0644]
basis/io/files/windows/windows.factor [changed mode: 0755->0644]
basis/io/launcher/launcher.factor [changed mode: 0755->0644]
basis/io/launcher/unix/unix-tests.factor
basis/io/launcher/windows/nt/nt-tests.factor [changed mode: 0755->0644]
basis/io/launcher/windows/nt/nt.factor [changed mode: 0755->0644]
basis/io/launcher/windows/windows.factor [changed mode: 0755->0644]
basis/io/mmap/mmap-docs.factor
basis/io/monitors/windows/nt/nt.factor [changed mode: 0755->0644]
basis/io/pipes/windows/nt/nt.factor
basis/io/ports/ports.factor
basis/io/servers/connection/connection.factor
basis/io/servers/packet/authors.txt [deleted file]
basis/io/servers/packet/packet.factor [deleted file]
basis/io/servers/packet/summary.txt [deleted file]
basis/io/servers/packet/tags.txt [deleted file]
basis/io/sockets/secure/openssl/openssl.factor
basis/io/sockets/sockets-docs.factor
basis/io/sockets/sockets-tests.factor [changed mode: 0755->0644]
basis/io/sockets/sockets.factor [changed mode: 0755->0644]
basis/io/sockets/unix/unix.factor [changed mode: 0755->0644]
basis/io/sockets/windows/nt/nt.factor [changed mode: 0755->0644]
basis/io/sockets/windows/windows.factor [changed mode: 0755->0644]
basis/io/streams/limited/limited-docs.factor [changed mode: 0755->0644]
basis/io/streams/limited/limited-tests.factor
basis/io/streams/limited/limited.factor [changed mode: 0755->0644]
basis/io/styles/styles-docs.factor [changed mode: 0755->0644]
basis/io/thread/thread.factor
basis/io/timeouts/timeouts.factor [changed mode: 0755->0644]
basis/iokit/hid/hid.factor
basis/iokit/iokit.factor [changed mode: 0755->0644]
basis/json/reader/reader-tests.factor
basis/json/reader/reader.factor
basis/lcs/diff2html/diff2html-tests.factor
basis/lcs/diff2html/diff2html.factor
basis/lcs/lcs.factor
basis/lists/lazy/lazy-tests.factor
basis/lists/lazy/lazy.factor
basis/lists/lists-docs.factor
basis/lists/lists.factor
basis/literals/literals-tests.factor [changed mode: 0755->0644]
basis/literals/literals.factor [changed mode: 0755->0644]
basis/locals/fry/fry.factor
basis/locals/locals-tests.factor
basis/locals/macros/macros.factor
basis/locals/rewrite/point-free/point-free.factor [changed mode: 0755->0644]
basis/locals/rewrite/sugar/sugar.factor [changed mode: 0755->0644]
basis/logging/server/server.factor
basis/macros/expander/expander.factor
basis/macros/macros-docs.factor [changed mode: 0755->0644]
basis/macros/macros.factor
basis/math/bitwise/bitwise-docs.factor [changed mode: 0755->0644]
basis/math/bitwise/bitwise-tests.factor
basis/math/bitwise/bitwise.factor [changed mode: 0755->0644]
basis/math/blas/matrices/matrices.factor [changed mode: 0755->0644]
basis/math/blas/vectors/vectors.factor [changed mode: 0755->0644]
basis/math/combinatorics/combinatorics-docs.factor
basis/math/combinatorics/combinatorics-tests.factor
basis/math/combinatorics/combinatorics.factor
basis/math/complex/complex-tests.factor
basis/math/floats/env/x86/32/32.factor [new file with mode: 0644]
basis/math/floats/env/x86/32/tags.txt [new file with mode: 0644]
basis/math/floats/env/x86/64/64.factor [new file with mode: 0644]
basis/math/floats/env/x86/64/tags.txt [new file with mode: 0644]
basis/math/floats/env/x86/x86.factor
basis/math/functions/functions.factor
basis/math/intervals/intervals-tests.factor
basis/math/intervals/intervals.factor [changed mode: 0755->0644]
basis/math/matrices/elimination/elimination.factor [changed mode: 0755->0644]
basis/math/matrices/matrices.factor
basis/math/polynomials/polynomials.factor
basis/math/primes/factors/factors.factor
basis/math/primes/miller-rabin/miller-rabin-tests.factor
basis/math/primes/miller-rabin/miller-rabin.factor [changed mode: 0755->0644]
basis/math/quaternions/quaternions.factor [changed mode: 0755->0644]
basis/math/ratios/ratios-tests.factor
basis/math/statistics/statistics-docs.factor
basis/math/statistics/statistics.factor
basis/math/vectors/conversion/backend/backend.factor [deleted file]
basis/math/vectors/conversion/conversion-docs.factor
basis/math/vectors/conversion/conversion-tests.factor
basis/math/vectors/conversion/conversion.factor
basis/math/vectors/simd/cords/cords.factor [new file with mode: 0644]
basis/math/vectors/simd/functor/authors.txt [deleted file]
basis/math/vectors/simd/functor/functor.factor [deleted file]
basis/math/vectors/simd/intrinsics/authors.txt [deleted file]
basis/math/vectors/simd/intrinsics/intrinsics-tests.factor [deleted file]
basis/math/vectors/simd/intrinsics/intrinsics.factor
basis/math/vectors/simd/mirrors/mirrors.factor [new file with mode: 0644]
basis/math/vectors/simd/simd-docs.factor
basis/math/vectors/simd/simd-tests.factor
basis/math/vectors/simd/simd.factor
basis/math/vectors/specialization/specialization-tests.factor [deleted file]
basis/math/vectors/specialization/specialization.factor [deleted file]
basis/math/vectors/vectors-docs.factor
basis/math/vectors/vectors.factor
basis/mime/multipart/multipart.factor [changed mode: 0755->0644]
basis/models/arrow/smart/smart.factor
basis/models/illusion/authors.txt [deleted file]
basis/models/illusion/illusion.factor [deleted file]
basis/models/illusion/summary.txt [deleted file]
basis/models/models.factor
basis/nibble-arrays/nibble-arrays-tests.factor
basis/opengl/capabilities/capabilities.factor [changed mode: 0755->0644]
basis/opengl/gl/extensions/extensions.factor
basis/opengl/gl/windows/windows.factor [changed mode: 0755->0644]
basis/opengl/opengl-tests.factor [new file with mode: 0644]
basis/opengl/opengl.factor [changed mode: 0755->0644]
basis/opengl/shaders/shaders.factor [changed mode: 0755->0644]
basis/opengl/textures/textures.factor [changed mode: 0755->0644]
basis/openssl/openssl.factor
basis/pack/pack-tests.factor [changed mode: 0755->0644]
basis/pack/pack.factor [changed mode: 0755->0644]
basis/pango/cairo/cairo.factor
basis/pango/fonts/fonts.factor
basis/peg/ebnf/ebnf-docs.factor
basis/peg/ebnf/ebnf.factor
basis/persistent/hashtables/hashtables-tests.factor
basis/persistent/hashtables/hashtables.factor
basis/persistent/vectors/vectors-tests.factor
basis/persistent/vectors/vectors.factor
basis/porter-stemmer/porter-stemmer.factor
basis/prettyprint/backend/backend.factor
basis/prettyprint/prettyprint.factor
basis/prettyprint/sections/sections.factor
basis/promises/promises-docs.factor [changed mode: 0755->0644]
basis/promises/promises.factor [changed mode: 0755->0644]
basis/quoted-printable/quoted-printable-tests.factor
basis/random/mersenne-twister/mersenne-twister-tests.factor
basis/random/mersenne-twister/mersenne-twister.factor
basis/random/random-docs.factor [changed mode: 0755->0644]
basis/random/random-tests.factor
basis/random/random.factor [changed mode: 0755->0644]
basis/random/sfmt/sfmt.factor
basis/random/unix/unix.factor
basis/random/windows/windows.factor
basis/refs/refs-docs.factor [changed mode: 0755->0644]
basis/regexp/dfa/dfa.factor
basis/regexp/disambiguate/disambiguate.factor
basis/regexp/minimize/minimize.factor
basis/roman/roman-docs.factor
basis/roman/roman-tests.factor
basis/roman/roman.factor
basis/sequences/cords/authors.txt [new file with mode: 0644]
basis/sequences/cords/cords-tests.factor [new file with mode: 0644]
basis/sequences/cords/cords.factor [new file with mode: 0644]
basis/sequences/cords/summary.txt [new file with mode: 0644]
basis/sequences/cords/tags.txt [new file with mode: 0644]
basis/sequences/deep/deep-docs.factor [changed mode: 0755->0644]
basis/sequences/deep/deep-tests.factor [changed mode: 0755->0644]
basis/sequences/deep/deep.factor [changed mode: 0755->0644]
basis/sequences/merged/merged-docs.factor
basis/sequences/merged/merged-tests.factor
basis/sequences/merged/merged.factor
basis/sequences/parser/authors.txt [new file with mode: 0644]
basis/sequences/parser/parser-tests.factor [new file with mode: 0644]
basis/sequences/parser/parser.factor [new file with mode: 0644]
basis/sequences/product/product-docs.factor
basis/sequences/product/product.factor
basis/serialize/serialize-tests.factor
basis/serialize/serialize.factor
basis/shuffle/shuffle-docs.factor
basis/shuffle/shuffle.factor
basis/smtp/smtp.factor
basis/sorting/insertion/insertion.factor
basis/sorting/slots/slots-tests.factor
basis/specialized-arrays/mirrors/mirrors.factor
basis/specialized-arrays/prettyprint/prettyprint.factor [changed mode: 0755->0644]
basis/specialized-arrays/specialized-arrays-docs.factor [changed mode: 0755->0644]
basis/specialized-arrays/specialized-arrays-tests.factor [changed mode: 0755->0644]
basis/specialized-arrays/specialized-arrays.factor [changed mode: 0755->0644]
basis/specialized-vectors/specialized-vectors.factor
basis/splitting/monotonic/monotonic.factor
basis/stack-checker/alien/alien.factor
basis/stack-checker/backend/backend-tests.factor
basis/stack-checker/backend/backend.factor [changed mode: 0755->0644]
basis/stack-checker/branches/branches.factor [changed mode: 0755->0644]
basis/stack-checker/dependencies/authors.txt [new file with mode: 0644]
basis/stack-checker/dependencies/dependencies-tests.factor [new file with mode: 0644]
basis/stack-checker/dependencies/dependencies.factor [new file with mode: 0644]
basis/stack-checker/errors/errors-docs.factor [changed mode: 0755->0644]
basis/stack-checker/errors/errors.factor
basis/stack-checker/errors/prettyprint/prettyprint.factor
basis/stack-checker/inlining/inlining.factor
basis/stack-checker/known-words/known-words.factor
basis/stack-checker/stack-checker-docs.factor
basis/stack-checker/stack-checker-tests.factor
basis/stack-checker/stack-checker.factor
basis/stack-checker/state/state-tests.factor [deleted file]
basis/stack-checker/state/state.factor
basis/stack-checker/transforms/transforms-tests.factor
basis/stack-checker/transforms/transforms.factor [changed mode: 0755->0644]
basis/stack-checker/values/values.factor
basis/stack-checker/visitor/dummy/dummy.factor
basis/stack-checker/visitor/visitor.factor
basis/strings/tables/tables.factor
basis/suffix-arrays/suffix-arrays-docs.factor [changed mode: 0755->0644]
basis/suffix-arrays/suffix-arrays-tests.factor [changed mode: 0755->0644]
basis/suffix-arrays/suffix-arrays.factor [changed mode: 0755->0644]
basis/suffix-arrays/words/words.factor [changed mode: 0755->0644]
basis/syndication/syndication.factor [changed mode: 0755->0644]
basis/system-info/system-info.factor [changed mode: 0755->0644]
basis/system-info/windows/ce/ce.factor [changed mode: 0755->0644]
basis/system-info/windows/nt/nt.factor [changed mode: 0755->0644]
basis/system-info/windows/windows.factor [changed mode: 0755->0644]
basis/threads/threads-docs.factor
basis/threads/threads-tests.factor
basis/threads/threads.factor
basis/tools/annotations/annotations-tests.factor
basis/tools/crossref/crossref-tests.factor [changed mode: 0755->0644]
basis/tools/crossref/crossref.factor
basis/tools/deploy/backend/backend.factor [changed mode: 0755->0644]
basis/tools/deploy/deploy-tests.factor
basis/tools/deploy/macosx/macosx.factor [changed mode: 0755->0644]
basis/tools/deploy/shaker/shaker.factor [changed mode: 0755->0644]
basis/tools/deploy/shaker/strip-cocoa.factor
basis/tools/deploy/test/17/17.factor [new file with mode: 0644]
basis/tools/deploy/test/17/deploy.factor [new file with mode: 0644]
basis/tools/deploy/test/4/4.factor
basis/tools/deploy/test/5/deploy.factor
basis/tools/deploy/test/test.factor [changed mode: 0755->0644]
basis/tools/deploy/unix/unix.factor [changed mode: 0755->0644]
basis/tools/deploy/windows/windows.factor [changed mode: 0755->0644]
basis/tools/deprecation/deprecation.factor
basis/tools/disassembler/disassembler.factor [changed mode: 0755->0644]
basis/tools/disassembler/gdb/gdb.factor [changed mode: 0755->0644]
basis/tools/disassembler/udis/udis-tests.factor
basis/tools/disassembler/udis/udis.factor [changed mode: 0755->0644]
basis/tools/disassembler/utils/utils.factor
basis/tools/errors/model/model.factor
basis/tools/files/files.factor [changed mode: 0755->0644]
basis/tools/files/unix/unix.factor [changed mode: 0755->0644]
basis/tools/files/windows/windows.factor [changed mode: 0755->0644]
basis/tools/memory/memory-docs.factor
basis/tools/memory/memory.factor
basis/tools/profiler/profiler-tests.factor
basis/tools/profiler/profiler.factor
basis/tools/scaffold/scaffold.factor [changed mode: 0755->0644]
basis/tools/scaffold/windows/windows.factor [changed mode: 0755->0644]
basis/tools/test/test.factor
basis/tools/threads/threads.factor
basis/tools/time/time-docs.factor
basis/tools/time/time-tests.factor [new file with mode: 0644]
basis/tools/time/time.factor
basis/tr/tr.factor
basis/tuple-arrays/tuple-arrays.factor
basis/typed/typed.factor
basis/ui/backend/backend.factor [changed mode: 0755->0644]
basis/ui/backend/cocoa/cocoa.factor [changed mode: 0755->0644]
basis/ui/backend/cocoa/tools/tools.factor
basis/ui/backend/windows/windows.factor [changed mode: 0755->0644]
basis/ui/backend/x11/x11.factor [changed mode: 0755->0644]
basis/ui/debugger/debugger.factor [changed mode: 0755->0644]
basis/ui/event-loop/event-loop.factor [changed mode: 0755->0644]
basis/ui/gadgets/buttons/buttons-docs.factor
basis/ui/gadgets/editors/editors.factor [changed mode: 0755->0644]
basis/ui/gadgets/gadgets-tests.factor
basis/ui/gadgets/gadgets.factor
basis/ui/gadgets/grid-lines/grid-lines.factor [changed mode: 0755->0644]
basis/ui/gadgets/packs/packs-tests.factor
basis/ui/gadgets/panes/panes-tests.factor
basis/ui/gadgets/presentations/presentations.factor [changed mode: 0755->0644]
basis/ui/gadgets/scrollers/scrollers-tests.factor
basis/ui/gadgets/search-tables/search-tables-tests.factor
basis/ui/gadgets/search-tables/search-tables.factor
basis/ui/gadgets/slots/slots-tests.factor
basis/ui/gadgets/tracks/tracks.factor
basis/ui/gadgets/worlds/worlds-docs.factor [changed mode: 0755->0644]
basis/ui/gadgets/worlds/worlds.factor [changed mode: 0755->0644]
basis/ui/gestures/gestures-docs.factor
basis/ui/gestures/gestures.factor
basis/ui/images/images.factor [changed mode: 0755->0644]
basis/ui/operations/operations.factor [changed mode: 0755->0644]
basis/ui/pens/gradient/gradient-tests.factor
basis/ui/pens/gradient/gradient.factor
basis/ui/render/render.factor [changed mode: 0755->0644]
basis/ui/text/core-text/core-text.factor [changed mode: 0755->0644]
basis/ui/text/pango/pango.factor [changed mode: 0755->0644]
basis/ui/text/text-tests.factor [changed mode: 0755->0644]
basis/ui/text/text.factor [changed mode: 0755->0644]
basis/ui/text/uniscribe/uniscribe.factor [changed mode: 0755->0644]
basis/ui/tools/debugger/debugger.factor [changed mode: 0755->0644]
basis/ui/tools/listener/listener-docs.factor
basis/ui/traverse/traverse.factor
basis/ui/ui-docs.factor
basis/ui/ui.factor
basis/unicode/breaks/breaks-tests.factor
basis/unicode/breaks/breaks.factor
basis/unicode/collation/collation.factor [changed mode: 0755->0644]
basis/unicode/data/data.factor
basis/unix/bsd/netbsd/netbsd.factor
basis/unix/groups/groups.factor
basis/unix/time/time.factor
basis/unix/types/macosx/macosx.factor
basis/unix/types/types.factor
basis/unix/unix.factor
basis/unrolled-lists/unrolled-lists-tests.factor
basis/uuid/uuid.factor
basis/validators/validators.factor
basis/vm/vm.factor
basis/vocabs/cache/cache.factor
basis/vocabs/refresh/monitor/monitor.factor
basis/windows/advapi32/advapi32.factor [changed mode: 0755->0644]
basis/windows/com/com-tests.factor
basis/windows/com/com.factor [changed mode: 0755->0644]
basis/windows/com/prettyprint/prettyprint.factor [changed mode: 0755->0644]
basis/windows/com/syntax/syntax.factor [changed mode: 0755->0644]
basis/windows/com/wrapper/wrapper-docs.factor
basis/windows/com/wrapper/wrapper.factor [changed mode: 0755->0644]
basis/windows/dinput/authors.txt [deleted file]
basis/windows/dinput/constants/constants-tests.factor [deleted file]
basis/windows/dinput/constants/constants.factor [deleted file]
basis/windows/dinput/constants/tags.txt [deleted file]
basis/windows/dinput/dinput.factor [deleted file]
basis/windows/dinput/summary.txt [deleted file]
basis/windows/dinput/tags.txt [deleted file]
basis/windows/directx/audiodefs/audiodefs.factor [new file with mode: 0644]
basis/windows/directx/audiodefs/authors.txt [new file with mode: 0644]
basis/windows/directx/audiodefs/summary.txt [new file with mode: 0644]
basis/windows/directx/audiodefs/tags.txt [new file with mode: 0644]
basis/windows/directx/d2d1/authors.txt [new file with mode: 0644]
basis/windows/directx/d2d1/d2d1.factor [new file with mode: 0644]
basis/windows/directx/d2d1/summary.txt [new file with mode: 0644]
basis/windows/directx/d2d1/tags.txt [new file with mode: 0644]
basis/windows/directx/d2dbasetypes/authors.txt [new file with mode: 0644]
basis/windows/directx/d2dbasetypes/d2dbasetypes.factor [new file with mode: 0644]
basis/windows/directx/d2dbasetypes/summary.txt [new file with mode: 0644]
basis/windows/directx/d2dbasetypes/tags.txt [new file with mode: 0644]
basis/windows/directx/d2derr/authors.txt [new file with mode: 0644]
basis/windows/directx/d2derr/d2derr.factor [new file with mode: 0644]
basis/windows/directx/d2derr/summary.txt [new file with mode: 0644]
basis/windows/directx/d2derr/tags.txt [new file with mode: 0644]
basis/windows/directx/d3d10/authors.txt [new file with mode: 0644]
basis/windows/directx/d3d10/d3d10.factor [new file with mode: 0644]
basis/windows/directx/d3d10/summary.txt [new file with mode: 0644]
basis/windows/directx/d3d10/tags.txt [new file with mode: 0644]
basis/windows/directx/d3d10_1/authors.txt [new file with mode: 0644]
basis/windows/directx/d3d10_1/d3d10_1.factor [new file with mode: 0644]
basis/windows/directx/d3d10_1/summary.txt [new file with mode: 0644]
basis/windows/directx/d3d10_1/tags.txt [new file with mode: 0644]
basis/windows/directx/d3d10_1shader/authors.txt [new file with mode: 0644]
basis/windows/directx/d3d10_1shader/d3d10_1shader.factor [new file with mode: 0644]
basis/windows/directx/d3d10_1shader/summary.txt [new file with mode: 0644]
basis/windows/directx/d3d10_1shader/tags.txt [new file with mode: 0644]
basis/windows/directx/d3d10effect/authors.txt [new file with mode: 0644]
basis/windows/directx/d3d10effect/d3d10effect.factor [new file with mode: 0644]
basis/windows/directx/d3d10effect/summary.txt [new file with mode: 0644]
basis/windows/directx/d3d10effect/tags.txt [new file with mode: 0644]
basis/windows/directx/d3d10misc/authors.txt [new file with mode: 0644]
basis/windows/directx/d3d10misc/d3d10misc.factor [new file with mode: 0644]
basis/windows/directx/d3d10misc/summary.txt [new file with mode: 0644]
basis/windows/directx/d3d10misc/tags.txt [new file with mode: 0644]
basis/windows/directx/d3d10shader/authors.txt [new file with mode: 0644]
basis/windows/directx/d3d10shader/d3d10shader.factor [new file with mode: 0644]
basis/windows/directx/d3d10shader/summary.txt [new file with mode: 0644]
basis/windows/directx/d3d10shader/tags.txt [new file with mode: 0644]
basis/windows/directx/d3d11/authors.txt [new file with mode: 0644]
basis/windows/directx/d3d11/d3d11.factor [new file with mode: 0644]
basis/windows/directx/d3d11/summary.txt [new file with mode: 0644]
basis/windows/directx/d3d11/tags.txt [new file with mode: 0644]
basis/windows/directx/d3d11shader/authors.txt [new file with mode: 0644]
basis/windows/directx/d3d11shader/d3d11shader.factor [new file with mode: 0644]
basis/windows/directx/d3d11shader/summary.txt [new file with mode: 0644]
basis/windows/directx/d3d11shader/tags.txt [new file with mode: 0644]
basis/windows/directx/d3d9/authors.txt [new file with mode: 0644]
basis/windows/directx/d3d9/d3d9.factor [new file with mode: 0644]
basis/windows/directx/d3d9/summary.txt [new file with mode: 0644]
basis/windows/directx/d3d9/tags.txt [new file with mode: 0644]
basis/windows/directx/d3d9caps/authors.txt [new file with mode: 0644]
basis/windows/directx/d3d9caps/d3d9caps.factor [new file with mode: 0644]
basis/windows/directx/d3d9caps/summary.txt [new file with mode: 0644]
basis/windows/directx/d3d9caps/tags.txt [new file with mode: 0644]
basis/windows/directx/d3d9types/authors.txt [new file with mode: 0644]
basis/windows/directx/d3d9types/d3d9types.factor [new file with mode: 0644]
basis/windows/directx/d3d9types/summary.txt [new file with mode: 0644]
basis/windows/directx/d3d9types/tags.txt [new file with mode: 0644]
basis/windows/directx/d3dcommon/authors.txt [new file with mode: 0644]
basis/windows/directx/d3dcommon/d3dcommon.factor [new file with mode: 0644]
basis/windows/directx/d3dcommon/summary.txt [new file with mode: 0644]
basis/windows/directx/d3dcommon/tags.txt [new file with mode: 0644]
basis/windows/directx/d3dcompiler/authors.txt [new file with mode: 0644]
basis/windows/directx/d3dcompiler/d3dcompiler.factor [new file with mode: 0644]
basis/windows/directx/d3dcompiler/summary.txt [new file with mode: 0644]
basis/windows/directx/d3dcompiler/tags.txt [new file with mode: 0644]
basis/windows/directx/d3dcsx/authors.txt [new file with mode: 0644]
basis/windows/directx/d3dcsx/d3dcsx.factor [new file with mode: 0644]
basis/windows/directx/d3dcsx/summary.txt [new file with mode: 0644]
basis/windows/directx/d3dcsx/tags.txt [new file with mode: 0644]
basis/windows/directx/d3dx10/authors.txt [new file with mode: 0644]
basis/windows/directx/d3dx10/d3dx10.factor [new file with mode: 0644]
basis/windows/directx/d3dx10/summary.txt [new file with mode: 0644]
basis/windows/directx/d3dx10/tags.txt [new file with mode: 0644]
basis/windows/directx/d3dx10async/authors.txt [new file with mode: 0644]
basis/windows/directx/d3dx10async/d3dx10async.factor [new file with mode: 0644]
basis/windows/directx/d3dx10async/summary.txt [new file with mode: 0644]
basis/windows/directx/d3dx10async/tags.txt [new file with mode: 0644]
basis/windows/directx/d3dx10core/authors.txt [new file with mode: 0644]
basis/windows/directx/d3dx10core/d3dx10core.factor [new file with mode: 0644]
basis/windows/directx/d3dx10core/summary.txt [new file with mode: 0644]
basis/windows/directx/d3dx10core/tags.txt [new file with mode: 0644]
basis/windows/directx/d3dx10math/authors.txt [new file with mode: 0644]
basis/windows/directx/d3dx10math/d3dx10math.factor [new file with mode: 0644]
basis/windows/directx/d3dx10math/summary.txt [new file with mode: 0644]
basis/windows/directx/d3dx10math/tags.txt [new file with mode: 0644]
basis/windows/directx/d3dx10mesh/authors.txt [new file with mode: 0644]
basis/windows/directx/d3dx10mesh/d3dx10mesh.factor [new file with mode: 0644]
basis/windows/directx/d3dx10mesh/summary.txt [new file with mode: 0644]
basis/windows/directx/d3dx10mesh/tags.txt [new file with mode: 0644]
basis/windows/directx/d3dx10tex/authors.txt [new file with mode: 0644]
basis/windows/directx/d3dx10tex/d3dx10tex.factor [new file with mode: 0644]
basis/windows/directx/d3dx10tex/summary.txt [new file with mode: 0644]
basis/windows/directx/d3dx10tex/tags.txt [new file with mode: 0644]
basis/windows/directx/d3dx11/authors.txt [new file with mode: 0644]
basis/windows/directx/d3dx11/d3dx11.factor [new file with mode: 0644]
basis/windows/directx/d3dx11/summary.txt [new file with mode: 0644]
basis/windows/directx/d3dx11/tags.txt [new file with mode: 0644]
basis/windows/directx/d3dx11async/authors.txt [new file with mode: 0644]
basis/windows/directx/d3dx11async/d3dx11async.factor [new file with mode: 0644]
basis/windows/directx/d3dx11async/summary.txt [new file with mode: 0644]
basis/windows/directx/d3dx11async/tags.txt [new file with mode: 0644]
basis/windows/directx/d3dx11core/authors.txt [new file with mode: 0644]
basis/windows/directx/d3dx11core/d3dx11core.factor [new file with mode: 0644]
basis/windows/directx/d3dx11core/summary.txt [new file with mode: 0644]
basis/windows/directx/d3dx11core/tags.txt [new file with mode: 0644]
basis/windows/directx/d3dx11tex/authors.txt [new file with mode: 0644]
basis/windows/directx/d3dx11tex/d3dx11tex.factor [new file with mode: 0644]
basis/windows/directx/d3dx11tex/summary.txt [new file with mode: 0644]
basis/windows/directx/d3dx11tex/tags.txt [new file with mode: 0644]
basis/windows/directx/d3dx9/authors.txt [new file with mode: 0644]
basis/windows/directx/d3dx9/d3dx9.factor [new file with mode: 0644]
basis/windows/directx/d3dx9/summary.txt [new file with mode: 0644]
basis/windows/directx/d3dx9/tags.txt [new file with mode: 0644]
basis/windows/directx/d3dx9anim/authors.txt [new file with mode: 0644]
basis/windows/directx/d3dx9anim/d3dx9anim.factor [new file with mode: 0644]
basis/windows/directx/d3dx9anim/summary.txt [new file with mode: 0644]
basis/windows/directx/d3dx9anim/tags.txt [new file with mode: 0644]
basis/windows/directx/d3dx9core/authors.txt [new file with mode: 0644]
basis/windows/directx/d3dx9core/d3dx9core.factor [new file with mode: 0644]
basis/windows/directx/d3dx9core/summary.txt [new file with mode: 0644]
basis/windows/directx/d3dx9core/tags.txt [new file with mode: 0644]
basis/windows/directx/d3dx9effect/authors.txt [new file with mode: 0644]
basis/windows/directx/d3dx9effect/d3dx9effect.factor [new file with mode: 0644]
basis/windows/directx/d3dx9effect/summary.txt [new file with mode: 0644]
basis/windows/directx/d3dx9effect/tags.txt [new file with mode: 0644]
basis/windows/directx/d3dx9math/authors.txt [new file with mode: 0644]
basis/windows/directx/d3dx9math/d3dx9math.factor [new file with mode: 0644]
basis/windows/directx/d3dx9math/summary.txt [new file with mode: 0644]
basis/windows/directx/d3dx9math/tags.txt [new file with mode: 0644]
basis/windows/directx/d3dx9mesh/authors.txt [new file with mode: 0644]
basis/windows/directx/d3dx9mesh/d3dx9mesh.factor [new file with mode: 0644]
basis/windows/directx/d3dx9mesh/summary.txt [new file with mode: 0644]
basis/windows/directx/d3dx9mesh/tags.txt [new file with mode: 0644]
basis/windows/directx/d3dx9shader/authors.txt [new file with mode: 0644]
basis/windows/directx/d3dx9shader/d3dx9shader.factor [new file with mode: 0644]
basis/windows/directx/d3dx9shader/summary.txt [new file with mode: 0644]
basis/windows/directx/d3dx9shader/tags.txt [new file with mode: 0644]
basis/windows/directx/d3dx9shape/authors.txt [new file with mode: 0644]
basis/windows/directx/d3dx9shape/d3dx9shape.factor [new file with mode: 0644]
basis/windows/directx/d3dx9shape/summary.txt [new file with mode: 0644]
basis/windows/directx/d3dx9shape/tags.txt [new file with mode: 0644]
basis/windows/directx/d3dx9tex/authors.txt [new file with mode: 0644]
basis/windows/directx/d3dx9tex/d3dx9tex.factor [new file with mode: 0644]
basis/windows/directx/d3dx9tex/summary.txt [new file with mode: 0644]
basis/windows/directx/d3dx9tex/tags.txt [new file with mode: 0644]
basis/windows/directx/d3dx9xof/authors.txt [new file with mode: 0644]
basis/windows/directx/d3dx9xof/d3dx9xof.factor [new file with mode: 0644]
basis/windows/directx/d3dx9xof/summary.txt [new file with mode: 0644]
basis/windows/directx/d3dx9xof/tags.txt [new file with mode: 0644]
basis/windows/directx/dcommon/authors.txt [new file with mode: 0644]
basis/windows/directx/dcommon/dcommon.factor [new file with mode: 0644]
basis/windows/directx/dcommon/summary.txt [new file with mode: 0644]
basis/windows/directx/dcommon/tags.txt [new file with mode: 0644]
basis/windows/directx/dinput/authors.txt [new file with mode: 0644]
basis/windows/directx/dinput/constants/constants-tests.factor [new file with mode: 0644]
basis/windows/directx/dinput/constants/constants.factor [new file with mode: 0644]
basis/windows/directx/dinput/constants/tags.txt [new file with mode: 0644]
basis/windows/directx/dinput/dinput.factor [new file with mode: 0644]
basis/windows/directx/dinput/summary.txt [new file with mode: 0644]
basis/windows/directx/dinput/tags.txt [new file with mode: 0644]
basis/windows/directx/dwrite/authors.txt [new file with mode: 0644]
basis/windows/directx/dwrite/dwrite.factor [new file with mode: 0644]
basis/windows/directx/dwrite/summary.txt [new file with mode: 0644]
basis/windows/directx/dwrite/tags.txt [new file with mode: 0644]
basis/windows/directx/dxfile/authors.txt [new file with mode: 0644]
basis/windows/directx/dxfile/dxfile.factor [new file with mode: 0644]
basis/windows/directx/dxfile/summary.txt [new file with mode: 0644]
basis/windows/directx/dxfile/tags.txt [new file with mode: 0644]
basis/windows/directx/dxgi/authors.txt [new file with mode: 0644]
basis/windows/directx/dxgi/dxgi.factor [new file with mode: 0644]
basis/windows/directx/dxgi/summary.txt [new file with mode: 0644]
basis/windows/directx/dxgi/tags.txt [new file with mode: 0644]
basis/windows/directx/dxgiformat/authors.txt [new file with mode: 0644]
basis/windows/directx/dxgiformat/dxgiformat.factor [new file with mode: 0644]
basis/windows/directx/dxgiformat/summary.txt [new file with mode: 0644]
basis/windows/directx/dxgiformat/tags.txt [new file with mode: 0644]
basis/windows/directx/dxgitype/authors.txt [new file with mode: 0644]
basis/windows/directx/dxgitype/dxgitype.factor [new file with mode: 0644]
basis/windows/directx/dxgitype/summary.txt [new file with mode: 0644]
basis/windows/directx/dxgitype/tags.txt [new file with mode: 0644]
basis/windows/directx/x3daudio/authors.txt [new file with mode: 0644]
basis/windows/directx/x3daudio/summary.txt [new file with mode: 0644]
basis/windows/directx/x3daudio/tags.txt [new file with mode: 0644]
basis/windows/directx/x3daudio/x3daudio.factor [new file with mode: 0644]
basis/windows/directx/xact3/authors.txt [new file with mode: 0644]
basis/windows/directx/xact3/summary.txt [new file with mode: 0644]
basis/windows/directx/xact3/tags.txt [new file with mode: 0644]
basis/windows/directx/xact3/xact3.factor [new file with mode: 0644]
basis/windows/directx/xapo/authors.txt [new file with mode: 0644]
basis/windows/directx/xapo/summary.txt [new file with mode: 0644]
basis/windows/directx/xapo/tags.txt [new file with mode: 0644]
basis/windows/directx/xapo/xapo.factor [new file with mode: 0644]
basis/windows/directx/xapofx/authors.txt [new file with mode: 0644]
basis/windows/directx/xapofx/summary.txt [new file with mode: 0644]
basis/windows/directx/xapofx/tags.txt [new file with mode: 0644]
basis/windows/directx/xapofx/xapofx.factor [new file with mode: 0644]
basis/windows/directx/xaudio2/authors.txt [new file with mode: 0644]
basis/windows/directx/xaudio2/summary.txt [new file with mode: 0644]
basis/windows/directx/xaudio2/tags.txt [new file with mode: 0644]
basis/windows/directx/xaudio2/xaudio2.factor [new file with mode: 0644]
basis/windows/directx/xaudio2fx/authors.txt [new file with mode: 0644]
basis/windows/directx/xaudio2fx/summary.txt [new file with mode: 0644]
basis/windows/directx/xaudio2fx/tags.txt [new file with mode: 0644]
basis/windows/directx/xaudio2fx/xaudio2fx.factor [new file with mode: 0644]
basis/windows/directx/xinput/authors.txt [new file with mode: 0644]
basis/windows/directx/xinput/summary.txt [new file with mode: 0644]
basis/windows/directx/xinput/tags.txt [new file with mode: 0644]
basis/windows/directx/xinput/xinput.factor [new file with mode: 0644]
basis/windows/dragdrop-listener/dragdrop-listener.factor [changed mode: 0755->0644]
basis/windows/dwmapi/dwmapi.factor [changed mode: 0755->0644]
basis/windows/errors/errors-tests.factor [changed mode: 0755->0644]
basis/windows/errors/errors.factor [changed mode: 0755->0644]
basis/windows/fonts/fonts.factor [changed mode: 0755->0644]
basis/windows/gdi32/gdi32.factor [changed mode: 0755->0644]
basis/windows/kernel32/kernel32.factor [changed mode: 0755->0644]
basis/windows/messages/messages.factor [changed mode: 0755->0644]
basis/windows/nt/nt.factor
basis/windows/offscreen/offscreen-tests.factor [changed mode: 0755->0644]
basis/windows/offscreen/offscreen.factor [changed mode: 0755->0644]
basis/windows/ole32/ole32.factor [changed mode: 0755->0644]
basis/windows/opengl32/opengl32.factor [changed mode: 0755->0644]
basis/windows/psapi/psapi.factor [changed mode: 0755->0644]
basis/windows/psapi/tags.txt [new file with mode: 0644]
basis/windows/shell32/shell32.factor [changed mode: 0755->0644]
basis/windows/time/time.factor
basis/windows/types/types-tests.factor [changed mode: 0755->0644]
basis/windows/types/types.factor [changed mode: 0755->0644]
basis/windows/uniscribe/uniscribe.factor [changed mode: 0755->0644]
basis/windows/user32/user32.factor [changed mode: 0755->0644]
basis/windows/usp10/usp10.factor [changed mode: 0755->0644]
basis/windows/windows.factor [changed mode: 0755->0644]
basis/windows/winsock/winsock.factor [changed mode: 0755->0644]
basis/xml/entities/html/html.factor
basis/xml/tests/encodings.factor
basis/xml/tests/xmltest.factor
basis/xml/tokenize/tokenize.factor
basis/xml/traversal/traversal.factor [changed mode: 0755->0644]
basis/xml/writer/writer.factor [changed mode: 0755->0644]
basis/xml/xml.factor [changed mode: 0755->0644]
basis/xmode/catalog/catalog.factor
basis/xmode/marker/marker.factor [changed mode: 0755->0644]
build-support/cleanup
build-support/factor.sh
core/alien/alien-docs.factor
core/alien/alien.factor
core/alien/strings/strings-tests.factor
core/alien/strings/strings.factor
core/assocs/assocs-docs.factor [changed mode: 0755->0644]
core/assocs/assocs.factor [changed mode: 0755->0644]
core/bootstrap/layouts/layouts.factor
core/bootstrap/primitives.factor
core/bootstrap/stage1.factor
core/bootstrap/syntax.factor
core/byte-vectors/byte-vectors-tests.factor
core/checksums/crc32/crc32.factor
core/classes/algebra/algebra-docs.factor
core/classes/algebra/algebra-tests.factor
core/classes/algebra/algebra.factor [changed mode: 0755->0644]
core/classes/builtin/builtin-tests.factor [changed mode: 0755->0644]
core/classes/builtin/builtin.factor
core/classes/intersection/intersection.factor
core/classes/predicate/predicate.factor
core/classes/singleton/singleton.factor
core/classes/tuple/tuple-tests.factor
core/classes/tuple/tuple.factor [changed mode: 0755->0644]
core/classes/union/union.factor [changed mode: 0755->0644]
core/combinators/combinators-docs.factor [changed mode: 0755->0644]
core/combinators/combinators-tests.factor [changed mode: 0755->0644]
core/combinators/combinators.factor [changed mode: 0755->0644]
core/compiler/units/units-tests.factor
core/compiler/units/units.factor
core/continuations/continuations-tests.factor
core/continuations/continuations.factor
core/definitions/definitions-docs.factor
core/definitions/definitions.factor
core/destructors/destructors.factor
core/effects/effects-docs.factor
core/effects/effects-tests.factor
core/effects/effects.factor
core/effects/parser/parser.factor
core/generic/generic-docs.factor
core/generic/generic-tests.factor [changed mode: 0755->0644]
core/generic/parser/parser.factor
core/generic/single/single.factor
core/hashtables/hashtables-docs.factor [changed mode: 0755->0644]
core/hashtables/hashtables-tests.factor
core/hashtables/hashtables.factor
core/init/init-docs.factor
core/init/init.factor
core/io/backend/backend.factor
core/io/encodings/utf8/utf8-tests.factor [changed mode: 0755->0644]
core/io/encodings/utf8/utf8.factor [changed mode: 0755->0644]
core/io/files/files-tests.factor
core/io/files/files.factor
core/io/io.factor
core/io/pathnames/pathnames-docs.factor
core/io/pathnames/pathnames.factor
core/io/streams/c/c.factor [changed mode: 0755->0644]
core/io/test/read-until-test.txt [new file with mode: 0644]
core/kernel/kernel-docs.factor
core/kernel/kernel-tests.factor
core/kernel/kernel.factor
core/layouts/layouts.factor
core/math/floats/floats-tests.factor
core/math/floats/floats.factor
core/math/integers/integers-docs.factor
core/math/integers/integers-tests.factor
core/math/integers/integers.factor
core/math/math-docs.factor
core/math/math.factor [changed mode: 0755->0644]
core/math/order/order-docs.factor
core/math/order/order.factor
core/math/parser/parser-docs.factor
core/memory/memory-docs.factor
core/memory/memory-tests.factor [changed mode: 0755->0644]
core/memory/memory.factor
core/namespaces/namespaces-docs.factor [changed mode: 0755->0644]
core/namespaces/namespaces.factor
core/parser/parser-docs.factor
core/parser/parser.factor
core/quotations/quotations-docs.factor
core/quotations/quotations.factor
core/sbufs/sbufs-tests.factor
core/sequences/sequences-docs.factor [changed mode: 0755->0644]
core/sequences/sequences-tests.factor
core/sequences/sequences.factor [changed mode: 0755->0644]
core/sets/sets-docs.factor [changed mode: 0755->0644]
core/sets/sets-tests.factor [changed mode: 0755->0644]
core/sets/sets.factor [changed mode: 0755->0644]
core/slots/slots-tests.factor
core/slots/slots.factor [changed mode: 0755->0644]
core/sorting/sorting-tests.factor
core/source-files/errors/errors.factor
core/source-files/source-files.factor
core/splitting/splitting-docs.factor
core/splitting/splitting-tests.factor
core/splitting/splitting.factor
core/strings/strings-tests.factor
core/system/system-docs.factor
core/system/system.factor
core/vectors/vectors-tests.factor
core/vocabs/loader/loader-docs.factor
core/vocabs/parser/parser.factor [changed mode: 0755->0644]
core/words/words-docs.factor
core/words/words-tests.factor [changed mode: 0755->0644]
core/words/words.factor [changed mode: 0755->0644]
extra/24-game/24-game.factor
extra/alien/data/map/map-tests.factor
extra/animations/animations-docs.factor [deleted file]
extra/animations/animations.factor [deleted file]
extra/animations/authors.txt [deleted file]
extra/asn1/asn1-tests.factor [changed mode: 0755->0644]
extra/audio/aiff/aiff.factor [new file with mode: 0644]
extra/audio/chunked-file/chunked-file.factor [new file with mode: 0644]
extra/audio/engine/engine.factor [new file with mode: 0644]
extra/audio/engine/test/loop.aiff [new file with mode: 0644]
extra/audio/engine/test/once.wav [new file with mode: 0644]
extra/audio/engine/test/test.factor [new file with mode: 0644]
extra/audio/loader/loader.factor [new file with mode: 0644]
extra/audio/wav/wav.factor
extra/backtrack/backtrack.factor [changed mode: 0755->0644]
extra/bank/bank.factor
extra/benchmark/3d-matrix-vector/3d-matrix-vector.factor
extra/benchmark/backtrack/backtrack.factor [changed mode: 0755->0644]
extra/benchmark/base64/base64.factor
extra/benchmark/benchmark.factor [changed mode: 0755->0644]
extra/benchmark/beust2/beust2.factor [changed mode: 0755->0644]
extra/benchmark/crc32/crc32.factor [changed mode: 0755->0644]
extra/benchmark/dawes/dawes.factor
extra/benchmark/dispatch2/dispatch2.factor
extra/benchmark/dispatch4/dispatch4.factor [changed mode: 0755->0644]
extra/benchmark/dispatch5/dispatch5.factor [changed mode: 0755->0644]
extra/benchmark/e-decimals/e-decimals.factor
extra/benchmark/empty-loop-2/empty-loop-2.factor
extra/benchmark/fannkuch/fannkuch.factor
extra/benchmark/fasta/fasta.factor [changed mode: 0755->0644]
extra/benchmark/fib6/fib6.factor [changed mode: 0755->0644]
extra/benchmark/gc1/gc1.factor
extra/benchmark/iteration/iteration.factor
extra/benchmark/knucleotide/knucleotide.factor
extra/benchmark/mandel/mandel.factor [changed mode: 0755->0644]
extra/benchmark/nbody-simd/nbody-simd.factor
extra/benchmark/partial-sums/partial-sums.factor
extra/benchmark/random/random.factor [changed mode: 0755->0644]
extra/benchmark/raytracer-simd/raytracer-simd.factor
extra/benchmark/raytracer/raytracer.factor [changed mode: 0755->0644]
extra/benchmark/recursive/recursive.factor [changed mode: 0755->0644]
extra/benchmark/reverse-complement/reverse-complement-tests.factor [changed mode: 0755->0644]
extra/benchmark/reverse-complement/reverse-complement.factor [changed mode: 0755->0644]
extra/benchmark/ring/ring.factor [changed mode: 0755->0644]
extra/benchmark/simd-1/simd-1.factor
extra/benchmark/sockets/sockets.factor [changed mode: 0755->0644]
extra/benchmark/sort/sort.factor [changed mode: 0755->0644]
extra/benchmark/spectral-norm/spectral-norm.factor
extra/benchmark/terrain-generation/terrain-generation.factor
extra/benchmark/tuple-arrays/tuple-arrays.factor
extra/benchmark/ui-panes/ui-panes.factor
extra/benchmark/yuv-to-rgb/yuv-to-rgb.factor
extra/bloom-filters/bloom-filters-tests.factor
extra/bloom-filters/bloom-filters.factor
extra/bson/reader/reader.factor
extra/bson/writer/writer.factor
extra/bunny/bunny.factor [changed mode: 0755->0644]
extra/bunny/deploy.factor [changed mode: 0755->0644]
extra/bunny/fixed-pipeline/fixed-pipeline.factor [changed mode: 0755->0644]
extra/bunny/model/model.factor [changed mode: 0755->0644]
extra/bunny/outlined/outlined.factor [changed mode: 0755->0644]
extra/c/lexer/lexer-tests.factor
extra/c/lexer/lexer.factor
extra/c/preprocessor/preprocessor.factor
extra/calendar/holidays/authors.txt [new file with mode: 0644]
extra/calendar/holidays/canada/authors.txt [new file with mode: 0644]
extra/calendar/holidays/canada/canada-tests.factor [new file with mode: 0644]
extra/calendar/holidays/canada/canada.factor [new file with mode: 0644]
extra/calendar/holidays/holidays.factor [new file with mode: 0644]
extra/calendar/holidays/us/authors.txt [new file with mode: 0644]
extra/calendar/holidays/us/us-tests.factor [new file with mode: 0644]
extra/calendar/holidays/us/us.factor [new file with mode: 0644]
extra/chicago-talk/deploy.factor [changed mode: 0755->0644]
extra/color-picker/color-picker.factor [changed mode: 0755->0644]
extra/color-picker/deploy.factor [changed mode: 0755->0644]
extra/color-table/color-table.factor
extra/constructors/constructors.factor
extra/contributors/contributors.factor [changed mode: 0755->0644]
extra/couchdb/couchdb.factor
extra/cpu/8080/8080.factor [changed mode: 0755->0644]
extra/cpu/8080/emulator/emulator.factor [changed mode: 0755->0644]
extra/cpu/8080/test/test.factor [changed mode: 0755->0644]
extra/crypto/aes/aes.factor
extra/curses/curses.factor
extra/decimals/decimals-tests.factor
extra/decimals/decimals.factor
extra/demos/demos.factor
extra/descriptive/descriptive-docs.factor [changed mode: 0755->0644]
extra/descriptive/descriptive-tests.factor [changed mode: 0755->0644]
extra/descriptive/descriptive.factor [changed mode: 0755->0644]
extra/digraphs/digraphs.factor [changed mode: 0755->0644]
extra/drills/deployed/deploy.factor [deleted file]
extra/drills/deployed/deployed.factor [deleted file]
extra/drills/deployed/tags.txt [deleted file]
extra/drills/drills.factor [deleted file]
extra/drills/tags.txt [deleted file]
extra/ecdsa/ecdsa.factor
extra/fjsc/fjsc-tests.factor [changed mode: 0755->0644]
extra/fjsc/fjsc.factor [changed mode: 0755->0644]
extra/fries/fries.factor
extra/furnace/mongodb/mongodb.factor [new file with mode: 0644]
extra/game/loop/authors.txt [new file with mode: 0644]
extra/game/loop/loop-docs.factor [new file with mode: 0644]
extra/game/loop/loop.factor
extra/game/loop/summary.txt [new file with mode: 0644]
extra/game/worlds/authors.txt [new file with mode: 0644]
extra/game/worlds/summary.txt [new file with mode: 0644]
extra/game/worlds/worlds-docs.factor [new file with mode: 0644]
extra/game/worlds/worlds.factor
extra/geobytes/geobytes.factor
extra/gesture-logger/deploy.factor [changed mode: 0755->0644]
extra/gpu/buffers/buffers.factor
extra/gpu/demos/bunny/bunny.factor [changed mode: 0755->0644]
extra/gpu/demos/raytrace/green-ball.aiff [new file with mode: 0644]
extra/gpu/demos/raytrace/mirror-ball.aiff [new file with mode: 0644]
extra/gpu/demos/raytrace/raytrace.factor
extra/gpu/demos/raytrace/red-ball.aiff [new file with mode: 0644]
extra/gpu/demos/raytrace/yellow-ball.aiff [new file with mode: 0644]
extra/gpu/framebuffers/framebuffers-docs.factor [changed mode: 0755->0644]
extra/gpu/framebuffers/framebuffers.factor [changed mode: 0755->0644]
extra/gpu/gpu-docs.factor [changed mode: 0755->0644]
extra/gpu/render/render-docs.factor [changed mode: 0755->0644]
extra/gpu/render/render.factor
extra/gpu/shaders/shaders-docs.factor [changed mode: 0755->0644]
extra/gpu/shaders/shaders.factor [changed mode: 0755->0644]
extra/gpu/state/state-docs.factor [changed mode: 0755->0644]
extra/gpu/state/state.factor [changed mode: 0755->0644]
extra/gpu/textures/textures.factor
extra/gpu/util/util.factor
extra/gpu/util/wasd/wasd.factor
extra/grid-meshes/grid-meshes-tests.factor [new file with mode: 0644]
extra/grid-meshes/grid-meshes.factor
extra/hashcash/hashcash.factor [changed mode: 0755->0644]
extra/hello-ui/deploy.factor
extra/hello-ui/hello-ui.factor
extra/hello-unicode/hello-unicode.factor
extra/hello-world/deploy.factor [changed mode: 0755->0644]
extra/html/parser/analyzer/analyzer.factor [changed mode: 0755->0644]
extra/html/parser/parser.factor
extra/icfp/2006/2006.factor [changed mode: 0755->0644]
extra/id3/id3-tests.factor
extra/infix/infix-docs.factor
extra/io/serial/unix/termios/bsd/bsd.factor
extra/io/serial/unix/termios/linux/linux.factor
extra/io/serial/windows/windows.factor [changed mode: 0755->0644]
extra/irc/client/chats/chats.factor
extra/irc/client/client.factor [changed mode: 0755->0644]
extra/irc/client/internals/internals.factor
extra/irc/gitbot/gitbot.factor
extra/irc/logbot/logbot.factor
extra/irc/messages/messages.factor [changed mode: 0755->0644]
extra/jamshred/gl/gl.factor
extra/jamshred/jamshred.factor
extra/jamshred/oint/oint.factor
extra/jamshred/player/player.factor
extra/jamshred/tunnel/tunnel-tests.factor
extra/jamshred/tunnel/tunnel.factor
extra/joystick-demo/joystick-demo.factor [changed mode: 0755->0644]
extra/key-caps/key-caps.factor [changed mode: 0755->0644]
extra/key-handlers/key-handlers.factor
extra/koszul/koszul-tests.factor [changed mode: 0755->0644]
extra/koszul/koszul.factor [changed mode: 0755->0644]
extra/lcd/lcd.factor [changed mode: 0755->0644]
extra/log-viewer/log-viewer.factor [changed mode: 0755->0644]
extra/mason/child/child.factor [changed mode: 0755->0644]
extra/mason/cleanup/cleanup.factor [changed mode: 0755->0644]
extra/mason/common/common-tests.factor
extra/mason/common/common.factor [changed mode: 0755->0644]
extra/mason/platform/platform.factor
extra/mason/release/archive/archive.factor [changed mode: 0755->0644]
extra/mason/release/tidy/tidy.factor [changed mode: 0755->0644]
extra/mason/report/report.factor
extra/mason/test/test.factor
extra/math/affine-transforms/affine-transforms.factor
extra/math/analysis/analysis.factor [changed mode: 0755->0644]
extra/math/binpack/binpack.factor
extra/math/finance/finance.factor
extra/math/matrices/simd/simd-tests.factor
extra/math/matrices/simd/simd.factor
extra/math/quadratic/quadratic.factor
extra/math/text/english/english.factor [changed mode: 0755->0644]
extra/math/text/utils/utils-docs.factor [changed mode: 0755->0644]
extra/math/text/utils/utils-tests.factor [changed mode: 0755->0644]
extra/math/text/utils/utils.factor [changed mode: 0755->0644]
extra/maze/deploy.factor [changed mode: 0755->0644]
extra/maze/maze.factor
extra/memory/pools/pools.factor
extra/merger/merger.factor
extra/method-chains/method-chains-docs.factor [new file with mode: 0644]
extra/method-chains/summary.txt [new file with mode: 0644]
extra/minneapolis-talk/deploy.factor [changed mode: 0755->0644]
extra/minneapolis-talk/minneapolis-talk.factor [changed mode: 0755->0644]
extra/models/combinators/authors.txt [deleted file]
extra/models/combinators/combinators-docs.factor [deleted file]
extra/models/combinators/combinators.factor [deleted file]
extra/models/combinators/summary.txt [deleted file]
extra/models/combinators/templates/templates.factor [deleted file]
extra/models/illusion/authors.txt [new file with mode: 0644]
extra/models/illusion/illusion.factor [new file with mode: 0644]
extra/models/illusion/summary.txt [new file with mode: 0644]
extra/mongodb/benchmark/benchmark.factor
extra/mongodb/driver/driver.factor
extra/mongodb/msg/msg.factor
extra/mongodb/operations/operations.factor
extra/mongodb/tuple/persistent/persistent.factor
extra/mongodb/tuple/state/state.factor
extra/multi-methods/multi-methods.factor [changed mode: 0755->0644]
extra/multi-methods/tests/definitions.factor
extra/nehe/2/2.factor
extra/nehe/3/3.factor
extra/nehe/4/4.factor
extra/nehe/5/5.factor [changed mode: 0755->0644]
extra/nehe/deploy.factor [changed mode: 0755->0644]
extra/nehe/nehe.factor
extra/noise/noise-tests.factor [new file with mode: 0644]
extra/noise/noise.factor
extra/openal/openal.factor
extra/opengl/demo-support/demo-support.factor [changed mode: 0755->0644]
extra/parser-combinators/parser-combinators-docs.factor [changed mode: 0755->0644]
extra/parser-combinators/parser-combinators-tests.factor [changed mode: 0755->0644]
extra/parser-combinators/parser-combinators.factor [changed mode: 0755->0644]
extra/parser-combinators/simple/simple-docs.factor [changed mode: 0755->0644]
extra/parser-combinators/simple/simple.factor [changed mode: 0755->0644]
extra/partial-continuations/partial-continuations-tests.factor
extra/partial-continuations/partial-continuations.factor [changed mode: 0755->0644]
extra/poker/poker-docs.factor
extra/poker/poker-tests.factor
extra/poker/poker.factor
extra/project-euler/001/001.factor
extra/project-euler/002/002.factor
extra/project-euler/011/011.factor
extra/project-euler/014/014.factor
extra/project-euler/024/024.factor [changed mode: 0755->0644]
extra/project-euler/027/027.factor
extra/project-euler/030/030.factor
extra/project-euler/032/032.factor [changed mode: 0755->0644]
extra/project-euler/035/035.factor [changed mode: 0755->0644]
extra/project-euler/037/037.factor [changed mode: 0755->0644]
extra/project-euler/038/038.factor [changed mode: 0755->0644]
extra/project-euler/039/039.factor [changed mode: 0755->0644]
extra/project-euler/040/040.factor [changed mode: 0755->0644]
extra/project-euler/043/043.factor
extra/project-euler/046/046.factor [changed mode: 0755->0644]
extra/project-euler/052/052.factor
extra/project-euler/053/053.factor
extra/project-euler/054/054.factor
extra/project-euler/055/055.factor
extra/project-euler/057/057.factor
extra/project-euler/062/062-tests.factor [new file with mode: 0644]
extra/project-euler/062/062.factor [new file with mode: 0644]
extra/project-euler/062/authors.txt [new file with mode: 0644]
extra/project-euler/075/075.factor [changed mode: 0755->0644]
extra/project-euler/081/081.factor
extra/project-euler/089/089-tests.factor [new file with mode: 0644]
extra/project-euler/089/089.factor [new file with mode: 0644]
extra/project-euler/089/authors.txt [new file with mode: 0644]
extra/project-euler/089/roman.txt [new file with mode: 0644]
extra/project-euler/100/100.factor
extra/project-euler/117/117.factor
extra/project-euler/150/150.factor
extra/project-euler/151/151.factor
extra/project-euler/164/164.factor
extra/project-euler/186/186.factor
extra/project-euler/188/188-tests.factor [changed mode: 0755->0644]
extra/project-euler/188/188.factor [changed mode: 0755->0644]
extra/project-euler/ave-time/ave-time-docs.factor
extra/project-euler/ave-time/ave-time-tests.factor [new file with mode: 0644]
extra/project-euler/ave-time/ave-time.factor
extra/project-euler/common/common.factor
extra/project-euler/project-euler.factor
extra/quadtrees/quadtrees.factor
extra/random/blum-blum-shub/blum-blum-shub-tests.factor
extra/random/blum-blum-shub/blum-blum-shub.factor [changed mode: 0755->0644]
extra/recipes/authors.txt [deleted file]
extra/recipes/icons/back.tiff [deleted file]
extra/recipes/icons/hate.tiff [deleted file]
extra/recipes/icons/love.tiff [deleted file]
extra/recipes/icons/more.tiff [deleted file]
extra/recipes/icons/submit.tiff [deleted file]
extra/recipes/recipes.factor [deleted file]
extra/recipes/summary.txt [deleted file]
extra/redis/redis.factor
extra/reports/noise/noise.factor [changed mode: 0755->0644]
extra/rot13/rot13.factor
extra/s3/s3-docs.factor
extra/sequence-parser/sequence-parser-tests.factor [deleted file]
extra/sequence-parser/sequence-parser.factor [deleted file]
extra/sequences/abbrev/abbrev.factor
extra/sequences/modified/modified.factor
extra/sequences/repeating/repeating.factor
extra/set-n/set-n.factor
extra/site-watcher/site-watcher.factor
extra/slides/slides.factor [changed mode: 0755->0644]
extra/smalltalk/compiler/compiler-tests.factor
extra/smalltalk/selectors/selectors.factor
extra/space-invaders/space-invaders.factor [changed mode: 0755->0644]
extra/spheres/spheres.factor [changed mode: 0755->0644]
extra/spider/spider.factor
extra/spider/unique-deque/unique-deque.factor
extra/sudoku/deploy.factor [changed mode: 0755->0644]
extra/sudoku/sudoku-tests.factor [new file with mode: 0644]
extra/sudoku/sudoku.factor [changed mode: 0755->0644]
extra/sudokus/authors.txt [deleted file]
extra/sudokus/sudokus.factor [deleted file]
extra/sudokus/summary.txt [deleted file]
extra/tar/tar.factor [changed mode: 0755->0644]
extra/taxes/usa/fica/fica.factor
extra/terrain/generation/generation.factor
extra/terrain/terrain.factor
extra/tetris/board/board.factor
extra/tetris/deploy.factor [changed mode: 0755->0644]
extra/tetris/game/game.factor
extra/tetris/gl/gl.factor
extra/tetris/piece/piece.factor
extra/tetris/tetris.factor
extra/tokyo/alien/tcbdb/tcbdb.factor [changed mode: 0755->0644]
extra/tokyo/alien/tcfdb/tcfdb.factor [changed mode: 0755->0644]
extra/tokyo/alien/tchdb/tchdb.factor [changed mode: 0755->0644]
extra/tokyo/alien/tcrdb/tcrdb.factor [changed mode: 0755->0644]
extra/tokyo/alien/tctdb/tctdb.factor [changed mode: 0755->0644]
extra/tokyo/alien/tcutil/tcutil.factor [changed mode: 0755->0644]
extra/tokyo/assoc-functor/assoc-functor.factor
extra/trees/avl/avl-tests.factor [changed mode: 0755->0644]
extra/trees/avl/avl.factor [changed mode: 0755->0644]
extra/trees/splay/splay-tests.factor
extra/trees/splay/splay.factor [changed mode: 0755->0644]
extra/trees/trees.factor [changed mode: 0755->0644]
extra/ui/gadgets/alerts/alerts.factor [deleted file]
extra/ui/gadgets/alerts/authors.txt [deleted file]
extra/ui/gadgets/alerts/summary.txt [deleted file]
extra/ui/gadgets/comboboxes/authors.txt [deleted file]
extra/ui/gadgets/comboboxes/comboboxes.factor [deleted file]
extra/ui/gadgets/comboboxes/summary.txt [deleted file]
extra/ui/gadgets/controls/authors.txt [deleted file]
extra/ui/gadgets/controls/controls-docs.factor [deleted file]
extra/ui/gadgets/controls/controls.factor [deleted file]
extra/ui/gadgets/controls/summary.txt [deleted file]
extra/ui/gadgets/layout/authors.txt [deleted file]
extra/ui/gadgets/layout/layout-docs.factor [deleted file]
extra/ui/gadgets/layout/layout.factor [deleted file]
extra/ui/gadgets/layout/summary.txt [deleted file]
extra/ui/gadgets/lists/lists.factor
extra/ui/gadgets/poppers/authors.txt [deleted file]
extra/ui/gadgets/poppers/poppers.factor [deleted file]
extra/ui/gadgets/worlds/null/null.factor
extra/ui/render/test/test.factor [changed mode: 0755->0644]
extra/units/units-tests.factor [changed mode: 0755->0644]
extra/units/units.factor [changed mode: 0755->0644]
extra/usa-cities/usa-cities.factor
extra/vocabs/git/authors.txt [new file with mode: 0644]
extra/vocabs/git/git.factor [new file with mode: 0644]
extra/webapps/imagebin/imagebin.factor [changed mode: 0755->0644]
extra/webapps/mason/mason.factor
extra/webapps/planet/planet.factor [changed mode: 0755->0644]
extra/webapps/todo/todo.factor [changed mode: 0755->0644]
extra/window-controls-demo/window-controls-demo.factor [changed mode: 0755->0644]
extra/yahoo/yahoo.factor [changed mode: 0755->0644]
extra/zoneinfo/africa [new file with mode: 0644]
extra/zoneinfo/antarctica [new file with mode: 0644]
extra/zoneinfo/asia [new file with mode: 0644]
extra/zoneinfo/australasia [new file with mode: 0644]
extra/zoneinfo/authors.txt [new file with mode: 0644]
extra/zoneinfo/europe [new file with mode: 0644]
extra/zoneinfo/leapseconds [new file with mode: 0644]
extra/zoneinfo/northamerica [new file with mode: 0644]
extra/zoneinfo/pacificnew [new file with mode: 0644]
extra/zoneinfo/solar87 [new file with mode: 0644]
extra/zoneinfo/solar88 [new file with mode: 0644]
extra/zoneinfo/solar89 [new file with mode: 0644]
extra/zoneinfo/southamerica [new file with mode: 0644]
extra/zoneinfo/systemv [new file with mode: 0644]
extra/zoneinfo/zoneinfo.factor [new file with mode: 0644]
unmaintained/4DNav/4DNav-docs.factor [changed mode: 0755->0644]
unmaintained/4DNav/4DNav.factor [changed mode: 0755->0644]
unmaintained/4DNav/camera/camera-docs.factor [changed mode: 0755->0644]
unmaintained/4DNav/camera/camera.factor [changed mode: 0755->0644]
unmaintained/4DNav/deep/deep-docs.factor [changed mode: 0755->0644]
unmaintained/4DNav/deep/deep.factor [changed mode: 0755->0644]
unmaintained/4DNav/deploy.factor [changed mode: 0755->0644]
unmaintained/4DNav/file-chooser/file-chooser.factor [changed mode: 0755->0644]
unmaintained/4DNav/space-file-decoder/space-file-decoder-docs.factor [changed mode: 0755->0644]
unmaintained/4DNav/space-file-decoder/space-file-decoder.factor [changed mode: 0755->0644]
unmaintained/4DNav/turtle/turtle-docs.factor [changed mode: 0755->0644]
unmaintained/4DNav/turtle/turtle.factor [changed mode: 0755->0644]
unmaintained/4DNav/window3D/window3D-docs.factor [changed mode: 0755->0644]
unmaintained/4DNav/window3D/window3D.factor [changed mode: 0755->0644]
unmaintained/adsoda/adsoda-docs.factor [changed mode: 0755->0644]
unmaintained/adsoda/adsoda-tests.factor [changed mode: 0755->0644]
unmaintained/adsoda/adsoda.factor [changed mode: 0755->0644]
unmaintained/adsoda/combinators/combinators-docs.factor [changed mode: 0755->0644]
unmaintained/adsoda/combinators/combinators-tests.factor [changed mode: 0755->0644]
unmaintained/adsoda/combinators/combinators.factor [changed mode: 0755->0644]
unmaintained/adsoda/solution2/solution2.factor [changed mode: 0755->0644]
unmaintained/adsoda/tools/tools-docs.factor [changed mode: 0755->0644]
unmaintained/adsoda/tools/tools-tests.factor [changed mode: 0755->0644]
unmaintained/adsoda/tools/tools.factor [changed mode: 0755->0644]
unmaintained/animations/animations-docs.factor [new file with mode: 0644]
unmaintained/animations/animations.factor [new file with mode: 0644]
unmaintained/animations/authors.txt [new file with mode: 0644]
unmaintained/arm/4/4.factor [changed mode: 0755->0644]
unmaintained/arm/allot/allot.factor [changed mode: 0755->0644]
unmaintained/arm/architecture/architecture.factor [changed mode: 0755->0644]
unmaintained/arm/arm.factor [changed mode: 0755->0644]
unmaintained/arm/bootstrap.factor [changed mode: 0755->0644]
unmaintained/arm/intrinsics/intrinsics.factor [changed mode: 0755->0644]
unmaintained/automata/ui/deploy.factor [changed mode: 0755->0644]
unmaintained/ce/backend/backend.factor [changed mode: 0755->0644]
unmaintained/ce/ce.factor [changed mode: 0755->0644]
unmaintained/ce/files/files.factor [changed mode: 0755->0644]
unmaintained/ce/privileges/privileges.factor [changed mode: 0755->0644]
unmaintained/ce/sockets/sockets.factor [changed mode: 0755->0644]
unmaintained/cont-responder/callbacks-tests.factor [changed mode: 0755->0644]
unmaintained/cont-responder/callbacks.factor [changed mode: 0755->0644]
unmaintained/cryptlib/streams/streams.factor [changed mode: 0755->0644]
unmaintained/db/mysql/mysql.factor [changed mode: 0755->0644]
unmaintained/drills/deployed/deploy.factor [new file with mode: 0644]
unmaintained/drills/deployed/deployed.factor [new file with mode: 0644]
unmaintained/drills/deployed/tags.txt [new file with mode: 0644]
unmaintained/drills/drills.factor [new file with mode: 0644]
unmaintained/drills/tags.txt [new file with mode: 0644]
unmaintained/golden-section/deploy.factor [changed mode: 0755->0644]
unmaintained/headers/bsd/bsd.factor [changed mode: 0755->0644]
unmaintained/headers/headers.factor [changed mode: 0755->0644]
unmaintained/images/processing/rotation/rotation-tests.factor [changed mode: 0755->0644]
unmaintained/irc-ui/commandparser/commandparser.factor [changed mode: 0755->0644]
unmaintained/irc-ui/commands/commands.factor [changed mode: 0755->0644]
unmaintained/irc-ui/load/load.factor [changed mode: 0755->0644]
unmaintained/irc-ui/ui.factor [changed mode: 0755->0644]
unmaintained/ldap/ldap-tests.factor [changed mode: 0755->0644]
unmaintained/ldap/libldap/libldap.factor [changed mode: 0755->0644]
unmaintained/lint/lint.factor [changed mode: 0755->0644]
unmaintained/models/combinators/authors.txt [new file with mode: 0644]
unmaintained/models/combinators/combinators-docs.factor [new file with mode: 0644]
unmaintained/models/combinators/combinators.factor [new file with mode: 0644]
unmaintained/models/combinators/summary.txt [new file with mode: 0644]
unmaintained/models/combinators/templates/templates.factor [new file with mode: 0644]
unmaintained/ogg/player/player.factor [changed mode: 0755->0644]
unmaintained/oracle/oracle-tests.factor [changed mode: 0755->0644]
unmaintained/pdf/pdf-tests.factor [changed mode: 0755->0644]
unmaintained/recipes/authors.txt [new file with mode: 0644]
unmaintained/recipes/icons/back.tiff [new file with mode: 0644]
unmaintained/recipes/icons/hate.tiff [new file with mode: 0644]
unmaintained/recipes/icons/love.tiff [new file with mode: 0644]
unmaintained/recipes/icons/more.tiff [new file with mode: 0644]
unmaintained/recipes/icons/submit.tiff [new file with mode: 0644]
unmaintained/recipes/recipes.factor [new file with mode: 0644]
unmaintained/recipes/summary.txt [new file with mode: 0644]
unmaintained/semantic-db/semantic-db.factor [changed mode: 0755->0644]
unmaintained/sniffer/channels/bsd/bsd.factor [changed mode: 0755->0644]
unmaintained/sniffer/channels/sniffer.factor [changed mode: 0755->0644]
unmaintained/sniffer/io/filter/filter.factor [changed mode: 0755->0644]
unmaintained/sniffer/io/sniffer.factor [changed mode: 0755->0644]
unmaintained/springies/springies.factor [changed mode: 0755->0644]
unmaintained/sudokus/authors.txt [new file with mode: 0644]
unmaintained/sudokus/sudokus.factor [new file with mode: 0644]
unmaintained/sudokus/summary.txt [new file with mode: 0644]
unmaintained/tabs/tabs.factor [changed mode: 0755->0644]
unmaintained/ui/gadgets/alerts/alerts.factor [new file with mode: 0644]
unmaintained/ui/gadgets/alerts/authors.txt [new file with mode: 0644]
unmaintained/ui/gadgets/alerts/summary.txt [new file with mode: 0644]
unmaintained/ui/gadgets/comboboxes/authors.txt [new file with mode: 0644]
unmaintained/ui/gadgets/comboboxes/comboboxes.factor [new file with mode: 0644]
unmaintained/ui/gadgets/comboboxes/summary.txt [new file with mode: 0644]
unmaintained/ui/gadgets/controls/authors.txt [new file with mode: 0644]
unmaintained/ui/gadgets/controls/controls-docs.factor [new file with mode: 0644]
unmaintained/ui/gadgets/controls/controls.factor [new file with mode: 0644]
unmaintained/ui/gadgets/controls/summary.txt [new file with mode: 0644]
unmaintained/ui/gadgets/layout/authors.txt [new file with mode: 0644]
unmaintained/ui/gadgets/layout/layout-docs.factor [new file with mode: 0644]
unmaintained/ui/gadgets/layout/layout.factor [new file with mode: 0644]
unmaintained/ui/gadgets/layout/summary.txt [new file with mode: 0644]
unmaintained/ui/gadgets/poppers/authors.txt [new file with mode: 0644]
unmaintained/ui/gadgets/poppers/poppers.factor [new file with mode: 0644]
unmaintained/ui/offscreen/offscreen.factor [changed mode: 0755->0644]
vm/Config.arm
vm/Config.freebsd
vm/Config.linux
vm/Config.netbsd
vm/Config.openbsd
vm/Config.solaris
vm/Config.windows
vm/Config.x86.32
vm/Config.x86.64
vm/aging_collector.cpp
vm/aging_space.hpp
vm/alien.cpp
vm/alien.hpp
vm/allot.hpp
vm/arrays.cpp
vm/arrays.hpp
vm/asm.h [deleted file]
vm/bignum.cpp
vm/bitwise_hacks.hpp [changed mode: 0644->0755]
vm/booleans.cpp
vm/booleans.hpp
vm/bump_allocator.hpp
vm/byte_arrays.cpp
vm/byte_arrays.hpp
vm/callbacks.cpp
vm/callbacks.hpp
vm/callstack.cpp
vm/callstack.hpp
vm/code_block.cpp [deleted file]
vm/code_block.hpp [deleted file]
vm/code_block_visitor.hpp
vm/code_blocks.cpp [new file with mode: 0755]
vm/code_blocks.hpp [new file with mode: 0644]
vm/code_heap.cpp
vm/code_heap.hpp
vm/collector.hpp
vm/compaction.cpp
vm/contexts.cpp
vm/contexts.hpp
vm/cpu-arm.S [deleted file]
vm/cpu-arm.hpp
vm/cpu-ppc.S
vm/cpu-ppc.hpp
vm/cpu-x86.32.S [deleted file]
vm/cpu-x86.32.hpp
vm/cpu-x86.64.S [deleted file]
vm/cpu-x86.64.hpp
vm/cpu-x86.S [deleted file]
vm/cpu-x86.hpp
vm/data_heap.cpp
vm/data_heap.hpp
vm/data_heap_checker.cpp [new file with mode: 0644]
vm/data_roots.hpp
vm/debug.cpp
vm/dispatch.cpp
vm/entry_points.cpp [new file with mode: 0644]
vm/entry_points.hpp [new file with mode: 0644]
vm/errors.cpp
vm/errors.hpp
vm/factor.cpp
vm/factor.hpp [changed mode: 0644->0755]
vm/free_list.cpp
vm/free_list.hpp [changed mode: 0644->0755]
vm/free_list_allocator.hpp
vm/full_collector.cpp
vm/full_collector.hpp
vm/gc.cpp
vm/gc.hpp
vm/generic_arrays.hpp
vm/image.cpp
vm/image.hpp
vm/inline_cache.cpp
vm/instruction_operands.cpp [new file with mode: 0644]
vm/instruction_operands.hpp [new file with mode: 0644]
vm/io.cpp
vm/jit.cpp
vm/jit.hpp
vm/layouts.hpp
vm/main-windows-ce.cpp [changed mode: 0644->0755]
vm/main-windows-nt.cpp [changed mode: 0644->0755]
vm/mark_bits.hpp
vm/master.hpp
vm/math.cpp
vm/math.hpp
vm/nursery_collector.cpp
vm/object_start_map.cpp
vm/objects.cpp [new file with mode: 0644]
vm/objects.hpp [new file with mode: 0644]
vm/os-genunix.cpp
vm/os-macosx.mm
vm/os-unix.cpp
vm/os-unix.hpp
vm/os-windows-ce.cpp
vm/os-windows-ce.hpp [changed mode: 0644->0755]
vm/os-windows-nt.cpp
vm/os-windows-nt.hpp
vm/os-windows.cpp
vm/os-windows.hpp [changed mode: 0644->0755]
vm/platform.hpp [changed mode: 0644->0755]
vm/primitives.cpp
vm/primitives.hpp
vm/profiler.cpp
vm/quotations.cpp
vm/quotations.hpp
vm/run.cpp
vm/run.hpp
vm/slot_visitor.hpp
vm/stacks.hpp [deleted file]
vm/strings.cpp
vm/tagged.hpp
vm/tenured_space.hpp
vm/to_tenured_collector.cpp
vm/to_tenured_collector.hpp
vm/tuples.cpp
vm/utilities.cpp
vm/utilities.hpp
vm/vm.cpp
vm/vm.hpp
vm/words.cpp

index b52c593b49078de911f8f400b84b53e698515c93..a839a6ff193a24a1a21d629266c15cca150db884 100644 (file)
@@ -8,6 +8,7 @@ Factor/factor
 *.a
 *.dll
 *.lib
+*.res
 *.image
 *.dylib
 factor
diff --git a/GNUmakefile b/GNUmakefile
new file mode 100755 (executable)
index 0000000..4447dfb
--- /dev/null
@@ -0,0 +1,223 @@
+ifdef CONFIG
+       CC = gcc
+       CPP = g++
+       AR = ar
+       LD = ld
+
+       VERSION = 0.92
+
+       BUNDLE = Factor.app
+       LIBPATH = -L/usr/X11R6/lib
+
+       CFLAGS = -Wall $(SITE_CFLAGS)
+
+       ifdef DEBUG
+               CFLAGS += -g -DFACTOR_DEBUG
+       else
+               CFLAGS += -O3
+       endif
+
+       include $(CONFIG)
+
+       ENGINE = $(DLL_PREFIX)factor$(DLL_SUFFIX)$(DLL_EXTENSION)
+       EXECUTABLE = factor$(EXE_SUFFIX)$(EXE_EXTENSION)
+       CONSOLE_EXECUTABLE = factor$(EXE_SUFFIX)$(CONSOLE_EXTENSION)
+
+       DLL_OBJS = $(PLAF_DLL_OBJS) \
+               vm/aging_collector.o \
+               vm/alien.o \
+               vm/arrays.o \
+               vm/bignum.o \
+               vm/booleans.o \
+               vm/byte_arrays.o \
+               vm/callbacks.o \
+               vm/callstack.o \
+               vm/code_blocks.o \
+               vm/code_heap.o \
+               vm/compaction.o \
+               vm/contexts.o \
+               vm/data_heap.o \
+               vm/data_heap_checker.o \
+               vm/debug.o \
+               vm/dispatch.o \
+               vm/entry_points.o \
+               vm/errors.o \
+               vm/factor.o \
+               vm/free_list.o \
+               vm/full_collector.o \
+               vm/gc.o \
+               vm/image.o \
+               vm/inline_cache.o \
+               vm/instruction_operands.o \
+               vm/io.o \
+               vm/jit.o \
+               vm/math.o \
+               vm/nursery_collector.o \
+               vm/object_start_map.o \
+               vm/objects.o \
+               vm/primitives.o \
+               vm/profiler.o \
+               vm/quotations.o \
+               vm/run.o \
+               vm/strings.o \
+               vm/to_tenured_collector.o \
+               vm/tuples.o \
+               vm/utilities.o \
+               vm/vm.o \
+               vm/words.o
+
+       EXE_OBJS = $(PLAF_EXE_OBJS)
+
+       FFI_TEST_LIBRARY = libfactor-ffi-test$(SHARED_DLL_EXTENSION)
+
+       TEST_OBJS = vm/ffi_test.o
+endif
+
+default:
+       $(MAKE) `./build-support/factor.sh make-target`
+
+help:
+       @echo "Run '$(MAKE)' with one of the following parameters:"
+       @echo ""
+       @echo "freebsd-x86-32"
+       @echo "freebsd-x86-64"
+       @echo "linux-x86-32"
+       @echo "linux-x86-64"
+       @echo "linux-ppc"
+       @echo "linux-arm"
+       @echo "openbsd-x86-32"
+       @echo "openbsd-x86-64"
+       @echo "netbsd-x86-32"
+       @echo "netbsd-x86-64"
+       @echo "macosx-x86-32"
+       @echo "macosx-x86-64"
+       @echo "macosx-ppc"
+       @echo "solaris-x86-32"
+       @echo "solaris-x86-64"
+       @echo "wince-arm"
+       @echo "winnt-x86-32"
+       @echo "winnt-x86-64"
+       @echo ""
+       @echo "Additional modifiers:"
+       @echo ""
+       @echo "DEBUG=1  compile VM with debugging information"
+       @echo "SITE_CFLAGS=...  additional optimization flags"
+       @echo "NO_UI=1  don't link with X11 libraries (ignored on Mac OS X)"
+       @echo "X11=1  force link with X11 libraries instead of Cocoa (only on Mac OS X)"
+
+openbsd-x86-32:
+       $(MAKE) factor factor-ffi-test CONFIG=vm/Config.openbsd.x86.32
+
+openbsd-x86-64:
+       $(MAKE) factor factor-ffi-test CONFIG=vm/Config.openbsd.x86.64
+
+freebsd-x86-32:
+       $(MAKE) factor factor-ffi-test CONFIG=vm/Config.freebsd.x86.32
+
+freebsd-x86-64:
+       $(MAKE) factor factor-ffi-test CONFIG=vm/Config.freebsd.x86.64
+
+netbsd-x86-32:
+       $(MAKE) factor factor-ffi-test CONFIG=vm/Config.netbsd.x86.32
+
+netbsd-x86-64:
+       $(MAKE) factor factor-ffi-test CONFIG=vm/Config.netbsd.x86.64
+
+macosx-ppc:
+       $(MAKE) factor factor-ffi-test macosx.app CONFIG=vm/Config.macosx.ppc
+
+macosx-x86-32:
+       $(MAKE) factor factor-ffi-test macosx.app CONFIG=vm/Config.macosx.x86.32
+
+macosx-x86-64:
+       $(MAKE) factor factor-ffi-test macosx.app CONFIG=vm/Config.macosx.x86.64
+
+linux-x86-32:
+       $(MAKE) factor factor-ffi-test CONFIG=vm/Config.linux.x86.32
+
+linux-x86-64:
+       $(MAKE) factor factor-ffi-test CONFIG=vm/Config.linux.x86.64
+
+linux-ppc:
+       $(MAKE) factor factor-ffi-test CONFIG=vm/Config.linux.ppc
+
+linux-arm:
+       $(MAKE) factor factor-ffi-test CONFIG=vm/Config.linux.arm
+
+solaris-x86-32:
+       $(MAKE) factor factor-ffi-test CONFIG=vm/Config.solaris.x86.32
+
+solaris-x86-64:
+       $(MAKE) factor factor-ffi-test CONFIG=vm/Config.solaris.x86.64
+
+winnt-x86-32:
+       $(MAKE) factor factor-ffi-test CONFIG=vm/Config.windows.nt.x86.32
+       $(MAKE) factor-console CONFIG=vm/Config.windows.nt.x86.32
+
+winnt-x86-64:
+       $(MAKE) factor factor-ffi-test CONFIG=vm/Config.windows.nt.x86.64
+       $(MAKE) factor-console CONFIG=vm/Config.windows.nt.x86.64
+
+wince-arm:
+       $(MAKE) factor factor-ffi-test CONFIG=vm/Config.windows.ce.arm
+
+ifdef CONFIG
+
+macosx.app: factor
+       mkdir -p $(BUNDLE)/Contents/MacOS
+       mkdir -p $(BUNDLE)/Contents/Frameworks
+       mv $(EXECUTABLE) $(BUNDLE)/Contents/MacOS/factor
+       ln -s Factor.app/Contents/MacOS/factor ./factor
+       cp $(ENGINE) $(BUNDLE)/Contents/Frameworks/$(ENGINE)
+
+       install_name_tool \
+               -change libfactor.dylib \
+               @executable_path/../Frameworks/libfactor.dylib \
+               Factor.app/Contents/MacOS/factor
+
+$(ENGINE): $(DLL_OBJS)
+       $(TOOLCHAIN_PREFIX)$(LINKER) $(ENGINE) $(DLL_OBJS)
+
+factor: $(EXE_OBJS) $(ENGINE)
+       $(TOOLCHAIN_PREFIX)$(CPP) $(LIBS) $(LIBPATH) -L. $(LINK_WITH_ENGINE) \
+               $(CFLAGS) -o $(EXECUTABLE) $(EXE_OBJS)
+
+factor-console: $(EXE_OBJS) $(ENGINE)
+       $(TOOLCHAIN_PREFIX)$(CPP) $(LIBS) $(LIBPATH) -L. $(LINK_WITH_ENGINE) \
+               $(CFLAGS) $(CFLAGS_CONSOLE) -o $(CONSOLE_EXECUTABLE) $(EXE_OBJS)
+
+factor-ffi-test: $(FFI_TEST_LIBRARY)
+
+$(FFI_TEST_LIBRARY): vm/ffi_test.o
+       $(TOOLCHAIN_PREFIX)$(CC) $(LIBPATH) $(CFLAGS) $(FFI_TEST_CFLAGS) $(SHARED_FLAG) -o $(FFI_TEST_LIBRARY) $(TEST_OBJS)
+
+vm/resources.o:
+       $(TOOLCHAIN_PREFIX)$(WINDRES) vm/factor.rs vm/resources.o
+
+vm/ffi_test.o: vm/ffi_test.c
+       $(TOOLCHAIN_PREFIX)$(CC) -c $(CFLAGS) $(FFI_TEST_CFLAGS) -o $@ $<
+
+.cpp.o:
+       $(TOOLCHAIN_PREFIX)$(CPP) -c $(CFLAGS) -o $@ $<
+
+.S.o:
+       $(TOOLCHAIN_PREFIX)$(CC) -x assembler-with-cpp -c $(CFLAGS) -o $@ $<
+
+.mm.o:
+       $(TOOLCHAIN_PREFIX)$(CPP) -c $(CFLAGS) -o $@ $<
+
+.SUFFIXES: .mm
+
+endif
+
+clean:
+       rm -f vm/*.o
+       rm -f factor.dll
+       rm -f libfactor.*
+       rm -f libfactor-ffi-test.*
+       rm -f Factor.app/Contents/Frameworks/libfactor.dylib
+
+tags:
+       etags vm/*.{cpp,hpp,mm,S,c}
+
+.PHONY: factor factor-console factor-ffi-test tags clean macosx.app
diff --git a/Makefile b/Makefile
deleted file mode 100755 (executable)
index 2ea4370..0000000
--- a/Makefile
+++ /dev/null
@@ -1,219 +0,0 @@
-CC = gcc
-CPP = g++
-AR = ar
-LD = ld
-
-EXECUTABLE = factor
-CONSOLE_EXECUTABLE = factor-console
-TEST_LIBRARY = factor-ffi-test
-VERSION = 0.92
-
-BUNDLE = Factor.app
-LIBPATH = -L/usr/X11R6/lib
-CFLAGS = -Wall
-
-ifdef DEBUG
-       CFLAGS += -g -DFACTOR_DEBUG
-else
-       CFLAGS += -O3
-endif
-
-ifdef REENTRANT
-       CFLAGS += -DFACTOR_REENTRANT
-endif
-
-CFLAGS += $(SITE_CFLAGS)
-
-ENGINE = $(DLL_PREFIX)factor$(DLL_SUFFIX)$(DLL_EXTENSION)
-
-ifdef CONFIG
-       include $(CONFIG)
-endif
-
-DLL_OBJS = $(PLAF_DLL_OBJS) \
-       vm/aging_collector.o \
-       vm/alien.o \
-       vm/arrays.o \
-       vm/bignum.o \
-       vm/booleans.o \
-       vm/byte_arrays.o \
-       vm/callbacks.o \
-       vm/callstack.o \
-       vm/code_block.o \
-       vm/code_heap.o \
-       vm/compaction.o \
-       vm/contexts.o \
-       vm/data_heap.o \
-       vm/debug.o \
-       vm/dispatch.o \
-       vm/errors.o \
-       vm/factor.o \
-       vm/free_list.o \
-       vm/full_collector.o \
-       vm/gc.o \
-       vm/image.o \
-       vm/inline_cache.o \
-       vm/io.o \
-       vm/jit.o \
-       vm/math.o \
-       vm/nursery_collector.o \
-       vm/object_start_map.o \
-       vm/primitives.o \
-       vm/profiler.o \
-       vm/quotations.o \
-       vm/run.o \
-       vm/strings.o \
-       vm/to_tenured_collector.o \
-       vm/tuples.o \
-       vm/utilities.o \
-        vm/vm.o \
-       vm/words.o
-
-EXE_OBJS = $(PLAF_EXE_OBJS)
-
-TEST_OBJS = vm/ffi_test.o
-
-default:
-       $(MAKE) `./build-support/factor.sh make-target`
-
-help:
-       @echo "Run '$(MAKE)' with one of the following parameters:"
-       @echo ""
-       @echo "freebsd-x86-32"
-       @echo "freebsd-x86-64"
-       @echo "linux-x86-32"
-       @echo "linux-x86-64"
-       @echo "linux-ppc"
-       @echo "linux-arm"
-       @echo "openbsd-x86-32"
-       @echo "openbsd-x86-64"
-       @echo "netbsd-x86-32"
-       @echo "netbsd-x86-64"
-       @echo "macosx-x86-32"
-       @echo "macosx-x86-64"
-       @echo "macosx-ppc"
-       @echo "solaris-x86-32"
-       @echo "solaris-x86-64"
-       @echo "wince-arm"
-       @echo "winnt-x86-32"
-       @echo "winnt-x86-64"
-       @echo ""
-       @echo "Additional modifiers:"
-       @echo ""
-       @echo "DEBUG=1  compile VM with debugging information"
-       @echo "SITE_CFLAGS=...  additional optimization flags"
-       @echo "NO_UI=1  don't link with X11 libraries (ignored on Mac OS X)"
-       @echo "X11=1  force link with X11 libraries instead of Cocoa (only on Mac OS X)"
-
-openbsd-x86-32:
-       $(MAKE) $(EXECUTABLE) $(TEST_LIBRARY) CONFIG=vm/Config.openbsd.x86.32
-
-openbsd-x86-64:
-       $(MAKE) $(EXECUTABLE) $(TEST_LIBRARY) CONFIG=vm/Config.openbsd.x86.64
-
-freebsd-x86-32:
-       $(MAKE) $(EXECUTABLE) $(TEST_LIBRARY) CONFIG=vm/Config.freebsd.x86.32
-
-freebsd-x86-64:
-       $(MAKE) $(EXECUTABLE) $(TEST_LIBRARY) CONFIG=vm/Config.freebsd.x86.64
-
-netbsd-x86-32:
-       $(MAKE) $(EXECUTABLE) $(TEST_LIBRARY) CONFIG=vm/Config.netbsd.x86.32
-
-netbsd-x86-64:
-       $(MAKE) $(EXECUTABLE) $(TEST_LIBRARY) CONFIG=vm/Config.netbsd.x86.64
-
-macosx-ppc:
-       $(MAKE) $(EXECUTABLE) $(TEST_LIBRARY) macosx.app CONFIG=vm/Config.macosx.ppc
-
-macosx-x86-32:
-       $(MAKE) $(EXECUTABLE) $(TEST_LIBRARY) macosx.app CONFIG=vm/Config.macosx.x86.32
-
-macosx-x86-64:
-       $(MAKE) $(EXECUTABLE) $(TEST_LIBRARY) macosx.app CONFIG=vm/Config.macosx.x86.64
-
-linux-x86-32:
-       $(MAKE) $(EXECUTABLE) $(TEST_LIBRARY) CONFIG=vm/Config.linux.x86.32
-
-linux-x86-64:
-       $(MAKE) $(EXECUTABLE) $(TEST_LIBRARY) CONFIG=vm/Config.linux.x86.64
-
-linux-ppc:
-       $(MAKE) $(EXECUTABLE) $(TEST_LIBRARY) CONFIG=vm/Config.linux.ppc
-
-linux-arm:
-       $(MAKE) $(EXECUTABLE) $(TEST_LIBRARY) CONFIG=vm/Config.linux.arm
-
-solaris-x86-32:
-       $(MAKE) $(EXECUTABLE) $(TEST_LIBRARY) CONFIG=vm/Config.solaris.x86.32
-
-solaris-x86-64:
-       $(MAKE) $(EXECUTABLE) $(TEST_LIBRARY) CONFIG=vm/Config.solaris.x86.64
-
-winnt-x86-32:
-       $(MAKE) $(EXECUTABLE) $(TEST_LIBRARY) CONFIG=vm/Config.windows.nt.x86.32
-       $(MAKE) $(CONSOLE_EXECUTABLE) CONFIG=vm/Config.windows.nt.x86.32
-
-winnt-x86-64:
-       $(MAKE) $(EXECUTABLE) $(TEST_LIBRARY) CONFIG=vm/Config.windows.nt.x86.64
-       $(MAKE) $(CONSOLE_EXECUTABLE) CONFIG=vm/Config.windows.nt.x86.64
-
-wince-arm:
-       $(MAKE) $(EXECUTABLE) $(TEST_LIBRARY) CONFIG=vm/Config.windows.ce.arm
-
-macosx.app: factor
-       mkdir -p $(BUNDLE)/Contents/MacOS
-       mkdir -p $(BUNDLE)/Contents/Frameworks
-       mv $(EXECUTABLE) $(BUNDLE)/Contents/MacOS/factor
-       ln -s Factor.app/Contents/MacOS/factor ./factor
-       cp $(ENGINE) $(BUNDLE)/Contents/Frameworks/$(ENGINE)
-
-       install_name_tool \
-               -change libfactor.dylib \
-               @executable_path/../Frameworks/libfactor.dylib \
-               Factor.app/Contents/MacOS/factor
-
-$(EXECUTABLE): $(DLL_OBJS) $(EXE_OBJS)
-       $(TOOLCHAIN_PREFIX)$(LINKER) $(ENGINE) $(DLL_OBJS)
-       $(TOOLCHAIN_PREFIX)$(CPP) $(LIBS) $(LIBPATH) -L. $(LINK_WITH_ENGINE) \
-               $(CFLAGS) -o $@$(EXE_SUFFIX)$(EXE_EXTENSION) $(EXE_OBJS)
-
-$(CONSOLE_EXECUTABLE): $(DLL_OBJS) $(EXE_OBJS)
-       $(TOOLCHAIN_PREFIX)$(LINKER) $(ENGINE) $(DLL_OBJS)
-       $(TOOLCHAIN_PREFIX)$(CPP) $(LIBS) $(LIBPATH) -L. $(LINK_WITH_ENGINE) \
-               $(CFLAGS) $(CFLAGS_CONSOLE) -o factor$(EXE_SUFFIX)$(CONSOLE_EXTENSION) $(EXE_OBJS)
-
-$(TEST_LIBRARY): vm/ffi_test.o
-       $(TOOLCHAIN_PREFIX)$(CC) $(LIBPATH) $(CFLAGS) $(FFI_TEST_CFLAGS) $(SHARED_FLAG) -o libfactor-ffi-test$(SHARED_DLL_EXTENSION) $(TEST_OBJS)
-
-clean:
-       rm -f vm/*.o
-       rm -f factor.dll
-       rm -f libfactor.*
-       rm -f libfactor-ffi-test.*
-       rm -f Factor.app/Contents/Frameworks/libfactor.dylib
-
-tags:
-       etags vm/*.{cpp,hpp,mm,S,c}
-
-vm/resources.o:
-       $(TOOLCHAIN_PREFIX)$(WINDRES) vm/factor.rs vm/resources.o
-
-vm/ffi_test.o: vm/ffi_test.c
-       $(TOOLCHAIN_PREFIX)$(CC) -c $(CFLAGS) $(FFI_TEST_CFLAGS) -o $@ $<
-
-.c.o:
-       $(TOOLCHAIN_PREFIX)$(CC) -c $(CFLAGS) -o $@ $<
-
-.cpp.o:
-       $(TOOLCHAIN_PREFIX)$(CPP) -c $(CFLAGS) -o $@ $<
-
-.S.o:
-       $(TOOLCHAIN_PREFIX)$(CC) -x assembler-with-cpp -c $(CFLAGS) -o $@ $<
-
-.mm.o:
-       $(TOOLCHAIN_PREFIX)$(CPP) -c $(CFLAGS) -o $@ $<
-
-.PHONY: factor tags clean
-
-.SUFFIXES: .mm
diff --git a/Nmakefile b/Nmakefile
new file mode 100755 (executable)
index 0000000..e964105
--- /dev/null
+++ b/Nmakefile
@@ -0,0 +1,77 @@
+LINK_FLAGS = /nologo shell32.lib\r
+CL_FLAGS = /nologo /O2 /W3\r
+\r
+EXE_OBJS = factor.dll.lib vm\main-windows-nt.obj vm\factor.res\r
+\r
+DLL_OBJS = vm\os-windows-nt.obj \\r
+       vm\os-windows.obj \\r
+       vm\aging_collector.obj \\r
+       vm\alien.obj \\r
+       vm\arrays.obj \\r
+       vm\bignum.obj \\r
+       vm\booleans.obj \\r
+       vm\byte_arrays.obj \\r
+       vm\callbacks.obj \\r
+       vm\callstack.obj \\r
+       vm\code_blocks.obj \\r
+       vm\code_heap.obj \\r
+       vm\compaction.obj \\r
+       vm\contexts.obj \\r
+       vm\data_heap.obj \\r
+       vm\data_heap_checker.obj \\r
+       vm\debug.obj \\r
+       vm\dispatch.obj \\r
+       vm\entry_points.obj \\r
+       vm\errors.obj \\r
+       vm\factor.obj \\r
+       vm\free_list.obj \\r
+       vm\full_collector.obj \\r
+       vm\gc.obj \\r
+       vm\image.obj \\r
+       vm\inline_cache.obj \\r
+       vm\instruction_operands.obj \\r
+       vm\io.obj \\r
+       vm\jit.obj \\r
+       vm\math.obj \\r
+       vm\nursery_collector.obj \\r
+       vm\object_start_map.obj \\r
+       vm\objects.obj \\r
+       vm\primitives.obj \\r
+       vm\profiler.obj \\r
+       vm\quotations.obj \\r
+       vm\run.obj \\r
+       vm\strings.obj \\r
+       vm\to_tenured_collector.obj \\r
+       vm\tuples.obj \\r
+       vm\utilities.obj \\r
+        vm\vm.obj \\r
+       vm\words.obj\r
+\r
+.cpp.obj:\r
+       cl /EHsc $(CL_FLAGS) /Fo$@ /c $<\r
+\r
+.rs.res:\r
+       rc $<\r
+\r
+all: factor.com factor.exe\r
+\r
+factor.dll.lib: $(DLL_OBJS)\r
+       link $(LINK_FLAGS) /implib:factor.dll.lib /out:factor.dll /dll $(DLL_OBJS)\r
+\r
+factor.com: $(EXE_OBJS)\r
+       link $(LINK_FLAGS) /out:factor.com /SUBSYSTEM:console $(EXE_OBJS)\r
+\r
+factor.exe: $(EXE_OBJS)\r
+       link $(LINK_FLAGS) /out:factor.exe /SUBSYSTEM:windows $(EXE_OBJS)\r
+\r
+clean:\r
+       del vm\*.obj\r
+       del factor.lib\r
+       del factor.com\r
+       del factor.exe\r
+       del factor.dll\r
+       del factor.dll.lib\r
+\r
+.PHONY: all clean\r
+\r
+.SUFFIXES: .rs\r
index 82134e825ea1320da202a2069d254212904bbdd5..396011a3515e26d791e29a7a8153ea6cf7924d47 100644 (file)
@@ -1,16 +1,37 @@
+USING: help.markup help.syntax calendar quotations system ;\r
 IN: alarms\r
-USING: help.markup help.syntax calendar quotations ;\r
 \r
 HELP: alarm\r
 { $class-description "An alarm. Can be passed to " { $link cancel-alarm } "." } ;\r
 \r
+HELP: current-alarm\r
+{ $description "A symbol that contains the currently executing alarm, availble only to the alarm quotation. One use for this symbol is if a repeated alarm wishes to cancel itself from executing in the future."\r
+}\r
+{ $examples\r
+    { $unchecked-example\r
+        """USING: alarms calendar io threads ;"""\r
+        """["""\r
+        """    "Hi, this should only get printed once..." print flush"""\r
+        """    current-alarm get cancel-alarm"""\r
+        """] 1 seconds every"""\r
+        ""\r
+    }\r
+} ;\r
+\r
 HELP: add-alarm\r
-{ $values { "quot" quotation } { "time" timestamp } { "frequency" { $maybe duration } } { "alarm" alarm } }\r
-{ $description "Creates and registers an alarm. If " { $snippet "frequency" } " is " { $link f } ", this will be a one-time alarm, otherwise it will fire with the given frequency. The quotation will be called from the alarm thread." } ;\r
+{ $values { "quot" quotation } { "start" duration } { "interval" { $maybe "duration/f" } } { "alarm" alarm } }\r
+{ $description "Creates and registers an alarm to start at " { $snippet "start" } " offset from the current time. If " { $snippet "interval" } " is " { $link f } ", this will be a one-time alarm, otherwise it will fire with the given frequency, with scheduling happening before the quotation is called in order to ensure that the next event will happen on time. The quotation will be called from a new thread spawned by the alarm thread. If a repeated alarm's quotation throws an exception, the alarm will not be rescheduled." } ;\r
 \r
 HELP: later\r
 { $values { "quot" quotation } { "duration" duration } { "alarm" alarm } }\r
-{ $description "Creates and registers an alarm which calls the quotation once at " { $snippet "time" } " from now." } ;\r
+{ $description "Creates and registers an alarm which calls the quotation once at " { $snippet "duration" } " offset from now." }\r
+{ $examples\r
+    { $unchecked-example\r
+        "USING: alarms io calendar ;"\r
+        """[ "Break's over!" print flush ] 15 minutes drop"""\r
+        ""\r
+    }\r
+} ;\r
 \r
 HELP: cancel-alarm\r
 { $values { "alarm" alarm } }\r
@@ -20,16 +41,29 @@ HELP: every
 { $values\r
      { "quot" quotation } { "duration" duration }\r
      { "alarm" alarm } }\r
-{ $description "Creates and registers an alarm which calls the quotation repeatedly, using " { $snippet "dt" } " as the frequency." } ;\r
+{ $description "Creates and registers an alarm which calls the quotation repeatedly, using " { $snippet "dt" } " as the frequency. If the quotation throws an exception that is not caught inside it, the alarm scheduler will cancel the alarm and will not reschedule it again." }\r
+{ $examples\r
+    { $unchecked-example\r
+        "USING: alarms io calendar ;"\r
+        """[ "Hi Buddy." print flush ] 10 seconds every drop"""\r
+        ""\r
+    }\r
+} ;\r
 \r
 ARTICLE: "alarms" "Alarms"\r
-"The " { $vocab-link "alarms" } " vocabulary provides a lightweight way to schedule one-time and recurring tasks without spawning a new thread."\r
-{ $subsections\r
-    alarm\r
-    add-alarm\r
-    later\r
-    cancel-alarm\r
-}\r
+"The " { $vocab-link "alarms" } " vocabulary provides a lightweight way to schedule one-time and recurring tasks without spawning a new thread. Alarms use " { $link nano-count } ", so they continue to work across system clock changes." $nl\r
+"The alarm class:"\r
+{ $subsections alarm }\r
+"Register a recurring alarm:"\r
+{ $subsections every }\r
+"Register a one-time alarm:"\r
+{ $subsections later }\r
+"The currently executing alarm:"\r
+{ $subsections current-alarm }\r
+"Low-level interface to add alarms:"\r
+{ $subsections add-alarm }\r
+"Cancelling an alarm:"\r
+{ $subsections cancel-alarm }\r
 "Alarms do not persist across image saves. Saving and restoring an image has the effect of calling " { $link cancel-alarm } " on all " { $link alarm } " instances." ;\r
 \r
 ABOUT: "alarms"\r
index 9943d39ad194a6d0efe5d356d3873afa6099ed94..9ab30a1fa4db79b3fde7bb4417e2308b6ddc8cf9 100644 (file)
@@ -1,48 +1,66 @@
 ! Copyright (C) 2005, 2008 Slava Pestov, Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors assocs boxes calendar
-combinators.short-circuit fry heaps init kernel math.order
-namespaces quotations threads ;
+USING: accessors assocs boxes calendar combinators.short-circuit
+continuations fry heaps init kernel math.order
+namespaces quotations threads math system ;
 IN: alarms
 
 TUPLE: alarm
     { quot callable initial: [ ] }
-    { time timestamp }
+    { start integer }
     interval
     { entry box } ;
 
-<PRIVATE
-
 SYMBOL: alarms
 SYMBOL: alarm-thread
+SYMBOL: current-alarm
+
+: cancel-alarm ( alarm -- )
+    entry>> [ alarms get-global heap-delete ] if-box? ;
+
+<PRIVATE
 
 : notify-alarm-thread ( -- )
     alarm-thread get-global interrupt ;
 
-ERROR: bad-alarm-frequency frequency ;
-: check-alarm ( frequency/f -- frequency/f )
-    dup { [ duration? ] [ not ] } 1|| [ bad-alarm-frequency ] unless ;
+GENERIC: >nanoseconds ( obj -- duration/f )
+M: f >nanoseconds ;
+M: real >nanoseconds >integer ;
+M: duration >nanoseconds duration>nanoseconds >integer ;
 
-: <alarm> ( quot time frequency -- alarm )
-    check-alarm <box> alarm boa ;
+: <alarm> ( quot start interval -- alarm )
+    alarm new
+        swap >nanoseconds >>interval
+        swap >nanoseconds nano-count + >>start
+        swap >>quot
+        <box> >>entry ;
 
 : register-alarm ( alarm -- )
-    [ dup time>> alarms get-global heap-push* ]
+    [ dup start>> alarms get-global heap-push* ]
     [ entry>> >box ] bi
     notify-alarm-thread ;
 
-: alarm-expired? ( alarm now -- ? )
-    [ time>> ] dip before=? ;
+: alarm-expired? ( alarm n -- ? )
+    [ start>> ] dip <= ;
 
 : reschedule-alarm ( alarm -- )
-    dup '[ _ interval>> time+ now max ] change-time register-alarm ;
+    dup interval>> nano-count + >>start register-alarm ;
 
 : call-alarm ( alarm -- )
     [ entry>> box> drop ]
-    [ quot>> "Alarm execution" spawn drop ]
-    [ dup interval>> [ reschedule-alarm ] [ drop ] if ] tri ;
-
-: (trigger-alarms) ( alarms now -- )
+    [ dup interval>> [ reschedule-alarm ] [ drop ] if ]
+    [
+        [ ] [ quot>> ] [ ] tri
+        '[
+            _ current-alarm
+            [
+                _ [ _ dup interval>> [ cancel-alarm ] [ drop ] if rethrow ]
+                recover
+            ] with-variable
+        ] "Alarm execution" spawn drop
+    ] tri ;
+
+: (trigger-alarms) ( alarms n -- )
     over heap-empty? [
         2drop
     ] [
@@ -54,11 +72,10 @@ ERROR: bad-alarm-frequency frequency ;
     ] if ;
 
 : trigger-alarms ( alarms -- )
-    now (trigger-alarms) ;
+    nano-count (trigger-alarms) ;
 
-: next-alarm ( alarms -- timestamp/f )
-    dup heap-empty?
-    [ drop f ] [ heap-peek drop time>> ] if ;
+: next-alarm ( alarms -- nanos/f )
+    dup heap-empty? [ drop f ] [ heap-peek drop start>> ] if ;
 
 : alarm-thread-loop ( -- )
     alarms get-global
@@ -75,18 +92,13 @@ ERROR: bad-alarm-frequency frequency ;
     [ alarm-thread-loop t ] "Alarms" spawn-server
     alarm-thread set-global ;
 
-[ init-alarms ] "alarms" add-init-hook
+[ init-alarms ] "alarms" add-startup-hook
 
 PRIVATE>
 
-: add-alarm ( quot time frequency -- alarm )
+: add-alarm ( quot start interval -- alarm )
     <alarm> [ register-alarm ] keep ;
 
-: later ( quot duration -- alarm )
-    hence f add-alarm ;
+: later ( quot duration -- alarm ) f add-alarm ;
 
-: every ( quot duration -- alarm )
-    [ hence ] keep add-alarm ;
-
-: cancel-alarm ( alarm -- )
-    entry>> [ alarms get-global heap-delete ] if-box? ;
+: every ( quot duration -- alarm ) dup add-alarm ;
old mode 100755 (executable)
new mode 100644 (file)
index ee75d22..7eed1a0
@@ -20,6 +20,8 @@ M: array heap-size unclip [ array-length ] [ heap-size ] bi* * ;
 
 M: array c-type-align first c-type-align ;
 
+M: array c-type-align-first first c-type-align-first ;
+
 M: array c-type-stack-align? drop f ;
 
 M: array unbox-parameter drop void* unbox-parameter ;
@@ -55,6 +57,9 @@ M: string-type heap-size
 M: string-type c-type-align
     drop void* c-type-align ;
 
+M: string-type c-type-align-first
+    drop void* c-type-align-first ;
+
 M: string-type c-type-stack-align?
     drop void* c-type-stack-align? ;
 
@@ -97,5 +102,5 @@ M: string-type c-type-setter
 { char* utf8 } char* typedef
 char* uchar* typedef
 
-char  char*  "pointer-c-type" set-word-prop
+char char* "pointer-c-type" set-word-prop
 uchar uchar* "pointer-c-type" set-word-prop
old mode 100755 (executable)
new mode 100644 (file)
index a0dea4e..b221051
@@ -66,12 +66,12 @@ HELP: unbox-return
 { $notes "This is an internal word used by the compiler when compiling callbacks." } ;
 
 HELP: define-deref
-{ $values { "name" "a word name" } }
+{ $values { "c-type" "a C type" } }
 { $description "Defines a word " { $snippet "*name" } " with stack effect " { $snippet "( c-ptr -- value )" } " for reading a value with C type " { $snippet "name" } " stored at an alien pointer." }
 { $notes "This is an internal word called when defining C types, there is no need to call it on your own." } ;
 
 HELP: define-out
-{ $values { "name" "a word name" } }
+{ $values { "c-type" "a C type" } }
 { $description "Defines a word " { $snippet "<" { $emphasis "name" } ">" } " with stack effect " { $snippet "( value -- array )" } ". This word allocates a byte array large enough to hold a value with C type " { $snippet "name" } ", and writes the value at the top of the stack to the array." }
 { $notes "This is an internal word called when defining C types, there is no need to call it on your own." } ;
 
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index cfbed53..347d157
@@ -30,8 +30,9 @@ TUPLE: abstract-c-type
 { unboxer-quot callable }
 { getter callable }
 { setter callable }
-size
-align ;
+{ size integer }
+{ align integer }
+{ align-first integer } ;
 
 TUPLE: c-type < abstract-c-type
 boxer
@@ -104,10 +105,9 @@ M: word c-type
 
 GENERIC: c-struct? ( c-type -- ? )
 
-M: object c-struct?
-    drop f ;
-M: c-type-name c-struct?
-    dup void? [ drop f ] [ c-type c-struct? ] if ;
+M: object c-struct? drop f ;
+
+M: c-type-name c-struct? dup void? [ drop f ] [ c-type c-struct? ] if ;
 
 ! These words being foldable means that words need to be
 ! recompiled if a C type is redefined. Even so, folding the
@@ -172,6 +172,12 @@ M: abstract-c-type c-type-align align>> ;
 
 M: c-type-name c-type-align c-type c-type-align ;
 
+GENERIC: c-type-align-first ( name -- n )
+
+M: c-type-name c-type-align-first c-type c-type-align-first ;
+
+M: abstract-c-type c-type-align-first align-first>> ;
+
 GENERIC: c-type-stack-align? ( name -- ? )
 
 M: c-type c-type-stack-align? stack-align?>> ;
@@ -212,13 +218,13 @@ M: c-type-name unbox-return c-type unbox-return ;
 
 : little-endian? ( -- ? ) 1 <int> *char 1 = ; foldable
 
-GENERIC: heap-size ( name -- size ) foldable
+GENERIC: heap-size ( name -- size )
 
 M: c-type-name heap-size c-type heap-size ;
 
 M: abstract-c-type heap-size size>> ;
 
-GENERIC: stack-size ( name -- size ) foldable
+GENERIC: stack-size ( name -- size )
 
 M: c-type-name stack-size c-type stack-size ;
 
@@ -291,20 +297,17 @@ M: long-long-type box-parameter ( n c-type -- )
 M: long-long-type box-return ( c-type -- )
     f swap box-parameter ;
 
-: define-deref ( name -- )
-    [ CHAR: * prefix "alien.c-types" create ] [ c-getter 0 prefix ] bi
+: define-deref ( c-type -- )
+    [ name>> CHAR: * prefix "alien.c-types" create ] [ c-getter 0 prefix ] bi
     (( c-ptr -- value )) define-inline ;
 
-: define-out ( name -- )
-    [ "alien.c-types" constructor-word ]
+: define-out ( c-type -- )
+    [ name>> "alien.c-types" constructor-word ]
     [ dup c-setter '[ _ heap-size (byte-array) [ 0 @ ] keep ] ] bi
     (( value -- c-ptr )) define-inline ;
 
 : define-primitive-type ( c-type name -- )
-    [ typedef ]
-    [ name>> define-deref ]
-    [ name>> define-out ]
-    tri ;
+    [ typedef ] [ define-deref ] [ define-out ] tri ;
 
 : if-void ( c-type true false -- )
     pick void? [ drop nip call ] [ nip call ] if ; inline
@@ -324,6 +327,13 @@ SYMBOLS:
     ptrdiff_t intptr_t uintptr_t size_t
     char* uchar* ;
 
+: 8-byte-alignment ( c-type -- c-type )
+    {
+        { [ cpu ppc? os macosx? and ] [ 4 >>align 8 >>align-first ] }
+        { [ cpu x86.32? os windows? not and ] [ 4 >>align 4 >>align-first ] }
+        [ 8 >>align 8 >>align-first ]
+    } cond ;
+
 [
     <c-type>
         c-ptr >>class
@@ -332,8 +342,9 @@ SYMBOLS:
         [ [ >c-ptr ] 2dip set-alien-cell ] >>setter
         bootstrap-cell >>size
         bootstrap-cell >>align
+        bootstrap-cell >>align-first
         [ >c-ptr ] >>unboxer-quot
-        "box_alien" >>boxer
+        "allot_alien" >>boxer
         "alien_offset" >>unboxer
     \ void* define-primitive-type
 
@@ -343,8 +354,8 @@ SYMBOLS:
         [ alien-signed-8 ] >>getter
         [ set-alien-signed-8 ] >>setter
         8 >>size
-        cpu x86.32? os windows? not and 4 8 ? >>align
-        "box_signed_8" >>boxer
+        8-byte-alignment
+        "from_signed_8" >>boxer
         "to_signed_8" >>unboxer
     \ longlong define-primitive-type
 
@@ -354,8 +365,8 @@ SYMBOLS:
         [ alien-unsigned-8 ] >>getter
         [ set-alien-unsigned-8 ] >>setter
         8 >>size
-        cpu x86.32? os windows? not and 4 8 ? >>align
-        "box_unsigned_8" >>boxer
+        8-byte-alignment
+        "from_unsigned_8" >>boxer
         "to_unsigned_8" >>unboxer
     \ ulonglong define-primitive-type
 
@@ -366,7 +377,8 @@ SYMBOLS:
         [ set-alien-signed-cell ] >>setter
         bootstrap-cell >>size
         bootstrap-cell >>align
-        "box_signed_cell" >>boxer
+        bootstrap-cell >>align-first
+        "from_signed_cell" >>boxer
         "to_fixnum" >>unboxer
     \ long define-primitive-type
 
@@ -377,7 +389,8 @@ SYMBOLS:
         [ set-alien-unsigned-cell ] >>setter
         bootstrap-cell >>size
         bootstrap-cell >>align
-        "box_unsigned_cell" >>boxer
+        bootstrap-cell >>align-first
+        "from_unsigned_cell" >>boxer
         "to_cell" >>unboxer
     \ ulong define-primitive-type
 
@@ -388,7 +401,8 @@ SYMBOLS:
         [ set-alien-signed-4 ] >>setter
         4 >>size
         4 >>align
-        "box_signed_4" >>boxer
+        4 >>align-first
+        "from_signed_4" >>boxer
         "to_fixnum" >>unboxer
     \ int define-primitive-type
 
@@ -399,7 +413,8 @@ SYMBOLS:
         [ set-alien-unsigned-4 ] >>setter
         4 >>size
         4 >>align
-        "box_unsigned_4" >>boxer
+        4 >>align-first
+        "from_unsigned_4" >>boxer
         "to_cell" >>unboxer
     \ uint define-primitive-type
 
@@ -410,7 +425,8 @@ SYMBOLS:
         [ set-alien-signed-2 ] >>setter
         2 >>size
         2 >>align
-        "box_signed_2" >>boxer
+        2 >>align-first
+        "from_signed_2" >>boxer
         "to_fixnum" >>unboxer
     \ short define-primitive-type
 
@@ -421,7 +437,8 @@ SYMBOLS:
         [ set-alien-unsigned-2 ] >>setter
         2 >>size
         2 >>align
-        "box_unsigned_2" >>boxer
+        2 >>align-first
+        "from_unsigned_2" >>boxer
         "to_cell" >>unboxer
     \ ushort define-primitive-type
 
@@ -432,7 +449,8 @@ SYMBOLS:
         [ set-alien-signed-1 ] >>setter
         1 >>size
         1 >>align
-        "box_signed_1" >>boxer
+        1 >>align-first
+        "from_signed_1" >>boxer
         "to_fixnum" >>unboxer
     \ char define-primitive-type
 
@@ -443,7 +461,8 @@ SYMBOLS:
         [ set-alien-unsigned-1 ] >>setter
         1 >>size
         1 >>align
-        "box_unsigned_1" >>boxer
+        1 >>align-first
+        "from_unsigned_1" >>boxer
         "to_cell" >>unboxer
     \ uchar define-primitive-type
 
@@ -453,7 +472,8 @@ SYMBOLS:
             [ [ >c-bool ] 2dip set-alien-unsigned-4 ] >>setter
             4 >>size
             4 >>align
-            "box_boolean" >>boxer
+            4 >>align-first
+            "from_boolean" >>boxer
             "to_boolean" >>unboxer
     ] [
         <c-type>
@@ -461,10 +481,11 @@ SYMBOLS:
             [ [ >c-bool ] 2dip set-alien-unsigned-1 ] >>setter
             1 >>size
             1 >>align
-            "box_boolean" >>boxer
+            1 >>align-first
+            "from_boolean" >>boxer
             "to_boolean" >>unboxer
-        \ bool define-primitive-type
     ] if
+    \ bool define-primitive-type
 
     <c-type>
         math:float >>class
@@ -473,7 +494,8 @@ SYMBOLS:
         [ [ >float ] 2dip set-alien-float ] >>setter
         4 >>size
         4 >>align
-        "box_float" >>boxer
+        4 >>align-first
+        "from_float" >>boxer
         "to_float" >>unboxer
         float-rep >>rep
         [ >float ] >>unboxer-quot
@@ -485,8 +507,8 @@ SYMBOLS:
         [ alien-double ] >>getter
         [ [ >float ] 2dip set-alien-double ] >>setter
         8 >>size
-        cpu x86.32? os windows? not and 4 8 ? >>align
-        "box_double" >>boxer
+        8-byte-alignment
+        "from_double" >>boxer
         "to_double" >>unboxer
         double-rep >>rep
         [ >float ] >>unboxer-quot
@@ -516,6 +538,9 @@ M: ulonglong-2-rep rep-component-type drop ulonglong ;
 M: float-4-rep rep-component-type drop float ;
 M: double-2-rep rep-component-type drop double ;
 
+: rep-length ( rep -- n )
+    16 swap rep-component-type heap-size /i ; foldable
+
 : (unsigned-interval) ( bytes -- from to ) [ 0 ] dip 8 * 2^ 1 - ; foldable
 : unsigned-interval ( c-type -- from to ) heap-size (unsigned-interval) ; foldable
 : (signed-interval) ( bytes -- from to ) 8 * 1 - 2^ [ neg ] [ 1 - ] bi ; foldable
@@ -528,4 +553,6 @@ M: double-2-rep rep-component-type drop double ;
         { [ dup { uchar ushort uint ulong ulonglong } member-eq? ] [ unsigned-interval ] }
     } cond ; foldable
 
-: c-type-clamp ( value c-type -- value' ) c-type-interval clamp ; inline
+: c-type-clamp ( value c-type -- value' )
+    dup { float double } member-eq?
+    [ drop ] [ c-type-interval clamp ] if ; inline
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 6a5644cceb5f675f77875e4b094d5cb308924611..ae694bed9c4b8da031dc212c9e187df1d92e97ca 100644 (file)
@@ -19,8 +19,8 @@ IN: alien.remote-control
     dup optimized? [ execute ] [ drop f ] if ; inline
 
 : init-remote-control ( -- )
-    \ eval-callback ?callback 16 setenv
-    \ yield-callback ?callback 17 setenv
-    \ sleep-callback ?callback 18 setenv ;
+    \ eval-callback ?callback 16 set-special-object
+    \ yield-callback ?callback 17 set-special-object
+    \ sleep-callback ?callback 18 set-special-object ;
 
 MAIN: init-remote-control
index eb2c9193a374b35e61a33a2f510f4c2582eaf04e..1a0648cef8b92f2037438ddc2686e24617e3ade3 100644 (file)
@@ -13,7 +13,8 @@ ERROR: malformed-base64 ;
     read1 2dup swap member? [ drop read1-ignoring ] [ nip ] if ;
 
 : read-ignoring ( ignoring n -- str )
-    [ drop read1-ignoring ] with map harvest
+    [ drop read1-ignoring ] with { } map-integers
+    [ { f 0 } member? not ] filter
     [ f ] [ >string ] if-empty ;
 
 : ch>base64 ( ch -- ch )
@@ -42,7 +43,7 @@ SYMBOL: column
     [ write1-lines ] each ;
 
 : encode3 ( seq -- )
-    be> 4 <reversed> [
+    be> 4 iota <reversed> [
         -6 * shift HEX: 3f bitand ch>base64 write1-lines
     ] with each ; inline
 
index f2ea7503f4851f8a8ac6bdb371a21237053d03ce..a797219a01466894624323ce5832c0965f4cec64 100644 (file)
@@ -1,4 +1,4 @@
-USING: binary-search math.order vectors kernel tools.test ;
+USING: binary-search math.order sequences kernel tools.test ;
 IN: binary-search.tests
 
 [ f ] [ 3 { } [ <=> ] with search drop ] unit-test
@@ -7,7 +7,7 @@ IN: binary-search.tests
 [ 3 ] [ 4 { 1 2 3 4 5 6 } [ <=> ] with search drop ] unit-test
 [ 2 ] [ 3.5 { 1 2 3 4 5 6 7 8 } [ <=> ] with search drop ] unit-test
 [ 4 ] [ 5.5 { 1 2 3 4 5 6 7 8 } [ <=> ] with search drop ] unit-test
-[ 10 ] [ 10 20 >vector [ <=> ] with search drop ] unit-test
+[ 10 ] [ 10 20 iota [ <=> ] with search drop ] unit-test
 
 [ t ] [ "hello" { "alligator" "cat" "fish" "hello" "ikarus" "java" } sorted-member? ] unit-test
 [ 3 ] [ "hey" { "alligator" "cat" "fish" "hello" "ikarus" "java" } sorted-index ] unit-test
index 7397791ab5b1b05058058d87fade66942c1ccb6d..f08db68441c9484a7f17c2f3c9752abdf42719c2 100644 (file)
@@ -40,7 +40,7 @@ IN: bit-arrays.tests
     100 [
         drop 100 [ 2 random zero? ] replicate
         dup >bit-array >array =
-    ] all?
+    ] all-integers?
 ] unit-test
 
 [ ?{ f } ] [
index f5613da6b552126b3edf31b7e494179c0246a9c0..4fafc528fdcb7728633915184f4ec5e97f23cdb8 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2007, 2008 Slava Pestov.
+! Copyright (C) 2007, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: alien.c-types alien.data accessors math alien.accessors kernel
 kernel.private sequences sequences.private byte-arrays
@@ -25,7 +25,7 @@ TUPLE: bit-array
 
 : (set-bits) ( bit-array n -- )
     [ [ length bits>cells ] keep ] dip swap underlying>>
-    '[ 2 shift [ _ _ ] dip set-alien-unsigned-4 ] each ; inline
+    '[ 2 shift [ _ _ ] dip set-alien-unsigned-4 ] each-integer ; inline
 
 : clean-up ( bit-array -- )
     ! Zero bits after the end.
@@ -99,7 +99,7 @@ SYNTAX: ?{ \ } [ >bit-array ] parse-literal ;
     ] if ;
 
 : bit-array>integer ( bit-array -- n )
-    0 swap underlying>> dup length <reversed> [
+    0 swap underlying>> dup length iota <reversed> [
         alien-unsigned-1 swap 8 shift bitor
     ] with each ;
 
index 5af44b59f7f30577e24a753a74c4565fe1f03689..a8a856ffd00476e73a9bef035886d965cfa0fd92 100644 (file)
@@ -4,7 +4,7 @@ IN: bit-vectors.tests
 [ 0 ] [ 123 <bit-vector> length ] unit-test\r
 \r
 : do-it ( seq -- )\r
-    1234 swap [ [ even? ] dip push ] curry each ;\r
+    1234 swap [ [ even? ] dip push ] curry each-integer ;\r
 \r
 [ t ] [\r
     3 <bit-vector> dup do-it\r
index 01eb002e447df51288fad9e384028dcd3548aaf6..7cae86b18672d4018ac209f203c45dca331900e7 100644 (file)
@@ -2,7 +2,8 @@ USING: continuations kernel io debugger vocabs words system namespaces ;
 
 :c
 :error
+
 "listener" vocab
 [ restarts. vocab-main execute ]
-[ die ] if*
+[ error get die ] if*
 1 exit
old mode 100755 (executable)
new mode 100644 (file)
index 3b78482..2d0613a
@@ -76,7 +76,7 @@ gc
     "." write flush
 
     {
-        + 2/ < <= > >= shift
+        + 2/ < <= > >= shift
     } compile-unoptimized
 
     "." write flush
index ab08aa87a9b02fa170d8cebe5f386a7cbaff74bd..70ccaedad422a1110da717d6f8fa91196527c66a 100644 (file)
@@ -3,7 +3,7 @@ namespaces eval kernel vocabs.loader io ;
 
 [
     boot
-    do-init-hooks
+    do-startup-hooks
     [
         (command-line) parse-command-line
         load-vocab-roots
@@ -14,4 +14,4 @@ namespaces eval kernel vocabs.loader io ;
         output-stream get [ stream-flush ] when*
         0 exit
     ] [ print-error 1 exit ] recover
-] set-boot-quot
+] set-startup-quot
index 49f504fd41441d34f148171aefb5c9f3a43f70b4..4512d84053246094415e10c77de2463ded519df6 100644 (file)
@@ -1,11 +1,10 @@
-USING: init command-line system namespaces kernel vocabs.loader
-io ;
+USING: init command-line system namespaces kernel vocabs.loader io ;
 
 [
     boot
-    do-init-hooks
+    do-startup-hooks
     (command-line) parse-command-line
     "run" get run
     output-stream get [ stream-flush ] when*
     0 exit
-] set-boot-quot
+] set-startup-quot
index 2178b5d4cb45653fc92ba9d29b0cfc252ed88278..90b4c3ae6f35ebe22e6d1eab562bf23f4fb3e844 100644 (file)
@@ -1,6 +1,6 @@
-! Copyright (C) 2004, 2009 Slava Pestov.
+! Copyright (C) 2004, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: alien arrays byte-arrays generic hashtables
+USING: alien alien.strings arrays byte-arrays generic hashtables
 hashtables.private io io.binary io.files io.encodings.binary
 io.pathnames kernel kernel.private math namespaces make parser
 prettyprint sequences strings sbufs vectors words quotations
@@ -10,7 +10,7 @@ vocabs.loader source-files definitions debugger
 quotations.private combinators combinators.short-circuit
 math.order math.private accessors slots.private
 generic.single.private compiler.units compiler.constants fry
-bootstrap.image.syntax ;
+locals bootstrap.image.syntax generalizations ;
 IN: bootstrap.image
 
 : arch ( os cpu -- arch )
@@ -71,6 +71,9 @@ C: <eq-wrapper> eq-wrapper
 M: eq-wrapper equal?
     over eq-wrapper? [ [ obj>> ] bi@ eq? ] [ 2drop f ] if ;
 
+M: eq-wrapper hashcode*
+    nip obj>> identity-hashcode ;
+
 SYMBOL: objects
 
 : cache-eql-object ( obj quot -- value )
@@ -90,7 +93,7 @@ CONSTANT: image-version 4
 
 CONSTANT: data-base 1024
 
-CONSTANT: userenv-size 70
+CONSTANT: special-objects-size 70
 
 CONSTANT: header-size 10
 
@@ -104,31 +107,62 @@ SYMBOL: sub-primitives
 
 SYMBOL: jit-relocations
 
-: compute-offset ( rc -- offset )
-    [ building get length ] dip rc-absolute-cell = bootstrap-cell 4 ? - ;
+SYMBOL: jit-offset
+
+: compute-offset ( -- offset )
+    building get length jit-offset get + ;
 
 : jit-rel ( rc rt -- )
-    over compute-offset 3array jit-relocations get push-all ;
+    compute-offset 3array jit-relocations get push-all ;
+
+SYMBOL: jit-parameters
+
+: jit-parameter ( parameter -- )
+    jit-parameters get push ;
 
 SYMBOL: jit-literals
 
 : jit-literal ( literal -- )
     jit-literals get push ;
 
-: make-jit ( quot -- jit-literals jit-data )
+: jit-vm ( offset rc -- )
+    [ jit-parameter ] dip rt-vm jit-rel ;
+
+: jit-dlsym ( name library rc -- )
+    rt-dlsym jit-rel [ string>symbol jit-parameter ] bi@ ;
+
+:: jit-conditional ( test-quot false-quot -- )
+    [ 0 test-quot call ] B{ } make length :> len
+    building get length jit-offset get + len +
+    [ jit-offset set false-quot call ] B{ } make
+    [ length test-quot call ] [ % ] bi ; inline
+
+: make-jit ( quot -- jit-parameters jit-literals jit-code )
     [
+        0 jit-offset set
+        V{ } clone jit-parameters set
         V{ } clone jit-literals set
         V{ } clone jit-relocations set
         call( -- )
+        jit-parameters get >array
         jit-literals get >array
         jit-relocations get >array
     ] B{ } make prefix ;
 
 : jit-define ( quot name -- )
-    [ make-jit nip ] dip set ;
+    [ make-jit 2nip ] dip set ;
 
 : define-sub-primitive ( quot word -- )
-    [ make-jit 2array ] dip sub-primitives get set-at ;
+    [ make-jit 3array ] dip sub-primitives get set-at ;
+
+: define-combinator-primitive ( quot non-tail-quot tail-quot word -- )
+    [
+        [ make-jit ]
+        [ make-jit 2nip ]
+        [ make-jit 2nip ]
+        tri* 5 narray
+    ] dip
+    sub-primitives get set-at ;
 
 ! The image being constructed; a vector of word-size integers
 SYMBOL: image
@@ -142,57 +176,58 @@ SYMBOL: architecture
 RESET
 
 ! Boot quotation, set in stage1.factor
-USERENV: bootstrap-boot-quot 20
+SPECIAL-OBJECT: bootstrap-startup-quot 20
 
 ! Bootstrap global namesapce
-USERENV: bootstrap-global 21
+SPECIAL-OBJECT: bootstrap-global 21
 
 ! JIT parameters
-USERENV: jit-prolog 23
-USERENV: jit-primitive-word 24
-USERENV: jit-primitive 25
-USERENV: jit-word-jump 26
-USERENV: jit-word-call 27
-USERENV: jit-word-special 28
-USERENV: jit-if-word 29
-USERENV: jit-if 30
-USERENV: jit-epilog 31
-USERENV: jit-return 32
-USERENV: jit-profiling 33
-USERENV: jit-push-immediate 34
-USERENV: jit-dip-word 35
-USERENV: jit-dip 36
-USERENV: jit-2dip-word 37
-USERENV: jit-2dip 38
-USERENV: jit-3dip-word 39
-USERENV: jit-3dip 40
-USERENV: jit-execute-word 41
-USERENV: jit-execute-jump 42
-USERENV: jit-execute-call 43
-USERENV: jit-declare-word 44
-
-USERENV: callback-stub 45
+SPECIAL-OBJECT: jit-prolog 23
+SPECIAL-OBJECT: jit-primitive-word 24
+SPECIAL-OBJECT: jit-primitive 25
+SPECIAL-OBJECT: jit-word-jump 26
+SPECIAL-OBJECT: jit-word-call 27
+SPECIAL-OBJECT: jit-if-word 28
+SPECIAL-OBJECT: jit-if 29
+SPECIAL-OBJECT: jit-epilog 30
+SPECIAL-OBJECT: jit-return 31
+SPECIAL-OBJECT: jit-profiling 32
+SPECIAL-OBJECT: jit-push 33
+SPECIAL-OBJECT: jit-dip-word 34
+SPECIAL-OBJECT: jit-dip 35
+SPECIAL-OBJECT: jit-2dip-word 36
+SPECIAL-OBJECT: jit-2dip 37
+SPECIAL-OBJECT: jit-3dip-word 38
+SPECIAL-OBJECT: jit-3dip 39
+SPECIAL-OBJECT: jit-execute 40
+SPECIAL-OBJECT: jit-declare-word 41
+
+SPECIAL-OBJECT: c-to-factor-word 42
+SPECIAL-OBJECT: lazy-jit-compile-word 43
+SPECIAL-OBJECT: unwind-native-frames-word 44
+
+SPECIAL-OBJECT: callback-stub 48
 
 ! PIC stubs
-USERENV: pic-load 47
-USERENV: pic-tag 48
-USERENV: pic-tuple 49
-USERENV: pic-check-tag 50
-USERENV: pic-check-tuple 51
-USERENV: pic-hit 52
-USERENV: pic-miss-word 53
-USERENV: pic-miss-tail-word 54
+SPECIAL-OBJECT: pic-load 49
+SPECIAL-OBJECT: pic-tag 50
+SPECIAL-OBJECT: pic-tuple 51
+SPECIAL-OBJECT: pic-check-tag 52
+SPECIAL-OBJECT: pic-check-tuple 53
+SPECIAL-OBJECT: pic-hit 54
+SPECIAL-OBJECT: pic-miss-word 55
+SPECIAL-OBJECT: pic-miss-tail-word 56
 
 ! Megamorphic dispatch
-USERENV: mega-lookup 57
-USERENV: mega-lookup-word 58
-USERENV: mega-miss-word 59
+SPECIAL-OBJECT: mega-lookup 57
+SPECIAL-OBJECT: mega-lookup-word 58
+SPECIAL-OBJECT: mega-miss-word 59
 
 ! Default definition for undefined words
-USERENV: undefined-quot 60
+SPECIAL-OBJECT: undefined-quot 60
 
-: userenv-offset ( symbol -- n )
-    userenvs get at header-size + ;
+: special-object-offset ( symbol -- n )
+    special-objects get at header-size + ;
 
 : emit ( cell -- ) image get push ;
 
@@ -208,7 +243,7 @@ USERENV: undefined-quot 60
 : fixup ( value offset -- ) image get set-nth ;
 
 : heap-size ( -- size )
-    image get length header-size - userenv-size -
+    image get length header-size - special-objects-size -
     bootstrap-cells ;
 
 : here ( -- size ) heap-size data-base + ;
@@ -224,9 +259,11 @@ USERENV: undefined-quot 60
 
 : emit-fixnum ( n -- ) tag-fixnum emit ;
 
+: emit-header ( n -- ) tag-header emit ;
+
 : emit-object ( class quot -- addr )
     [ type-number ] dip over here-as
-    [ swap tag-fixnum emit call align-here ] dip ;
+    [ swap emit-header call align-here ] dip ;
     inline
 
 ! Write an object to the image.
@@ -234,7 +271,7 @@ GENERIC: ' ( obj -- ptr )
 
 ! Image header
 
-: emit-header ( -- )
+: emit-image-header ( -- )
     image-magic emit
     image-version emit
     data-base emit ! relocation base at end of header
@@ -245,10 +282,10 @@ GENERIC: ' ( obj -- ptr )
     0 emit ! pointer to bignum 0
     0 emit ! pointer to bignum 1
     0 emit ! pointer to bignum -1
-    userenv-size [ f ' emit ] times ;
+    special-objects-size [ f ' emit ] times ;
 
-: emit-userenv ( symbol -- )
-    [ get ' ] [ userenv-offset ] bi fixup ;
+: emit-special-object ( symbol -- )
+    [ get ' ] [ special-object-offset ] bi fixup ;
 
 ! Bignums
 
@@ -501,16 +538,18 @@ M: quotation '
     \ dip jit-dip-word set
     \ 2dip jit-2dip-word set
     \ 3dip jit-3dip-word set
-    \ (execute) jit-execute-word set
-    \ inline-cache-miss \ pic-miss-word set
-    \ inline-cache-miss-tail \ pic-miss-tail-word set
-    \ mega-cache-lookup \ mega-lookup-word set
-    \ mega-cache-miss \ mega-miss-word set
+    \ inline-cache-miss pic-miss-word set
+    \ inline-cache-miss-tail pic-miss-tail-word set
+    \ mega-cache-lookup mega-lookup-word set
+    \ mega-cache-miss mega-miss-word set
     \ declare jit-declare-word set
+    \ c-to-factor c-to-factor-word set
+    \ lazy-jit-compile lazy-jit-compile-word set
+    \ unwind-native-frames unwind-native-frames-word set
     [ undefined ] undefined-quot set ;
 
-: emit-userenvs ( -- )
-    userenvs get keys [ emit-userenv ] each ;
+: emit-special-objects ( -- )
+    special-objects get keys [ emit-special-object ] each ;
 
 : fixup-header ( -- )
     heap-size data-heap-size-offset fixup ;
@@ -518,7 +557,7 @@ M: quotation '
 : build-image ( -- image )
     800000 <vector> image set
     20000 <hashtable> objects set
-    emit-header t, 0, 1, -1,
+    emit-image-header t, 0, 1, -1,
     "Building generic words..." print flush
     remake-generics
     "Serializing words..." print flush
@@ -527,8 +566,8 @@ M: quotation '
     emit-jit-data
     "Serializing global namespace..." print flush
     emit-global
-    "Serializing user environment..." print flush
-    emit-userenvs
+    "Serializing special object table..." print flush
+    emit-special-objects
     "Performing word fixups..." print flush
     fixup-words
     "Performing header fixups..." print flush
index 29dc09717a605a8ed023933e68b15c235fa6fa44..7025cd61e14bbaf491b768ab88bb95395760d5a8 100644 (file)
@@ -1,14 +1,14 @@
-! Copyright (C) 2009 Slava Pestov.
+! Copyright (C) 2009, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: parser kernel namespaces assocs words.symbol ;
 IN: bootstrap.image.syntax
 
-SYMBOL: userenvs
+SYMBOL: special-objects
 
-SYNTAX: RESET H{ } clone userenvs set-global ;
+SYNTAX: RESET H{ } clone special-objects set-global ;
 
-SYNTAX: USERENV:
+SYNTAX: SPECIAL-OBJECT:
     CREATE-WORD scan-word
-    [ swap userenvs get set-at ]
+    [ swap special-objects get set-at ]
     [ drop define-symbol ]
     2bi ;
\ No newline at end of file
index 0b517c0e66f649fd0c4d1228d2d422fa52390b26..98b6a472edc0e0ad49b44076e790379c67d11a7c 100644 (file)
@@ -35,8 +35,8 @@ SYMBOL: bootstrap-time
 : count-words ( pred -- )
     all-words swap count number>string write ; inline
 
-: print-time ( ms -- )
-    1000 /i
+: print-time ( us -- )
+    1,000,000,000 /i
     60 /mod swap
     number>string write
     " minutes and " write number>string write " seconds." print ;
@@ -56,9 +56,10 @@ SYMBOL: bootstrap-time
     error-continuation set-global
     error set-global ; inline
 
+
 [
     ! We time bootstrap
-    millis
+    nano-count
 
     default-image-name "output-image" set-global
 
@@ -83,14 +84,14 @@ SYMBOL: bootstrap-time
 
     load-components
 
-    millis over - core-bootstrap-time set-global
+    nano-count over - core-bootstrap-time set-global
 
     run-bootstrap-init
 
     f error set-global
     f error-continuation set-global
 
-    millis swap - bootstrap-time set-global
+    nano-count swap - bootstrap-time set-global
     print-report
 
     "deploy-vocab" get [
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 074798a..38398ae
@@ -16,7 +16,7 @@ ERROR: cairo-error message ;
 
 : check-surface ( surface -- ) cairo_surface_status (check-cairo) ;
 
-: width>stride ( width -- stride ) "uint" heap-size * ; inline
+: width>stride ( width -- stride ) uint heap-size * ; inline
 
 : <image-surface> ( data dim -- surface )
     [ CAIRO_FORMAT_ARGB32 ] dip first2 over width>stride
index 8cb1e751b26fde2202ad6c3967f847cfd6a77e8d..616c4d2c2c77873f2ea8b0968972ebd91ffd5c4a 100644 (file)
@@ -32,7 +32,7 @@ HELP: month-names
 { $warning "Do not use this array for looking up a month name directly. Use month-name instead." } ;
 
 HELP: month-name
-{ $values { "n" integer } { "string" string } }
+{ $values { "obj" { $or integer timestamp } } { "string" string } }
 { $description "Looks up the month name and returns it as a string.  January has an index of 1 instead of zero." } ;
 
 HELP: month-abbreviations
@@ -46,11 +46,11 @@ HELP: month-abbreviation
 
 
 HELP: day-names
-{ $values { "array" array } }
+{ $values { "value" array } }
 { $description "Returns an array with the English names of the days of the week." } ;
 
 HELP: day-name
-{ $values { "n" integer } { "string" string } }
+{ $values { "obj" { $or integer timestamp } } { "string" string } }
 { $description "Looks up the day name and returns it as a string." } ;
 
 HELP: day-abbreviations2
@@ -355,7 +355,7 @@ HELP: before
 
 HELP: <zero>
 { $values { "timestamp" timestamp } }
-{ $description "Outputs a zero timestamp that consists of zeros for every slot.  Used to see if timestamps are valid." } ;
+{ $description "Returns a zero timestamp that consists of zeros for every slot.  Used to see if timestamps are valid." } ;
 
 HELP: valid-timestamp?
 { $values { "timestamp" timestamp } { "?" "a boolean" } }
@@ -363,7 +363,7 @@ HELP: valid-timestamp?
 
 HELP: unix-1970
 { $values { "timestamp" timestamp } }
-{ $description "Outputs the beginning of UNIX time, or midnight, January 1, 1970." } ;
+{ $description "Returns the beginning of UNIX time, or midnight, January 1, 1970." } ;
 
 HELP: micros>timestamp
 { $values { "x" number } { "timestamp" timestamp } }
@@ -377,13 +377,13 @@ HELP: micros>timestamp
 
 HELP: gmt
 { $values { "timestamp" timestamp } }
-{ $description "Outputs the time right now, but in the GMT timezone." } ;
+{ $description "Returns the time right now, but in the GMT timezone." } ;
 
 { gmt now } related-words
 
 HELP: now
 { $values { "timestamp" timestamp } }
-{ $description "Outputs the time right now in your computer's timezone." }
+{ $description "Returns the time right now in your computer's timezone." }
 { $examples
     { $unchecked-example "USING: calendar prettyprint ;"
         "now ."
@@ -490,23 +490,23 @@ HELP: saturday
 
 HELP: midnight
 { $values { "timestamp" timestamp } { "new-timestamp" timestamp } }
-{ $description "Returns a timestamp that represents today at midnight, or the beginning of the day." } ;
+{ $description "Returns a new timestamp that represents today at midnight, or the beginning of the day." } ;
 
 HELP: noon
 { $values { "timestamp" timestamp } { "new-timestamp" timestamp } }
-{ $description "Returns a timestamp that represents today at noon, or the middle of the day." } ;
+{ $description "Returns a new timestamp that represents today at noon, or the middle of the day." } ;
 
 HELP: beginning-of-month
 { $values { "timestamp" timestamp } { "new-timestamp" timestamp } }
-{ $description "Outputs a timestamp with the day set to one." } ;
+{ $description "Returns a new timestamp with the day set to one." } ;
 
 HELP: beginning-of-week
 { $values { "timestamp" timestamp } { "new-timestamp" timestamp } }
-{ $description "Outputs a timestamp where the day of the week is Sunday." } ;
+{ $description "Returns a new timestamp where the day of the week is Sunday." } ;
 
 HELP: beginning-of-year
-{ $values { "timestamp" timestamp } { "new-timestamp" timestamp } }
-{ $description "Outputs a timestamp with the month and day set to one, or January 1 of the input timestamp." } ;
+{ $values { "object" object } { "new-timestamp" timestamp } }
+{ $description "Returns a new timestamp with the month and day set to one, or January 1 of the input timestamp, given a year or a timestamp." } ;
 
 HELP: time-since-midnight
 { $values { "timestamp" timestamp } { "duration" duration } }
index 8d1071122d98f5c58bb214097f785a460311a6cf..2490b87c374b0876dc6bf991d2b7ec232f305a31 100644 (file)
@@ -1,5 +1,6 @@
 USING: arrays calendar kernel math sequences tools.test
-continuations system math.order threads accessors ;
+continuations system math.order threads accessors
+random ;
 IN: calendar.tests
 
 [ f ] [ 2004 12 32 0   0  0 instant <timestamp> valid-timestamp? ] unit-test
@@ -139,7 +140,7 @@ IN: calendar.tests
 [ +gt+ ] [ 2005 1 1 12 30 0 instant <timestamp>
         2004 1 1 13 30 0 instant <timestamp> <=> ] unit-test
 
-[ t ] [ now timestamp>micros micros - 1000000 < ] unit-test
+[ t ] [ now timestamp>micros system-micros - 1000000 < ] unit-test
 [ t ] [ 0 micros>timestamp unix-1970 = ] unit-test
 [ t ] [ 123456789000000 [ micros>timestamp timestamp>micros ] keep = ] unit-test
 [ t ] [ 123456789123456000 [ micros>timestamp timestamp>micros ] keep = ] unit-test
@@ -170,3 +171,8 @@ IN: calendar.tests
 [ f ] [ now dup midnight eq? ] unit-test
 [ f ] [ now dup easter eq? ] unit-test
 [ f ] [ now dup beginning-of-year eq? ] unit-test
+
+[ t ] [ 1325376000 unix-time>timestamp 2012 <year-gmt> = ] unit-test
+[ t ] [ 1356998399 unix-time>timestamp 2013 <year-gmt> 1 seconds time- = ] unit-test
+
+[ t ] [ 1500000000 random [ unix-time>timestamp timestamp>unix-time ] keep = ] unit-test
index 0378e2701ee16e2a61c58576e13bf4ec3f4222ef..3940af48563a87bbfebb3eb1cc2f1174289a051a 100644 (file)
@@ -17,6 +17,8 @@ TUPLE: duration
 
 C: <duration> duration
 
+: instant ( -- duration ) 0 0 0 0 0 0 <duration> ;
+
 TUPLE: timestamp
     { year integer }
     { month integer }
@@ -34,6 +36,15 @@ C: <timestamp> timestamp
 : <date> ( year month day -- timestamp )
     0 0 0 gmt-offset-duration <timestamp> ;
 
+: <date-gmt> ( year month day -- timestamp )
+    0 0 0 instant <timestamp> ;
+
+: <year> ( year -- timestamp )
+    1 1 <date> ;
+
+: <year-gmt> ( year -- timestamp )
+    1 1 <date-gmt> ;
+
 ERROR: not-a-month ;
 M: not-a-month summary
     drop "Months are indexed starting at 1" ;
@@ -51,8 +62,16 @@ CONSTANT: month-names
         "July" "August" "September" "October" "November" "December"
     }
 
-: month-name ( n -- string )
-    check-month 1 - month-names nth ;
+<PRIVATE
+
+: (month-name) ( n -- string ) 1 - month-names nth ;
+
+PRIVATE>
+
+GENERIC: month-name ( obj -- string )
+
+M: integer month-name check-month 1 - month-names nth ;
+M: timestamp month-name month>> 1 - month-names nth ;
 
 CONSTANT: month-abbreviations
     {
@@ -65,12 +84,8 @@ CONSTANT: month-abbreviations
 
 CONSTANT: day-counts { 0 31 28 31 30 31 30 31 31 30 31 30 31 }
 
-: day-names ( -- array )
-    {
-        "Sunday" "Monday" "Tuesday" "Wednesday" "Thursday" "Friday" "Saturday"
-    } ;
-
-: day-name ( n -- string ) day-names nth ;
+CONSTANT: day-names
+    { "Sunday" "Monday" "Tuesday" "Wednesday" "Thursday" "Friday" "Saturday" }
 
 CONSTANT: day-abbreviations2
     { "Su" "Mo" "Tu" "We" "Th" "Fr" "Sa" }
@@ -128,8 +143,7 @@ GENERIC: easter ( obj -- obj' )
     32 2 e * + 2 i * + h - k - 7 mod :> l
     a 11 h * + 22 l * + 451 /i :> m
 
-    h l + 7 m * - 114 + 31 /mod 1 + :> ( month day )
-    month day ;
+    h l + 7 m * - 114 + 31 /mod 1 + ;
 
 M: integer easter ( year -- timestamp )
     dup easter-month-day <date> ;
@@ -145,7 +159,6 @@ M: timestamp easter ( timestamp -- timestamp )
 : >time< ( timestamp -- hour minute second )
     [ hour>> ] [ minute>> ] [ second>> ] tri ;
 
-: instant ( -- duration ) 0 0 0 0 0 0 <duration> ;
 : years ( x -- duration ) instant clone swap >>year ;
 : months ( x -- duration ) instant clone swap >>month ;
 : days ( x -- duration ) instant clone swap >>day ;
@@ -157,6 +170,18 @@ M: timestamp easter ( timestamp -- timestamp )
 : microseconds ( x -- duration ) 1000000 / seconds ;
 : nanoseconds ( x -- duration ) 1000000000 / seconds ;
 
+GENERIC: year ( obj -- n )
+M: integer year ;
+M: timestamp year year>> ;
+
+GENERIC: month ( obj -- n )
+M: integer month ;
+M: timestamp month month>> ;
+
+GENERIC: day ( obj -- n )
+M: integer day ;
+M: timestamp day day>> ;
+
 GENERIC: leap-year? ( obj -- ? )
 
 M: integer leap-year? ( year -- ? )
@@ -305,6 +330,9 @@ GENERIC: time- ( time1 time2 -- time3 )
 M: timestamp <=> ( ts1 ts2 -- n )
     [ >gmt tuple-slots ] compare ;
 
+: same-day? ( ts1 ts2 -- ? )
+    [ >gmt >date< <date> ] bi@ = ;
+
 : (time-) ( timestamp timestamp -- n )
     [ >gmt ] bi@
     [ [ >date< julian-day-number ] bi@ - 86400 * ] 2keep
@@ -357,7 +385,7 @@ M: duration time-
 
 : gmt ( -- timestamp )
     #! GMT time, right now
-    unix-1970 micros microseconds time+ ;
+    unix-1970 system-micros microseconds time+ ;
 
 : now ( -- timestamp ) gmt >local-time ;
 : hence ( duration -- timestamp ) now swap time+ ;
@@ -387,6 +415,10 @@ M: timestamp days-in-year ( timestamp -- n ) year>> days-in-year ;
 : day-of-week ( timestamp -- n )
     >date< zeller-congruence ;
 
+GENERIC: day-name ( obj -- string )
+M: integer day-name day-names nth ;
+M: timestamp day-name day-of-week day-names nth ;
+
 :: (day-of-year) ( year month day -- n )
     day-counts month head-slice sum day +
     year leap-year? [
@@ -398,14 +430,75 @@ M: timestamp days-in-year ( timestamp -- n ) year>> days-in-year ;
 : day-of-year ( timestamp -- n )
     >date< (day-of-year) ;
 
+: midnight ( timestamp -- new-timestamp )
+    clone 0 >>hour 0 >>minute 0 >>second ; inline
+
+: noon ( timestamp -- new-timestamp )
+    midnight 12 >>hour ; inline
+
+: beginning-of-month ( timestamp -- new-timestamp )
+    midnight 1 >>day ;
+
+: end-of-month ( timestamp -- new-timestamp )
+    [ midnight ] [ days-in-month ] bi >>day ;
+
 <PRIVATE
-: day-offset ( timestamp m -- timestamp n )
+
+: day-offset ( timestamp m -- new-timestamp n )
     over day-of-week - ; inline
 
-: day-this-week ( timestamp n -- timestamp )
+: day-this-week ( timestamp n -- new-timestamp )
     day-offset days time+ ;
+
+:: nth-day-this-month ( timestamp n day -- new-timestamp )
+    timestamp beginning-of-month day day-this-week
+    dup timestamp [ month>> ] bi@ = [ 1 weeks time+ ] unless
+    n 1 - [ weeks time+ ] unless-zero ;
+
+: last-day-this-month ( timestamp day -- new-timestamp )
+    [ 1 months time+ 1 ] dip nth-day-this-month 1 weeks time- ;
+
 PRIVATE>
 
+GENERIC: january ( obj -- timestamp )
+GENERIC: february ( obj -- timestamp )
+GENERIC: march ( obj -- timestamp )
+GENERIC: april ( obj -- timestamp )
+GENERIC: may ( obj -- timestamp )
+GENERIC: june ( obj -- timestamp )
+GENERIC: july ( obj -- timestamp )
+GENERIC: august ( obj -- timestamp )
+GENERIC: september ( obj -- timestamp )
+GENERIC: october ( obj -- timestamp )
+GENERIC: november ( obj -- timestamp )
+GENERIC: december ( obj -- timestamp )
+
+M: integer january 1 1 <date> ;
+M: integer february 2 1 <date> ;
+M: integer march 3 1 <date> ;
+M: integer april 4 1 <date> ;
+M: integer may 5 1 <date> ;
+M: integer june 6 1 <date> ;
+M: integer july 7 1 <date> ;
+M: integer august 8 1 <date> ;
+M: integer september 9 1 <date> ;
+M: integer october 10 1 <date> ;
+M: integer november 11 1 <date> ;
+M: integer december 12 1 <date> ;
+
+M: timestamp january clone 1 >>month ;
+M: timestamp february clone 2 >>month ;
+M: timestamp march clone 3 >>month ;
+M: timestamp april clone 4 >>month ;
+M: timestamp may clone 5 >>month ;
+M: timestamp june clone 6 >>month ;
+M: timestamp july clone 7 >>month ;
+M: timestamp august clone 8 >>month ;
+M: timestamp september clone 9 >>month ;
+M: timestamp october clone 10 >>month ;
+M: timestamp november clone 11 >>month ;
+M: timestamp december clone 12 >>month ;
+
 : sunday ( timestamp -- new-timestamp ) 0 day-this-week ;
 : monday ( timestamp -- new-timestamp ) 1 day-this-week ;
 : tuesday ( timestamp -- new-timestamp ) 2 day-this-week ;
@@ -414,20 +507,40 @@ PRIVATE>
 : friday ( timestamp -- new-timestamp ) 5 day-this-week ;
 : saturday ( timestamp -- new-timestamp ) 6 day-this-week ;
 
-: midnight ( timestamp -- new-timestamp )
-    clone 0 >>hour 0 >>minute 0 >>second ; inline
-
-: noon ( timestamp -- new-timestamp )
-    midnight 12 >>hour ; inline
-
-: beginning-of-month ( timestamp -- new-timestamp )
-    midnight 1 >>day ;
+: sunday? ( timestamp -- ? ) day-of-week 0 = ;
+: monday? ( timestamp -- ? ) day-of-week 1 = ;
+: tuesday? ( timestamp -- ? ) day-of-week 2 = ;
+: wednesday? ( timestamp -- ? ) day-of-week 3 = ;
+: thursday? ( timestamp -- ? ) day-of-week 4 = ;
+: friday? ( timestamp -- ? ) day-of-week 5 = ;
+: saturday? ( timestamp -- ? ) day-of-week 6 = ;
+
+: sunday-of-month ( timestamp n -- new-timestamp ) 0 nth-day-this-month ;
+: monday-of-month ( timestamp n -- new-timestamp ) 1 nth-day-this-month ;
+: tuesday-of-month ( timestamp n -- new-timestamp ) 2 nth-day-this-month ;
+: wednesday-of-month ( timestamp n -- new-timestamp ) 3 nth-day-this-month ;
+: thursday-of-month ( timestamp n -- new-timestamp ) 4 nth-day-this-month ;
+: friday-of-month ( timestamp n -- new-timestamp ) 5 nth-day-this-month ;
+: saturday-of-month ( timestamp n -- new-timestamp ) 6 nth-day-this-month ;
+
+: last-sunday-of-month ( timestamp -- new-timestamp ) 0 last-day-this-month ;
+: last-monday-of-month ( timestamp -- new-timestamp ) 1 last-day-this-month ;
+: last-tuesday-of-month ( timestamp -- new-timestamp ) 2 last-day-this-month ;
+: last-wednesday-of-month ( timestamp -- new-timestamp ) 3 last-day-this-month ;
+: last-thursday-of-month ( timestamp -- new-timestamp ) 4 last-day-this-month ;
+: last-friday-of-month ( timestamp -- new-timestamp ) 5 last-day-this-month ;
+: last-saturday-of-month ( timestamp -- new-timestamp ) 6 last-day-this-month ;
 
 : beginning-of-week ( timestamp -- new-timestamp )
     midnight sunday ;
 
-: beginning-of-year ( timestamp -- new-timestamp )
-    beginning-of-month 1 >>month ;
+GENERIC: beginning-of-year ( object -- new-timestamp )
+M: timestamp beginning-of-year beginning-of-month 1 >>month ;
+M: integer beginning-of-year <year> ;
+
+GENERIC: end-of-year ( object -- new-timestamp )
+M: timestamp end-of-year 12 >>month 31 >>day ;
+M: integer end-of-year 12 31 <date> ;
 
 : time-since-midnight ( timestamp -- duration )
     dup midnight time- ;
@@ -435,9 +548,14 @@ PRIVATE>
 : since-1970 ( duration -- timestamp )
     unix-1970 time+ >local-time ;
 
-M: timestamp sleep-until timestamp>micros sleep-until ;
+: timestamp>unix-time ( timestamp -- seconds )
+    unix-1970 time- second>> ;
+
+: unix-time>timestamp ( seconds -- timestamp )
+    seconds unix-1970 time+ ;
 
-M: duration sleep hence sleep-until ;
+M: duration sleep
+    duration>nanoseconds >integer nano-count + sleep-until ;
 
 {
     { [ os unix? ] [ "calendar.unix" ] }
index d07d74722a71de9c45ad58b231d55b71acd54a3b..96d76d0ce86430c5e7b9badbd0502b7393f8aba8 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2008 Slava Pestov.\r
+! Copyright (C) 2008, 2010 Slava Pestov, Doug Coleman.\r
 ! See http://factorcode.org/license.txt for BSD license.\r
 USING: math math.order math.parser math.functions kernel\r
 sequences io accessors arrays io.streams.string splitting\r
@@ -70,7 +70,7 @@ M: array month. ( pair -- )
     [\r
         [ 1 + day. ] keep\r
         1 + + 7 mod zero? [ nl ] [ bl ] if\r
-    ] with each nl ;\r
+    ] with each-integer nl ;\r
 \r
 M: timestamp month. ( timestamp -- )\r
     [ year>> ] [ month>> ] bi 2array month. ;\r
@@ -78,7 +78,7 @@ M: timestamp month. ( timestamp -- )
 GENERIC: year. ( obj -- )\r
 \r
 M: integer year. ( n -- )\r
-    12 [ 1 + 2array month. nl ] with each ;\r
+    12 [ 1 + 2array month. nl ] with each-integer ;\r
 \r
 M: timestamp year. ( timestamp -- )\r
     year>> year. ;\r
index 8665cc22cefe67749a59f0dca7fbe8bd490a42a8..38ad986952c224800a29ca4e4b58ca1c4a94fb9e 100644 (file)
@@ -16,4 +16,4 @@ SYMBOL: time
     ] "Time model update" spawn drop ;\r
 \r
 f <model> time set-global\r
-[ time-thread ] "calendar.model" add-init-hook\r
+[ time-thread ] "calendar.model" add-startup-hook\r
index 28e54b89fb5d95fa01d1119d3a9fbdb2ab9cf28d..ac72385d8c75a33d8ce55270a7cfcaf4b17eaa40 100644 (file)
@@ -14,6 +14,9 @@ IN: calendar.unix
 : timespec>seconds ( timespec -- seconds )
     [ sec>> seconds ] [ nsec>> nanoseconds ] bi time+ ;
 
+: timespec>nanoseconds ( timespec -- seconds )
+    [ sec>> 1000000000 * ] [ nsec>> ] bi + ;
+
 : timespec>unix-time ( timespec -- timestamp )
     timespec>seconds since-1970 ;
 
index 0a8887554491c777078ad001552996d3f62bd66b..4eab29fd81f15322cf6f5283c9663dfb5d4cb6ef 100644 (file)
@@ -69,4 +69,4 @@ M: remote-channel from ( remote-channel -- value )
 [
     H{ } clone \ remote-channels set-global
     start-channel-node
-] "channel-registry" add-init-hook
+] "channel-registry" add-startup-hook
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 35262bb0b0fb718103d9b3ef39138a598f86effd..ba85add03c63727406fb6d650b5f745b2b911e68 100644 (file)
@@ -301,7 +301,7 @@ GENERIC: pad-initial-bytes ( string sha2 -- padded-string )
         M cloned-H sha2 T1-256
         cloned-H T2-256
         cloned-H update-H
-    ] each
+    ] each-integer
     sha2 [ cloned-H [ w+ ] 2map ] change-H drop ; inline
 
 M: sha2-short checksum-block
@@ -391,7 +391,7 @@ M: sha-256 checksum-stream ( stream checksum -- byte-array )
         b H nth-unsafe 30 bitroll-32 c H set-nth-unsafe
         a H nth-unsafe b H set-nth-unsafe
         a H set-nth-unsafe
-    ] each
+    ] each-integer
     state [ H [ w+ ] 2map ] change-H drop ; inline
 
 M:: sha1-state checksum-block ( bytes state -- )
index 8abadfadd2230f54f41bb8921f50d0fbbe70de96..93d137d626d3b377a5a734652029d14a815264ae 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2008 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: help.markup help.syntax io.streams.string sequences
-math kernel ;
+math kernel quotations ;
 IN: circular
 
 HELP: <circular-string>
@@ -33,12 +33,12 @@ HELP: circular
 HELP: growing-circular
 { $description "A circular sequence that is growable." } ;
 
-HELP: push-circular
+HELP: circular-push
 { $values
      { "elt" object } { "circular" circular } }
 { $description "Pushes an element to a " { $link circular } " object." } ;
 
-HELP: push-growing-circular
+HELP: growing-circular-push
 { $values
      { "elt" object } { "circular" circular } }
 { $description "Pushes an element onto a " { $link growing-circular } " object." } ;
@@ -48,6 +48,13 @@ HELP: rotate-circular
     { "circular" circular } }
 { $description "Advances the start index of a circular object by one." } ;
 
+HELP: circular-while
+{ $values
+    { "circular" circular }
+    { "quot" quotation }
+}
+{ $description "Calls " { $snippet "quot" } " on each element of the sequence until each call yields " { $link f } " in succession." } ;
+
 ARTICLE: "circular" "Circular sequences"
 "The " { $vocab-link "circular" } " vocabulary implements the " { $link "sequence-protocol" } " to allow an arbitrary start index and wrap-around indexing." $nl
 "Creating a new circular object:"
@@ -63,8 +70,10 @@ ARTICLE: "circular" "Circular sequences"
 }
 "Pushing new elements:"
 { $subsections
-    push-circular
-    push-growing-circular
-} ;
+    circular-push
+    growing-circular-push
+}
+"Iterating over a circular until a stop condition:"
+{ $subsections circular-while } ;
 
 ABOUT: "circular"
index c3c4860f953a3e51b1f219f811ec4c015f561374..cda26df1d3f54e9e31444a1761b3ce94a6005adb 100644 (file)
@@ -23,7 +23,7 @@ IN: circular.tests
 [ "boo" ] [ "foo" <circular> CHAR: b 3 pick set-nth-unsafe >string ] unit-test
 [ "ornact" ] [ "factor" <circular> 4 over change-circular-start CHAR: n 2 pick set-nth >string ] unit-test
 
-[ "bcd" ] [ 3 <circular-string> "abcd" [ over push-circular ] each >string ] unit-test
+[ "bcd" ] [ 3 <circular-string> "abcd" [ over circular-push ] each >string ] unit-test
 
 [ { 0 0 } ] [ { 0 0 } <circular> -1 over change-circular-start >array ] unit-test
 
@@ -34,11 +34,11 @@ IN: circular.tests
 [ { } ] [ 3 <growing-circular> >array ] unit-test
 [ { 1 2 } ] [
     3 <growing-circular>
-    [ 1 swap push-growing-circular ] keep
-    [ 2 swap push-growing-circular ] keep >array
+    [ 1 swap growing-circular-push ] keep
+    [ 2 swap growing-circular-push ] keep >array
 ] unit-test
 [ { 3 4 5 } ] [
     3 <growing-circular> dup { 1 2 3 4 5 } [
-        swap push-growing-circular
+        swap growing-circular-push
     ] with each >array
 ] unit-test
index b3be4651cd627799269edbefa72ac168f97718ba..ccb70c617f534f4af67498ae0c51adf91012ad04 100644 (file)
@@ -1,57 +1,79 @@
 ! Copyright (C) 2005, 2006 Alex Chapman, Daniel Ehrenberg
 ! See http;//factorcode.org/license.txt for BSD license
 USING: kernel sequences math sequences.private strings
-accessors ;
+accessors locals fry ;
 IN: circular
 
-! a circular sequence wraps another sequence, but begins at an
-! arbitrary element in the underlying sequence.
-TUPLE: circular seq start ;
+TUPLE: circular { seq read-only } { start integer } ;
 
 : <circular> ( seq -- circular )
-    0 circular boa ;
+    0 circular boa ; inline
 
 <PRIVATE
+
 : circular-wrap ( n circular -- n circular )
     [ start>> + ] keep
     [ seq>> length rem ] keep ; inline
+
 PRIVATE>
 
-M: circular length seq>> length ;
+M: circular length seq>> length ; inline
 
-M: circular virtual@ circular-wrap seq>> ;
+M: circular virtual@ circular-wrap seq>> ; inline
 
-M: circular virtual-seq seq>> ;
+M: circular virtual-exemplar seq>> ; inline
 
 : change-circular-start ( n circular -- )
     #! change start to (start + n) mod length
-    circular-wrap (>>start) ;
+    circular-wrap (>>start) ; inline
 
 : rotate-circular ( circular -- )
-    [ 1 ] dip change-circular-start ;
+    [ 1 ] dip change-circular-start ; inline
 
-: push-circular ( elt circular -- )
+: circular-push ( elt circular -- )
     [ set-first ] [ rotate-circular ] bi ;
 
 : <circular-string> ( n -- circular )
-    0 <string> <circular> ;
+    0 <string> <circular> ; inline
 
 INSTANCE: circular virtual-sequence
 
-TUPLE: growing-circular < circular length ;
+TUPLE: growing-circular < circular { length integer } ;
 
-M: growing-circular length length>> ;
+M: growing-circular length length>> ; inline
 
 <PRIVATE
 
 : full? ( circular -- ? )
-    [ length ] [ seq>> length ] bi = ;
+    [ length ] [ seq>> length ] bi = ; inline
 
 PRIVATE>
 
-: push-growing-circular ( elt circular -- )
-    dup full? [ push-circular ]
+: growing-circular-push ( elt circular -- )
+    dup full? [ circular-push ]
     [ [ 1 + ] change-length set-last ] if ;
 
 : <growing-circular> ( capacity -- growing-circular )
-    { } new-sequence 0 0 growing-circular boa ;
+    { } new-sequence 0 0 growing-circular boa ; inline
+
+TUPLE: circular-iterator
+    { circular read-only } { n integer } { last-start integer } ;
+
+: <circular-iterator> ( circular -- obj )
+    0 0 circular-iterator boa ; inline
+
+<PRIVATE
+
+: (circular-while) ( iterator quot: ( obj -- ? ) -- )
+    [ [ [ n>> ] [ circular>> ] bi nth ] dip call ] 2keep
+    rot [ [ dup n>> >>last-start ] dip ] when
+    over [ n>> ] [ [ last-start>> ] [ circular>> length ] bi + 1 - ] bi = [
+        2drop
+    ] [
+        [ [ 1 + ] change-n ] dip (circular-while)
+    ] if ; inline recursive
+
+PRIVATE>
+
+: circular-while ( circular quot: ( obj -- ? ) -- )
+    [ clone ] dip [ <circular-iterator> ] dip (circular-while) ; inline
index e2ff6dbd9c5c15e834f0bcb05f28f2c43fa22e01..ecf7b68a2d89fc25a048998299451679511823b5 100644 (file)
@@ -1,6 +1,7 @@
 ! Copyright (C) 2009 Daniel Ehrenberg
 ! See http://factorcode.org/license.txt for BSD license.
-USING: classes.struct.bit-accessors tools.test effects kernel random stack-checker ;
+USING: classes.struct.bit-accessors tools.test effects kernel
+sequences random stack-checker ;
 IN: classes.struct.bit-accessors.test
 
 [ t ] [ 20 random 20 random bit-reader infer (( alien -- n )) effect= ] unit-test
old mode 100755 (executable)
new mode 100644 (file)
index 58ab2df..2c0db93
@@ -365,3 +365,18 @@ STRUCT: bit-field-test
 [ -2 ] [ bit-field-test <struct> 2 >>b b>> ] unit-test
 [ 1 ] [ bit-field-test <struct> 257 >>c c>> ] unit-test
 [ 3 ] [ bit-field-test heap-size ] unit-test
+
+cpu ppc? [
+    STRUCT: ppc-align-test-1
+        { x longlong }
+        { y int } ;
+
+    [ 16 ] [ ppc-align-test-1 heap-size ] unit-test
+
+    STRUCT: ppc-align-test-2
+        { y int }
+        { x longlong } ;
+
+    [ 12 ] [ ppc-align-test-2 heap-size ] unit-test
+    [ 4 ] [ "x" ppc-align-test-2 offset-of ] unit-test
+] when
old mode 100755 (executable)
new mode 100644 (file)
index d5e5fdc..cdd47ca
@@ -189,9 +189,6 @@ M: struct-c-type c-struct? drop t ;
     \ cleave [ ] 2sequence
     \ output>array [ ] 2sequence ;
 
-: define-inline-method ( class generic quot -- )
-    [ create-method-in ] dip [ define ] [ drop make-inline ] 2bi ;
-
 : (define-struct-slot-values-method) ( class -- )
     [ \ struct-slot-values ] [ struct-slot-values-quot ] bi
     define-inline-method ;
@@ -211,27 +208,32 @@ M: struct-c-type c-struct? drop t ;
         slots >>fields
         size >>size
         align >>align
+        align >>align-first
         class (unboxer-quot) >>unboxer-quot
-        class (boxer-quot)   >>boxer-quot ;
-    
-GENERIC: align-offset ( offset class -- offset' )
+        class (boxer-quot) >>boxer-quot ;
+
+GENERIC: compute-slot-offset ( offset class -- offset' )
 
-M: struct-slot-spec align-offset
-    [ type>> c-type-align 8 * align ] keep
+: c-type-align-at ( class offset -- n )
+    0 = [ c-type-align-first ] [ c-type-align ] if ;
+
+M: struct-slot-spec compute-slot-offset
+    [ type>> over c-type-align-at 8 * align ] keep
     [ [ 8 /i ] dip (>>offset) ] [ type>> heap-size 8 * + ] 2bi ;
 
-M: struct-bit-slot-spec align-offset
+M: struct-bit-slot-spec compute-slot-offset
     [ (>>offset) ] [ bits>> + ] 2bi ;
 
-: struct-offsets ( slots -- size )
-    0 [ align-offset ] reduce 8 align 8 /i ;
+: compute-struct-offsets ( slots -- size )
+    0 [ compute-slot-offset ] reduce 8 align 8 /i ;
 
-: union-struct-offsets ( slots -- size )
+: compute-union-offsets ( slots -- size )
     1 [ 0 >>offset type>> heap-size max ] reduce ;
 
-: struct-align ( slots -- align )
+: struct-alignment ( slots -- align )
     [ struct-bit-slot-spec? not ] filter
-    1 [ type>> c-type-align max ] reduce ;
+    1 [ [ type>> ] [ offset>> ] bi c-type-align-at max ] reduce ;
+
 PRIVATE>
 
 M: struct byte-length class "struct-size" word-prop ; foldable
@@ -243,10 +245,8 @@ GENERIC: binary-zero? ( value -- ? )
 
 M: object binary-zero? drop f ;
 M: f binary-zero? drop t ;
-M: number binary-zero? zero? ;
-M: struct binary-zero?
-    [ byte-length iota ] [ >c-ptr ] bi
-    [ <displaced-alien> *uchar zero? ] curry all? ;
+M: number binary-zero? 0 = ;
+M: struct binary-zero? >c-ptr [ 0 = ] all? ;
 
 : struct-needs-prototype? ( class -- ? )
     struct-slots [ initial>> binary-zero? ] all? not ;
@@ -278,8 +278,9 @@ M: struct binary-zero?
     slots empty? [ struct-must-have-slots ] when
     class redefine-struct-tuple-class
     slots make-slots dup check-struct-slots :> slot-specs
-    slot-specs struct-align :> alignment
-    slot-specs offsets-quot call alignment align :> size
+    slot-specs offsets-quot call :> unaligned-size
+    slot-specs struct-alignment :> alignment
+    unaligned-size alignment align :> size
 
     class  slot-specs  size  alignment  c-type-for-class :> c-type
 
@@ -291,10 +292,10 @@ M: struct binary-zero?
 PRIVATE>
 
 : define-struct-class ( class slots -- )
-    [ struct-offsets ] (define-struct-class) ;
+    [ compute-struct-offsets ] (define-struct-class) ;
 
 : define-union-struct-class ( class slots -- )
-    [ union-struct-offsets ] (define-struct-class) ;
+    [ compute-union-offsets ] (define-struct-class) ;
 
 M: struct-class reset-class
     [ call-next-method ] [ name>> c-types get delete-at ] bi ;
index cbf8636a7537f4a3862b3d30c70a98010ee1690c..df56ce5c4c43568bf9cbdcd5226d64aac3a21156 100644 (file)
@@ -49,7 +49,7 @@ TUPLE: objc-error alien reason ;
 M: objc-error summary ( error -- )
     drop "Objective C exception" ;
 
-[ [ objc-error ] 19 setenv ] "cocoa.application" add-init-hook
+[ [ objc-error ] 19 set-special-object ] "cocoa.application" add-startup-hook
 
 : running.app? ( -- ? )
     #! Test if we're running a .app.
index ec09f8f2ba3108a017b52b017eae01f1c146544d..34bac0a5055229e13b7a738190f577359fd3ab7e 100644 (file)
@@ -27,7 +27,7 @@ SYMBOL: frameworks
 
 frameworks [ V{ } clone ] initialize
 
-[ frameworks get [ load-framework ] each ] "cocoa" add-init-hook
+[ frameworks get [ load-framework ] each ] "cocoa" add-startup-hook
 
 SYNTAX: FRAMEWORK: scan [ load-framework ] [ frameworks get push ] bi ;
 
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index fce7adc..02e6335
@@ -1,4 +1,4 @@
-! Copyright (C) 2006, 2009 Slava Pestov.
+! Copyright (C) 2006, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors alien alien.c-types alien.strings arrays assocs
 classes.struct continuations combinators compiler compiler.alien
@@ -76,13 +76,13 @@ MACRO: (send) ( selector super? -- quot )
 : super-send ( receiver args... selector -- return... ) t (send) ; inline
 
 ! Runtime introspection
-SYMBOL: class-init-hooks
+SYMBOL: class-startup-hooks
 
-class-init-hooks [ H{ } clone ] initialize
+class-startup-hooks [ H{ } clone ] initialize
 
 : (objc-class) ( name word -- class )
     2dup execute dup [ 2nip ] [
-        drop over class-init-hooks get at [ call( -- ) ] when*
+        drop over class-startup-hooks get at [ call( -- ) ] when*
         2dup execute dup [ 2nip ] [
             2drop "No such class: " prepend throw
         ] if
@@ -202,7 +202,7 @@ ERROR: no-objc-type name ;
     (free) ;
 
 : method-arg-types ( method -- args )
-    dup method_getNumberOfArguments
+    dup method_getNumberOfArguments iota
     [ method-arg-type ] with map ;
 
 : method-return-type ( method -- ctype )
@@ -229,7 +229,7 @@ ERROR: no-objc-type name ;
 : class-exists? ( string -- class ) objc_getClass >boolean ;
 
 : define-objc-class-word ( quot name -- )
-    [ class-init-hooks get set-at ]
+    [ class-startup-hooks get set-at ]
     [
         [ "cocoa.classes" create ] [ '[ _ objc-class ] ] bi
         (( -- class )) define-declared
index 434c2339368a24b1970dcd1a20e938f5df79e010..c0e0956709582c1421577dc4accf9af2488b62c5 100644 (file)
@@ -7,3 +7,5 @@ IN: columns.tests
 [ { 1 4 7 } ] [ "seq" get 0 <column> >array ] unit-test
 [ ] [ "seq" get 1 <column> [ sq ] map! drop ] unit-test
 [ { 4 25 64 } ] [ "seq" get 1 <column> >array ] unit-test
+
+[ { { 1 3 } { 2 4 } } ] [ { { 1 2 } { 3 4 } } <flipped> [ >array ] map ] unit-test
index 8f45dab8728c4e7ef153f94692dea47d0b2c36a1..c36505ab6d1d727f091ff83be941935005fd1c10 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2005, 2008 Slava Pestov, Daniel Ehrenberg.
+! Copyright (C) 2005, 2010 Slava Pestov, Daniel Ehrenberg.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: sequences kernel accessors ;
 IN: columns
@@ -8,11 +8,11 @@ TUPLE: column seq col ;
 
 C: <column> column
 
-M: column virtual-seq seq>> ;
+M: column virtual-exemplar seq>> ;
 M: column virtual@ [ col>> swap ] [ seq>> ] bi nth bounds-check ;
 M: column length seq>> length ;
 
 INSTANCE: column virtual-sequence
 
 : <flipped> ( seq -- seq' )
-    dup empty? [ dup first length [ <column> ] with map ] unless ;
+    dup empty? [ dup first length [ <column> ] with { } map-integers ] unless ;
index 399b4dc36fe35feaf226288c2944ea555094265c..bd224919f9e00c524e2a59f355f6797df286fde9 100644 (file)
@@ -47,3 +47,9 @@ IN: combinators.smart.tests
 [ { { 1 2 } { 3 4 } } ] [ nested-smart-combo-test ] unit-test
 
 [ 14 ] [ [ 1 2 3 ] [ sq ] [ + ] map-reduce-outputs ] unit-test
+
+{ 2 3 } [ [ + ] preserving ] must-infer-as
+
+{ 2 0 } [ [ + ] nullary ] must-infer-as
+
+{ 2 2 } [ [ [ + ] nullary ] preserving ] must-infer-as
index a00967742f716a28c58afbb54b2fd49edc95c614..cb1b309c86ebccc34cbc9bb0ef0ab9b6e75a9b52 100644 (file)
@@ -5,46 +5,49 @@ stack-checker math sequences ;
 IN: combinators.smart
 
 MACRO: drop-outputs ( quot -- quot' )
-    dup infer out>> '[ @ _ ndrop ] ;
+    dup outputs '[ @ _ ndrop ] ;
 
 MACRO: keep-inputs ( quot -- quot' )
-    dup infer in>> '[ _ _ nkeep ] ;
+    dup inputs '[ _ _ nkeep ] ;
 
 MACRO: output>sequence ( quot exemplar -- newquot )
-    [ dup infer out>> ] dip
+    [ dup outputs ] dip
     '[ @ _ _ nsequence ] ;
 
 MACRO: output>array ( quot -- newquot )
     '[ _ { } output>sequence ] ;
 
 MACRO: input<sequence ( quot -- newquot )
-    [ infer in>> ] keep
+    [ inputs ] keep
     '[ _ firstn @ ] ;
 
 MACRO: input<sequence-unsafe ( quot -- newquot )
-    [ infer in>> ] keep
+    [ inputs ] keep
     '[ _ firstn-unsafe @ ] ;
 
 MACRO: reduce-outputs ( quot operation -- newquot )
-    [ dup infer out>> 1 [-] ] dip n*quot compose ;
+    [ dup outputs 1 [-] ] dip n*quot compose ;
 
 MACRO: sum-outputs ( quot -- n )
     '[ _ [ + ] reduce-outputs ] ;
 
 MACRO: map-reduce-outputs ( quot mapper reducer -- newquot )
-    [ dup infer out>> ] 2dip
+    [ dup outputs ] 2dip
     [ swap '[ _ _ napply ] ]
     [ [ 1 [-] ] dip n*quot ] bi-curry* bi
     '[ @ @ @ ] ;
 
 MACRO: append-outputs-as ( quot exemplar -- newquot )
-    [ dup infer out>> ] dip '[ @ _ _ nappend-as ] ;
+    [ dup outputs ] dip '[ @ _ _ nappend-as ] ;
 
 MACRO: append-outputs ( quot -- seq )
     '[ _ { } append-outputs-as ] ;
 
 MACRO: preserving ( quot -- )
-    [ infer in>> length ] keep '[ _ ndup @ ] ;
+    [ inputs ] keep '[ _ ndup @ ] ;
+
+MACRO: nullary ( quot -- quot' )
+    dup outputs '[ @ _ ndrop ] ;
 
 MACRO: smart-if ( pred true false -- )
     '[ _ preserving _ _ if ] ; inline
index 19421359a395f96168981a6bcb37073c34a20561..939fb82f008f0da27277faef527039dea009b3cd 100644 (file)
@@ -8,7 +8,8 @@ IN: command-line
 SYMBOL: script
 SYMBOL: command-line
 
-: (command-line) ( -- args ) 10 getenv sift [ alien>native-string ] map ;
+: (command-line) ( -- args )
+    10 special-object sift [ alien>native-string ] map ;
 
 : rc-path ( name -- path )
     os windows? [ "." prepend ] unless
@@ -69,4 +70,4 @@ SYMBOL: main-vocab-hook
 : ignore-cli-args? ( -- ? )
     os macosx? "run" get "ui" = and ;
 
-[ default-cli-args ] "command-line" add-init-hook
+[ default-cli-args ] "command-line" add-startup-hook
index 1f01bc438b8c07a6e76acd3e318a0a322cc6359a..670e34e5f9b4282b6b82e75a263781d09c103b4b 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2008, 2009 Slava Pestov.
+! Copyright (C) 2008, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: namespaces accessors math.order assocs kernel sequences
 combinators make classes words cpu.architecture layouts
@@ -17,13 +17,13 @@ GENERIC: compute-stack-frame* ( insn -- )
 UNION: stack-frame-insn
     ##alien-invoke
     ##alien-indirect
+    ##alien-assembly
     ##alien-callback ;
 
 M: stack-frame-insn compute-stack-frame*
     stack-frame>> request-stack-frame ;
 
-M: ##call compute-stack-frame*
-    word>> sub-primitive>> [ frame-required? on ] unless ;
+M: ##call compute-stack-frame* drop frame-required? on ;
 
 M: ##gc compute-stack-frame*
     frame-required? on
old mode 100755 (executable)
new mode 100644 (file)
index cf6215c..529c3b5
@@ -1,4 +1,4 @@
-! Copyright (C) 2004, 2009 Slava Pestov.
+! Copyright (C) 2004, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors arrays assocs combinators hashtables kernel
 math fry namespaces make sequences words byte-arrays
@@ -45,6 +45,12 @@ SYMBOL: loops
         end-stack-analysis
     ] with-scope ; inline
 
+: with-dummy-cfg-builder ( node quot -- )
+    [
+        [ V{ } clone procedures ] 2dip
+        '[ _ t t [ _ call( node -- ) ] with-cfg-builder ] with-variable
+    ] { } make drop ;
+
 GENERIC: emit-node ( node -- )
 
 : emit-nodes ( nodes -- )
@@ -230,13 +236,16 @@ M: #alien-invoke emit-node
 M: #alien-indirect emit-node
     [ ##alien-indirect ] emit-alien-node ;
 
+M: #alien-assembly emit-node
+    [ ##alien-assembly ] emit-alien-node ;
+
 M: #alien-callback emit-node
     dup params>> xt>> dup
     [
         ##prologue
-        dup [ ##alien-callback ] emit-alien-node
+        [ ##alien-callback ] emit-alien-node
         ##epilogue
-        params>> ##callback-return
+        ##return
     ] with-cfg-builder ;
 
 ! No-op nodes
index 369e6ebc32631f8177b338225cc12f8e79da93cb..5d815e3b0f06b79edb1fce4524d077ebc5c3f3a2 100644 (file)
@@ -10,14 +10,14 @@ number
 { successors vector }
 { predecessors vector } ;
 
-M: basic-block hashcode* nip id>> ;
-
 : <basic-block> ( -- bb )
     basic-block new
+        \ basic-block counter >>id
         V{ } clone >>instructions
         V{ } clone >>successors
-        V{ } clone >>predecessors
-        \ basic-block counter >>id ;
+        V{ } clone >>predecessors ;
+
+M: basic-block hashcode* nip id>> ;
 
 TUPLE: cfg { entry basic-block } word label
 spill-area-size reps
index 051b0e3e1f2c3064607c9c9ed82b554e26dfe561..d6f2702ee79873a868b3b67327d8216ec9683737 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2009 Slava Pestov.
+! Copyright (C) 2009, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel combinators.short-circuit accessors math sequences
 sets assocs compiler.cfg.instructions compiler.cfg.rpo
@@ -14,7 +14,7 @@ ERROR: bad-kill-block bb ;
     dup instructions>> dup penultimate ##epilogue? [
         {
             [ length 2 = ]
-            [ last { [ ##return? ] [ ##callback-return? ] [ ##jump? ] } 1|| ]
+            [ last { [ ##return? ] [ ##jump? ] } 1|| ]
         } 1&&
     ] [ last ##branch? ] if
     [ drop ] [ bad-kill-block ] if ;
index 91ac92327339bf3780acd01d6de2a43997422559..68a8b8ce59d6fc376e2d6251a1be2f1c9cf12d06 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2008, 2009 Slava Pestov.
+! Copyright (C) 2008, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: assocs accessors arrays kernel sequences namespaces words
 math math.order layouts classes.algebra classes.union
@@ -382,6 +382,16 @@ def: dst
 use: src1 src2
 literal: rep ;
 
+PURE-INSN: ##mul-high-vector
+def: dst
+use: src1 src2
+literal: rep ;
+
+PURE-INSN: ##mul-horizontal-add-vector
+def: dst
+use: src1 src2
+literal: rep ;
+
 PURE-INSN: ##saturated-mul-vector
 def: dst
 use: src1 src2
@@ -402,19 +412,29 @@ def: dst
 use: src1 src2
 literal: rep ;
 
+PURE-INSN: ##avg-vector
+def: dst
+use: src1 src2
+literal: rep ;
+
 PURE-INSN: ##dot-vector
 def: dst/scalar-rep
 use: src1 src2
 literal: rep ;
 
+PURE-INSN: ##sad-vector
+def: dst
+use: src1 src2
+literal: rep ;
+
 PURE-INSN: ##horizontal-add-vector
-def: dst/scalar-rep
-use: src
+def: dst
+use: src1 src2
 literal: rep ;
 
 PURE-INSN: ##horizontal-sub-vector
-def: dst/scalar-rep
-use: src
+def: dst
+use: src1 src2
 literal: rep ;
 
 PURE-INSN: ##horizontal-shl-vector-imm
@@ -651,11 +671,11 @@ literal: params stack-frame ;
 INSN: ##alien-indirect
 literal: params stack-frame ;
 
-INSN: ##alien-callback
+INSN: ##alien-assembly
 literal: params stack-frame ;
 
-INSN: ##callback-return
-literal: params ;
+INSN: ##alien-callback
+literal: params stack-frame ;
 
 ! Instructions used by CFG IR only.
 INSN: ##prologue ;
@@ -728,8 +748,7 @@ temp: temp1/int-rep temp2/int-rep
 literal: size data-values tagged-values uninitialized-locs ;
 
 INSN: ##save-context
-temp: temp1/int-rep temp2/int-rep
-literal: callback-allowed? ;
+temp: temp1/int-rep temp2/int-rep ;
 
 ! Instructions used by machine IR only.
 INSN: _prologue
index bca5e1ee64491c2c8956fd7c74e5f40bc8ca725b..cd76652d06076508be8cfaa3308093cc26c23ef8 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2008, 2009 Slava Pestov.
+! Copyright (C) 2008, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: classes.tuple classes.tuple.parser kernel words
 make fry sequences parser accessors effects namespaces
@@ -61,14 +61,14 @@ TUPLE: insn-slot-spec type name rep ;
     "pure-insn" "compiler.cfg.instructions" lookup ;
 
 : insn-effect ( word -- effect )
-    boa-effect in>> but-last f <effect> ;
+    boa-effect in>> but-last { } <effect> ;
 
 : define-insn-tuple ( class superclass specs -- )
     [ name>> ] map "insn#" suffix define-tuple-class ;
 
 : define-insn-ctor ( class specs -- )
     [ dup '[ _ ] [ f ] [ boa , ] surround ] dip
-    [ name>> ] map f <effect> define-declared ;
+    [ name>> ] map { } <effect> define-declared ;
 
 : define-insn ( class superclass specs -- )
     parse-insn-slot-specs {
index 9804244ecb939da2a2d7d5996b808f9b4b61019c..31a8a898bc1fb07837e1a88425dda876e0f27210 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2008, 2009 Slava Pestov.
+! Copyright (C) 2008, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel math math.order sequences accessors arrays
 byte-arrays layouts classes.tuple.private fry locals
@@ -34,7 +34,7 @@ IN: compiler.cfg.intrinsics.allot
     [ [ ^^load-literal ] dip 1 ] dip type-number ##set-slot-imm ;
 
 :: store-initial-element ( len reg elt class -- )
-    len [ [ elt reg ] dip 2 + class type-number ##set-slot-imm ] each ;
+    len [ [ elt reg ] dip 2 + class type-number ##set-slot-imm ] each-integer ;
 
 : expand-<array>? ( obj -- ? )
     dup integer? [ 0 8 between? ] [ drop f ] if ;
index a03f04f182aed195b4dc95ec5c454614e7f4799f..d753a4c1b496c75cbf0a329e9147bc685689ba23 100644 (file)
@@ -7,7 +7,6 @@ compiler.cfg.intrinsics.alien
 compiler.cfg.intrinsics.allot
 compiler.cfg.intrinsics.fixnum
 compiler.cfg.intrinsics.float
-compiler.cfg.intrinsics.simd
 compiler.cfg.intrinsics.slots
 compiler.cfg.intrinsics.misc
 compiler.cfg.comparisons ;
@@ -23,7 +22,6 @@ QUALIFIED: classes.tuple.private
 QUALIFIED: math.private
 QUALIFIED: math.integers.private
 QUALIFIED: math.floats.private
-QUALIFIED: math.vectors.simd.intrinsics
 QUALIFIED: math.libm
 IN: compiler.cfg.intrinsics
 
@@ -32,7 +30,8 @@ IN: compiler.cfg.intrinsics
 
 {
     { kernel.private:tag [ drop emit-tag ] }
-    { kernel.private:getenv [ emit-getenv ] }
+    { kernel.private:special-object [ emit-special-object ] }
+    { kernel.private:(identity-hashcode) [ drop emit-identity-hashcode ] }
     { math.private:both-fixnums? [ drop emit-both-fixnums? ] }
     { math.private:fixnum+ [ drop emit-fixnum+ ] }
     { math.private:fixnum- [ drop emit-fixnum- ] }
@@ -151,64 +150,5 @@ IN: compiler.cfg.intrinsics
         { math.integers.private:fixnum-log2 [ drop emit-fixnum-log2 ] }
     } enable-intrinsics ;
 
-: enable-simd ( -- )
-    {
-        { math.vectors.simd.intrinsics:assert-positive [ drop ] }
-        { math.vectors.simd.intrinsics:(simd-v+) [ [ ^^add-vector ] emit-binary-vector-op ] }
-        { math.vectors.simd.intrinsics:(simd-vs+) [ [ ^^saturated-add-vector ] emit-binary-vector-op ] }
-        { math.vectors.simd.intrinsics:(simd-v+-) [ [ ^^add-sub-vector ] emit-binary-vector-op ] }
-        { math.vectors.simd.intrinsics:(simd-v-) [ [ ^^sub-vector ] emit-binary-vector-op ] }
-        { math.vectors.simd.intrinsics:(simd-vs-) [ [ ^^saturated-sub-vector ] emit-binary-vector-op ] }
-        { math.vectors.simd.intrinsics:(simd-vneg) [ [ generate-neg-vector ] emit-unary-vector-op ] }
-        { math.vectors.simd.intrinsics:(simd-v*) [ [ ^^mul-vector ] emit-binary-vector-op ] }
-        { math.vectors.simd.intrinsics:(simd-vs*) [ [ ^^saturated-mul-vector ] emit-binary-vector-op ] }
-        { math.vectors.simd.intrinsics:(simd-v/) [ [ ^^div-vector ] emit-binary-vector-op ] }
-        { math.vectors.simd.intrinsics:(simd-vmin) [ [ generate-min-vector ] emit-binary-vector-op ] }
-        { math.vectors.simd.intrinsics:(simd-vmax) [ [ generate-max-vector ] emit-binary-vector-op ] }
-        { math.vectors.simd.intrinsics:(simd-v.) [ [ ^^dot-vector ] emit-binary-vector-op ] }
-        { math.vectors.simd.intrinsics:(simd-vabs) [ [ generate-abs-vector ] emit-unary-vector-op ] }
-        { math.vectors.simd.intrinsics:(simd-vsqrt) [ [ ^^sqrt-vector ] emit-unary-vector-op ] }
-        { math.vectors.simd.intrinsics:(simd-vbitand) [ [ ^^and-vector ] emit-binary-vector-op ] }
-        { math.vectors.simd.intrinsics:(simd-vbitandn) [ [ ^^andn-vector ] emit-binary-vector-op ] }
-        { math.vectors.simd.intrinsics:(simd-vbitor) [ [ ^^or-vector ] emit-binary-vector-op ] }
-        { math.vectors.simd.intrinsics:(simd-vbitxor) [ [ ^^xor-vector ] emit-binary-vector-op ] }
-        { math.vectors.simd.intrinsics:(simd-vbitnot) [ [ generate-not-vector ] emit-unary-vector-op ] }
-        { math.vectors.simd.intrinsics:(simd-vand) [ [ ^^and-vector ] emit-binary-vector-op ] }
-        { math.vectors.simd.intrinsics:(simd-vandn) [ [ ^^andn-vector ] emit-binary-vector-op ] }
-        { math.vectors.simd.intrinsics:(simd-vor) [ [ ^^or-vector ] emit-binary-vector-op ] }
-        { math.vectors.simd.intrinsics:(simd-vxor) [ [ ^^xor-vector ] emit-binary-vector-op ] }
-        { math.vectors.simd.intrinsics:(simd-vnot) [ [ generate-not-vector ] emit-unary-vector-op ] }
-        { math.vectors.simd.intrinsics:(simd-v<=) [ [ cc<= generate-compare-vector ] emit-binary-vector-op ] }
-        { math.vectors.simd.intrinsics:(simd-v<) [ [ cc< generate-compare-vector ] emit-binary-vector-op ] }
-        { math.vectors.simd.intrinsics:(simd-v=) [ [ cc= generate-compare-vector ] emit-binary-vector-op ] }
-        { math.vectors.simd.intrinsics:(simd-v>) [ [ cc> generate-compare-vector ] emit-binary-vector-op ] }
-        { math.vectors.simd.intrinsics:(simd-v>=) [ [ cc>= generate-compare-vector ] emit-binary-vector-op ] }
-        { math.vectors.simd.intrinsics:(simd-vunordered?) [ [ cc/<>= generate-compare-vector ] emit-binary-vector-op ] }
-        { math.vectors.simd.intrinsics:(simd-vany?) [ [ vcc-any ^^test-vector ] emit-unary-vector-op ] }
-        { math.vectors.simd.intrinsics:(simd-vall?) [ [ vcc-all ^^test-vector ] emit-unary-vector-op ] }
-        { math.vectors.simd.intrinsics:(simd-vnone?) [ [ vcc-none ^^test-vector ] emit-unary-vector-op ] }
-        { math.vectors.simd.intrinsics:(simd-vlshift) [ [ ^^shl-vector-imm ] [ ^^shl-vector ] emit-shift-vector-op ] }
-        { math.vectors.simd.intrinsics:(simd-vrshift) [ [ ^^shr-vector-imm ] [ ^^shr-vector ] emit-shift-vector-op ] }
-        { math.vectors.simd.intrinsics:(simd-hlshift) [ [ ^^horizontal-shl-vector-imm ] emit-shift-vector-imm-op ] }
-        { math.vectors.simd.intrinsics:(simd-hrshift) [ [ ^^horizontal-shr-vector-imm ] emit-shift-vector-imm-op ] }
-        { math.vectors.simd.intrinsics:(simd-with) [ [ ^^with-vector ] emit-unary-vector-op ] }
-        { math.vectors.simd.intrinsics:(simd-gather-2) [ emit-gather-vector-2 ] }
-        { math.vectors.simd.intrinsics:(simd-gather-4) [ emit-gather-vector-4 ] }
-        { math.vectors.simd.intrinsics:(simd-vshuffle-elements) [ emit-shuffle-vector ] }
-        { math.vectors.simd.intrinsics:(simd-vshuffle-bytes) [ emit-shuffle-vector-var ] }
-        { math.vectors.simd.intrinsics:(simd-(vmerge-head)) [ [ ^^merge-vector-head ] emit-binary-vector-op ] }
-        { math.vectors.simd.intrinsics:(simd-(vmerge-tail)) [ [ ^^merge-vector-tail ] emit-binary-vector-op ] }
-        { math.vectors.simd.intrinsics:(simd-(v>float)) [ [ ^^integer>float-vector ] emit-unary-vector-op ] }
-        { math.vectors.simd.intrinsics:(simd-(v>integer)) [ [ ^^float>integer-vector ] emit-unary-vector-op ] }
-        { math.vectors.simd.intrinsics:(simd-(vpack-signed)) [ [ ^^signed-pack-vector ] emit-binary-vector-op ] }
-        { math.vectors.simd.intrinsics:(simd-(vpack-unsigned)) [ [ ^^unsigned-pack-vector ] emit-binary-vector-op ] }
-        { math.vectors.simd.intrinsics:(simd-(vunpack-head)) [ [ generate-unpack-vector-head ] emit-unary-vector-op ] }
-        { math.vectors.simd.intrinsics:(simd-(vunpack-tail)) [ [ generate-unpack-vector-tail ] emit-unary-vector-op ] }
-        { math.vectors.simd.intrinsics:(simd-select) [ emit-select-vector ] }
-        { math.vectors.simd.intrinsics:(simd-sum) [ [ ^^horizontal-add-vector ] emit-unary-vector-op ] }
-        { math.vectors.simd.intrinsics:alien-vector [ emit-alien-vector ] }
-        { math.vectors.simd.intrinsics:set-alien-vector [ emit-set-alien-vector ] }
-    } enable-intrinsics ;
-
 : emit-intrinsic ( node word -- )
     "intrinsic" word-prop call( node -- ) ;
index ce005e8353650e5f6461b4d4188b8fef7be11f8c..fed5492220847bbd760935147a1995d2c94151f3 100644 (file)
@@ -1,16 +1,22 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: namespaces layouts sequences kernel
-accessors compiler.tree.propagation.info
-compiler.cfg.stacks compiler.cfg.hats
-compiler.cfg.instructions compiler.cfg.utilities ;
+USING: namespaces layouts sequences kernel math accessors
+compiler.tree.propagation.info compiler.cfg.stacks
+compiler.cfg.hats compiler.cfg.instructions
+compiler.cfg.utilities ;
 IN: compiler.cfg.intrinsics.misc
 
 : emit-tag ( -- )
     ds-pop tag-mask get ^^and-imm ^^tag-fixnum ds-push ;
 
-: emit-getenv ( node -- )
-    "userenv" ^^vm-field-ptr
+: emit-special-object ( node -- )
+    "special-objects" ^^vm-field-ptr
     swap node-input-infos first literal>>
     [ ds-drop 0 ^^slot-imm ] [ ds-pop ^^offset>slot ^^slot ] if*
     ds-push ;
+
+: emit-identity-hashcode ( -- )
+    ds-pop tag-mask get bitnot ^^load-immediate ^^and 0 0 ^^slot-imm
+    hashcode-shift ^^shr-imm
+    ^^tag-fixnum
+    ds-push ;
diff --git a/basis/compiler/cfg/intrinsics/simd/backend/backend.factor b/basis/compiler/cfg/intrinsics/simd/backend/backend.factor
new file mode 100644 (file)
index 0000000..e8b9e3c
--- /dev/null
@@ -0,0 +1,206 @@
+! (c)2009 Joe Groff bsd license
+USING: accessors arrays assocs classes combinators
+combinators.short-circuit compiler.cfg.builder.blocks
+compiler.cfg.registers compiler.cfg.stacks
+compiler.cfg.stacks.local compiler.tree.propagation.info
+cpu.architecture effects fry generalizations
+kernel locals macros math namespaces quotations sequences
+splitting stack-checker words ;
+IN: compiler.cfg.intrinsics.simd.backend
+
+! Selection of implementation based on available CPU instructions
+
+: can-has? ( quot -- ? )
+    [ t \ can-has? ] dip '[ @ drop \ can-has? get ] with-variable ; inline
+
+: can-has-rep? ( rep reps -- )
+    member? \ can-has? [ and ] change ; inline
+
+GENERIC: create-can-has ( word -- word' )
+
+PREDICATE: hat-word < word
+    {
+        [ name>> { [ "^" head? ] [ "##" head? ] } 1|| ]
+        [ vocabulary>> { "compiler.cfg.intrinsics.simd" "compiler.cfg.hats" } member? ]
+    } 1&& ;
+
+PREDICATE: vector-op-word < hat-word
+    name>> "-vector" swap subseq? ;
+
+: reps-word ( word -- word' )
+    name>> "^^" ?head drop "##" ?head drop
+    "%" "-reps" surround "cpu.architecture" lookup ;
+
+SYMBOL: blub
+
+:: can-has-^^-quot ( word def effect -- quot )
+    effect in>> { "rep" } split1 [ length ] bi@ 1 +
+    word reps-word 1quotation
+    effect out>> length blub <array> >quotation
+    '[ [ _ ndrop ] _ ndip @ can-has-rep? @ ] ;
+
+:: can-has-^-quot ( word def effect -- quot )
+    def create-can-has first ;
+
+: map-concat-like ( seq quot -- seq' )
+    '[ _ map ] [ concat-as ] bi ; inline
+
+M: object create-can-has 1quotation ;
+
+M: array create-can-has
+    [ create-can-has ] map-concat-like 1quotation ;
+M: callable create-can-has
+    [ create-can-has ] map-concat-like 1quotation ;
+
+: (can-has-word) ( word -- word' )
+    name>> "can-has-" prepend "compiler.cfg.intrinsics.simd.backend" lookup ;
+
+: (can-has-quot) ( word -- quot )
+    [ ] [ def>> ] [ stack-effect ] tri {
+        { [ pick name>> "^^" head? ] [ can-has-^^-quot ] }
+        { [ pick name>> "##" head? ] [ can-has-^^-quot ] }
+        { [ pick name>> "^"  head? ] [ can-has-^-quot  ] }
+    } cond ;
+
+: (can-has-nop-quot) ( word -- quot )
+    stack-effect in>> length '[ _ ndrop blub ] ;
+
+DEFER: can-has-words
+
+M: word create-can-has
+    can-has-words ?at drop 1quotation ;
+
+M: hat-word create-can-has
+    (can-has-nop-quot) ;
+
+M: vector-op-word create-can-has
+    dup (can-has-word) [ 1quotation ] [ (can-has-quot) ] ?if ;
+
+GENERIC# >can-has-cond 2 ( quot #pick #dup -- quotpair )
+M:: callable >can-has-cond ( quot #pick #dup -- quotpair )
+    #dup quot create-can-has '[ _ ndup @ can-has? ] quot 2array ;
+
+M:: pair >can-has-cond ( pair #pick #dup -- quotpair )
+    pair first2 :> ( class quot )
+    #pick class #dup quot create-can-has
+    '[ _ npick _ instance? [ _ ndup @ can-has? ] dip and ]
+    quot 2array ;
+
+MACRO: v-vector-op ( trials -- )
+    [ 1 2 >can-has-cond ] map '[ _ cond ] ;
+MACRO: vl-vector-op ( trials -- )
+    [ 1 3 >can-has-cond ] map '[ _ cond ] ;
+MACRO: vv-vector-op ( trials -- )
+    [ 1 3 >can-has-cond ] map '[ _ cond ] ;
+MACRO: vv-cc-vector-op ( trials -- )
+    [ 2 4 >can-has-cond ] map '[ _ cond ] ;
+MACRO: vvvv-vector-op ( trials -- )
+    [ 1 5 >can-has-cond ] map '[ _ cond ] ;
+
+! Special-case conditional instructions
+
+: can-has-^(compare-vector) ( src1 src2 rep cc -- dst )
+    [ 2drop ] 2dip %compare-vector-reps member?
+    \ can-has? [ and ] change
+    blub ;
+
+: can-has-^^test-vector ( src rep vcc -- dst )
+    [ drop ] 2dip drop %test-vector-reps member?
+    \ can-has? [ and ] change
+    blub ;
+
+MACRO: can-has-case ( cases -- )
+    dup first second inputs 1 +
+    '[ _ ndrop f ] suffix '[ _ case ] ;
+
+GENERIC# >can-has-trial 1 ( obj #pick -- quot )
+
+M: callable >can-has-trial
+    drop '[ _ can-has? ] ;
+M: pair >can-has-trial
+    swap first2 dup inputs
+    '[ _ npick _ instance? [ _ can-has? ] [ _ ndrop blub ] if ] ; 
+
+MACRO: can-has-vector-op ( trials #pick #dup -- )
+    [ '[ _ >can-has-trial ] map ] dip '[ _ _ n|| \ can-has? [ and ] change blub ] ;
+
+: can-has-v-vector-op ( trials -- ? )
+    1 2 can-has-vector-op ; inline
+: can-has-vv-vector-op ( trials -- ? )
+    1 3 can-has-vector-op ; inline
+: can-has-vv-cc-vector-op ( trials -- ? )
+    2 4 can-has-vector-op ; inline
+: can-has-vvvv-vector-op ( trials -- ? )
+    1 5 can-has-vector-op ; inline
+
+CONSTANT: can-has-words
+    H{
+        { case can-has-case }
+        { v-vector-op     can-has-v-vector-op  }
+        { vl-vector-op    can-has-vv-vector-op }
+        { vv-vector-op    can-has-vv-vector-op }
+        { vv-cc-vector-op can-has-vv-cc-vector-op }
+        { vvvv-vector-op  can-has-vvvv-vector-op }
+    }
+
+! Intrinsic code emission
+
+MACRO: check-elements ( quots -- )
+    [ length '[ _ firstn ] ]
+    [ '[ _ spread ] ]
+    [ length 1 - \ and <repetition> [ ] like ]
+    tri 3append ;
+
+ERROR: bad-simd-intrinsic node ;
+
+MACRO: if-literals-match ( quots -- )
+    [ length ] [ ] [ length ] tri
+    ! n quots n
+    '[
+        ! node quot
+        [
+            dup node-input-infos
+            _ tail-slice* [ literal>> ] map
+            dup _ check-elements
+        ] dip
+        swap [
+            ! node literals quot
+            [ _ firstn ] dip call
+            drop
+        ] [ 2drop bad-simd-intrinsic ] if
+    ] ;
+
+CONSTANT: [unary]       [ ds-drop  ds-pop ]
+CONSTANT: [unary/param] [ [ -2 inc-d ds-pop ] dip ]
+CONSTANT: [binary]      [ ds-drop 2inputs ]
+CONSTANT: [quaternary]
+    [
+        ds-drop 
+        D 3 peek-loc
+        D 2 peek-loc
+        D 1 peek-loc
+        D 0 peek-loc
+        -4 inc-d
+    ]
+
+:: [emit-vector-op] ( trials params-quot op-quot literal-preds -- quot )
+    params-quot trials op-quot literal-preds 
+    '[ [ _ dip _ @ ds-push ] _ if-literals-match ] ;
+
+MACRO: emit-v-vector-op ( trials -- )
+    [unary] [ v-vector-op ] { [ representation? ] } [emit-vector-op] ;
+MACRO: emit-vl-vector-op ( trials literal-pred -- )
+    [ [unary/param] [ vl-vector-op ] { [ representation? ] } ] dip prefix [emit-vector-op] ;
+MACRO: emit-vv-vector-op ( trials -- )
+    [binary] [ vv-vector-op ] { [ representation? ] } [emit-vector-op] ;
+MACRO: emit-vvvv-vector-op ( trials -- )
+    [quaternary] [ vvvv-vector-op ] { [ representation? ] } [emit-vector-op] ;
+
+MACRO:: emit-vv-or-vl-vector-op ( var-trials imm-trials literal-pred -- )
+    literal-pred imm-trials literal-pred var-trials
+    '[
+        dup node-input-infos 2 tail-slice* first literal>> @
+        [ _ _ emit-vl-vector-op ]
+        [ _   emit-vv-vector-op ] if 
+    ] ;
+
diff --git a/basis/compiler/cfg/intrinsics/simd/simd-tests.factor b/basis/compiler/cfg/intrinsics/simd/simd-tests.factor
new file mode 100644 (file)
index 0000000..8bd936c
--- /dev/null
@@ -0,0 +1,536 @@
+! (c)2009 Joe Groff bsd license
+USING: arrays assocs biassocs byte-arrays byte-arrays.hex
+classes compiler.cfg compiler.cfg.comparisons compiler.cfg.instructions
+compiler.cfg.intrinsics.simd compiler.cfg.intrinsics.simd.backend
+compiler.cfg.registers compiler.cfg.stacks.height
+compiler.cfg.stacks.local compiler.tree compiler.tree.propagation.info
+cpu.architecture fry hashtables kernel locals make namespaces sequences
+system tools.test words ;
+IN: compiler.cfg.intrinsics.simd.tests
+
+:: test-node ( rep -- node ) 
+    T{ #call
+        { in-d  { 1 2 3 4 } }
+        { out-d { 5 } }
+        { info H{
+            { 1 T{ value-info { class byte-array } } }
+            { 2 T{ value-info { class byte-array } } }
+            { 3 T{ value-info { class byte-array } } }
+            { 4 T{ value-info { class word } { literal? t } { literal rep } } }
+            { 5 T{ value-info { class byte-array } } }
+        } }
+    } ;
+
+:: test-node-literal ( lit rep -- node )
+    lit class :> lit-class
+    T{ #call
+        { in-d  { 1 2 3 4 } }
+        { out-d { 5 } }
+        { info H{
+            { 1 T{ value-info { class byte-array } } }
+            { 2 T{ value-info { class byte-array } } }
+            { 3 T{ value-info { class lit-class } { literal? t } { literal lit } } }
+            { 4 T{ value-info { class word } { literal? t } { literal rep } } }
+            { 5 T{ value-info { class byte-array } } }
+        } }
+    } ;
+
+: test-node-nonliteral-rep ( -- node )
+    T{ #call
+        { in-d  { 1 2 3 4 } }
+        { out-d { 5 } }
+        { info H{
+            { 1 T{ value-info { class byte-array } } }
+            { 2 T{ value-info { class byte-array } } }
+            { 3 T{ value-info { class byte-array } } }
+            { 4 T{ value-info { class object } } }
+            { 5 T{ value-info { class byte-array } } }
+        } }
+    } ;
+
+: test-compiler-env ( -- x )
+    H{ } clone
+        T{ basic-block { id 0 } }
+            [ \ basic-block pick set-at ]
+            [ 0 swap associate \ ds-heights pick set-at ]
+            [ 0 swap associate \ rs-heights pick set-at ] tri
+        T{ current-height { d 0 } { r 0 } { emit-d 0 } { emit-r 0 } } \ current-height pick set-at
+        H{ } clone \ local-peek-set pick set-at
+        H{ } clone \ replace-mapping pick set-at
+        H{ } <biassoc> \ locs>vregs pick set-at
+        H{ } clone \ peek-sets pick set-at
+        H{ } clone \ replace-sets pick set-at
+        H{ } clone \ kill-sets pick set-at ;
+
+: make-classes ( quot -- seq )
+    { } make [ class ] map ; inline
+
+: test-emit ( cpu rep quot -- node )
+    [
+        [ new \ cpu ] 2dip '[
+            test-compiler-env [ _ test-node @ ] bind
+        ] with-variable
+    ] make-classes ; inline
+
+: test-emit-literal ( cpu lit rep quot -- node )
+    [
+        [ new \ cpu ] 3dip '[
+            test-compiler-env [ _ _ test-node-literal @ ] bind
+        ] with-variable
+    ] make-classes ; inline
+
+: test-emit-nonliteral-rep ( cpu quot -- node )
+    [
+        [ new \ cpu ] dip '[
+            test-compiler-env [ test-node-nonliteral-rep @ ] bind
+        ] with-variable
+    ] make-classes ; inline
+
+CONSTANT: signed-reps
+    { char-16-rep short-8-rep int-4-rep longlong-2-rep float-4-rep double-2-rep }
+CONSTANT: all-reps
+    {
+        char-16-rep short-8-rep int-4-rep longlong-2-rep float-4-rep double-2-rep
+        uchar-16-rep ushort-8-rep uint-4-rep ulonglong-2-rep
+    }
+
+TUPLE: scalar-cpu ;
+
+TUPLE: simple-ops-cpu ;
+M: simple-ops-cpu %zero-vector-reps  all-reps ;
+M: simple-ops-cpu %fill-vector-reps  all-reps ;
+M: simple-ops-cpu %add-vector-reps   all-reps ;
+M: simple-ops-cpu %sub-vector-reps   all-reps ;
+M: simple-ops-cpu %mul-vector-reps   all-reps ;
+M: simple-ops-cpu %div-vector-reps   all-reps ;
+M: simple-ops-cpu %andn-vector-reps  all-reps ;
+M: simple-ops-cpu %and-vector-reps   all-reps ;
+M: simple-ops-cpu %or-vector-reps    all-reps ;
+M: simple-ops-cpu %xor-vector-reps   all-reps ;
+M: simple-ops-cpu %merge-vector-reps all-reps ;
+M: simple-ops-cpu %sqrt-vector-reps  all-reps ;
+M: simple-ops-cpu %test-vector-reps  all-reps ;
+M: simple-ops-cpu %signed-pack-vector-reps   all-reps ;
+M: simple-ops-cpu %unsigned-pack-vector-reps all-reps ;
+M: simple-ops-cpu %gather-vector-2-reps { longlong-2-rep ulonglong-2-rep double-2-rep } ;
+M: simple-ops-cpu %gather-vector-4-reps { int-4-rep uint-4-rep float-4-rep } ;
+M: simple-ops-cpu %alien-vector-reps all-reps ;
+
+! v+
+[ { ##add-vector } ]
+[ simple-ops-cpu float-4-rep [ emit-simd-v+ ] test-emit ]
+unit-test
+
+! v-
+[ { ##sub-vector } ]
+[ simple-ops-cpu float-4-rep [ emit-simd-v- ] test-emit ]
+unit-test
+
+! vneg
+[ { ##load-constant ##sub-vector } ]
+[ simple-ops-cpu float-4-rep [ emit-simd-vneg ] test-emit ]
+unit-test
+
+[ { ##zero-vector ##sub-vector } ]
+[ simple-ops-cpu int-4-rep [ emit-simd-vneg ] test-emit ]
+unit-test
+
+! v*
+[ { ##mul-vector } ]
+[ simple-ops-cpu float-4-rep [ emit-simd-v* ] test-emit ]
+unit-test
+
+! v/
+[ { ##div-vector } ]
+[ simple-ops-cpu float-4-rep [ emit-simd-v/ ] test-emit ]
+unit-test
+
+TUPLE: addsub-cpu < simple-ops-cpu ;
+M: addsub-cpu %add-sub-vector-reps { int-4-rep float-4-rep } ;
+
+! v+-
+[ { ##add-sub-vector } ]
+[ addsub-cpu float-4-rep [ emit-simd-v+- ] test-emit ]
+unit-test
+
+[ { ##load-constant ##xor-vector ##add-vector } ]
+[ simple-ops-cpu float-4-rep [ emit-simd-v+- ] test-emit ]
+unit-test
+
+[ { ##load-constant ##xor-vector ##sub-vector ##add-vector } ]
+[ simple-ops-cpu int-4-rep [ emit-simd-v+- ] test-emit ]
+unit-test
+
+TUPLE: saturating-cpu < simple-ops-cpu ;
+M: saturating-cpu %saturated-add-vector-reps { int-4-rep } ;
+M: saturating-cpu %saturated-sub-vector-reps { int-4-rep } ;
+M: saturating-cpu %saturated-mul-vector-reps { int-4-rep } ;
+
+! vs+
+[ { ##add-vector } ]
+[ simple-ops-cpu float-4-rep [ emit-simd-vs+ ] test-emit ]
+unit-test
+
+[ { ##add-vector } ]
+[ saturating-cpu float-4-rep [ emit-simd-vs+ ] test-emit ]
+unit-test
+
+[ { ##saturated-add-vector } ]
+[ saturating-cpu int-4-rep [ emit-simd-vs+ ] test-emit ]
+unit-test
+
+! vs-
+[ { ##sub-vector } ]
+[ simple-ops-cpu float-4-rep [ emit-simd-vs- ] test-emit ]
+unit-test
+
+[ { ##sub-vector } ]
+[ saturating-cpu float-4-rep [ emit-simd-vs- ] test-emit ]
+unit-test
+
+[ { ##saturated-sub-vector } ]
+[ saturating-cpu int-4-rep [ emit-simd-vs- ] test-emit ]
+unit-test
+
+! vs*
+[ { ##mul-vector } ]
+[ simple-ops-cpu float-4-rep [ emit-simd-vs* ] test-emit ]
+unit-test
+
+[ { ##mul-vector } ]
+[ saturating-cpu float-4-rep [ emit-simd-vs* ] test-emit ]
+unit-test
+
+[ { ##saturated-mul-vector } ]
+[ saturating-cpu int-4-rep [ emit-simd-vs* ] test-emit ]
+unit-test
+
+TUPLE: minmax-cpu < simple-ops-cpu ;
+M: minmax-cpu %min-vector-reps signed-reps ;
+M: minmax-cpu %max-vector-reps signed-reps ;
+M: minmax-cpu %compare-vector-reps { cc= cc/= } member? [ signed-reps ] [ { } ] if ;
+M: minmax-cpu %compare-vector-ccs nip f 2array 1array f ;
+
+TUPLE: compare-cpu < simple-ops-cpu ;
+M: compare-cpu %compare-vector-reps drop signed-reps ;
+M: compare-cpu %compare-vector-ccs nip f 2array 1array f ;
+
+! vmin
+[ { ##min-vector } ]
+[ minmax-cpu float-4-rep [ emit-simd-vmin ] test-emit ]
+unit-test
+
+[ { ##compare-vector ##and-vector ##andn-vector ##or-vector } ]
+[ compare-cpu float-4-rep [ emit-simd-vmin ] test-emit ]
+unit-test
+
+! vmax
+[ { ##max-vector } ]
+[ minmax-cpu float-4-rep [ emit-simd-vmax ] test-emit ]
+unit-test
+
+[ { ##compare-vector ##and-vector ##andn-vector ##or-vector } ]
+[ compare-cpu float-4-rep [ emit-simd-vmax ] test-emit ]
+unit-test
+
+TUPLE: dot-cpu < simple-ops-cpu ;
+M: dot-cpu %dot-vector-reps { float-4-rep } ;
+
+TUPLE: horizontal-cpu < simple-ops-cpu ;
+M: horizontal-cpu %horizontal-add-vector-reps signed-reps ;
+M: horizontal-cpu %unpack-vector-head-reps signed-reps ;
+M: horizontal-cpu %unpack-vector-tail-reps signed-reps ;
+
+! v.
+[ { ##dot-vector } ]
+[ dot-cpu float-4-rep [ emit-simd-v. ] test-emit ]
+unit-test
+
+[ { ##mul-vector ##horizontal-add-vector ##horizontal-add-vector ##vector>scalar } ]
+[ horizontal-cpu float-4-rep [ emit-simd-v. ] test-emit ]
+unit-test
+
+[ {
+    ##mul-vector
+    ##merge-vector-head ##merge-vector-tail ##add-vector 
+    ##merge-vector-head ##merge-vector-tail ##add-vector 
+    ##vector>scalar
+} ]
+[ simple-ops-cpu float-4-rep [ emit-simd-v. ] test-emit ]
+unit-test
+
+! vsqrt
+[ { ##sqrt-vector } ]
+[ simple-ops-cpu float-4-rep [ emit-simd-vsqrt ] test-emit ]
+unit-test
+
+! sum
+[ { ##horizontal-add-vector ##vector>scalar } ]
+[ horizontal-cpu double-2-rep [ emit-simd-sum ] test-emit ]
+unit-test
+
+[ { ##horizontal-add-vector ##horizontal-add-vector ##vector>scalar } ]
+[ horizontal-cpu float-4-rep [ emit-simd-sum ] test-emit ]
+unit-test
+
+[ {
+    ##unpack-vector-head ##unpack-vector-tail ##add-vector
+    ##horizontal-add-vector ##horizontal-add-vector
+    ##vector>scalar
+} ]
+[ horizontal-cpu short-8-rep [ emit-simd-sum ] test-emit ]
+unit-test
+
+[ {
+    ##unpack-vector-head ##unpack-vector-tail ##add-vector
+    ##horizontal-add-vector ##horizontal-add-vector ##horizontal-add-vector
+    ##vector>scalar
+} ]
+[ horizontal-cpu char-16-rep [ emit-simd-sum ] test-emit ]
+unit-test
+
+TUPLE: abs-cpu < simple-ops-cpu ;
+M: abs-cpu %abs-vector-reps signed-reps ;
+
+! vabs
+[ { } ]
+[ simple-ops-cpu uint-4-rep [ emit-simd-vabs ] test-emit ]
+unit-test
+
+[ { ##abs-vector } ]
+[ abs-cpu float-4-rep [ emit-simd-vabs ] test-emit ]
+unit-test
+
+[ { ##load-constant ##andn-vector } ]
+[ simple-ops-cpu float-4-rep [ emit-simd-vabs ] test-emit ]
+unit-test
+
+[ { ##zero-vector ##sub-vector ##compare-vector ##and-vector ##andn-vector ##or-vector } ]
+[ compare-cpu int-4-rep [ emit-simd-vabs ] test-emit ]
+unit-test
+
+! vand
+[ { ##and-vector } ]
+[ simple-ops-cpu float-4-rep [ emit-simd-vand ] test-emit ]
+unit-test
+
+! vandn
+[ { ##andn-vector } ]
+[ simple-ops-cpu float-4-rep [ emit-simd-vandn ] test-emit ]
+unit-test
+
+! vor
+[ { ##or-vector } ]
+[ simple-ops-cpu float-4-rep [ emit-simd-vor ] test-emit ]
+unit-test
+
+! vxor
+[ { ##xor-vector } ]
+[ simple-ops-cpu float-4-rep [ emit-simd-vxor ] test-emit ]
+unit-test
+
+TUPLE: not-cpu < simple-ops-cpu ;
+M: not-cpu %not-vector-reps signed-reps ;
+
+! vnot
+[ { ##not-vector } ]
+[ not-cpu float-4-rep [ emit-simd-vnot ] test-emit ]
+unit-test
+
+[ { ##fill-vector ##xor-vector } ]
+[ simple-ops-cpu float-4-rep [ emit-simd-vnot ] test-emit ]
+unit-test
+
+TUPLE: shift-cpu < simple-ops-cpu ;
+M: shift-cpu %shl-vector-reps signed-reps ;
+M: shift-cpu %shr-vector-reps signed-reps ;
+
+TUPLE: shift-imm-cpu < simple-ops-cpu ;
+M: shift-imm-cpu %shl-vector-imm-reps signed-reps ;
+M: shift-imm-cpu %shr-vector-imm-reps signed-reps ;
+
+TUPLE: horizontal-shift-cpu < simple-ops-cpu ;
+M: horizontal-shift-cpu %horizontal-shl-vector-imm-reps signed-reps ;
+M: horizontal-shift-cpu %horizontal-shr-vector-imm-reps signed-reps ;
+
+! vlshift
+[ { ##shl-vector-imm } ]
+[ shift-imm-cpu 2 int-4-rep [ emit-simd-vlshift ] test-emit-literal ]
+unit-test
+
+[ { ##shl-vector } ]
+[ shift-cpu int-4-rep [ emit-simd-vlshift ] test-emit ]
+unit-test
+
+! vrshift
+[ { ##shr-vector-imm } ]
+[ shift-imm-cpu 2 int-4-rep [ emit-simd-vrshift ] test-emit-literal ]
+unit-test
+
+[ { ##shr-vector } ]
+[ shift-cpu int-4-rep [ emit-simd-vrshift ] test-emit ]
+unit-test
+
+! hlshift
+[ { ##horizontal-shl-vector-imm } ]
+[ horizontal-shift-cpu 2 int-4-rep [ emit-simd-hlshift ] test-emit-literal ]
+unit-test
+
+! hrshift
+[ { ##horizontal-shr-vector-imm } ]
+[ horizontal-shift-cpu 2 int-4-rep [ emit-simd-hrshift ] test-emit-literal ]
+unit-test
+
+TUPLE: shuffle-imm-cpu < simple-ops-cpu ;
+M: shuffle-imm-cpu %shuffle-vector-imm-reps signed-reps ;
+
+TUPLE: shuffle-cpu < simple-ops-cpu ;
+M: shuffle-cpu %shuffle-vector-reps signed-reps ;
+
+! vshuffle-elements
+[ { ##load-constant ##shuffle-vector } ]
+[ shuffle-cpu { 0 1 2 3 } int-4-rep [ emit-simd-vshuffle-elements ] test-emit-literal ]
+unit-test
+
+[ { ##shuffle-vector-imm } ]
+[ shuffle-imm-cpu { 0 1 2 3 } int-4-rep [ emit-simd-vshuffle-elements ] test-emit-literal ]
+unit-test
+
+! vshuffle-bytes
+[ { ##shuffle-vector } ]
+[ shuffle-cpu int-4-rep [ emit-simd-vshuffle-bytes ] test-emit ]
+unit-test
+
+! vmerge-head
+[ { ##merge-vector-head } ]
+[ simple-ops-cpu float-4-rep [ emit-simd-vmerge-head ] test-emit ]
+unit-test
+
+! vmerge-tail
+[ { ##merge-vector-tail } ]
+[ simple-ops-cpu float-4-rep [ emit-simd-vmerge-tail ] test-emit ]
+unit-test
+
+! v<= etc.
+[ { ##compare-vector } ]
+[ compare-cpu int-4-rep [ emit-simd-v<= ] test-emit ]
+unit-test
+
+[ { ##min-vector ##compare-vector } ]
+[ minmax-cpu int-4-rep [ emit-simd-v<= ] test-emit ]
+unit-test
+
+[ { ##load-constant ##xor-vector ##xor-vector ##compare-vector } ]
+[ compare-cpu uint-4-rep [ emit-simd-v<= ] test-emit ]
+unit-test
+
+! vany? etc.
+[ { ##test-vector } ]
+[ simple-ops-cpu int-4-rep [ emit-simd-vany? ] test-emit ]
+unit-test
+
+TUPLE: convert-cpu < simple-ops-cpu ;
+M: convert-cpu %integer>float-vector-reps { int-4-rep } ;
+M: convert-cpu %float>integer-vector-reps { float-4-rep } ;
+
+! v>float
+[ { } ]
+[ convert-cpu float-4-rep [ emit-simd-v>float ] test-emit ]
+unit-test
+
+[ { ##integer>float-vector } ]
+[ convert-cpu int-4-rep [ emit-simd-v>float ] test-emit ]
+unit-test
+
+! v>integer
+[ { } ]
+[ convert-cpu int-4-rep [ emit-simd-v>integer ] test-emit ]
+unit-test
+
+[ { ##float>integer-vector } ]
+[ convert-cpu float-4-rep [ emit-simd-v>integer ] test-emit ]
+unit-test
+
+! vpack-signed
+[ { ##signed-pack-vector } ]
+[ simple-ops-cpu int-4-rep [ emit-simd-vpack-signed ] test-emit ]
+unit-test
+
+! vpack-unsigned
+[ { ##unsigned-pack-vector } ]
+[ simple-ops-cpu int-4-rep [ emit-simd-vpack-unsigned ] test-emit ]
+unit-test
+
+TUPLE: unpack-head-cpu < simple-ops-cpu ;
+M: unpack-head-cpu %unpack-vector-head-reps all-reps ;
+TUPLE: unpack-cpu < unpack-head-cpu ;
+M: unpack-cpu %unpack-vector-tail-reps all-reps ;
+
+! vunpack-head
+[ { ##unpack-vector-head } ]
+[ unpack-head-cpu int-4-rep [ emit-simd-vunpack-head ] test-emit ]
+unit-test
+
+[ { ##zero-vector ##merge-vector-head } ]
+[ simple-ops-cpu uint-4-rep [ emit-simd-vunpack-head ] test-emit ]
+unit-test
+
+[ { ##merge-vector-head ##shr-vector-imm } ]
+[ shift-imm-cpu int-4-rep [ emit-simd-vunpack-head ] test-emit ]
+unit-test
+
+[ { ##zero-vector ##compare-vector ##merge-vector-head } ]
+[ compare-cpu int-4-rep [ emit-simd-vunpack-head ] test-emit ]
+unit-test
+
+! vunpack-tail
+[ { ##unpack-vector-tail } ]
+[ unpack-cpu int-4-rep [ emit-simd-vunpack-tail ] test-emit ]
+unit-test
+
+[ { ##tail>head-vector ##unpack-vector-head } ]
+[ unpack-head-cpu int-4-rep [ emit-simd-vunpack-tail ] test-emit ]
+unit-test
+
+[ { ##zero-vector ##merge-vector-tail } ]
+[ simple-ops-cpu uint-4-rep [ emit-simd-vunpack-tail ] test-emit ]
+unit-test
+
+[ { ##merge-vector-tail ##shr-vector-imm } ]
+[ shift-imm-cpu int-4-rep [ emit-simd-vunpack-tail ] test-emit ]
+unit-test
+
+[ { ##zero-vector ##compare-vector ##merge-vector-tail } ]
+[ compare-cpu int-4-rep [ emit-simd-vunpack-tail ] test-emit ]
+unit-test
+
+! with
+[ { ##scalar>vector ##shuffle-vector-imm } ]
+[ shuffle-imm-cpu float-4-rep [ emit-simd-with ] test-emit ]
+unit-test
+
+! gather-2
+[ { ##gather-vector-2 } ]
+[ simple-ops-cpu double-2-rep [ emit-simd-gather-2 ] test-emit ]
+unit-test
+
+! gather-4
+[ { ##gather-vector-4 } ]
+[ simple-ops-cpu float-4-rep [ emit-simd-gather-4 ] test-emit ]
+unit-test
+
+! select
+[ { ##shuffle-vector-imm ##vector>scalar } ]
+[ shuffle-imm-cpu 1 float-4-rep [ emit-simd-select ] test-emit-literal ]
+unit-test
+
+! test with nonliteral/invalid reps
+[ simple-ops-cpu [ emit-simd-v+ ] test-emit-nonliteral-rep ]
+[ bad-simd-intrinsic? ] must-fail-with
+
+[ simple-ops-cpu f [ emit-simd-v+ ] test-emit ]
+[ bad-simd-intrinsic? ] must-fail-with
+
+[ simple-ops-cpu 3 [ emit-simd-v+ ] test-emit ]
+[ bad-simd-intrinsic? ] must-fail-with
+
index a8dfaab2ddffbd2295175ed04f77633872784bdb..c75e890c27e2d0279315b300ffec44b7efb83d5f 100644 (file)
@@ -1,87 +1,67 @@
-! Copyright (C) 2009 Slava Pestov.
+! Copyright (C) 2009 Slava Pestov, Joe Groff.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors alien byte-arrays fry classes.algebra
-cpu.architecture kernel math sequences math.vectors
-math.vectors.simd.intrinsics macros generalizations combinators
-combinators.short-circuit arrays locals
-compiler.tree.propagation.info compiler.cfg.builder.blocks
+USING: accessors alien alien.c-types byte-arrays fry
+classes.algebra cpu.architecture kernel layouts math sequences
+math.vectors math.vectors.simd.intrinsics
+macros generalizations combinators combinators.short-circuit
+arrays locals compiler.tree.propagation.info
+compiler.cfg.builder.blocks
 compiler.cfg.comparisons
 compiler.cfg.stacks compiler.cfg.stacks.local compiler.cfg.hats
 compiler.cfg.instructions compiler.cfg.registers
+compiler.cfg.intrinsics
 compiler.cfg.intrinsics.alien
+compiler.cfg.intrinsics.simd.backend
 specialized-arrays ;
-FROM: alien.c-types => heap-size uchar ushort uint ulonglong float double ;
-SPECIALIZED-ARRAYS: uchar ushort uint ulonglong float double ;
+FROM: alien.c-types => heap-size char short int longlong float double ;
+SPECIALIZED-ARRAYS: char uchar short ushort int uint longlong ulonglong float double ;
 IN: compiler.cfg.intrinsics.simd
 
-MACRO: check-elements ( quots -- )
-    [ length '[ _ firstn ] ]
-    [ '[ _ spread ] ]
-    [ length 1 - \ and <repetition> [ ] like ]
-    tri 3append ;
-
-MACRO: if-literals-match ( quots -- )
-    [ length ] [ ] [ length ] tri
-    ! n quots n
-    '[
-        ! node quot
-        [
-            dup node-input-infos
-            _ tail-slice* [ literal>> ] map
-            dup _ check-elements
-        ] dip
-        swap [
-            ! node literals quot
-            [ _ firstn ] dip call
-            drop
-        ] [ 2drop emit-primitive ] if
-    ] ;
-
-: emit-vector-op ( node quot: ( rep -- ) -- )
-    { [ representation? ] } if-literals-match ; inline
-
-: [binary] ( quot -- quot' )
-    '[ [ ds-drop 2inputs ] dip @ ds-push ] ; inline
-
-: emit-binary-vector-op ( node quot -- )
-    [binary] emit-vector-op ; inline
-
-: [unary] ( quot -- quot' )
-    '[ [ ds-drop ds-pop ] dip @ ds-push ] ; inline
-
-: emit-unary-vector-op ( node quot -- )
-    [unary] emit-vector-op ; inline
-
-: [unary/param] ( quot -- quot' )
-    '[ [ -2 inc-d ds-pop ] 2dip @ ds-push ] ; inline
-
-: emit-shift-vector-imm-op ( node quot -- )
-    [unary/param]
-    { [ integer? ] [ representation? ] } if-literals-match ; inline
+! compound vector ops
 
-:: emit-shift-vector-op ( node imm-quot var-quot -- )
-    node node-input-infos 2 tail-slice* first literal>> integer?
-    [ node imm-quot emit-shift-vector-imm-op ]
-    [ node var-quot emit-binary-vector-op ] if ; inline
+: sign-bit-mask ( rep -- byte-array )
+    signed-rep {
+        { char-16-rep [ uchar-array{
+            HEX: 80 HEX: 80 HEX: 80 HEX: 80
+            HEX: 80 HEX: 80 HEX: 80 HEX: 80
+            HEX: 80 HEX: 80 HEX: 80 HEX: 80
+            HEX: 80 HEX: 80 HEX: 80 HEX: 80
+        } underlying>> ] }
+        { short-8-rep [ ushort-array{
+            HEX: 8000 HEX: 8000 HEX: 8000 HEX: 8000
+            HEX: 8000 HEX: 8000 HEX: 8000 HEX: 8000
+        } underlying>> ] }
+        { int-4-rep [ uint-array{
+            HEX: 8000,0000 HEX: 8000,0000
+            HEX: 8000,0000 HEX: 8000,0000
+        } underlying>> ] }
+        { longlong-2-rep [ ulonglong-array{
+            HEX: 8000,0000,0000,0000
+            HEX: 8000,0000,0000,0000
+        } underlying>> ] }
+    } case ;
 
-: emit-gather-vector-2 ( node -- )
-    [ ^^gather-vector-2 ] emit-binary-vector-op ;
+: ^load-neg-zero-vector ( rep -- dst )
+    {
+        { float-4-rep [ float-array{ -0.0 -0.0 -0.0 -0.0 } underlying>> ^^load-constant ] }
+        { double-2-rep [ double-array{ -0.0 -0.0 } underlying>> ^^load-constant ] }
+    } case ;
 
-: emit-gather-vector-4 ( node -- )
-    [
-        ds-drop
-        [
-            D 3 peek-loc
-            D 2 peek-loc
-            D 1 peek-loc
-            D 0 peek-loc
-            -4 inc-d
-        ] dip
-        ^^gather-vector-4
-        ds-push
-    ] emit-vector-op ;
+: ^load-add-sub-vector ( rep -- dst )
+    signed-rep {
+        { float-4-rep    [ float-array{ -0.0  0.0 -0.0  0.0 } underlying>> ^^load-constant ] }
+        { double-2-rep   [ double-array{ -0.0  0.0 } underlying>> ^^load-constant ] }
+        { char-16-rep    [ char-array{ -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 } underlying>> ^^load-constant ] }
+        { short-8-rep    [ short-array{ -1 0 -1 0 -1 0 -1 0 } underlying>> ^^load-constant ] }
+        { int-4-rep      [ int-array{ -1 0 -1 0 } underlying>> ^^load-constant ] }
+        { longlong-2-rep [ longlong-array{ -1 0 } underlying>> ^^load-constant ] }
+    } case ;
 
-: shuffle? ( obj -- ? ) { [ array? ] [ [ integer? ] all? ] } 1&& ;
+: ^load-half-vector ( rep -- dst )
+    {
+        { float-4-rep  [ float-array{  0.5 0.5 0.5 0.5 } underlying>> ^^load-constant ] }
+        { double-2-rep [ double-array{ 0.5 0.5 }         underlying>> ^^load-constant ] }
+    } case ;
 
 : >variable-shuffle ( shuffle rep -- shuffle' )
     rep-component-type heap-size
@@ -89,265 +69,600 @@ MACRO: if-literals-match ( quots -- )
     [ iota >byte-array ] bi
     '[ _ n*v _ v+ ] map concat ;
 
-: generate-shuffle-vector-imm ( src shuffle rep -- dst )
-    dup %shuffle-vector-imm-reps member?
-    [ ^^shuffle-vector-imm ]
-    [
-        [ >variable-shuffle ^^load-constant ] keep
-        ^^shuffle-vector
-    ] if ;
-
-: emit-shuffle-vector-imm ( node -- )
-    ! Pad the permutation with zeroes if it's too short, since we
-    ! can't throw an error at this point.
-    [ [ rep-components 0 pad-tail ] keep generate-shuffle-vector-imm ] [unary/param]
-    { [ shuffle? ] [ representation? ] } if-literals-match ;
-
-: emit-shuffle-vector-var ( node -- )
-    [ ^^shuffle-vector ] [binary]
-    { [ %shuffle-vector-reps member? ] } if-literals-match ;
-
-: emit-shuffle-vector ( node -- )
-    dup node-input-infos {
-        [ length 3 = ]
-        [ first  class>> byte-array class<= ]
-        [ second class>> byte-array class<= ]
-        [ third  literal>> representation?  ]
-    } 1&& [ emit-shuffle-vector-var ] [ emit-shuffle-vector-imm ] if ;
-
-: ^^broadcast-vector ( src n rep -- dst )
-    [ rep-components swap <array> ] keep
-    generate-shuffle-vector-imm ;
-
-: emit-broadcast-vector ( node -- )
-    [ ^^broadcast-vector ] [unary/param]
-    { [ integer? ] [ representation? ] } if-literals-match ;
-
-: ^^with-vector ( src rep -- dst )
-    [ ^^scalar>vector ] keep [ 0 ] dip ^^broadcast-vector ;
+: ^load-immediate-shuffle ( shuffle rep -- dst )
+    >variable-shuffle ^^load-constant ;
 
-: ^^select-vector ( src n rep -- dst )
-    [ ^^broadcast-vector ] keep ^^vector>scalar ;
-
-: emit-select-vector ( node -- )
-    [ ^^select-vector ] [unary/param]
-    { [ integer? ] [ representation? ] } if-literals-match ; inline
-
-: emit-alien-vector-op ( node quot: ( rep -- ) -- )
-    { [ %alien-vector-reps member? ] } if-literals-match ; inline
-
-: emit-alien-vector ( node -- )
-    dup [
-        '[
-            ds-drop prepare-alien-getter
-            _ ^^alien-vector ds-push
-        ]
-        [ inline-alien-getter? ] inline-alien
-    ] with emit-alien-vector-op ;
-
-: emit-set-alien-vector ( node -- )
-    dup [
-        '[
-            ds-drop prepare-alien-setter ds-pop
-            _ ##set-alien-vector
-        ]
-        [ byte-array inline-alien-setter? ]
-        inline-alien
-    ] with emit-alien-vector-op ;
+:: ^blend-vector ( mask true false rep -- dst )
+    true mask rep ^^and-vector
+    mask false rep ^^andn-vector
+    rep ^^or-vector ;
 
-: generate-not-vector ( src rep -- dst )
-    dup %not-vector-reps member?
-    [ ^^not-vector ]
-    [ [ ^^fill-vector ] [ ^^xor-vector ] bi ] if ;
+: ^not-vector ( src rep -- dst )
+    {
+        [ ^^not-vector ]
+        [ [ ^^fill-vector ] [ ^^xor-vector ] bi ]
+    } v-vector-op ;
 
-:: ((generate-compare-vector)) ( src1 src2 rep {cc,swap} -- dst )
+:: ^((compare-vector)) ( src1 src2 rep {cc,swap} -- dst )
     {cc,swap} first2 :> ( cc swap? )
     swap?
     [ src2 src1 rep cc ^^compare-vector ]
     [ src1 src2 rep cc ^^compare-vector ] if ;
 
-:: (generate-compare-vector) ( src1 src2 rep orig-cc -- dst )
+:: ^(compare-vector) ( src1 src2 rep orig-cc -- dst )
     rep orig-cc %compare-vector-ccs :> ( ccs not? )
 
     ccs empty?
     [ rep not? [ ^^fill-vector ] [ ^^zero-vector ] if ]
     [
         ccs unclip :> ( rest-ccs first-cc )
-        src1 src2 rep first-cc ((generate-compare-vector)) :> first-dst
+        src1 src2 rep first-cc ^((compare-vector)) :> first-dst
 
         rest-ccs first-dst
-        [ [ src1 src2 rep ] dip ((generate-compare-vector)) rep ^^or-vector ]
+        [ [ src1 src2 rep ] dip ^((compare-vector)) rep ^^or-vector ]
         reduce
 
-        not? [ rep generate-not-vector ] when
+        not? [ rep ^not-vector ] when
     ] if ;
 
-: sign-bit-mask ( rep -- byte-array )
-    unsign-rep {
-        { char-16-rep [ uchar-array{
-            HEX: 80 HEX: 80 HEX: 80 HEX: 80
-            HEX: 80 HEX: 80 HEX: 80 HEX: 80
-            HEX: 80 HEX: 80 HEX: 80 HEX: 80
-            HEX: 80 HEX: 80 HEX: 80 HEX: 80
-        } underlying>> ] }
-        { short-8-rep [ ushort-array{
-            HEX: 8000 HEX: 8000 HEX: 8000 HEX: 8000
-            HEX: 8000 HEX: 8000 HEX: 8000 HEX: 8000
-        } underlying>> ] }
-        { int-4-rep [ uint-array{
-            HEX: 8000,0000 HEX: 8000,0000
-            HEX: 8000,0000 HEX: 8000,0000
-        } underlying>> ] }
-        { longlong-2-rep [ ulonglong-array{
-            HEX: 8000,0000,0000,0000
-            HEX: 8000,0000,0000,0000
-        } underlying>> ] }
-    } case ;
-
-:: (generate-minmax-compare-vector) ( src1 src2 rep orig-cc -- dst )
-    orig-cc order-cc {
-        { cc<  [ src1 src2 rep ^^max-vector src1 rep cc/= (generate-compare-vector) ] }
-        { cc<= [ src1 src2 rep ^^min-vector src1 rep cc=  (generate-compare-vector) ] }
-        { cc>  [ src1 src2 rep ^^min-vector src1 rep cc/= (generate-compare-vector) ] }
-        { cc>= [ src1 src2 rep ^^max-vector src1 rep cc=  (generate-compare-vector) ] }
+:: ^minmax-compare-vector ( src1 src2 rep cc -- dst )
+    cc order-cc {
+        { cc<  [ src1 src2 rep ^^max-vector src1 rep cc/= ^(compare-vector) ] }
+        { cc<= [ src1 src2 rep ^^min-vector src1 rep cc=  ^(compare-vector) ] }
+        { cc>  [ src1 src2 rep ^^min-vector src1 rep cc/= ^(compare-vector) ] }
+        { cc>= [ src1 src2 rep ^^max-vector src1 rep cc=  ^(compare-vector) ] }
     } case ;
 
-:: generate-compare-vector ( src1 src2 rep orig-cc -- dst )
-    {
-        {
-            [ rep orig-cc %compare-vector-reps member? ]
-            [ src1 src2 rep orig-cc (generate-compare-vector) ]
-        }
-        {
-            [ rep %min-vector-reps member? ]
-            [ src1 src2 rep orig-cc (generate-minmax-compare-vector) ]
-        }
-        {
-            [ rep unsign-rep orig-cc %compare-vector-reps member? ]
-            [ 
-                rep sign-bit-mask ^^load-constant :> sign-bits
-                src1 sign-bits rep ^^xor-vector
-                src2 sign-bits rep ^^xor-vector
-                rep unsign-rep orig-cc (generate-compare-vector)
-            ]
-        }
-    } cond ;
-
-:: generate-unpack-vector-head ( src rep -- dst )
-    {
-        {
-            [ rep %unpack-vector-head-reps member? ]
-            [ src rep ^^unpack-vector-head ]
-        }
-        {
-            [ rep unsigned-int-vector-rep? ]
-            [
-                rep ^^zero-vector :> zero
-                src zero rep ^^merge-vector-head
-            ]
-        }
-        {
-            [ rep widen-vector-rep %shr-vector-imm-reps member? ]
-            [
-                src src rep ^^merge-vector-head
-                rep rep-component-type
-                heap-size 8 * rep widen-vector-rep ^^shr-vector-imm
-            ]
-        }
-        [
+: ^compare-vector ( src1 src2 rep cc -- dst )
+    {
+        [ ^(compare-vector) ]
+        [ ^minmax-compare-vector ]
+        { unsigned-int-vector-rep [| src1 src2 rep cc |
+            rep sign-bit-mask ^^load-constant :> sign-bits
+            src1 sign-bits rep ^^xor-vector
+            src2 sign-bits rep ^^xor-vector
+            rep signed-rep cc ^(compare-vector)
+        ] }
+    } vv-cc-vector-op ;
+
+: ^unpack-vector-head ( src rep -- dst )
+    {
+        [ ^^unpack-vector-head ]
+        { unsigned-int-vector-rep [ [ ^^zero-vector ] [ ^^merge-vector-head ] bi ] }
+        { signed-int-vector-rep [| src rep |
+            src src rep ^^merge-vector-head :> merged
+            rep rep-component-type heap-size 8 * :> bits
+            merged bits rep widen-vector-rep ^^shr-vector-imm
+        ] }
+        { signed-int-vector-rep [| src rep |
             rep ^^zero-vector :> zero
-            zero src rep cc> ^^compare-vector :> sign
+            zero src rep cc> ^compare-vector :> sign
             src sign rep ^^merge-vector-head
-        ] 
-    } cond ;
-
-:: generate-unpack-vector-tail ( src rep -- dst )
-    {
-        {
-            [ rep %unpack-vector-tail-reps member? ]
-            [ src rep ^^unpack-vector-tail ]
-        }
-        {
-            [ rep %unpack-vector-head-reps member? ]
-            [
-                src rep ^^tail>head-vector :> tail
-                tail rep ^^unpack-vector-head
-            ]
-        }
-        {
-            [ rep unsigned-int-vector-rep? ]
-            [
-                rep ^^zero-vector :> zero
-                src zero rep ^^merge-vector-tail
-            ]
-        }
-        {
-            [ rep widen-vector-rep %shr-vector-imm-reps member? ]
-            [
-                src src rep ^^merge-vector-tail
-                rep rep-component-type
-                heap-size 8 * rep widen-vector-rep ^^shr-vector-imm
-            ]
-        }
-        [
+        ] }
+    } v-vector-op ;
+
+: ^unpack-vector-tail ( src rep -- dst )
+    {
+        [ ^^unpack-vector-tail ]
+        [ [ ^^tail>head-vector ] [ ^^unpack-vector-head ] bi ]
+        { unsigned-int-vector-rep [ [ ^^zero-vector ] [ ^^merge-vector-tail ] bi ] }
+        { signed-int-vector-rep [| src rep |
+            src src rep ^^merge-vector-tail :> merged
+            rep rep-component-type heap-size 8 * :> bits
+            merged bits rep widen-vector-rep ^^shr-vector-imm
+        ] }
+        { signed-int-vector-rep [| src rep |
             rep ^^zero-vector :> zero
-            zero src rep cc> ^^compare-vector :> sign
+            zero src rep cc> ^compare-vector :> sign
             src sign rep ^^merge-vector-tail
-        ] 
-    } cond ;
+        ] }
+    } v-vector-op ;
 
-:: generate-load-neg-zero-vector ( rep -- dst )
-    rep {
-        { float-4-rep [ float-array{ -0.0 -0.0 -0.0 -0.0 } underlying>> ^^load-constant ] }
-        { double-2-rep [ double-array{ -0.0 -0.0 } underlying>> ^^load-constant ] }
-        [ drop rep ^^zero-vector ]
-    } case ;
+PREDICATE: fixnum-vector-rep < int-vector-rep
+    rep-component-type heap-size cell < ;
 
-:: generate-neg-vector ( src rep -- dst )
-    rep generate-load-neg-zero-vector
-    src rep ^^sub-vector ;
+: ^(sum-vector-2) ( src rep -- dst )
+    {
+        [ dupd ^^horizontal-add-vector ]
+        [| src rep | 
+            src src rep ^^merge-vector-head :> head
+            src src rep ^^merge-vector-tail :> tail
+            head tail rep ^^add-vector
+        ]
+    } v-vector-op ;
 
-:: generate-blend-vector ( mask true false rep -- dst )
-    mask true rep ^^and-vector
-    mask false rep ^^andn-vector
-    rep ^^or-vector ;
+: ^(sum-vector-4) ( src rep -- dst )
+    {
+        [
+            [ dupd ^^horizontal-add-vector ]
+            [ dupd ^^horizontal-add-vector ] bi
+        ]
+        [| src rep | 
+            src src rep ^^merge-vector-head :> head
+            src src rep ^^merge-vector-tail :> tail
+            head tail rep ^^add-vector :> src'
+
+            rep widen-vector-rep :> rep'
+            src' src' rep' ^^merge-vector-head :> head'
+            src' src' rep' ^^merge-vector-tail :> tail'
+            head' tail' rep ^^add-vector
+        ]
+    } v-vector-op ;
+
+: ^(sum-vector-8) ( src rep -- dst )
+    {
+        [
+            [ dupd ^^horizontal-add-vector ]
+            [ dupd ^^horizontal-add-vector ]
+            [ dupd ^^horizontal-add-vector ] tri
+        ]
+        [| src rep | 
+            src src rep ^^merge-vector-head :> head
+            src src rep ^^merge-vector-tail :> tail
+            head tail rep ^^add-vector :> src'
+
+            rep widen-vector-rep :> rep'
+            src' src' rep' ^^merge-vector-head :> head'
+            src' src' rep' ^^merge-vector-tail :> tail'
+            head' tail' rep ^^add-vector :> src''
+
+            rep' widen-vector-rep :> rep''
+            src'' src'' rep'' ^^merge-vector-head :> head''
+            src'' src'' rep'' ^^merge-vector-tail :> tail''
+            head'' tail'' rep ^^add-vector
+        ]
+    } v-vector-op ;
+
+: ^(sum-vector-16) ( src rep -- dst )
+    {
+        [
+            {
+                [ dupd ^^horizontal-add-vector ]
+                [ dupd ^^horizontal-add-vector ]
+                [ dupd ^^horizontal-add-vector ]
+                [ dupd ^^horizontal-add-vector ]
+            } cleave
+        ]
+        [| src rep | 
+            src src rep ^^merge-vector-head :> head
+            src src rep ^^merge-vector-tail :> tail
+            head tail rep ^^add-vector :> src'
+
+            rep widen-vector-rep :> rep'
+            src' src' rep' ^^merge-vector-head :> head'
+            src' src' rep' ^^merge-vector-tail :> tail'
+            head' tail' rep ^^add-vector :> src''
+
+            rep' widen-vector-rep :> rep''
+            src'' src'' rep'' ^^merge-vector-head :> head''
+            src'' src'' rep'' ^^merge-vector-tail :> tail''
+            head'' tail'' rep ^^add-vector :> src'''
+
+            rep'' widen-vector-rep :> rep'''
+            src''' src''' rep''' ^^merge-vector-head :> head'''
+            src''' src''' rep''' ^^merge-vector-tail :> tail'''
+            head''' tail''' rep ^^add-vector
+        ]
+    } v-vector-op ;
+
+: ^(sum-vector) ( src rep -- dst )
+    [
+        dup rep-length {
+            {  2 [ ^(sum-vector-2) ] }
+            {  4 [ ^(sum-vector-4) ] }
+            {  8 [ ^(sum-vector-8) ] }
+            { 16 [ ^(sum-vector-16) ] }
+        } case
+    ] [ ^^vector>scalar ] bi ;
+
+: ^sum-vector ( src rep -- dst )
+    {
+        { float-vector-rep [ ^(sum-vector) ] }
+        { fixnum-vector-rep [| src rep |
+            src rep ^unpack-vector-head :> head
+            src rep ^unpack-vector-tail :> tail
+            rep widen-vector-rep :> wide-rep
+            head tail wide-rep ^^add-vector wide-rep
+            ^(sum-vector)
+        ] }
+    } v-vector-op ;
+
+: shuffle? ( obj -- ? ) { [ array? ] [ [ integer? ] all? ] } 1&& ;
+
+: ^shuffle-vector-imm ( src1 shuffle rep -- dst )
+    [ rep-length 0 pad-tail ] keep {
+        [ ^^shuffle-vector-imm ]
+        [ [ ^load-immediate-shuffle ] [ ^^shuffle-vector ] bi ]
+    } vl-vector-op ;
 
-:: generate-abs-vector ( src rep -- dst )
-    {
-        {
-            [ rep unsigned-int-vector-rep? ]
-            [ src ]
-        }
-        {
-            [ rep %abs-vector-reps member? ]
-            [ src rep ^^abs-vector ]
-        }
-        {
-            [ rep float-vector-rep? ]
-            [
-                rep generate-load-neg-zero-vector
-                src rep ^^andn-vector
-            ]
-        }
-        [ 
+: ^broadcast-vector ( src n rep -- dst )
+    [ rep-length swap <array> ] keep
+    ^shuffle-vector-imm ;
+
+: ^with-vector ( src rep -- dst )
+    [ ^^scalar>vector ] keep [ 0 ] dip ^broadcast-vector ;
+
+: ^select-vector ( src n rep -- dst )
+    [ ^broadcast-vector ] keep ^^vector>scalar ;
+
+! intrinsic emitters
+
+: emit-simd-v+ ( node -- )
+    {
+        [ ^^add-vector ]
+    } emit-vv-vector-op ;
+
+: emit-simd-v- ( node -- )
+    {
+        [ ^^sub-vector ]
+    } emit-vv-vector-op ;
+
+: emit-simd-vneg ( node -- )
+    {
+        { float-vector-rep [ [ ^load-neg-zero-vector swap ] [ ^^sub-vector ] bi ] }
+        { int-vector-rep   [ [ ^^zero-vector         swap ] [ ^^sub-vector ] bi ] }
+    } emit-v-vector-op ;
+
+: emit-simd-v+- ( node -- )
+    {
+        [ ^^add-sub-vector ]
+        { float-vector-rep [| src1 src2 rep |
+            rep ^load-add-sub-vector :> signs
+            src2 signs rep ^^xor-vector :> src2'
+            src1 src2' rep ^^add-vector
+        ] }
+        { int-vector-rep   [| src1 src2 rep |
+            rep ^load-add-sub-vector :> signs
+            src2  signs rep ^^xor-vector :> src2'
+            src2' signs rep ^^sub-vector :> src2''
+            src1 src2'' rep ^^add-vector
+        ] }
+    } emit-vv-vector-op ;
+
+: emit-simd-vs+ ( node -- )
+    {
+        { float-vector-rep [ ^^add-vector ] }
+        { int-vector-rep [ ^^saturated-add-vector ] }
+    } emit-vv-vector-op ;
+
+: emit-simd-vs- ( node -- )
+    {
+        { float-vector-rep [ ^^sub-vector ] }
+        { int-vector-rep [ ^^saturated-sub-vector ] }
+    } emit-vv-vector-op ;
+
+: emit-simd-vs* ( node -- )
+    {
+        { float-vector-rep [ ^^mul-vector ] }
+        { int-vector-rep [ ^^saturated-mul-vector ] }
+    } emit-vv-vector-op ;
+
+: emit-simd-v* ( node -- )
+    {
+        [ ^^mul-vector ]
+    } emit-vv-vector-op ;
+
+: emit-simd-v*high ( node -- )
+    {
+        [ ^^mul-high-vector ]
+    } emit-vv-vector-op ;
+
+: emit-simd-v*hs+ ( node -- )
+    {
+        [ ^^mul-horizontal-add-vector ]
+    } emit-vv-vector-op ;
+
+: emit-simd-v/ ( node -- )
+    {
+        [ ^^div-vector ]
+    } emit-vv-vector-op ;
+
+: emit-simd-vmin ( node -- )
+    {
+        [ ^^min-vector ]
+        [
+            [ cc< ^compare-vector ]
+            [ ^blend-vector ] 3bi
+        ]
+    } emit-vv-vector-op ;
+
+: emit-simd-vmax ( node -- )
+    {
+        [ ^^max-vector ]
+        [
+            [ cc> ^compare-vector ]
+            [ ^blend-vector ] 3bi
+        ]
+    } emit-vv-vector-op ;
+
+: emit-simd-vavg ( node -- )
+    {
+        [ ^^avg-vector ]
+        { float-vector-rep [| src1 src2 rep |
+            src1 src2 rep ^^add-vector
+            rep ^load-half-vector rep ^^mul-vector
+        ] }
+    } emit-vv-vector-op ;
+
+: emit-simd-v. ( node -- )
+    {
+        [ ^^dot-vector ]
+        { float-vector-rep [ [ ^^mul-vector ] [ ^sum-vector ] bi ] }
+    } emit-vv-vector-op ;
+
+: emit-simd-vsad ( node -- )
+    {
+        [
+            [ ^^sad-vector dup { 2 3 0 1 } int-4-rep ^^shuffle-vector-imm int-4-rep ^^add-vector ]
+            [ widen-vector-rep ^^vector>scalar ] bi
+        ]
+    } emit-vv-vector-op ;
+
+: emit-simd-vsqrt ( node -- )
+    {
+        [ ^^sqrt-vector ]
+    } emit-v-vector-op ;
+
+: emit-simd-sum ( node -- )
+    {
+        [ ^sum-vector ]
+    } emit-v-vector-op ;
+
+: emit-simd-vabs ( node -- )
+    {
+        { unsigned-int-vector-rep [ drop ] }
+        [ ^^abs-vector ]
+        { float-vector-rep [ [ ^load-neg-zero-vector ] [ swapd ^^andn-vector ] bi ] }
+        { int-vector-rep [| src rep |
             rep ^^zero-vector :> zero
             zero src rep ^^sub-vector :> -src
-            zero src rep cc> ^^compare-vector :> sign 
-            sign -src src rep generate-blend-vector
-        ]
-    } cond ;
+            zero src rep cc> ^compare-vector :> sign
+            sign -src src rep ^blend-vector
+        ] }
+    } emit-v-vector-op ;
 
-: generate-min-vector ( src1 src2 rep -- dst )
-    dup %min-vector-reps member?
-    [ ^^min-vector ] [
-        [ cc< generate-compare-vector ]
-        [ generate-blend-vector ] 3bi
-    ] if ;
+: emit-simd-vand ( node -- )
+    {
+        [ ^^and-vector ]
+    } emit-vv-vector-op ;
 
-: generate-max-vector ( src1 src2 rep -- dst )
-    dup %max-vector-reps member?
-    [ ^^max-vector ] [
-        [ cc> generate-compare-vector ]
-        [ generate-blend-vector ] 3bi
-    ] if ;
+: emit-simd-vandn ( node -- )
+    {
+        [ ^^andn-vector ]
+    } emit-vv-vector-op ;
+
+: emit-simd-vor ( node -- )
+    {
+        [ ^^or-vector ]
+    } emit-vv-vector-op ;
+
+: emit-simd-vxor ( node -- )
+    {
+        [ ^^xor-vector ]
+    } emit-vv-vector-op ;
 
+: emit-simd-vnot ( node -- )
+    {
+        [ ^not-vector ]
+    } emit-v-vector-op ;
+
+: emit-simd-vlshift ( node -- )
+    {
+        [ ^^shl-vector ]
+    } {
+        [ ^^shl-vector-imm ]
+    } [ integer? ] emit-vv-or-vl-vector-op ;
+
+: emit-simd-vrshift ( node -- )
+    {
+        [ ^^shr-vector ]
+    } {
+        [ ^^shr-vector-imm ]
+    } [ integer? ] emit-vv-or-vl-vector-op ;
+
+: emit-simd-hlshift ( node -- )
+    {
+        [ ^^horizontal-shl-vector-imm ]
+    } [ integer? ] emit-vl-vector-op ;
+
+: emit-simd-hrshift ( node -- )
+    {
+        [ ^^horizontal-shr-vector-imm ]
+    } [ integer? ] emit-vl-vector-op ;
+
+: emit-simd-vshuffle-elements ( node -- )
+    {
+        [ ^shuffle-vector-imm ]
+    } [ shuffle? ] emit-vl-vector-op ;
+
+: emit-simd-vshuffle-bytes ( node -- )
+    {
+        [ ^^shuffle-vector ]
+    } emit-vv-vector-op ;
+
+: emit-simd-vmerge-head ( node -- )
+    {
+        [ ^^merge-vector-head ]
+    } emit-vv-vector-op ;
+
+: emit-simd-vmerge-tail ( node -- )
+    {
+        [ ^^merge-vector-tail ]
+    } emit-vv-vector-op ;
+
+: emit-simd-v<= ( node -- )
+    {
+        [ cc<= ^compare-vector ]
+    } emit-vv-vector-op ;
+: emit-simd-v< ( node -- )
+    {
+        [ cc< ^compare-vector ]
+    } emit-vv-vector-op ;
+: emit-simd-v= ( node -- )
+    {
+        [ cc=  ^compare-vector ]
+    } emit-vv-vector-op ;
+: emit-simd-v> ( node -- )
+    {
+        [ cc>  ^compare-vector ]
+    } emit-vv-vector-op ;
+: emit-simd-v>= ( node -- )
+    {
+        [ cc>= ^compare-vector ]
+    } emit-vv-vector-op ;
+: emit-simd-vunordered? ( node -- )
+    {
+        [ cc/<>= ^compare-vector ]
+    } emit-vv-vector-op ;
+
+: emit-simd-vany? ( node -- )
+    {
+        [ vcc-any ^^test-vector ]
+    } emit-v-vector-op ;
+: emit-simd-vall? ( node -- )
+    {
+        [ vcc-all ^^test-vector ]
+    } emit-v-vector-op ;
+: emit-simd-vnone? ( node -- )
+    {
+        [ vcc-none ^^test-vector ]
+    } emit-v-vector-op ;
+
+: emit-simd-v>float ( node -- )
+    {
+        { float-vector-rep [ drop ] }
+        { int-vector-rep [ ^^integer>float-vector ] }
+    } emit-v-vector-op ;
+
+: emit-simd-v>integer ( node -- )
+    {
+        { float-vector-rep [ ^^float>integer-vector ] }
+        { int-vector-rep [ drop ] }
+    } emit-v-vector-op ;
+
+: emit-simd-vpack-signed ( node -- )
+    {
+        [ ^^signed-pack-vector ]
+    } emit-vv-vector-op ;
+
+: emit-simd-vpack-unsigned ( node -- )
+    {
+        [ ^^unsigned-pack-vector ]
+    } emit-vv-vector-op ;
+
+: emit-simd-vunpack-head ( node -- )
+    {
+        [ ^unpack-vector-head ]
+    } emit-v-vector-op ;
+
+: emit-simd-vunpack-tail ( node -- )
+    {
+        [ ^unpack-vector-tail ]
+    } emit-v-vector-op ;
+
+: emit-simd-with ( node -- )
+    {
+        { fixnum-vector-rep [ ^with-vector ] }
+        { float-vector-rep  [ ^with-vector ] }
+    } emit-v-vector-op ;
+
+: emit-simd-gather-2 ( node -- )
+    {
+        { fixnum-vector-rep [ ^^gather-vector-2 ] }
+        { float-vector-rep  [ ^^gather-vector-2 ] }
+    } emit-vv-vector-op ;
+
+: emit-simd-gather-4 ( node -- )
+    {
+        { fixnum-vector-rep [ ^^gather-vector-4 ] }
+        { float-vector-rep  [ ^^gather-vector-4 ] }
+    } emit-vvvv-vector-op ;
+
+: emit-simd-select ( node -- )
+    {
+        { fixnum-vector-rep [ ^select-vector ] }
+        { float-vector-rep  [ ^select-vector ] }
+    } [ integer? ] emit-vl-vector-op ;
+
+: emit-alien-vector ( node -- )
+    dup [
+        '[
+            ds-drop prepare-alien-getter
+            _ ^^alien-vector ds-push
+        ]
+        [ inline-alien-getter? ] inline-alien
+    ] with { [ %alien-vector-reps member? ] } if-literals-match ;
+
+: emit-set-alien-vector ( node -- )
+    dup [
+        '[
+            ds-drop prepare-alien-setter ds-pop
+            _ ##set-alien-vector
+        ]
+        [ byte-array inline-alien-setter? ]
+        inline-alien
+    ] with { [ %alien-vector-reps member? ] } if-literals-match ;
+
+: enable-simd ( -- )
+    {
+        { (simd-v+)                [ emit-simd-v+                  ] }
+        { (simd-v-)                [ emit-simd-v-                  ] }
+        { (simd-vneg)              [ emit-simd-vneg                ] }
+        { (simd-v+-)               [ emit-simd-v+-                 ] }
+        { (simd-vs+)               [ emit-simd-vs+                 ] }
+        { (simd-vs-)               [ emit-simd-vs-                 ] }
+        { (simd-vs*)               [ emit-simd-vs*                 ] }
+        { (simd-v*)                [ emit-simd-v*                  ] }
+        { (simd-v*high)            [ emit-simd-v*high              ] }
+        { (simd-v*hs+)             [ emit-simd-v*hs+               ] }
+        { (simd-v/)                [ emit-simd-v/                  ] }
+        { (simd-vmin)              [ emit-simd-vmin                ] }
+        { (simd-vmax)              [ emit-simd-vmax                ] }
+        { (simd-vavg)              [ emit-simd-vavg                ] }
+        { (simd-v.)                [ emit-simd-v.                  ] }
+        { (simd-vsad)              [ emit-simd-vsad                ] }
+        { (simd-vsqrt)             [ emit-simd-vsqrt               ] }
+        { (simd-sum)               [ emit-simd-sum                 ] }
+        { (simd-vabs)              [ emit-simd-vabs                ] }
+        { (simd-vbitand)           [ emit-simd-vand                ] }
+        { (simd-vbitandn)          [ emit-simd-vandn               ] }
+        { (simd-vbitor)            [ emit-simd-vor                 ] }
+        { (simd-vbitxor)           [ emit-simd-vxor                ] }
+        { (simd-vbitnot)           [ emit-simd-vnot                ] }
+        { (simd-vand)              [ emit-simd-vand                ] }
+        { (simd-vandn)             [ emit-simd-vandn               ] }
+        { (simd-vor)               [ emit-simd-vor                 ] }
+        { (simd-vxor)              [ emit-simd-vxor                ] }
+        { (simd-vnot)              [ emit-simd-vnot                ] }
+        { (simd-vlshift)           [ emit-simd-vlshift             ] }
+        { (simd-vrshift)           [ emit-simd-vrshift             ] }
+        { (simd-hlshift)           [ emit-simd-hlshift             ] }
+        { (simd-hrshift)           [ emit-simd-hrshift             ] }
+        { (simd-vshuffle-elements) [ emit-simd-vshuffle-elements   ] }
+        { (simd-vshuffle-bytes)    [ emit-simd-vshuffle-bytes      ] }
+        { (simd-vmerge-head)       [ emit-simd-vmerge-head         ] }
+        { (simd-vmerge-tail)       [ emit-simd-vmerge-tail         ] }
+        { (simd-v<=)               [ emit-simd-v<=                 ] }
+        { (simd-v<)                [ emit-simd-v<                  ] }
+        { (simd-v=)                [ emit-simd-v=                  ] }
+        { (simd-v>)                [ emit-simd-v>                  ] }
+        { (simd-v>=)               [ emit-simd-v>=                 ] }
+        { (simd-vunordered?)       [ emit-simd-vunordered?         ] }
+        { (simd-vany?)             [ emit-simd-vany?               ] }
+        { (simd-vall?)             [ emit-simd-vall?               ] }
+        { (simd-vnone?)            [ emit-simd-vnone?              ] }
+        { (simd-v>float)           [ emit-simd-v>float             ] }
+        { (simd-v>integer)         [ emit-simd-v>integer           ] }
+        { (simd-vpack-signed)      [ emit-simd-vpack-signed        ] }
+        { (simd-vpack-unsigned)    [ emit-simd-vpack-unsigned      ] }
+        { (simd-vunpack-head)      [ emit-simd-vunpack-head        ] }
+        { (simd-vunpack-tail)      [ emit-simd-vunpack-tail        ] }
+        { (simd-with)              [ emit-simd-with                ] }
+        { (simd-gather-2)          [ emit-simd-gather-2            ] }
+        { (simd-gather-4)          [ emit-simd-gather-4            ] }
+        { (simd-select)            [ emit-simd-select              ] }
+        { alien-vector             [ emit-alien-vector             ] }
+        { set-alien-vector         [ emit-set-alien-vector         ] }
+    } enable-intrinsics ;
+
+enable-simd
index 1424aba354d968557e51db6ec316f3d5bee12b8c..1ceac4990ace32a93fdea8342e6af3bf07474b3c 100644 (file)
@@ -1,14 +1,17 @@
 ! Copyright (C) 2008, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: layouts namespaces kernel accessors sequences math
-classes.algebra locals combinators cpu.architecture
-compiler.tree.propagation.info compiler.cfg.stacks
-compiler.cfg.hats compiler.cfg.registers
+classes.algebra classes.builtin locals combinators
+cpu.architecture compiler.tree.propagation.info
+compiler.cfg.stacks compiler.cfg.hats compiler.cfg.registers
 compiler.cfg.instructions compiler.cfg.utilities
 compiler.cfg.builder.blocks compiler.constants ;
 IN: compiler.cfg.intrinsics.slots
 
-: value-tag ( info -- n ) class>> class-type ; inline
+: class-tag ( class -- tag/f )
+    builtins get [ class<= ] with find drop ;
+
+: value-tag ( info -- n ) class>> class-tag ;
 
 : ^^tag-offset>slot ( slot tag -- vreg' )
     [ ^^offset>slot ] dip ^^sub-imm ;
index 23646cfcd7bd274336ba1ec5e1a4c9f38830e876..020d000b6aeb10027e2115e315346bf50ced4d85 100644 (file)
@@ -15,7 +15,7 @@ V{
 
 [
     V{
-        T{ ##save-context f 1 2 }
+        T{ ##save-context f 1 2 }
         T{ ##unary-float-function f 2 3 "sqrt" }
         T{ ##branch }
     }
index fd92ace1507937b92a97544793cbfef0a2947dec..c7b6db06715000941bc0255c73fd769d382ab4df 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2009 Slava Pestov.
+! Copyright (C) 2009, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors combinators.short-circuit
 compiler.cfg.instructions compiler.cfg.registers
@@ -14,14 +14,7 @@ IN: compiler.cfg.save-contexts
             [ ##binary-float-function? ]
             [ ##alien-invoke? ]
             [ ##alien-indirect? ]
-        } 1||
-    ] any? ;
-
-: needs-callback-context? ( insns -- ? )
-    [
-        {
-            [ ##alien-invoke? ]
-            [ ##alien-indirect? ]
+            [ ##alien-assembly? ]
         } 1||
     ] any? ;
 
@@ -29,7 +22,6 @@ IN: compiler.cfg.save-contexts
     dup instructions>> dup needs-save-context? [
         int-rep next-vreg-rep
         int-rep next-vreg-rep
-        pick needs-callback-context?
         \ ##save-context new-insn prefix
         >>instructions drop
     ] [ 2drop ] if ;
old mode 100755 (executable)
new mode 100644 (file)
index ce673ba..6cf362c
@@ -1,4 +1,4 @@
-! Copyright (C) 2008, 2009 Slava Pestov.
+! Copyright (C) 2008, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: math sequences kernel namespaces accessors biassocs compiler.cfg
 compiler.cfg.instructions compiler.cfg.registers compiler.cfg.hats
@@ -33,7 +33,7 @@ IN: compiler.cfg.stacks
 : ds-load ( n -- vregs )
     dup 0 =
     [ drop f ]
-    [ [ <reversed> [ <ds-loc> peek-loc ] map ] [ neg inc-d ] bi ] if ;
+    [ [ iota <reversed> [ <ds-loc> peek-loc ] map ] [ neg inc-d ] bi ] if ;
 
 : ds-store ( vregs -- )
     [
index 0bed759e5286d615932726245ce860e5f772f123..e5fbfa6c40bcbafa674be12d46eb07044682a640 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2009 Slava Pestov.
+! Copyright (C) 2009, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel sequences byte-arrays namespaces accessors classes math
 math.order fry arrays combinators compiler.cfg.registers
@@ -55,7 +55,7 @@ M: insn visit-insn drop ;
     2dup [ length ] bi@ max '[ _ 1 pad-tail ] bi@ [ bitand ] 2map ;
 
 : (uninitialized-locs) ( seq quot -- seq' )
-    [ dup length [ drop 0 = ] pusher [ 2each ] dip ] dip map ; inline
+    [ [ drop 0 = ] pusher [ each-index ] dip ] dip map ; inline
 
 PRIVATE>
 
index 6534aa74ab07b90f81cafde06e19c216f93d35e2..d2e7c2ac864fd48a0ff07e0ffb3265ead010cdd1 100644 (file)
@@ -27,6 +27,9 @@ C: <reference> reference-expr
 M: reference-expr equal?
     over reference-expr? [ [ value>> ] bi@ eq? ] [ 2drop f ] if ;
 
+M: reference-expr hashcode*
+    nip value>> identity-hashcode ;
+
 : constant>vn ( constant -- vn ) <constant> expr>vn ; inline
 
 GENERIC: >expr ( insn -- expr )
old mode 100755 (executable)
new mode 100644 (file)
index 4864a8b..0fa0314
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors combinators combinators.short-circuit arrays
 fry kernel layouts math namespaces sequences cpu.architecture
-math.bitwise math.order math.vectors.simd.intrinsics classes
+math.bitwise math.order classes
 vectors locals make alien.c-types io.binary grouping
 compiler.cfg
 compiler.cfg.registers
@@ -42,6 +42,14 @@ M: insn rewrite drop f ;
     ] [ drop f ] if ; inline
 
 : general-compare-expr? ( insn -- ? )
+    {
+        [ compare-expr? ]
+        [ compare-imm-expr? ]
+        [ compare-float-unordered-expr? ]
+        [ compare-float-ordered-expr? ]
+    } 1|| ;
+
+: general-or-vector-compare-expr? ( insn -- ? )
     {
         [ compare-expr? ]
         [ compare-imm-expr? ]
@@ -52,7 +60,7 @@ M: insn rewrite drop f ;
 
 : rewrite-boolean-comparison? ( insn -- ? )
     dup ##branch-t? [
-        src1>> vreg>expr general-compare-expr?
+        src1>> vreg>expr general-or-vector-compare-expr?
     ] [ drop f ] if ; inline
  
 : >compare-expr< ( expr -- in1 in2 cc )
@@ -463,100 +471,9 @@ M: ##alien-signed-2 rewrite rewrite-alien-addressing ;
 M: ##alien-signed-4 rewrite rewrite-alien-addressing ;
 M: ##alien-float rewrite rewrite-alien-addressing ;
 M: ##alien-double rewrite rewrite-alien-addressing ;
-M: ##alien-vector rewrite rewrite-alien-addressing ;
 M: ##set-alien-integer-1 rewrite rewrite-alien-addressing ;
 M: ##set-alien-integer-2 rewrite rewrite-alien-addressing ;
 M: ##set-alien-integer-4 rewrite rewrite-alien-addressing ;
 M: ##set-alien-float rewrite rewrite-alien-addressing ;
 M: ##set-alien-double rewrite rewrite-alien-addressing ;
-M: ##set-alien-vector rewrite rewrite-alien-addressing ;
-
-! Some lame constant folding for SIMD intrinsics. Eventually this
-! should be redone completely.
-
-: rewrite-shuffle-vector-imm ( insn expr -- insn' )
-    2dup [ rep>> ] bi@ eq? [
-        [ [ dst>> ] [ src>> vn>vreg ] bi* ]
-        [ [ shuffle>> ] bi@ nths ]
-        [ drop rep>> ]
-        2tri \ ##shuffle-vector-imm new-insn
-    ] [ 2drop f ] if ;
-
-: (fold-shuffle-vector-imm) ( shuffle bytes -- bytes' )
-    2dup length swap length /i group nths concat ;
-
-: fold-shuffle-vector-imm ( insn expr -- insn' )
-    [ [ dst>> ] [ shuffle>> ] bi ] dip value>>
-    (fold-shuffle-vector-imm) \ ##load-constant new-insn ;
-
-M: ##shuffle-vector-imm rewrite
-    dup src>> vreg>expr {
-        { [ dup shuffle-vector-imm-expr? ] [ rewrite-shuffle-vector-imm ] }
-        { [ dup reference-expr? ] [ fold-shuffle-vector-imm ] }
-        { [ dup constant-expr? ] [ fold-shuffle-vector-imm ] }
-        [ 2drop f ]
-    } cond ;
-
-: (fold-scalar>vector) ( insn bytes -- insn' )
-    [ [ dst>> ] [ rep>> rep-components ] bi ] dip <repetition> concat
-    \ ##load-constant new-insn ;
 
-: fold-scalar>vector ( insn expr -- insn' )
-    value>> over rep>> {
-        { float-4-rep [ float>bits 4 >le (fold-scalar>vector) ] }
-        { double-2-rep [ double>bits 8 >le (fold-scalar>vector) ] }
-        [ [ untag-fixnum ] dip rep-component-type heap-size >le (fold-scalar>vector) ]
-    } case ;
-
-M: ##scalar>vector rewrite
-    dup src>> vreg>expr dup constant-expr?
-    [ fold-scalar>vector ] [ 2drop f ] if ;
-
-M: ##xor-vector rewrite
-    dup [ src1>> vreg>vn ] [ src2>> vreg>vn ] bi eq?
-    [ [ dst>> ] [ rep>> ] bi \ ##zero-vector new-insn ] [ drop f ] if ;
-
-: vector-not? ( expr -- ? )
-    {
-        [ not-vector-expr? ]
-        [ {
-            [ xor-vector-expr? ]
-            [ [ src1>> ] [ src2>> ] bi [ vn>expr fill-vector-expr? ] either? ]
-        } 1&& ]
-    } 1|| ;
-
-GENERIC: vector-not-src ( expr -- vreg )
-M: not-vector-expr vector-not-src src>> vn>vreg ;
-M: xor-vector-expr vector-not-src
-    dup src1>> vn>expr fill-vector-expr? [ src2>> ] [ src1>> ] if vn>vreg ;
-
-M: ##and-vector rewrite 
-    {
-        { [ dup src1>> vreg>expr vector-not? ] [
-            {
-                [ dst>> ]
-                [ src1>> vreg>expr vector-not-src ]
-                [ src2>> ]
-                [ rep>> ]
-            } cleave \ ##andn-vector new-insn
-        ] }
-        { [ dup src2>> vreg>expr vector-not? ] [
-            {
-                [ dst>> ]
-                [ src2>> vreg>expr vector-not-src ]
-                [ src1>> ]
-                [ rep>> ]
-            } cleave \ ##andn-vector new-insn
-        ] }
-        [ drop f ]
-    } cond ;
-
-M: ##andn-vector rewrite
-    dup src1>> vreg>expr vector-not? [
-        {
-            [ dst>> ]
-            [ src1>> vreg>expr vector-not-src ]
-            [ src2>> ]
-            [ rep>> ]
-        } cleave \ ##and-vector new-insn
-    ] [ drop f ] if ;
diff --git a/basis/compiler/cfg/value-numbering/simd/simd.factor b/basis/compiler/cfg/value-numbering/simd/simd.factor
new file mode 100644 (file)
index 0000000..16d38bc
--- /dev/null
@@ -0,0 +1,120 @@
+! Copyright (C) 2008, 2009 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: accessors combinators combinators.short-circuit arrays
+fry kernel layouts math namespaces sequences cpu.architecture
+math.bitwise math.order classes
+vectors locals make alien.c-types io.binary grouping
+math.vectors.simd.intrinsics
+compiler.cfg
+compiler.cfg.registers
+compiler.cfg.comparisons
+compiler.cfg.instructions
+compiler.cfg.value-numbering.expressions
+compiler.cfg.value-numbering.graph
+compiler.cfg.value-numbering.rewrite
+compiler.cfg.value-numbering.simplify ;
+IN: compiler.cfg.value-numbering.simd
+
+M: ##alien-vector rewrite rewrite-alien-addressing ;
+M: ##set-alien-vector rewrite rewrite-alien-addressing ;
+
+! Some lame constant folding for SIMD intrinsics. Eventually this
+! should be redone completely.
+
+: rewrite-shuffle-vector-imm ( insn expr -- insn' )
+    2dup [ rep>> ] bi@ eq? [
+        [ [ dst>> ] [ src>> vn>vreg ] bi* ]
+        [ [ shuffle>> ] bi@ nths ]
+        [ drop rep>> ]
+        2tri \ ##shuffle-vector-imm new-insn
+    ] [ 2drop f ] if ;
+
+: (fold-shuffle-vector-imm) ( shuffle bytes -- bytes' )
+    2dup length swap length /i group nths concat ;
+
+: fold-shuffle-vector-imm ( insn expr -- insn' )
+    [ [ dst>> ] [ shuffle>> ] bi ] dip value>>
+    (fold-shuffle-vector-imm) \ ##load-constant new-insn ;
+
+M: ##shuffle-vector-imm rewrite
+    dup src>> vreg>expr {
+        { [ dup shuffle-vector-imm-expr? ] [ rewrite-shuffle-vector-imm ] }
+        { [ dup reference-expr? ] [ fold-shuffle-vector-imm ] }
+        { [ dup constant-expr? ] [ fold-shuffle-vector-imm ] }
+        [ 2drop f ]
+    } cond ;
+
+: (fold-scalar>vector) ( insn bytes -- insn' )
+    [ [ dst>> ] [ rep>> rep-length ] bi ] dip <repetition> concat
+    \ ##load-constant new-insn ;
+
+: fold-scalar>vector ( insn expr -- insn' )
+    value>> over rep>> {
+        { float-4-rep [ float>bits 4 >le (fold-scalar>vector) ] }
+        { double-2-rep [ double>bits 8 >le (fold-scalar>vector) ] }
+        [ [ untag-fixnum ] dip rep-component-type heap-size >le (fold-scalar>vector) ]
+    } case ;
+
+M: ##scalar>vector rewrite
+    dup src>> vreg>expr dup constant-expr?
+    [ fold-scalar>vector ] [ 2drop f ] if ;
+
+M: ##xor-vector rewrite
+    dup [ src1>> vreg>vn ] [ src2>> vreg>vn ] bi eq?
+    [ [ dst>> ] [ rep>> ] bi \ ##zero-vector new-insn ] [ drop f ] if ;
+
+: vector-not? ( expr -- ? )
+    {
+        [ not-vector-expr? ]
+        [ {
+            [ xor-vector-expr? ]
+            [ [ src1>> ] [ src2>> ] bi [ vn>expr fill-vector-expr? ] either? ]
+        } 1&& ]
+    } 1|| ;
+
+GENERIC: vector-not-src ( expr -- vreg )
+M: not-vector-expr vector-not-src src>> vn>vreg ;
+M: xor-vector-expr vector-not-src
+    dup src1>> vn>expr fill-vector-expr? [ src2>> ] [ src1>> ] if vn>vreg ;
+
+M: ##and-vector rewrite 
+    {
+        { [ dup src1>> vreg>expr vector-not? ] [
+            {
+                [ dst>> ]
+                [ src1>> vreg>expr vector-not-src ]
+                [ src2>> ]
+                [ rep>> ]
+            } cleave \ ##andn-vector new-insn
+        ] }
+        { [ dup src2>> vreg>expr vector-not? ] [
+            {
+                [ dst>> ]
+                [ src2>> vreg>expr vector-not-src ]
+                [ src1>> ]
+                [ rep>> ]
+            } cleave \ ##andn-vector new-insn
+        ] }
+        [ drop f ]
+    } cond ;
+
+M: ##andn-vector rewrite
+    dup src1>> vreg>expr vector-not? [
+        {
+            [ dst>> ]
+            [ src1>> vreg>expr vector-not-src ]
+            [ src2>> ]
+            [ rep>> ]
+        } cleave \ ##and-vector new-insn
+    ] [ drop f ] if ;
+
+M: scalar>vector-expr simplify*
+    src>> vn>expr {
+        { [ dup vector>scalar-expr? ] [ src>> ] }
+        [ drop f ]
+    } cond ;
+
+M: shuffle-vector-imm-expr simplify*
+    [ src>> ] [ shuffle>> ] [ rep>> rep-length iota ] tri
+    sequence= [ drop f ] unless ;
+
index df3dc6aab9a054cee5907de3dc6b2ff695f9e07b..7a95711b019dbfc1a195ecd5290cabbe1f1cb051 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2008, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel accessors combinators classes math layouts
-sequences math.vectors.simd.intrinsics
+sequences 
 compiler.cfg.instructions
 compiler.cfg.value-numbering.graph
 compiler.cfg.value-numbering.expressions ;
@@ -130,16 +130,6 @@ M: box-displaced-alien-expr simplify*
         [ 2drop f ]
     } cond ;
 
-M: scalar>vector-expr simplify*
-    src>> vn>expr {
-        { [ dup vector>scalar-expr? ] [ src>> ] }
-        [ drop f ]
-    } cond ;
-
-M: shuffle-vector-imm-expr simplify*
-    [ src>> ] [ shuffle>> ] [ rep>> rep-components iota ] tri
-    sequence= [ drop f ] unless ;
-
 M: expr simplify* drop f ;
 
 : simplify ( expr -- vn )
index b404c4d4a42e1eed1de7e24b77dac07a67377a59..ac992ff98d7ec0e58eb15dcc6caa08f2d159d960 100644 (file)
@@ -4,7 +4,7 @@ cpu.architecture tools.test kernel math combinators.short-circuit
 accessors sequences compiler.cfg.predecessors locals compiler.cfg.dce
 compiler.cfg.ssa.destruction compiler.cfg.loop-detection
 compiler.cfg.representations compiler.cfg assocs vectors arrays
-layouts literals namespaces alien ;
+layouts literals namespaces alien compiler.cfg.value-numbering.simd ;
 IN: compiler.cfg.value-numbering.tests
 
 : trim-temps ( insns -- insns )
old mode 100755 (executable)
new mode 100644 (file)
index 15c4e14..ef6794e
@@ -1,4 +1,4 @@
-! Copyright (C) 2008, 2009 Slava Pestov.
+! Copyright (C) 2008, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: namespaces make math math.order math.parser sequences accessors
 kernel kernel.private layouts assocs words summary arrays
@@ -40,7 +40,7 @@ SYMBOL: labels
     V{ } clone calls set ;
 
 : generate-insns ( asm -- code )
-    dup word>> [
+    dup label>> [
         init-generator
         instructions>> [
             [ class insn-counts get inc-at ]
@@ -61,9 +61,7 @@ SYMBOL: labels
 ! Special cases
 M: ##no-tco generate-insn drop ;
 
-M: ##call generate-insn
-    word>> dup sub-primitive>>
-    [ second first % ] [ [ add-call ] [ %call ] bi ] ?if ;
+M: ##call generate-insn word>> [ add-call ] [ %call ] bi ;
 
 M: ##jump generate-insn word>> [ add-call ] [ %jump ] bi ;
 
@@ -173,11 +171,15 @@ CODEGEN: ##add-sub-vector %add-sub-vector
 CODEGEN: ##sub-vector %sub-vector
 CODEGEN: ##saturated-sub-vector %saturated-sub-vector
 CODEGEN: ##mul-vector %mul-vector
+CODEGEN: ##mul-high-vector %mul-high-vector
+CODEGEN: ##mul-horizontal-add-vector %mul-horizontal-add-vector
 CODEGEN: ##saturated-mul-vector %saturated-mul-vector
 CODEGEN: ##div-vector %div-vector
 CODEGEN: ##min-vector %min-vector
 CODEGEN: ##max-vector %max-vector
+CODEGEN: ##avg-vector %avg-vector
 CODEGEN: ##dot-vector %dot-vector
+CODEGEN: ##sad-vector %sad-vector
 CODEGEN: ##sqrt-vector %sqrt-vector
 CODEGEN: ##horizontal-add-vector %horizontal-add-vector
 CODEGEN: ##horizontal-sub-vector %horizontal-sub-vector
@@ -281,7 +283,7 @@ M: ##gc generate-insn
         [ [ uninitialized-locs>> ] [ temp1>> ] bi wipe-locs ]
         [ data-values>> save-data-regs ]
         [ [ tagged-values>> ] [ temp1>> ] bi save-gc-roots ]
-        [ [ temp1>> ] [ temp2>> ] bi %save-context ]
+        [ [ temp1>> ] [ temp2>> ] bi %save-context ]
         [ [ tagged-values>> length ] [ temp1>> ] bi %call-gc ]
         [ [ tagged-values>> ] [ temp1>> ] bi load-gc-roots ]
         [ data-values>> load-data-regs ]
@@ -378,11 +380,11 @@ M: c-type-name flatten-value-type c-type flatten-value-type ;
     [ [ parameter-offsets nip ] keep ] dip 2reverse-each ; inline
 
 : prepare-unbox-parameters ( parameters -- offsets types indices )
-    [ parameter-offsets nip ] [ ] [ length iota reverse ] tri ;
+    [ parameter-offsets nip ] [ ] [ length iota <reversed> ] tri ;
 
 : unbox-parameters ( offset node -- )
     parameters>> swap
-    '[ prepare-unbox-parameters [ %prepare-unbox [ _ + ] dip unbox-parameter ] 3each ]
+    '[ prepare-unbox-parameters [ %pop-stack [ _ + ] dip unbox-parameter ] 3each ]
     [ length neg %inc-d ]
     bi ;
 
@@ -405,7 +407,7 @@ M: c-type-name flatten-value-type c-type flatten-value-type ;
     ] with-param-regs ;
 
 : box-return* ( node -- )
-    return>> [ ] [ box-return ] if-void ;
+    return>> [ ] [ box-return %push-stack ] if-void ;
 
 : check-dlsym ( symbols dll -- )
     dup dll-valid? [
@@ -434,6 +436,16 @@ M: ##alien-invoke generate-insn
     dup %cleanup
     box-return* ;
 
+M: ##alien-assembly generate-insn
+    params>>
+    ! Unbox parameters
+    dup objects>registers
+    %prepare-var-args
+    ! Generate assembly
+    dup quot>> call( -- )
+    ! Box return value
+    box-return* ;
+
 ! ##alien-indirect
 M: ##alien-indirect generate-insn
     params>>
@@ -450,7 +462,7 @@ M: ##alien-indirect generate-insn
 
 ! ##alien-callback
 : box-parameters ( params -- )
-    alien-parameters [ box-parameter ] each-parameter ;
+    alien-parameters [ box-parameter %push-context-stack ] each-parameter ;
 
 : registers>objects ( node -- )
     ! Generate code for boxing input parameters in a callback.
@@ -462,7 +474,7 @@ M: ##alien-indirect generate-insn
 
 TUPLE: callback-context ;
 
-: current-callback ( -- id ) 2 getenv ;
+: current-callback ( -- id ) 2 special-object ;
 
 : wait-to-return ( token -- )
     dup current-callback eq? [
@@ -473,7 +485,7 @@ TUPLE: callback-context ;
 
 : do-callback ( quot token -- )
     init-catchstack
-    [ 2 setenv call ] keep
+    [ 2 set-special-object call ] keep
     wait-to-return ; inline
 
 : callback-return-quot ( ctype -- quot )
@@ -494,11 +506,6 @@ TUPLE: callback-context ;
         [ callback-context new do-callback ] %
     ] [ ] make ;
 
-M: ##callback-return generate-insn
-    #! All the extra book-keeping for %unwind is only for x86.
-    #! On other platforms its an alias for %return.
-    params>> %callback-return ;
-
 M: ##alien-callback generate-insn
     params>>
     [ registers>objects ]
old mode 100755 (executable)
new mode 100644 (file)
index 21a8db8..eef517a
@@ -1,15 +1,20 @@
-! Copyright (C) 2007, 2009 Slava Pestov.
+! Copyright (C) 2007, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: arrays byte-arrays byte-vectors generic assocs hashtables
 io.binary kernel kernel.private math namespaces make sequences
 words quotations strings alien.accessors alien.strings layouts
-system combinators math.bitwise math.order
-accessors growable fry generalizations compiler.constants ;
+system combinators math.bitwise math.order generalizations
+accessors growable fry compiler.constants memoize ;
 IN: compiler.codegen.fixup
 
 ! Owner
 SYMBOL: compiling-word
 
+! Parameter table
+SYMBOL: parameter-table
+
+: add-parameter ( obj -- ) parameter-table get push ;
+
 ! Literal table
 SYMBOL: literal-table
 
@@ -29,13 +34,10 @@ TUPLE: label offset ;
     dup label? [ get ] unless
     compiled-offset >>offset drop ;
 
-: offset-for-class ( class -- n )
-    rc-absolute-cell = cell 4 ? compiled-offset swap - ;
-
 TUPLE: label-fixup { label label } { class integer } { offset integer } ;
 
 : label-fixup ( label class -- )
-    dup offset-for-class \ label-fixup boa label-table get push ;
+    compiled-offset \ label-fixup boa label-table get push ;
 
 ! Relocation table
 SYMBOL: relocation-table
@@ -48,28 +50,28 @@ SYMBOL: relocation-table
     { 0 24 28 } bitfield relocation-table get push-4 ;
 
 : rel-fixup ( class type -- )
-    swap dup offset-for-class add-relocation-entry ;
+    swap compiled-offset add-relocation-entry ;
 
-: add-dlsym-literals ( symbol dll -- )
-    [ string>symbol add-literal ] [ add-literal ] bi* ;
+! Caching common symbol names reduces image size a bit
+MEMO: cached-string>symbol ( symbol -- obj ) string>symbol ;
+
+: add-dlsym-parameters ( symbol dll -- )
+    [ cached-string>symbol add-parameter ] [ add-parameter ] bi* ;
 
 : rel-dlsym ( name dll class -- )
-    [ add-dlsym-literals ] dip rt-dlsym rel-fixup ;
+    [ add-dlsym-parameters ] dip rt-dlsym rel-fixup ;
 
 : rel-word ( word class -- )
-    [ add-literal ] dip rt-xt rel-fixup ;
+    [ add-literal ] dip rt-entry-point rel-fixup ;
 
 : rel-word-pic ( word class -- )
-    [ add-literal ] dip rt-xt-pic rel-fixup ;
+    [ add-literal ] dip rt-entry-point-pic rel-fixup ;
 
 : rel-word-pic-tail ( word class -- )
-    [ add-literal ] dip rt-xt-pic-tail rel-fixup ;
-
-: rel-primitive ( word class -- )
-    [ def>> first add-literal ] dip rt-primitive rel-fixup ;
+    [ add-literal ] dip rt-entry-point-pic-tail rel-fixup ;
 
 : rel-immediate ( literal class -- )
-    [ add-literal ] dip rt-immediate rel-fixup ;
+    [ add-literal ] dip rt-literal rel-fixup ;
 
 : rel-this ( class -- )
     rt-this rel-fixup ;
@@ -78,7 +80,7 @@ SYMBOL: relocation-table
     [ add-literal ] dip rt-here rel-fixup ;
 
 : rel-vm ( offset class -- )
-    [ add-literal ] dip rt-vm rel-fixup ;
+    [ add-parameter ] dip rt-vm rel-fixup ;
 
 : rel-cards-offset ( class -- )
     rt-cards-offset rel-fixup ;
@@ -105,6 +107,7 @@ SYMBOL: relocation-table
 
 : init-fixup ( word -- )
     compiling-word set
+    V{ } clone parameter-table set
     V{ } clone literal-table set
     V{ } clone label-table set
     BV{ } clone relocation-table set ;
@@ -114,7 +117,7 @@ SYMBOL: relocation-table
         init-fixup
         @
         label-table [ resolve-labels ] change
-        compiling-word get
+        parameter-table get >array
         literal-table get >array
         relocation-table get >byte-array
         label-table get
old mode 100755 (executable)
new mode 100644 (file)
index e58cf0c..2375d85
@@ -5,13 +5,16 @@ continuations vocabs assocs dlists definitions math graphs generic
 generic.single combinators deques search-deques macros
 source-files.errors combinators.short-circuit
 
-stack-checker stack-checker.state stack-checker.inlining stack-checker.errors
+stack-checker stack-checker.dependencies stack-checker.inlining
+stack-checker.errors
 
 compiler.errors compiler.units compiler.utilities
 
 compiler.tree.builder
 compiler.tree.optimizer
 
+compiler.crossref
+
 compiler.cfg
 compiler.cfg.builder
 compiler.cfg.optimizer
@@ -29,7 +32,6 @@ SYMBOL: compiled
         [ "forgotten" word-prop ]
         [ compiled get key? ]
         [ inlined-block? ]
-        [ primitive? ]
     } 1|| not ;
 
 : queue-compile ( word -- )
@@ -60,17 +62,23 @@ M: method-body no-compile? "method-generic" word-prop no-compile? ;
 M: predicate-engine-word no-compile? "owner-generic" word-prop no-compile? ;
 
 M: word no-compile?
-    {
-        [ macro? ]
-        [ inline? ]
-        [ "special" word-prop ]
-        [ "no-compile" word-prop ]
-    } 1|| ;
+    { [ macro? ] [ "special" word-prop ] [ "no-compile" word-prop ] } 1|| ;
+
+GENERIC: combinator? ( word -- ? )
+
+M: method-body combinator? "method-generic" word-prop combinator? ;
+
+M: predicate-engine-word combinator? "owner-generic" word-prop combinator? ;
+
+M: word combinator? inline? ;
 
 : ignore-error? ( word error -- ? )
     #! Ignore some errors on inline combinators, macros, and special
     #! words such as 'call'.
-    [ no-compile? ] [ { [ do-not-compile? ] [ literal-expected? ] } 1|| ] bi* and ;
+    {
+        [ drop no-compile? ]
+        [ [ combinator? ] [ unknown-macro-input? ] bi* and ]
+    } 2|| ;
 
 : finish ( word -- )
     #! Recompile callers if the word's stack effect changed, then
@@ -117,7 +125,10 @@ M: word no-compile?
     } cond ;
 
 : optimize? ( word -- ? )
-    single-generic? not ;
+    {
+        [ single-generic? ]
+        [ primitive? ]
+    } 1|| not ;
 
 : contains-breakpoints? ( -- ? )
     dependencies get keys [ "break?" word-prop ] any? ;
@@ -193,6 +204,14 @@ M: optimizing-compiler recompile ( words -- alist )
     ] with-scope
     "--- compile done" compiler-message ;
 
+M: optimizing-compiler to-recompile ( -- words )
+    changed-definitions get compiled-usages
+    changed-generics get compiled-generic-usages
+    append assoc-combine keys ;
+
+M: optimizing-compiler process-forgotten-words
+    [ delete-compiled-xref ] each ;
+
 : with-optimizer ( quot -- )
     [ optimizing-compiler compiler-impl ] dip with-variable ; inline
 
index 19cdb6eebdb033b76fdf1686f12abb239f844e1d..73e77cca4dd94f074b5f66acb75f9c2ee90d5794 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2008, 2009 Slava Pestov.
+! Copyright (C) 2008, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: math kernel layouts system strings words quotations byte-arrays
 alien arrays literals sequences ;
@@ -20,11 +20,18 @@ CONSTANT: deck-bits 18
 : alien-offset ( -- n ) 4 alien type-number slot-offset ; inline
 : underlying-alien-offset ( -- n ) 1 alien type-number slot-offset ; inline
 : tuple-class-offset ( -- n ) 1 tuple type-number slot-offset ; inline
-: word-xt-offset ( -- n ) 10 \ word type-number slot-offset ; inline
-: quot-xt-offset ( -- n ) 4 quotation type-number slot-offset ; inline
+: word-entry-point-offset ( -- n ) 10 \ word type-number slot-offset ; inline
+: quot-entry-point-offset ( -- n ) 4 quotation type-number slot-offset ; inline
 : word-code-offset ( -- n ) 11 \ word type-number slot-offset ; inline
 : array-start-offset ( -- n ) 2 array type-number slot-offset ; inline
 : compiled-header-size ( -- n ) 4 bootstrap-cells ; inline
+: callstack-length-offset ( -- n ) 1 \ callstack type-number slot-offset ; inline
+: callstack-top-offset ( -- n ) 2 \ callstack type-number slot-offset ; inline
+: vm-context-offset ( -- n ) 0 bootstrap-cells ; inline
+: context-callstack-top-offset ( -- n ) 0 bootstrap-cells ; inline
+: context-callstack-bottom-offset ( -- n ) 1 bootstrap-cells ; inline
+: context-datastack-offset ( -- n ) 2 bootstrap-cells ; inline
+: context-retainstack-offset ( -- n ) 3 bootstrap-cells ; inline
 
 ! Relocation classes
 CONSTANT: rc-absolute-cell 0
@@ -37,23 +44,21 @@ CONSTANT: rc-relative-ppc-3 6
 CONSTANT: rc-relative-arm-3 7
 CONSTANT: rc-indirect-arm 8
 CONSTANT: rc-indirect-arm-pc 9
+CONSTANT: rc-absolute-2 10
 
 ! Relocation types
-CONSTANT: rt-primitive 0
-CONSTANT: rt-dlsym 1
-CONSTANT: rt-dispatch 2
-CONSTANT: rt-xt 3
-CONSTANT: rt-xt-pic 4
-CONSTANT: rt-xt-pic-tail 5
-CONSTANT: rt-here 6
-CONSTANT: rt-this 7
-CONSTANT: rt-immediate 8
-CONSTANT: rt-stack-chain 9
-CONSTANT: rt-untagged 10
-CONSTANT: rt-megamorphic-cache-hits 11
-CONSTANT: rt-vm 12
-CONSTANT: rt-cards-offset 13
-CONSTANT: rt-decks-offset 14
+CONSTANT: rt-dlsym 0
+CONSTANT: rt-entry-point 1
+CONSTANT: rt-entry-point-pic 2
+CONSTANT: rt-entry-point-pic-tail 3
+CONSTANT: rt-here 4
+CONSTANT: rt-this 5
+CONSTANT: rt-literal 6
+CONSTANT: rt-untagged 7
+CONSTANT: rt-megamorphic-cache-hits 8
+CONSTANT: rt-vm 9
+CONSTANT: rt-cards-offset 10
+CONSTANT: rt-decks-offset 11
 
 : rc-absolute? ( n -- ? )
     ${ rc-absolute-ppc-2/2 rc-absolute-cell rc-absolute } member? ;
diff --git a/basis/compiler/crossref/authors.txt b/basis/compiler/crossref/authors.txt
new file mode 100644 (file)
index 0000000..1901f27
--- /dev/null
@@ -0,0 +1 @@
+Slava Pestov
diff --git a/basis/compiler/crossref/crossref.factor b/basis/compiler/crossref/crossref.factor
new file mode 100644 (file)
index 0000000..e6ef5cf
--- /dev/null
@@ -0,0 +1,68 @@
+! Copyright (C) 2009 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: assocs classes.algebra compiler.units definitions graphs
+grouping kernel namespaces sequences words
+stack-checker.dependencies ;
+IN: compiler.crossref
+
+SYMBOL: compiled-crossref
+
+compiled-crossref [ H{ } clone ] initialize
+
+SYMBOL: compiled-generic-crossref
+
+compiled-generic-crossref [ H{ } clone ] initialize
+
+: compiled-usage ( word -- assoc )
+    compiled-crossref get at ;
+
+: (compiled-usages) ( word -- assoc )
+    #! If the word is not flushable anymore, we have to recompile
+    #! all words which flushable away a call (presumably when the
+    #! word was still flushable). If the word is flushable, we
+    #! don't have to recompile words that folded this away.
+    [ compiled-usage ]
+    [ "flushable" word-prop inlined-dependency flushed-dependency ? ] bi
+    [ dependency>= nip ] curry assoc-filter ;
+
+: compiled-usages ( seq -- assocs )
+    [ drop word? ] assoc-filter
+    [ [ drop (compiled-usages) ] { } assoc>map ] keep suffix ;
+
+: compiled-generic-usage ( word -- assoc )
+    compiled-generic-crossref get at ;
+
+: (compiled-generic-usages) ( generic class -- assoc )
+    [ compiled-generic-usage ] dip
+    [
+        2dup [ valid-class? ] both?
+        [ classes-intersect? ] [ 2drop f ] if nip
+    ] curry assoc-filter ;
+
+: compiled-generic-usages ( assoc -- assocs )
+    [ (compiled-generic-usages) ] { } assoc>map ;
+
+: (compiled-xref) ( word dependencies word-prop variable -- )
+    [ [ concat ] dip set-word-prop ] [ get add-vertex* ] bi-curry* 2bi ;
+
+: compiled-xref ( word dependencies generic-dependencies -- )
+    [ [ drop crossref? ] { } assoc-filter-as ] bi@
+    [ "compiled-uses" compiled-crossref (compiled-xref) ]
+    [ "compiled-generic-uses" compiled-generic-crossref (compiled-xref) ]
+    bi-curry* bi ;
+
+: (compiled-unxref) ( word word-prop variable -- )
+    [ [ [ dupd word-prop 2 <groups> ] dip get remove-vertex* ] 2curry ]
+    [ drop [ remove-word-prop ] curry ]
+    2bi bi ;
+
+: compiled-unxref ( word -- )
+    [ "compiled-uses" compiled-crossref (compiled-unxref) ]
+    [ "compiled-generic-uses" compiled-generic-crossref (compiled-unxref) ]
+    bi ;
+
+: delete-compiled-xref ( word -- )
+    [ compiled-unxref ]
+    [ compiled-crossref get delete-at ]
+    [ compiled-generic-crossref get delete-at ]
+    tri ;
old mode 100755 (executable)
new mode 100644 (file)
index 04ee02a..4cfbe8f
@@ -94,6 +94,8 @@ FUNCTION: TINY ffi_test_17 int x ;
 
 { 1 1 } [ indirect-test-1 ] must-infer-as
 
+[ B{ } indirect-test-1 ] [ { "kernel-error" 3 6 B{ } } = ] must-fail-with
+
 [ 3 ] [ &: ffi_test_1 indirect-test-1 ] unit-test
 
 : indirect-test-1' ( ptr -- )
@@ -162,7 +164,7 @@ FUNCTION: void ffi_test_20 double x1, double x2, double x3,
     { int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int }
     alien-invoke gc 3 ;
 
-[ 861 3 ] [ 42 [ ] each ffi_test_31 ] unit-test
+[ 861 3 ] [ 42 [ ] each-integer ffi_test_31 ] unit-test
 
 : ffi_test_31_point_5 ( a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a -- result )
     float
@@ -170,7 +172,7 @@ FUNCTION: void ffi_test_20 double x1, double x2, double x3,
     { float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float }
     alien-invoke ;
 
-[ 861.0 ] [ 42 [ >float ] each ffi_test_31_point_5 ] unit-test
+[ 861.0 ] [ 42 [ >float ] each-integer ffi_test_31_point_5 ] unit-test
 
 FUNCTION: longlong ffi_test_21 long x long y ;
 
@@ -314,7 +316,7 @@ FUNCTION: ulonglong ffi_test_38 ( ulonglong x, ulonglong y ) ;
 
 : callback-1 ( -- callback ) void { } "cdecl" [ ] alien-callback ;
 
-[ 0 1 ] [ [ callback-1 ] infer [ in>> ] [ out>> ] bi ] unit-test
+[ 0 1 ] [ [ callback-1 ] infer [ in>> length ] [ out>> length ] bi ] unit-test
 
 [ t ] [ callback-1 alien? ] unit-test
 
@@ -375,9 +377,7 @@ FUNCTION: ulonglong ffi_test_38 ( ulonglong x, ulonglong y ) ;
 [ f ] [ namespace global eq? ] unit-test
 
 : callback-8 ( -- callback )
-    void { } "cdecl" [
-        [ continue ] callcc0
-    ] alien-callback ;
+    void { } "cdecl" [ [ ] in-thread yield ] alien-callback ;
 
 [ ] [ callback-8 callback_test_1 ] unit-test
 
@@ -588,5 +588,9 @@ FUNCTION: short ffi_test_48 ( bool-field-test x ) ;
 ! Regression: calling an undefined function would raise a protection fault
 FUNCTION: void this_does_not_exist ( ) ;
 
-[ this_does_not_exist ] [ { "kernel-error" 10 f f } = ] must-fail-with
+[ this_does_not_exist ] [ { "kernel-error" 9 f f } = ] must-fail-with
+
+! More alien-assembly tests are in cpu.* vocabs
+: assembly-test-1 ( -- ) void { } "cdecl" [ ] alien-assembly ;
 
+[ ] [ assembly-test-1 ] unit-test
index eba65805746b39c2b1466639b1935ff4013f8c4a..cff685eaf6e7066d059a0704561a15c1c1ed7c93 100644 (file)
@@ -116,7 +116,7 @@ unit-test
     1 1.0 2.5 try-breaking-dispatch "bye" = [ 3.5 = ] dip and ;
 
 [ t ] [
-    10000000 [ drop try-breaking-dispatch-2 ] all?
+    10000000 [ drop try-breaking-dispatch-2 ] all-integers?
 ] unit-test
 
 ! Regression
@@ -314,7 +314,7 @@ cell 4 = [
 
 ! Bug with ##return node construction
 : return-recursive-bug ( nodes -- ? )
-    { fixnum } declare [
+    { fixnum } declare iota [
         dup 3 bitand 1 = [ drop t ] [
             dup 3 bitand 2 = [
                 return-recursive-bug
index 14b347008cb3f7524850ba4c68da4b8812bca741..632a560c0df9834f7a27f854678f0115be408d73 100644 (file)
@@ -1,5 +1,5 @@
 USING: compiler.units compiler kernel kernel.private memory math
-math.private tools.test math.floats.private ;
+math.private tools.test math.floats.private math.order fry ;
 IN: compiler.tests.float
 
 [ 5.0 ] [ [ 5.0 ] compile-call gc gc gc ] unit-test
@@ -84,11 +84,6 @@ IN: compiler.tests.float
 
 [ 315 315.0 ] [ 313 [ 2 fixnum+fast dup fixnum>float ] compile-call ] unit-test
 
-[ 17.5 ] [ -11.3 17.5 [ float-max ] compile-call ] unit-test
-[ 17.5 ] [ 17.5 -11.3 [ float-max ] compile-call ] unit-test
-[ -11.3 ] [ -11.3 17.5 [ float-min ] compile-call ] unit-test
-[ -11.3 ] [ 17.5 -11.3 [ float-min ] compile-call ] unit-test
-
 [ t ] [ 0/0. 0/0. [ float-unordered? ] compile-call ] unit-test
 [ t ] [ 0/0. 1.0 [ float-unordered? ] compile-call ] unit-test
 [ t ] [ 1.0 0/0. [ float-unordered? ] compile-call ] unit-test
@@ -100,3 +95,23 @@ IN: compiler.tests.float
 [ 1 ] [ 1.0 0/0. [ float-unordered? [ 1 ] [ 2 ] if ] compile-call ] unit-test
 [ 2 ] [ 3.0 1.0 [ float-unordered? [ 1 ] [ 2 ] if ] compile-call ] unit-test
 [ 2 ] [ 1.0 3.0 [ float-unordered? [ 1 ] [ 2 ] if ] compile-call ] unit-test
+
+! Ensure that float-min and min, and float-max and max, have
+! consistent behavior with respect to NaNs
+
+: two-floats ( a b -- a b ) { float float } declare ; inline
+
+[ -11.3 ] [ -11.3 17.5 [ two-floats min ] compile-call ] unit-test
+[ -11.3 ] [ 17.5 -11.3 [ two-floats min ] compile-call ] unit-test
+[ 17.5 ] [ -11.3 17.5 [ two-floats max ] compile-call ] unit-test
+[ 17.5 ] [ 17.5 -11.3 [ two-floats max ] compile-call ] unit-test
+
+: check-compiled-binary-op ( a b word -- )
+    [ '[ [ [ two-floats _ execute ] compile-call ] call( a b -- c ) ] ]
+    [ '[ _ execute ] ]
+    bi 2bi fp-bitwise= ; inline
+
+[ t ] [ 0/0. 3.0 \ min check-compiled-binary-op ] unit-test
+[ t ] [ 3.0 0/0. \ min check-compiled-binary-op ] unit-test
+[ t ] [ 0/0. 3.0 \ max check-compiled-binary-op ] unit-test
+[ t ] [ 3.0 0/0. \ max check-compiled-binary-op ] unit-test
old mode 100755 (executable)
new mode 100644 (file)
index a26ba5a..1c066f2
@@ -21,7 +21,6 @@ IN: compiler.tests.intrinsics
 [ 2 1 3 ] [ 1 2 3 [ swapd ] compile-call ] unit-test
 [ 2 ] [ 1 2 [ nip ] compile-call ] unit-test
 [ 3 ] [ 1 2 3 [ 2nip ] compile-call ] unit-test
-[ 2 1 2 ] [ 1 2 [ tuck ] compile-call ] unit-test
 [ 1 2 1 ] [ 1 2 [ over ] compile-call ] unit-test
 [ 1 2 3 1 ] [ 1 2 3 [ pick ] compile-call ] unit-test
 [ 2 1 ] [ 1 2 [ swap ] compile-call ] unit-test
@@ -55,8 +54,8 @@ IN: compiler.tests.intrinsics
 [ HEX: 123456 ] [ 1 [ "a\u123456c" string-nth ] compile-call ] unit-test
 [ HEX: 123456 ] [ [ 1 "a\u123456c" string-nth ] compile-call ] unit-test
 
-[ ] [ [ 0 getenv ] compile-call drop ] unit-test
-[ ] [ 1 getenv [ 1 setenv ] compile-call ] unit-test
+[ ] [ [ 0 special-object ] compile-call drop ] unit-test
+[ ] [ 1 special-object [ 1 set-special-object ] compile-call ] unit-test
 
 [ ] [ 1 [ drop ] compile-call ] unit-test
 [ ] [ [ 1 drop ] compile-call ] unit-test
@@ -338,7 +337,7 @@ ERROR: bug-in-fixnum* x y a b ;
 
 [ ] [
     10000 [
-        5 random [ drop 32 random-bits ] map product >bignum
+        5 random iota [ drop 32 random-bits ] map product >bignum
         dup [ bignum>fixnum ] keep compiled-bignum>fixnum =
         [ drop ] [ "Oops" throw ] if
     ] times
@@ -586,16 +585,16 @@ TUPLE: alien-accessor-regression { b byte-array } { i fixnum } ;
     swap [
         { tuple } declare 1 slot
     ] [
-        0 slot
+        1 slot
     ] if ;
 
-[ t ] [ f B{ } mutable-value-bug-1 byte-array type-number = ] unit-test
+[ 0 ] [ f { } mutable-value-bug-1 ] unit-test
 
 : mutable-value-bug-2 ( a b -- c )
     swap [
-        0 slot
+        1 slot
     ] [
         { tuple } declare 1 slot
     ] if ;
 
-[ t ] [ t B{ } mutable-value-bug-2 byte-array type-number = ] unit-test
+[ 0 ] [ t { } mutable-value-bug-2 ] unit-test
index 0831d6e8ddc91b7aeb2d7c768b514237123cf5af..865cd639a356583633aa93018d5eac11356a63b2 100644 (file)
@@ -4,7 +4,7 @@ sbufs strings tools.test vectors words sequences.private
 quotations classes classes.algebra classes.tuple.private
 continuations growable namespaces hints alien.accessors
 compiler.tree.builder compiler.tree.optimizer sequences.deep
-compiler definitions generic.single shuffle ;
+compiler definitions generic.single shuffle math.order ;
 IN: compiler.tests.optimizer
 
 GENERIC: xyz ( obj -- obj )
@@ -90,7 +90,7 @@ TUPLE: pred-test ;
 : double-label-2 ( a -- b )
     dup array? [ ] [ ] if 0 t double-label-1 ;
 
-[ 0 ] [ 10 double-label-2 ] unit-test
+[ 0 ] [ 10 iota double-label-2 ] unit-test
 
 ! regression
 GENERIC: void-generic ( obj -- * )
@@ -208,7 +208,7 @@ USE: binary-search.private
     ] if ; inline recursive
 
 [ 10 ] [
-    10 20 >vector <flat-slice>
+    10 20 iota <flat-slice>
     [ [ - ] swap old-binsearch ] compile-call 2nip
 ] unit-test
 
@@ -349,7 +349,7 @@ TUPLE: some-tuple x ;
 [ 5 ] [ { 1 2 { 3 { 4 5 } } } deep-find-test ] unit-test
 [ f ] [ { 1 2 { 3 { 4 } } } deep-find-test ] unit-test
 
-[ B{ 0 1 2 3 4 5 6 7 } ] [ [ 8 [ ] B{ } map-as ] compile-call ] unit-test
+[ B{ 0 1 2 3 4 5 6 7 } ] [ [ 8 iota [ ] B{ } map-as ] compile-call ] unit-test
 
 [ 0 ] [ 1234 [ { fixnum } declare -64 shift ] compile-call ] unit-test
 
@@ -445,5 +445,17 @@ M: object bad-dispatch-position-test* ;
 
 [ 1024 bignum ] [ 10 [ 1 >bignum swap >fixnum shift ] compile-call dup class ] unit-test
 
-! Not sure if I want to fix this...
-! [ t [ [ f ] [ 3 ] if >fixnum ] compile-call ] [ no-method? ] must-fail-with
+TUPLE: grid-mesh-tuple { length read-only } { step read-only } ;
+
+: grid-mesh-test-case ( -- vertices )
+    1.0 1.0 { 2 } first /f [ /i 1 + ] keep grid-mesh-tuple boa
+    1 f <array>
+    [
+        [ drop length>> >fixnum 2 min ] 2keep
+        [
+            [ step>> 1 * ] dip
+            0 swap set-nth-unsafe
+        ] 2curry times
+    ] keep ;
+
+[ { 0.5 } ] [ grid-mesh-test-case ] unit-test
index 67added49d9b53647545b01332539ebf65a8bf3f..913111b8ea34586a677bbe908770eb23e0826608 100644 (file)
@@ -1,6 +1,6 @@
 USING: accessors compiler compiler.units tools.test math parser
 kernel sequences sequences.private classes.mixin generic
-definitions arrays words assocs eval ;
+definitions arrays words assocs eval grouping ;
 IN: compiler.tests.redefine3
 
 GENERIC: sheeple ( obj -- x )
@@ -13,20 +13,23 @@ M: empty-mixin sheeple drop "wake up" ; inline
 
 : sheeple-test ( -- string ) { } sheeple ;
 
+: compiled-use? ( key word -- ? )
+    "compiled-uses" word-prop 2 <groups> key? ;
+
 [ "sheeple" ] [ sheeple-test ] unit-test
 [ t ] [ \ sheeple-test optimized? ] unit-test
-[ t ] [ object \ sheeple method \ sheeple-test "compiled-uses" word-prop key? ] unit-test
-[ f ] [ empty-mixin \ sheeple method \ sheeple-test "compiled-uses" word-prop key? ] unit-test
+[ t ] [ object \ sheeple method \ sheeple-test compiled-use? ] unit-test
+[ f ] [ empty-mixin \ sheeple method \ sheeple-test compiled-use? ] unit-test
 
 [ ] [ "IN: compiler.tests.redefine3 USE: arrays INSTANCE: array empty-mixin" eval( -- ) ] unit-test
 
 [ "wake up" ] [ sheeple-test ] unit-test
-[ f ] [ object \ sheeple method \ sheeple-test "compiled-uses" word-prop key? ] unit-test
-[ t ] [ empty-mixin \ sheeple method \ sheeple-test "compiled-uses" word-prop key? ] unit-test
+[ f ] [ object \ sheeple method \ sheeple-test compiled-use? ] unit-test
+[ t ] [ empty-mixin \ sheeple method \ sheeple-test compiled-use? ] unit-test
 
 [ ] [ [ array empty-mixin remove-mixin-instance ] with-compilation-unit ] unit-test
 
 [ "sheeple" ] [ sheeple-test ] unit-test
 [ t ] [ \ sheeple-test optimized? ] unit-test
-[ t ] [ object \ sheeple method \ sheeple-test "compiled-uses" word-prop key? ] unit-test
-[ f ] [ empty-mixin \ sheeple method \ sheeple-test "compiled-uses" word-prop key? ] unit-test
+[ t ] [ object \ sheeple method \ sheeple-test compiled-use? ] unit-test
+[ f ] [ empty-mixin \ sheeple method \ sheeple-test compiled-use? ] unit-test
old mode 100755 (executable)
new mode 100644 (file)
index e4523deb9ff7515575f0223e8e4afdac85f87582..8eb66fde1f82c9ed5b2bbf67e795e169df0d2be1 100644 (file)
@@ -39,7 +39,7 @@ M: word (build-tree)
     [
         <recursive-state> recursive-state set
         V{ } clone stack-visitor set
-        [ [ >vector \ meta-d set ] [ length d-in set ] bi ]
+        [ [ >vector \ meta-d set ] [ length input-count set ] bi ]
         [ (build-tree) ]
         bi*
     ] with-infer nip ;
old mode 100755 (executable)
new mode 100644 (file)
index 0b3b46f..b3f01c8
@@ -185,9 +185,7 @@ M: #recursive check-stack-flow*
 
 M: #copy check-stack-flow* [ check-in-d ] [ check-out-d ] bi ;
 
-M: #alien-invoke check-stack-flow* [ check-in-d ] [ check-out-d ] bi ;
-
-M: #alien-indirect check-stack-flow* [ check-in-d ] [ check-out-d ] bi ;
+M: #alien-node check-stack-flow* [ check-in-d ] [ check-out-d ] bi ;
 
 M: #alien-callback check-stack-flow* drop ;
 
old mode 100755 (executable)
new mode 100644 (file)
index db96086..05f9092
@@ -339,28 +339,23 @@ cell-bits 32 = [
 ] unit-test
 
 [ t ] [
-    [ { fixnum } declare length [ drop ] each-integer ]
+    [ { fixnum } declare iota [ drop ] each ]
     { < <-integer-fixnum +-integer-fixnum + } inlined?
 ] unit-test
 
 [ t ] [
-    [ { fixnum } declare [ drop ] each ]
-    { < <-integer-fixnum +-integer-fixnum + } inlined?
-] unit-test
-
-[ t ] [
-    [ { fixnum } declare 0 [ + ] reduce ]
+    [ { fixnum } declare iota 0 [ + ] reduce ]
     { < <-integer-fixnum nth-unsafe } inlined?
 ] unit-test
 
 [ f ] [
-    [ { fixnum } declare 0 [ + ] reduce ]
+    [ { fixnum } declare iota 0 [ + ] reduce ]
     \ +-integer-fixnum inlined?
 ] unit-test
 
 [ f ] [
     [
-        { integer } declare [ ] map
+        { integer } declare iota [ ] map
     ] \ >fixnum inlined?
 ] unit-test
 
@@ -403,7 +398,7 @@ cell-bits 32 = [
 
 [ t ] [
     [
-        { integer } declare [ 0 >= ] map
+        { integer } declare iota [ 0 >= ] map
     ] { >= fixnum>= } inlined?
 ] unit-test
 
index 8ed83188e5ddd6841f019340e4081501e78513be..ec819d0eacaee737d47cb5243b5947d3f95508d0 100644 (file)
@@ -3,7 +3,7 @@
 USING: kernel accessors sequences combinators fry
 classes.algebra namespaces assocs words math math.private
 math.partial-dispatch math.intervals classes classes.tuple
-classes.tuple.private layouts definitions stack-checker.state
+classes.tuple.private layouts definitions stack-checker.dependencies
 stack-checker.branches
 compiler.utilities
 compiler.tree
index 6cef45a9c91767ab64577697f9e6f51bf9d61c52..d1fdf6359a19322c472b5422b4c7365105487a2c 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2008 Slava Pestov.
+! Copyright (C) 2008, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: sequences namespaces kernel accessors assocs sets fry
 arrays combinators columns stack-checker.backend
@@ -36,7 +36,7 @@ M: #branch remove-dead-code*
 
 : drop-indexed-values ( values indices -- node )
     [ drop filter-live ] [ swap nths ] 2bi
-    [ make-values ] keep
+    [ length make-values ] keep
     [ drop ] [ zip ] 2bi
     #data-shuffle ;
 
index 482d370947bb626a601c217fc42689edd9ee5f8b..0c9464374a6edae178674a1494a32b523991fc83 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2008 Slava Pestov.
+! Copyright (C) 2008, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors arrays assocs sequences kernel locals fry
 combinators stack-checker.backend
@@ -24,7 +24,7 @@ M: #call-recursive compute-live-values*
 
 :: drop-dead-inputs ( inputs outputs -- #shuffle )
     inputs filter-live
-    outputs inputs filter-corresponding make-values
+    outputs inputs filter-corresponding length make-values
     outputs
     inputs
     drop-values ;
@@ -39,7 +39,7 @@ M: #enter-recursive remove-dead-code*
     2bi ;
 
 :: (drop-call-recursive-outputs) ( inputs outputs -- #shuffle )
-    inputs outputs filter-corresponding make-values :> new-live-outputs
+    inputs outputs filter-corresponding length make-values :> new-live-outputs
     outputs filter-live :> live-outputs
     new-live-outputs
     live-outputs
old mode 100755 (executable)
new mode 100644 (file)
index f6165a4..7752356
@@ -1,8 +1,8 @@
-! Copyright (C) 2008 Slava Pestov.
+! Copyright (C) 2008, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel accessors words assocs sequences arrays namespaces
 fry locals definitions classes classes.algebra generic
-stack-checker.state
+stack-checker.dependencies
 stack-checker.backend
 compiler.tree
 compiler.tree.propagation.info
@@ -28,9 +28,7 @@ M: method-body flushable? "method-generic" word-prop flushable? ;
 M: #call mark-live-values*
     dup flushable-call? [ drop ] [ look-at-inputs ] if ;
 
-M: #alien-invoke mark-live-values* look-at-inputs ;
-
-M: #alien-indirect mark-live-values* look-at-inputs ;
+M: #alien-node mark-live-values* look-at-inputs ;
 
 M: #return mark-live-values* look-at-inputs ;
 
@@ -47,9 +45,7 @@ M: #call compute-live-values* nip look-at-inputs ;
 M: #shuffle compute-live-values*
     mapping>> at look-at-value ;
 
-M: #alien-invoke compute-live-values* nip look-at-inputs ;
-
-M: #alien-indirect compute-live-values* nip look-at-inputs ;
+M: #alien-node compute-live-values* nip look-at-inputs ;
 
 : filter-mapping ( assoc -- assoc' )
     live-values get '[ drop _ key? ] assoc-filter ;
@@ -71,7 +67,7 @@ M: #alien-indirect compute-live-values* nip look-at-inputs ;
     filter-corresponding zip #data-shuffle ; inline
 
 :: drop-dead-values ( outputs -- #shuffle )
-    outputs make-values :> new-outputs
+    outputs length make-values :> new-outputs
     outputs filter-live :> live-outputs
     new-outputs
     live-outputs
@@ -127,8 +123,5 @@ M: #terminate remove-dead-code*
     [ filter-live ] change-in-d
     [ filter-live ] change-in-r ;
 
-M: #alien-invoke remove-dead-code*
-    maybe-drop-dead-outputs ;
-
-M: #alien-indirect remove-dead-code*
+M: #alien-node remove-dead-code*
     maybe-drop-dead-outputs ;
index 4bf4cf88f02bb4efb92c0cd341d9977c12dff984..47ec13e809b4eb9f3084c6bb145b4dafc76f0e31 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2006, 2009 Slava Pestov.
+! Copyright (C) 2006, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel assocs match fry accessors namespaces make effects
 sequences sequences.private quotations generic macros arrays
@@ -51,7 +51,6 @@ MATCH-VARS: ?a ?b ?c ;
         { { { ?b ?a } { ?a ?b } } [ swap ] }
         { { { ?b ?a ?c } { ?a ?b ?c } } [ swapd ] }
         { { { ?a ?b } { ?a ?a ?b } } [ dupd ] }
-        { { { ?a ?b } { ?b ?a ?b } } [ tuck ] }
         { { { ?a ?b ?c } { ?a ?b ?c ?a } } [ pick ] }
         { { { ?a ?b ?c } { ?c ?a ?b } } [ -rot ] }
         { { { ?a ?b ?c } { ?b ?c ?a } } [ rot ] }
@@ -65,7 +64,7 @@ TUPLE: shuffle-node { effect effect } ;
 M: shuffle-node pprint* effect>> effect>string text ;
  
 : (shuffle-effect) ( in out #shuffle -- effect )
-    mapping>> '[ _ at ] map <effect> ;
+    mapping>> '[ _ at ] map [ >array ] bi@ <effect> ;
 
 : shuffle-effect ( #shuffle -- effect )
     [ in-d>> ] [ out-d>> ] [ ] tri (shuffle-effect) ;
@@ -127,6 +126,8 @@ M: #alien-invoke node>quot params>> , \ #alien-invoke , ;
 
 M: #alien-indirect node>quot params>> , \ #alien-indirect , ;
 
+M: #alien-assembly node>quot params>> , \ #alien-assembly , ;
+
 M: #alien-callback node>quot params>> , \ #alien-callback , ;
 
 M: node node>quot drop ;
index debb66b8d42044589aee98489e6d00b849b95a39..6c50347c3a82114d7ae61e227c6b57398fa57b4c 100644 (file)
@@ -7,7 +7,7 @@ math.private kernel tools.test accessors slots.private
 quotations.private prettyprint classes.tuple.private classes
 classes.tuple namespaces
 compiler.tree.propagation.info stack-checker.errors
-compiler.tree.checker
+compiler.tree.checker compiler.tree.def-use compiler.tree.dead-code
 kernel.private vectors ;
 IN: compiler.tree.escape-analysis.tests
 
@@ -37,6 +37,8 @@ M: node count-unboxed-allocations* drop ;
     cleanup
     escape-analysis
     dup check-nodes
+    compute-def-use
+    remove-dead-code
     0 swap [ count-unboxed-allocations* ] each-node ;
 
 [ 0 ] [ [ [ + ] curry ] count-unboxed-allocations ] unit-test
@@ -173,12 +175,6 @@ TUPLE: cons { car read-only } { cdr read-only } ;
     [ 10 [ drop ] each-integer ] count-unboxed-allocations
 ] unit-test
 
-[ 2 ] [
-    [
-        1 2 cons boa 10 [ 2drop 1 2 cons boa ] each-integer car>>
-    ] count-unboxed-allocations
-] unit-test
-
 [ 0 ] [
     [
         1 2 cons boa 10 [ drop 2 cons boa ] each-integer car>>
@@ -304,14 +300,6 @@ C: <ro-box> ro-box
 
 [ 0 ] [ [ 1 cons boa "x" get slot ] count-unboxed-allocations ] unit-test
 
-: impeach-node ( quot: ( node -- ) -- )
-    [ call ] keep impeach-node ; inline recursive
-
-: bleach-node ( quot: ( node -- ) -- )
-    [ bleach-node ] curry [ ] compose impeach-node ; inline recursive
-
-[ 3 ] [ [ [ ] bleach-node ] count-unboxed-allocations ] unit-test
-
 [ 0 ] [
     [ dup -1 over >= [ 0 >= [ "A" throw ] unless ] [ drop ] if ]
     count-unboxed-allocations
@@ -322,10 +310,6 @@ C: <ro-box> ro-box
     count-unboxed-allocations
 ] unit-test
 
-[ 0 ] [
-    [ { null } declare [ 1 ] [ 2 ] if ] count-unboxed-allocations
-] unit-test
-
 ! Doug found a regression
 
 TUPLE: empty-tuple ;
index c26f3ddefc02a26a7f779ed1c69aea5829d04649..bb32e6e23b1a229cee60d336cacfcad359547a88 100644 (file)
@@ -1,4 +1,4 @@
-USING: kernel tools.test namespaces sequences
+USING: kernel tools.test namespaces sequences math
 compiler.tree.escape-analysis.recursive
 compiler.tree.escape-analysis.allocations ;
 IN: compiler.tree.escape-analysis.recursive.tests
@@ -6,7 +6,7 @@ IN: compiler.tree.escape-analysis.recursive.tests
 H{ } clone allocations set
 <escaping-values> escaping-values set
 
-[ ] [ 8 [ introduce-value ] each ] unit-test
+[ ] [ 8 [ introduce-value ] each-integer ] unit-test
 
 [ ] [ { 1 2 } 3 record-allocation ] unit-test
 
index c053b15f29704aaa002b4e57418c2e7fa123e385..50fa7ef0a85f18abfd824349817252eb2cba913d 100644 (file)
@@ -86,12 +86,7 @@ M: #call escape-analysis*
 M: #return escape-analysis*
     in-d>> add-escaping-values ;
 
-M: #alien-invoke escape-analysis*
-    [ in-d>> add-escaping-values ]
-    [ out-d>> unknown-allocations ]
-    bi ;
-
-M: #alien-indirect escape-analysis*
+M: #alien-node escape-analysis*
     [ in-d>> add-escaping-values ]
     [ out-d>> unknown-allocations ]
     bi ;
index 42e7f421bfc04073ae014c6abd8d45aa6e931840..7366a83ee176f34df1920eb20c02556d89b7b6ba 100644 (file)
@@ -73,7 +73,7 @@ TUPLE: declared-fixnum { x fixnum } ;
 
 [ t ] [
     [
-        { fixnum } declare 0 swap
+        { fixnum } declare iota 0 swap
         [
             drop 615949 * 797807 + 20 2^ rem dup 19 2^ -
         ] map
@@ -94,7 +94,7 @@ TUPLE: declared-fixnum { x fixnum } ;
 
 [ t ] [
     [
-        { integer } declare [ 256 mod ] map
+        { integer } declare iota [ 256 mod ] map
     ] { mod fixnum-mod } inlined?
 ] unit-test
 
index fcfa42c70ba56388420cc896a217edd4c753c897..7912fce1f68d2c59256aef72c2b963e3da829467 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2008 Slava Pestov.
+! Copyright (C) 2008, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: fry namespaces sequences math math.order accessors kernel arrays
 combinators assocs
@@ -75,10 +75,9 @@ M: #phi normalize*
     ] with-variable ;
 
 M: #recursive normalize*
-    dup label>> introductions>>
-    [ drop [ child>> first ] [ in-d>> ] bi >>in-d drop ]
-    [ make-values '[ _ (normalize) ] change-child ]
-    2bi ;
+    [ [ child>> first ] [ in-d>> ] bi >>in-d drop ]
+    [ dup label>> introductions>> make-values '[ _ (normalize) ] change-child ]
+    bi ;
 
 M: #enter-recursive normalize*
     [ introduction-stack get prepend ] change-out-d
old mode 100755 (executable)
new mode 100644 (file)
index 0d837d8..28f34cb
@@ -97,7 +97,7 @@ M: #phi propagate-before ( #phi -- )
     constraints get last update-constraints ;
 
 : branch-phi-constraints ( output values booleans -- )
-     {
+    {
         {
             { { t } { f } }
             [
@@ -130,6 +130,22 @@ M: #phi propagate-before ( #phi -- )
                 swap t-->
             ]
         }
+        {
+            { { t f } { t } }
+            [
+                first =f
+                condition-value get =t /\
+                swap f-->
+            ]
+        }
+        {
+            { { t } { t f } }
+            [
+                second =f
+                condition-value get =f /\
+                swap f-->
+            ]
+        }
         {
             { { t f } { } }
             [
index 79a9f69de5c2a1566f87f4811c8699db77975263..4a543fb87a1e427bffbdff157faffea8e8831a28 100644 (file)
@@ -1,7 +1,8 @@
 ! Copyright (C) 2009 Slava Pestov, Daniel Ehrenberg.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: compiler.tree.propagation.call-effect tools.test fry math effects kernel
-compiler.tree.builder compiler.tree.optimizer compiler.tree.debugger sequences ;
+compiler.tree.builder compiler.tree.optimizer compiler.tree.debugger sequences
+eval combinators ;
 IN: compiler.tree.propagation.call-effect.tests
 
 [ t ] [ \ + (( a b -- c )) execute-effect-unsafe? ] unit-test
@@ -58,4 +59,23 @@ IN: compiler.tree.propagation.call-effect.tests
 ! [ boa ] by itself doesn't infer
 TUPLE: a-tuple x ;
 
-[ V{ a-tuple } ] [ [ a-tuple '[ _ boa ] call( x -- tuple ) ] final-classes ] unit-test
\ No newline at end of file
+[ V{ a-tuple } ] [ [ a-tuple '[ _ boa ] call( x -- tuple ) ] final-classes ] unit-test
+
+! See if redefinitions are handled correctly
+: call(-redefine-test ( a -- b ) 1 + ;
+
+: test-quotatation ( -- quot ) [ call(-redefine-test ] ;
+
+[ t ] [ test-quotatation cached-effect (( a -- b )) effect<= ] unit-test
+
+[ ] [ "IN: compiler.tree.propagation.call-effect.tests USE: math : call(-redefine-test ( a b -- c ) + ;" eval( -- ) ] unit-test
+
+[ t ] [ test-quotatation cached-effect (( a b -- c )) effect<= ] unit-test
+
+: inline-cache-invalidation-test ( a b c -- c ) call( a b -- c ) ;
+
+[ 4 ] [ 1 3 test-quotatation inline-cache-invalidation-test ] unit-test
+
+[ ] [ "IN: compiler.tree.propagation.call-effect.tests USE: math : call(-redefine-test ( a -- c ) 1 + ;" eval( -- ) ] unit-test
+
+[ 1 3 test-quotatation inline-cache-invalidation-test ] [ T{ wrong-values f (( a b -- c )) } = ] must-fail-with
index 614ceeb59770bf5eb74c0f8b75f41a74b68312da..04320ee792b1b364ba2aae930c1554f9f17932dc 100644 (file)
@@ -1,10 +1,10 @@
-! Copyright (C) 2009 Slava Pestov, Daniel Ehrenberg.
+! Copyright (C) 2009, 2010 Slava Pestov, Daniel Ehrenberg.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors combinators combinators.private effects fry
-kernel kernel.private make sequences continuations quotations
-words math stack-checker stack-checker.transforms
-compiler.tree.propagation.info
-compiler.tree.propagation.inlining ;
+USING: accessors arrays combinators combinators.private effects
+fry kernel kernel.private make sequences continuations
+quotations words math stack-checker combinators.short-circuit
+stack-checker.transforms compiler.tree.propagation.info
+compiler.tree.propagation.inlining compiler.units ;
 IN: compiler.tree.propagation.call-effect
 
 ! call( and execute( have complex expansions.
@@ -15,13 +15,20 @@ IN: compiler.tree.propagation.call-effect
 !   and compare it with declaration. If matches, call it unsafely.
 ! - Fallback. If the above doesn't work, call it and compare the datastack before
 !   and after to make sure it didn't mess anything up.
+! - Inline caches and cached effects are invalidated whenever a macro is redefined, or
+!   a word's effect changes, by comparing a global counter against the counter value
+!   last observed. The counter is incremented by compiler.units.
 
 ! execute( uses a similar strategy.
 
-TUPLE: inline-cache value ;
+TUPLE: inline-cache value counter ;
 
-: cache-hit? ( word/quot ic -- ? )
-    [ value>> eq? ] [ value>> ] bi and ; inline
+: inline-cache-hit? ( word/quot ic -- ? )
+    { [ value>> eq? ] [ nip counter>> effect-counter eq? ] } 2&& ; inline
+
+: update-inline-cache ( word/quot ic -- )
+    [ effect-counter ] dip
+    [ (>>value) ] [ (>>counter) ] bi-curry bi* ; inline
 
 SINGLETON: +unknown+
 
@@ -36,7 +43,7 @@ M: +unknown+ curry-effect ;
 M: effect curry-effect
     [ in>> length ] [ out>> length ] [ terminated?>> ] tri
     pick 0 = [ [ 1 + ] dip ] [ [ 1 - ] 2dip ] if
-    effect boa ;
+    [ [ "x" <array> ] bi@ ] dip effect boa ;
 
 M: curry cached-effect
     quot>> cached-effect curry-effect ;
@@ -53,14 +60,21 @@ M: compose cached-effect
 : safe-infer ( quot -- effect )
     [ infer ] [ 2drop +unknown+ ] recover ;
 
+: cached-effect-valid? ( quot -- ? )
+    cache-counter>> effect-counter eq? ; inline
+
+: save-effect ( effect quot -- )
+    [ effect-counter ] dip
+    [ (>>cached-effect) ] [ (>>cache-counter) ] bi-curry bi* ;
+
 M: quotation cached-effect
-    dup cached-effect>>
-    [ ] [ [ safe-infer dup ] keep (>>cached-effect) ] ?if ;
+    dup cached-effect-valid?
+    [ cached-effect>> ] [ [ safe-infer dup ] keep save-effect ] if ;
 
 : call-effect-unsafe? ( quot effect -- ? )
     [ cached-effect ] dip
     over +unknown+ eq?
-    [ 2drop f ] [ effect<= ] if ; inline
+    [ 2drop f ] [ [ { effect } declare ] dip effect<= ] if ; inline
 
 : (call-effect-slow>quot) ( in out effect -- quot )
     [
@@ -82,12 +96,12 @@ M: quotation cached-effect
 
 : call-effect-fast ( quot effect inline-cache -- )
     2over call-effect-unsafe?
-    [ [ nip (>>value) ] [ drop call-effect-unsafe ] 3bi ]
+    [ [ nip update-inline-cache ] [ drop call-effect-unsafe ] 3bi ]
     [ drop call-effect-slow ]
     if ; inline
 
 : call-effect-ic ( quot effect inline-cache -- )
-    3dup nip cache-hit?
+    3dup nip inline-cache-hit?
     [ drop call-effect-unsafe ]
     [ call-effect-fast ]
     if ; inline
@@ -103,12 +117,12 @@ M: quotation cached-effect
 
 : execute-effect-fast ( word effect inline-cache -- )
     2over execute-effect-unsafe?
-    [ [ nip (>>value) ] [ drop execute-effect-unsafe ] 3bi ]
+    [ [ nip update-inline-cache ] [ drop execute-effect-unsafe ] 3bi ]
     [ drop execute-effect-slow ]
     if ; inline
 
 : execute-effect-ic ( word effect inline-cache -- )
-    3dup nip cache-hit?
+    3dup nip inline-cache-hit?
     [ drop execute-effect-unsafe ]
     [ execute-effect-fast ]
     if ; inline
index 59c9912e47539f3a519a200f207b97d7c3b19f7a..617352d6998fcc8fbd7e627725e7451ec166f052 100644 (file)
@@ -39,8 +39,8 @@ M: true-constraint assume*
     bi ;
 
 M: true-constraint satisfied?
-    value>> value-info class>>
-    { [ true-class? ] [ null-class? not ] } 1&& ;
+    value>> value-info*
+    [ class>> true-class? ] [ drop f ] if ;
 
 TUPLE: false-constraint value ;
 
@@ -52,8 +52,8 @@ M: false-constraint assume*
     bi ;
 
 M: false-constraint satisfied?
-    value>> value-info class>>
-    { [ false-class? ] [ null-class? not ] } 1&& ;
+    value>> value-info*
+    [ class>> false-class? ] [ drop f ] if ;
 
 ! Class constraints
 TUPLE: class-constraint value class ;
index 826131ab612525013b49a2c37c14488d238bbafe..446aad89e5cf224dab4e3e95cc260841c3b19946 100644 (file)
@@ -4,13 +4,6 @@ IN: compiler.tree.propagation.info.tests
 
 [ f ] [ 0.0 -0.0 eql? ] unit-test
 
-[ t ] [
-    number <class-info>
-    sequence <class-info>
-    value-info-intersect
-    class>> integer class=
-] unit-test
-
 [ t t ] [
     0 10 [a,b] <interval-info>
     5 20 [a,b] <interval-info>
index 9030914e340a657faf0c46393ac0b8c32560b1c3..28ffb96f8fe83bb1452f7726438429737db17f8d 100644 (file)
@@ -294,8 +294,11 @@ DEFER: (value-info-union)
 ! Assoc stack of current value --> info mapping
 SYMBOL: value-infos
 
+: value-info* ( value -- info ? )
+    resolve-copy value-infos get assoc-stack [ null-info or ] [ >boolean ] bi ; inline
+
 : value-info ( value -- info )
-    resolve-copy value-infos get assoc-stack null-info or ;
+    value-info* drop ;
 
 : set-value-info ( info value -- )
     resolve-copy value-infos get last set-at ;
@@ -309,16 +312,12 @@ SYMBOL: value-infos
     value-info >literal< ;
 
 : possible-boolean-values ( info -- values )
-    dup literal?>> [
-        literal>> 1array
-    ] [
-        class>> {
-            { [ dup null-class? ] [ { } ] }
-            { [ dup true-class? ] [ { t } ] }
-            { [ dup false-class? ] [ { f } ] }
-            [ { t f } ]
-        } cond nip
-    ] if ;
+    class>> {
+        { [ dup null-class? ] [ { } ] }
+        { [ dup true-class? ] [ { t } ] }
+        { [ dup false-class? ] [ { f } ] }
+        [ { t f } ]
+    } cond nip ;
 
 : node-value-info ( node value -- info )
     swap info>> at* [ drop null-info ] unless ;
index 8afbaf0099082710c1ee8e2805dec359b8e6a575..6aacbc57daaa4a5168f5918ad52368e6c9588f72 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2008, 2009 Slava Pestov.
+! Copyright (C) 2008, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel effects accessors math math.private
 math.integers.private math.floats.private math.partial-dispatch
@@ -8,7 +8,7 @@ classes.algebra combinators generic.math splitting fry locals
 classes.tuple alien.accessors classes.tuple.private
 slots.private definitions strings.private vectors hashtables
 generic quotations alien
-stack-checker.state
+stack-checker.dependencies
 compiler.tree.comparisons
 compiler.tree.propagation.info
 compiler.tree.propagation.nodes
@@ -16,19 +16,17 @@ compiler.tree.propagation.slots
 compiler.tree.propagation.simple
 compiler.tree.propagation.constraints
 compiler.tree.propagation.call-effect
-compiler.tree.propagation.transforms
-compiler.tree.propagation.simd ;
+compiler.tree.propagation.transforms ;
 FROM: alien.c-types => (signed-interval) (unsigned-interval) ;
 IN: compiler.tree.propagation.known-words
 
 { + - * / }
 [ { number number } "input-classes" set-word-prop ] each
 
-{ /f < > <= >= u< u> u<= u>= }
+{ /f /i mod < > <= >= u< u> u<= u>= }
 [ { real real } "input-classes" set-word-prop ] each
 
-{ /i mod /mod }
-[ { rational rational } "input-classes" set-word-prop ] each
+\ /mod { rational rational } "input-classes" set-word-prop
 
 { bitand bitor bitxor bitnot shift }
 [ { integer integer } "input-classes" set-word-prop ] each
index 3627757acd485f736d8703e4ba40f6d1ce5b2718..ad17ccc1c95f32e373ea069a72514c30950d407e 100644 (file)
@@ -1,14 +1,13 @@
 USING: kernel compiler.tree.builder compiler.tree
 compiler.tree.propagation compiler.tree.recursive
-compiler.tree.normalization tools.test math math.order
-accessors sequences arrays kernel.private vectors
-alien.accessors alien.c-types sequences.private
-byte-arrays classes.algebra classes.tuple.private
-math.functions math.private strings layouts
-compiler.tree.propagation.info compiler.tree.def-use
-compiler.tree.debugger compiler.tree.checker
-slots.private words hashtables classes assocs locals
-specialized-arrays system sorting math.libm
+compiler.tree.normalization tools.test math math.order accessors
+sequences arrays kernel.private vectors alien.accessors
+alien.c-types sequences.private byte-arrays classes.algebra
+classes.tuple.private math.functions math.private strings
+layouts compiler.tree.propagation.info compiler.tree.def-use
+compiler.tree.debugger compiler.tree.checker slots.private words
+hashtables classes assocs locals specialized-arrays system
+sorting math.libm math.floats.private math.integers.private
 math.intervals quotations effects alien alien.data ;
 FROM: math => float ;
 SPECIALIZED-ARRAY: double
@@ -91,6 +90,8 @@ IN: compiler.tree.propagation.tests
 
 [ float ] [ [ { float float } declare mod ] final-math-class ] unit-test
 
+[ V{ integer float } ] [ [ { float float } declare [ /i ] keep ] final-classes ] unit-test
+
 [ V{ fixnum } ] [ [ 255 bitand ] final-classes ] unit-test
 
 [ V{ fixnum } ] [
@@ -224,6 +225,14 @@ IN: compiler.tree.propagation.tests
 
 [ t ] [ [ over [ drop f ] when [ "A" throw ] unless ] final-classes first false-class? ] unit-test
 
+[ V{ fixnum } ] [
+    [
+        [ { fixnum } declare ] [ drop f ] if
+        dup [ dup 13 eq? [ t ] [ f ] if ] [ t ] if
+        [ "Oops" throw ] when
+    ] final-classes
+] unit-test
+
 [ V{ fixnum } ] [
     [
         >fixnum
@@ -231,6 +240,14 @@ IN: compiler.tree.propagation.tests
     ] final-classes
 ] unit-test
 
+[ ] [
+    [
+        dup dup dup [ 100 < ] [ drop f ] if dup
+        [ 2drop f ] [ 2drop f ] if
+        [ ] [ dup [ ] [ ] if ] if
+    ] final-info drop
+] unit-test
+
 [ V{ fixnum } ] [
     [ { fixnum } declare (clone) ] final-classes
 ] unit-test
@@ -389,14 +406,6 @@ IN: compiler.tree.propagation.tests
     ] final-literals
 ] unit-test
 
-[ V{ 27 } ] [
-    [
-        dup number? over sequence? and [
-            dup 10 < over 8 <= not and [ 3 * ] [ "A" throw ] if
-        ] [ "B" throw ] if
-    ] final-literals
-] unit-test
-
 [ V{ string string } ] [
     [
         2dup [ dup string? [ "Oops" throw ] unless ] bi@ 2drop
@@ -664,7 +673,7 @@ M: array iterate first t ; inline
 ] unit-test
 
 [ V{ fixnum } ] [
-    [ { fixnum fixnum } declare [ nth-unsafe ] curry call ] final-classes
+    [ { fixnum fixnum } declare iota [ nth-unsafe ] curry call ] final-classes
 ] unit-test
 
 [ V{ f } ] [
@@ -925,3 +934,21 @@ M: tuple-with-read-only-slot clone
 
 ! Could be bignum not integer but who cares
 [ V{ integer } ] [ [ 10 >bignum bitand ] final-classes ] unit-test
+
+[ t ] [ [ { fixnum fixnum } declare min ] { min } inlined? ] unit-test
+[ f ] [ [ { fixnum fixnum } declare min ] { fixnum-min } inlined? ] unit-test
+
+[ t ] [ [ { float float } declare min ] { min } inlined? ] unit-test
+[ f ] [ [ { float float } declare min ] { float-min } inlined? ] unit-test
+
+[ t ] [ [ { fixnum fixnum } declare max ] { max } inlined? ] unit-test
+[ f ] [ [ { fixnum fixnum } declare max ] { fixnum-max } inlined? ] unit-test
+
+[ t ] [ [ { float float } declare max ] { max } inlined? ] unit-test
+[ f ] [ [ { float float } declare max ] { float-max } inlined? ] unit-test
+
+! Propagation should not call equal?, hashcode, etc on literals in user code
+[ V{ } ] [ [ 4 <reversed> [ 2drop ] with each ] final-info ] unit-test
+
+! Reduction
+[ 1 ] [ [ 4 <reversed> [ nth-unsafe ] [ ] unless ] final-info length ] unit-test
index 974bb584eba38b70b82bb59611e59a34908626ae..42325d97ca8ee132d59f2c86a2630a9aa19210a5 100644 (file)
@@ -27,14 +27,16 @@ IN: compiler.tree.propagation.recursive.tests
 ] unit-test
 
 [ t ] [
+    T{ interval f { -268435456 t } { 268435455 t } }
     T{ interval f { 1 t } { 268435455 t } }
-    T{ interval f { -268435456 t } { 268435455 t } } tuck
+    over
     integer generalize-counter-interval =
 ] unit-test
 
 [ t ] [
+    T{ interval f { -268435456 t } { 268435455 t } }
     T{ interval f { 1 t } { 268435455 t } }
-    T{ interval f { -268435456 t } { 268435455 t } } tuck
+    over
     fixnum generalize-counter-interval =
 ] unit-test
 
index 1637148b8838b7764eb785cd70513f404cab957e..250a9379e87b299e17a44676feccaa68c30bb304 100644 (file)
@@ -1,57 +1,81 @@
 ! Copyright (C) 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors byte-arrays combinators fry sequences
-compiler.tree.propagation.info cpu.architecture kernel words math
-math.intervals math.vectors.simd.intrinsics ;
+USING: accessors assocs byte-arrays combinators compiler.cfg.builder
+continuations fry sequences compiler.tree.propagation.info
+cpu.architecture kernel words make math math.intervals
+math.vectors.simd.intrinsics namespaces ;
 IN: compiler.tree.propagation.simd
 
-{
-    (simd-v+)
-    (simd-v-)
-    (simd-vneg)
-    (simd-vabs)
-    (simd-v+-)
-    (simd-v*)
-    (simd-v/)
-    (simd-vmin)
-    (simd-vmax)
-    (simd-sum)
-    (simd-vsqrt)
-    (simd-vbitand)
-    (simd-vbitandn)
-    (simd-vbitor)
-    (simd-vbitxor)
-    (simd-vbitnot)
-    (simd-vand)
-    (simd-vandn)
-    (simd-vor)
-    (simd-vxor)
-    (simd-vnot)
-    (simd-vlshift)
-    (simd-vrshift)
-    (simd-hlshift)
-    (simd-hrshift)
-    (simd-vshuffle-bytes)
-    (simd-vshuffle-elements)
-    (simd-(vmerge-head))
-    (simd-(vmerge-tail))
-    (simd-(v>float))
-    (simd-(v>integer))
-    (simd-(vpack-signed))
-    (simd-(vpack-unsigned))
-    (simd-(vunpack-head))
-    (simd-(vunpack-tail))
-    (simd-v<=)
-    (simd-v<)
-    (simd-v=)
-    (simd-v>)
-    (simd-v>=)
-    (simd-vunordered?)
-    (simd-with)
-    (simd-gather-2)
-    (simd-gather-4)
-    alien-vector
-} [ { byte-array } "default-output-classes" set-word-prop ] each
+CONSTANT: vector>vector-intrinsics
+    {
+        (simd-v+)
+        (simd-v-)
+        (simd-vneg)
+        (simd-v+-)
+        (simd-vs+)
+        (simd-vs-)
+        (simd-vs*)
+        (simd-v*)
+        (simd-v*high)
+        (simd-v*hs+)
+        (simd-v/)
+        (simd-vmin)
+        (simd-vmax)
+        (simd-vavg)
+        (simd-vsqrt)
+        (simd-vabs)
+        (simd-vbitand)
+        (simd-vbitandn)
+        (simd-vbitor)
+        (simd-vbitxor)
+        (simd-vbitnot)
+        (simd-vand)
+        (simd-vandn)
+        (simd-vor)
+        (simd-vxor)
+        (simd-vnot)
+        (simd-vlshift)
+        (simd-vrshift)
+        (simd-hlshift)
+        (simd-hrshift)
+        (simd-vshuffle-elements)
+        (simd-vshuffle-bytes)
+        (simd-vmerge-head)
+        (simd-vmerge-tail)
+        (simd-v<=)
+        (simd-v<)
+        (simd-v=)
+        (simd-v>)
+        (simd-v>=)
+        (simd-vunordered?)
+        (simd-v>float)
+        (simd-v>integer)
+        (simd-vpack-signed)
+        (simd-vpack-unsigned)
+        (simd-vunpack-head)
+        (simd-vunpack-tail)
+        (simd-with)
+        (simd-gather-2)
+        (simd-gather-4)
+        alien-vector
+    }
+
+CONSTANT: vector-other-intrinsics
+    {
+        (simd-v.)
+        (simd-vsad)
+        (simd-sum)
+        (simd-vany?)
+        (simd-vall?)
+        (simd-vnone?)
+        (simd-select)
+        set-alien-vector
+    }
+
+: vector-intrinsics ( -- x )
+    vector>vector-intrinsics vector-other-intrinsics append ;
+
+vector>vector-intrinsics [ { byte-array } "default-output-classes" set-word-prop ] each
 
 : scalar-output-class ( rep -- class )
     dup literal?>> [
@@ -79,12 +103,24 @@ IN: compiler.tree.propagation.simd
     real [0,inf] <class/interval-info> value-info-intersect
 ] "outputs" set-word-prop
 
-! If SIMD is not available, inline alien-vector and set-alien-vector
-! to get a speedup
+: clone-with-value-infos ( node -- node' )
+    clone dup in-d>> [ dup value-info ] H{ } map>assoc >>info ;
+
+: try-intrinsic ( node intrinsic-quot -- ? )
+    '[
+        _ clone-with-value-infos
+        _ with-dummy-cfg-builder
+        t
+    ] [ drop f ] recover ;
+
 : inline-unless-intrinsic ( word -- )
-    dup '[ drop _ dup "intrinsic" word-prop [ drop f ] [ def>> ] if ]
+    dup '[
+        _ swap over "intrinsic" word-prop
+        "always-inline-simd-intrinsics" get not swap and
+        ! word node intrinsic
+        [ try-intrinsic [ drop f ] [ def>> ] if ]
+        [ drop def>> ] if*
+    ]
     "custom-inlining" set-word-prop ;
 
-\ alien-vector inline-unless-intrinsic
-
-\ set-alien-vector inline-unless-intrinsic
+vector-intrinsics [ inline-unless-intrinsic ] each
index 5de5e26a304e4f8d8025157cf06364f5b21259ca..225f10d342ef55b729d37b70cf9b0d486aed2e04 100644 (file)
@@ -4,7 +4,7 @@ USING: fry accessors kernel sequences sequences.private assocs
 words namespaces classes.algebra combinators
 combinators.short-circuit classes classes.tuple
 classes.tuple.private continuations arrays alien.c-types math
-math.private slots generic definitions stack-checker.state
+math.private slots generic definitions stack-checker.dependencies
 compiler.tree
 compiler.tree.propagation.info
 compiler.tree.propagation.nodes
@@ -80,7 +80,7 @@ M: #declare propagate-before
 : (fold-call) ( #call word -- info )
     [ [ out-d>> ] [ in-d>> [ value-info literal>> ] map ] bi ] [ '[ _ execute ] ] bi*
     '[ _ _ with-datastack [ <literal-info> ] map nip ]
-    [ drop [ object-info ] replicate ]
+    [ drop length [ object-info ] replicate ]
     recover ;
 
 : fold-call ( #call word -- )
@@ -153,8 +153,6 @@ M: #call propagate-after
     [ out-d>> ] [ params>> return>> ] bi
     [ drop ] [ c-type-class <class-info> swap first set-value-info ] if-void ;
 
-M: #alien-invoke propagate-before propagate-alien-invoke ;
-
-M: #alien-indirect propagate-before propagate-alien-invoke ;
+M: #alien-node propagate-before propagate-alien-invoke ;
 
 M: #return annotate-node dup in-d>> (annotate-node) ;
index b0605bfb356bfa0660d85410f0a104bc8a10ca86..2d145ef74f637265b300fd14ad350f1ea6229433 100644 (file)
@@ -1,13 +1,14 @@
-! Copyright (C) 2008, 2009 Slava Pestov, Daniel Ehrenberg.
+! Copyright (C) 2008, 2010 Slava Pestov, Daniel Ehrenberg.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel sequences words fry generic accessors
+USING: alien.c-types kernel sequences words fry generic accessors
 classes.tuple classes classes.algebra definitions
-stack-checker.state quotations classes.tuple.private math
+stack-checker.dependencies quotations classes.tuple.private math
 math.partial-dispatch math.private math.intervals sets.private
 math.floats.private math.integers.private layouts math.order
 vectors hashtables combinators effects generalizations assocs
-sets combinators.short-circuit sequences.private locals
+sets combinators.short-circuit sequences.private locals growable
 stack-checker namespaces compiler.tree.propagation.info ;
+FROM: math => float ;
 IN: compiler.tree.propagation.transforms
 
 \ equal? [
@@ -131,26 +132,6 @@ IN: compiler.tree.propagation.transforms
     ] "custom-inlining" set-word-prop
 ] each
 
-! Integrate this with generic arithmetic optimization instead?
-: both-inputs? ( #call class -- ? )
-    [ in-d>> first2 ] dip '[ value-info class>> _ class<= ] both? ;
-
-\ min [
-    {
-        { [ dup fixnum both-inputs? ] [ [ fixnum-min ] ] }
-        { [ dup float both-inputs? ] [ [ float-min ] ] }
-        [ f ]
-    } cond nip
-] "custom-inlining" set-word-prop
-
-\ max [
-    {
-        { [ dup fixnum both-inputs? ] [ [ fixnum-max ] ] }
-        { [ dup float both-inputs? ] [ [ float-max ] ] }
-        [ f ]
-    } cond nip
-] "custom-inlining" set-word-prop
-
 ! Generate more efficient code for common idiom
 \ clone [
     in-d>> first value-info literal>> {
@@ -208,7 +189,7 @@ ERROR: bad-partial-eval quot word ;
 \ index [
     dup sequence? [
         dup length 4 >= [
-            dup length zip >hashtable '[ _ at ]
+            dup length iota zip >hashtable '[ _ at ]
         ] [ drop f ] if
     ] [ drop f ] if
 ] 1 define-partial-eval
@@ -247,7 +228,7 @@ CONSTANT: lookup-table-at-max 256
     } 1&& ;
 
 : lookup-table-seq ( assoc -- table )
-    [ keys supremum 1 + ] keep '[ _ at ] { } map-as ;
+    [ keys supremum 1 + iota ] keep '[ _ at ] { } map-as ;
 
 : lookup-table-quot ( seq -- newquot )
     lookup-table-seq
@@ -309,3 +290,18 @@ CONSTANT: lookup-table-at-max 256
     [ [ >fixnum ] dip fixnum-bit? ] f ? ;
 
 \ bit? [ bit-quot ] "custom-inlining" set-word-prop
+
+! Speeds up sum-file, sort and reverse-complement benchmarks by
+! compiling decoder-readln better
+\ push [
+    in-d>> second value-info class>> growable class<=
+    [ \ push def>> ] [ f ] if
+] "custom-inlining" set-word-prop
+
+! We want to constant-fold calls to heap-size, and recompile those
+! calls when a C type is redefined
+\ heap-size [
+    dup word? [
+        [ inlined-dependency depends-on ] [ heap-size '[ _ ] ] bi
+    ] [ drop f ] if
+] 1 define-partial-eval
index 7fa096b62392f828aef97bee34568b97cf5c93dd..a1d1b4db611f57f909a3cd30e51a2b29f739bed7 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2004, 2008 Slava Pestov.
+! Copyright (C) 2004, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: fry arrays generic assocs kernel math namespaces parser
 sequences words vectors math.intervals classes
@@ -10,8 +10,6 @@ IN: compiler.tree
 
 TUPLE: node < identity-tuple ;
 
-M: node hashcode* drop node hashcode* ;
-
 TUPLE: #introduce < node out-d ;
 
 : #introduce ( out-d -- node )
@@ -151,7 +149,12 @@ TUPLE: #alien-indirect < #alien-node in-d out-d ;
 : #alien-indirect ( params -- node )
     \ #alien-indirect new-alien-node ;
 
-TUPLE: #alien-callback < #alien-node ;
+TUPLE: #alien-assembly < #alien-node in-d out-d ;
+
+: #alien-assembly ( params -- node )
+    \ #alien-assembly new-alien-node ;
+
+TUPLE: #alien-callback < node params ;
 
 : #alien-callback ( params -- node )
     \ #alien-callback new
@@ -189,4 +192,5 @@ M: vector #recursive, #recursive node, ;
 M: vector #copy, #copy node, ;
 M: vector #alien-invoke, #alien-invoke node, ;
 M: vector #alien-indirect, #alien-indirect node, ;
+M: vector #alien-assembly, #alien-assembly node, ;
 M: vector #alien-callback, #alien-callback node, ;
old mode 100755 (executable)
new mode 100644 (file)
index de2848e..d4ca301
@@ -164,9 +164,7 @@ M: #branch unbox-tuples* dup in-d>> assert-not-unboxed ;
 
 M: #return unbox-tuples* dup in-d>> assert-not-unboxed ;
 
-M: #alien-invoke unbox-tuples* dup in-d>> assert-not-unboxed ;
-
-M: #alien-indirect unbox-tuples* dup in-d>> assert-not-unboxed ;
+M: #alien-node unbox-tuples* dup in-d>> assert-not-unboxed ;
 
 M: #alien-callback unbox-tuples* ;
 
old mode 100755 (executable)
new mode 100644 (file)
index 567c435c2e05486e97378c1d7852c149d69e58e2..d96946d53dea21ae96bad72e81a6ccbe0da7cfd6 100644 (file)
@@ -36,7 +36,7 @@ CONSTANT: clen-shuffle { 16 17 18 0 8 7 9 6 10 5 11 4 12 3 13 2 14 1 15 }
     5 bitstream bs:read 1 +
     4 bitstream bs:read 4 + clen-shuffle swap head 
 
-    dup length iota [ 3 bitstream bs:read ] replicate
+    dup length [ 3 bitstream bs:read ] replicate
     get-table
     bitstream swap <huffman-decoder>
     [ 2dup + ] dip swap :> k!
@@ -64,13 +64,13 @@ CONSTANT: clen-shuffle { 16 17 18 0 8 7 9 6 10 5 11 4 12 3 13 2 14 1 15 }
 
 MEMO: static-huffman-tables ( -- obj )
     [
-        0 143 [a,b] [ 8 ] replicate
-        144 255 [a,b] [ 9 ] replicate append
-        256 279 [a,b] [ 7 ] replicate append
-        280 287 [a,b] [ 8 ] replicate append
+        0 143 [a,b] length [ 8 ] replicate
+        144 255 [a,b] length [ 9 ] replicate append
+        256 279 [a,b] length [ 7 ] replicate append
+        280 287 [a,b] length [ 8 ] replicate append
     ] append-outputs
-    0 31 [a,b] [ 5 ] replicate 2array
-    [ [ length>> [0,b) ] [ ] bi get-table ] map ;
+    0 31 [a,b] length [ 5 ] replicate 2array
+    [ [ length>> iota ] [ ] bi get-table ] map ;
 
 CONSTANT: length-table
     {
index cde2a7e1134c537cb7b00a93b9434b17c60ecb75..ce25cd6a63ad2c215bd69ce867c420ac0d0c306d 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2009 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors arrays combinators grouping kernel locals math
-math.matrices math.order multiline sequence-parser sequences
+math.matrices math.order multiline sequences.parser sequences
 tools.continuations ;
 IN: compression.run-length
 
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 1baeba7..b9bc502
@@ -1,9 +1,12 @@
 ! Copyright (C) 2009 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel tools.test compression.zlib classes ;
+USING: accessors kernel tools.test compression.zlib classes ;
+QUALIFIED-WITH: compression.zlib.ffi ffi
 IN: compression.zlib.tests
 
 : compress-me ( -- byte-array ) B{ 1 2 3 4 5 } ;
 
 [ t ] [ compress-me [ compress uncompress ] keep = ] unit-test
 [ t ] [ compress-me compress compressed instance? ] unit-test
+
+[ ffi:Z_DATA_ERROR zlib-error-message ] [ string>> "data error" = ] must-fail-with
old mode 100755 (executable)
new mode 100644 (file)
index 7818173..c662eec
@@ -19,7 +19,9 @@ ERROR: zlib-failed n string ;
     dup compression.zlib.ffi:Z_ERRNO = [
         drop errno "native libc error"
     ] [
-        dup {
+        dup
+        neg ! zlib error codes are negative
+        {
             "no error" "libc_error"
             "stream error" "data error"
             "memory error" "buffer error" "zlib version error"
index d3f3229171bb279522c8d01d0e6c869d62a00077..f33f6513a97330472ef301dd3cac8601419f37bf 100644 (file)
@@ -17,12 +17,12 @@ IN: concurrency.combinators.tests
 [ error>> "Even" = ] must-fail-with\r
 \r
 [ V{ 0 3 6 9 } ]\r
-[ 10 [ 3 mod zero? ] parallel-filter ] unit-test\r
+[ 10 iota [ 3 mod zero? ] parallel-filter ] unit-test\r
 \r
 [ 10 ]\r
 [\r
     V{ } clone\r
-    10 over [ push ] curry parallel-each\r
+    10 iota over [ push ] curry parallel-each\r
     length\r
 ] unit-test\r
 \r
@@ -41,7 +41,7 @@ IN: concurrency.combinators.tests
 [ 20 ]\r
 [\r
     V{ } clone\r
-    10 10 pick [ [ push ] [ push ] bi ] curry 2parallel-each\r
+    10 iota 10 iota pick [ [ push ] [ push ] bi ] curry 2parallel-each\r
     length\r
 ] unit-test\r
 \r
index 244f1d95a34c082ddda82ad597e24d066aedb952..0015b10cef444c70b0903a24545f177a7acc6981 100644 (file)
@@ -60,6 +60,4 @@ M: thread (serialize) ( obj -- )
 
 [
     H{ } clone \ registered-remote-threads set-global
-] "remote-thread-registry" add-init-hook
-
-
+] "remote-thread-registry" add-startup-hook
old mode 100755 (executable)
new mode 100644 (file)
diff --git a/basis/cords/authors.txt b/basis/cords/authors.txt
deleted file mode 100644 (file)
index 1901f27..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Slava Pestov
diff --git a/basis/cords/cords-tests.factor b/basis/cords/cords-tests.factor
deleted file mode 100644 (file)
index 898e4e5..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-USING: cords strings tools.test kernel sequences ;
-IN: cords.tests
-
-[ "hello world" ] [ "hello" " world" cord-append dup like ] unit-test
-[ "hello world" ] [ { "he" "llo" " world" } cord-concat dup like ] unit-test
diff --git a/basis/cords/cords.factor b/basis/cords/cords.factor
deleted file mode 100644 (file)
index a50de60..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-! Copyright (C) 2008 Slava Pestov.
-! See http://factorcode.org/license.txt for BSD license.
-USING: accessors assocs sequences sorting binary-search math
-math.order arrays combinators kernel ;
-IN: cords
-
-<PRIVATE
-
-TUPLE: simple-cord
-    { first read-only } { second read-only } ;
-
-M: simple-cord length
-    [ first>> length ] [ second>> length ] bi + ; inline
-
-M: simple-cord virtual-seq first>> ; inline
-
-M: simple-cord virtual@
-    2dup first>> length <
-    [ first>> ] [ [ first>> length - ] [ second>> ] bi ] if ; inline
-
-TUPLE: multi-cord
-    { count read-only } { seqs read-only } ;
-
-M: multi-cord length count>> ; inline
-
-M: multi-cord virtual@
-    dupd
-    seqs>> [ first <=> ] with search nip
-    [ first - ] [ second ] bi ; inline
-
-M: multi-cord virtual-seq
-    seqs>> [ f ] [ first second ] if-empty ; inline
-
-: <cord> ( seqs -- cord )
-    dup length 2 = [
-        first2 simple-cord boa
-    ] [
-        [ 0 [ length + ] accumulate ] keep zip multi-cord boa
-    ] if ; inline
-
-PRIVATE>
-
-UNION: cord simple-cord multi-cord ;
-
-INSTANCE: cord virtual-sequence
-
-INSTANCE: multi-cord virtual-sequence
-
-: cord-append ( seq1 seq2 -- cord )
-    {
-        { [ over empty? ] [ nip ] }
-        { [ dup empty? ] [ drop ] }
-        { [ 2dup [ cord? ] both? ] [ [ seqs>> values ] bi@ append <cord> ] }
-        { [ over cord? ] [ [ seqs>> values ] dip suffix <cord> ] }
-        { [ dup cord? ] [ seqs>> values swap prefix <cord> ] }
-        [ 2array <cord> ]
-    } cond ; inline
-
-: cord-concat ( seqs -- cord )
-    {
-        { [ dup empty? ] [ drop f ] }
-        { [ dup length 1 = ] [ first ] }
-        [
-            [
-                {
-                    { [ dup cord? ] [ seqs>> values ] }
-                    { [ dup empty? ] [ drop { } ] }
-                    [ 1array ]
-                } cond
-            ] map concat <cord>
-        ]
-    } cond ; inline
diff --git a/basis/cords/summary.txt b/basis/cords/summary.txt
deleted file mode 100644 (file)
index 3c69862..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Virtual sequence concatenation
diff --git a/basis/cords/tags.txt b/basis/cords/tags.txt
deleted file mode 100644 (file)
index 42d711b..0000000
+++ /dev/null
@@ -1 +0,0 @@
-collections
old mode 100755 (executable)
new mode 100644 (file)
index 24ac24b..37dbcd1
@@ -156,7 +156,7 @@ SYMBOL: event-stream-callbacks
 [
     event-stream-callbacks
     [ [ drop expired? not ] assoc-filter H{ } assoc-like ] change-global
-] "core-foundation" add-init-hook
+] "core-foundation" add-startup-hook
 
 : add-event-source-callback ( quot -- id )
     event-stream-counter <alien>
index 0b61274b22fc6debce7bf44ea8b416de8f565a89..2370dd45628dd47005409f8a897c8c6416033685 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors alien alien.c-types alien.syntax kernel math
 namespaces sequences destructors combinators threads heaps
-deques calendar core-foundation core-foundation.strings
+deques calendar system core-foundation core-foundation.strings
 core-foundation.file-descriptors core-foundation.timers
 core-foundation.time ;
 IN: core-foundation.run-loop
@@ -96,12 +96,15 @@ TUPLE: run-loop fds sources timers ;
 : ((reset-timer)) ( timer counter timestamp -- )
     nip >CFAbsoluteTime CFRunLoopTimerSetNextFireDate ;
 
+: nano-count>timestamp ( x -- timestamp )
+    nano-count - nanoseconds now time+ ;
+
 : (reset-timer) ( timer counter -- )
     yield {
         { [ dup 0 = ] [ now ((reset-timer)) ] }
         { [ run-queue deque-empty? not ] [ 1 - (reset-timer) ] }
         { [ sleep-queue heap-empty? ] [ 5 minutes hence ((reset-timer)) ] }
-        [ sleep-queue heap-peek nip micros>timestamp ((reset-timer)) ]
+        [ sleep-queue heap-peek nip nano-count>timestamp ((reset-timer)) ]
     } cond ;
 
 : reset-timer ( timer -- )
@@ -121,8 +124,8 @@ PRIVATE>
 : init-thread-timer ( -- )
     timer-callback <CFTimer> add-timer-to-run-loop ;
 
-: run-one-iteration ( us -- handled? )
+: run-one-iteration ( nanos -- handled? )
     reset-run-loop
     CFRunLoopDefaultMode
-    swap [ microseconds ] [ 5 minutes ] if* >CFTimeInterval
+    swap [ nanoseconds ] [ 5 minutes ] if* >CFTimeInterval
     t CFRunLoopRunInMode kCFRunLoopRunHandledSource = ;
index a5cf69fdee3e23b7fa5db1aec4b59ddd8db3fffa..b6b54df7c3b567865a3926ce0c6d2a7a0967adfa 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: tools.test core-text core-text.fonts core-foundation
 core-foundation.dictionaries destructors arrays kernel generalizations
-math accessors core-foundation.utilities combinators hashtables colors
+locals math accessors core-foundation.utilities combinators hashtables colors
 colors.constants ;
 IN: core-text.tests
 
@@ -18,10 +18,11 @@ IN: core-text.tests
     ] with-destructors
 ] unit-test
 
-: test-typographic-bounds ( string font -- ? )
+:: test-typographic-bounds ( string font -- ? )
     [
-        test-font &CFRelease tuck COLOR: white <CTLine> &CFRelease
-        compute-line-metrics {
+        font test-font &CFRelease :> ctfont
+        string ctfont COLOR: white <CTLine> &CFRelease :> ctline
+        ctfont ctline compute-line-metrics {
             [ width>> float? ]
             [ ascent>> float? ]
             [ descent>> float? ]
@@ -33,4 +34,4 @@ IN: core-text.tests
 
 [ t ] [ "Hello world" "Chicago" test-typographic-bounds ] unit-test
 
-[ t ] [ "日本語" "Helvetica" test-typographic-bounds ] unit-test
\ No newline at end of file
+[ t ] [ "日本語" "Helvetica" test-typographic-bounds ] unit-test
index e431df941424ef135bd90861886a50cc4aade04e..7af6792e79845d8d14517139ba4d86f0b66513b7 100644 (file)
@@ -149,4 +149,4 @@ SYMBOL: cached-lines
 : cached-line ( font string -- line )
     cached-lines get [ <line> ] 2cache ;
 
-[ <cache-assoc> cached-lines set-global ] "core-text" add-init-hook
+[ <cache-assoc> cached-lines set-global ] "core-text" add-startup-hook
index 5c57034632ea973d43a023f0e3a3d4e1ca2ce985..63b9a0f6e155e5670194e5a78181dde923660bb1 100644 (file)
@@ -127,4 +127,4 @@ MEMO: (cache-font-metrics) ( font -- metrics )
 [
     \ (cache-font) reset-memoized
     \ (cache-font-metrics) reset-memoized
-] "core-text.fonts" add-init-hook
+] "core-text.fonts" add-startup-hook
index 6723956780733aae7150cfd7b85bd43e2b96cb70..03090dc4b514138cb6561f6955677a899b9d34c7 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2006, 2009 Slava Pestov.
+! Copyright (C) 2006, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors arrays assocs generic kernel kernel.private
 math memory namespaces make sequences layouts system hashtables
@@ -95,7 +95,7 @@ double-rep
 vector-rep
 scalar-rep ;
 
-: unsign-rep ( rep -- rep' )
+: signed-rep ( rep -- rep' )
     {
         { uint-4-rep           int-4-rep }
         { ulonglong-2-rep      longlong-2-rep }
@@ -105,7 +105,7 @@ scalar-rep ;
         { ushort-scalar-rep    short-scalar-rep }
         { uint-scalar-rep      int-scalar-rep }
         { ulonglong-scalar-rep longlong-scalar-rep }
-    } ?at drop ;
+    } ?at drop ; foldable
 
 : widen-vector-rep ( rep -- rep' )
     {
@@ -115,7 +115,19 @@ scalar-rep ;
         { uchar-16-rep    ushort-8-rep    }
         { ushort-8-rep    uint-4-rep      }
         { uint-4-rep      ulonglong-2-rep }
-    } at ;
+        { float-4-rep     double-2-rep    }
+    } at ; foldable
+
+: narrow-vector-rep ( rep -- rep' )
+    {
+        { short-8-rep     char-16-rep     }
+        { int-4-rep       short-8-rep     }
+        { longlong-2-rep  int-4-rep       }
+        { ushort-8-rep    uchar-16-rep    }
+        { uint-4-rep      ushort-8-rep    }
+        { ulonglong-2-rep uint-4-rep      }
+        { double-2-rep    float-4-rep     }
+    } at ; foldable
 
 ! Register classes
 SINGLETONS: int-regs float-regs ;
@@ -271,14 +283,18 @@ HOOK: %add-sub-vector cpu ( dst src1 src2 rep -- )
 HOOK: %sub-vector cpu ( dst src1 src2 rep -- )
 HOOK: %saturated-sub-vector cpu ( dst src1 src2 rep -- )
 HOOK: %mul-vector cpu ( dst src1 src2 rep -- )
+HOOK: %mul-high-vector cpu ( dst src1 src2 rep -- )
+HOOK: %mul-horizontal-add-vector cpu ( dst src1 src2 rep -- )
 HOOK: %saturated-mul-vector cpu ( dst src1 src2 rep -- )
 HOOK: %div-vector cpu ( dst src1 src2 rep -- )
 HOOK: %min-vector cpu ( dst src1 src2 rep -- )
 HOOK: %max-vector cpu ( dst src1 src2 rep -- )
+HOOK: %avg-vector cpu ( dst src1 src2 rep -- )
 HOOK: %dot-vector cpu ( dst src1 src2 rep -- )
+HOOK: %sad-vector cpu ( dst src1 src2 rep -- )
 HOOK: %sqrt-vector cpu ( dst src rep -- )
-HOOK: %horizontal-add-vector cpu ( dst src rep -- )
-HOOK: %horizontal-sub-vector cpu ( dst src rep -- )
+HOOK: %horizontal-add-vector cpu ( dst src1 src2 rep -- )
+HOOK: %horizontal-sub-vector cpu ( dst src1 src2 rep -- )
 HOOK: %abs-vector cpu ( dst src rep -- )
 HOOK: %and-vector cpu ( dst src1 src2 rep -- )
 HOOK: %andn-vector cpu ( dst src1 src2 rep -- )
@@ -320,11 +336,15 @@ HOOK: %add-sub-vector-reps cpu ( -- reps )
 HOOK: %sub-vector-reps cpu ( -- reps )
 HOOK: %saturated-sub-vector-reps cpu ( -- reps )
 HOOK: %mul-vector-reps cpu ( -- reps )
+HOOK: %mul-high-vector-reps cpu ( -- reps )
+HOOK: %mul-horizontal-add-vector-reps cpu ( -- reps )
 HOOK: %saturated-mul-vector-reps cpu ( -- reps )
 HOOK: %div-vector-reps cpu ( -- reps )
 HOOK: %min-vector-reps cpu ( -- reps )
 HOOK: %max-vector-reps cpu ( -- reps )
+HOOK: %avg-vector-reps cpu ( -- reps )
 HOOK: %dot-vector-reps cpu ( -- reps )
+HOOK: %sad-vector-reps cpu ( -- reps )
 HOOK: %sqrt-vector-reps cpu ( -- reps )
 HOOK: %horizontal-add-vector-reps cpu ( -- reps )
 HOOK: %horizontal-sub-vector-reps cpu ( -- reps )
@@ -385,6 +405,10 @@ M: object %shr-vector-imm-reps { } ;
 M: object %horizontal-shl-vector-imm-reps { } ;
 M: object %horizontal-shr-vector-imm-reps { } ;
 
+ALIAS: %merge-vector-head-reps %merge-vector-reps
+ALIAS: %merge-vector-tail-reps %merge-vector-reps
+ALIAS: %tail>head-vector-reps %unpack-vector-head-reps
+
 HOOK: %unbox-alien cpu ( dst src -- )
 HOOK: %unbox-any-c-ptr cpu ( dst src -- )
 HOOK: %box-alien cpu ( dst src temp -- )
@@ -479,8 +503,27 @@ HOOK: dummy-int-params? cpu ( -- ? )
 ! If t, all int parameters are shadowed by dummy FP parameters
 HOOK: dummy-fp-params? cpu ( -- ? )
 
-HOOK: %prepare-unbox cpu ( n -- )
+! Load a value (from the data stack in the ds register).
+! The value is then passed as a parameter to a VM to_*() function
+HOOK: %pop-stack cpu ( n -- )
+
+! Store a value (to the data stack in the VM's current context)
+! The value is passed to a VM to_*() function -- used for
+! callback returns
+HOOK: %pop-context-stack cpu ( -- )
 
+! Store a value (to the data stack in the ds register).
+! The value was returned from a VM from_*() function
+HOOK: %push-stack cpu ( -- )
+
+! Store a value (to the data stack in the VM's current context)
+! The value is returned from a VM from_*() function -- used for
+! callback parameters
+HOOK: %push-context-stack cpu ( -- )
+
+! Call a function to convert a tagged pointer returned by
+! %pop-stack or %pop-context-stack into a value that can be
+! passed to a C function, or returned from a callback
 HOOK: %unbox cpu ( n rep func -- )
 
 HOOK: %unbox-long-long cpu ( n func -- )
@@ -489,6 +532,10 @@ HOOK: %unbox-small-struct cpu ( c-type -- )
 
 HOOK: %unbox-large-struct cpu ( n c-type -- )
 
+! Call a function to convert a value into a tagged pointer,
+! possibly allocating a bignum, float, or alien instance,
+! which is then pushed on the data stack by %push-stack or
+! %push-context-stack
 HOOK: %box cpu ( n rep func -- )
 
 HOOK: %box-long-long cpu ( n func -- )
@@ -503,7 +550,9 @@ HOOK: %save-param-reg cpu ( stack reg rep -- )
 
 HOOK: %load-param-reg cpu ( stack reg rep -- )
 
-HOOK: %save-context cpu ( temp1 temp2 callback-allowed? -- )
+HOOK: %restore-context cpu ( temp1 temp2 -- )
+
+HOOK: %save-context cpu ( temp1 temp2 -- )
 
 HOOK: %prepare-var-args cpu ( -- )
 
@@ -527,7 +576,6 @@ HOOK: %nest-stacks cpu ( -- )
 
 HOOK: %unnest-stacks cpu ( -- )
 
-! Return to caller with stdcall unwinding (only for x86)
-HOOK: %callback-return cpu ( params -- )
+HOOK: callback-return-rewind cpu ( params -- n )
 
-M: object %callback-return drop %return ;
+M: object callback-return-rewind drop 0 ;
old mode 100755 (executable)
new mode 100644 (file)
index c16d564e13751d96e07009048a791bb515565233..698fc6257a3b2bc3c61060cc46003b2c641928a5 100644 (file)
@@ -1,9 +1,9 @@
-! Copyright (C) 2007, 2008 Slava Pestov.\r
+! Copyright (C) 2007, 2010 Slava Pestov.\r
 ! See http://factorcode.org/license.txt for BSD license.\r
 USING: bootstrap.image.private kernel kernel.private namespaces\r
-system cpu.ppc.assembler compiler.codegen.fixup compiler.units\r
-compiler.constants math math.private layouts words\r
-vocabs slots.private locals.backend ;\r
+system cpu.ppc.assembler compiler.units compiler.constants math\r
+math.private math.ranges layouts words vocabs slots.private\r
+locals locals.backend generic.single.private fry sequences ;\r
 FROM: cpu.ppc.assembler => B ;\r
 IN: bootstrap.ppc\r
 \r
@@ -12,17 +12,92 @@ big-endian on
 \r
 CONSTANT: ds-reg 13\r
 CONSTANT: rs-reg 14\r
+CONSTANT: vm-reg 15\r
+CONSTANT: ctx-reg 16\r
 \r
-: factor-area-size ( -- n ) 4 bootstrap-cells ;\r
+: factor-area-size ( -- n ) 16 ;\r
 \r
 : stack-frame ( -- n )\r
-    factor-area-size c-area-size + 4 bootstrap-cells align ;\r
+    reserved-size\r
+    factor-area-size +\r
+    16 align ;\r
 \r
-: next-save ( -- n ) stack-frame bootstrap-cell - ;\r
-: xt-save ( -- n ) stack-frame 2 bootstrap-cells - ;\r
+: next-save ( -- n ) stack-frame 4 - ;\r
+: xt-save ( -- n ) stack-frame 8 - ;\r
+\r
+: param-size ( -- n ) 32 ;\r
+\r
+: save-at ( m -- n ) reserved-size + param-size + ;\r
+\r
+: save-int ( register offset -- ) [ 1 ] dip save-at STW ;\r
+: restore-int ( register offset -- ) [ 1 ] dip save-at LWZ ;\r
+\r
+: save-fp ( register offset -- ) [ 1 ] dip save-at STFD ;\r
+: restore-fp ( register offset -- ) [ 1 ] dip save-at LFD ;\r
+\r
+: save-vec ( register offset -- ) save-at 2 LI 2 1 STVXL ;\r
+: restore-vec ( register offset -- ) save-at 2 LI 2 1 LVXL ;\r
+\r
+: nv-int-regs ( -- seq ) 13 31 [a,b] ;\r
+: nv-fp-regs ( -- seq ) 14 31 [a,b] ;\r
+: nv-vec-regs ( -- seq ) 20 31 [a,b] ;\r
+\r
+: saved-int-regs-size ( -- n ) 96 ;\r
+: saved-fp-regs-size ( -- n ) 144 ;\r
+: saved-vec-regs-size ( -- n ) 208 ;\r
+\r
+: callback-frame-size ( -- n )\r
+    reserved-size\r
+    param-size +\r
+    saved-int-regs-size +\r
+    saved-fp-regs-size +\r
+    saved-vec-regs-size +\r
+    16 align ;\r
 \r
 [\r
-    0 3 LOAD32 rc-absolute-ppc-2/2 rt-immediate jit-rel\r
+    0 MFLR\r
+    1 1 callback-frame-size neg STWU\r
+    0 1 callback-frame-size lr-save + STW\r
+\r
+    nv-int-regs [ 4 * save-int ] each-index\r
+    nv-fp-regs [ 8 * 80 + save-fp ] each-index\r
+    nv-vec-regs [ 16 * 224 + save-vec ] each-index\r
+\r
+    0 vm-reg LOAD32 rc-absolute-ppc-2/2 rt-vm jit-rel\r
+\r
+    0 2 LOAD32 rc-absolute-ppc-2/2 rt-entry-point jit-rel\r
+    2 MTLR\r
+    BLRL\r
+\r
+    nv-vec-regs [ 16 * 224 + restore-vec ] each-index\r
+    nv-fp-regs [ 8 * 80 + restore-fp ] each-index\r
+    nv-int-regs [ 4 * restore-int ] each-index\r
+\r
+    0 1 callback-frame-size lr-save + LWZ\r
+    1 1 0 LWZ\r
+    0 MTLR\r
+    BLR\r
+] callback-stub jit-define\r
+\r
+: jit-conditional* ( test-quot false-quot -- )\r
+    [ '[ 4 /i 1 + @ ] ] dip jit-conditional ; inline\r
+\r
+: jit-load-context ( -- )\r
+    ctx-reg vm-reg vm-context-offset LWZ ;\r
+\r
+: jit-save-context ( -- )\r
+    jit-load-context\r
+    1 ctx-reg context-callstack-top-offset STW\r
+    ds-reg ctx-reg context-datastack-offset STW\r
+    rs-reg ctx-reg context-retainstack-offset STW ;\r
+\r
+: jit-restore-context ( -- )\r
+    jit-load-context\r
+    ds-reg ctx-reg context-datastack-offset LWZ\r
+    rs-reg ctx-reg context-retainstack-offset LWZ ;\r
+\r
+[\r
+    0 3 LOAD32 rc-absolute-ppc-2/2 rt-literal jit-rel\r
     11 3 profile-count-offset LWZ\r
     11 11 1 tag-fixnum ADDI\r
     11 3 profile-count-offset STW\r
@@ -33,46 +108,42 @@ CONSTANT: rs-reg 14
 ] jit-profiling jit-define\r
 \r
 [\r
-    0 3 LOAD32 rc-absolute-ppc-2/2 rt-this jit-rel\r
+    0 2 LOAD32 rc-absolute-ppc-2/2 rt-this jit-rel\r
     0 MFLR\r
     1 1 stack-frame SUBI\r
-    3 1 xt-save STW\r
-    stack-frame 3 LI\r
-    3 1 next-save STW\r
+    2 1 xt-save STW\r
+    stack-frame 2 LI\r
+    2 1 next-save STW\r
     0 1 lr-save stack-frame + STW\r
 ] jit-prolog jit-define\r
 \r
 [\r
-    0 3 LOAD32 rc-absolute-ppc-2/2 rt-immediate jit-rel\r
+    0 3 LOAD32 rc-absolute-ppc-2/2 rt-literal jit-rel\r
     3 ds-reg 4 STWU\r
-] jit-push-immediate jit-define\r
+] jit-push jit-define\r
 \r
 [\r
-    0 3 LOAD32 rc-absolute-ppc-2/2 rt-stack-chain jit-rel\r
-    4 3 0 LWZ\r
-    1 4 0 STW\r
-    4 0 swap LOAD32 rc-absolute-ppc-2/2 rt-vm jit-rel\r
-    0 5 LOAD32 rc-absolute-ppc-2/2 rt-primitive jit-rel\r
-    5 MTCTR\r
-    BCTR\r
+    jit-save-context\r
+    3 vm-reg MR\r
+    0 4 LOAD32 rc-absolute-ppc-2/2 rt-dlsym jit-rel\r
+    4 MTLR\r
+    BLRL\r
+    jit-restore-context\r
 ] jit-primitive jit-define\r
 \r
-[ 0 BL rc-relative-ppc-3 rt-xt-pic jit-rel ] jit-word-call jit-define\r
+[ 0 BL rc-relative-ppc-3 rt-entry-point-pic jit-rel ] jit-word-call jit-define\r
 \r
 [\r
     0 6 LOAD32 rc-absolute-ppc-2/2 rt-here jit-rel\r
-    0 B rc-relative-ppc-3 rt-xt-pic-tail jit-rel\r
+    0 B rc-relative-ppc-3 rt-entry-point-pic-tail jit-rel\r
 ] jit-word-jump jit-define\r
 \r
-[ 0 B rc-relative-ppc-3 rt-xt jit-rel ] jit-word-special jit-define\r
-\r
 [\r
     3 ds-reg 0 LWZ\r
     ds-reg dup 4 SUBI\r
     0 3 \ f type-number CMPI\r
-    2 BEQ\r
-    0 B rc-relative-ppc-3 rt-xt jit-rel\r
-    0 B rc-relative-ppc-3 rt-xt jit-rel\r
+    [ BEQ ] [ 0 B rc-relative-ppc-3 rt-entry-point jit-rel ] jit-conditional*\r
+    0 B rc-relative-ppc-3 rt-entry-point jit-rel\r
 ] jit-if jit-define\r
 \r
 : jit->r ( -- )\r
@@ -123,32 +194,22 @@ CONSTANT: rs-reg 14
 \r
 [\r
     jit->r\r
-    0 BL rc-relative-ppc-3 rt-xt jit-rel\r
+    0 BL rc-relative-ppc-3 rt-entry-point jit-rel\r
     jit-r>\r
 ] jit-dip jit-define\r
 \r
 [\r
     jit-2>r\r
-    0 BL rc-relative-ppc-3 rt-xt jit-rel\r
+    0 BL rc-relative-ppc-3 rt-entry-point jit-rel\r
     jit-2r>\r
 ] jit-2dip jit-define\r
 \r
 [\r
     jit-3>r\r
-    0 BL rc-relative-ppc-3 rt-xt jit-rel\r
+    0 BL rc-relative-ppc-3 rt-entry-point jit-rel\r
     jit-3r>\r
 ] jit-3dip jit-define\r
 \r
-: prepare-(execute) ( -- operand )\r
-    3 ds-reg 0 LWZ\r
-    ds-reg dup 4 SUBI\r
-    4 3 word-xt-offset LWZ\r
-    4 ;\r
-\r
-[ prepare-(execute) MTCTR BCTR ] jit-execute-jump jit-define\r
-\r
-[ prepare-(execute) MTLR BLRL ] jit-execute-call jit-define\r
-\r
 [\r
     0 1 lr-save stack-frame + LWZ\r
     1 1 stack-frame ADDI\r
@@ -179,35 +240,57 @@ CONSTANT: rs-reg 14
     3 4 MR\r
     load-tag\r
     0 4 tuple type-number tag-fixnum CMPI\r
-    2 BNE\r
-    4 3 tuple type-number neg bootstrap-cell + LWZ\r
+    [ BNE ]\r
+    [ 4 3 tuple type-number neg 4 + LWZ ]\r
+    jit-conditional*\r
 ] pic-tuple jit-define\r
 \r
 [\r
-    0 4 0 CMPI rc-absolute-ppc-2 rt-immediate jit-rel\r
+    0 4 0 CMPI rc-absolute-ppc-2 rt-literal jit-rel\r
 ] pic-check-tag jit-define\r
 \r
 [\r
-    0 5 LOAD32 rc-absolute-ppc-2/2 rt-immediate jit-rel\r
+    0 5 LOAD32 rc-absolute-ppc-2/2 rt-literal jit-rel\r
     4 0 5 CMP\r
 ] pic-check-tuple jit-define\r
 \r
-[ 2 BNE 0 B rc-relative-ppc-3 rt-xt jit-rel ] pic-hit jit-define\r
+[\r
+    [ BNE ] [ 0 B rc-relative-ppc-3 rt-entry-point jit-rel ] jit-conditional*\r
+] pic-hit jit-define\r
+\r
+! Inline cache miss entry points\r
+: jit-load-return-address ( -- ) 6 MFLR ;\r
+\r
+! These are always in tail position with an existing stack\r
+! frame, and the stack. The frame setup takes this into account.\r
+: jit-inline-cache-miss ( -- )\r
+    jit-save-context\r
+    3 6 MR\r
+    4 vm-reg MR\r
+    0 5 LOAD32 "inline_cache_miss" f rc-absolute-ppc-2/2 jit-dlsym\r
+    5 MTLR\r
+    BLRL\r
+    jit-restore-context ;\r
+\r
+[ jit-load-return-address jit-inline-cache-miss ]\r
+[ 3 MTLR BLRL ]\r
+[ 3 MTCTR BCTR ]\r
+\ inline-cache-miss define-combinator-primitive\r
+\r
+[ jit-inline-cache-miss ]\r
+[ 3 MTLR BLRL ]\r
+[ 3 MTCTR BCTR ]\r
+\ inline-cache-miss-tail define-combinator-primitive\r
 \r
 ! ! ! Megamorphic caches\r
 \r
 [\r
     ! cache = ...\r
-    0 3 LOAD32 rc-absolute-ppc-2/2 rt-immediate jit-rel\r
+    0 3 LOAD32 rc-absolute-ppc-2/2 rt-literal jit-rel\r
     ! key = hashcode(class)\r
-    5 4 3 SRAWI\r
-    6 4 8 SRAWI\r
-    5 5 6 ADD\r
-    6 4 13 SRAWI\r
-    5 5 6 ADD\r
-    5 5 3 SLWI\r
+    5 4 1 SRAWI\r
     ! key &= cache.length - 1\r
-    5 5 mega-cache-size get 1 - bootstrap-cell * ANDI\r
+    5 5 mega-cache-size get 1 - 4 * ANDI\r
     ! cache += array-start-offset\r
     3 3 array-start-offset ADDI\r
     ! cache += key\r
@@ -215,37 +298,121 @@ CONSTANT: rs-reg 14
     ! if(get(cache) == class)\r
     6 3 0 LWZ\r
     6 0 4 CMP\r
-    10 BNE\r
-    ! megamorphic_cache_hits++\r
-    0 4 LOAD32 rc-absolute-ppc-2/2 rt-megamorphic-cache-hits jit-rel\r
-    5 4 0 LWZ\r
-    5 5 1 ADDI\r
-    5 4 0 STW\r
-    ! ... goto get(cache + bootstrap-cell)\r
-    3 3 4 LWZ\r
-    3 3 word-xt-offset LWZ\r
-    3 MTCTR\r
-    BCTR\r
+    [ BNE ]\r
+    [\r
+        ! megamorphic_cache_hits++\r
+        0 4 LOAD32 rc-absolute-ppc-2/2 rt-megamorphic-cache-hits jit-rel\r
+        5 4 0 LWZ\r
+        5 5 1 ADDI\r
+        5 4 0 STW\r
+        ! ... goto get(cache + 4)\r
+        3 3 4 LWZ\r
+        3 3 word-entry-point-offset LWZ\r
+        3 MTCTR\r
+        BCTR\r
+    ]\r
+    jit-conditional*\r
     ! fall-through on miss\r
 ] mega-lookup jit-define\r
 \r
-[\r
-    0 2 LOAD32 rc-absolute-ppc-2/2 rt-xt jit-rel\r
-    2 MTCTR\r
-    BCTR\r
-] callback-stub jit-define\r
-\r
 ! ! ! Sub-primitives\r
 \r
 ! Quotations and words\r
 [\r
     3 ds-reg 0 LWZ\r
     ds-reg dup 4 SUBI\r
-    4 0 swap LOAD32 0 jit-literal rc-absolute-ppc-2/2 rt-vm jit-rel\r
-    5 3 quot-xt-offset LWZ\r
-    5 MTCTR\r
+    5 3 quot-entry-point-offset LWZ\r
+]\r
+[ 5 MTLR BLRL ]\r
+[ 5 MTCTR BCTR ] \ (call) define-combinator-primitive\r
+\r
+[\r
+    3 ds-reg 0 LWZ\r
+    ds-reg dup 4 SUBI\r
+    4 3 word-entry-point-offset LWZ\r
+]\r
+[ 4 MTLR BLRL ]\r
+[ 4 MTCTR BCTR ] \ (execute) define-combinator-primitive\r
+\r
+[\r
+    3 ds-reg 0 LWZ\r
+    ds-reg dup 4 SUBI\r
+    4 3 word-entry-point-offset LWZ\r
+    4 MTCTR BCTR\r
+] jit-execute jit-define\r
+\r
+! Special primitives\r
+[\r
+    jit-restore-context\r
+    ! Save ctx->callstack_bottom\r
+    1 ctx-reg context-callstack-bottom-offset STW\r
+    ! Call quotation\r
+    5 3 quot-entry-point-offset LWZ\r
+    5 MTLR\r
+    BLRL\r
+    jit-save-context\r
+] \ c-to-factor define-sub-primitive\r
+\r
+[\r
+    ! Unwind stack frames\r
+    1 4 MR\r
+\r
+    ! Load VM pointer into vm-reg, since we're entering from\r
+    ! C code\r
+    0 vm-reg LOAD32 0 rc-absolute-ppc-2/2 jit-vm\r
+\r
+    ! Load ds and rs registers\r
+    jit-restore-context\r
+\r
+    ! We have changed the stack; load return address again\r
+    0 1 lr-save LWZ\r
+    0 MTLR\r
+\r
+    ! Call quotation\r
+    4 3 quot-entry-point-offset LWZ\r
+    4 MTCTR\r
     BCTR\r
-] \ (call) define-sub-primitive\r
+] \ unwind-native-frames define-sub-primitive\r
+\r
+[\r
+    ! Load callstack object\r
+    6 ds-reg 0 LWZ\r
+    ds-reg ds-reg 4 SUBI\r
+    ! Get ctx->callstack_bottom\r
+    jit-load-context\r
+    3 ctx-reg context-callstack-bottom-offset LWZ\r
+    ! Get top of callstack object -- 'src' for memcpy\r
+    4 6 callstack-top-offset ADDI\r
+    ! Get callstack length, in bytes --- 'len' for memcpy\r
+    5 6 callstack-length-offset LWZ\r
+    5 5 tag-bits get SRAWI\r
+    ! Compute new stack pointer -- 'dst' for memcpy\r
+    3 5 3 SUBF\r
+    ! Install new stack pointer\r
+    1 3 MR\r
+    ! Call memcpy; arguments are now in the correct registers\r
+    1 1 -64 STWU\r
+    0 2 LOAD32 "factor_memcpy" f rc-absolute-ppc-2/2 jit-dlsym\r
+    2 MTLR\r
+    BLRL\r
+    1 1 0 LWZ\r
+    ! Return with new callstack\r
+    0 1 lr-save LWZ\r
+    0 MTLR\r
+    BLR\r
+] \ set-callstack define-sub-primitive\r
+\r
+[\r
+    jit-save-context\r
+    4 vm-reg MR\r
+    0 2 LOAD32 "lazy_jit_compile" f rc-absolute-ppc-2/2 jit-dlsym\r
+    2 MTLR\r
+    BLRL\r
+    5 3 quot-entry-point-offset LWZ\r
+]\r
+[ 5 MTLR BLRL ]\r
+[ 5 MTCTR BCTR ]\r
+\ lazy-jit-compile define-combinator-primitive\r
 \r
 ! Objects\r
 [\r
@@ -329,14 +496,6 @@ CONSTANT: rs-reg 14
     3 ds-reg 4 STWU\r
 ] \ dupd define-sub-primitive\r
 \r
-[\r
-    3 ds-reg 0 LWZ\r
-    4 ds-reg -4 LWZ\r
-    3 ds-reg 4 STWU\r
-    4 ds-reg -4 STW\r
-    3 ds-reg -8 STW\r
-] \ tuck define-sub-primitive\r
-\r
 [\r
     3 ds-reg 0 LWZ\r
     4 ds-reg -4 LWZ\r
@@ -374,7 +533,7 @@ CONSTANT: rs-reg 14
 ! Comparisons\r
 : jit-compare ( insn -- )\r
     t jit-literal\r
-    0 3 LOAD32 rc-absolute-ppc-2/2 rt-immediate jit-rel\r
+    0 3 LOAD32 rc-absolute-ppc-2/2 rt-literal jit-rel\r
     4 ds-reg 0 LWZ\r
     5 ds-reg -4 LWZU\r
     5 0 4 CMP\r
@@ -400,8 +559,7 @@ CONSTANT: rs-reg 14
     3 3 tag-mask get ANDI\r
     \ f type-number 4 LI\r
     0 3 0 CMPI\r
-    2 BNE\r
-    1 tag-fixnum 4 LI\r
+    [ BNE ] [ 1 tag-fixnum 4 LI ] jit-conditional*\r
     4 ds-reg 0 STW\r
 ] \ both-fixnums? define-sub-primitive\r
 \r
@@ -446,8 +604,7 @@ CONSTANT: rs-reg 14
     7 4 6 SRAW\r
     7 7 0 0 31 tag-bits get - RLWINM\r
     0 3 0 CMPI\r
-    2 BGT\r
-    5 7 MR\r
+    [ BGT ] [ 5 7 MR ] jit-conditional*\r
     5 ds-reg 0 STW\r
 ] \ fixnum-shift-fast define-sub-primitive\r
 \r
@@ -483,7 +640,7 @@ CONSTANT: rs-reg 14
 \r
 [\r
     3 ds-reg 0 LWZ\r
-    3 3 1 SRAWI\r
+    3 3 2 SRAWI\r
     rs-reg 3 3 LWZX\r
     3 ds-reg 0 STW\r
 ] \ get-local define-sub-primitive\r
@@ -491,8 +648,52 @@ CONSTANT: rs-reg 14
 [\r
     3 ds-reg 0 LWZ\r
     ds-reg ds-reg 4 SUBI\r
-    3 3 1 SRAWI\r
+    3 3 2 SRAWI\r
     rs-reg 3 rs-reg SUBF\r
 ] \ drop-locals define-sub-primitive\r
 \r
+! Overflowing fixnum arithmetic\r
+:: jit-overflow ( insn func -- )\r
+    ds-reg ds-reg 4 SUBI\r
+    jit-save-context\r
+    3 ds-reg 0 LWZ\r
+    4 ds-reg 4 LWZ\r
+    0 0 LI\r
+    0 MTXER\r
+    6 4 3 insn call( d a s -- )\r
+    6 ds-reg 0 STW\r
+    [ BNO ]\r
+    [\r
+        5 vm-reg MR\r
+        0 6 LOAD32 func f rc-absolute-ppc-2/2 jit-dlsym\r
+        6 MTLR\r
+        BLRL\r
+    ]\r
+    jit-conditional* ;\r
+\r
+[ [ ADDO. ] "overflow_fixnum_add" jit-overflow ] \ fixnum+ define-sub-primitive\r
+\r
+[ [ SUBFO. ] "overflow_fixnum_subtract" jit-overflow ] \ fixnum- define-sub-primitive\r
+\r
+[\r
+    ds-reg ds-reg 4 SUBI\r
+    jit-save-context\r
+    3 ds-reg 0 LWZ\r
+    3 3 tag-bits get SRAWI\r
+    4 ds-reg 4 LWZ\r
+    0 0 LI\r
+    0 MTXER\r
+    6 3 4 MULLWO.\r
+    6 ds-reg 0 STW\r
+    [ BNO ]\r
+    [\r
+        4 4 tag-bits get SRAWI\r
+        5 vm-reg MR\r
+        0 6 LOAD32 "overflow_fixnum_multiply" f rc-absolute-ppc-2/2 jit-dlsym\r
+        6 MTLR\r
+        BLRL\r
+    ]\r
+    jit-conditional*\r
+] \ fixnum* define-sub-primitive\r
+\r
 [ "bootstrap.ppc" forget-vocab ] with-compilation-unit\r
index a5250414ab22dbb7abd63ca75ff43e219f2d316e..2f463dea007515dbe88c014c121c8f02533fe5f5 100644 (file)
@@ -1,10 +1,10 @@
-! Copyright (C) 2007, 2008 Slava Pestov.
+! Copyright (C) 2007, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: parser layouts system kernel sequences ;
+USING: parser system kernel sequences ;
 IN: bootstrap.ppc
 
-: c-area-size ( -- n ) 10 bootstrap-cells ;
-: lr-save ( -- n ) bootstrap-cell ;
+: reserved-size ( -- n ) 24 ;
+: lr-save ( -- n ) 4 ;
 
 << "vocab:cpu/ppc/bootstrap.factor" parse-file suffix! >>
 call
index 2aa0ddc4a27f4ec8e5e392e5442add49aea30531..0960011c70163e9f7081830282de9d3a2f51170a 100644 (file)
@@ -1,10 +1,10 @@
-! Copyright (C) 2007, 2008 Slava Pestov.
+! Copyright (C) 2007, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: parser layouts system kernel sequences ;
+USING: parser system kernel sequences ;
 IN: bootstrap.ppc
 
-: c-area-size ( -- n ) 14 bootstrap-cells ;
-: lr-save ( -- n ) 2 bootstrap-cells ;
+: reserved-size ( -- n ) 24 ;
+: lr-save ( -- n ) 8 ;
 
 << "vocab:cpu/ppc/bootstrap.factor" parse-file suffix! >>
 call
index c742cf2ddc2aba25ecef3d8e828626dd4ba0ac87..152a3aa7209e81f1c2f982802c27b5a4fb66ca48 100644 (file)
@@ -4,12 +4,6 @@ USING: accessors system kernel layouts
 alien.c-types cpu.architecture cpu.ppc ;
 IN: cpu.ppc.macosx
 
-<<
-4 "longlong" c-type (>>align)
-4 "ulonglong" c-type (>>align)
-4 "double" c-type (>>align)
->>
-
 M: macosx reserved-area-size 6 cells ;
 
 M: macosx lr-save 2 cells ;
index 0f33df8df7cc8a6fef0a8d2effa0ed0cbf08b82b..a914b3551e7de1800403cc827331a05450319a1f 100644 (file)
@@ -15,7 +15,10 @@ IN: cpu.ppc
 
 ! PowerPC register assignments:
 ! r2-r12: integer vregs
-! r15-r29
+! r13: data stack
+! r14: retain stack
+! r15: VM pointer
+! r16-r29: integer vregs
 ! r30: integer scratch
 ! f0-f29: float vregs
 ! f30: float scratch
@@ -31,18 +34,9 @@ enable-float-intrinsics
 \ ##float>integer t frame-required? set-word-prop
 >>
 
-: %load-vm-addr ( reg -- )
-    0 swap LOAD32 0 rc-absolute-ppc-2/2 rel-vm ;
-
-: %load-vm-field-addr ( reg symbol -- )
-    [ 0 swap LOAD32 ] dip
-    vm-field-offset rc-absolute-ppc-2/2 rel-vm ;
-
-M: ppc %vm-field-ptr ( dst field -- ) %load-vm-field-addr ;
-
 M: ppc machine-registers
     {
-        { int-regs $[ 2 12 [a,b] 15 29 [a,b] append ] }
+        { int-regs $[ 2 12 [a,b] 16 29 [a,b] append ] }
         { float-regs $[ 0 29 [a,b] ] }
     } ;
 
@@ -59,6 +53,14 @@ M: ppc %alien-global ( register symbol dll -- )
 
 CONSTANT: ds-reg 13
 CONSTANT: rs-reg 14
+CONSTANT: vm-reg 15
+
+: %load-vm-addr ( reg -- ) vm-reg MR ;
+
+: %load-vm-field-addr ( reg symbol -- )
+    [ vm-reg ] dip vm-field-offset ADDI ;
+
+M: ppc %vm-field-ptr ( dst field -- ) %load-vm-field-addr ;
 
 GENERIC: loc-reg ( loc -- reg )
 
@@ -79,10 +81,10 @@ M: ppc %inc-r ( n -- ) rs-reg (%inc) ;
 HOOK: reserved-area-size os ( -- n )
 
 ! The start of the stack frame contains the size of this frame
-! as well as the currently executing XT
+! as well as the currently executing code block
 : factor-area-size ( -- n ) 2 cells ; foldable
-: next-save ( n -- i ) cell - ;
-: xt-save ( n -- i ) 2 cells - ;
+: next-save ( n -- i ) cell - ; foldable
+: xt-save ( n -- i ) 2 cells - ; foldable
 
 ! Next, we have the spill area as well as the FFI parameter area.
 ! It is safe for them to overlap, since basic blocks with FFI calls
@@ -124,7 +126,7 @@ M: ppc stack-frame-size ( stack-frame -- i )
 M: ppc %call ( word -- ) 0 BL rc-relative-ppc-3 rel-word-pic ;
 
 M: ppc %jump ( word -- )
-    0 6 LOAD32 8 rc-absolute-ppc-2/2 rel-here
+    0 6 LOAD32 4 rc-absolute-ppc-2/2 rel-here
     0 B rc-relative-ppc-3 rel-word-pic-tail ;
 
 M: ppc %jump-label ( label -- ) B ;
@@ -132,7 +134,7 @@ M: ppc %return ( -- ) BLR ;
 
 M:: ppc %dispatch ( src temp -- )
     0 temp LOAD32
-    4 cells rc-absolute-ppc-2/2 rel-here
+    3 cells rc-absolute-ppc-2/2 rel-here
     temp temp src LWZX
     temp MTCTR
     BCTR ;
@@ -256,35 +258,22 @@ M: ppc %double>single-float FRSP ;
 M: ppc %unbox-alien ( dst src -- )
     alien-offset LWZ ;
 
-M:: ppc %unbox-any-c-ptr ( dst src temp -- )
+M:: ppc %unbox-any-c-ptr ( dst src -- )
     [
-        { "is-byte-array" "end" "start" } [ define-label ] each
-        ! Address is computed in dst
+        "end" define-label
         0 dst LI
-        ! Load object into scratch-reg
-        scratch-reg src MR
-        ! We come back here with displaced aliens
-        "start" resolve-label
         ! Is the object f?
-        0 scratch-reg \ f type-number CMPI
-        ! If so, done
+        0 src \ f type-number CMPI
         "end" get BEQ
+        ! Compute tag in dst register
+        dst src tag-mask get ANDI
         ! Is the object an alien?
-        0 scratch-reg header-offset LWZ
-        0 0 alien type-number tag-fixnum CMPI
-        "is-byte-array" get BNE
-        ! If so, load the offset
-        0 scratch-reg alien-offset LWZ
-        ! Add it to address being computed
-        dst dst 0 ADD
-        ! Now recurse on the underlying alien
-        scratch-reg scratch-reg underlying-alien-offset LWZ
-        "start" get B
-        "is-byte-array" resolve-label
-        ! Add byte array address to address being computed
-        dst dst scratch-reg ADD
-        ! Add an offset to start of byte array's data area
-        dst dst byte-array-offset ADDI
+        0 dst alien type-number CMPI
+        ! Add an offset to start of byte array's data
+        dst src byte-array-offset ADDI
+        "end" get BNE
+        ! If so, load the offset and add it to the address
+        dst src alien-offset LWZ
         "end" resolve-label
     ] with-scope ;
 
@@ -293,53 +282,84 @@ M:: ppc %unbox-any-c-ptr ( dst src temp -- )
 M:: ppc %box-alien ( dst src temp -- )
     [
         "f" define-label
-        dst  %load-immediate
+        dst \ f type-number %load-immediate
         0 src 0 CMPI
         "f" get BEQ
         dst 5 cells alien temp %allot
         temp \ f type-number %load-immediate
         temp dst 1 alien@ STW
         temp dst 2 alien@ STW
-        displacement dst 3 alien@ STW
-        displacement dst 4 alien@ STW
+        src dst 3 alien@ STW
+        src dst 4 alien@ STW
         "f" resolve-label
     ] with-scope ;
 
-M:: ppc %box-displaced-alien ( dst displacement base displacement' base' base-class -- )
+M:: ppc %box-displaced-alien ( dst displacement base temp base-class -- )
+    ! This is ridiculous
     [
         "end" define-label
-        "alloc" define-label
-        "simple-case" define-label
+        "not-f" define-label
+        "not-alien" define-label
+
         ! If displacement is zero, return the base
         dst base MR
         0 displacement 0 CMPI
         "end" get BEQ
-        ! Quickly use displacement' before its needed for real, as allot temporary
-        displacement' :> temp
-        dst 4 cells alien temp %allot
-        ! If base is already a displaced alien, unpack it
-        0 base \ f type-number CMPI
-        "simple-case" get BEQ
-        temp base header-offset LWZ
-        0 temp alien type-number tag-fixnum CMPI
-        "simple-case" get BNE
-        ! displacement += base.displacement
-        temp base 3 alien@ LWZ
-        displacement' displacement temp ADD
-        ! base = base.base
-        base' base 1 alien@ LWZ
-        "alloc" get B
-        "simple-case" resolve-label
-        displacement' displacement MR
-        base' base MR
-        "alloc" resolve-label
-        ! Store underlying-alien slot
-        base' dst 1 alien@ STW
-        ! Store offset
-        displacement' dst 3 alien@ STW
-        ! Store expired slot (its ok to clobber displacement')
+
+        ! Displacement is non-zero, we're going to be allocating a new
+        ! object
+        dst 5 cells alien temp %allot
+
+        ! Set expired to f
         temp \ f type-number %load-immediate
         temp dst 2 alien@ STW
+
+        ! Is base f?
+        0 base \ f type-number CMPI
+        "not-f" get BNE
+
+        ! Yes, it is f. Fill in new object
+        base dst 1 alien@ STW
+        displacement dst 3 alien@ STW
+        displacement dst 4 alien@ STW
+
+        "end" get B
+
+        "not-f" resolve-label
+
+        ! Check base type
+        temp base tag-mask get ANDI
+
+        ! Is base an alien?
+        0 temp alien type-number CMPI
+        "not-alien" get BNE
+
+        ! Yes, it is an alien. Set new alien's base to base.base
+        temp base 1 alien@ LWZ
+        temp dst 1 alien@ STW
+
+        ! Compute displacement
+        temp base 3 alien@ LWZ
+        temp temp displacement ADD
+        temp dst 3 alien@ STW
+
+        ! Compute address
+        temp base 4 alien@ LWZ
+        temp temp displacement ADD
+        temp dst 4 alien@ STW
+
+        ! We are done
+        "end" get B
+
+        ! Is base a byte array? It has to be, by now...
+        "not-alien" resolve-label
+
+        base dst 1 alien@ STW
+        displacement dst 3 alien@ STW
+        temp base byte-array-offset ADDI
+        temp temp displacement ADD
+        temp dst 4 alien@ STW
+
         "end" resolve-label
     ] with-scope ;
 
@@ -373,7 +393,7 @@ M: ppc %set-alien-double -rot STFD ;
     scratch-reg nursery-ptr 0 STW ;
 
 :: store-header ( dst class -- )
-    class type-number tag-fixnum scratch-reg LI
+    class type-number tag-header scratch-reg LI
     scratch-reg dst 0 STW ;
 
 : store-tagged ( dst tag -- )
@@ -544,14 +564,16 @@ M:: ppc %compare-float-unordered-branch ( label src1 src2 cc -- )
         { stack-params [ [ 0 1 ] dip LWZ [ 0 1 ] dip param@ STW ] }
     } case ;
 
-: next-param@ ( n -- x ) param@ stack-frame get total-size>> + ;
+: next-param@ ( n -- reg x )
+    2 1 stack-frame get total-size>> LWZ
+    [ 2 ] dip param@ ;
 
 : store-to-frame ( src n rep -- )
     {
         { int-rep [ [ 1 ] dip STW ] }
         { float-rep [ [ 1 ] dip STFS ] }
         { double-rep [ [ 1 ] dip STFD ] }
-        { stack-params [ [ [ 0 ] dip next-param@ LWZ 0 1 ] dip STW ] }
+        { stack-params [ [ [ 0 ] dip next-param@ LWZ 0 1 ] dip STW ] }
     } case ;
 
 M: ppc %spill ( src rep dst -- )
@@ -572,9 +594,34 @@ M:: ppc %save-param-reg ( stack reg rep -- )
 M:: ppc %load-param-reg ( stack reg rep -- )
     reg stack local@ rep load-from-frame ;
 
-M: ppc %prepare-unbox ( n -- )
+M: ppc %pop-stack ( n -- )
     [ 3 ] dip <ds-loc> loc>operand LWZ ;
 
+M: ppc %push-stack ( -- )
+    ds-reg ds-reg 4 ADDI
+    int-regs return-reg ds-reg 0 STW ;
+
+:: %load-context-datastack ( dst -- )
+    ! Load context struct
+    dst "ctx" %vm-field-ptr
+    dst dst 0 LWZ
+    ! Load context datastack pointer
+    dst dst "datastack" context-field-offset ADDI ;
+
+M: ppc %push-context-stack ( -- )
+    11 %load-context-datastack
+    12 11 0 LWZ
+    12 12 4 ADDI
+    12 11 0 STW
+    int-regs return-reg 12 0 STW ;
+
+M: ppc %pop-context-stack ( -- )
+    11 %load-context-datastack
+    12 11 0 LWZ
+    int-regs return-reg 12 0 LWZ
+    12 12 4 SUBI
+    12 11 0 STW ;
+
 M: ppc %unbox ( n rep func -- )
     ! Value must be in r3
     4 %load-vm-addr
@@ -632,35 +679,43 @@ M: ppc %box-large-struct ( n c-type -- )
     [ [ 3 1 ] dip struct-return@ ADDI ] [ heap-size 4 LI ] bi*
     5 %load-vm-addr
     ! Call the function
-    "box_value_struct" f %alien-invoke ;
+    "from_value_struct" f %alien-invoke ;
 
-M:: ppc %save-context ( temp1 temp2 callback-allowed? -- )
-    #! Save Factor stack pointers in case the C code calls a
-    #! callback which does a GC, which must reliably trace
-    #! all roots.
-    temp1 "stack_chain" %load-vm-field-addr
+M:: ppc %restore-context ( temp1 temp2 -- )
+    temp1 "ctx" %load-vm-field-addr
+    temp1 temp1 0 LWZ
+    temp2 1 stack-frame get total-size>> ADDI
+    temp2 temp1 "callstack-bottom" context-field-offset STW
+    ds-reg temp1 8 LWZ
+    rs-reg temp1 12 LWZ ;
+
+M:: ppc %save-context ( temp1 temp2 -- )
+    temp1 "ctx" %load-vm-field-addr
     temp1 temp1 0 LWZ
     1 temp1 0 STW
-    callback-allowed? [
-        ds-reg temp1 8 STW
-        rs-reg temp1 12 STW
-    ] when ;
+    ds-reg temp1 8 STW
+    rs-reg temp1 12 STW ;
 
 M: ppc %alien-invoke ( symbol dll -- )
     [ 11 ] 2dip %alien-global 11 MTLR BLRL ;
 
 M: ppc %alien-callback ( quot -- )
+    3 4 %restore-context
     3 swap %load-reference
-    4 %load-vm-addr
-    "c_to_factor" f %alien-invoke ;
+    4 3 quot-entry-point-offset LWZ
+    4 MTLR
+    BLRL
+    3 4 %save-context ;
 
 M: ppc %prepare-alien-indirect ( -- )
-    3 %load-vm-addr
-    "unbox_alien" f %alien-invoke
-    15 3 MR ;
+    3 ds-reg 0 LWZ
+    ds-reg ds-reg 4 SUBI
+    4 %load-vm-addr
+    "pinned_alien_offset" f %alien-invoke
+    16 3 MR ;
 
 M: ppc %alien-indirect ( -- )
-    15 MTLR BLRL ;
+    16 MTLR BLRL ;
 
 M: ppc %callback-value ( ctype -- )
     ! Save top of data stack
@@ -685,7 +740,7 @@ M: ppc %box-small-struct ( c-type -- )
     #! Box a <= 16-byte struct returned in r3:r4:r5:r6
     heap-size 7 LI
     8 %load-vm-addr
-    "box_medium_struct" f %alien-invoke ;
+    "from_medium_struct" f %alien-invoke ;
 
 : %unbox-struct-1 ( -- )
     ! Alien must be in r3.
@@ -710,9 +765,7 @@ M: ppc %box-small-struct ( c-type -- )
     3 3 0 LWZ ;
 
 M: ppc %nest-stacks ( -- )
-    ! Save current frame. See comment in vm/contexts.hpp
-    3 1 stack-frame get total-size>> 2 cells - ADDI
-    4 %load-vm-addr
+    3 %load-vm-addr
     "nest_stacks" f %alien-invoke ;
 
 M: ppc %unnest-stacks ( -- )
@@ -720,7 +773,6 @@ M: ppc %unnest-stacks ( -- )
     "unnest_stacks" f %alien-invoke ;
 
 M: ppc %unbox-small-struct ( size -- )
-    #! Alien must be in EAX.
     heap-size cell align cell /i {
         { 1 [ %unbox-struct-1 ] }
         { 2 [ %unbox-struct-2 ] }
diff --git a/basis/cpu/x86/32/32-tests.factor b/basis/cpu/x86/32/32-tests.factor
new file mode 100644 (file)
index 0000000..bc07e3a
--- /dev/null
@@ -0,0 +1,7 @@
+IN: cpu.x86.32.tests
+USING: alien alien.c-types tools.test cpu.x86.assembler
+cpu.x86.assembler.operands ;
+
+: assembly-test-1 ( -- x ) int { } "cdecl" [ EAX 3 MOV ] alien-assembly ;
+
+[ 3 ] [ assembly-test-1 ] unit-test
old mode 100755 (executable)
new mode 100644 (file)
index 8867ca6..3348ef0
@@ -1,4 +1,4 @@
-! Copyright (C) 2005, 2009 Slava Pestov.
+! Copyright (C) 2005, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: locals alien.c-types alien.libraries alien.syntax arrays
 kernel fry math namespaces sequences system layouts io
@@ -8,7 +8,8 @@ compiler.codegen compiler.codegen.fixup
 compiler.cfg.instructions compiler.cfg.builder
 compiler.cfg.intrinsics compiler.cfg.stack-frame
 cpu.x86.assembler cpu.x86.assembler.operands cpu.x86
-cpu.architecture ;
+cpu.architecture vm ;
+FROM: layouts => cell ;
 IN: cpu.x86.32
 
 M: x86.32 machine-registers
@@ -20,8 +21,15 @@ M: x86.32 machine-registers
 M: x86.32 ds-reg ESI ;
 M: x86.32 rs-reg EDI ;
 M: x86.32 stack-reg ESP ;
+M: x86.32 frame-reg EBP ;
 M: x86.32 temp-reg ECX ;
 
+M: x86.32 %mov-vm-ptr ( reg -- )
+    0 MOV 0 rc-absolute-cell rel-vm ;
+
+M: x86.32 %vm-field-ptr ( dst field -- )
+    [ 0 MOV ] dip vm-field-offset rc-absolute-cell rel-vm ;
+
 : local@ ( n -- op )
     stack-frame get extra-stack-space dup 16 assert= + stack@ ;
 
@@ -42,7 +50,7 @@ M: x86.32 %mark-deck
 M:: x86.32 %dispatch ( src temp -- )
     ! Load jump table base.
     temp src HEX: ffffffff [+] LEA
-    building get length cell - :> start
+    building get length :> start
     0 rc-absolute-cell rel-here
     ! Go
     temp HEX: 7f [+] JMP
@@ -53,10 +61,6 @@ M:: x86.32 %dispatch ( src temp -- )
     [ align-code ]
     bi ;
 
-! Registers for fastcall
-: param-reg-1 ( -- reg ) EAX ;
-: param-reg-2 ( -- reg ) EDX ;
-
 M: x86.32 pic-tail-reg EBX ;
 
 M: x86.32 reserved-stack-space 4 cells ;
@@ -136,7 +140,7 @@ M:: x86.32 %box-large-struct ( n c-type -- )
     8 save-vm-ptr
     4 stack@ c-type heap-size MOV
     0 stack@ EDX MOV
-    "box_value_struct" f %alien-invoke ;
+    "from_value_struct" f %alien-invoke ;
 
 M: x86.32 %prepare-box-struct ( -- )
     ! Compute target address for value struct return
@@ -150,11 +154,17 @@ M: x86.32 %box-small-struct ( c-type -- )
     8 stack@ swap heap-size MOV
     4 stack@ EDX MOV
     0 stack@ EAX MOV
-    "box_small_struct" f %alien-invoke ;
+    "from_small_struct" f %alien-invoke ;
 
-M: x86.32 %prepare-unbox ( -- )
+M: x86.32 %pop-stack ( n -- )
     EAX swap ds-reg reg-stack MOV ;
 
+M: x86.32 %pop-context-stack ( -- )
+    temp-reg %load-context-datastack
+    EAX temp-reg [] MOV
+    EAX EAX [] MOV
+    temp-reg [] bootstrap-cell SUB ;
+
 : call-unbox-func ( func -- )
     4 save-vm-ptr
     0 stack@ EAX MOV
@@ -213,10 +223,7 @@ M:: x86.32 %unbox-large-struct ( n c-type -- )
     "to_value_struct" f %alien-invoke ;
 
 M: x86.32 %nest-stacks ( -- )
-    ! Save current frame. See comment in vm/contexts.hpp
-    EAX stack-reg stack-frame get total-size>> 3 cells - [+] LEA
-    4 save-vm-ptr
-    0 stack@ EAX MOV
+    0 save-vm-ptr
     "nest_stacks" f %alien-invoke ;
 
 M: x86.32 %unnest-stacks ( -- )
@@ -224,21 +231,24 @@ M: x86.32 %unnest-stacks ( -- )
     "unnest_stacks" f %alien-invoke ;
 
 M: x86.32 %prepare-alien-indirect ( -- )
-    0 save-vm-ptr
-    "unbox_alien" f %alien-invoke
+    EAX ds-reg [] MOV
+    ds-reg 4 SUB
+    4 save-vm-ptr
+    0 stack@ EAX MOV
+    "pinned_alien_offset" f %alien-invoke
     EBP EAX MOV ;
 
 M: x86.32 %alien-indirect ( -- )
     EBP CALL ;
 
 M: x86.32 %alien-callback ( quot -- )
-    ! Fastcall
-    param-reg-1 swap %load-reference
-    param-reg-2 %mov-vm-ptr
-    "c_to_factor" f %alien-invoke ;
+    EAX EDX %restore-context
+    EAX swap %load-reference
+    EAX quot-entry-point-offset [+] CALL
+    EAX EDX %save-context ;
 
 M: x86.32 %callback-value ( ctype -- )
-    0 %prepare-unbox
+    %pop-context-stack
     4 stack@ EAX MOV
     0 save-vm-ptr
     ! Restore data/call/retain stacks
@@ -294,20 +304,6 @@ M: x86.32 %cleanup ( params -- )
         [ drop ]
     } cond ;
 
-M: x86.32 %callback-return ( n -- )
-    #! a) If the callback is stdcall, we have to clean up the
-    #! caller's stack frame.
-    #! b) If the callback is returning a large struct, we have
-    #! to fix ESP.
-    {
-        { [ dup abi>> "stdcall" = ] [
-            <alien-stack-frame>
-            [ params>> ] [ return>> ] bi +
-        ] }
-        { [ dup return>> large-struct? ] [ drop 4 ] }
-        [ drop 0 ]
-    } cond RET ;
-
 M:: x86.32 %call-gc ( gc-root-count temp -- )
     temp gc-root-base special@ LEA
     8 save-vm-ptr
@@ -321,6 +317,20 @@ M: x86.32 dummy-int-params? f ;
 
 M: x86.32 dummy-fp-params? f ;
 
+M: x86.32 callback-return-rewind ( params -- n )
+    #! a) If the callback is stdcall, we have to clean up the
+    #! caller's stack frame.
+    #! b) If the callback is returning a large struct, we have
+    #! to fix ESP.
+    {
+        { [ dup abi>> "stdcall" = ] [
+            <alien-stack-frame>
+            [ params>> ] [ return>> ] bi +
+        ] }
+        { [ dup return>> large-struct? ] [ drop 4 ] }
+        [ drop 0 ]
+    } cond ;
+
 ! Dreadful
 M: object flatten-value-type (flatten-int-type) ;
 
index f777040e86fa8599f7b811755016439d1118ee6c..d11aa952d991db077f2845f4748ef21c670ef325 100644 (file)
-! Copyright (C) 2007, 2009 Slava Pestov.
+! Copyright (C) 2007, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: bootstrap.image.private kernel namespaces system
-cpu.x86.assembler cpu.x86.assembler.operands layouts
-vocabs parser compiler.constants sequences ;
+USING: bootstrap.image.private kernel kernel.private namespaces
+system cpu.x86.assembler cpu.x86.assembler.operands layouts
+vocabs parser compiler.constants sequences math math.private
+generic.single.private ;
 IN: bootstrap.x86
 
 4 \ cell set
 
-: stack-frame-size ( -- n ) 4 bootstrap-cells ;
+: stack-frame-size ( -- n ) 8 bootstrap-cells ;
 : shift-arg ( -- reg ) ECX ;
 : div-arg ( -- reg ) EAX ;
 : mod-arg ( -- reg ) EDX ;
-: arg1 ( -- reg ) EAX ;
-: arg2 ( -- reg ) EDX ;
 : temp0 ( -- reg ) EAX ;
 : temp1 ( -- reg ) EDX ;
 : temp2 ( -- reg ) ECX ;
 : temp3 ( -- reg ) EBX ;
 : safe-reg ( -- reg ) EAX ;
 : stack-reg ( -- reg ) ESP ;
+: frame-reg ( -- reg ) EBP ;
+: vm-reg ( -- reg ) ECX ;
+: ctx-reg ( -- reg ) EBP ;
+: nv-regs ( -- seq ) { ESI EDI EBX } ;
 : ds-reg ( -- reg ) ESI ;
 : rs-reg ( -- reg ) EDI ;
 : fixnum>slot@ ( -- ) temp0 2 SAR ;
 : rex-length ( -- n ) 0 ;
 
 [
-    ! load stack_chain
-    temp0 0 [] MOV rc-absolute-cell rt-stack-chain jit-rel
-    ! save stack pointer
-    temp0 [] stack-reg MOV
-    ! pass vm ptr to primitive
-    arg1 0 MOV rc-absolute-cell rt-vm jit-rel
+    ! save stack frame size
+    stack-frame-size PUSH
+    ! push entry point
+    0 PUSH rc-absolute-cell rt-this jit-rel
+    ! alignment
+    ESP stack-frame-size 3 bootstrap-cells - SUB
+] jit-prolog jit-define
+
+: jit-load-vm ( -- )
+    vm-reg 0 MOV 0 rc-absolute-cell jit-vm ;
+
+: jit-load-context ( -- )
+    ! VM pointer must be in vm-reg already
+    ctx-reg vm-reg vm-context-offset [+] MOV ;
+
+: jit-save-context ( -- )
+    EDX RSP -4 [+] LEA
+    ctx-reg context-callstack-top-offset [+] EDX MOV
+    ctx-reg context-datastack-offset [+] ds-reg MOV
+    ctx-reg context-retainstack-offset [+] rs-reg MOV ;
+
+: jit-restore-context ( -- )
+    ds-reg ctx-reg context-datastack-offset [+] MOV
+    rs-reg ctx-reg context-retainstack-offset [+] MOV ;
+
+[
+    jit-load-vm
+    jit-load-context
+    jit-save-context
     ! call the primitive
-    0 JMP rc-relative rt-primitive jit-rel
+    ESP [] vm-reg MOV
+    0 CALL rc-relative rt-dlsym jit-rel
+    ! restore ds, rs registers
+    jit-restore-context
 ] jit-primitive jit-define
 
+[
+    ! Load quotation
+    EAX EBP 8 [+] MOV
+    ! save ctx->callstack_bottom, load ds, rs registers
+    jit-load-vm
+    jit-load-context
+    jit-restore-context
+    EDX stack-reg stack-frame-size 4 - [+] LEA
+    ctx-reg context-callstack-bottom-offset [+] EDX MOV
+    ! call the quotation
+    EAX quot-entry-point-offset [+] CALL
+    ! save ds, rs registers
+    jit-save-context
+] \ c-to-factor define-sub-primitive
+
+[
+    EAX ds-reg [] MOV
+    ds-reg bootstrap-cell SUB
+]
+[ EAX quot-entry-point-offset [+] CALL ]
+[ EAX quot-entry-point-offset [+] JMP ]
+\ (call) define-combinator-primitive
+
+[
+    ! Clear x87 stack, but preserve rounding mode and exception flags
+    ESP 2 SUB
+    ESP [] FNSTCW
+    FNINIT
+    ESP [] FLDCW
+    ESP 2 ADD
+
+    ! Load arguments
+    EAX ESP stack-frame-size [+] MOV
+    EDX ESP stack-frame-size 4 + [+] MOV
+
+    ! Unwind stack frames
+    ESP EDX MOV
+
+    ! Load ds and rs registers
+    jit-load-vm
+    jit-load-context
+    jit-restore-context
+
+    ! Call quotation
+    EAX quot-entry-point-offset [+] JMP
+] \ unwind-native-frames define-sub-primitive
+
+[
+    ! Load callstack object
+    EBX ds-reg [] MOV
+    ds-reg bootstrap-cell SUB
+    ! Get ctx->callstack_bottom
+    jit-load-vm
+    jit-load-context
+    EAX ctx-reg context-callstack-bottom-offset [+] MOV
+    ! Get top of callstack object -- 'src' for memcpy
+    EBP EBX callstack-top-offset [+] LEA
+    ! Get callstack length, in bytes --- 'len' for memcpy
+    EDX EBX callstack-length-offset [+] MOV
+    EDX tag-bits get SHR
+    ! Compute new stack pointer -- 'dst' for memcpy
+    EAX EDX SUB
+    ! Install new stack pointer
+    ESP EAX MOV
+    ! Call memcpy
+    EDX PUSH
+    EBP PUSH
+    EAX PUSH
+    0 CALL "factor_memcpy" f rc-relative jit-dlsym
+    ESP 12 ADD
+    ! Return with new callstack
+    0 RET
+] \ set-callstack define-sub-primitive
+
+[
+    jit-load-vm
+    jit-load-context
+    jit-save-context
+
+    ! Store arguments
+    ESP [] EAX MOV
+    ESP 4 [+] vm-reg MOV
+
+    ! Call VM
+    0 CALL "lazy_jit_compile" f rc-relative jit-dlsym
+]
+[ EAX quot-entry-point-offset [+] CALL ]
+[ EAX quot-entry-point-offset [+] JMP ]
+\ lazy-jit-compile define-combinator-primitive
+
+! Inline cache miss entry points
+: jit-load-return-address ( -- )
+    EBX ESP stack-frame-size bootstrap-cell - [+] MOV ;
+
+! These are always in tail position with an existing stack
+! frame, and the stack. The frame setup takes this into account.
+: jit-inline-cache-miss ( -- )
+    jit-load-vm
+    jit-load-context
+    jit-save-context
+    ESP 4 [+] vm-reg MOV
+    ESP [] EBX MOV
+    0 CALL "inline_cache_miss" f rc-relative jit-dlsym
+    jit-restore-context ;
+
+[ jit-load-return-address jit-inline-cache-miss ]
+[ EAX CALL ]
+[ EAX JMP ]
+\ inline-cache-miss define-combinator-primitive
+
+[ jit-inline-cache-miss ]
+[ EAX CALL ]
+[ EAX JMP ]
+\ inline-cache-miss-tail define-combinator-primitive
+
+! Overflowing fixnum arithmetic
+: jit-overflow ( insn func -- )
+    ds-reg 4 SUB
+    jit-load-vm
+    jit-load-context
+    jit-save-context
+    EAX ds-reg [] MOV
+    EDX ds-reg 4 [+] MOV
+    EBX EAX MOV
+    [ [ EBX EDX ] dip call( dst src -- ) ] dip
+    ds-reg [] EBX MOV
+    [ JNO ]
+    [
+        ESP [] EAX MOV
+        ESP 4 [+] EDX MOV
+        ESP 8 [+] vm-reg MOV
+        [ 0 CALL ] dip f rc-relative jit-dlsym
+    ]
+    jit-conditional ;
+
+[ [ ADD ] "overflow_fixnum_add" jit-overflow ] \ fixnum+ define-sub-primitive
+
+[ [ SUB ] "overflow_fixnum_subtract" jit-overflow ] \ fixnum- define-sub-primitive
+
+[
+    ds-reg 4 SUB
+    jit-load-vm
+    jit-load-context
+    jit-save-context
+    EBX ds-reg [] MOV
+    EAX EBX MOV
+    EBP ds-reg 4 [+] MOV
+    EBP tag-bits get SAR
+    EBP IMUL
+    ds-reg [] EAX MOV
+    [ JNO ]
+    [
+        EBX tag-bits get SAR
+        ESP [] EBX MOV
+        ESP 4 [+] EBP MOV
+        ESP 8 [+] vm-reg MOV
+        0 CALL "overflow_fixnum_multiply" f rc-relative jit-dlsym
+    ]
+    jit-conditional
+] \ fixnum* define-sub-primitive
+
 << "vocab:cpu/x86/bootstrap.factor" parse-file suffix! >>
 call
diff --git a/basis/cpu/x86/64/64-tests.factor b/basis/cpu/x86/64/64-tests.factor
new file mode 100644 (file)
index 0000000..6d171af
--- /dev/null
@@ -0,0 +1,15 @@
+USING: alien alien.c-types cpu.architecture cpu.x86.64
+cpu.x86.assembler cpu.x86.assembler.operands tools.test ;
+IN: cpu.x86.64.tests
+
+: assembly-test-1 ( -- x ) int { } "cdecl" [ RAX 3 MOV ] alien-assembly ;
+
+[ 3 ] [ assembly-test-1 ] unit-test
+
+: assembly-test-2 ( a b -- x )
+    int { int int } "cdecl" [
+        param-reg-0 param-reg-1 ADD
+        int-regs return-reg param-reg-0 MOV
+    ] alien-assembly ;
+
+[ 23 ] [ 17 6 assembly-test-2 ] unit-test
index cbc5c4d7e5a399b7bc270026bd2bb153d42f1129..d3196397c311a0d0c915477f1182e395407e6a38 100644 (file)
@@ -1,17 +1,20 @@
-! Copyright (C) 2005, 2009 Slava Pestov.
+! Copyright (C) 2005, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors arrays kernel math namespaces make sequences system
-layouts alien alien.c-types alien.accessors slots
+USING: accessors arrays kernel math namespaces make sequences
+system layouts alien alien.c-types alien.accessors slots
 splitting assocs combinators locals compiler.constants
-compiler.codegen compiler.codegen.fixup compiler.cfg.instructions
-compiler.cfg.builder compiler.cfg.intrinsics compiler.cfg.stack-frame
-cpu.x86.assembler cpu.x86.assembler.operands cpu.x86 cpu.architecture ;
+compiler.codegen compiler.codegen.fixup
+compiler.cfg.instructions compiler.cfg.builder
+compiler.cfg.intrinsics compiler.cfg.stack-frame
+cpu.x86.assembler cpu.x86.assembler.operands cpu.x86
+cpu.architecture vm ;
+FROM: layouts => cell cells ;
 IN: cpu.x86.64
 
-: param-reg-1 ( -- reg ) int-regs param-regs first ; inline
-: param-reg-2 ( -- reg ) int-regs param-regs second ; inline
-: param-reg-3 ( -- reg ) int-regs param-regs third ; inline
-: param-reg-4 ( -- reg ) int-regs param-regs fourth ; inline
+: param-reg-0 ( -- reg ) 0 int-regs param-reg ; inline
+: param-reg-1 ( -- reg ) 1 int-regs param-reg ; inline
+: param-reg-2 ( -- reg ) 2 int-regs param-reg ; inline
+: param-reg-3 ( -- reg ) 3 int-regs param-reg ; inline
 
 M: x86.64 pic-tail-reg RBX ;
 
@@ -21,18 +24,27 @@ M: float-regs return-reg drop XMM0 ;
 M: x86.64 ds-reg R14 ;
 M: x86.64 rs-reg R15 ;
 M: x86.64 stack-reg RSP ;
+M: x86.64 frame-reg RBP ;
 
 M: x86.64 extra-stack-space drop 0 ;
 
 M: x86.64 machine-registers
     {
-        { int-regs { RAX RCX RDX RBX RBP RSI RDI R8 R9 R10 R11 R12 R13 } }
+        { int-regs { RAX RCX RDX RBX RBP RSI RDI R8 R9 R10 R11 R12 } }
         { float-regs {
             XMM0 XMM1 XMM2 XMM3 XMM4 XMM5 XMM6 XMM7
             XMM8 XMM9 XMM10 XMM11 XMM12 XMM13 XMM14 XMM15
         } }
     } ;
 
+: vm-reg ( -- reg ) R13 ; inline
+
+M: x86.64 %mov-vm-ptr ( reg -- )
+    vm-reg MOV ;
+
+M: x86.64 %vm-field-ptr ( dst field -- )
+    [ vm-reg ] dip vm-field-offset [+] LEA ;
+
 : param@ ( n -- op ) reserved-stack-space + stack@ ;
 
 M: x86.64 %prologue ( n -- )
@@ -56,9 +68,9 @@ M: x86.64 %mark-deck
     [+] card-mark <byte> MOV ;
 
 M:: x86.64 %dispatch ( src temp -- )
-    building get length :> start
     ! Load jump table base.
     temp HEX: ffffffff MOV
+    building get length :> start
     0 rc-absolute-cell rel-here
     ! Add jump table base
     temp src ADD
@@ -66,7 +78,7 @@ M:: x86.64 %dispatch ( src temp -- )
     building get length :> end
     ! Fix up the displacement above
     cell code-alignment
-    [ end start - 2 - + building get dup pop* push ]
+    [ end start - + building get dup pop* push ]
     [ align-code ]
     bi ;
 
@@ -77,9 +89,9 @@ M: stack-params copy-register*
         { [ over integer? ] [ R11 swap MOV              param@ R11 MOV ] }
     } cond ;
 
-M: x86 %save-param-reg [ param@ ] 2dip %copy ;
+M: x86.64 %save-param-reg [ param@ ] 2dip %copy ;
 
-M: x86 %load-param-reg [ swap param@ ] dip %copy ;
+M: x86.64 %load-param-reg [ swap param@ ] dip %copy ;
 
 : with-return-regs ( quot -- )
     [
@@ -88,11 +100,17 @@ M: x86 %load-param-reg [ swap param@ ] dip %copy ;
         call
     ] with-scope ; inline
 
-M: x86.64 %prepare-unbox ( n -- )
-    param-reg-1 swap ds-reg reg-stack MOV ;
+M: x86.64 %pop-stack ( n -- )
+    param-reg-0 swap ds-reg reg-stack MOV ;
+
+M: x86.64 %pop-context-stack ( -- )
+    temp-reg %load-context-datastack
+    param-reg-0 temp-reg [] MOV
+    param-reg-0 param-reg-0 [] MOV
+    temp-reg [] bootstrap-cell SUB ;
 
 M:: x86.64 %unbox ( n rep func -- )
-    param-reg-2 %mov-vm-ptr
+    param-reg-1 %mov-vm-ptr
     ! Call the unboxer
     func f %alien-invoke
     ! Store the return value on the C stack if this is an
@@ -104,15 +122,15 @@ M: x86.64 %unbox-long-long ( n func -- )
     [ int-rep ] dip %unbox ;
 
 : %unbox-struct-field ( c-type i -- )
-    ! Alien must be in param-reg-1.
+    ! Alien must be in param-reg-0.
     R11 swap cells [+] swap rep>> reg-class-of {
         { int-regs [ int-regs get pop swap MOV ] }
         { float-regs [ float-regs get pop swap MOVSD ] }
     } case ;
 
 M: x86.64 %unbox-small-struct ( c-type -- )
-    ! Alien must be in param-reg-1.
-    param-reg-2 %mov-vm-ptr
+    ! Alien must be in param-reg-0.
+    param-reg-1 %mov-vm-ptr
     "alien_offset" f %alien-invoke
     ! Move alien_offset() return value to R11 so that we don't
     ! clobber it.
@@ -122,12 +140,12 @@ M: x86.64 %unbox-small-struct ( c-type -- )
     ] with-return-regs ;
 
 M:: x86.64 %unbox-large-struct ( n c-type -- )
-    ! Source is in param-reg-1
-    ! Load destination address into param-reg-2
-    param-reg-2 n param@ LEA
-    ! Load structure size into param-reg-3
-    param-reg-3 c-type heap-size MOV
-    param-reg-4 %mov-vm-ptr
+    ! Source is in param-reg-0
+    ! Load destination address into param-reg-1
+    param-reg-1 n param@ LEA
+    ! Load structure size into param-reg-2
+    param-reg-2 c-type heap-size MOV
+    param-reg-3 %mov-vm-ptr
     ! Copy the struct to the C stack
     "to_value_struct" f %alien-invoke ;
 
@@ -145,7 +163,7 @@ M:: x86.64 %box ( n rep func -- )
     ] [
         rep load-return-value
     ] if
-    rep int-rep? [ param-reg-2 ] [ param-reg-1 ] if %mov-vm-ptr
+    rep int-rep? [ param-reg-1 ] [ param-reg-0 ] if %mov-vm-ptr
     func f %alien-invoke ;
 
 M: x86.64 %box-long-long ( n func -- )
@@ -163,11 +181,11 @@ M: x86.64 %box-small-struct ( c-type -- )
     #! Box a <= 16-byte struct.
     [
         [ flatten-value-type [ %box-struct-field ] each-index ]
-        [ param-reg-3 swap heap-size MOV ] bi
-        param-reg-1 0 box-struct-field@ MOV
-        param-reg-2 1 box-struct-field@ MOV
-        param-reg-4 %mov-vm-ptr
-        "box_small_struct" f %alien-invoke
+        [ param-reg-2 swap heap-size MOV ] bi
+        param-reg-0 0 box-struct-field@ MOV
+        param-reg-1 1 box-struct-field@ MOV
+        param-reg-3 %mov-vm-ptr
+        "from_small_struct" f %alien-invoke
     ] with-return-regs ;
 
 : struct-return@ ( n -- operand )
@@ -175,12 +193,12 @@ M: x86.64 %box-small-struct ( c-type -- )
 
 M: x86.64 %box-large-struct ( n c-type -- )
     ! Struct size is parameter 2
-    param-reg-2 swap heap-size MOV
+    param-reg-1 swap heap-size MOV
     ! Compute destination address
-    param-reg-1 swap struct-return@ LEA
-    param-reg-3 %mov-vm-ptr
+    param-reg-0 swap struct-return@ LEA
+    param-reg-2 %mov-vm-ptr
     ! Copy the struct from the C stack
-    "box_value_struct" f %alien-invoke ;
+    "from_value_struct" f %alien-invoke ;
 
 M: x86.64 %prepare-box-struct ( -- )
     ! Compute target address for value struct return
@@ -196,37 +214,38 @@ M: x86.64 %alien-invoke
     R11 CALL ;
 
 M: x86.64 %nest-stacks ( -- )
-    ! Save current frame. See comment in vm/contexts.hpp
-    param-reg-1 stack-reg stack-frame get total-size>> 3 cells - [+] LEA
-    param-reg-2 %mov-vm-ptr
+    param-reg-0 %mov-vm-ptr
     "nest_stacks" f %alien-invoke ;
 
 M: x86.64 %unnest-stacks ( -- )
-    param-reg-1 %mov-vm-ptr
+    param-reg-0 %mov-vm-ptr
     "unnest_stacks" f %alien-invoke ;
 
 M: x86.64 %prepare-alien-indirect ( -- )
+    param-reg-0 ds-reg [] MOV
+    ds-reg 8 SUB
     param-reg-1 %mov-vm-ptr
-    "unbox_alien" f %alien-invoke
+    "pinned_alien_offset" f %alien-invoke
     RBP RAX MOV ;
 
 M: x86.64 %alien-indirect ( -- )
     RBP CALL ;
 
 M: x86.64 %alien-callback ( quot -- )
-    param-reg-1 swap %load-reference
-    param-reg-2 %mov-vm-ptr
-    "c_to_factor" f %alien-invoke ;
+    param-reg-0 param-reg-1 %restore-context
+    param-reg-0 swap %load-reference
+    param-reg-0 quot-entry-point-offset [+] CALL
+    param-reg-0 param-reg-1 %save-context ;
 
 M: x86.64 %callback-value ( ctype -- )
-    0 %prepare-unbox
+    %pop-context-stack
     RSP 8 SUB
-    param-reg-1 PUSH
-    param-reg-1 %mov-vm-ptr
+    param-reg-0 PUSH
+    param-reg-0 %mov-vm-ptr
     ! Restore data/call/retain stacks
     "unnest_stacks" f %alien-invoke
-    ! Put former top of data stack in param-reg-1
-    param-reg-1 POP
+    ! Put former top of data stack in param-reg-0
+    param-reg-0 POP
     RSP 8 ADD
     ! Unbox former top of data stack to return registers
     unbox-return ;
@@ -252,11 +271,11 @@ M:: x86.64 %binary-float-function ( dst src1 src2 func -- )
 
 M:: x86.64 %call-gc ( gc-root-count temp -- )
     ! Pass pointer to start of GC roots as first parameter
-    param-reg-1 gc-root-base param@ LEA
+    param-reg-0 gc-root-base param@ LEA
     ! Pass number of roots as second parameter
-    param-reg-2 gc-root-count MOV
+    param-reg-1 gc-root-count MOV
     ! Pass VM ptr as third parameter
-    param-reg-3 %mov-vm-ptr
+    param-reg-2 %mov-vm-ptr
     ! Call GC
     "inline_gc" f %alien-invoke ;
 
index 0fc029fdfee4438875f9f998cad4ef91b1dc33c7..828598074ff8d249b12d2694fac62b43fc7db780 100644 (file)
@@ -1,8 +1,9 @@
-! Copyright (C) 2007, 2009 Slava Pestov.
+! Copyright (C) 2007, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: bootstrap.image.private kernel namespaces system
-layouts vocabs parser compiler.constants math
-cpu.x86.assembler cpu.x86.assembler.operands sequences ;
+USING: bootstrap.image.private kernel kernel.private namespaces
+system layouts vocabs parser compiler.constants math
+math.private cpu.x86.assembler cpu.x86.assembler.operands
+sequences generic.single.private ;
 IN: bootstrap.x86
 
 8 \ cell set
@@ -14,26 +15,193 @@ IN: bootstrap.x86
 : temp1 ( -- reg ) RSI ;
 : temp2 ( -- reg ) RDX ;
 : temp3 ( -- reg ) RBX ;
+: return-reg ( -- reg ) RAX ;
 : safe-reg ( -- reg ) RAX ;
 : stack-reg ( -- reg ) RSP ;
+: frame-reg ( -- reg ) RBP ;
+: ctx-reg ( -- reg ) R12 ;
+: vm-reg ( -- reg ) R13 ;
 : ds-reg ( -- reg ) R14 ;
 : rs-reg ( -- reg ) R15 ;
 : fixnum>slot@ ( -- ) temp0 1 SAR ;
 : rex-length ( -- n ) 1 ;
 
 [
-    ! load stack_chain
-    temp0 0 MOV rc-absolute-cell rt-stack-chain jit-rel
-    temp0 temp0 [] MOV
-    ! save stack pointer
-    temp0 [] stack-reg MOV
-    ! load vm ptr
-    arg1 0 MOV rc-absolute-cell rt-vm jit-rel
-    ! load XT
-    temp1 0 MOV rc-absolute-cell rt-primitive jit-rel
-    ! go
-    temp1 JMP
+    ! load entry point
+    safe-reg 0 MOV rc-absolute-cell rt-this jit-rel
+    ! save stack frame size
+    stack-frame-size PUSH
+    ! push entry point
+    safe-reg PUSH
+    ! alignment
+    RSP stack-frame-size 3 bootstrap-cells - SUB
+] jit-prolog jit-define
+
+: jit-load-context ( -- )
+    ctx-reg vm-reg vm-context-offset [+] MOV ;
+
+: jit-save-context ( -- )
+    jit-load-context
+    safe-reg RSP -8 [+] LEA
+    ctx-reg context-callstack-top-offset [+] safe-reg MOV
+    ctx-reg context-datastack-offset [+] ds-reg MOV
+    ctx-reg context-retainstack-offset [+] rs-reg MOV ;
+
+: jit-restore-context ( -- )
+    jit-load-context
+    ds-reg ctx-reg context-datastack-offset [+] MOV
+    rs-reg ctx-reg context-retainstack-offset [+] MOV ;
+
+[
+    jit-save-context
+    ! call the primitive
+    arg1 vm-reg MOV
+    RAX 0 MOV rc-absolute-cell rt-dlsym jit-rel
+    RAX CALL
+    jit-restore-context
 ] jit-primitive jit-define
 
+[
+    jit-restore-context
+    ! save ctx->callstack_bottom
+    safe-reg stack-reg stack-frame-size 8 - [+] LEA
+    ctx-reg context-callstack-bottom-offset [+] safe-reg MOV
+    ! call the quotation
+    arg1 quot-entry-point-offset [+] CALL
+    jit-save-context
+] \ c-to-factor define-sub-primitive
+
+[
+    arg1 ds-reg [] MOV
+    ds-reg bootstrap-cell SUB
+]
+[ arg1 quot-entry-point-offset [+] CALL ]
+[ arg1 quot-entry-point-offset [+] JMP ]
+\ (call) define-combinator-primitive
+
+[
+    ! Clear x87 stack, but preserve rounding mode and exception flags
+    RSP 2 SUB
+    RSP [] FNSTCW
+    FNINIT
+    RSP [] FLDCW
+
+    ! Unwind stack frames
+    RSP arg2 MOV
+
+    ! Load VM pointer into vm-reg, since we're entering from
+    ! C code
+    vm-reg 0 MOV 0 rc-absolute-cell jit-vm
+
+    ! Load ds and rs registers
+    jit-restore-context
+
+    ! Call quotation
+    arg1 quot-entry-point-offset [+] JMP
+] \ unwind-native-frames define-sub-primitive
+
+[
+    ! Load callstack object
+    arg4 ds-reg [] MOV
+    ds-reg bootstrap-cell SUB
+    ! Get ctx->callstack_bottom
+    jit-load-context
+    arg1 ctx-reg context-callstack-bottom-offset [+] MOV
+    ! Get top of callstack object -- 'src' for memcpy
+    arg2 arg4 callstack-top-offset [+] LEA
+    ! Get callstack length, in bytes --- 'len' for memcpy
+    arg3 arg4 callstack-length-offset [+] MOV
+    arg3 tag-bits get SHR
+    ! Compute new stack pointer -- 'dst' for memcpy
+    arg1 arg3 SUB
+    ! Install new stack pointer
+    RSP arg1 MOV
+    ! Call memcpy; arguments are now in the correct registers
+    ! Create register shadow area for Win64
+    RSP 32 SUB
+    safe-reg 0 MOV "factor_memcpy" f rc-absolute-cell jit-dlsym
+    safe-reg CALL
+    ! Tear down register shadow area
+    RSP 32 ADD
+    ! Return with new callstack
+    0 RET
+] \ set-callstack define-sub-primitive
+
+[
+    jit-save-context
+    arg2 vm-reg MOV
+    safe-reg 0 MOV "lazy_jit_compile" f rc-absolute-cell jit-dlsym
+    safe-reg CALL
+]
+[ return-reg quot-entry-point-offset [+] CALL ]
+[ return-reg quot-entry-point-offset [+] JMP ]
+\ lazy-jit-compile define-combinator-primitive
+
+! Inline cache miss entry points
+: jit-load-return-address ( -- )
+    RBX RSP stack-frame-size bootstrap-cell - [+] MOV ;
+
+! These are always in tail position with an existing stack
+! frame, and the stack. The frame setup takes this into account.
+: jit-inline-cache-miss ( -- )
+    jit-save-context
+    arg1 RBX MOV
+    arg2 vm-reg MOV
+    RAX 0 MOV "inline_cache_miss" f rc-absolute-cell jit-dlsym
+    RAX CALL
+    jit-restore-context ;
+
+[ jit-load-return-address jit-inline-cache-miss ]
+[ RAX CALL ]
+[ RAX JMP ]
+\ inline-cache-miss define-combinator-primitive
+
+[ jit-inline-cache-miss ]
+[ RAX CALL ]
+[ RAX JMP ]
+\ inline-cache-miss-tail define-combinator-primitive
+
+! Overflowing fixnum arithmetic
+: jit-overflow ( insn func -- )
+    ds-reg 8 SUB
+    jit-save-context
+    arg1 ds-reg [] MOV
+    arg2 ds-reg 8 [+] MOV
+    arg3 arg1 MOV
+    [ [ arg3 arg2 ] dip call ] dip
+    ds-reg [] arg3 MOV
+    [ JNO ]
+    [
+        arg3 vm-reg MOV
+        RAX 0 MOV f rc-absolute-cell jit-dlsym
+        RAX CALL
+    ]
+    jit-conditional ; inline
+
+[ [ ADD ] "overflow_fixnum_add" jit-overflow ] \ fixnum+ define-sub-primitive
+
+[ [ SUB ] "overflow_fixnum_subtract" jit-overflow ] \ fixnum- define-sub-primitive
+
+[
+    ds-reg 8 SUB
+    jit-save-context
+    RCX ds-reg [] MOV
+    RBX ds-reg 8 [+] MOV
+    RBX tag-bits get SAR
+    RAX RCX MOV
+    RBX IMUL
+    ds-reg [] RAX MOV
+    [ JNO ]
+    [
+        arg1 RCX MOV
+        arg1 tag-bits get SAR
+        arg2 RBX MOV
+        arg3 vm-reg MOV
+        RAX 0 MOV "overflow_fixnum_multiply" f rc-absolute-cell jit-dlsym
+        RAX CALL
+    ]
+    jit-conditional
+] \ fixnum* define-sub-primitive
+
 << "vocab:cpu/x86/bootstrap.factor" parse-file suffix! >>
 call
index 238fad984a86420115d186df8433a648f64c05e4..d19b5306a0ea8bf2514609148fec95b72b821653 100644 (file)
@@ -6,8 +6,11 @@ sequences system vocabs ;
 IN: bootstrap.x86
 
 : stack-frame-size ( -- n ) 4 bootstrap-cells ;
+: nv-regs ( -- seq ) { RBX R12 R13 R14 R15 } ;
 : arg1 ( -- reg ) RDI ;
 : arg2 ( -- reg ) RSI ;
+: arg3 ( -- reg ) RDX ;
+: arg4 ( -- reg ) RCX ;
 
 << "vocab:cpu/x86/64/bootstrap.factor" parse-file suffix! >>
 call
index 2e3944fcaf10177c88e8158b02fff2388b8356cb..113a13918f1f84bd04c4cfda4e6372624acf8768 100644 (file)
@@ -1,13 +1,16 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: bootstrap.image.private kernel namespaces system
-layouts vocabs parser sequences cpu.x86.assembler parser
+USING: bootstrap.image.private kernel namespaces system layouts
+vocabs sequences cpu.x86.assembler parser
 cpu.x86.assembler.operands ;
 IN: bootstrap.x86
 
 : stack-frame-size ( -- n ) 8 bootstrap-cells ;
+: nv-regs ( -- seq ) { RBX RSI RDI R12 R13 R14 R15 } ;
 : arg1 ( -- reg ) RCX ;
 : arg2 ( -- reg ) RDX ;
+: arg3 ( -- reg ) R8 ;
+: arg4 ( -- reg ) R9 ;
 
 << "vocab:cpu/x86/64/bootstrap.factor" parse-file suffix! >>
 call
index 57738ce4bad7553057950781670998b669327e6c..b075b121a5c7c130f285af29ac3c3853c8ee1f31 100644 (file)
@@ -375,6 +375,7 @@ PRIVATE>
 : NOP ( -- ) HEX: 90 , ;
 : PAUSE ( -- ) HEX: f3 , HEX: 90 , ;
 
+: RDTSC ( -- ) HEX: 0f , HEX: 31 , ;
 : RDPMC ( -- ) HEX: 0f , HEX: 33 , ;
 
 ! x87 Floating Point Unit
@@ -385,6 +386,13 @@ PRIVATE>
 : FLDS ( operand -- ) { BIN: 000 f HEX: d9 } 1-operand ;
 : FLDL ( operand -- ) { BIN: 000 f HEX: dd } 1-operand ;
 
+: FNSTCW ( operand -- ) { BIN: 111 f HEX: d9 } 1-operand ;
+: FNSTSW ( operand -- ) { BIN: 111 f HEX: dd } 1-operand ;
+: FLDCW ( operand -- ) { BIN: 101 f HEX: d9 } 1-operand ;
+
+: FNCLEX ( -- ) HEX: db , HEX: e2 , ;
+: FNINIT ( -- ) HEX: db , HEX: e3 , ;
+
 ! SSE multimedia instructions
 
 <PRIVATE
index 98a51889629d87da7de27bc8ae5441928d3275bb..2304f9c9f3761f49a597550c658289601bd20548 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2007, 2009 Slava Pestov.
+! Copyright (C) 2007, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: bootstrap.image.private compiler.constants
 compiler.units cpu.x86.assembler cpu.x86.assembler.operands
@@ -8,52 +8,83 @@ IN: bootstrap.x86
 
 big-endian off
 
+! C to Factor entry point
+[
+    ! Optimizing compiler's side of callback accesses
+    ! arguments that are on the stack via the frame pointer.
+    ! On x86-64, some arguments are passed in registers, and
+    ! so the only register that is safe for use here is safe-reg.
+    frame-reg PUSH
+    frame-reg stack-reg MOV
+
+    ! Save all non-volatile registers
+    nv-regs [ PUSH ] each
+
+    ! Save old stack pointer and align
+    safe-reg stack-reg MOV
+    stack-reg bootstrap-cell SUB
+    stack-reg -16 AND
+    stack-reg [] safe-reg MOV
+
+    ! Register shadow area - only required on Win64, but doesn't
+    ! hurt on other platforms
+    stack-reg 32 SUB
+
+    ! Load VM into vm-reg
+    vm-reg 0 MOV rc-absolute-cell rt-vm jit-rel
+
+    ! Call into Factor code
+    safe-reg 0 MOV rc-absolute-cell rt-entry-point jit-rel
+    safe-reg CALL
+
+    ! Tear down register shadow area
+    stack-reg 32 ADD
+
+    ! Undo stack alignment
+    stack-reg stack-reg [] MOV
+
+    ! Restore non-volatile registers
+    nv-regs <reversed> [ POP ] each
+
+    frame-reg POP
+
+    ! Callbacks which return structs, or use stdcall, need a
+    ! parameter here. See the comment in callback-return-rewind
+    ! in cpu.x86.32
+    HEX: ffff RET rc-absolute-2 rt-untagged jit-rel
+] callback-stub jit-define
+
 [
     ! Load word
-    temp0 0 MOV rc-absolute-cell rt-immediate jit-rel
+    temp0 0 MOV rc-absolute-cell rt-literal jit-rel
     ! Bump profiling counter
     temp0 profile-count-offset [+] 1 tag-fixnum ADD
     ! Load word->code
     temp0 temp0 word-code-offset [+] MOV
-    ! Compute word XT
+    ! Compute word entry point
     temp0 compiled-header-size ADD
-    ! Jump to XT
+    ! Jump to entry point
     temp0 JMP
 ] jit-profiling jit-define
 
-[
-    ! load XT
-    temp0 0 MOV rc-absolute-cell rt-this jit-rel
-    ! save stack frame size
-    stack-frame-size PUSH
-    ! push XT
-    temp0 PUSH
-    ! alignment
-    stack-reg stack-frame-size 3 bootstrap-cells - SUB
-] jit-prolog jit-define
-
 [
     ! load literal
-    temp0 0 MOV rc-absolute-cell rt-immediate jit-rel
+    temp0 0 MOV rc-absolute-cell rt-literal jit-rel
     ! increment datastack pointer
     ds-reg bootstrap-cell ADD
     ! store literal on datastack
     ds-reg [] temp0 MOV
-] jit-push-immediate jit-define
+] jit-push jit-define
 
 [
     temp3 0 MOV rc-absolute-cell rt-here jit-rel
-    0 JMP rc-relative rt-xt-pic-tail jit-rel
+    0 JMP rc-relative rt-entry-point-pic-tail jit-rel
 ] jit-word-jump jit-define
 
 [
-    0 CALL rc-relative rt-xt-pic jit-rel
+    0 CALL rc-relative rt-entry-point-pic jit-rel
 ] jit-word-call jit-define
 
-[
-    0 JMP rc-relative rt-xt jit-rel
-] jit-word-special jit-define
-
 [
     ! load boolean
     temp0 ds-reg [] MOV
@@ -62,9 +93,9 @@ big-endian off
     ! compare boolean with f
     temp0 \ f type-number CMP
     ! jump to true branch if not equal
-    0 JNE rc-relative rt-xt jit-rel
+    0 JNE rc-relative rt-entry-point jit-rel
     ! jump to false branch if equal
-    0 JMP rc-relative rt-xt jit-rel
+    0 JMP rc-relative rt-entry-point jit-rel
 ] jit-if jit-define
 
 : jit->r ( -- )
@@ -117,36 +148,39 @@ big-endian off
 
 [
     jit->r
-    0 CALL rc-relative rt-xt jit-rel
+    0 CALL rc-relative rt-entry-point jit-rel
     jit-r>
 ] jit-dip jit-define
 
 [
     jit-2>r
-    0 CALL rc-relative rt-xt jit-rel
+    0 CALL rc-relative rt-entry-point jit-rel
     jit-2r>
 ] jit-2dip jit-define
 
 [
     jit-3>r
-    0 CALL rc-relative rt-xt jit-rel
+    0 CALL rc-relative rt-entry-point jit-rel
     jit-3r>
 ] jit-3dip jit-define
 
-: prepare-(execute) ( -- operand )
+[
     ! load from stack
     temp0 ds-reg [] MOV
     ! pop stack
     ds-reg bootstrap-cell SUB
-    ! execute word
-    temp0 word-xt-offset [+] ;
-
-[ prepare-(execute) JMP ] jit-execute-jump jit-define
+]
+[ temp0 word-entry-point-offset [+] CALL ]
+[ temp0 word-entry-point-offset [+] JMP ]
+\ (execute) define-combinator-primitive
 
-[ prepare-(execute) CALL ] jit-execute-call jit-define
+[
+    temp0 ds-reg [] MOV
+    ds-reg bootstrap-cell SUB
+    temp0 word-entry-point-offset [+] JMP
+] jit-execute jit-define
 
 [
-    ! unwind stack frame
     stack-reg stack-frame-size bootstrap-cell - ADD
 ] jit-epilog jit-define
 
@@ -176,26 +210,27 @@ big-endian off
     temp0 temp1 MOV
     load-tag
     temp1 tuple type-number tag-fixnum CMP
-    [ temp1 temp0 tuple type-number neg bootstrap-cell + [+] MOV ] { } make
-    [ length JNE ] [ % ] bi
+    [ JNE ]
+    [ temp1 temp0 tuple type-number neg bootstrap-cell + [+] MOV ]
+    jit-conditional
 ] pic-tuple jit-define
 
 [
-    temp1 HEX: ffffffff CMP rc-absolute rt-immediate jit-rel
+    temp1 HEX: ffffffff CMP rc-absolute rt-literal jit-rel
 ] pic-check-tag jit-define
 
 [
-    temp2 HEX: ffffffff MOV rc-absolute-cell rt-immediate jit-rel
+    temp2 HEX: ffffffff MOV rc-absolute-cell rt-literal jit-rel
     temp1 temp2 CMP
 ] pic-check-tuple jit-define
 
-[ 0 JE rc-relative rt-xt jit-rel ] pic-hit jit-define
+[ 0 JE rc-relative rt-entry-point jit-rel ] pic-hit jit-define
 
 ! ! ! Megamorphic caches
 
 [
     ! cache = ...
-    temp0 0 MOV rc-absolute-cell rt-immediate jit-rel
+    temp0 0 MOV rc-absolute-cell rt-literal jit-rel
     ! key = hashcode(class)
     temp2 temp1 MOV
     bootstrap-cell 4 = [ temp2 1 SHR ] when
@@ -213,29 +248,12 @@ big-endian off
     temp1 [] 1 ADD
     ! goto get(cache + bootstrap-cell)
     temp0 temp0 bootstrap-cell [+] MOV
-    temp0 word-xt-offset [+] JMP
+    temp0 word-entry-point-offset [+] JMP
     ! fall-through on miss
 ] mega-lookup jit-define
 
-[
-    safe-reg 0 MOV rc-absolute-cell rt-xt jit-rel
-    safe-reg JMP
-] callback-stub jit-define
-
 ! ! ! Sub-primitives
 
-! Quotations and words
-[
-    ! load from stack
-    arg1 ds-reg [] MOV
-    ! pop stack
-    ds-reg bootstrap-cell SUB
-    ! pass vm pointer
-    arg2 0 MOV 0 jit-literal rc-absolute-cell rt-vm jit-rel
-    ! call quotation
-    arg1 quot-xt-offset [+] JMP
-] \ (call) define-sub-primitive
-
 ! Objects
 [
     ! load from stack
@@ -335,15 +353,6 @@ big-endian off
     ds-reg [] temp0 MOV
 ] \ dupd define-sub-primitive
 
-[
-    temp0 ds-reg [] MOV
-    temp1 ds-reg -1 bootstrap-cells [+] MOV
-    ds-reg bootstrap-cell ADD
-    ds-reg [] temp0 MOV
-    ds-reg -1 bootstrap-cells [+] temp1 MOV
-    ds-reg -2 bootstrap-cells [+] temp0 MOV
-] \ tuck define-sub-primitive
-
 [
     temp0 ds-reg [] MOV
     temp1 ds-reg bootstrap-cell neg [+] MOV
@@ -382,7 +391,7 @@ big-endian off
 : jit-compare ( insn -- )
     ! load t
     t jit-literal
-    temp3 0 MOV rc-absolute-cell rt-immediate jit-rel
+    temp3 0 MOV rc-absolute-cell rt-literal jit-rel
     ! load f
     temp1 \ f type-number MOV
     ! load first value
index b21aa762d861c078f29588d2ea02ffa3bbd259bd..30b2ce3b57accf63cd05a6aaa80bbcd16f89e275 100644 (file)
@@ -1,23 +1,80 @@
-! Copyright (C) 2009 Slava Pestov.
+! Copyright (C) 2009, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: system kernel memoize math math.order math.parser
-namespaces alien.c-types alien.syntax combinators locals init io
-compiler compiler.units accessors ;
+USING: accessors alien alien.c-types combinators compiler
+compiler.codegen.fixup compiler.units cpu.architecture
+cpu.x86.assembler cpu.x86.assembler.operands init io kernel
+locals math math.order math.parser memoize namespaces system ;
 IN: cpu.x86.features
 
 <PRIVATE
 
-FUNCTION: int sse_version ( ) ;
+: (sse-version) ( -- n )
+    int { } "cdecl" [
+        "sse-42" define-label
+        "sse-41" define-label
+        "ssse-3" define-label
+        "sse-3" define-label
+        "sse-2" define-label
+        "sse-1" define-label
+        "end" define-label
 
-FUNCTION: longlong read_timestamp_counter ( ) ;
+        int-regs return-reg 1 MOV
+
+        CPUID
+
+        ECX HEX: 100000 TEST
+        "sse-42" get JNE
+
+        ECX HEX: 80000 TEST
+        "sse-41" get JNE
+
+        ECX HEX: 200 TEST
+        "ssse-3" get JNE
+
+        ECX HEX: 1 TEST
+        "sse-3" get JNE
+
+        EDX HEX: 4000000 TEST
+        "sse-2" get JNE
+
+        EDX HEX: 2000000 TEST
+        "sse-1" get JNE
+
+        int-regs return-reg 0 MOV
+        "end" get JMP
+
+        "sse-42" resolve-label
+        int-regs return-reg 42 MOV
+        "end" get JMP
+
+        "sse-41" resolve-label
+        int-regs return-reg 41 MOV
+        "end" get JMP
+
+        "ssse-3" resolve-label
+        int-regs return-reg 33 MOV
+        "end" get JMP
+
+        "sse-3" resolve-label
+        int-regs return-reg 30 MOV
+        "end" get JMP
+
+        "sse-2" resolve-label
+        int-regs return-reg 20 MOV
+        "end" get JMP
+
+        "sse-1" resolve-label
+        int-regs return-reg 10 MOV
+
+        "end" resolve-label
+    ] alien-assembly ;
 
 PRIVATE>
 
 MEMO: sse-version ( -- n )
-    sse_version
-    "sse-version" get string>number [ min ] when* ;
+    (sse-version) "sse-version" get string>number [ min ] when* ;
 
-[ \ sse-version reset-memoized ] "cpu.x86.features" add-init-hook
+[ \ sse-version reset-memoized ] "cpu.x86.features" add-startup-hook
 
 : sse? ( -- ? ) sse-version 10 >= ;
 : sse2? ( -- ? ) sse-version 20 >= ;
@@ -39,7 +96,18 @@ MEMO: sse-version ( -- n )
 
 HOOK: instruction-count cpu ( -- n )
 
-M: x86 instruction-count read_timestamp_counter ;
+M: x86.32 instruction-count
+    longlong { } "cdecl" [
+        RDTSC
+    ] alien-assembly ;
+
+M: x86.64 instruction-count
+    longlong { } "cdecl" [
+        RAX 0 MOV
+        RDTSC
+        RDX 32 SHL
+        RAX RDX OR
+    ] alien-assembly ;
 
 : count-instructions ( quot -- n )
-    instruction-count [ call ] dip instruction-count swap - ; inline
+    instruction-count [ call instruction-count ] dip - ; inline
index a63b92e05081c8abb815b48adaaf13c9e284fc8d..f2751b1be21b23c51b488aa0308d901549d0b91b 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2005, 2009 Slava Pestov.
+! Copyright (C) 2005, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors assocs alien alien.c-types arrays strings
 cpu.x86.assembler cpu.x86.assembler.private cpu.x86.assembler.operands
@@ -24,6 +24,8 @@ M: x86 vector-regs float-regs ;
 
 HOOK: stack-reg cpu ( -- reg )
 
+HOOK: frame-reg cpu ( -- reg )
+
 HOOK: reserved-stack-space cpu ( -- n )
 
 HOOK: extra-stack-space cpu ( stack-frame -- n )
@@ -84,7 +86,7 @@ M: x86 %call ( word -- ) 0 CALL rc-relative rel-word-pic ;
 
 : xt-tail-pic-offset ( -- n )
     #! See the comment in vm/cpu-x86.hpp
-    cell 4 + 1 + ; inline
+    4 1 + ; inline
 
 M: x86 %jump ( word -- )
     pic-tail-reg 0 MOV xt-tail-pic-offset rc-absolute-cell rel-here
@@ -417,11 +419,7 @@ M: x86 %shl int-rep two-operand [ SHL ] emit-shift ;
 M: x86 %shr int-rep two-operand [ SHR ] emit-shift ;
 M: x86 %sar int-rep two-operand [ SAR ] emit-shift ;
 
-: %mov-vm-ptr ( reg -- )
-    0 MOV 0 rc-absolute-cell rel-vm ;
-
-M: x86 %vm-field-ptr ( dst field -- )
-    [ 0 MOV ] dip vm-field-offset rc-absolute-cell rel-vm ;
+HOOK: %mov-vm-ptr cpu ( reg -- )
 
 : load-allot-ptr ( nursery-ptr allot-ptr -- )
     [ drop "nursery" %vm-field-ptr ] [ swap [] MOV ] 2bi ;
@@ -430,7 +428,7 @@ M: x86 %vm-field-ptr ( dst field -- )
     [ [] ] dip data-alignment get align ADD ;
 
 : store-header ( temp class -- )
-    [ [] ] [ type-number tag-fixnum ] bi* MOV ;
+    [ [] ] [ type-number tag-header ] bi* MOV ;
 
 : store-tagged ( dst tag -- )
     type-number OR ;
@@ -472,6 +470,23 @@ M: x86 %load-gc-root ( gc-root register -- ) swap gc-root@ MOV ;
 M: x86 %alien-global ( dst symbol library -- )
     [ 0 MOV ] 2dip rc-absolute-cell rel-dlsym ;    
 
+M: x86 %push-stack ( -- )
+    ds-reg cell ADD
+    ds-reg [] int-regs return-reg MOV ;
+
+:: %load-context-datastack ( dst -- )
+    ! Load context struct
+    dst "ctx" %vm-field-ptr
+    dst dst [] MOV
+    ! Load context datastack pointer
+    dst "datastack" context-field-offset ADD ;
+
+M: x86 %push-context-stack ( -- )
+    temp-reg %load-context-datastack
+    temp-reg [] bootstrap-cell ADD
+    temp-reg temp-reg [] MOV
+    temp-reg [] int-regs return-reg MOV ;
+
 M: x86 %epilogue ( n -- ) cell - incr-stack-reg ;
 
 :: %boolean ( dst temp word -- )
@@ -649,45 +664,8 @@ M: x86 %fill-vector-reps
         { sse2? { double-2-rep char-16-rep uchar-16-rep short-8-rep ushort-8-rep int-4-rep uint-4-rep longlong-2-rep ulonglong-2-rep } }
     } available-reps ;
 
-! M:: x86 %broadcast-vector ( dst src rep -- )
-!     rep unsign-rep {
-!         { float-4-rep [
-!             dst src float-4-rep %copy
-!             dst dst { 0 0 0 0 } SHUFPS
-!         ] }
-!         { double-2-rep [
-!             dst src MOVDDUP
-!         ] }
-!         { longlong-2-rep [
-!             dst src =
-!             [ dst dst PUNPCKLQDQ ]
-!             [ dst src { 0 1 0 1 } PSHUFD ]
-!             if
-!         ] }
-!         { int-4-rep [
-!             dst src { 0 0 0 0 } PSHUFD
-!         ] }
-!         { short-8-rep [
-!             dst src { 0 0 0 0 } PSHUFLW 
-!             dst dst PUNPCKLQDQ 
-!         ] }
-!         { char-16-rep [
-!             dst src char-16-rep %copy
-!             dst dst PUNPCKLBW
-!             dst dst { 0 0 0 0 } PSHUFLW
-!             dst dst PUNPCKLQDQ
-!         ] }
-!     } case ;
-! 
-! M: x86 %broadcast-vector-reps
-!     {
-!         ! Can't do this with sse1 since it will want to unbox
-!         ! a double-precision float and convert to single precision
-!         { sse2? { float-4-rep double-2-rep longlong-2-rep ulonglong-2-rep int-4-rep uint-4-rep short-8-rep ushort-8-rep char-16-rep uchar-16-rep } }
-!     } available-reps ;
-
 M:: x86 %gather-vector-4 ( dst src1 src2 src3 src4 rep -- )
-    rep unsign-rep {
+    rep signed-rep {
         { float-4-rep [
             dst src1 float-4-rep %copy
             dst src2 UNPCKLPS
@@ -710,7 +688,7 @@ M: x86 %gather-vector-4-reps
     } available-reps ;
 
 M:: x86 %gather-vector-2 ( dst src1 src2 rep -- )
-    rep unsign-rep {
+    rep signed-rep {
         { double-2-rep [
             dst src1 double-2-rep %copy
             dst src2 MOVLHPS
@@ -763,7 +741,7 @@ M: x86 %gather-vector-2-reps
 
 M:: x86 %shuffle-vector-imm ( dst src shuffle rep -- )
     dst src rep %copy
-    dst shuffle rep unsign-rep {
+    dst shuffle rep signed-rep {
         { double-2-rep [ >float-4-shuffle float-4-shuffle ] }
         { float-4-rep [ float-4-shuffle ] }
         { int-4-rep [ int-4-shuffle ] }
@@ -786,7 +764,7 @@ M: x86 %shuffle-vector-reps
 
 M: x86 %merge-vector-head
     [ two-operand ] keep
-    unsign-rep {
+    signed-rep {
         { double-2-rep   [ MOVLHPS ] }
         { float-4-rep    [ UNPCKLPS ] }
         { longlong-2-rep [ PUNPCKLQDQ ] }
@@ -797,7 +775,7 @@ M: x86 %merge-vector-head
 
 M: x86 %merge-vector-tail
     [ two-operand ] keep
-    unsign-rep {
+    signed-rep {
         { double-2-rep   [ UNPCKHPD ] }
         { float-4-rep    [ UNPCKHPS ] }
         { longlong-2-rep [ PUNPCKHQDQ ] }
@@ -826,7 +804,7 @@ M: x86 %signed-pack-vector-reps
 
 M: x86 %unsigned-pack-vector
     [ two-operand ] keep
-    unsign-rep {
+    signed-rep {
         { int-4-rep   [ PACKUSDW ] }
         { short-8-rep [ PACKUSWB ] }
     } case ;
@@ -883,6 +861,7 @@ M: x86 %float>integer-vector-reps
 
 : (%compare-float-vector) ( dst src rep double single -- )
     [ double-2-rep eq? ] 2dip if ; inline
+
 : %compare-float-vector ( dst src rep cc -- )
     {
         { cc<    [ [ CMPLTPD    ] [ CMPLTPS    ] (%compare-float-vector) ] }
@@ -896,13 +875,14 @@ M: x86 %float>integer-vector-reps
     } case ;
 
 :: (%compare-int-vector) ( dst src rep int64 int32 int16 int8 -- )
-    rep unsign-rep :> rep'
+    rep signed-rep :> rep'
     dst src rep' {
         { longlong-2-rep [ int64 call ] }
         { int-4-rep      [ int32 call ] }
         { short-8-rep    [ int16 call ] }
         { char-16-rep    [ int8  call ] }
     } case ; inline
+
 : %compare-int-vector ( dst src rep cc -- )
     {
         { cc= [ [ PCMPEQQ ] [ PCMPEQD ] [ PCMPEQW ] [ PCMPEQB ] (%compare-int-vector) ] }
@@ -921,6 +901,7 @@ M: x86 %compare-vector ( dst src1 src2 rep cc -- )
         { sse2? { double-2-rep char-16-rep uchar-16-rep short-8-rep ushort-8-rep int-4-rep uint-4-rep } }
         { sse4.1? { longlong-2-rep ulonglong-2-rep } }
     } available-reps ;
+
 : %compare-vector-ord-reps ( -- reps )
     {
         { sse? { float-4-rep } }
@@ -1106,6 +1087,32 @@ M: x86 %mul-vector-reps
         { sse4.1? { int-4-rep uint-4-rep } }
     } available-reps ;
 
+M: x86 %mul-high-vector ( dst src1 src2 rep -- )
+    [ two-operand ] keep
+    {
+        { short-8-rep  [ PMULHW ] }
+        { ushort-8-rep [ PMULHUW ] }
+    } case ;
+
+M: x86 %mul-high-vector-reps
+    {
+        { sse2? { short-8-rep ushort-8-rep } }
+    } available-reps ;
+
+M: x86 %mul-horizontal-add-vector ( dst src1 src2 rep -- )
+    [ two-operand ] keep
+    {
+        { char-16-rep  [ PMADDUBSW ] }
+        { uchar-16-rep [ PMADDUBSW ] }
+        { short-8-rep  [ PMADDWD ] }
+    } case ;
+
+M: x86 %mul-horizontal-add-vector-reps
+    {
+        { sse2?  { short-8-rep } }
+        { ssse3? { char-16-rep uchar-16-rep } }
+    } available-reps ;
+
 M: x86 %div-vector ( dst src1 src2 rep -- )
     [ two-operand ] keep
     {
@@ -1159,37 +1166,54 @@ M: x86 %max-vector-reps
         { sse4.1? { char-16-rep ushort-8-rep int-4-rep uint-4-rep } }
     } available-reps ;
 
+M: x86 %avg-vector ( dst src1 src2 rep -- )
+    [ two-operand ] keep
+    {
+        { uchar-16-rep [ PAVGB ] }
+        { ushort-8-rep [ PAVGW ] }
+    } case ;
+
+M: x86 %avg-vector-reps
+    {
+        { sse2? { uchar-16-rep ushort-8-rep } }
+    } available-reps ;
+
 M: x86 %dot-vector
     [ two-operand ] keep
     {
-        { float-4-rep [
-            sse4.1?
-            [ HEX: ff DPPS ]
-            [ [ MULPS ] [ drop dup float-4-rep %horizontal-add-vector ] 2bi ]
-            if
-        ] }
-        { double-2-rep [
-            sse4.1?
-            [ HEX: ff DPPD ]
-            [ [ MULPD ] [ drop dup double-2-rep %horizontal-add-vector ] 2bi ]
-            if
-        ] }
+        { float-4-rep [ HEX: ff DPPS ] }
+        { double-2-rep [ HEX: ff DPPD ] }
     } case ;
 
 M: x86 %dot-vector-reps
     {
-        { sse3? { float-4-rep double-2-rep } }
+        { sse4.1? { float-4-rep double-2-rep } }
     } available-reps ;
 
-M: x86 %horizontal-add-vector ( dst src rep -- )
+M: x86 %sad-vector
+    [ two-operand ] keep
+    {
+        { uchar-16-rep [ PSADBW ] }
+    } case ;
+
+M: x86 %sad-vector-reps
     {
-        { float-4-rep [ [ float-4-rep %copy ] [ HADDPS ] [ HADDPS ] 2tri ] }
-        { double-2-rep [ [ double-2-rep %copy ] [ HADDPD ] 2bi ] }
+        { sse2? { uchar-16-rep } }
+    } available-reps ;
+
+M: x86 %horizontal-add-vector ( dst src1 src2 rep -- )
+    [ two-operand ] keep
+    signed-rep {
+        { float-4-rep  [ HADDPS ] }
+        { double-2-rep [ HADDPD ] }
+        { int-4-rep    [ PHADDD ] }
+        { short-8-rep  [ PHADDW ] }
     } case ;
 
 M: x86 %horizontal-add-vector-reps
     {
         { sse3? { float-4-rep double-2-rep } }
+        { ssse3? { int-4-rep uint-4-rep short-8-rep ushort-8-rep } }
     } available-reps ;
 
 M: x86 %horizontal-shl-vector-imm ( dst src1 src2 rep -- )
@@ -1197,7 +1221,7 @@ M: x86 %horizontal-shl-vector-imm ( dst src1 src2 rep -- )
 
 M: x86 %horizontal-shl-vector-imm-reps
     {
-        { sse2? { char-16-rep uchar-16-rep short-8-rep ushort-8-rep int-4-rep uint-4-rep longlong-2-rep ulonglong-2-rep } }
+        { sse2? { char-16-rep uchar-16-rep short-8-rep ushort-8-rep int-4-rep uint-4-rep longlong-2-rep ulonglong-2-rep float-4-rep double-2-rep } }
     } available-reps ;
 
 M: x86 %horizontal-shr-vector-imm ( dst src1 src2 rep -- )
@@ -1205,7 +1229,7 @@ M: x86 %horizontal-shr-vector-imm ( dst src1 src2 rep -- )
 
 M: x86 %horizontal-shr-vector-imm-reps
     {
-        { sse2? { char-16-rep uchar-16-rep short-8-rep ushort-8-rep int-4-rep uint-4-rep longlong-2-rep ulonglong-2-rep } }
+        { sse2? { char-16-rep uchar-16-rep short-8-rep ushort-8-rep int-4-rep uint-4-rep longlong-2-rep ulonglong-2-rep float-4-rep double-2-rep } }
     } available-reps ;
 
 M: x86 %abs-vector ( dst src rep -- )
@@ -1329,7 +1353,7 @@ M: x86 %shr-vector-imm-reps %shr-vector-reps ;
 
 M: x86 %integer>scalar drop MOVD ;
 
-M:: x86 %scalar>integer ( dst src rep -- )
+:: %scalar>integer-32 ( dst src rep -- )
     rep {
         { int-scalar-rep [
             dst 32-bit-version-of src MOVD
@@ -1365,6 +1389,15 @@ M:: x86 %scalar>integer ( dst src rep -- )
         ] }
     } case ;
 
+M: x86.32 %scalar>integer ( dst src rep -- ) %scalar>integer-32 ;
+
+M: x86.64 %scalar>integer ( dst src rep -- )
+    {
+        { longlong-scalar-rep  [ MOVD ] }
+        { ulonglong-scalar-rep [ MOVD ] }
+        [ %scalar>integer-32 ]
+    } case ;
+
 M: x86 %vector>scalar %copy ;
 M: x86 %scalar>vector %copy ;
 
@@ -1373,18 +1406,26 @@ M:: x86 %reload ( dst rep src -- ) dst src rep %copy ;
 
 M: x86 %loop-entry 16 code-alignment [ NOP ] times ;
 
-M:: x86 %save-context ( temp1 temp2 callback-allowed? -- )
+M:: x86 %restore-context ( temp1 temp2 -- )
+    #! Load Factor stack pointers on entry from C to Factor.
+    #! Also save callstack bottom!
+    temp1 "ctx" %vm-field-ptr
+    temp1 temp1 [] MOV
+    temp2 stack-reg stack-frame get total-size>> cell - [+] LEA
+    temp1 "callstack-bottom" context-field-offset [+] temp2 MOV
+    ds-reg temp1 "datastack" context-field-offset [+] MOV
+    rs-reg temp1 "retainstack" context-field-offset [+] MOV ;
+
+M:: x86 %save-context ( temp1 temp2 -- )
     #! Save Factor stack pointers in case the C code calls a
     #! callback which does a GC, which must reliably trace
     #! all roots.
-    temp1 "stack_chain" %vm-field-ptr
+    temp1 "ctx" %vm-field-ptr
     temp1 temp1 [] MOV
     temp2 stack-reg cell neg [+] LEA
-    temp1 [] temp2 MOV
-    callback-allowed? [
-        temp1 2 cells [+] ds-reg MOV
-        temp1 3 cells [+] rs-reg MOV
-    ] when ;
+    temp1 "callstack-top" context-field-offset [+] temp2 MOV
+    temp1 "datastack" context-field-offset [+] ds-reg MOV
+    temp1 "retainstack" context-field-offset [+] rs-reg MOV ;
 
 M: x86 value-struct? drop t ;
 
@@ -1399,9 +1440,8 @@ M: x86 immediate-bitwise? ( n -- ? )
     #! input values to callbacks; the callback has its own
     #! stack frame set up, and we want to read the frame
     #! set up by the caller.
-    stack-frame get total-size>> + stack@ ;
+    frame-reg swap 2 cells + [+] ;
 
-enable-simd
 enable-min/max
 enable-fixnum-log2
 
@@ -1413,7 +1453,7 @@ enable-fixnum-log2
             flush
             1 exit
         ] when
-    ] "cpu.x86" add-init-hook ;
+    ] "cpu.x86" add-startup-hook ;
 
 : enable-sse2 ( version -- )
     20 >= [
@@ -1425,6 +1465,6 @@ enable-fixnum-log2
     ] when ;
 
 : check-sse ( -- )
-    [ { sse_version } compile ] with-optimizer
+    [ { (sse-version) } compile ] with-optimizer
     "Checking for multimedia extensions: " write sse-version
     [ sse-string write " detected" print ] [ enable-sse2 ] bi ;
index 6ba8e2d5b8a965b67767fc7400ce751aed0c3892..829637b4aa18b2e916ac4e6f9aed77d954ffdf4c 100644 (file)
@@ -70,11 +70,12 @@ IN: csv.tests
 
 "can write csv too!"
 [ "foo1,bar1\nfoo2,bar2\n" ]
-[ { { "foo1" "bar1" } { "foo2" "bar2" } } <string-writer> tuck write-csv >string ] named-unit-test
+[ { { "foo1" "bar1" } { "foo2" "bar2" } } <string-writer> [ write-csv ] keep >string ] named-unit-test
+
 
 "escapes quotes commas and newlines when writing"
 [ "\"fo\"\"o1\",bar1\n\"fo\no2\",\"b,ar2\"\n" ]
-[ { { "fo\"o1" "bar1" } { "fo\no2" "b,ar2" } } <string-writer> tuck write-csv >string ] named-unit-test ! "
+[ { { "fo\"o1" "bar1" } { "fo\no2" "b,ar2" } } <string-writer> [ write-csv ] keep >string ] named-unit-test ! "
 
 [ { { "writing" "some" "csv" "tests" } } ]
 [
old mode 100755 (executable)
new mode 100644 (file)
index bd523b38e6d81a887ab9f3db2ce5e9653b50e0c3..f26729f8eae2a955293ce661752126281d87501c 100644 (file)
@@ -100,10 +100,10 @@ M: object execute-statement* ( statement type -- )
     t >>bound? drop ;
 
 : sql-row ( result-set -- seq )
-    dup #columns [ row-column ] with map ;
+    dup #columns [ row-column ] with { } map-integers ;
 
 : sql-row-typed ( result-set -- seq )
-    dup #columns [ row-column-typed ] with map ;
+    dup #columns [ row-column-typed ] with { } map-integers ;
 
 : query-each ( statement quot: ( statement -- ) -- )
     over more-rows? [
old mode 100755 (executable)
new mode 100644 (file)
index e9aa01f..3ff93f4
@@ -34,7 +34,7 @@ SINGLETON: retryable
     ] 2map >>bind-params ;
     
 M: retryable execute-statement* ( statement type -- )
-    drop [ retries>> ] [
+    drop [ retries>> iota ] [
         [
             nip
             [ query-results dispose t ]
index 163026f5ff2031bd3158b0db4135845a71a904e7..53034d148ab5aa194429655b8b5ad8182bd48b4e 100644 (file)
@@ -32,14 +32,14 @@ ERROR: sqlite-sql-error < sql-error n string ;
 
 : sqlite-open ( path -- db )
     normalize-path
-    "void*" <c-object>
+    void* <c-object>
     [ sqlite3_open sqlite-check-result ] keep *void* ;
 
 : sqlite-close ( db -- )
     sqlite3_close sqlite-check-result ;
 
 : sqlite-prepare ( db sql -- handle )
-    utf8 encode dup length "void*" <c-object> "void*" <c-object>
+    utf8 encode dup length void* <c-object> void* <c-object>
     [ sqlite3_prepare_v2 sqlite-check-result ] 2keep
     drop *void* ;
 
old mode 100755 (executable)
new mode 100644 (file)
index ffcbec7..8d26d3b
@@ -4,7 +4,7 @@ USING: alien arrays assocs classes compiler db hashtables
 io.files kernel math math.parser namespaces prettyprint fry
 sequences strings classes.tuple alien.c-types continuations
 db.sqlite.lib db.sqlite.ffi db.tuples words db.types combinators
-math.intervals io nmake accessors vectors math.ranges random
+math.intervals io locals nmake accessors vectors math.ranges random
 math.bitwise db.queries destructors db.tuples.private interpolate
 io.streams.string make db.private sequences.deep
 db.errors.sqlite ;
@@ -85,12 +85,11 @@ M: literal-bind sqlite-bind-conversion ( tuple literal-bind -- array )
     nip [ key>> ] [ value>> ] [ type>> ] tri
     <sqlite-low-level-binding> ;
 
-M: generator-bind sqlite-bind-conversion ( tuple generate-bind -- array )
-    tuck
-    [ generator-singleton>> eval-generator tuck ] [ slot-name>> ] bi
-    rot set-slot-named
-    [ [ key>> ] [ type>> ] bi ] dip
-    swap <sqlite-low-level-binding> ;
+M:: generator-bind sqlite-bind-conversion ( tuple generate-bind -- array )
+    generate-bind generator-singleton>> eval-generator :> obj
+    generate-bind slot-name>> :> name
+    obj name tuple set-slot-named
+    generate-bind key>> obj generate-bind type>> <sqlite-low-level-binding> ;
 
 M: sqlite-statement bind-tuple ( tuple statement -- )
     [
index 19140259bf1e4b913a4243f8b7abd81ab99b0254..d0ea6cbcf12eee933beefc083c1c12fa8664e67a 100644 (file)
@@ -67,7 +67,7 @@ test-2 "TEST2" {
             test-2 ensure-table
         ] with-db
     ] [
-        10 [
+        10 iota [
             drop
             10 [
                 dup [
@@ -85,7 +85,7 @@ test-2 "TEST2" {
         ] with-db
     ] [
         <db-pool> [
-            10 [
+            10 iota [
                 10 [
                     test-1-tuple insert-tuple yield
                 ] times
old mode 100755 (executable)
new mode 100644 (file)
index 87e70d69e7e64baa662de1cd298dc628bb26dae2..4bcd9c5b789fa2edd3cbf08a48fd8ba9429cad77 100644 (file)
@@ -129,9 +129,6 @@ HELP: c-string-error.
 HELP: ffi-error.
 { $error-description "Thrown by " { $link dlopen } " and " { $link dlsym } " if a problem occurs while loading a native library or looking up a symbol. See " { $link "alien" } "." } ;
 
-HELP: heap-scan-error.
-{ $error-description "Thrown if " { $link next-object } " is called outside of a " { $link begin-scan } "/" { $link end-scan } " pair." } ;
-
 HELP: undefined-symbol-error.
 { $error-description "Thrown if a previously-compiled " { $link alien-invoke } " call refers to a native library symbol which no longer exists." } ;
 
index 690e631e81bb8bf01451c36d37d2137971657089..5c76216c4fdf402b8402595d189250ba4218ccef 100644 (file)
@@ -26,6 +26,9 @@ M: object error. short. ;
 
 M: string error. print ;
 
+: traceback-link. ( continuation -- )
+    "[" write [ "Traceback" ] dip write-object "]" print ;
+
 : :s ( -- )
     error-continuation get data>> stack. ;
 
@@ -103,9 +106,6 @@ HOOK: signal-error. os ( obj -- )
 : ffi-error. ( obj -- )
     "FFI error" print drop ;
 
-: heap-scan-error. ( obj -- )
-    "Cannot do next-object outside begin/end-scan" print drop ;
-
 : undefined-symbol-error. ( obj -- )
     "The image refers to a library or symbol that was not found at load time"
     print drop ;
@@ -148,14 +148,13 @@ PREDICATE: vm-error < array
         { 6  [ array-size-error.       ] }
         { 7  [ c-string-error.         ] }
         { 8  [ ffi-error.              ] }
-        { 9  [ heap-scan-error.        ] }
-        { 10 [ undefined-symbol-error. ] }
-        { 11 [ datastack-underflow.    ] }
-        { 12 [ datastack-overflow.     ] }
-        { 13 [ retainstack-underflow.  ] }
-        { 14 [ retainstack-overflow.   ] }
-        { 15 [ memory-error.           ] }
-        { 16 [ fp-trap-error.          ] }
+        { 9  [ undefined-symbol-error. ] }
+        { 10 [ datastack-underflow.    ] }
+        { 11 [ datastack-overflow.     ] }
+        { 12 [ retainstack-underflow.  ] }
+        { 13 [ retainstack-overflow.   ] }
+        { 14 [ memory-error.           ] }
+        { 15 [ fp-trap-error.          ] }
     } ; inline
 
 M: vm-error summary drop "VM error" ;
@@ -334,6 +333,8 @@ M: not-found-in-roots summary drop "Cannot resolve vocab: path" ;
 
 M: wrong-values summary drop "Quotation called with wrong stack effect" ;
 
+M: stack-effect-omits-dashes summary drop "Stack effect must contain “--”" ;
+
 {
     { [ os windows? ] [ "debugger.windows" require ] }
     { [ os unix? ] [ "debugger.unix" require ] }
diff --git a/basis/debugger/windows/tags.txt b/basis/debugger/windows/tags.txt
new file mode 100644 (file)
index 0000000..6bf6830
--- /dev/null
@@ -0,0 +1 @@
+unportable
old mode 100755 (executable)
new mode 100644 (file)
index 319f100..73c6b0e
@@ -32,6 +32,7 @@ CONSTANT: seh-names
         { $ STATUS_CONTROL_C_EXIT             "STATUS_CONTROL_C_EXIT"           }
         { $ STATUS_FLOAT_MULTIPLE_FAULTS      "STATUS_FLOAT_MULTIPLE_FAULTS"    }
         { $ STATUS_FLOAT_MULTIPLE_TRAPS       "STATUS_FLOAT_MULTIPLE_TRAPS"     }
+        { HEX: e06d7363 "Visual C++ exception" }
     }
 
 : seh-name. ( n -- )
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index feb19af04057f6c0def58ed57d9b7f988067d416..7e16c1c218478d08fdef4734d1165d5b7a2768a4 100644 (file)
@@ -49,7 +49,7 @@ M: cannot-find-source error.
 
 : edit-error ( error -- )
     [ error-file ] [ error-line ] bi
-    2dup and [ edit-location ] [ 2drop ] if ;
+    over [ 1 or edit-location ] [ 2drop ] if ;
 
 : :edit ( -- )
     error get edit-error ;
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index e60a52c995b94fb2613c4b272242ff1a88663a9c..ccdbd66d96c53f8fb35d797cd0a3b3256a08755c 100644 (file)
@@ -32,4 +32,4 @@ HOOK: (set-os-envs) os ( seq -- )
         os windows? ";" ":" ? split
         [ add-vocab-root ] each
     ] when*    
-] "environment" add-init-hook
+] "environment" add-startup-hook
old mode 100755 (executable)
new mode 100644 (file)
index 863dc522b2d694de12c3b3cc30ab095b24aa914b..7ef62bfb77eefcb955cbc304513d98c51db21dfc 100644 (file)
@@ -205,7 +205,7 @@ link-no-follow? off
     100 [
         drop random-markup
         [ convert-farkup drop t ] [ drop print f ] recover
-    ] all?
+    ] all-integers?
 ] unit-test
 
 [ "<p><a href=\"http://foo.com/~foo\">http://foo.com/~foo</a></p>" ] [ "[[http://foo.com/~foo]]" convert-farkup ] unit-test
index 9602933785d60492af2ff4ac419145f4a178c01f..b3d2ff296e196b367706b6031cb87b9feb417c92 100644 (file)
@@ -2,17 +2,20 @@ USING: help.markup help.syntax quotations kernel ;
 IN: fry\r
 \r
 HELP: _\r
-{ $description "Fry specifier. Inserts a literal value into the fried quotation." } ;\r
+{ $description "Fry specifier. Inserts a literal value into the fried quotation." }\r
+{ $examples "See " { $link "fry.examples" } "." } ;\r
 \r
 HELP: @\r
-{ $description "Fry specifier. Splices a quotation into the fried quotation." } ;\r
+{ $description "Fry specifier. Splices a quotation into the fried quotation." }\r
+{ $examples "See " { $link "fry.examples" } "." } ;\r
 \r
 HELP: fry\r
 { $values { "quot" quotation } { "quot'" quotation } }\r
 { $description "Outputs a quotation that when called, fries " { $snippet "quot" } " by taking values from the stack and substituting them in." }\r
 { $notes "This word is used to implement " { $link POSTPONE: '[ } "; the following two lines are equivalent:"\r
     { $code "[ X ] fry call" "'[ X ]" }\r
-} ;\r
+}\r
+{ $examples "See " { $link "fry.examples" } "." } ;\r
 \r
 HELP: '[\r
 { $syntax "'[ code... ]" }\r
@@ -59,7 +62,6 @@ $nl
     { { $link literalize } { $snippet ": literalize '[ _ ] ;" } }\r
     { { $link curry } { $snippet ": curry '[ _ @ ] ;" } }\r
     { { $link compose } { $snippet ": compose '[ @ @ ] ;" } }\r
-    { { $link bi@ } { $snippet ": bi@ tuck '[ _ @ _ @ ] call ;" } }\r
 } ;\r
 \r
 ARTICLE: "fry.philosophy" "Fried quotation philosophy"\r
index 549db25e09e96e76639dbfe6fa44e411c98968b7..b341c462be39afe739f41d64a4298a4204a8e794 100644 (file)
@@ -1,18 +1,43 @@
+! (c)2009 Slava Pestov, Eduardo Cavazos, Joe Groff bsd license
 USING: fry tools.test math prettyprint kernel io arrays
 sequences eval accessors ;
 IN: fry.tests
 
+SYMBOLS: a b c d e f g h ;
+
+[ [ ] ] [ '[ ] ] unit-test
+[ [ + ] ] [ '[ + ] ] unit-test
+[ [ 1 ] ] [ 1 '[ _ ] ] unit-test
+[ [ 1 ] ] [ [ 1 ] '[ @ ] ] unit-test
+[ [ 1 2 ] ] [ [ 1 ] [ 2 ] '[ @ @ ] ] unit-test
+
+[ [ 1 2 a ] ] [ 1 2 '[ _ _ a ] ] unit-test
+[ [ 1 2 ] ] [ 1 2 '[ _ _ ] ] unit-test
+[ [ a 1 2 ] ] [ 1 2 '[ a _ _ ] ] unit-test
+[ [ 1 2 a ] ] [ [ 1 ] [ 2 ] '[ @ @ a ] ] unit-test
+[ [ 1 a 2 b ] ] [ 1 2 '[ _ a _ b ] ] unit-test
+[ [ 1 a 2 b ] ] [ 1 [ 2 ] '[ _ a @ b ] ] unit-test
+[ [ a 1 b ] ] [ 1 '[ a _ b ] ] unit-test
+
+[ [ a 1 b ] ] [ [ 1 ] '[ a @ b ] ] unit-test
+[ [ a 1 2 ] ] [ [ 1 ] [ 2 ] '[ a @ @ ] ] unit-test
+
+[ [ a [ 1 ] b ] ] [ 1 '[ a [ _ ] b ] ] unit-test
+[ [ a 1 b [ c 2 d ] e 3 f ] ] [ 1 2 3 '[ a _ b [ c _ d ] e _ f ] ] unit-test
+[ [ a 1 b [ c 2 d [ e 3 f ] ] g 4 h ] ] [ 1 2 3 4 '[ a _ b [ c _ d [ e _ f ] ] g _ h ] ] unit-test
+[ [ a 1 b [ [ c 2 d ] e 3 f ] g 4 h ] ] [ 1 2 3 4 '[ a _ b [ [ c _ d ] e _ f ] g _ h ] ] unit-test
+
 [ [ 3 + ] ] [ 3 '[ _ + ] ] unit-test
 
 [ [ 1 3 + ] ] [ 1 3 '[ _ _ + ] ] unit-test
 
-[ [ 1 [ + ] call ] ] [ 1 [ + ] '[ _ @ ] ] unit-test
+[ [ 1 + ] ] [ 1 [ + ] '[ _ @ ] ] unit-test
 
-[ [ 1 [ + ] call . ] ] [ 1 [ + ] '[ _ @ . ] ] unit-test
+[ [ 1 + . ] ] [ 1 [ + ] '[ _ @ . ] ] unit-test
 
-[ [ [ + ] [ - ] [ call ] dip call ] ] [ [ + ] [ - ] '[ @ @ ] ] unit-test
+[ [ + - ] ] [ [ + ] [ - ] '[ @ @ ] ] unit-test
 
-[ [ "a" "b" [ write ] dip print ] ]
+[ [ "a" write "b" print ] ]
 [ "a" "b" '[ _ write _ print ] ] unit-test
 
 [ 1/2 ] [
@@ -39,7 +64,7 @@ IN: fry.tests
 [ "hi" 3 ] [ "h" "i" 3 [ append ] funny-dip ] unit-test
 
 [ { 1 2 3 } ] [
-    3 1 '[ _ [ _ + ] map ] call
+    3 1 '[ _ iota [ _ + ] map ] call
 ] unit-test
 
 [ { 1 { 2 { 3 } } } ] [
index 184c6247a6004e32ba3b7b898aa5bdbb5990be84..e58253692f8fda4259ec6041fc95c7b9f03fd406 100644 (file)
@@ -1,7 +1,6 @@
-! Copyright (C) 2008 Slava Pestov, Eduardo Cavazos.
-! See http://factorcode.org/license.txt for BSD license.
-USING: kernel sequences combinators parser splitting math
-quotations arrays make words locals.backend summary sets ;
+! (c)2009 Slava Pestov, Eduardo Cavazos, Joe Groff bsd license
+USING: accessors combinators kernel locals.backend math parser
+quotations sequences sets splitting words ;
 IN: fry
 
 : _ ( -- * ) "Only valid inside a fry" throw ;
@@ -9,20 +8,9 @@ IN: fry
 
 ERROR: >r/r>-in-fry-error ;
 
-<PRIVATE
-
-: [ncurry] ( n -- quot )
-    {
-        { 0 [ [ ] ] }
-        { 1 [ [ curry ] ] }
-        { 2 [ [ 2curry ] ] }
-        { 3 [ [ 3curry ] ] }
-        [ \ curry <repetition> ]
-    } case ;
+GENERIC: fry ( quot -- quot' )
 
-M: >r/r>-in-fry-error summary
-    drop
-    "Explicit retain stack manipulation is not permitted in fried quotations" ;
+<PRIVATE
 
 : check-fry ( quot -- quot )
     dup { load-local load-locals get-local drop-locals } intersect
@@ -36,21 +24,124 @@ M: callable count-inputs [ count-inputs ] map-sum ;
 M: fry-specifier count-inputs drop 1 ;
 M: object count-inputs drop 0 ;
 
-GENERIC: deep-fry ( obj -- )
+MIXIN: fried
+PREDICATE: fried-callable < callable
+    count-inputs 0 > ;
+INSTANCE: fried-callable fried
 
-: shallow-fry ( quot -- quot' curry# )
-    check-fry
-    [ [ deep-fry ] each ] [ ] make
-    [ dup \ @ = [ drop [ _ call ] ] [ 1array ] if ] map concat
-    { _ } split [ spread>quot ] [ length 1 - ] bi ;
+: (ncurry) ( quot n -- quot )
+    {
+        { 0 [ ] }
+        { 1 [ \ curry  suffix! ] }
+        { 2 [ \ 2curry suffix! ] }
+        { 3 [ \ 3curry suffix! ] }
+        [ [ \ 3curry suffix! ] dip 3 - (ncurry) ]
+    } case ;
 
-PRIVATE>
+: wrap-non-callable ( obj -- quot )
+    dup callable? [ ] [ [ call ] curry ] if ; inline
 
-: fry ( quot -- quot' ) shallow-fry [ncurry] swap prefix ;
+: [ncurry] ( n -- quot )
+    [ V{ } clone ] dip (ncurry) >quotation ;
 
-M: callable deep-fry
-    [ count-inputs \ _ <repetition> % ] [ fry % ] bi ;
+: [ndip] ( quot n -- quot' )
+    {
+        { 0 [ wrap-non-callable ] }
+        { 1 [ \ dip  [ ] 2sequence ] }
+        { 2 [ \ 2dip [ ] 2sequence ] }
+        { 3 [ \ 3dip [ ] 2sequence ] }
+        [ [ \ 3dip [ ] 2sequence ] dip 3 - [ndip] ]
+    } case ;
+
+: (make-curry) ( tail quot -- quot' )
+    swap [ncurry] curry [ compose ] compose ;
+
+: make-compose ( consecutive quot -- consecutive quot' )
+    [
+        [ [ ] ]
+        [ [ncurry] ] if-zero
+    ] [
+        [ [ compose ] ]
+        [ [ compose compose ] curry ] if-empty
+    ] bi* compose
+    0 swap ;
+
+: make-curry ( consecutive quot -- consecutive' quot' )
+    [ 1 + ] dip
+    [ [ ] ] [ (make-curry) 0 swap ] if-empty ;
+
+: convert-curry ( consecutive quot -- consecutive' quot' )
+    [ [ ] make-curry ] [
+        dup first \ @ =
+        [ rest >quotation make-compose ]
+        [ >quotation make-curry ] if
+    ] if-empty ;
+
+: prune-curries ( seq -- seq' )
+    dup [ empty? not ] find 
+    [ [ 1 + tail ] dip but-last prefix ]
+    [ 2drop { } ] if* ;
+
+: convert-curries ( seq -- tail seq' )
+    unclip-slice [ 0 swap [ convert-curry ] map ] dip
+    [ prune-curries ]
+    [ >quotation 1quotation prefix ] if-empty ;
+
+: mark-composes ( quot -- quot' )
+    [ dup \ @ = [ drop [ _ @ ] ] [ 1quotation ] if ] map concat ; inline
+
+: shallow-fry ( quot -- quot' )
+    check-fry mark-composes
+    { _ } split convert-curries
+    [ [ [ ] ] [ [ ] (make-curry) but-last ] if-zero ]
+    [ spread>quot swap [ [ ] (make-curry) compose ] unless-zero ] if-empty ;
+
+DEFER: dredge-fry
+
+TUPLE: dredge-fry-state
+    { in-quot read-only }
+    { prequot read-only }
+    { quot read-only } ;
+
+: <dredge-fry> ( quot -- dredge-fry )
+    V{ } clone V{ } clone dredge-fry-state boa ; inline
+
+: in-quot-slices ( n i state -- head tail )
+    in-quot>>
+    [ <slice> ]
+    [ [ drop ] 2dip swap 1 + tail-slice ] 3bi ; inline
+
+: push-head-slice ( head state -- )
+    quot>> [ push-all ] [ \ _ swap push ] bi ; inline
+
+: push-subquot ( tail elt state -- )
+    [ fry swap >quotation count-inputs [ndip] ] dip prequot>> push-all ; inline
+
+: (dredge-fry-subquot) ( n state i elt -- )
+    rot {
+        [ nip in-quot-slices ] ! head tail i elt state
+        [ [ 2drop swap ] dip push-head-slice ]
+        [ [ drop ] 2dip push-subquot ]
+        [ [ 1 + ] [ drop ] [ ] tri* dredge-fry ]
+    } 3cleave ; inline recursive
+
+: (dredge-fry-simple) ( n state -- )
+    [ in-quot>> swap tail-slice ] [ quot>> ] bi push-all ; inline recursive
+
+: dredge-fry ( n dredge-fry -- )
+    2dup in-quot>> [ fried? ] find-from
+    [ (dredge-fry-subquot) ]
+    [ drop (dredge-fry-simple) ] if* ; inline recursive
+
+PRIVATE>
 
-M: object deep-fry , ;
+M: callable fry ( quot -- quot' )
+    [ [ [ ] ] ] [
+        0 swap <dredge-fry>
+        [ dredge-fry ] [
+            [ prequot>> >quotation ]
+            [ quot>> >quotation shallow-fry ] bi append
+        ] bi
+    ] if-empty ;
 
 SYNTAX: '[ parse-quotation fry append! ;
index 7653a922eae57aebcfaeeeee60a804f0a8e12c3f..251a99115efaa31dcecf204172002f7ac35e13e4 100644 (file)
@@ -3,13 +3,13 @@
 USING: accessors assocs byte-arrays calendar classes
 combinators combinators.short-circuit concurrency.promises
 continuations destructors ftp io io.backend io.directories
-io.encodings io.encodings.8-bit io.encodings.binary
+io.encodings io.encodings.binary
 tools.files io.encodings.utf8 io.files io.files.info
 io.pathnames io.launcher.unix.parser io.servers.connection
 io.sockets io.streams.duplex io.streams.string io.timeouts
 kernel make math math.bitwise math.parser namespaces sequences
 splitting threads unicode.case logging calendar.format
-strings io.files.links io.files.types ;
+strings io.files.links io.files.types io.encodings.8-bit.latin1 ;
 IN: ftp.server
 
 SYMBOL: server
index fe2840c9eba3d2e1f14e71daeb82cac4ae386176..51de8c0be6852053c8af3ad55a7508ac90899508 100644 (file)
@@ -22,7 +22,7 @@ server-state f
 
 : expire-state ( class -- )
     new
-        -1/0. millis [a,b] >>expires
+        -1/0. system-micros [a,b] >>expires
     delete-tuples ;
 
 TUPLE: server-state-manager < filter-responder timeout ;
@@ -33,4 +33,4 @@ TUPLE: server-state-manager < filter-responder timeout ;
         20 minutes >>timeout ; inline
 
 : touch-state ( state manager -- )
-    timeout>> hence timestamp>millis >>expires drop ;
+    timeout>> hence timestamp>micros >>expires drop ;
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index f031472..964b952
@@ -4,9 +4,10 @@ continuations game.input game.input.dinput.keys-array
 io.encodings.utf16 io.encodings.utf16n kernel locals math
 math.bitwise math.rectangles namespaces parser sequences
 shuffle specialized-arrays ui.backend.windows vectors
-windows.com windows.dinput windows.dinput.constants
-windows.errors windows.kernel32 windows.messages
-windows.ole32 windows.user32 classes.struct alien.data ;
+windows.com windows.directx.dinput
+windows.directx.dinput.constants .errors windows.kernel32
+windows.messages .ole32 windows.user32 classes.struct
+alien.data ;
 SPECIALIZED-ARRAY: DIDEVICEOBJECTDATA
 IN: game.input.dinput
 
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 377a89a..261f19c
@@ -35,7 +35,7 @@ M: f (reset-game-input) ;
 : reset-game-input ( -- )
     (reset-game-input) ;
 
-[ reset-game-input ] "game-input" add-init-hook
+[ reset-game-input ] "game-input" add-startup-hook
 
 PRIVATE>
 
@@ -75,9 +75,8 @@ SYMBOLS:
     get-controllers [ product-id = ] with filter ;
 : find-controller-instance ( product-id instance-id -- controller/f )
     get-controllers [
-        tuck
         [ product-id  = ]
-        [ instance-id = ] 2bi* and
+        [ instance-id = ] bi-curry bi* and
     ] with with find nip ;
 
 TUPLE: keyboard-state keys ;
old mode 100755 (executable)
new mode 100644 (file)
index 258f19e..efc586e
@@ -4,7 +4,7 @@ sequences locals combinators.short-circuit threads
 namespaces assocs arrays combinators hints alien
 core-foundation.run-loop accessors sequences.private
 alien.c-types alien.data math parser game.input vectors
-bit-arrays ;
+bit-arrays unix.types ;
 IN: game.input.iokit
 
 SINGLETON: iokit-game-input-backend
index e9a709030e067e86963644f5d2947c26dce2598e..5b869f138ee09205fa10db5d13f2382e9eed4dcc 100644 (file)
@@ -212,7 +212,7 @@ HELP: nwith
 } ;\r
 \r
 HELP: napply\r
-{ $values { "n" integer } }\r
+{ $values { "quot" quotation } { "n" integer } }\r
 { $description "A generalization of " { $link bi@ } " and " { $link tri@ } " that can work for any stack depth."\r
 } \r
 { $examples\r
@@ -332,18 +332,6 @@ HELP: nappend-as
 \r
 { nappend nappend-as } related-words\r
 \r
-HELP: ntuck\r
-{ $values\r
-     { "n" integer }\r
-}\r
-{ $description "A generalization of " { $link tuck } " that can work for any stack depth. The top item will be copied and placed " { $snippet "n" } " items down on the stack." } ;\r
-\r
-HELP: nspin\r
-{ $values\r
-    { "n" integer }\r
-}\r
-{ $description "A generalization of " { $link spin } " that can work for any stack depth. The top " { $snippet "n" } " items will be reversed in order." } ;\r
-\r
 ARTICLE: "sequence-generalizations" "Generalized sequence operations"\r
 { $subsections\r
     narray\r
@@ -363,8 +351,6 @@ ARTICLE: "shuffle-generalizations" "Generalized shuffle words"
     -nrot\r
     nnip\r
     ndrop\r
-    ntuck\r
-    nspin\r
     mnswap\r
     nweave\r
 } ;\r
index c54e35002f3803d56342baf8229b65bf777ef805..0c35f157142419ed6b1e912c6fe23707a950d3b8 100644 (file)
@@ -26,8 +26,6 @@ IN: generalizations.tests
 { 0 } [ 0 1 2 3 4 4 ndrop ] unit-test\r
 [ [ 1 ] 5 ndip ] must-infer\r
 [ 1 2 3 4 ] [ 2 3 4 [ 1 ] 3 ndip ] unit-test\r
-[ 5 nspin ] must-infer\r
-[ 1 5 4 3 2 ] [ 1 2 3 4 5 4 nspin ] unit-test\r
 \r
 [ 1 2 3 4 5 [ drop drop drop drop drop 2 ] 5 nkeep ] must-infer\r
 [ 1 2 3 4 5 2 '[ drop drop drop drop drop _ ] 5 nkeep ] must-infer\r
@@ -66,7 +64,7 @@ IN: generalizations.tests
 { 3 5 } [ 2 nweave ] must-infer-as\r
 \r
 [ { 0 1 2 } { 3 5 4 } { 7 8 6 } ]\r
-[ 9 [ ] each { [ 3array ] [ swap 3array ] [ rot 3array ] } 3 nspread ] unit-test\r
+[ 9 [ ] each-integer { [ 3array ] [ swap 3array ] [ rot 3array ] } 3 nspread ] unit-test\r
 \r
 [ 1 2 3 4 1 2 3 ] [ 1 2 3 4 3 nover ] unit-test\r
 \r
index 8d6d6f2ac0e77fd347a9b68a9216f2420d9fd602..6c8a0b5fdecf9558538ead28593a5d2904c3bba0 100644 (file)
@@ -71,9 +71,6 @@ MACRO: ndrop ( n -- )
 MACRO: nnip ( n -- )
     '[ [ _ ndrop ] dip ] ;
 
-MACRO: ntuck ( n -- )
-    2 + '[ dup _ -nrot ] ;
-
 MACRO: ndip ( n -- )
     [ [ dip ] curry ] n*quot [ call ] compose ;
 
@@ -112,8 +109,8 @@ MACRO: cleave* ( n -- )
     [ 1 - [ [ [ keep ] curry ] dip compose ] n*quot [ call ] compose ] 
     if-zero ;
 
-MACRO: napply ( n -- )
-    [ [ drop ] ] dip [ '[ tuck _ 2dip call ] ] times ;
+: napply ( quot n -- )
+    [ dupn ] [ spread* ] bi ; inline
 
 : apply-curry ( ...a quot n -- )
     [ [curry] ] dip napply ; inline
@@ -139,6 +136,3 @@ MACRO: nbi-curry ( n -- )
 
 : nappend ( n -- seq ) narray concat ; inline
 
-MACRO: nspin ( n -- )
-    [ [ ] ] swap [ swap [ ] curry compose ] n*quot [ call ] 3append ;
-
old mode 100755 (executable)
new mode 100644 (file)
index e1044b0feb0e5ef1bddff64fd1c97ab9b01dc820..2c2fee1d70e79233249c8803478f3652bcb2f97f 100644 (file)
@@ -52,7 +52,7 @@ HELP: <groups>
 { $examples
     { $example
         "USING: arrays kernel prettyprint sequences grouping ;"
-        "9 >array 3 <groups> reverse! concat >array ." "{ 6 7 8 3 4 5 0 1 2 }"
+        "9 iota >array 3 <groups> reverse! concat >array ." "{ 6 7 8 3 4 5 0 1 2 }"
     }
     { $example
         "USING: kernel prettyprint sequences grouping ;"
@@ -67,7 +67,7 @@ HELP: <sliced-groups>
 { $examples
     { $example
         "USING: arrays kernel prettyprint sequences grouping ;"
-        "9 >array 3 <sliced-groups>"
+        "9 iota >array 3 <sliced-groups>"
         "dup [ reverse! drop ] each concat >array ."
         "{ 2 1 0 5 4 3 8 7 6 }"
     }
old mode 100755 (executable)
new mode 100644 (file)
index d0f6a09..4c84bb8
@@ -39,6 +39,7 @@ SYMBOL: half
     [ [ >float half>bits ] 2dip set-alien-unsigned-2 ] >>setter
     2 >>size
     2 >>align
+    2 >>align-first
     [ >float ] >>unboxer-quot
 \ half define-primitive-type
 
index c1985c516f995cdee7c614985f4e9330a4b7c36e..703cf530805c06b44fbb6552847a12743c7d3d04 100644 (file)
@@ -31,7 +31,7 @@ IN: heaps.tests
     <min-heap> [ heap-push-all ] keep heap-pop-all ;
 
 : random-alist ( n -- alist )
-    [
+    iota [
         drop 32 random-bits dup number>string
     ] H{ } map>assoc ;
 
@@ -40,16 +40,16 @@ IN: heaps.tests
 
 14 [
     [ t ] swap [ 2^ test-heap-sort ] curry unit-test
-] each
+] each-integer
 
 : test-entry-indices ( n -- ? )
     random-alist
     <min-heap> [ heap-push-all ] keep
-    data>> dup length swap [ index>> ] map sequence= ;
+    data>> dup length iota swap [ index>> ] map sequence= ;
 
 14 [
     [ t ] swap [ 2^ test-entry-indices ] curry unit-test
-] each
+] each-integer
 
 : sort-entries ( entries -- entries' )
     [ key>> ] sort-with ;
@@ -66,4 +66,4 @@ IN: heaps.tests
 
 11 [
     [ t ] swap [ 2^ delete-test sequence= ] curry unit-test
-] each
+] each-integer
index 3bcc8151911fb042ccab52becf2966e8c78f743c..e77e7bccad0b13a3be79eb785a7b420c309ad559 100644 (file)
@@ -73,4 +73,4 @@ M: apropos >link ;
 INSTANCE: apropos topic
 
 : apropos ( str -- )
-    <apropos> print-topic ;
+    <apropos> print-topic nl ;
index ddd6ce23fca8566b1c3689c1708d3c79d5dee7c4..6fb87d7a33a74c35cf61c989c00e2db8dcbeb3d8 100644 (file)
@@ -129,7 +129,7 @@ M: word set-article-parent swap "help-parent" set-word-prop ;
 
 SYMBOL: help-hook
 
-help-hook [ [ print-topic ] ] initialize
+help-hook [ [ print-topic nl ] ] initialize
 
 : help ( topic -- )
     help-hook get call( topic -- ) ;
old mode 100755 (executable)
new mode 100644 (file)
index 56a2cb9142a1bdc2c1a90ab7c804ef929269a089..46bdc698b73a59874c1884ba25626bfec96aa5fa 100644 (file)
@@ -20,7 +20,7 @@ HELP: specialized-def
 { $description "Outputs the definition of a word after it has been split into specialized branches. This is the definition which will actually be compiled by the compiler." } ;
 
 HELP: HINTS:
-{ $values { "defspec" "a definition specifier" } { "hints..." "a list of sequences of classes or literals" } }
+{ $values { "defspec" "a word or method" } { "hints..." "a list of sequences of classes or literals" } }
 { $description "Defines specialization hints for a word or a method."
 $nl
 "Each sequence in the list will cause a specialized version of the word to be compiled. Classes are tested for using their predicate, and literals are tested using " { $link eq? } "." }
@@ -35,8 +35,8 @@ $nl
     "M: assoc count-occurrences"
     "    swap [ = nip ] curry assoc-filter assoc-size ;"
     ""
-    "HINTS: { sequence count-occurrences } { object array } ;"
-    "HINTS: { assoc count-occurrences } { object hashtable } ;"
+    "HINTS: M\ sequence count-occurrences { object array } ;"
+    "HINTS: M\ assoc count-occurrences { object hashtable } ;"
 }
 } ;
 
index 1ca5bf1bc54ff898a1fec4d11b8c5be848f463cc..e4bbb3459e53a3b6543573666bde13843b7b8046 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2008, 2009 Slava Pestov.
+! Copyright (C) 2008, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors arrays assocs byte-arrays byte-vectors classes
 combinators definitions effects fry generic generic.single
@@ -24,7 +24,7 @@ M: object specializer-declaration class ;
     "specializer" word-prop ;
 
 : make-specializer ( specs -- quot )
-    dup length <reversed>
+    dup length iota <reversed>
     [ (picker) 2array ] 2map
     [ drop object eq? not ] assoc-filter
     [ [ t ] ] [
index 330db4467b12b5d07d67da1d47d1e01ed8b6a24d..04077fc2f7b0369b4cab6750041a1e57de778f6a 100644 (file)
@@ -1,7 +1,7 @@
 USING: http help.markup help.syntax io.pathnames io.streams.string
-io.encodings.8-bit io.encodings.binary kernel urls
+io.encodings.binary kernel urls
 urls.encoding byte-arrays strings assocs sequences destructors
-http.client.post-data.private ;
+http.client.post-data.private io.encodings.8-bit.latin1 ;
 IN: http.client
 
 HELP: download-failed
index 016e347e89bc2b66d62d5c2a8a983f3215cef796..482a23aeaa644328712528762155b16e210b9202 100644 (file)
@@ -5,7 +5,7 @@ sequences strings splitting calendar continuations accessors vectors
 math.order hashtables byte-arrays destructors
 io io.sockets io.streams.string io.files io.timeouts
 io.pathnames io.encodings io.encodings.string io.encodings.ascii
-io.encodings.utf8 io.encodings.8-bit io.encodings.binary io.crlf
+io.encodings.utf8 io.encodings.binary io.crlf
 io.streams.duplex fry ascii urls urls.encoding present locals
 http http.parsers http.client.post-data ;
 IN: http.client
index 0dca26fd328b35aa43a930731bb9479cffa95d98..2de2323394634150def828ea5b12d533f7443e3f 100644 (file)
@@ -103,9 +103,10 @@ HELP: post-data
 $nl
 "Instances contain the following slots:"
 { $table
-    { { $slot "raw" } { "The raw bytes of the POST data" } }
-    { { $slot "content" } { "The POST data. This can be in a higher-level form, such as an assoc of POST parameters, a string, or an XML document" } }
-    { { $slot "content-type" } "A MIME type" }
+    { { $slot "data" } { "The POST data. This can be in a higher-level form, such as an assoc of POST parameters, a string, or an XML document" } }
+    { { $slot "params" } { "Parameters passed in the POST request." } } 
+    { { $slot "content-type" } { "A MIME type" } }
+    { { $slot "content-encoding" } { "Encoding used for the POST data" } }
 } } ;
 
 HELP: set-header
index 3fe5e84abd6762a3cdd781ebbff437392d10041f..35d01c10141d7ebbd6157cb02206af74dcc1039e 100644 (file)
@@ -2,7 +2,8 @@ USING: http http.server http.client http.client.private tools.test
 multiline io.streams.string io.encodings.utf8 io.encodings.8-bit
 io.encodings.binary io.encodings.string io.encodings.ascii kernel
 arrays splitting sequences assocs io.sockets db db.sqlite
-continuations urls hashtables accessors namespaces xml.data ;
+continuations urls hashtables accessors namespaces xml.data
+io.encodings.8-bit.latin1 ;
 IN: http.tests
 
 [ "text/plain" latin1 ] [ "text/plain" parse-content-type ] unit-test
old mode 100755 (executable)
new mode 100644 (file)
index 4bcfbeb..6f898e9
@@ -5,9 +5,7 @@ sequences splitting sorting sets strings vectors hashtables
 quotations arrays byte-arrays math.parser calendar
 calendar.format present urls fry
 io io.encodings io.encodings.iana io.encodings.binary
-io.encodings.8-bit io.crlf ascii
-http.parsers
-base64 ;
+io.crlf ascii io.encodings.8-bit.latin1 http.parsers base64 ;
 IN: http
 
 CONSTANT: max-redirects 10
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 50926666f6239205473b2018e05e4e3a7520aa71..702fd14472fa2f2dc45a6035b93cff0c2c0fa8cb 100644 (file)
@@ -2,9 +2,9 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors alien.c-types arrays byte-arrays combinators
 compression.run-length fry grouping images images.loader io
-io.binary io.encodings.8-bit io.encodings.binary
+io.binary io.encodings.binary
 io.encodings.string io.streams.limited kernel math math.bitwise
-sequences specialized-arrays summary images.bitmap ;
+io.encodings.8-bit.latin1 sequences specialized-arrays summary images.bitmap ;
 QUALIFIED-WITH: bitstreams b
 SPECIALIZED-ARRAY: ushort
 IN: images.bitmap.loading
old mode 100755 (executable)
new mode 100644 (file)
index 4f10808b040887e5f103abafa8d83a5fdbdf7ca6..9a67d43e7d90aa24d575225cb1f2a9a36a6828f0 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2009 Marc Fauconneau.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors arrays byte-arrays combinators
-grouping compression.huffman images
+grouping compression.huffman images fry
 images.processing io io.binary io.encodings.binary io.files
 io.streams.byte-array kernel locals math math.bitwise
 math.constants math.functions math.matrices math.order
@@ -137,7 +137,7 @@ TUPLE: jpeg-color-info
     data>>
     binary
     [
-        read1 [0,b)
+        read1 iota
         [   drop
             read1 jpeg> color-info>> nth clone
             read1 16 /mod [ >>dc-huff-table ] [ >>ac-huff-table ] bi*
@@ -198,7 +198,7 @@ MEMO: yuv>bgr-matrix ( -- m )
     { 8 8 } coord-matrix [ { u v } [ wave ] 2map product ] map^2
     1 u v [ 0 = [ 2 sqrt / ] when ] bi@ 4 / m*n ;
 
-MEMO: dct-matrix ( -- m ) 64 [0,b) [ 8 /mod dct-vect flatten ] map ;
+MEMO: dct-matrix ( -- m ) 64 iota [ 8 /mod dct-vect flatten ] map ;
 
 : mb-dim ( component -- dim )  [ h>> ] [ v>> ] bi 2array ;
 
@@ -232,7 +232,7 @@ MEMO: dct-matrix-blas ( -- m ) dct-matrix >float-blas-matrix ;
     block dup length>> sqrt >fixnum group flip
     dup matrix-dim coord-matrix flip
     [
-        [ first2 spin nth nth ]
+        [ '[ _ [ second ] [ first ] bi ] dip nth nth ]
         [ x,y v+ color-id jpeg-image draw-color ] bi
     ] with each^2 ;
 
@@ -295,7 +295,7 @@ MEMO: dct-matrix-blas ( -- m ) dct-matrix >float-blas-matrix ;
     binary [
         [
             { HEX: FF } read-until
-            read1 tuck HEX: 00 = and
+            read1 [ HEX: 00 = and ] keep swap
         ]
         [ drop ] produce
         swap >marker {  EOI } assert=
index ccf891d770f4458687d432dbdfdc6b543160ab35..883a0975118ddbdefb2c5db9f985e307686df227 100644 (file)
@@ -10,7 +10,7 @@ IN: images.memory
 
 <PRIVATE
 
-: bitmap-size ( dim -- n ) product "uint" heap-size * ;
+: bitmap-size ( dim -- n ) product uint heap-size * ;
 
 : malloc-bitmap-data ( dim -- alien ) bitmap-size 1 calloc &free ;
 
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index cb9a347..d4a9c4a
@@ -120,7 +120,7 @@ ERROR: unimplemented-color-type image ;
     prev width tail-slice :> b
     curr :> a
     curr width tail-slice :> x
-    x length [0,b)
+    x length iota
     filter {
         { filter-none [ drop ] }
         { filter-sub [ [| n | n x nth n a nth + 256 wrap n x set-nth ] each ] }
@@ -290,6 +290,14 @@ ERROR: invalid-color-type/bit-depth loading-png ;
 : validate-truecolor-alpha ( loading-png -- loading-png )
     { 8 16 } validate-bit-depth ;
 
+: pad-bitmap ( image -- image )
+    dup dim>> second 4 divisor? [
+        dup [ bytes-per-pixel ]
+        [ dim>> first * ]
+        [ dim>> first 4 mod ] tri
+        '[ _ group [ _ 0 <array> append ] map B{ } concat-as ] change-bitmap
+    ] unless ;
+
 : loading-png>bitmap ( loading-png -- bytes component-order )
     dup color-type>> {
         { greyscale [
@@ -315,7 +323,7 @@ ERROR: invalid-color-type/bit-depth loading-png ;
         [ loading-png>bitmap [ >>bitmap ] [ >>component-order ] bi* ]
         [ [ width>> ] [ height>> ] bi 2array >>dim ]
         [ png-component >>component-type ]
-    } cleave ;
+    } cleave pad-bitmap ;
 
 : load-png ( stream -- loading-png )
     [
old mode 100755 (executable)
new mode 100644 (file)
index cd67545..b21eb50
@@ -6,7 +6,7 @@ math.ranges math.vectors sequences sequences.deep fry ;
 IN: images.processing\r
 \r
 : coord-matrix ( dim -- m )\r
-    [ [0,b) ] map first2 [ [ 2array ] with map ] curry map ;\r
+    [ iota ] map first2 [ [ 2array ] with map ] curry map ;\r
 \r
 : map^2 ( m quot -- m' ) '[ _ map ] map ; inline\r
 : each^2 ( m quot -- m' ) '[ _ each ] each ; inline\r
@@ -16,7 +16,7 @@ IN: images.processing
 : matrix>image ( m -- image )\r
     <image> over matrix-dim >>dim\r
     swap flip flatten\r
-    [ 128 * 128 + 0 max 255 min  >fixnum ] map\r
+    [ 128 * 128 + 0 255 clamp >fixnum ] map\r
     >byte-array >>bitmap L >>component-order ubyte-components >>component-type ;\r
 \r
 :: matrix-zoom ( m f -- m' )\r
@@ -30,7 +30,7 @@ IN: images.processing
 :: draw-grey ( value x,y image -- )\r
     x,y image image-offset 3 * { 0 1 2 }\r
     [\r
-        + value 128 + >fixnum 0 max 255 min swap image bitmap>> set-nth\r
+        + value 128 + >fixnum 0 255 clamp swap image bitmap>> set-nth\r
     ] with each ;\r
 \r
 :: draw-color ( value x,y color-id image -- )\r
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 82c2487f671b30bacb8af47767b6da887e2e7a7e..2aa7cd218e02b051ca1ac66b2612bbefe620b2d1 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2005, 2009 Slava Pestov.
+! Copyright (C) 2005, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors arrays generic hashtables io kernel assocs math
 namespaces prettyprint prettyprint.custom prettyprint.sections
@@ -23,9 +23,7 @@ GENERIC: add-numbers ( alist -- table' )
 M: enum add-numbers ;
 
 M: assoc add-numbers
-    +number-rows+ get [
-        dup length [ prefix ] 2map
-    ] when ;
+    +number-rows+ get [ [ prefix ] map-index ] when ;
 
 TUPLE: slot-name name ;
 
old mode 100755 (executable)
new mode 100644 (file)
index 1e941af..d112e4e
@@ -68,7 +68,7 @@ UNION: explicit-inverse normal-inverse math-inverse pop-inverse ;
 
 : enough? ( stack word -- ? )
     dup deferred? [ 2drop f ] [
-        [ [ length ] [ 1quotation infer in>> ] bi* >= ]
+        [ [ length ] [ 1quotation inputs ] bi* >= ]
         [ 3drop f ] recover
     ] if ;
 
@@ -141,7 +141,6 @@ MACRO: undo ( quot -- ) [undo] ;
 \ 2dup [ over =/fail over =/fail ] define-inverse
 \ 3dup [ pick =/fail pick =/fail pick =/fail ] define-inverse
 \ pick [ [ pick ] dip =/fail ] define-inverse
-\ tuck [ swapd [ =/fail ] keep ] define-inverse
 
 \ bi@ 1 [ [undo] '[ _ bi@ ] ] define-pop-inverse
 \ tri@ 1 [ [undo] '[ _ tri@ ] ] define-pop-inverse
@@ -274,10 +273,10 @@ DEFER: __
     ] recover ; inline
 
 : true-out ( quot effect -- quot' )
-    out>> '[ @ _ ndrop t ] ;
+    out>> length '[ @ _ ndrop t ] ;
 
 : false-recover ( effect -- quot )
-    in>> [ ndrop f ] curry [ recover-fail ] curry ;
+    in>> length [ ndrop f ] curry [ recover-fail ] curry ;
 
 : [matches?] ( quot -- undoes?-quot )
     [undo] dup infer [ true-out ] [ false-recover ] bi curry ;
index e669875448cb6066b4747a19117441bd0a6f457f..0bc2b85b321e91e256b5c79bf248c3f2e255fd1b 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: io.backend system namespaces io.backend.unix.bsd
 io.backend.unix.multiplexers io.backend.unix.multiplexers.run-loop ;
-IN: io.backend.macosx
+IN: io.backend.unix.macosx
 
 M: macosx init-io ( -- )
     <run-loop-mx> mx set-global ;
index b9c224c6294bb3d2c2f739dd9b2badb97e97c80f..6ec8caaad8e2def161071f4b291013421cfc7be0 100644 (file)
@@ -9,10 +9,9 @@ IN: io.backend.unix.multiplexers.epoll
 
 TUPLE: epoll-mx < mx events ;
 
-: max-events ( -- n )
-    #! We read up to 256 events at a time. This is an arbitrary
-    #! constant...
-    256 ; inline
+#! We read up to 256 events at a time. This is an arbitrary
+#! constant...
+CONSTANT: max-events 256
 
 : <epoll-mx> ( -- mx )
     epoll-mx new-mx
@@ -51,8 +50,8 @@ M: epoll-mx remove-output-callbacks ( fd mx -- seq )
         [ EPOLLOUT do-epoll-del ] [ call-next-method ] 2bi
     ] [ 2drop f ] if ;
 
-: wait-event ( mx us -- n )
-    [ [ fd>> ] [ events>> ] bi dup length ] [ 1000 /i ] bi*
+: wait-event ( mx nanos -- n )
+    [ [ fd>> ] [ events>> ] bi dup length ] [ 1000000 /i ] bi*
     epoll_wait multiplexer-error ;
 
 : handle-event ( event mx -- )
@@ -63,5 +62,5 @@ M: epoll-mx remove-output-callbacks ( fd mx -- seq )
 : handle-events ( mx n -- )
     [ dup events>> ] dip head-slice swap '[ _ handle-event ] each ;
 
-M: epoll-mx wait-for-events ( us mx -- )
+M: epoll-mx wait-for-events ( nanos mx -- )
     swap 60000000 or dupd wait-event handle-events ;
index c777e57f1db528649fa30fb949576323d35ff6c2..16d0338da532eb39f8e59129797353b2db545155 100644 (file)
@@ -73,6 +73,6 @@ M: kqueue-mx remove-output-callbacks ( fd mx -- seq )
     [ dup events>> ] dip head-slice
     [ handle-kevent ] with each ;
 
-M: kqueue-mx wait-for-events ( us mx -- )
+M: kqueue-mx wait-for-events ( nanos mx -- )
     swap dup [ make-timespec ] when
     dupd wait-kevent handle-kevents ;
index 73d8a603104061b7b7f81c36ae100ef59fc81ca1..ded028dda49e62a15bb61a66526f72ff7fde6319 100644 (file)
@@ -26,7 +26,7 @@ GENERIC: remove-output-callbacks ( fd mx -- callbacks )
 
 M: mx remove-output-callbacks writes>> delete-at* drop ;
 
-GENERIC: wait-for-events ( ms mx -- )
+GENERIC: wait-for-events ( nanos mx -- )
 
 : input-available ( fd mx -- )
     reads>> delete-at* drop [ resume ] each ;
index 276949a99fadcb501776a8981994e082ab117299..05328b48dc9e34f438ee3af44460638e73c7f486 100644 (file)
@@ -30,5 +30,5 @@ M: run-loop-mx add-output-callback kqueue-mx>> add-output-callback ;
 M: run-loop-mx remove-input-callbacks kqueue-mx>> remove-input-callbacks ;
 M: run-loop-mx remove-output-callbacks kqueue-mx>> remove-output-callbacks ;
 
-M: run-loop-mx wait-for-events ( us mx -- )
+M: run-loop-mx wait-for-events ( nanos mx -- )
     swap run-one-iteration [ 0 swap wait-for-events ] [ drop ] if ;
index 8022ed34e223f899cb302486d63efa795b3e2368..f2d1a3a3b78c3cf7a22f5048c3a1e26591cb0741 100644 (file)
@@ -48,9 +48,9 @@ TUPLE: select-mx < mx read-fdset write-fdset ;
     [ write-fdset/tasks [ init-fdset ] keep ] tri
     f ;
 
-M:: select-mx wait-for-events ( us mx -- )
+M:: select-mx wait-for-events ( nanos mx -- )
     mx
-    [ init-fdsets us dup [ make-timeval ] when select multiplexer-error drop ]
+    [ init-fdsets nanos 1000 /i dup [ make-timeval ] when select multiplexer-error drop ]
     [ [ read-fdset/tasks ] keep [ input-available ] check-fdset ]
     [ [ write-fdset/tasks ] keep [ output-available ] check-fdset ]
     tri ;
index ebb8f1ec05c9367050661c2ecd736221bbf08779..a8070525c7d3ca676b5d3d2389811de801d5043a 100644 (file)
@@ -5,7 +5,7 @@ kernel.private math io.ports sequences strings sbufs threads
 unix vectors io.buffers io.backend io.encodings math.parser
 continuations system libc namespaces make io.timeouts
 io.encodings.utf8 destructors destructors.private accessors
-summary combinators locals unix.time fry
+summary combinators locals unix.time unix.types fry
 io.backend.unix.multiplexers ;
 QUALIFIED: io
 IN: io.backend.unix
@@ -151,7 +151,7 @@ M: stdin dispose*
 
 : wait-for-stdin ( stdin -- n )
     [ control>> CHAR: X over io:stream-write1 io:stream-flush ]
-    [ size>> "ssize_t" heap-size swap io:stream-read *int ]
+    [ size>> ssize_t heap-size swap io:stream-read *int ]
     bi ;
 
 :: refill-stdin ( buffer stdin size -- )
old mode 100755 (executable)
new mode 100644 (file)
index 452dc4a..de29f33
@@ -50,21 +50,22 @@ M: winnt add-completion ( win32-handle -- )
         } cond
     ] with-timeout ;
 
-:: wait-for-overlapped ( us -- bytes-transferred overlapped error? )
+:: wait-for-overlapped ( nanos -- bytes-transferred overlapped error? )
     master-completion-port get-global
-    0 <int> [ ! bytes
-        f <void*> ! key
-        f <void*> [ ! overlapped
-            us [ 1000 /i ] [ INFINITE ] if* ! timeout
-            GetQueuedCompletionStatus zero?
-        ] keep
-        *void* dup [ OVERLAPPED memory>struct ] when
-    ] keep *int spin ;
+    0 <int> :> bytes
+    f <void*> :> key
+    f <void*> :> overlapped
+    nanos [ 1,000,000 /i ] [ INFINITE ] if* :> timeout
+    bytes key overlapped timeout GetQueuedCompletionStatus zero? :> error?
+
+    bytes *int
+    overlapped *void* dup [ OVERLAPPED memory>struct ] when
+    error? ;
 
 : resume-callback ( result overlapped -- )
     >c-ptr pending-overlapped get-global delete-at* drop resume-with ;
 
-: handle-overlapped ( us -- ? )
+: handle-overlapped ( nanos -- ? )
     wait-for-overlapped [
         [
             [ drop GetLastError 1array ] dip resume-callback t
@@ -74,7 +75,7 @@ M: winnt add-completion ( win32-handle -- )
 M: win32-handle cancel-operation
     [ check-disposed ] [ handle>> CancelIo drop ] bi ;
 
-M: winnt io-multiplex ( us -- )
+M: winnt io-multiplex ( nanos -- )
     handle-overlapped [ 0 io-multiplex ] when ;
 
 M: winnt init-io ( -- )
old mode 100755 (executable)
new mode 100644 (file)
index d366df7c54ff33aa97b696ff0796eec9ce3740dd..836b4d0cc8aea7c273318d5d2028d0e7ebc64ddb 100644 (file)
@@ -8,7 +8,7 @@ strings accessors destructors ;
     [ length ] dip buffer-reset ;
 
 : string>buffer ( string -- buffer )
-    dup length <buffer> tuck buffer-set ;
+    dup length <buffer> [ buffer-set ] keep ;
 
 : buffer-read-all ( buffer -- byte-array )
     [ [ pos>> ] [ ptr>> ] bi <displaced-alien> ]
@@ -58,3 +58,7 @@ strings accessors destructors ;
 100 <buffer> "b" set
 [ 1000 "b" get n>buffer >string ] must-fail
 "b" get dispose
+
+"hello world" string>buffer "b" set
+[ "hello" CHAR: \s ] [ " " "b" get buffer-until [ >string ] dip ] unit-test
+"b" get dispose
index f45d3bb06223ba8d1619921c081a5ebeb4f76ebe..23358d9a0e20c2fcfd61e331ba344da53ccc1434 100644 (file)
@@ -1,5 +1,5 @@
 ! Copyright (C) 2004, 2005 Mackenzie Straight.
-! Copyright (C) 2006, 2008 Slava Pestov.
+! Copyright (C) 2006, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors alien alien.accessors alien.c-types
 alien.data alien.syntax kernel libc math sequences byte-arrays
@@ -73,7 +73,9 @@ HINTS: >buffer byte-array buffer ;
     bi ; inline
 
 : search-buffer-until ( pos fill ptr separators -- n )
-    [ [ swap alien-unsigned-1 ] dip member-eq? ] 2curry find-from drop ; inline
+    [ iota ] 2dip
+    [ [ swap alien-unsigned-1 ] dip member-eq? ] 2curry
+    find-from drop ; inline
 
 : finish-buffer-until ( buffer n -- byte-array separator )
     [
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 203d7c187ff6cc5254d7c2ad49cb8c658aa78fa1..b0677e80bd201e5937071417006d826bb2db7ec5 100644 (file)
@@ -5,106 +5,34 @@ strings ;
 IN: io.encodings.8-bit
 
 ARTICLE: "io.encodings.8-bit" "Legacy 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:"
-{ $subsections
-    latin1
-    latin2
-    latin3
-    latin4
-    latin/cyrillic
-    latin/arabic
-    latin/greek
-    latin/hebrew
-    latin5
-    latin6
-    latin/thai
-    latin7
-    latin8
-    latin9
-    latin10
-    koi8-r
-    windows-1252
-    ebcdic
-    mac-roman
+"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 available:"
+{ $list
+    { $vocab-link "io.encodings.8-bit.ebcdic" }
+    { $vocab-link "io.encodings.8-bit.latin1" }
+    { $vocab-link "io.encodings.8-bit.latin2" }
+    { $vocab-link "io.encodings.8-bit.latin3" }
+    { $vocab-link "io.encodings.8-bit.latin4" }
+    { $vocab-link "io.encodings.8-bit.cyrillic" }
+    { $vocab-link "io.encodings.8-bit.arabic" }
+    { $vocab-link "io.encodings.8-bit.greek" }
+    { $vocab-link "io.encodings.8-bit.hebrew" }
+    { $vocab-link "io.encodings.8-bit.latin5" }
+    { $vocab-link "io.encodings.8-bit.latin6" }
+    { $vocab-link "io.encodings.8-bit.thai" }
+    { $vocab-link "io.encodings.8-bit.latin7" }
+    { $vocab-link "io.encodings.8-bit.latin8" }
+    { $vocab-link "io.encodings.8-bit.latin9" }
+    { $vocab-link "io.encodings.8-bit.koi8-r" }
+    { $vocab-link "io.encodings.8-bit.mac-roman" }
+    { $vocab-link "io.encodings.8-bit.windows-1250" }
+    { $vocab-link "io.encodings.8-bit.windows-1251" }
+    { $vocab-link "io.encodings.8-bit.windows-1252" }
+    { $vocab-link "io.encodings.8-bit.windows-1253" }
+    { $vocab-link "io.encodings.8-bit.windows-1254" }
+    { $vocab-link "io.encodings.8-bit.windows-1255" }
+    { $vocab-link "io.encodings.8-bit.windows-1256" }
+    { $vocab-link "io.encodings.8-bit.windows-1257" }
+    { $vocab-link "io.encodings.8-bit.windows-1258" }
 } ;
 
 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: 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" } ;
index 55b9c44934e2c0448fe22de49f6b7e5b1446c841..5178630f0fa0cecda1cdf58306415731435a61ef 100644 (file)
@@ -1,5 +1,6 @@
 USING: io.encodings.string io.encodings.8-bit
-io.encodings.8-bit.private tools.test strings arrays ;
+io.encodings.8-bit.private tools.test strings arrays
+io.encodings.8-bit.latin1 io.encodings.8-bit.windows-1252 ;
 IN: io.encodings.8-bit.tests
 
 [ B{ CHAR: f CHAR: o CHAR: o } ] [ "foo" latin1 encode ] unit-test
index c13bbccd432e988644245c824265cef8c13920c6..7f92028c312ff3417e28047ba79e520f43603b9f 100644 (file)
@@ -1,42 +1,19 @@
-! Copyright (C) 2008 Daniel Ehrenberg
+! Copyright (C) 2008 Daniel Ehrenberg, Doug Coleman.
 ! 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
 words.symbol io io.files splitting namespaces math
 compiler.units accessors classes.singleton classes.mixin
-io.encodings.iana fry simple-flat-file ;
+io.encodings.iana fry simple-flat-file lexer ;
 IN: io.encodings.8-bit
 
 <PRIVATE
 
-CONSTANT: mappings {
-    ! encoding-name iana-name file-name
-    { "latin1" "ISO_8859-1:1987" "8859-1" }
-    { "latin2" "ISO_8859-2:1987" "8859-2" }
-    { "latin3" "ISO_8859-3:1988" "8859-3" }
-    { "latin4" "ISO_8859-4:1988" "8859-4" }
-    { "latin/cyrillic" "ISO_8859-5:1988" "8859-5" }
-    { "latin/arabic" "ISO_8859-6:1987" "8859-6" }
-    { "latin/greek" "ISO_8859-7:1987" "8859-7" }
-    { "latin/hebrew" "ISO_8859-8:1988" "8859-8" }
-    { "latin5" "ISO_8859-9:1989" "8859-9" }
-    { "latin6" "ISO-8859-10" "8859-10" }
-    { "latin/thai" "TIS-620" "8859-11" }
-    { "latin7" "ISO-8859-13" "8859-13" }
-    { "latin8" "ISO-8859-14" "8859-14" }
-    { "latin9" "ISO-8859-15" "8859-15" }
-    { "latin10" "ISO-8859-16" "8859-16" }
-    { "koi8-r" "KOI8-R" "KOI8-R" }
-    { "windows-1250" "windows-1250" "CP1250" }
-    { "windows-1252" "windows-1252" "CP1252" }
-    { "ebcdic" "IBM037" "CP037" }
-    { "mac-roman" "macintosh" "ROMAN" }
-}
-
 : encoding-file ( file-name -- stream )
     "vocab:io/encodings/8-bit/" ".TXT" surround ;
 
 SYMBOL: 8-bit-encodings
+8-bit-encodings [ H{ } clone ] initialize
 
 TUPLE: 8-bit biassoc ;
 
@@ -62,20 +39,17 @@ M: 8-bit-encoding <decoder>
     8-bit-encodings get-global at <decoder> ;
 
 : create-encoding ( name -- word )
-    "io.encodings.8-bit" create
+    create-in
     [ define-singleton-class ]
     [ 8-bit-encoding add-mixin-instance ]
     [ ] tri ;
 
+: load-encoding ( name iana-name file-name -- )
+    [ create-encoding dup ]
+    [ register-encoding ]
+    [ encoding-file flat-file>biassoc 8-bit boa ] tri*
+    swap 8-bit-encodings get-global set-at ;
+
 PRIVATE>
 
-[
-    mappings [
-        first3
-        [ create-encoding ]
-        [ dupd register-encoding ]
-        [ encoding-file flat-file>biassoc 8-bit boa ]
-        tri*
-    ] H{ } map>assoc
-    8-bit-encodings set-global
-] with-compilation-unit
+SYNTAX: 8-BIT: scan scan scan load-encoding ;
diff --git a/basis/io/encodings/8-bit/CP1251.TXT b/basis/io/encodings/8-bit/CP1251.TXT
new file mode 100644 (file)
index 0000000..4d9b355
--- /dev/null
@@ -0,0 +1,274 @@
+#
+#    Name:     cp1251 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 cp1251 code (in hex)
+#        Column #2 is the Unicode (in hex as 0xXXXX)
+#        Column #3 is the Unicode name (follows a comment sign, '#')
+#
+#    The entries are in cp1251 order
+#
+0x00   0x0000  #NULL
+0x01   0x0001  #START OF HEADING
+0x02   0x0002  #START OF TEXT
+0x03   0x0003  #END OF TEXT
+0x04   0x0004  #END OF TRANSMISSION
+0x05   0x0005  #ENQUIRY
+0x06   0x0006  #ACKNOWLEDGE
+0x07   0x0007  #BELL
+0x08   0x0008  #BACKSPACE
+0x09   0x0009  #HORIZONTAL TABULATION
+0x0A   0x000A  #LINE FEED
+0x0B   0x000B  #VERTICAL TABULATION
+0x0C   0x000C  #FORM FEED
+0x0D   0x000D  #CARRIAGE RETURN
+0x0E   0x000E  #SHIFT OUT
+0x0F   0x000F  #SHIFT IN
+0x10   0x0010  #DATA LINK ESCAPE
+0x11   0x0011  #DEVICE CONTROL ONE
+0x12   0x0012  #DEVICE CONTROL TWO
+0x13   0x0013  #DEVICE CONTROL THREE
+0x14   0x0014  #DEVICE CONTROL FOUR
+0x15   0x0015  #NEGATIVE ACKNOWLEDGE
+0x16   0x0016  #SYNCHRONOUS IDLE
+0x17   0x0017  #END OF TRANSMISSION BLOCK
+0x18   0x0018  #CANCEL
+0x19   0x0019  #END OF MEDIUM
+0x1A   0x001A  #SUBSTITUTE
+0x1B   0x001B  #ESCAPE
+0x1C   0x001C  #FILE SEPARATOR
+0x1D   0x001D  #GROUP SEPARATOR
+0x1E   0x001E  #RECORD SEPARATOR
+0x1F   0x001F  #UNIT SEPARATOR
+0x20   0x0020  #SPACE
+0x21   0x0021  #EXCLAMATION MARK
+0x22   0x0022  #QUOTATION MARK
+0x23   0x0023  #NUMBER SIGN
+0x24   0x0024  #DOLLAR SIGN
+0x25   0x0025  #PERCENT SIGN
+0x26   0x0026  #AMPERSAND
+0x27   0x0027  #APOSTROPHE
+0x28   0x0028  #LEFT PARENTHESIS
+0x29   0x0029  #RIGHT PARENTHESIS
+0x2A   0x002A  #ASTERISK
+0x2B   0x002B  #PLUS SIGN
+0x2C   0x002C  #COMMA
+0x2D   0x002D  #HYPHEN-MINUS
+0x2E   0x002E  #FULL STOP
+0x2F   0x002F  #SOLIDUS
+0x30   0x0030  #DIGIT ZERO
+0x31   0x0031  #DIGIT ONE
+0x32   0x0032  #DIGIT TWO
+0x33   0x0033  #DIGIT THREE
+0x34   0x0034  #DIGIT FOUR
+0x35   0x0035  #DIGIT FIVE
+0x36   0x0036  #DIGIT SIX
+0x37   0x0037  #DIGIT SEVEN
+0x38   0x0038  #DIGIT EIGHT
+0x39   0x0039  #DIGIT NINE
+0x3A   0x003A  #COLON
+0x3B   0x003B  #SEMICOLON
+0x3C   0x003C  #LESS-THAN SIGN
+0x3D   0x003D  #EQUALS SIGN
+0x3E   0x003E  #GREATER-THAN SIGN
+0x3F   0x003F  #QUESTION MARK
+0x40   0x0040  #COMMERCIAL AT
+0x41   0x0041  #LATIN CAPITAL LETTER A
+0x42   0x0042  #LATIN CAPITAL LETTER B
+0x43   0x0043  #LATIN CAPITAL LETTER C
+0x44   0x0044  #LATIN CAPITAL LETTER D
+0x45   0x0045  #LATIN CAPITAL LETTER E
+0x46   0x0046  #LATIN CAPITAL LETTER F
+0x47   0x0047  #LATIN CAPITAL LETTER G
+0x48   0x0048  #LATIN CAPITAL LETTER H
+0x49   0x0049  #LATIN CAPITAL LETTER I
+0x4A   0x004A  #LATIN CAPITAL LETTER J
+0x4B   0x004B  #LATIN CAPITAL LETTER K
+0x4C   0x004C  #LATIN CAPITAL LETTER L
+0x4D   0x004D  #LATIN CAPITAL LETTER M
+0x4E   0x004E  #LATIN CAPITAL LETTER N
+0x4F   0x004F  #LATIN CAPITAL LETTER O
+0x50   0x0050  #LATIN CAPITAL LETTER P
+0x51   0x0051  #LATIN CAPITAL LETTER Q
+0x52   0x0052  #LATIN CAPITAL LETTER R
+0x53   0x0053  #LATIN CAPITAL LETTER S
+0x54   0x0054  #LATIN CAPITAL LETTER T
+0x55   0x0055  #LATIN CAPITAL LETTER U
+0x56   0x0056  #LATIN CAPITAL LETTER V
+0x57   0x0057  #LATIN CAPITAL LETTER W
+0x58   0x0058  #LATIN CAPITAL LETTER X
+0x59   0x0059  #LATIN CAPITAL LETTER Y
+0x5A   0x005A  #LATIN CAPITAL LETTER Z
+0x5B   0x005B  #LEFT SQUARE BRACKET
+0x5C   0x005C  #REVERSE SOLIDUS
+0x5D   0x005D  #RIGHT SQUARE BRACKET
+0x5E   0x005E  #CIRCUMFLEX ACCENT
+0x5F   0x005F  #LOW LINE
+0x60   0x0060  #GRAVE ACCENT
+0x61   0x0061  #LATIN SMALL LETTER A
+0x62   0x0062  #LATIN SMALL LETTER B
+0x63   0x0063  #LATIN SMALL LETTER C
+0x64   0x0064  #LATIN SMALL LETTER D
+0x65   0x0065  #LATIN SMALL LETTER E
+0x66   0x0066  #LATIN SMALL LETTER F
+0x67   0x0067  #LATIN SMALL LETTER G
+0x68   0x0068  #LATIN SMALL LETTER H
+0x69   0x0069  #LATIN SMALL LETTER I
+0x6A   0x006A  #LATIN SMALL LETTER J
+0x6B   0x006B  #LATIN SMALL LETTER K
+0x6C   0x006C  #LATIN SMALL LETTER L
+0x6D   0x006D  #LATIN SMALL LETTER M
+0x6E   0x006E  #LATIN SMALL LETTER N
+0x6F   0x006F  #LATIN SMALL LETTER O
+0x70   0x0070  #LATIN SMALL LETTER P
+0x71   0x0071  #LATIN SMALL LETTER Q
+0x72   0x0072  #LATIN SMALL LETTER R
+0x73   0x0073  #LATIN SMALL LETTER S
+0x74   0x0074  #LATIN SMALL LETTER T
+0x75   0x0075  #LATIN SMALL LETTER U
+0x76   0x0076  #LATIN SMALL LETTER V
+0x77   0x0077  #LATIN SMALL LETTER W
+0x78   0x0078  #LATIN SMALL LETTER X
+0x79   0x0079  #LATIN SMALL LETTER Y
+0x7A   0x007A  #LATIN SMALL LETTER Z
+0x7B   0x007B  #LEFT CURLY BRACKET
+0x7C   0x007C  #VERTICAL LINE
+0x7D   0x007D  #RIGHT CURLY BRACKET
+0x7E   0x007E  #TILDE
+0x7F   0x007F  #DELETE
+0x80   0x0402  #CYRILLIC CAPITAL LETTER DJE
+0x81   0x0403  #CYRILLIC CAPITAL LETTER GJE
+0x82   0x201A  #SINGLE LOW-9 QUOTATION MARK
+0x83   0x0453  #CYRILLIC SMALL LETTER GJE
+0x84   0x201E  #DOUBLE LOW-9 QUOTATION MARK
+0x85   0x2026  #HORIZONTAL ELLIPSIS
+0x86   0x2020  #DAGGER
+0x87   0x2021  #DOUBLE DAGGER
+0x88   0x20AC  #EURO SIGN
+0x89   0x2030  #PER MILLE SIGN
+0x8A   0x0409  #CYRILLIC CAPITAL LETTER LJE
+0x8B   0x2039  #SINGLE LEFT-POINTING ANGLE QUOTATION MARK
+0x8C   0x040A  #CYRILLIC CAPITAL LETTER NJE
+0x8D   0x040C  #CYRILLIC CAPITAL LETTER KJE
+0x8E   0x040B  #CYRILLIC CAPITAL LETTER TSHE
+0x8F   0x040F  #CYRILLIC CAPITAL LETTER DZHE
+0x90   0x0452  #CYRILLIC SMALL LETTER DJE
+0x91   0x2018  #LEFT SINGLE QUOTATION MARK
+0x92   0x2019  #RIGHT SINGLE QUOTATION MARK
+0x93   0x201C  #LEFT DOUBLE QUOTATION MARK
+0x94   0x201D  #RIGHT DOUBLE QUOTATION MARK
+0x95   0x2022  #BULLET
+0x96   0x2013  #EN DASH
+0x97   0x2014  #EM DASH
+0x98           #UNDEFINED
+0x99   0x2122  #TRADE MARK SIGN
+0x9A   0x0459  #CYRILLIC SMALL LETTER LJE
+0x9B   0x203A  #SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
+0x9C   0x045A  #CYRILLIC SMALL LETTER NJE
+0x9D   0x045C  #CYRILLIC SMALL LETTER KJE
+0x9E   0x045B  #CYRILLIC SMALL LETTER TSHE
+0x9F   0x045F  #CYRILLIC SMALL LETTER DZHE
+0xA0   0x00A0  #NO-BREAK SPACE
+0xA1   0x040E  #CYRILLIC CAPITAL LETTER SHORT U
+0xA2   0x045E  #CYRILLIC SMALL LETTER SHORT U
+0xA3   0x0408  #CYRILLIC CAPITAL LETTER JE
+0xA4   0x00A4  #CURRENCY SIGN
+0xA5   0x0490  #CYRILLIC CAPITAL LETTER GHE WITH UPTURN
+0xA6   0x00A6  #BROKEN BAR
+0xA7   0x00A7  #SECTION SIGN
+0xA8   0x0401  #CYRILLIC CAPITAL LETTER IO
+0xA9   0x00A9  #COPYRIGHT SIGN
+0xAA   0x0404  #CYRILLIC CAPITAL LETTER UKRAINIAN IE
+0xAB   0x00AB  #LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+0xAC   0x00AC  #NOT SIGN
+0xAD   0x00AD  #SOFT HYPHEN
+0xAE   0x00AE  #REGISTERED SIGN
+0xAF   0x0407  #CYRILLIC CAPITAL LETTER YI
+0xB0   0x00B0  #DEGREE SIGN
+0xB1   0x00B1  #PLUS-MINUS SIGN
+0xB2   0x0406  #CYRILLIC CAPITAL LETTER BYELORUSSIAN-UKRAINIAN I
+0xB3   0x0456  #CYRILLIC SMALL LETTER BYELORUSSIAN-UKRAINIAN I
+0xB4   0x0491  #CYRILLIC SMALL LETTER GHE WITH UPTURN
+0xB5   0x00B5  #MICRO SIGN
+0xB6   0x00B6  #PILCROW SIGN
+0xB7   0x00B7  #MIDDLE DOT
+0xB8   0x0451  #CYRILLIC SMALL LETTER IO
+0xB9   0x2116  #NUMERO SIGN
+0xBA   0x0454  #CYRILLIC SMALL LETTER UKRAINIAN IE
+0xBB   0x00BB  #RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
+0xBC   0x0458  #CYRILLIC SMALL LETTER JE
+0xBD   0x0405  #CYRILLIC CAPITAL LETTER DZE
+0xBE   0x0455  #CYRILLIC SMALL LETTER DZE
+0xBF   0x0457  #CYRILLIC SMALL LETTER YI
+0xC0   0x0410  #CYRILLIC CAPITAL LETTER A
+0xC1   0x0411  #CYRILLIC CAPITAL LETTER BE
+0xC2   0x0412  #CYRILLIC CAPITAL LETTER VE
+0xC3   0x0413  #CYRILLIC CAPITAL LETTER GHE
+0xC4   0x0414  #CYRILLIC CAPITAL LETTER DE
+0xC5   0x0415  #CYRILLIC CAPITAL LETTER IE
+0xC6   0x0416  #CYRILLIC CAPITAL LETTER ZHE
+0xC7   0x0417  #CYRILLIC CAPITAL LETTER ZE
+0xC8   0x0418  #CYRILLIC CAPITAL LETTER I
+0xC9   0x0419  #CYRILLIC CAPITAL LETTER SHORT I
+0xCA   0x041A  #CYRILLIC CAPITAL LETTER KA
+0xCB   0x041B  #CYRILLIC CAPITAL LETTER EL
+0xCC   0x041C  #CYRILLIC CAPITAL LETTER EM
+0xCD   0x041D  #CYRILLIC CAPITAL LETTER EN
+0xCE   0x041E  #CYRILLIC CAPITAL LETTER O
+0xCF   0x041F  #CYRILLIC CAPITAL LETTER PE
+0xD0   0x0420  #CYRILLIC CAPITAL LETTER ER
+0xD1   0x0421  #CYRILLIC CAPITAL LETTER ES
+0xD2   0x0422  #CYRILLIC CAPITAL LETTER TE
+0xD3   0x0423  #CYRILLIC CAPITAL LETTER U
+0xD4   0x0424  #CYRILLIC CAPITAL LETTER EF
+0xD5   0x0425  #CYRILLIC CAPITAL LETTER HA
+0xD6   0x0426  #CYRILLIC CAPITAL LETTER TSE
+0xD7   0x0427  #CYRILLIC CAPITAL LETTER CHE
+0xD8   0x0428  #CYRILLIC CAPITAL LETTER SHA
+0xD9   0x0429  #CYRILLIC CAPITAL LETTER SHCHA
+0xDA   0x042A  #CYRILLIC CAPITAL LETTER HARD SIGN
+0xDB   0x042B  #CYRILLIC CAPITAL LETTER YERU
+0xDC   0x042C  #CYRILLIC CAPITAL LETTER SOFT SIGN
+0xDD   0x042D  #CYRILLIC CAPITAL LETTER E
+0xDE   0x042E  #CYRILLIC CAPITAL LETTER YU
+0xDF   0x042F  #CYRILLIC CAPITAL LETTER YA
+0xE0   0x0430  #CYRILLIC SMALL LETTER A
+0xE1   0x0431  #CYRILLIC SMALL LETTER BE
+0xE2   0x0432  #CYRILLIC SMALL LETTER VE
+0xE3   0x0433  #CYRILLIC SMALL LETTER GHE
+0xE4   0x0434  #CYRILLIC SMALL LETTER DE
+0xE5   0x0435  #CYRILLIC SMALL LETTER IE
+0xE6   0x0436  #CYRILLIC SMALL LETTER ZHE
+0xE7   0x0437  #CYRILLIC SMALL LETTER ZE
+0xE8   0x0438  #CYRILLIC SMALL LETTER I
+0xE9   0x0439  #CYRILLIC SMALL LETTER SHORT I
+0xEA   0x043A  #CYRILLIC SMALL LETTER KA
+0xEB   0x043B  #CYRILLIC SMALL LETTER EL
+0xEC   0x043C  #CYRILLIC SMALL LETTER EM
+0xED   0x043D  #CYRILLIC SMALL LETTER EN
+0xEE   0x043E  #CYRILLIC SMALL LETTER O
+0xEF   0x043F  #CYRILLIC SMALL LETTER PE
+0xF0   0x0440  #CYRILLIC SMALL LETTER ER
+0xF1   0x0441  #CYRILLIC SMALL LETTER ES
+0xF2   0x0442  #CYRILLIC SMALL LETTER TE
+0xF3   0x0443  #CYRILLIC SMALL LETTER U
+0xF4   0x0444  #CYRILLIC SMALL LETTER EF
+0xF5   0x0445  #CYRILLIC SMALL LETTER HA
+0xF6   0x0446  #CYRILLIC SMALL LETTER TSE
+0xF7   0x0447  #CYRILLIC SMALL LETTER CHE
+0xF8   0x0448  #CYRILLIC SMALL LETTER SHA
+0xF9   0x0449  #CYRILLIC SMALL LETTER SHCHA
+0xFA   0x044A  #CYRILLIC SMALL LETTER HARD SIGN
+0xFB   0x044B  #CYRILLIC SMALL LETTER YERU
+0xFC   0x044C  #CYRILLIC SMALL LETTER SOFT SIGN
+0xFD   0x044D  #CYRILLIC SMALL LETTER E
+0xFE   0x044E  #CYRILLIC SMALL LETTER YU
+0xFF   0x044F  #CYRILLIC SMALL LETTER YA
diff --git a/basis/io/encodings/8-bit/CP1253.TXT b/basis/io/encodings/8-bit/CP1253.TXT
new file mode 100644 (file)
index 0000000..20a55b0
--- /dev/null
@@ -0,0 +1,274 @@
+#
+#    Name:     cp1253 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 cp1253 code (in hex)
+#        Column #2 is the Unicode (in hex as 0xXXXX)
+#        Column #3 is the Unicode name (follows a comment sign, '#')
+#
+#    The entries are in cp1253 order
+#
+0x00   0x0000  #NULL
+0x01   0x0001  #START OF HEADING
+0x02   0x0002  #START OF TEXT
+0x03   0x0003  #END OF TEXT
+0x04   0x0004  #END OF TRANSMISSION
+0x05   0x0005  #ENQUIRY
+0x06   0x0006  #ACKNOWLEDGE
+0x07   0x0007  #BELL
+0x08   0x0008  #BACKSPACE
+0x09   0x0009  #HORIZONTAL TABULATION
+0x0A   0x000A  #LINE FEED
+0x0B   0x000B  #VERTICAL TABULATION
+0x0C   0x000C  #FORM FEED
+0x0D   0x000D  #CARRIAGE RETURN
+0x0E   0x000E  #SHIFT OUT
+0x0F   0x000F  #SHIFT IN
+0x10   0x0010  #DATA LINK ESCAPE
+0x11   0x0011  #DEVICE CONTROL ONE
+0x12   0x0012  #DEVICE CONTROL TWO
+0x13   0x0013  #DEVICE CONTROL THREE
+0x14   0x0014  #DEVICE CONTROL FOUR
+0x15   0x0015  #NEGATIVE ACKNOWLEDGE
+0x16   0x0016  #SYNCHRONOUS IDLE
+0x17   0x0017  #END OF TRANSMISSION BLOCK
+0x18   0x0018  #CANCEL
+0x19   0x0019  #END OF MEDIUM
+0x1A   0x001A  #SUBSTITUTE
+0x1B   0x001B  #ESCAPE
+0x1C   0x001C  #FILE SEPARATOR
+0x1D   0x001D  #GROUP SEPARATOR
+0x1E   0x001E  #RECORD SEPARATOR
+0x1F   0x001F  #UNIT SEPARATOR
+0x20   0x0020  #SPACE
+0x21   0x0021  #EXCLAMATION MARK
+0x22   0x0022  #QUOTATION MARK
+0x23   0x0023  #NUMBER SIGN
+0x24   0x0024  #DOLLAR SIGN
+0x25   0x0025  #PERCENT SIGN
+0x26   0x0026  #AMPERSAND
+0x27   0x0027  #APOSTROPHE
+0x28   0x0028  #LEFT PARENTHESIS
+0x29   0x0029  #RIGHT PARENTHESIS
+0x2A   0x002A  #ASTERISK
+0x2B   0x002B  #PLUS SIGN
+0x2C   0x002C  #COMMA
+0x2D   0x002D  #HYPHEN-MINUS
+0x2E   0x002E  #FULL STOP
+0x2F   0x002F  #SOLIDUS
+0x30   0x0030  #DIGIT ZERO
+0x31   0x0031  #DIGIT ONE
+0x32   0x0032  #DIGIT TWO
+0x33   0x0033  #DIGIT THREE
+0x34   0x0034  #DIGIT FOUR
+0x35   0x0035  #DIGIT FIVE
+0x36   0x0036  #DIGIT SIX
+0x37   0x0037  #DIGIT SEVEN
+0x38   0x0038  #DIGIT EIGHT
+0x39   0x0039  #DIGIT NINE
+0x3A   0x003A  #COLON
+0x3B   0x003B  #SEMICOLON
+0x3C   0x003C  #LESS-THAN SIGN
+0x3D   0x003D  #EQUALS SIGN
+0x3E   0x003E  #GREATER-THAN SIGN
+0x3F   0x003F  #QUESTION MARK
+0x40   0x0040  #COMMERCIAL AT
+0x41   0x0041  #LATIN CAPITAL LETTER A
+0x42   0x0042  #LATIN CAPITAL LETTER B
+0x43   0x0043  #LATIN CAPITAL LETTER C
+0x44   0x0044  #LATIN CAPITAL LETTER D
+0x45   0x0045  #LATIN CAPITAL LETTER E
+0x46   0x0046  #LATIN CAPITAL LETTER F
+0x47   0x0047  #LATIN CAPITAL LETTER G
+0x48   0x0048  #LATIN CAPITAL LETTER H
+0x49   0x0049  #LATIN CAPITAL LETTER I
+0x4A   0x004A  #LATIN CAPITAL LETTER J
+0x4B   0x004B  #LATIN CAPITAL LETTER K
+0x4C   0x004C  #LATIN CAPITAL LETTER L
+0x4D   0x004D  #LATIN CAPITAL LETTER M
+0x4E   0x004E  #LATIN CAPITAL LETTER N
+0x4F   0x004F  #LATIN CAPITAL LETTER O
+0x50   0x0050  #LATIN CAPITAL LETTER P
+0x51   0x0051  #LATIN CAPITAL LETTER Q
+0x52   0x0052  #LATIN CAPITAL LETTER R
+0x53   0x0053  #LATIN CAPITAL LETTER S
+0x54   0x0054  #LATIN CAPITAL LETTER T
+0x55   0x0055  #LATIN CAPITAL LETTER U
+0x56   0x0056  #LATIN CAPITAL LETTER V
+0x57   0x0057  #LATIN CAPITAL LETTER W
+0x58   0x0058  #LATIN CAPITAL LETTER X
+0x59   0x0059  #LATIN CAPITAL LETTER Y
+0x5A   0x005A  #LATIN CAPITAL LETTER Z
+0x5B   0x005B  #LEFT SQUARE BRACKET
+0x5C   0x005C  #REVERSE SOLIDUS
+0x5D   0x005D  #RIGHT SQUARE BRACKET
+0x5E   0x005E  #CIRCUMFLEX ACCENT
+0x5F   0x005F  #LOW LINE
+0x60   0x0060  #GRAVE ACCENT
+0x61   0x0061  #LATIN SMALL LETTER A
+0x62   0x0062  #LATIN SMALL LETTER B
+0x63   0x0063  #LATIN SMALL LETTER C
+0x64   0x0064  #LATIN SMALL LETTER D
+0x65   0x0065  #LATIN SMALL LETTER E
+0x66   0x0066  #LATIN SMALL LETTER F
+0x67   0x0067  #LATIN SMALL LETTER G
+0x68   0x0068  #LATIN SMALL LETTER H
+0x69   0x0069  #LATIN SMALL LETTER I
+0x6A   0x006A  #LATIN SMALL LETTER J
+0x6B   0x006B  #LATIN SMALL LETTER K
+0x6C   0x006C  #LATIN SMALL LETTER L
+0x6D   0x006D  #LATIN SMALL LETTER M
+0x6E   0x006E  #LATIN SMALL LETTER N
+0x6F   0x006F  #LATIN SMALL LETTER O
+0x70   0x0070  #LATIN SMALL LETTER P
+0x71   0x0071  #LATIN SMALL LETTER Q
+0x72   0x0072  #LATIN SMALL LETTER R
+0x73   0x0073  #LATIN SMALL LETTER S
+0x74   0x0074  #LATIN SMALL LETTER T
+0x75   0x0075  #LATIN SMALL LETTER U
+0x76   0x0076  #LATIN SMALL LETTER V
+0x77   0x0077  #LATIN SMALL LETTER W
+0x78   0x0078  #LATIN SMALL LETTER X
+0x79   0x0079  #LATIN SMALL LETTER Y
+0x7A   0x007A  #LATIN SMALL LETTER Z
+0x7B   0x007B  #LEFT CURLY BRACKET
+0x7C   0x007C  #VERTICAL LINE
+0x7D   0x007D  #RIGHT CURLY BRACKET
+0x7E   0x007E  #TILDE
+0x7F   0x007F  #DELETE
+0x80   0x20AC  #EURO SIGN
+0x81           #UNDEFINED
+0x82   0x201A  #SINGLE LOW-9 QUOTATION MARK
+0x83   0x0192  #LATIN SMALL LETTER F WITH HOOK
+0x84   0x201E  #DOUBLE LOW-9 QUOTATION MARK
+0x85   0x2026  #HORIZONTAL ELLIPSIS
+0x86   0x2020  #DAGGER
+0x87   0x2021  #DOUBLE DAGGER
+0x88           #UNDEFINED
+0x89   0x2030  #PER MILLE SIGN
+0x8A           #UNDEFINED
+0x8B   0x2039  #SINGLE LEFT-POINTING ANGLE QUOTATION MARK
+0x8C           #UNDEFINED
+0x8D           #UNDEFINED
+0x8E           #UNDEFINED
+0x8F           #UNDEFINED
+0x90           #UNDEFINED
+0x91   0x2018  #LEFT SINGLE QUOTATION MARK
+0x92   0x2019  #RIGHT SINGLE QUOTATION MARK
+0x93   0x201C  #LEFT DOUBLE QUOTATION MARK
+0x94   0x201D  #RIGHT DOUBLE QUOTATION MARK
+0x95   0x2022  #BULLET
+0x96   0x2013  #EN DASH
+0x97   0x2014  #EM DASH
+0x98           #UNDEFINED
+0x99   0x2122  #TRADE MARK SIGN
+0x9A           #UNDEFINED
+0x9B   0x203A  #SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
+0x9C           #UNDEFINED
+0x9D           #UNDEFINED
+0x9E           #UNDEFINED
+0x9F           #UNDEFINED
+0xA0   0x00A0  #NO-BREAK SPACE
+0xA1   0x0385  #GREEK DIALYTIKA TONOS
+0xA2   0x0386  #GREEK CAPITAL LETTER ALPHA WITH TONOS
+0xA3   0x00A3  #POUND SIGN
+0xA4   0x00A4  #CURRENCY SIGN
+0xA5   0x00A5  #YEN SIGN
+0xA6   0x00A6  #BROKEN BAR
+0xA7   0x00A7  #SECTION SIGN
+0xA8   0x00A8  #DIAERESIS
+0xA9   0x00A9  #COPYRIGHT SIGN
+0xAA           #UNDEFINED
+0xAB   0x00AB  #LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+0xAC   0x00AC  #NOT SIGN
+0xAD   0x00AD  #SOFT HYPHEN
+0xAE   0x00AE  #REGISTERED SIGN
+0xAF   0x2015  #HORIZONTAL BAR
+0xB0   0x00B0  #DEGREE SIGN
+0xB1   0x00B1  #PLUS-MINUS SIGN
+0xB2   0x00B2  #SUPERSCRIPT TWO
+0xB3   0x00B3  #SUPERSCRIPT THREE
+0xB4   0x0384  #GREEK TONOS
+0xB5   0x00B5  #MICRO SIGN
+0xB6   0x00B6  #PILCROW SIGN
+0xB7   0x00B7  #MIDDLE DOT
+0xB8   0x0388  #GREEK CAPITAL LETTER EPSILON WITH TONOS
+0xB9   0x0389  #GREEK CAPITAL LETTER ETA WITH TONOS
+0xBA   0x038A  #GREEK CAPITAL LETTER IOTA WITH TONOS
+0xBB   0x00BB  #RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
+0xBC   0x038C  #GREEK CAPITAL LETTER OMICRON WITH TONOS
+0xBD   0x00BD  #VULGAR FRACTION ONE HALF
+0xBE   0x038E  #GREEK CAPITAL LETTER UPSILON WITH TONOS
+0xBF   0x038F  #GREEK CAPITAL LETTER OMEGA WITH TONOS
+0xC0   0x0390  #GREEK SMALL LETTER IOTA WITH DIALYTIKA AND TONOS
+0xC1   0x0391  #GREEK CAPITAL LETTER ALPHA
+0xC2   0x0392  #GREEK CAPITAL LETTER BETA
+0xC3   0x0393  #GREEK CAPITAL LETTER GAMMA
+0xC4   0x0394  #GREEK CAPITAL LETTER DELTA
+0xC5   0x0395  #GREEK CAPITAL LETTER EPSILON
+0xC6   0x0396  #GREEK CAPITAL LETTER ZETA
+0xC7   0x0397  #GREEK CAPITAL LETTER ETA
+0xC8   0x0398  #GREEK CAPITAL LETTER THETA
+0xC9   0x0399  #GREEK CAPITAL LETTER IOTA
+0xCA   0x039A  #GREEK CAPITAL LETTER KAPPA
+0xCB   0x039B  #GREEK CAPITAL LETTER LAMDA
+0xCC   0x039C  #GREEK CAPITAL LETTER MU
+0xCD   0x039D  #GREEK CAPITAL LETTER NU
+0xCE   0x039E  #GREEK CAPITAL LETTER XI
+0xCF   0x039F  #GREEK CAPITAL LETTER OMICRON
+0xD0   0x03A0  #GREEK CAPITAL LETTER PI
+0xD1   0x03A1  #GREEK CAPITAL LETTER RHO
+0xD2           #UNDEFINED
+0xD3   0x03A3  #GREEK CAPITAL LETTER SIGMA
+0xD4   0x03A4  #GREEK CAPITAL LETTER TAU
+0xD5   0x03A5  #GREEK CAPITAL LETTER UPSILON
+0xD6   0x03A6  #GREEK CAPITAL LETTER PHI
+0xD7   0x03A7  #GREEK CAPITAL LETTER CHI
+0xD8   0x03A8  #GREEK CAPITAL LETTER PSI
+0xD9   0x03A9  #GREEK CAPITAL LETTER OMEGA
+0xDA   0x03AA  #GREEK CAPITAL LETTER IOTA WITH DIALYTIKA
+0xDB   0x03AB  #GREEK CAPITAL LETTER UPSILON WITH DIALYTIKA
+0xDC   0x03AC  #GREEK SMALL LETTER ALPHA WITH TONOS
+0xDD   0x03AD  #GREEK SMALL LETTER EPSILON WITH TONOS
+0xDE   0x03AE  #GREEK SMALL LETTER ETA WITH TONOS
+0xDF   0x03AF  #GREEK SMALL LETTER IOTA WITH TONOS
+0xE0   0x03B0  #GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND TONOS
+0xE1   0x03B1  #GREEK SMALL LETTER ALPHA
+0xE2   0x03B2  #GREEK SMALL LETTER BETA
+0xE3   0x03B3  #GREEK SMALL LETTER GAMMA
+0xE4   0x03B4  #GREEK SMALL LETTER DELTA
+0xE5   0x03B5  #GREEK SMALL LETTER EPSILON
+0xE6   0x03B6  #GREEK SMALL LETTER ZETA
+0xE7   0x03B7  #GREEK SMALL LETTER ETA
+0xE8   0x03B8  #GREEK SMALL LETTER THETA
+0xE9   0x03B9  #GREEK SMALL LETTER IOTA
+0xEA   0x03BA  #GREEK SMALL LETTER KAPPA
+0xEB   0x03BB  #GREEK SMALL LETTER LAMDA
+0xEC   0x03BC  #GREEK SMALL LETTER MU
+0xED   0x03BD  #GREEK SMALL LETTER NU
+0xEE   0x03BE  #GREEK SMALL LETTER XI
+0xEF   0x03BF  #GREEK SMALL LETTER OMICRON
+0xF0   0x03C0  #GREEK SMALL LETTER PI
+0xF1   0x03C1  #GREEK SMALL LETTER RHO
+0xF2   0x03C2  #GREEK SMALL LETTER FINAL SIGMA
+0xF3   0x03C3  #GREEK SMALL LETTER SIGMA
+0xF4   0x03C4  #GREEK SMALL LETTER TAU
+0xF5   0x03C5  #GREEK SMALL LETTER UPSILON
+0xF6   0x03C6  #GREEK SMALL LETTER PHI
+0xF7   0x03C7  #GREEK SMALL LETTER CHI
+0xF8   0x03C8  #GREEK SMALL LETTER PSI
+0xF9   0x03C9  #GREEK SMALL LETTER OMEGA
+0xFA   0x03CA  #GREEK SMALL LETTER IOTA WITH DIALYTIKA
+0xFB   0x03CB  #GREEK SMALL LETTER UPSILON WITH DIALYTIKA
+0xFC   0x03CC  #GREEK SMALL LETTER OMICRON WITH TONOS
+0xFD   0x03CD  #GREEK SMALL LETTER UPSILON WITH TONOS
+0xFE   0x03CE  #GREEK SMALL LETTER OMEGA WITH TONOS
+0xFF           #UNDEFINED
diff --git a/basis/io/encodings/8-bit/CP1254.TXT b/basis/io/encodings/8-bit/CP1254.TXT
new file mode 100644 (file)
index 0000000..987ed98
--- /dev/null
@@ -0,0 +1,274 @@
+#
+#    Name:     cp1254 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 cp1254 code (in hex)
+#        Column #2 is the Unicode (in hex as 0xXXXX)
+#        Column #3 is the Unicode name (follows a comment sign, '#')
+#
+#    The entries are in cp1254 order
+#
+0x00   0x0000  #NULL
+0x01   0x0001  #START OF HEADING
+0x02   0x0002  #START OF TEXT
+0x03   0x0003  #END OF TEXT
+0x04   0x0004  #END OF TRANSMISSION
+0x05   0x0005  #ENQUIRY
+0x06   0x0006  #ACKNOWLEDGE
+0x07   0x0007  #BELL
+0x08   0x0008  #BACKSPACE
+0x09   0x0009  #HORIZONTAL TABULATION
+0x0A   0x000A  #LINE FEED
+0x0B   0x000B  #VERTICAL TABULATION
+0x0C   0x000C  #FORM FEED
+0x0D   0x000D  #CARRIAGE RETURN
+0x0E   0x000E  #SHIFT OUT
+0x0F   0x000F  #SHIFT IN
+0x10   0x0010  #DATA LINK ESCAPE
+0x11   0x0011  #DEVICE CONTROL ONE
+0x12   0x0012  #DEVICE CONTROL TWO
+0x13   0x0013  #DEVICE CONTROL THREE
+0x14   0x0014  #DEVICE CONTROL FOUR
+0x15   0x0015  #NEGATIVE ACKNOWLEDGE
+0x16   0x0016  #SYNCHRONOUS IDLE
+0x17   0x0017  #END OF TRANSMISSION BLOCK
+0x18   0x0018  #CANCEL
+0x19   0x0019  #END OF MEDIUM
+0x1A   0x001A  #SUBSTITUTE
+0x1B   0x001B  #ESCAPE
+0x1C   0x001C  #FILE SEPARATOR
+0x1D   0x001D  #GROUP SEPARATOR
+0x1E   0x001E  #RECORD SEPARATOR
+0x1F   0x001F  #UNIT SEPARATOR
+0x20   0x0020  #SPACE
+0x21   0x0021  #EXCLAMATION MARK
+0x22   0x0022  #QUOTATION MARK
+0x23   0x0023  #NUMBER SIGN
+0x24   0x0024  #DOLLAR SIGN
+0x25   0x0025  #PERCENT SIGN
+0x26   0x0026  #AMPERSAND
+0x27   0x0027  #APOSTROPHE
+0x28   0x0028  #LEFT PARENTHESIS
+0x29   0x0029  #RIGHT PARENTHESIS
+0x2A   0x002A  #ASTERISK
+0x2B   0x002B  #PLUS SIGN
+0x2C   0x002C  #COMMA
+0x2D   0x002D  #HYPHEN-MINUS
+0x2E   0x002E  #FULL STOP
+0x2F   0x002F  #SOLIDUS
+0x30   0x0030  #DIGIT ZERO
+0x31   0x0031  #DIGIT ONE
+0x32   0x0032  #DIGIT TWO
+0x33   0x0033  #DIGIT THREE
+0x34   0x0034  #DIGIT FOUR
+0x35   0x0035  #DIGIT FIVE
+0x36   0x0036  #DIGIT SIX
+0x37   0x0037  #DIGIT SEVEN
+0x38   0x0038  #DIGIT EIGHT
+0x39   0x0039  #DIGIT NINE
+0x3A   0x003A  #COLON
+0x3B   0x003B  #SEMICOLON
+0x3C   0x003C  #LESS-THAN SIGN
+0x3D   0x003D  #EQUALS SIGN
+0x3E   0x003E  #GREATER-THAN SIGN
+0x3F   0x003F  #QUESTION MARK
+0x40   0x0040  #COMMERCIAL AT
+0x41   0x0041  #LATIN CAPITAL LETTER A
+0x42   0x0042  #LATIN CAPITAL LETTER B
+0x43   0x0043  #LATIN CAPITAL LETTER C
+0x44   0x0044  #LATIN CAPITAL LETTER D
+0x45   0x0045  #LATIN CAPITAL LETTER E
+0x46   0x0046  #LATIN CAPITAL LETTER F
+0x47   0x0047  #LATIN CAPITAL LETTER G
+0x48   0x0048  #LATIN CAPITAL LETTER H
+0x49   0x0049  #LATIN CAPITAL LETTER I
+0x4A   0x004A  #LATIN CAPITAL LETTER J
+0x4B   0x004B  #LATIN CAPITAL LETTER K
+0x4C   0x004C  #LATIN CAPITAL LETTER L
+0x4D   0x004D  #LATIN CAPITAL LETTER M
+0x4E   0x004E  #LATIN CAPITAL LETTER N
+0x4F   0x004F  #LATIN CAPITAL LETTER O
+0x50   0x0050  #LATIN CAPITAL LETTER P
+0x51   0x0051  #LATIN CAPITAL LETTER Q
+0x52   0x0052  #LATIN CAPITAL LETTER R
+0x53   0x0053  #LATIN CAPITAL LETTER S
+0x54   0x0054  #LATIN CAPITAL LETTER T
+0x55   0x0055  #LATIN CAPITAL LETTER U
+0x56   0x0056  #LATIN CAPITAL LETTER V
+0x57   0x0057  #LATIN CAPITAL LETTER W
+0x58   0x0058  #LATIN CAPITAL LETTER X
+0x59   0x0059  #LATIN CAPITAL LETTER Y
+0x5A   0x005A  #LATIN CAPITAL LETTER Z
+0x5B   0x005B  #LEFT SQUARE BRACKET
+0x5C   0x005C  #REVERSE SOLIDUS
+0x5D   0x005D  #RIGHT SQUARE BRACKET
+0x5E   0x005E  #CIRCUMFLEX ACCENT
+0x5F   0x005F  #LOW LINE
+0x60   0x0060  #GRAVE ACCENT
+0x61   0x0061  #LATIN SMALL LETTER A
+0x62   0x0062  #LATIN SMALL LETTER B
+0x63   0x0063  #LATIN SMALL LETTER C
+0x64   0x0064  #LATIN SMALL LETTER D
+0x65   0x0065  #LATIN SMALL LETTER E
+0x66   0x0066  #LATIN SMALL LETTER F
+0x67   0x0067  #LATIN SMALL LETTER G
+0x68   0x0068  #LATIN SMALL LETTER H
+0x69   0x0069  #LATIN SMALL LETTER I
+0x6A   0x006A  #LATIN SMALL LETTER J
+0x6B   0x006B  #LATIN SMALL LETTER K
+0x6C   0x006C  #LATIN SMALL LETTER L
+0x6D   0x006D  #LATIN SMALL LETTER M
+0x6E   0x006E  #LATIN SMALL LETTER N
+0x6F   0x006F  #LATIN SMALL LETTER O
+0x70   0x0070  #LATIN SMALL LETTER P
+0x71   0x0071  #LATIN SMALL LETTER Q
+0x72   0x0072  #LATIN SMALL LETTER R
+0x73   0x0073  #LATIN SMALL LETTER S
+0x74   0x0074  #LATIN SMALL LETTER T
+0x75   0x0075  #LATIN SMALL LETTER U
+0x76   0x0076  #LATIN SMALL LETTER V
+0x77   0x0077  #LATIN SMALL LETTER W
+0x78   0x0078  #LATIN SMALL LETTER X
+0x79   0x0079  #LATIN SMALL LETTER Y
+0x7A   0x007A  #LATIN SMALL LETTER Z
+0x7B   0x007B  #LEFT CURLY BRACKET
+0x7C   0x007C  #VERTICAL LINE
+0x7D   0x007D  #RIGHT CURLY BRACKET
+0x7E   0x007E  #TILDE
+0x7F   0x007F  #DELETE
+0x80   0x20AC  #EURO SIGN
+0x81           #UNDEFINED
+0x82   0x201A  #SINGLE LOW-9 QUOTATION MARK
+0x83   0x0192  #LATIN SMALL LETTER F WITH HOOK
+0x84   0x201E  #DOUBLE LOW-9 QUOTATION MARK
+0x85   0x2026  #HORIZONTAL ELLIPSIS
+0x86   0x2020  #DAGGER
+0x87   0x2021  #DOUBLE DAGGER
+0x88   0x02C6  #MODIFIER LETTER CIRCUMFLEX ACCENT
+0x89   0x2030  #PER MILLE SIGN
+0x8A   0x0160  #LATIN CAPITAL LETTER S WITH CARON
+0x8B   0x2039  #SINGLE LEFT-POINTING ANGLE QUOTATION MARK
+0x8C   0x0152  #LATIN CAPITAL LIGATURE OE
+0x8D           #UNDEFINED
+0x8E           #UNDEFINED
+0x8F           #UNDEFINED
+0x90           #UNDEFINED
+0x91   0x2018  #LEFT SINGLE QUOTATION MARK
+0x92   0x2019  #RIGHT SINGLE QUOTATION MARK
+0x93   0x201C  #LEFT DOUBLE QUOTATION MARK
+0x94   0x201D  #RIGHT DOUBLE QUOTATION MARK
+0x95   0x2022  #BULLET
+0x96   0x2013  #EN DASH
+0x97   0x2014  #EM DASH
+0x98   0x02DC  #SMALL TILDE
+0x99   0x2122  #TRADE MARK SIGN
+0x9A   0x0161  #LATIN SMALL LETTER S WITH CARON
+0x9B   0x203A  #SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
+0x9C   0x0153  #LATIN SMALL LIGATURE OE
+0x9D           #UNDEFINED
+0x9E           #UNDEFINED
+0x9F   0x0178  #LATIN CAPITAL LETTER Y WITH DIAERESIS
+0xA0   0x00A0  #NO-BREAK SPACE
+0xA1   0x00A1  #INVERTED EXCLAMATION MARK
+0xA2   0x00A2  #CENT SIGN
+0xA3   0x00A3  #POUND SIGN
+0xA4   0x00A4  #CURRENCY SIGN
+0xA5   0x00A5  #YEN SIGN
+0xA6   0x00A6  #BROKEN BAR
+0xA7   0x00A7  #SECTION SIGN
+0xA8   0x00A8  #DIAERESIS
+0xA9   0x00A9  #COPYRIGHT SIGN
+0xAA   0x00AA  #FEMININE ORDINAL INDICATOR
+0xAB   0x00AB  #LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+0xAC   0x00AC  #NOT SIGN
+0xAD   0x00AD  #SOFT HYPHEN
+0xAE   0x00AE  #REGISTERED SIGN
+0xAF   0x00AF  #MACRON
+0xB0   0x00B0  #DEGREE SIGN
+0xB1   0x00B1  #PLUS-MINUS SIGN
+0xB2   0x00B2  #SUPERSCRIPT TWO
+0xB3   0x00B3  #SUPERSCRIPT THREE
+0xB4   0x00B4  #ACUTE ACCENT
+0xB5   0x00B5  #MICRO SIGN
+0xB6   0x00B6  #PILCROW SIGN
+0xB7   0x00B7  #MIDDLE DOT
+0xB8   0x00B8  #CEDILLA
+0xB9   0x00B9  #SUPERSCRIPT ONE
+0xBA   0x00BA  #MASCULINE ORDINAL INDICATOR
+0xBB   0x00BB  #RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
+0xBC   0x00BC  #VULGAR FRACTION ONE QUARTER
+0xBD   0x00BD  #VULGAR FRACTION ONE HALF
+0xBE   0x00BE  #VULGAR FRACTION THREE QUARTERS
+0xBF   0x00BF  #INVERTED QUESTION MARK
+0xC0   0x00C0  #LATIN CAPITAL LETTER A WITH GRAVE
+0xC1   0x00C1  #LATIN CAPITAL LETTER A WITH ACUTE
+0xC2   0x00C2  #LATIN CAPITAL LETTER A WITH CIRCUMFLEX
+0xC3   0x00C3  #LATIN CAPITAL LETTER A WITH TILDE
+0xC4   0x00C4  #LATIN CAPITAL LETTER A WITH DIAERESIS
+0xC5   0x00C5  #LATIN CAPITAL LETTER A WITH RING ABOVE
+0xC6   0x00C6  #LATIN CAPITAL LETTER AE
+0xC7   0x00C7  #LATIN CAPITAL LETTER C WITH CEDILLA
+0xC8   0x00C8  #LATIN CAPITAL LETTER E WITH GRAVE
+0xC9   0x00C9  #LATIN CAPITAL LETTER E WITH ACUTE
+0xCA   0x00CA  #LATIN CAPITAL LETTER E WITH CIRCUMFLEX
+0xCB   0x00CB  #LATIN CAPITAL LETTER E WITH DIAERESIS
+0xCC   0x00CC  #LATIN CAPITAL LETTER I WITH GRAVE
+0xCD   0x00CD  #LATIN CAPITAL LETTER I WITH ACUTE
+0xCE   0x00CE  #LATIN CAPITAL LETTER I WITH CIRCUMFLEX
+0xCF   0x00CF  #LATIN CAPITAL LETTER I WITH DIAERESIS
+0xD0   0x011E  #LATIN CAPITAL LETTER G WITH BREVE
+0xD1   0x00D1  #LATIN CAPITAL LETTER N WITH TILDE
+0xD2   0x00D2  #LATIN CAPITAL LETTER O WITH GRAVE
+0xD3   0x00D3  #LATIN CAPITAL LETTER O WITH ACUTE
+0xD4   0x00D4  #LATIN CAPITAL LETTER O WITH CIRCUMFLEX
+0xD5   0x00D5  #LATIN CAPITAL LETTER O WITH TILDE
+0xD6   0x00D6  #LATIN CAPITAL LETTER O WITH DIAERESIS
+0xD7   0x00D7  #MULTIPLICATION SIGN
+0xD8   0x00D8  #LATIN CAPITAL LETTER O WITH STROKE
+0xD9   0x00D9  #LATIN CAPITAL LETTER U WITH GRAVE
+0xDA   0x00DA  #LATIN CAPITAL LETTER U WITH ACUTE
+0xDB   0x00DB  #LATIN CAPITAL LETTER U WITH CIRCUMFLEX
+0xDC   0x00DC  #LATIN CAPITAL LETTER U WITH DIAERESIS
+0xDD   0x0130  #LATIN CAPITAL LETTER I WITH DOT ABOVE
+0xDE   0x015E  #LATIN CAPITAL LETTER S WITH CEDILLA
+0xDF   0x00DF  #LATIN SMALL LETTER SHARP S
+0xE0   0x00E0  #LATIN SMALL LETTER A WITH GRAVE
+0xE1   0x00E1  #LATIN SMALL LETTER A WITH ACUTE
+0xE2   0x00E2  #LATIN SMALL LETTER A WITH CIRCUMFLEX
+0xE3   0x00E3  #LATIN SMALL LETTER A WITH TILDE
+0xE4   0x00E4  #LATIN SMALL LETTER A WITH DIAERESIS
+0xE5   0x00E5  #LATIN SMALL LETTER A WITH RING ABOVE
+0xE6   0x00E6  #LATIN SMALL LETTER AE
+0xE7   0x00E7  #LATIN SMALL LETTER C WITH CEDILLA
+0xE8   0x00E8  #LATIN SMALL LETTER E WITH GRAVE
+0xE9   0x00E9  #LATIN SMALL LETTER E WITH ACUTE
+0xEA   0x00EA  #LATIN SMALL LETTER E WITH CIRCUMFLEX
+0xEB   0x00EB  #LATIN SMALL LETTER E WITH DIAERESIS
+0xEC   0x00EC  #LATIN SMALL LETTER I WITH GRAVE
+0xED   0x00ED  #LATIN SMALL LETTER I WITH ACUTE
+0xEE   0x00EE  #LATIN SMALL LETTER I WITH CIRCUMFLEX
+0xEF   0x00EF  #LATIN SMALL LETTER I WITH DIAERESIS
+0xF0   0x011F  #LATIN SMALL LETTER G WITH BREVE
+0xF1   0x00F1  #LATIN SMALL LETTER N WITH TILDE
+0xF2   0x00F2  #LATIN SMALL LETTER O WITH GRAVE
+0xF3   0x00F3  #LATIN SMALL LETTER O WITH ACUTE
+0xF4   0x00F4  #LATIN SMALL LETTER O WITH CIRCUMFLEX
+0xF5   0x00F5  #LATIN SMALL LETTER O WITH TILDE
+0xF6   0x00F6  #LATIN SMALL LETTER O WITH DIAERESIS
+0xF7   0x00F7  #DIVISION SIGN
+0xF8   0x00F8  #LATIN SMALL LETTER O WITH STROKE
+0xF9   0x00F9  #LATIN SMALL LETTER U WITH GRAVE
+0xFA   0x00FA  #LATIN SMALL LETTER U WITH ACUTE
+0xFB   0x00FB  #LATIN SMALL LETTER U WITH CIRCUMFLEX
+0xFC   0x00FC  #LATIN SMALL LETTER U WITH DIAERESIS
+0xFD   0x0131  #LATIN SMALL LETTER DOTLESS I
+0xFE   0x015F  #LATIN SMALL LETTER S WITH CEDILLA
+0xFF   0x00FF  #LATIN SMALL LETTER Y WITH DIAERESIS
diff --git a/basis/io/encodings/8-bit/CP1255.TXT b/basis/io/encodings/8-bit/CP1255.TXT
new file mode 100644 (file)
index 0000000..585f993
--- /dev/null
@@ -0,0 +1,274 @@
+#
+#    Name:     cp1255 to Unicode table
+#    Unicode version: 2.0
+#    Table version: 2.01
+#    Table format:  Format A
+#    Date:          1/7/2000
+#
+#    Contact:       Shawn.Steele@microsoft.com
+#
+#    General notes: none
+#
+#    Format: Three tab-separated columns
+#        Column #1 is the cp1255 code (in hex)
+#        Column #2 is the Unicode (in hex as 0xXXXX)
+#        Column #3 is the Unicode name (follows a comment sign, '#')
+#
+#    The entries are in cp1255 order
+#
+0x00   0x0000  #NULL
+0x01   0x0001  #START OF HEADING
+0x02   0x0002  #START OF TEXT
+0x03   0x0003  #END OF TEXT
+0x04   0x0004  #END OF TRANSMISSION
+0x05   0x0005  #ENQUIRY
+0x06   0x0006  #ACKNOWLEDGE
+0x07   0x0007  #BELL
+0x08   0x0008  #BACKSPACE
+0x09   0x0009  #HORIZONTAL TABULATION
+0x0A   0x000A  #LINE FEED
+0x0B   0x000B  #VERTICAL TABULATION
+0x0C   0x000C  #FORM FEED
+0x0D   0x000D  #CARRIAGE RETURN
+0x0E   0x000E  #SHIFT OUT
+0x0F   0x000F  #SHIFT IN
+0x10   0x0010  #DATA LINK ESCAPE
+0x11   0x0011  #DEVICE CONTROL ONE
+0x12   0x0012  #DEVICE CONTROL TWO
+0x13   0x0013  #DEVICE CONTROL THREE
+0x14   0x0014  #DEVICE CONTROL FOUR
+0x15   0x0015  #NEGATIVE ACKNOWLEDGE
+0x16   0x0016  #SYNCHRONOUS IDLE
+0x17   0x0017  #END OF TRANSMISSION BLOCK
+0x18   0x0018  #CANCEL
+0x19   0x0019  #END OF MEDIUM
+0x1A   0x001A  #SUBSTITUTE
+0x1B   0x001B  #ESCAPE
+0x1C   0x001C  #FILE SEPARATOR
+0x1D   0x001D  #GROUP SEPARATOR
+0x1E   0x001E  #RECORD SEPARATOR
+0x1F   0x001F  #UNIT SEPARATOR
+0x20   0x0020  #SPACE
+0x21   0x0021  #EXCLAMATION MARK
+0x22   0x0022  #QUOTATION MARK
+0x23   0x0023  #NUMBER SIGN
+0x24   0x0024  #DOLLAR SIGN
+0x25   0x0025  #PERCENT SIGN
+0x26   0x0026  #AMPERSAND
+0x27   0x0027  #APOSTROPHE
+0x28   0x0028  #LEFT PARENTHESIS
+0x29   0x0029  #RIGHT PARENTHESIS
+0x2A   0x002A  #ASTERISK
+0x2B   0x002B  #PLUS SIGN
+0x2C   0x002C  #COMMA
+0x2D   0x002D  #HYPHEN-MINUS
+0x2E   0x002E  #FULL STOP
+0x2F   0x002F  #SOLIDUS
+0x30   0x0030  #DIGIT ZERO
+0x31   0x0031  #DIGIT ONE
+0x32   0x0032  #DIGIT TWO
+0x33   0x0033  #DIGIT THREE
+0x34   0x0034  #DIGIT FOUR
+0x35   0x0035  #DIGIT FIVE
+0x36   0x0036  #DIGIT SIX
+0x37   0x0037  #DIGIT SEVEN
+0x38   0x0038  #DIGIT EIGHT
+0x39   0x0039  #DIGIT NINE
+0x3A   0x003A  #COLON
+0x3B   0x003B  #SEMICOLON
+0x3C   0x003C  #LESS-THAN SIGN
+0x3D   0x003D  #EQUALS SIGN
+0x3E   0x003E  #GREATER-THAN SIGN
+0x3F   0x003F  #QUESTION MARK
+0x40   0x0040  #COMMERCIAL AT
+0x41   0x0041  #LATIN CAPITAL LETTER A
+0x42   0x0042  #LATIN CAPITAL LETTER B
+0x43   0x0043  #LATIN CAPITAL LETTER C
+0x44   0x0044  #LATIN CAPITAL LETTER D
+0x45   0x0045  #LATIN CAPITAL LETTER E
+0x46   0x0046  #LATIN CAPITAL LETTER F
+0x47   0x0047  #LATIN CAPITAL LETTER G
+0x48   0x0048  #LATIN CAPITAL LETTER H
+0x49   0x0049  #LATIN CAPITAL LETTER I
+0x4A   0x004A  #LATIN CAPITAL LETTER J
+0x4B   0x004B  #LATIN CAPITAL LETTER K
+0x4C   0x004C  #LATIN CAPITAL LETTER L
+0x4D   0x004D  #LATIN CAPITAL LETTER M
+0x4E   0x004E  #LATIN CAPITAL LETTER N
+0x4F   0x004F  #LATIN CAPITAL LETTER O
+0x50   0x0050  #LATIN CAPITAL LETTER P
+0x51   0x0051  #LATIN CAPITAL LETTER Q
+0x52   0x0052  #LATIN CAPITAL LETTER R
+0x53   0x0053  #LATIN CAPITAL LETTER S
+0x54   0x0054  #LATIN CAPITAL LETTER T
+0x55   0x0055  #LATIN CAPITAL LETTER U
+0x56   0x0056  #LATIN CAPITAL LETTER V
+0x57   0x0057  #LATIN CAPITAL LETTER W
+0x58   0x0058  #LATIN CAPITAL LETTER X
+0x59   0x0059  #LATIN CAPITAL LETTER Y
+0x5A   0x005A  #LATIN CAPITAL LETTER Z
+0x5B   0x005B  #LEFT SQUARE BRACKET
+0x5C   0x005C  #REVERSE SOLIDUS
+0x5D   0x005D  #RIGHT SQUARE BRACKET
+0x5E   0x005E  #CIRCUMFLEX ACCENT
+0x5F   0x005F  #LOW LINE
+0x60   0x0060  #GRAVE ACCENT
+0x61   0x0061  #LATIN SMALL LETTER A
+0x62   0x0062  #LATIN SMALL LETTER B
+0x63   0x0063  #LATIN SMALL LETTER C
+0x64   0x0064  #LATIN SMALL LETTER D
+0x65   0x0065  #LATIN SMALL LETTER E
+0x66   0x0066  #LATIN SMALL LETTER F
+0x67   0x0067  #LATIN SMALL LETTER G
+0x68   0x0068  #LATIN SMALL LETTER H
+0x69   0x0069  #LATIN SMALL LETTER I
+0x6A   0x006A  #LATIN SMALL LETTER J
+0x6B   0x006B  #LATIN SMALL LETTER K
+0x6C   0x006C  #LATIN SMALL LETTER L
+0x6D   0x006D  #LATIN SMALL LETTER M
+0x6E   0x006E  #LATIN SMALL LETTER N
+0x6F   0x006F  #LATIN SMALL LETTER O
+0x70   0x0070  #LATIN SMALL LETTER P
+0x71   0x0071  #LATIN SMALL LETTER Q
+0x72   0x0072  #LATIN SMALL LETTER R
+0x73   0x0073  #LATIN SMALL LETTER S
+0x74   0x0074  #LATIN SMALL LETTER T
+0x75   0x0075  #LATIN SMALL LETTER U
+0x76   0x0076  #LATIN SMALL LETTER V
+0x77   0x0077  #LATIN SMALL LETTER W
+0x78   0x0078  #LATIN SMALL LETTER X
+0x79   0x0079  #LATIN SMALL LETTER Y
+0x7A   0x007A  #LATIN SMALL LETTER Z
+0x7B   0x007B  #LEFT CURLY BRACKET
+0x7C   0x007C  #VERTICAL LINE
+0x7D   0x007D  #RIGHT CURLY BRACKET
+0x7E   0x007E  #TILDE
+0x7F   0x007F  #DELETE
+0x80   0x20AC  #EURO SIGN
+0x81           #UNDEFINED
+0x82   0x201A  #SINGLE LOW-9 QUOTATION MARK
+0x83   0x0192  #LATIN SMALL LETTER F WITH HOOK
+0x84   0x201E  #DOUBLE LOW-9 QUOTATION MARK
+0x85   0x2026  #HORIZONTAL ELLIPSIS
+0x86   0x2020  #DAGGER
+0x87   0x2021  #DOUBLE DAGGER
+0x88   0x02C6  #MODIFIER LETTER CIRCUMFLEX ACCENT
+0x89   0x2030  #PER MILLE SIGN
+0x8A           #UNDEFINED
+0x8B   0x2039  #SINGLE LEFT-POINTING ANGLE QUOTATION MARK
+0x8C           #UNDEFINED
+0x8D           #UNDEFINED
+0x8E           #UNDEFINED
+0x8F           #UNDEFINED
+0x90           #UNDEFINED
+0x91   0x2018  #LEFT SINGLE QUOTATION MARK
+0x92   0x2019  #RIGHT SINGLE QUOTATION MARK
+0x93   0x201C  #LEFT DOUBLE QUOTATION MARK
+0x94   0x201D  #RIGHT DOUBLE QUOTATION MARK
+0x95   0x2022  #BULLET
+0x96   0x2013  #EN DASH
+0x97   0x2014  #EM DASH
+0x98   0x02DC  #SMALL TILDE
+0x99   0x2122  #TRADE MARK SIGN
+0x9A           #UNDEFINED
+0x9B   0x203A  #SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
+0x9C           #UNDEFINED
+0x9D           #UNDEFINED
+0x9E           #UNDEFINED
+0x9F           #UNDEFINED
+0xA0   0x00A0  #NO-BREAK SPACE
+0xA1   0x00A1  #INVERTED EXCLAMATION MARK
+0xA2   0x00A2  #CENT SIGN
+0xA3   0x00A3  #POUND SIGN
+0xA4   0x20AA  #NEW SHEQEL SIGN
+0xA5   0x00A5  #YEN SIGN
+0xA6   0x00A6  #BROKEN BAR
+0xA7   0x00A7  #SECTION SIGN
+0xA8   0x00A8  #DIAERESIS
+0xA9   0x00A9  #COPYRIGHT SIGN
+0xAA   0x00D7  #MULTIPLICATION SIGN
+0xAB   0x00AB  #LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+0xAC   0x00AC  #NOT SIGN
+0xAD   0x00AD  #SOFT HYPHEN
+0xAE   0x00AE  #REGISTERED SIGN
+0xAF   0x00AF  #MACRON
+0xB0   0x00B0  #DEGREE SIGN
+0xB1   0x00B1  #PLUS-MINUS SIGN
+0xB2   0x00B2  #SUPERSCRIPT TWO
+0xB3   0x00B3  #SUPERSCRIPT THREE
+0xB4   0x00B4  #ACUTE ACCENT
+0xB5   0x00B5  #MICRO SIGN
+0xB6   0x00B6  #PILCROW SIGN
+0xB7   0x00B7  #MIDDLE DOT
+0xB8   0x00B8  #CEDILLA
+0xB9   0x00B9  #SUPERSCRIPT ONE
+0xBA   0x00F7  #DIVISION SIGN
+0xBB   0x00BB  #RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
+0xBC   0x00BC  #VULGAR FRACTION ONE QUARTER
+0xBD   0x00BD  #VULGAR FRACTION ONE HALF
+0xBE   0x00BE  #VULGAR FRACTION THREE QUARTERS
+0xBF   0x00BF  #INVERTED QUESTION MARK
+0xC0   0x05B0  #HEBREW POINT SHEVA
+0xC1   0x05B1  #HEBREW POINT HATAF SEGOL
+0xC2   0x05B2  #HEBREW POINT HATAF PATAH
+0xC3   0x05B3  #HEBREW POINT HATAF QAMATS
+0xC4   0x05B4  #HEBREW POINT HIRIQ
+0xC5   0x05B5  #HEBREW POINT TSERE
+0xC6   0x05B6  #HEBREW POINT SEGOL
+0xC7   0x05B7  #HEBREW POINT PATAH
+0xC8   0x05B8  #HEBREW POINT QAMATS
+0xC9   0x05B9  #HEBREW POINT HOLAM
+0xCA           #UNDEFINED
+0xCB   0x05BB  #HEBREW POINT QUBUTS
+0xCC   0x05BC  #HEBREW POINT DAGESH OR MAPIQ
+0xCD   0x05BD  #HEBREW POINT METEG
+0xCE   0x05BE  #HEBREW PUNCTUATION MAQAF
+0xCF   0x05BF  #HEBREW POINT RAFE
+0xD0   0x05C0  #HEBREW PUNCTUATION PASEQ
+0xD1   0x05C1  #HEBREW POINT SHIN DOT
+0xD2   0x05C2  #HEBREW POINT SIN DOT
+0xD3   0x05C3  #HEBREW PUNCTUATION SOF PASUQ
+0xD4   0x05F0  #HEBREW LIGATURE YIDDISH DOUBLE VAV
+0xD5   0x05F1  #HEBREW LIGATURE YIDDISH VAV YOD
+0xD6   0x05F2  #HEBREW LIGATURE YIDDISH DOUBLE YOD
+0xD7   0x05F3  #HEBREW PUNCTUATION GERESH
+0xD8   0x05F4  #HEBREW PUNCTUATION GERSHAYIM
+0xD9           #UNDEFINED
+0xDA           #UNDEFINED
+0xDB           #UNDEFINED
+0xDC           #UNDEFINED
+0xDD           #UNDEFINED
+0xDE           #UNDEFINED
+0xDF           #UNDEFINED
+0xE0   0x05D0  #HEBREW LETTER ALEF
+0xE1   0x05D1  #HEBREW LETTER BET
+0xE2   0x05D2  #HEBREW LETTER GIMEL
+0xE3   0x05D3  #HEBREW LETTER DALET
+0xE4   0x05D4  #HEBREW LETTER HE
+0xE5   0x05D5  #HEBREW LETTER VAV
+0xE6   0x05D6  #HEBREW LETTER ZAYIN
+0xE7   0x05D7  #HEBREW LETTER HET
+0xE8   0x05D8  #HEBREW LETTER TET
+0xE9   0x05D9  #HEBREW LETTER YOD
+0xEA   0x05DA  #HEBREW LETTER FINAL KAF
+0xEB   0x05DB  #HEBREW LETTER KAF
+0xEC   0x05DC  #HEBREW LETTER LAMED
+0xED   0x05DD  #HEBREW LETTER FINAL MEM
+0xEE   0x05DE  #HEBREW LETTER MEM
+0xEF   0x05DF  #HEBREW LETTER FINAL NUN
+0xF0   0x05E0  #HEBREW LETTER NUN
+0xF1   0x05E1  #HEBREW LETTER SAMEKH
+0xF2   0x05E2  #HEBREW LETTER AYIN
+0xF3   0x05E3  #HEBREW LETTER FINAL PE
+0xF4   0x05E4  #HEBREW LETTER PE
+0xF5   0x05E5  #HEBREW LETTER FINAL TSADI
+0xF6   0x05E6  #HEBREW LETTER TSADI
+0xF7   0x05E7  #HEBREW LETTER QOF
+0xF8   0x05E8  #HEBREW LETTER RESH
+0xF9   0x05E9  #HEBREW LETTER SHIN
+0xFA   0x05EA  #HEBREW LETTER TAV
+0xFB           #UNDEFINED
+0xFC           #UNDEFINED
+0xFD   0x200E  #LEFT-TO-RIGHT MARK
+0xFE   0x200F  #RIGHT-TO-LEFT MARK
+0xFF           #UNDEFINED
diff --git a/basis/io/encodings/8-bit/CP1256.TXT b/basis/io/encodings/8-bit/CP1256.TXT
new file mode 100644 (file)
index 0000000..244dcce
--- /dev/null
@@ -0,0 +1,274 @@
+#
+#    Name:     cp1256 to Unicode table
+#    Unicode version: 2.1
+#    Table version: 2.01
+#    Table format:  Format A
+#    Date:          01/5/99
+#
+#    Contact:       Shawn.Steele@microsoft.com
+#
+#    General notes: none
+#
+#    Format: Three tab-separated columns
+#        Column #1 is the cp1256 code (in hex)
+#        Column #2 is the Unicode (in hex as 0xXXXX)
+#        Column #3 is the Unicode name (follows a comment sign, '#')
+#
+#    The entries are in cp1256 order
+#
+0x00   0x0000  #NULL
+0x01   0x0001  #START OF HEADING
+0x02   0x0002  #START OF TEXT
+0x03   0x0003  #END OF TEXT
+0x04   0x0004  #END OF TRANSMISSION
+0x05   0x0005  #ENQUIRY
+0x06   0x0006  #ACKNOWLEDGE
+0x07   0x0007  #BELL
+0x08   0x0008  #BACKSPACE
+0x09   0x0009  #HORIZONTAL TABULATION
+0x0A   0x000A  #LINE FEED
+0x0B   0x000B  #VERTICAL TABULATION
+0x0C   0x000C  #FORM FEED
+0x0D   0x000D  #CARRIAGE RETURN
+0x0E   0x000E  #SHIFT OUT
+0x0F   0x000F  #SHIFT IN
+0x10   0x0010  #DATA LINK ESCAPE
+0x11   0x0011  #DEVICE CONTROL ONE
+0x12   0x0012  #DEVICE CONTROL TWO
+0x13   0x0013  #DEVICE CONTROL THREE
+0x14   0x0014  #DEVICE CONTROL FOUR
+0x15   0x0015  #NEGATIVE ACKNOWLEDGE
+0x16   0x0016  #SYNCHRONOUS IDLE
+0x17   0x0017  #END OF TRANSMISSION BLOCK
+0x18   0x0018  #CANCEL
+0x19   0x0019  #END OF MEDIUM
+0x1A   0x001A  #SUBSTITUTE
+0x1B   0x001B  #ESCAPE
+0x1C   0x001C  #FILE SEPARATOR
+0x1D   0x001D  #GROUP SEPARATOR
+0x1E   0x001E  #RECORD SEPARATOR
+0x1F   0x001F  #UNIT SEPARATOR
+0x20   0x0020  #SPACE
+0x21   0x0021  #EXCLAMATION MARK
+0x22   0x0022  #QUOTATION MARK
+0x23   0x0023  #NUMBER SIGN
+0x24   0x0024  #DOLLAR SIGN
+0x25   0x0025  #PERCENT SIGN
+0x26   0x0026  #AMPERSAND
+0x27   0x0027  #APOSTROPHE
+0x28   0x0028  #LEFT PARENTHESIS
+0x29   0x0029  #RIGHT PARENTHESIS
+0x2A   0x002A  #ASTERISK
+0x2B   0x002B  #PLUS SIGN
+0x2C   0x002C  #COMMA
+0x2D   0x002D  #HYPHEN-MINUS
+0x2E   0x002E  #FULL STOP
+0x2F   0x002F  #SOLIDUS
+0x30   0x0030  #DIGIT ZERO
+0x31   0x0031  #DIGIT ONE
+0x32   0x0032  #DIGIT TWO
+0x33   0x0033  #DIGIT THREE
+0x34   0x0034  #DIGIT FOUR
+0x35   0x0035  #DIGIT FIVE
+0x36   0x0036  #DIGIT SIX
+0x37   0x0037  #DIGIT SEVEN
+0x38   0x0038  #DIGIT EIGHT
+0x39   0x0039  #DIGIT NINE
+0x3A   0x003A  #COLON
+0x3B   0x003B  #SEMICOLON
+0x3C   0x003C  #LESS-THAN SIGN
+0x3D   0x003D  #EQUALS SIGN
+0x3E   0x003E  #GREATER-THAN SIGN
+0x3F   0x003F  #QUESTION MARK
+0x40   0x0040  #COMMERCIAL AT
+0x41   0x0041  #LATIN CAPITAL LETTER A
+0x42   0x0042  #LATIN CAPITAL LETTER B
+0x43   0x0043  #LATIN CAPITAL LETTER C
+0x44   0x0044  #LATIN CAPITAL LETTER D
+0x45   0x0045  #LATIN CAPITAL LETTER E
+0x46   0x0046  #LATIN CAPITAL LETTER F
+0x47   0x0047  #LATIN CAPITAL LETTER G
+0x48   0x0048  #LATIN CAPITAL LETTER H
+0x49   0x0049  #LATIN CAPITAL LETTER I
+0x4A   0x004A  #LATIN CAPITAL LETTER J
+0x4B   0x004B  #LATIN CAPITAL LETTER K
+0x4C   0x004C  #LATIN CAPITAL LETTER L
+0x4D   0x004D  #LATIN CAPITAL LETTER M
+0x4E   0x004E  #LATIN CAPITAL LETTER N
+0x4F   0x004F  #LATIN CAPITAL LETTER O
+0x50   0x0050  #LATIN CAPITAL LETTER P
+0x51   0x0051  #LATIN CAPITAL LETTER Q
+0x52   0x0052  #LATIN CAPITAL LETTER R
+0x53   0x0053  #LATIN CAPITAL LETTER S
+0x54   0x0054  #LATIN CAPITAL LETTER T
+0x55   0x0055  #LATIN CAPITAL LETTER U
+0x56   0x0056  #LATIN CAPITAL LETTER V
+0x57   0x0057  #LATIN CAPITAL LETTER W
+0x58   0x0058  #LATIN CAPITAL LETTER X
+0x59   0x0059  #LATIN CAPITAL LETTER Y
+0x5A   0x005A  #LATIN CAPITAL LETTER Z
+0x5B   0x005B  #LEFT SQUARE BRACKET
+0x5C   0x005C  #REVERSE SOLIDUS
+0x5D   0x005D  #RIGHT SQUARE BRACKET
+0x5E   0x005E  #CIRCUMFLEX ACCENT
+0x5F   0x005F  #LOW LINE
+0x60   0x0060  #GRAVE ACCENT
+0x61   0x0061  #LATIN SMALL LETTER A
+0x62   0x0062  #LATIN SMALL LETTER B
+0x63   0x0063  #LATIN SMALL LETTER C
+0x64   0x0064  #LATIN SMALL LETTER D
+0x65   0x0065  #LATIN SMALL LETTER E
+0x66   0x0066  #LATIN SMALL LETTER F
+0x67   0x0067  #LATIN SMALL LETTER G
+0x68   0x0068  #LATIN SMALL LETTER H
+0x69   0x0069  #LATIN SMALL LETTER I
+0x6A   0x006A  #LATIN SMALL LETTER J
+0x6B   0x006B  #LATIN SMALL LETTER K
+0x6C   0x006C  #LATIN SMALL LETTER L
+0x6D   0x006D  #LATIN SMALL LETTER M
+0x6E   0x006E  #LATIN SMALL LETTER N
+0x6F   0x006F  #LATIN SMALL LETTER O
+0x70   0x0070  #LATIN SMALL LETTER P
+0x71   0x0071  #LATIN SMALL LETTER Q
+0x72   0x0072  #LATIN SMALL LETTER R
+0x73   0x0073  #LATIN SMALL LETTER S
+0x74   0x0074  #LATIN SMALL LETTER T
+0x75   0x0075  #LATIN SMALL LETTER U
+0x76   0x0076  #LATIN SMALL LETTER V
+0x77   0x0077  #LATIN SMALL LETTER W
+0x78   0x0078  #LATIN SMALL LETTER X
+0x79   0x0079  #LATIN SMALL LETTER Y
+0x7A   0x007A  #LATIN SMALL LETTER Z
+0x7B   0x007B  #LEFT CURLY BRACKET
+0x7C   0x007C  #VERTICAL LINE
+0x7D   0x007D  #RIGHT CURLY BRACKET
+0x7E   0x007E  #TILDE
+0x7F   0x007F  #DELETE
+0x80   0x20AC  #EURO SIGN
+0x81   0x067E  #ARABIC LETTER PEH
+0x82   0x201A  #SINGLE LOW-9 QUOTATION MARK
+0x83   0x0192  #LATIN SMALL LETTER F WITH HOOK
+0x84   0x201E  #DOUBLE LOW-9 QUOTATION MARK
+0x85   0x2026  #HORIZONTAL ELLIPSIS
+0x86   0x2020  #DAGGER
+0x87   0x2021  #DOUBLE DAGGER
+0x88   0x02C6  #MODIFIER LETTER CIRCUMFLEX ACCENT
+0x89   0x2030  #PER MILLE SIGN
+0x8A   0x0679  #ARABIC LETTER TTEH
+0x8B   0x2039  #SINGLE LEFT-POINTING ANGLE QUOTATION MARK
+0x8C   0x0152  #LATIN CAPITAL LIGATURE OE
+0x8D   0x0686  #ARABIC LETTER TCHEH
+0x8E   0x0698  #ARABIC LETTER JEH
+0x8F   0x0688  #ARABIC LETTER DDAL
+0x90   0x06AF  #ARABIC LETTER GAF
+0x91   0x2018  #LEFT SINGLE QUOTATION MARK
+0x92   0x2019  #RIGHT SINGLE QUOTATION MARK
+0x93   0x201C  #LEFT DOUBLE QUOTATION MARK
+0x94   0x201D  #RIGHT DOUBLE QUOTATION MARK
+0x95   0x2022  #BULLET
+0x96   0x2013  #EN DASH
+0x97   0x2014  #EM DASH
+0x98   0x06A9  #ARABIC LETTER KEHEH
+0x99   0x2122  #TRADE MARK SIGN
+0x9A   0x0691  #ARABIC LETTER RREH
+0x9B   0x203A  #SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
+0x9C   0x0153  #LATIN SMALL LIGATURE OE
+0x9D   0x200C  #ZERO WIDTH NON-JOINER
+0x9E   0x200D  #ZERO WIDTH JOINER
+0x9F   0x06BA  #ARABIC LETTER NOON GHUNNA
+0xA0   0x00A0  #NO-BREAK SPACE
+0xA1   0x060C  #ARABIC COMMA
+0xA2   0x00A2  #CENT SIGN
+0xA3   0x00A3  #POUND SIGN
+0xA4   0x00A4  #CURRENCY SIGN
+0xA5   0x00A5  #YEN SIGN
+0xA6   0x00A6  #BROKEN BAR
+0xA7   0x00A7  #SECTION SIGN
+0xA8   0x00A8  #DIAERESIS
+0xA9   0x00A9  #COPYRIGHT SIGN
+0xAA   0x06BE  #ARABIC LETTER HEH DOACHASHMEE
+0xAB   0x00AB  #LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+0xAC   0x00AC  #NOT SIGN
+0xAD   0x00AD  #SOFT HYPHEN
+0xAE   0x00AE  #REGISTERED SIGN
+0xAF   0x00AF  #MACRON
+0xB0   0x00B0  #DEGREE SIGN
+0xB1   0x00B1  #PLUS-MINUS SIGN
+0xB2   0x00B2  #SUPERSCRIPT TWO
+0xB3   0x00B3  #SUPERSCRIPT THREE
+0xB4   0x00B4  #ACUTE ACCENT
+0xB5   0x00B5  #MICRO SIGN
+0xB6   0x00B6  #PILCROW SIGN
+0xB7   0x00B7  #MIDDLE DOT
+0xB8   0x00B8  #CEDILLA
+0xB9   0x00B9  #SUPERSCRIPT ONE
+0xBA   0x061B  #ARABIC SEMICOLON
+0xBB   0x00BB  #RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
+0xBC   0x00BC  #VULGAR FRACTION ONE QUARTER
+0xBD   0x00BD  #VULGAR FRACTION ONE HALF
+0xBE   0x00BE  #VULGAR FRACTION THREE QUARTERS
+0xBF   0x061F  #ARABIC QUESTION MARK
+0xC0   0x06C1  #ARABIC LETTER HEH GOAL
+0xC1   0x0621  #ARABIC LETTER HAMZA
+0xC2   0x0622  #ARABIC LETTER ALEF WITH MADDA ABOVE
+0xC3   0x0623  #ARABIC LETTER ALEF WITH HAMZA ABOVE
+0xC4   0x0624  #ARABIC LETTER WAW WITH HAMZA ABOVE
+0xC5   0x0625  #ARABIC LETTER ALEF WITH HAMZA BELOW
+0xC6   0x0626  #ARABIC LETTER YEH WITH HAMZA ABOVE
+0xC7   0x0627  #ARABIC LETTER ALEF
+0xC8   0x0628  #ARABIC LETTER BEH
+0xC9   0x0629  #ARABIC LETTER TEH MARBUTA
+0xCA   0x062A  #ARABIC LETTER TEH
+0xCB   0x062B  #ARABIC LETTER THEH
+0xCC   0x062C  #ARABIC LETTER JEEM
+0xCD   0x062D  #ARABIC LETTER HAH
+0xCE   0x062E  #ARABIC LETTER KHAH
+0xCF   0x062F  #ARABIC LETTER DAL
+0xD0   0x0630  #ARABIC LETTER THAL
+0xD1   0x0631  #ARABIC LETTER REH
+0xD2   0x0632  #ARABIC LETTER ZAIN
+0xD3   0x0633  #ARABIC LETTER SEEN
+0xD4   0x0634  #ARABIC LETTER SHEEN
+0xD5   0x0635  #ARABIC LETTER SAD
+0xD6   0x0636  #ARABIC LETTER DAD
+0xD7   0x00D7  #MULTIPLICATION SIGN
+0xD8   0x0637  #ARABIC LETTER TAH
+0xD9   0x0638  #ARABIC LETTER ZAH
+0xDA   0x0639  #ARABIC LETTER AIN
+0xDB   0x063A  #ARABIC LETTER GHAIN
+0xDC   0x0640  #ARABIC TATWEEL
+0xDD   0x0641  #ARABIC LETTER FEH
+0xDE   0x0642  #ARABIC LETTER QAF
+0xDF   0x0643  #ARABIC LETTER KAF
+0xE0   0x00E0  #LATIN SMALL LETTER A WITH GRAVE
+0xE1   0x0644  #ARABIC LETTER LAM
+0xE2   0x00E2  #LATIN SMALL LETTER A WITH CIRCUMFLEX
+0xE3   0x0645  #ARABIC LETTER MEEM
+0xE4   0x0646  #ARABIC LETTER NOON
+0xE5   0x0647  #ARABIC LETTER HEH
+0xE6   0x0648  #ARABIC LETTER WAW
+0xE7   0x00E7  #LATIN SMALL LETTER C WITH CEDILLA
+0xE8   0x00E8  #LATIN SMALL LETTER E WITH GRAVE
+0xE9   0x00E9  #LATIN SMALL LETTER E WITH ACUTE
+0xEA   0x00EA  #LATIN SMALL LETTER E WITH CIRCUMFLEX
+0xEB   0x00EB  #LATIN SMALL LETTER E WITH DIAERESIS
+0xEC   0x0649  #ARABIC LETTER ALEF MAKSURA
+0xED   0x064A  #ARABIC LETTER YEH
+0xEE   0x00EE  #LATIN SMALL LETTER I WITH CIRCUMFLEX
+0xEF   0x00EF  #LATIN SMALL LETTER I WITH DIAERESIS
+0xF0   0x064B  #ARABIC FATHATAN
+0xF1   0x064C  #ARABIC DAMMATAN
+0xF2   0x064D  #ARABIC KASRATAN
+0xF3   0x064E  #ARABIC FATHA
+0xF4   0x00F4  #LATIN SMALL LETTER O WITH CIRCUMFLEX
+0xF5   0x064F  #ARABIC DAMMA
+0xF6   0x0650  #ARABIC KASRA
+0xF7   0x00F7  #DIVISION SIGN
+0xF8   0x0651  #ARABIC SHADDA
+0xF9   0x00F9  #LATIN SMALL LETTER U WITH GRAVE
+0xFA   0x0652  #ARABIC SUKUN
+0xFB   0x00FB  #LATIN SMALL LETTER U WITH CIRCUMFLEX
+0xFC   0x00FC  #LATIN SMALL LETTER U WITH DIAERESIS
+0xFD   0x200E  #LEFT-TO-RIGHT MARK
+0xFE   0x200F  #RIGHT-TO-LEFT MARK
+0xFF   0x06D2  #ARABIC LETTER YEH BARREE
diff --git a/basis/io/encodings/8-bit/CP1257.TXT b/basis/io/encodings/8-bit/CP1257.TXT
new file mode 100644 (file)
index 0000000..0dc475e
--- /dev/null
@@ -0,0 +1,274 @@
+#
+#    Name:     cp1257 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 cp1257 code (in hex)
+#        Column #2 is the Unicode (in hex as 0xXXXX)
+#        Column #3 is the Unicode name (follows a comment sign, '#')
+#
+#    The entries are in cp1257 order
+#
+0x00   0x0000  #NULL
+0x01   0x0001  #START OF HEADING
+0x02   0x0002  #START OF TEXT
+0x03   0x0003  #END OF TEXT
+0x04   0x0004  #END OF TRANSMISSION
+0x05   0x0005  #ENQUIRY
+0x06   0x0006  #ACKNOWLEDGE
+0x07   0x0007  #BELL
+0x08   0x0008  #BACKSPACE
+0x09   0x0009  #HORIZONTAL TABULATION
+0x0A   0x000A  #LINE FEED
+0x0B   0x000B  #VERTICAL TABULATION
+0x0C   0x000C  #FORM FEED
+0x0D   0x000D  #CARRIAGE RETURN
+0x0E   0x000E  #SHIFT OUT
+0x0F   0x000F  #SHIFT IN
+0x10   0x0010  #DATA LINK ESCAPE
+0x11   0x0011  #DEVICE CONTROL ONE
+0x12   0x0012  #DEVICE CONTROL TWO
+0x13   0x0013  #DEVICE CONTROL THREE
+0x14   0x0014  #DEVICE CONTROL FOUR
+0x15   0x0015  #NEGATIVE ACKNOWLEDGE
+0x16   0x0016  #SYNCHRONOUS IDLE
+0x17   0x0017  #END OF TRANSMISSION BLOCK
+0x18   0x0018  #CANCEL
+0x19   0x0019  #END OF MEDIUM
+0x1A   0x001A  #SUBSTITUTE
+0x1B   0x001B  #ESCAPE
+0x1C   0x001C  #FILE SEPARATOR
+0x1D   0x001D  #GROUP SEPARATOR
+0x1E   0x001E  #RECORD SEPARATOR
+0x1F   0x001F  #UNIT SEPARATOR
+0x20   0x0020  #SPACE
+0x21   0x0021  #EXCLAMATION MARK
+0x22   0x0022  #QUOTATION MARK
+0x23   0x0023  #NUMBER SIGN
+0x24   0x0024  #DOLLAR SIGN
+0x25   0x0025  #PERCENT SIGN
+0x26   0x0026  #AMPERSAND
+0x27   0x0027  #APOSTROPHE
+0x28   0x0028  #LEFT PARENTHESIS
+0x29   0x0029  #RIGHT PARENTHESIS
+0x2A   0x002A  #ASTERISK
+0x2B   0x002B  #PLUS SIGN
+0x2C   0x002C  #COMMA
+0x2D   0x002D  #HYPHEN-MINUS
+0x2E   0x002E  #FULL STOP
+0x2F   0x002F  #SOLIDUS
+0x30   0x0030  #DIGIT ZERO
+0x31   0x0031  #DIGIT ONE
+0x32   0x0032  #DIGIT TWO
+0x33   0x0033  #DIGIT THREE
+0x34   0x0034  #DIGIT FOUR
+0x35   0x0035  #DIGIT FIVE
+0x36   0x0036  #DIGIT SIX
+0x37   0x0037  #DIGIT SEVEN
+0x38   0x0038  #DIGIT EIGHT
+0x39   0x0039  #DIGIT NINE
+0x3A   0x003A  #COLON
+0x3B   0x003B  #SEMICOLON
+0x3C   0x003C  #LESS-THAN SIGN
+0x3D   0x003D  #EQUALS SIGN
+0x3E   0x003E  #GREATER-THAN SIGN
+0x3F   0x003F  #QUESTION MARK
+0x40   0x0040  #COMMERCIAL AT
+0x41   0x0041  #LATIN CAPITAL LETTER A
+0x42   0x0042  #LATIN CAPITAL LETTER B
+0x43   0x0043  #LATIN CAPITAL LETTER C
+0x44   0x0044  #LATIN CAPITAL LETTER D
+0x45   0x0045  #LATIN CAPITAL LETTER E
+0x46   0x0046  #LATIN CAPITAL LETTER F
+0x47   0x0047  #LATIN CAPITAL LETTER G
+0x48   0x0048  #LATIN CAPITAL LETTER H
+0x49   0x0049  #LATIN CAPITAL LETTER I
+0x4A   0x004A  #LATIN CAPITAL LETTER J
+0x4B   0x004B  #LATIN CAPITAL LETTER K
+0x4C   0x004C  #LATIN CAPITAL LETTER L
+0x4D   0x004D  #LATIN CAPITAL LETTER M
+0x4E   0x004E  #LATIN CAPITAL LETTER N
+0x4F   0x004F  #LATIN CAPITAL LETTER O
+0x50   0x0050  #LATIN CAPITAL LETTER P
+0x51   0x0051  #LATIN CAPITAL LETTER Q
+0x52   0x0052  #LATIN CAPITAL LETTER R
+0x53   0x0053  #LATIN CAPITAL LETTER S
+0x54   0x0054  #LATIN CAPITAL LETTER T
+0x55   0x0055  #LATIN CAPITAL LETTER U
+0x56   0x0056  #LATIN CAPITAL LETTER V
+0x57   0x0057  #LATIN CAPITAL LETTER W
+0x58   0x0058  #LATIN CAPITAL LETTER X
+0x59   0x0059  #LATIN CAPITAL LETTER Y
+0x5A   0x005A  #LATIN CAPITAL LETTER Z
+0x5B   0x005B  #LEFT SQUARE BRACKET
+0x5C   0x005C  #REVERSE SOLIDUS
+0x5D   0x005D  #RIGHT SQUARE BRACKET
+0x5E   0x005E  #CIRCUMFLEX ACCENT
+0x5F   0x005F  #LOW LINE
+0x60   0x0060  #GRAVE ACCENT
+0x61   0x0061  #LATIN SMALL LETTER A
+0x62   0x0062  #LATIN SMALL LETTER B
+0x63   0x0063  #LATIN SMALL LETTER C
+0x64   0x0064  #LATIN SMALL LETTER D
+0x65   0x0065  #LATIN SMALL LETTER E
+0x66   0x0066  #LATIN SMALL LETTER F
+0x67   0x0067  #LATIN SMALL LETTER G
+0x68   0x0068  #LATIN SMALL LETTER H
+0x69   0x0069  #LATIN SMALL LETTER I
+0x6A   0x006A  #LATIN SMALL LETTER J
+0x6B   0x006B  #LATIN SMALL LETTER K
+0x6C   0x006C  #LATIN SMALL LETTER L
+0x6D   0x006D  #LATIN SMALL LETTER M
+0x6E   0x006E  #LATIN SMALL LETTER N
+0x6F   0x006F  #LATIN SMALL LETTER O
+0x70   0x0070  #LATIN SMALL LETTER P
+0x71   0x0071  #LATIN SMALL LETTER Q
+0x72   0x0072  #LATIN SMALL LETTER R
+0x73   0x0073  #LATIN SMALL LETTER S
+0x74   0x0074  #LATIN SMALL LETTER T
+0x75   0x0075  #LATIN SMALL LETTER U
+0x76   0x0076  #LATIN SMALL LETTER V
+0x77   0x0077  #LATIN SMALL LETTER W
+0x78   0x0078  #LATIN SMALL LETTER X
+0x79   0x0079  #LATIN SMALL LETTER Y
+0x7A   0x007A  #LATIN SMALL LETTER Z
+0x7B   0x007B  #LEFT CURLY BRACKET
+0x7C   0x007C  #VERTICAL LINE
+0x7D   0x007D  #RIGHT CURLY BRACKET
+0x7E   0x007E  #TILDE
+0x7F   0x007F  #DELETE
+0x80   0x20AC  #EURO SIGN
+0x81           #UNDEFINED
+0x82   0x201A  #SINGLE LOW-9 QUOTATION MARK
+0x83           #UNDEFINED
+0x84   0x201E  #DOUBLE LOW-9 QUOTATION MARK
+0x85   0x2026  #HORIZONTAL ELLIPSIS
+0x86   0x2020  #DAGGER
+0x87   0x2021  #DOUBLE DAGGER
+0x88           #UNDEFINED
+0x89   0x2030  #PER MILLE SIGN
+0x8A           #UNDEFINED
+0x8B   0x2039  #SINGLE LEFT-POINTING ANGLE QUOTATION MARK
+0x8C           #UNDEFINED
+0x8D   0x00A8  #DIAERESIS
+0x8E   0x02C7  #CARON
+0x8F   0x00B8  #CEDILLA
+0x90           #UNDEFINED
+0x91   0x2018  #LEFT SINGLE QUOTATION MARK
+0x92   0x2019  #RIGHT SINGLE QUOTATION MARK
+0x93   0x201C  #LEFT DOUBLE QUOTATION MARK
+0x94   0x201D  #RIGHT DOUBLE QUOTATION MARK
+0x95   0x2022  #BULLET
+0x96   0x2013  #EN DASH
+0x97   0x2014  #EM DASH
+0x98           #UNDEFINED
+0x99   0x2122  #TRADE MARK SIGN
+0x9A           #UNDEFINED
+0x9B   0x203A  #SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
+0x9C           #UNDEFINED
+0x9D   0x00AF  #MACRON
+0x9E   0x02DB  #OGONEK
+0x9F           #UNDEFINED
+0xA0   0x00A0  #NO-BREAK SPACE
+0xA1           #UNDEFINED
+0xA2   0x00A2  #CENT SIGN
+0xA3   0x00A3  #POUND SIGN
+0xA4   0x00A4  #CURRENCY SIGN
+0xA5           #UNDEFINED
+0xA6   0x00A6  #BROKEN BAR
+0xA7   0x00A7  #SECTION SIGN
+0xA8   0x00D8  #LATIN CAPITAL LETTER O WITH STROKE
+0xA9   0x00A9  #COPYRIGHT SIGN
+0xAA   0x0156  #LATIN CAPITAL LETTER R WITH CEDILLA
+0xAB   0x00AB  #LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+0xAC   0x00AC  #NOT SIGN
+0xAD   0x00AD  #SOFT HYPHEN
+0xAE   0x00AE  #REGISTERED SIGN
+0xAF   0x00C6  #LATIN CAPITAL LETTER AE
+0xB0   0x00B0  #DEGREE SIGN
+0xB1   0x00B1  #PLUS-MINUS SIGN
+0xB2   0x00B2  #SUPERSCRIPT TWO
+0xB3   0x00B3  #SUPERSCRIPT THREE
+0xB4   0x00B4  #ACUTE ACCENT
+0xB5   0x00B5  #MICRO SIGN
+0xB6   0x00B6  #PILCROW SIGN
+0xB7   0x00B7  #MIDDLE DOT
+0xB8   0x00F8  #LATIN SMALL LETTER O WITH STROKE
+0xB9   0x00B9  #SUPERSCRIPT ONE
+0xBA   0x0157  #LATIN SMALL LETTER R WITH CEDILLA
+0xBB   0x00BB  #RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
+0xBC   0x00BC  #VULGAR FRACTION ONE QUARTER
+0xBD   0x00BD  #VULGAR FRACTION ONE HALF
+0xBE   0x00BE  #VULGAR FRACTION THREE QUARTERS
+0xBF   0x00E6  #LATIN SMALL LETTER AE
+0xC0   0x0104  #LATIN CAPITAL LETTER A WITH OGONEK
+0xC1   0x012E  #LATIN CAPITAL LETTER I WITH OGONEK
+0xC2   0x0100  #LATIN CAPITAL LETTER A WITH MACRON
+0xC3   0x0106  #LATIN CAPITAL LETTER C WITH ACUTE
+0xC4   0x00C4  #LATIN CAPITAL LETTER A WITH DIAERESIS
+0xC5   0x00C5  #LATIN CAPITAL LETTER A WITH RING ABOVE
+0xC6   0x0118  #LATIN CAPITAL LETTER E WITH OGONEK
+0xC7   0x0112  #LATIN CAPITAL LETTER E WITH MACRON
+0xC8   0x010C  #LATIN CAPITAL LETTER C WITH CARON
+0xC9   0x00C9  #LATIN CAPITAL LETTER E WITH ACUTE
+0xCA   0x0179  #LATIN CAPITAL LETTER Z WITH ACUTE
+0xCB   0x0116  #LATIN CAPITAL LETTER E WITH DOT ABOVE
+0xCC   0x0122  #LATIN CAPITAL LETTER G WITH CEDILLA
+0xCD   0x0136  #LATIN CAPITAL LETTER K WITH CEDILLA
+0xCE   0x012A  #LATIN CAPITAL LETTER I WITH MACRON
+0xCF   0x013B  #LATIN CAPITAL LETTER L WITH CEDILLA
+0xD0   0x0160  #LATIN CAPITAL LETTER S WITH CARON
+0xD1   0x0143  #LATIN CAPITAL LETTER N WITH ACUTE
+0xD2   0x0145  #LATIN CAPITAL LETTER N WITH CEDILLA
+0xD3   0x00D3  #LATIN CAPITAL LETTER O WITH ACUTE
+0xD4   0x014C  #LATIN CAPITAL LETTER O WITH MACRON
+0xD5   0x00D5  #LATIN CAPITAL LETTER O WITH TILDE
+0xD6   0x00D6  #LATIN CAPITAL LETTER O WITH DIAERESIS
+0xD7   0x00D7  #MULTIPLICATION SIGN
+0xD8   0x0172  #LATIN CAPITAL LETTER U WITH OGONEK
+0xD9   0x0141  #LATIN CAPITAL LETTER L WITH STROKE
+0xDA   0x015A  #LATIN CAPITAL LETTER S WITH ACUTE
+0xDB   0x016A  #LATIN CAPITAL LETTER U WITH MACRON
+0xDC   0x00DC  #LATIN CAPITAL LETTER U WITH DIAERESIS
+0xDD   0x017B  #LATIN CAPITAL LETTER Z WITH DOT ABOVE
+0xDE   0x017D  #LATIN CAPITAL LETTER Z WITH CARON
+0xDF   0x00DF  #LATIN SMALL LETTER SHARP S
+0xE0   0x0105  #LATIN SMALL LETTER A WITH OGONEK
+0xE1   0x012F  #LATIN SMALL LETTER I WITH OGONEK
+0xE2   0x0101  #LATIN SMALL LETTER A WITH MACRON
+0xE3   0x0107  #LATIN SMALL LETTER C WITH ACUTE
+0xE4   0x00E4  #LATIN SMALL LETTER A WITH DIAERESIS
+0xE5   0x00E5  #LATIN SMALL LETTER A WITH RING ABOVE
+0xE6   0x0119  #LATIN SMALL LETTER E WITH OGONEK
+0xE7   0x0113  #LATIN SMALL LETTER E WITH MACRON
+0xE8   0x010D  #LATIN SMALL LETTER C WITH CARON
+0xE9   0x00E9  #LATIN SMALL LETTER E WITH ACUTE
+0xEA   0x017A  #LATIN SMALL LETTER Z WITH ACUTE
+0xEB   0x0117  #LATIN SMALL LETTER E WITH DOT ABOVE
+0xEC   0x0123  #LATIN SMALL LETTER G WITH CEDILLA
+0xED   0x0137  #LATIN SMALL LETTER K WITH CEDILLA
+0xEE   0x012B  #LATIN SMALL LETTER I WITH MACRON
+0xEF   0x013C  #LATIN SMALL LETTER L WITH CEDILLA
+0xF0   0x0161  #LATIN SMALL LETTER S WITH CARON
+0xF1   0x0144  #LATIN SMALL LETTER N WITH ACUTE
+0xF2   0x0146  #LATIN SMALL LETTER N WITH CEDILLA
+0xF3   0x00F3  #LATIN SMALL LETTER O WITH ACUTE
+0xF4   0x014D  #LATIN SMALL LETTER O WITH MACRON
+0xF5   0x00F5  #LATIN SMALL LETTER O WITH TILDE
+0xF6   0x00F6  #LATIN SMALL LETTER O WITH DIAERESIS
+0xF7   0x00F7  #DIVISION SIGN
+0xF8   0x0173  #LATIN SMALL LETTER U WITH OGONEK
+0xF9   0x0142  #LATIN SMALL LETTER L WITH STROKE
+0xFA   0x015B  #LATIN SMALL LETTER S WITH ACUTE
+0xFB   0x016B  #LATIN SMALL LETTER U WITH MACRON
+0xFC   0x00FC  #LATIN SMALL LETTER U WITH DIAERESIS
+0xFD   0x017C  #LATIN SMALL LETTER Z WITH DOT ABOVE
+0xFE   0x017E  #LATIN SMALL LETTER Z WITH CARON
+0xFF   0x02D9  #DOT ABOVE
diff --git a/basis/io/encodings/8-bit/CP1258.TXT b/basis/io/encodings/8-bit/CP1258.TXT
new file mode 100644 (file)
index 0000000..f402b34
--- /dev/null
@@ -0,0 +1,274 @@
+#
+#    Name:     cp1258 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 cp1258 code (in hex)
+#        Column #2 is the Unicode (in hex as 0xXXXX)
+#        Column #3 is the Unicode name (follows a comment sign, '#')
+#
+#    The entries are in cp1258 order
+#
+0x00   0x0000  #NULL
+0x01   0x0001  #START OF HEADING
+0x02   0x0002  #START OF TEXT
+0x03   0x0003  #END OF TEXT
+0x04   0x0004  #END OF TRANSMISSION
+0x05   0x0005  #ENQUIRY
+0x06   0x0006  #ACKNOWLEDGE
+0x07   0x0007  #BELL
+0x08   0x0008  #BACKSPACE
+0x09   0x0009  #HORIZONTAL TABULATION
+0x0A   0x000A  #LINE FEED
+0x0B   0x000B  #VERTICAL TABULATION
+0x0C   0x000C  #FORM FEED
+0x0D   0x000D  #CARRIAGE RETURN
+0x0E   0x000E  #SHIFT OUT
+0x0F   0x000F  #SHIFT IN
+0x10   0x0010  #DATA LINK ESCAPE
+0x11   0x0011  #DEVICE CONTROL ONE
+0x12   0x0012  #DEVICE CONTROL TWO
+0x13   0x0013  #DEVICE CONTROL THREE
+0x14   0x0014  #DEVICE CONTROL FOUR
+0x15   0x0015  #NEGATIVE ACKNOWLEDGE
+0x16   0x0016  #SYNCHRONOUS IDLE
+0x17   0x0017  #END OF TRANSMISSION BLOCK
+0x18   0x0018  #CANCEL
+0x19   0x0019  #END OF MEDIUM
+0x1A   0x001A  #SUBSTITUTE
+0x1B   0x001B  #ESCAPE
+0x1C   0x001C  #FILE SEPARATOR
+0x1D   0x001D  #GROUP SEPARATOR
+0x1E   0x001E  #RECORD SEPARATOR
+0x1F   0x001F  #UNIT SEPARATOR
+0x20   0x0020  #SPACE
+0x21   0x0021  #EXCLAMATION MARK
+0x22   0x0022  #QUOTATION MARK
+0x23   0x0023  #NUMBER SIGN
+0x24   0x0024  #DOLLAR SIGN
+0x25   0x0025  #PERCENT SIGN
+0x26   0x0026  #AMPERSAND
+0x27   0x0027  #APOSTROPHE
+0x28   0x0028  #LEFT PARENTHESIS
+0x29   0x0029  #RIGHT PARENTHESIS
+0x2A   0x002A  #ASTERISK
+0x2B   0x002B  #PLUS SIGN
+0x2C   0x002C  #COMMA
+0x2D   0x002D  #HYPHEN-MINUS
+0x2E   0x002E  #FULL STOP
+0x2F   0x002F  #SOLIDUS
+0x30   0x0030  #DIGIT ZERO
+0x31   0x0031  #DIGIT ONE
+0x32   0x0032  #DIGIT TWO
+0x33   0x0033  #DIGIT THREE
+0x34   0x0034  #DIGIT FOUR
+0x35   0x0035  #DIGIT FIVE
+0x36   0x0036  #DIGIT SIX
+0x37   0x0037  #DIGIT SEVEN
+0x38   0x0038  #DIGIT EIGHT
+0x39   0x0039  #DIGIT NINE
+0x3A   0x003A  #COLON
+0x3B   0x003B  #SEMICOLON
+0x3C   0x003C  #LESS-THAN SIGN
+0x3D   0x003D  #EQUALS SIGN
+0x3E   0x003E  #GREATER-THAN SIGN
+0x3F   0x003F  #QUESTION MARK
+0x40   0x0040  #COMMERCIAL AT
+0x41   0x0041  #LATIN CAPITAL LETTER A
+0x42   0x0042  #LATIN CAPITAL LETTER B
+0x43   0x0043  #LATIN CAPITAL LETTER C
+0x44   0x0044  #LATIN CAPITAL LETTER D
+0x45   0x0045  #LATIN CAPITAL LETTER E
+0x46   0x0046  #LATIN CAPITAL LETTER F
+0x47   0x0047  #LATIN CAPITAL LETTER G
+0x48   0x0048  #LATIN CAPITAL LETTER H
+0x49   0x0049  #LATIN CAPITAL LETTER I
+0x4A   0x004A  #LATIN CAPITAL LETTER J
+0x4B   0x004B  #LATIN CAPITAL LETTER K
+0x4C   0x004C  #LATIN CAPITAL LETTER L
+0x4D   0x004D  #LATIN CAPITAL LETTER M
+0x4E   0x004E  #LATIN CAPITAL LETTER N
+0x4F   0x004F  #LATIN CAPITAL LETTER O
+0x50   0x0050  #LATIN CAPITAL LETTER P
+0x51   0x0051  #LATIN CAPITAL LETTER Q
+0x52   0x0052  #LATIN CAPITAL LETTER R
+0x53   0x0053  #LATIN CAPITAL LETTER S
+0x54   0x0054  #LATIN CAPITAL LETTER T
+0x55   0x0055  #LATIN CAPITAL LETTER U
+0x56   0x0056  #LATIN CAPITAL LETTER V
+0x57   0x0057  #LATIN CAPITAL LETTER W
+0x58   0x0058  #LATIN CAPITAL LETTER X
+0x59   0x0059  #LATIN CAPITAL LETTER Y
+0x5A   0x005A  #LATIN CAPITAL LETTER Z
+0x5B   0x005B  #LEFT SQUARE BRACKET
+0x5C   0x005C  #REVERSE SOLIDUS
+0x5D   0x005D  #RIGHT SQUARE BRACKET
+0x5E   0x005E  #CIRCUMFLEX ACCENT
+0x5F   0x005F  #LOW LINE
+0x60   0x0060  #GRAVE ACCENT
+0x61   0x0061  #LATIN SMALL LETTER A
+0x62   0x0062  #LATIN SMALL LETTER B
+0x63   0x0063  #LATIN SMALL LETTER C
+0x64   0x0064  #LATIN SMALL LETTER D
+0x65   0x0065  #LATIN SMALL LETTER E
+0x66   0x0066  #LATIN SMALL LETTER F
+0x67   0x0067  #LATIN SMALL LETTER G
+0x68   0x0068  #LATIN SMALL LETTER H
+0x69   0x0069  #LATIN SMALL LETTER I
+0x6A   0x006A  #LATIN SMALL LETTER J
+0x6B   0x006B  #LATIN SMALL LETTER K
+0x6C   0x006C  #LATIN SMALL LETTER L
+0x6D   0x006D  #LATIN SMALL LETTER M
+0x6E   0x006E  #LATIN SMALL LETTER N
+0x6F   0x006F  #LATIN SMALL LETTER O
+0x70   0x0070  #LATIN SMALL LETTER P
+0x71   0x0071  #LATIN SMALL LETTER Q
+0x72   0x0072  #LATIN SMALL LETTER R
+0x73   0x0073  #LATIN SMALL LETTER S
+0x74   0x0074  #LATIN SMALL LETTER T
+0x75   0x0075  #LATIN SMALL LETTER U
+0x76   0x0076  #LATIN SMALL LETTER V
+0x77   0x0077  #LATIN SMALL LETTER W
+0x78   0x0078  #LATIN SMALL LETTER X
+0x79   0x0079  #LATIN SMALL LETTER Y
+0x7A   0x007A  #LATIN SMALL LETTER Z
+0x7B   0x007B  #LEFT CURLY BRACKET
+0x7C   0x007C  #VERTICAL LINE
+0x7D   0x007D  #RIGHT CURLY BRACKET
+0x7E   0x007E  #TILDE
+0x7F   0x007F  #DELETE
+0x80   0x20AC  #EURO SIGN
+0x81           #UNDEFINED
+0x82   0x201A  #SINGLE LOW-9 QUOTATION MARK
+0x83   0x0192  #LATIN SMALL LETTER F WITH HOOK
+0x84   0x201E  #DOUBLE LOW-9 QUOTATION MARK
+0x85   0x2026  #HORIZONTAL ELLIPSIS
+0x86   0x2020  #DAGGER
+0x87   0x2021  #DOUBLE DAGGER
+0x88   0x02C6  #MODIFIER LETTER CIRCUMFLEX ACCENT
+0x89   0x2030  #PER MILLE SIGN
+0x8A           #UNDEFINED
+0x8B   0x2039  #SINGLE LEFT-POINTING ANGLE QUOTATION MARK
+0x8C   0x0152  #LATIN CAPITAL LIGATURE OE
+0x8D           #UNDEFINED
+0x8E           #UNDEFINED
+0x8F           #UNDEFINED
+0x90           #UNDEFINED
+0x91   0x2018  #LEFT SINGLE QUOTATION MARK
+0x92   0x2019  #RIGHT SINGLE QUOTATION MARK
+0x93   0x201C  #LEFT DOUBLE QUOTATION MARK
+0x94   0x201D  #RIGHT DOUBLE QUOTATION MARK
+0x95   0x2022  #BULLET
+0x96   0x2013  #EN DASH
+0x97   0x2014  #EM DASH
+0x98   0x02DC  #SMALL TILDE
+0x99   0x2122  #TRADE MARK SIGN
+0x9A           #UNDEFINED
+0x9B   0x203A  #SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
+0x9C   0x0153  #LATIN SMALL LIGATURE OE
+0x9D           #UNDEFINED
+0x9E           #UNDEFINED
+0x9F   0x0178  #LATIN CAPITAL LETTER Y WITH DIAERESIS
+0xA0   0x00A0  #NO-BREAK SPACE
+0xA1   0x00A1  #INVERTED EXCLAMATION MARK
+0xA2   0x00A2  #CENT SIGN
+0xA3   0x00A3  #POUND SIGN
+0xA4   0x00A4  #CURRENCY SIGN
+0xA5   0x00A5  #YEN SIGN
+0xA6   0x00A6  #BROKEN BAR
+0xA7   0x00A7  #SECTION SIGN
+0xA8   0x00A8  #DIAERESIS
+0xA9   0x00A9  #COPYRIGHT SIGN
+0xAA   0x00AA  #FEMININE ORDINAL INDICATOR
+0xAB   0x00AB  #LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+0xAC   0x00AC  #NOT SIGN
+0xAD   0x00AD  #SOFT HYPHEN
+0xAE   0x00AE  #REGISTERED SIGN
+0xAF   0x00AF  #MACRON
+0xB0   0x00B0  #DEGREE SIGN
+0xB1   0x00B1  #PLUS-MINUS SIGN
+0xB2   0x00B2  #SUPERSCRIPT TWO
+0xB3   0x00B3  #SUPERSCRIPT THREE
+0xB4   0x00B4  #ACUTE ACCENT
+0xB5   0x00B5  #MICRO SIGN
+0xB6   0x00B6  #PILCROW SIGN
+0xB7   0x00B7  #MIDDLE DOT
+0xB8   0x00B8  #CEDILLA
+0xB9   0x00B9  #SUPERSCRIPT ONE
+0xBA   0x00BA  #MASCULINE ORDINAL INDICATOR
+0xBB   0x00BB  #RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
+0xBC   0x00BC  #VULGAR FRACTION ONE QUARTER
+0xBD   0x00BD  #VULGAR FRACTION ONE HALF
+0xBE   0x00BE  #VULGAR FRACTION THREE QUARTERS
+0xBF   0x00BF  #INVERTED QUESTION MARK
+0xC0   0x00C0  #LATIN CAPITAL LETTER A WITH GRAVE
+0xC1   0x00C1  #LATIN CAPITAL LETTER A WITH ACUTE
+0xC2   0x00C2  #LATIN CAPITAL LETTER A WITH CIRCUMFLEX
+0xC3   0x0102  #LATIN CAPITAL LETTER A WITH BREVE
+0xC4   0x00C4  #LATIN CAPITAL LETTER A WITH DIAERESIS
+0xC5   0x00C5  #LATIN CAPITAL LETTER A WITH RING ABOVE
+0xC6   0x00C6  #LATIN CAPITAL LETTER AE
+0xC7   0x00C7  #LATIN CAPITAL LETTER C WITH CEDILLA
+0xC8   0x00C8  #LATIN CAPITAL LETTER E WITH GRAVE
+0xC9   0x00C9  #LATIN CAPITAL LETTER E WITH ACUTE
+0xCA   0x00CA  #LATIN CAPITAL LETTER E WITH CIRCUMFLEX
+0xCB   0x00CB  #LATIN CAPITAL LETTER E WITH DIAERESIS
+0xCC   0x0300  #COMBINING GRAVE ACCENT
+0xCD   0x00CD  #LATIN CAPITAL LETTER I WITH ACUTE
+0xCE   0x00CE  #LATIN CAPITAL LETTER I WITH CIRCUMFLEX
+0xCF   0x00CF  #LATIN CAPITAL LETTER I WITH DIAERESIS
+0xD0   0x0110  #LATIN CAPITAL LETTER D WITH STROKE
+0xD1   0x00D1  #LATIN CAPITAL LETTER N WITH TILDE
+0xD2   0x0309  #COMBINING HOOK ABOVE
+0xD3   0x00D3  #LATIN CAPITAL LETTER O WITH ACUTE
+0xD4   0x00D4  #LATIN CAPITAL LETTER O WITH CIRCUMFLEX
+0xD5   0x01A0  #LATIN CAPITAL LETTER O WITH HORN
+0xD6   0x00D6  #LATIN CAPITAL LETTER O WITH DIAERESIS
+0xD7   0x00D7  #MULTIPLICATION SIGN
+0xD8   0x00D8  #LATIN CAPITAL LETTER O WITH STROKE
+0xD9   0x00D9  #LATIN CAPITAL LETTER U WITH GRAVE
+0xDA   0x00DA  #LATIN CAPITAL LETTER U WITH ACUTE
+0xDB   0x00DB  #LATIN CAPITAL LETTER U WITH CIRCUMFLEX
+0xDC   0x00DC  #LATIN CAPITAL LETTER U WITH DIAERESIS
+0xDD   0x01AF  #LATIN CAPITAL LETTER U WITH HORN
+0xDE   0x0303  #COMBINING TILDE
+0xDF   0x00DF  #LATIN SMALL LETTER SHARP S
+0xE0   0x00E0  #LATIN SMALL LETTER A WITH GRAVE
+0xE1   0x00E1  #LATIN SMALL LETTER A WITH ACUTE
+0xE2   0x00E2  #LATIN SMALL LETTER A WITH CIRCUMFLEX
+0xE3   0x0103  #LATIN SMALL LETTER A WITH BREVE
+0xE4   0x00E4  #LATIN SMALL LETTER A WITH DIAERESIS
+0xE5   0x00E5  #LATIN SMALL LETTER A WITH RING ABOVE
+0xE6   0x00E6  #LATIN SMALL LETTER AE
+0xE7   0x00E7  #LATIN SMALL LETTER C WITH CEDILLA
+0xE8   0x00E8  #LATIN SMALL LETTER E WITH GRAVE
+0xE9   0x00E9  #LATIN SMALL LETTER E WITH ACUTE
+0xEA   0x00EA  #LATIN SMALL LETTER E WITH CIRCUMFLEX
+0xEB   0x00EB  #LATIN SMALL LETTER E WITH DIAERESIS
+0xEC   0x0301  #COMBINING ACUTE ACCENT
+0xED   0x00ED  #LATIN SMALL LETTER I WITH ACUTE
+0xEE   0x00EE  #LATIN SMALL LETTER I WITH CIRCUMFLEX
+0xEF   0x00EF  #LATIN SMALL LETTER I WITH DIAERESIS
+0xF0   0x0111  #LATIN SMALL LETTER D WITH STROKE
+0xF1   0x00F1  #LATIN SMALL LETTER N WITH TILDE
+0xF2   0x0323  #COMBINING DOT BELOW
+0xF3   0x00F3  #LATIN SMALL LETTER O WITH ACUTE
+0xF4   0x00F4  #LATIN SMALL LETTER O WITH CIRCUMFLEX
+0xF5   0x01A1  #LATIN SMALL LETTER O WITH HORN
+0xF6   0x00F6  #LATIN SMALL LETTER O WITH DIAERESIS
+0xF7   0x00F7  #DIVISION SIGN
+0xF8   0x00F8  #LATIN SMALL LETTER O WITH STROKE
+0xF9   0x00F9  #LATIN SMALL LETTER U WITH GRAVE
+0xFA   0x00FA  #LATIN SMALL LETTER U WITH ACUTE
+0xFB   0x00FB  #LATIN SMALL LETTER U WITH CIRCUMFLEX
+0xFC   0x00FC  #LATIN SMALL LETTER U WITH DIAERESIS
+0xFD   0x01B0  #LATIN SMALL LETTER U WITH HORN
+0xFE   0x20AB  #DONG SIGN
+0xFF   0x00FF  #LATIN SMALL LETTER Y WITH DIAERESIS
diff --git a/basis/io/encodings/8-bit/arabic/arabic-docs.factor b/basis/io/encodings/8-bit/arabic/arabic-docs.factor
new file mode 100644 (file)
index 0000000..5c86326
--- /dev/null
@@ -0,0 +1,13 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: help.markup help.syntax ;
+IN: io.encodings.8-bit.arabic
+
+HELP: latin/arabic
+{ $var-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" } ;
+
+ARTICLE: "io.encodings.8-bit.arabic" "Arabic encoding"
+"The " { $vocab-link "io.encodings.8-bit.arabic" }  " vocabulary provides the " { $link latin/arabic } " encoding." ;
+
+ABOUT: "io.encodings.8-bit.arabic"
diff --git a/basis/io/encodings/8-bit/arabic/arabic.factor b/basis/io/encodings/8-bit/arabic/arabic.factor
new file mode 100644 (file)
index 0000000..5a80921
--- /dev/null
@@ -0,0 +1,6 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: io.encodings.8-bit ;
+IN: io.encodings.8-bit.arabic
+
+8-BIT: latin/arabic ISO_8859-6:1987 8859-6
diff --git a/basis/io/encodings/8-bit/arabic/authors.txt b/basis/io/encodings/8-bit/arabic/authors.txt
new file mode 100644 (file)
index 0000000..b4bd0e7
--- /dev/null
@@ -0,0 +1 @@
+Doug Coleman
\ No newline at end of file
diff --git a/basis/io/encodings/8-bit/cyrillic/authors.txt b/basis/io/encodings/8-bit/cyrillic/authors.txt
new file mode 100644 (file)
index 0000000..b4bd0e7
--- /dev/null
@@ -0,0 +1 @@
+Doug Coleman
\ No newline at end of file
diff --git a/basis/io/encodings/8-bit/cyrillic/cyrillic-docs.factor b/basis/io/encodings/8-bit/cyrillic/cyrillic-docs.factor
new file mode 100644 (file)
index 0000000..741f1de
--- /dev/null
@@ -0,0 +1,13 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: help.markup help.syntax ;
+IN: io.encodings.8-bit.cyrillic
+
+HELP: latin/cyrillic
+{ $var-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" } ;
+
+ARTICLE: "io.encodings.8-bit.cyrillic" "Cyrillic encoding"
+"The " { $vocab-link "io.encodings.8-bit.cyrillic" } " vocabulary provides the " { $link latin/cyrillic } " encoding." ;
+
+ABOUT: "io.encodings.8-bit.cyrillic"
diff --git a/basis/io/encodings/8-bit/cyrillic/cyrillic.factor b/basis/io/encodings/8-bit/cyrillic/cyrillic.factor
new file mode 100644 (file)
index 0000000..13cfbc0
--- /dev/null
@@ -0,0 +1,6 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: io.encodings.8-bit ;
+IN: io.encodings.8-bit.cyrillic
+
+8-BIT: latin/cyrillic ISO_8859-5:1988 8859-5
diff --git a/basis/io/encodings/8-bit/ebcdic/authors.txt b/basis/io/encodings/8-bit/ebcdic/authors.txt
new file mode 100644 (file)
index 0000000..b4bd0e7
--- /dev/null
@@ -0,0 +1 @@
+Doug Coleman
\ No newline at end of file
diff --git a/basis/io/encodings/8-bit/ebcdic/ebcdic-docs.factor b/basis/io/encodings/8-bit/ebcdic/ebcdic-docs.factor
new file mode 100644 (file)
index 0000000..09646fd
--- /dev/null
@@ -0,0 +1,13 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: help.markup help.syntax ;
+IN: io.encodings.8-bit.ebcdic
+
+HELP: ebcdic
+{ $var-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" } ;
+
+ARTICLE: "io.encodings.8-bit.ebcdic" "EBCDIC encoding"
+"The " { $vocab-link "io.encodings.8-bit.ebcdic" } " vocabulary provides the " { $link ebcdic } " encoding." ;
+
+ABOUT: "io.encodings.8-bit.ebcdic"
diff --git a/basis/io/encodings/8-bit/ebcdic/ebcdic.factor b/basis/io/encodings/8-bit/ebcdic/ebcdic.factor
new file mode 100644 (file)
index 0000000..fd8f29c
--- /dev/null
@@ -0,0 +1,6 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: io.encodings.8-bit ;
+IN: io.encodings.8-bit.ebcdic
+
+8-BIT: ebcdic IBM037 CP037
diff --git a/basis/io/encodings/8-bit/greek/authors.txt b/basis/io/encodings/8-bit/greek/authors.txt
new file mode 100644 (file)
index 0000000..b4bd0e7
--- /dev/null
@@ -0,0 +1 @@
+Doug Coleman
\ No newline at end of file
diff --git a/basis/io/encodings/8-bit/greek/greek-docs.factor b/basis/io/encodings/8-bit/greek/greek-docs.factor
new file mode 100644 (file)
index 0000000..b7d658a
--- /dev/null
@@ -0,0 +1,13 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: help.markup help.syntax ;
+IN: io.encodings.8-bit.greek
+
+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" } ;
+
+ARTICLE: "io.encodings.8-bit.greek" "Greek encoding"
+"The " { $vocab-link "io.encodings.8-bit.greek" }  " vocabulary provides the " { $link latin/greek } " encoding." ;
+
+ABOUT: "io.encodings.8-bit.greek"
diff --git a/basis/io/encodings/8-bit/greek/greek.factor b/basis/io/encodings/8-bit/greek/greek.factor
new file mode 100644 (file)
index 0000000..98eb09a
--- /dev/null
@@ -0,0 +1,6 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: io.encodings.8-bit ;
+IN: io.encodings.8-bit.greek
+
+8-BIT: latin/greek ISO_8859-7:1987 8859-7
diff --git a/basis/io/encodings/8-bit/hebrew/authors.txt b/basis/io/encodings/8-bit/hebrew/authors.txt
new file mode 100644 (file)
index 0000000..b4bd0e7
--- /dev/null
@@ -0,0 +1 @@
+Doug Coleman
\ No newline at end of file
diff --git a/basis/io/encodings/8-bit/hebrew/hebrew-docs.factor b/basis/io/encodings/8-bit/hebrew/hebrew-docs.factor
new file mode 100644 (file)
index 0000000..43433e2
--- /dev/null
@@ -0,0 +1,13 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: help.markup help.syntax ;
+IN: io.encodings.8-bit.hebrew
+
+HELP: latin/hebrew
+{ $var-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" } ;
+
+ARTICLE: "io.encodings.8-bit.hebrew" "Hebrew encoding"
+"The " { $vocab-link "io.encodings.8-bit.hebrew" } " vocabulary provides the " { $link latin/hebrew } " encoding." ;
+
+ABOUT: "io.encodings.8-bit.hebrew"
diff --git a/basis/io/encodings/8-bit/hebrew/hebrew.factor b/basis/io/encodings/8-bit/hebrew/hebrew.factor
new file mode 100644 (file)
index 0000000..6619f64
--- /dev/null
@@ -0,0 +1,6 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: io.encodings.8-bit ;
+IN: io.encodings.8-bit.hebrew
+
+8-BIT: latin/hebrew ISO_8859-8:1988 8859-8
diff --git a/basis/io/encodings/8-bit/koi8-r/authors.txt b/basis/io/encodings/8-bit/koi8-r/authors.txt
new file mode 100644 (file)
index 0000000..b4bd0e7
--- /dev/null
@@ -0,0 +1 @@
+Doug Coleman
\ No newline at end of file
diff --git a/basis/io/encodings/8-bit/koi8-r/koi8-r-docs.factor b/basis/io/encodings/8-bit/koi8-r/koi8-r-docs.factor
new file mode 100644 (file)
index 0000000..94e2652
--- /dev/null
@@ -0,0 +1,13 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: help.markup help.syntax ;
+IN: io.encodings.8-bit.koi8-r
+
+HELP: koi8-r
+{ $var-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" } ;
+
+ARTICLE: "io.encodings.8-bit.koi8-r" "KOI8-R encoding"
+"The " { $vocab-link "io.encodings.8-bit.koi8-r" } " vocabulary provides the " { $link koi8-r } " encoding." ;
+
+ABOUT: "io.encodings.8-bit.koi8-r"
diff --git a/basis/io/encodings/8-bit/koi8-r/koi8-r.factor b/basis/io/encodings/8-bit/koi8-r/koi8-r.factor
new file mode 100644 (file)
index 0000000..6203fbd
--- /dev/null
@@ -0,0 +1,6 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: io.encodings.8-bit ;
+IN: io.encodings.8-bit.koi8-r
+
+8-BIT: koi8-r KOI8-R KOI8-R
diff --git a/basis/io/encodings/8-bit/latin1/authors.txt b/basis/io/encodings/8-bit/latin1/authors.txt
new file mode 100644 (file)
index 0000000..b4bd0e7
--- /dev/null
@@ -0,0 +1 @@
+Doug Coleman
\ No newline at end of file
diff --git a/basis/io/encodings/8-bit/latin1/latin1-docs.factor b/basis/io/encodings/8-bit/latin1/latin1-docs.factor
new file mode 100644 (file)
index 0000000..90bc012
--- /dev/null
@@ -0,0 +1,13 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: help.markup help.syntax ;
+IN: io.encodings.8-bit.latin1
+
+HELP: latin1
+{ $var-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" } ;
+
+ARTICLE: "io.encodings.8-bit.latin1" "Latin1 encoding"
+"The " { $vocab-link "io.encodings.8-bit.latin1" } " vocabulary provides the " { $link latin1 } " encoding." ;
+
+ABOUT: "io.encodings.8-bit.latin1"
diff --git a/basis/io/encodings/8-bit/latin1/latin1.factor b/basis/io/encodings/8-bit/latin1/latin1.factor
new file mode 100644 (file)
index 0000000..17a2941
--- /dev/null
@@ -0,0 +1,6 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: io.encodings.8-bit ;
+IN: io.encodings.8-bit.latin1
+
+8-BIT: latin1 ISO_8859-1:1987 8859-1
diff --git a/basis/io/encodings/8-bit/latin10/authors.txt b/basis/io/encodings/8-bit/latin10/authors.txt
new file mode 100644 (file)
index 0000000..b4bd0e7
--- /dev/null
@@ -0,0 +1 @@
+Doug Coleman
\ No newline at end of file
diff --git a/basis/io/encodings/8-bit/latin10/latin10-docs.factor b/basis/io/encodings/8-bit/latin10/latin10-docs.factor
new file mode 100644 (file)
index 0000000..382b083
--- /dev/null
@@ -0,0 +1,13 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: help.markup help.syntax ;
+IN: io.encodings.8-bit.latin10
+
+HELP: latin10
+{ $var-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" } ;
+
+ARTICLE: "io.encodings.8-bit.latin10" "Latin10 encoding"
+"The " { $vocab-link "io.encodings.8-bit.latin10" } " vocabulary provides the " { $link latin10 } " encoding." ;
+
+ABOUT: "io.encodings.8-bit.latin10"
diff --git a/basis/io/encodings/8-bit/latin10/latin10.factor b/basis/io/encodings/8-bit/latin10/latin10.factor
new file mode 100644 (file)
index 0000000..86831d4
--- /dev/null
@@ -0,0 +1,6 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: io.encodings.8-bit ;
+IN: io.encodings.8-bit.latin10
+
+8-BIT: latin10 ISO-8859-16 8859-16
diff --git a/basis/io/encodings/8-bit/latin2/authors.txt b/basis/io/encodings/8-bit/latin2/authors.txt
new file mode 100644 (file)
index 0000000..b4bd0e7
--- /dev/null
@@ -0,0 +1 @@
+Doug Coleman
\ No newline at end of file
diff --git a/basis/io/encodings/8-bit/latin2/latin2-docs.factor b/basis/io/encodings/8-bit/latin2/latin2-docs.factor
new file mode 100644 (file)
index 0000000..1da488f
--- /dev/null
@@ -0,0 +1,13 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: help.markup help.syntax ;
+IN: io.encodings.8-bit.latin2
+
+HELP: latin2
+{ $var-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" } ;
+
+ARTICLE: "io.encodings.8-bit.latin2" "Latin2 encoding"
+"The " { $vocab-link "io.encodings.8-bit.latin2" }  " vocabulary provides the " { $link latin2 } " encoding." ;
+
+ABOUT: "io.encodings.8-bit.latin2"
diff --git a/basis/io/encodings/8-bit/latin2/latin2.factor b/basis/io/encodings/8-bit/latin2/latin2.factor
new file mode 100644 (file)
index 0000000..52ecc64
--- /dev/null
@@ -0,0 +1,6 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: io.encodings.8-bit ;
+IN: io.encodings.8-bit.latin2
+
+8-BIT: latin2 ISO_8859-2:1987 8859-2
diff --git a/basis/io/encodings/8-bit/latin3/authors.txt b/basis/io/encodings/8-bit/latin3/authors.txt
new file mode 100644 (file)
index 0000000..b4bd0e7
--- /dev/null
@@ -0,0 +1 @@
+Doug Coleman
\ No newline at end of file
diff --git a/basis/io/encodings/8-bit/latin3/latin3-docs.factor b/basis/io/encodings/8-bit/latin3/latin3-docs.factor
new file mode 100644 (file)
index 0000000..8cb719b
--- /dev/null
@@ -0,0 +1,13 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: help.markup help.syntax ;
+IN: io.encodings.8-bit.latin3
+
+HELP: latin3
+{ $var-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" } ;
+
+ARTICLE: "io.encodings.8-bit.latin3" "Latin3 encoding"
+"The " { $vocab-link "io.encodings.8-bit.latin3" }  " vocabulary provides the " { $link latin3 } " encoding." ;
+
+ABOUT: "io.encodings.8-bit.latin3"
diff --git a/basis/io/encodings/8-bit/latin3/latin3.factor b/basis/io/encodings/8-bit/latin3/latin3.factor
new file mode 100644 (file)
index 0000000..a9a6333
--- /dev/null
@@ -0,0 +1,6 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: io.encodings.8-bit ;
+IN: io.encodings.8-bit.latin3
+
+8-BIT: latin3 ISO_8859-3:1988 8859-3
diff --git a/basis/io/encodings/8-bit/latin4/authors.txt b/basis/io/encodings/8-bit/latin4/authors.txt
new file mode 100644 (file)
index 0000000..b4bd0e7
--- /dev/null
@@ -0,0 +1 @@
+Doug Coleman
\ No newline at end of file
diff --git a/basis/io/encodings/8-bit/latin4/latin4-docs.factor b/basis/io/encodings/8-bit/latin4/latin4-docs.factor
new file mode 100644 (file)
index 0000000..cfb53d2
--- /dev/null
@@ -0,0 +1,13 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: help.markup help.syntax ;
+IN: io.encodings.8-bit.latin4
+
+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" } ;
+
+ARTICLE: "io.encodings.8-bit.latin4" "Latin4 encoding"
+"The " { $vocab-link "io.encodings.8-bit.latin4" }  " vocabulary provides the " { $link latin4 } " encoding." ;
+
+ABOUT: "io.encodings.8-bit.latin4"
diff --git a/basis/io/encodings/8-bit/latin4/latin4.factor b/basis/io/encodings/8-bit/latin4/latin4.factor
new file mode 100644 (file)
index 0000000..34a68a8
--- /dev/null
@@ -0,0 +1,7 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: io.encodings.8-bit ;
+IN: io.encodings.8-bit.latin4
+
+8-BIT: latin4 ISO_8859-4:1988 8859-4
+
diff --git a/basis/io/encodings/8-bit/latin5/authors.txt b/basis/io/encodings/8-bit/latin5/authors.txt
new file mode 100644 (file)
index 0000000..b4bd0e7
--- /dev/null
@@ -0,0 +1 @@
+Doug Coleman
\ No newline at end of file
diff --git a/basis/io/encodings/8-bit/latin5/latin5-docs.factor b/basis/io/encodings/8-bit/latin5/latin5-docs.factor
new file mode 100644 (file)
index 0000000..60feed1
--- /dev/null
@@ -0,0 +1,13 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: help.markup help.syntax ;
+IN: io.encodings.8-bit.latin5
+
+HELP: latin5
+{ $var-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" } ;
+
+ARTICLE: "io.encodings.8-bit.latin5" "Latin5 encoding"
+"The " { $vocab-link "io.encodings.8-bit.latin5" }  " vocabulary provides the " { $link latin5 } " encoding." ;
+
+ABOUT: "io.encodings.8-bit.latin5"
diff --git a/basis/io/encodings/8-bit/latin5/latin5.factor b/basis/io/encodings/8-bit/latin5/latin5.factor
new file mode 100644 (file)
index 0000000..502c10f
--- /dev/null
@@ -0,0 +1,6 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: io.encodings.8-bit ;
+IN: io.encodings.8-bit.latin5
+
+8-BIT: latin5 ISO_8859-9:1989 8859-9
diff --git a/basis/io/encodings/8-bit/latin6/authors.txt b/basis/io/encodings/8-bit/latin6/authors.txt
new file mode 100644 (file)
index 0000000..b4bd0e7
--- /dev/null
@@ -0,0 +1 @@
+Doug Coleman
\ No newline at end of file
diff --git a/basis/io/encodings/8-bit/latin6/latin6-docs.factor b/basis/io/encodings/8-bit/latin6/latin6-docs.factor
new file mode 100644 (file)
index 0000000..f1866c3
--- /dev/null
@@ -0,0 +1,13 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: help.markup help.syntax ;
+IN: io.encodings.8-bit.latin6
+
+HELP: latin6
+{ $var-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" } ;
+
+ARTICLE: "io.encodings.8-bit.latin6" "Latin6 encoding"
+"The " { $vocab-link "io.encodings.8-bit.latin6" }  " vocabulary provides the " { $link latin6 } " encoding." ;
+
+ABOUT: "io.encodings.8-bit.latin6"
diff --git a/basis/io/encodings/8-bit/latin6/latin6.factor b/basis/io/encodings/8-bit/latin6/latin6.factor
new file mode 100644 (file)
index 0000000..5e71f75
--- /dev/null
@@ -0,0 +1,7 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: io.encodings.8-bit ;
+IN: io.encodings.8-bit.latin6
+
+8-BIT: latin6 ISO-8859-10 8859-10
+
diff --git a/basis/io/encodings/8-bit/latin7/authors.txt b/basis/io/encodings/8-bit/latin7/authors.txt
new file mode 100644 (file)
index 0000000..b4bd0e7
--- /dev/null
@@ -0,0 +1 @@
+Doug Coleman
\ No newline at end of file
diff --git a/basis/io/encodings/8-bit/latin7/latin7-docs.factor b/basis/io/encodings/8-bit/latin7/latin7-docs.factor
new file mode 100644 (file)
index 0000000..ebd5eb6
--- /dev/null
@@ -0,0 +1,13 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: help.markup help.syntax ;
+IN: io.encodings.8-bit.latin7
+
+HELP: latin7
+{ $var-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 necessary to represent Baltic Rim languages, as previous character sets were incomplete." } 
+{ $see-also "encodings-introduction" } ;
+
+ARTICLE: "io.encodings.8-bit.latin7" "Latin7 encoding"
+"The " { $vocab-link "io.encodings.8-bit.latin7" }  " vocabulary provides the " { $link latin7 } " encoding." ;
+
+ABOUT: "io.encodings.8-bit.latin7"
diff --git a/basis/io/encodings/8-bit/latin7/latin7.factor b/basis/io/encodings/8-bit/latin7/latin7.factor
new file mode 100644 (file)
index 0000000..862daae
--- /dev/null
@@ -0,0 +1,6 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: io.encodings.8-bit ;
+IN: io.encodings.8-bit.latin7
+
+8-BIT: latin7 ISO-8859-13 8859-13
diff --git a/basis/io/encodings/8-bit/latin8/authors.txt b/basis/io/encodings/8-bit/latin8/authors.txt
new file mode 100644 (file)
index 0000000..b4bd0e7
--- /dev/null
@@ -0,0 +1 @@
+Doug Coleman
\ No newline at end of file
diff --git a/basis/io/encodings/8-bit/latin8/latin8-docs.factor b/basis/io/encodings/8-bit/latin8/latin8-docs.factor
new file mode 100644 (file)
index 0000000..5dc2f1e
--- /dev/null
@@ -0,0 +1,13 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: help.markup help.syntax ;
+IN: io.encodings.8-bit.latin8
+
+HELP: latin8
+{ $var-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" } ;
+
+ARTICLE: "io.encodings.8-bit.latin8" "Latin8 encoding"
+"The " { $vocab-link "io.encodings.8-bit.latin8" }  " vocabulary provides the " { $link latin8 } " encoding." ;
+
+ABOUT: "io.encodings.8-bit.latin8"
diff --git a/basis/io/encodings/8-bit/latin8/latin8.factor b/basis/io/encodings/8-bit/latin8/latin8.factor
new file mode 100644 (file)
index 0000000..e925737
--- /dev/null
@@ -0,0 +1,6 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: io.encodings.8-bit ;
+IN: io.encodings.8-bit.latin8
+
+8-BIT: latin8 ISO-8859-14 8859-14
diff --git a/basis/io/encodings/8-bit/latin9/authors.txt b/basis/io/encodings/8-bit/latin9/authors.txt
new file mode 100644 (file)
index 0000000..b4bd0e7
--- /dev/null
@@ -0,0 +1 @@
+Doug Coleman
\ No newline at end of file
diff --git a/basis/io/encodings/8-bit/latin9/latin9-docs.factor b/basis/io/encodings/8-bit/latin9/latin9-docs.factor
new file mode 100644 (file)
index 0000000..2416db3
--- /dev/null
@@ -0,0 +1,13 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: help.markup help.syntax ;
+IN: io.encodings.8-bit.latin9
+
+HELP: latin9
+{ $var-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" } ;
+
+ARTICLE: "io.encodings.8-bit.latin9" "Latin9 encoding"
+"The " { $vocab-link "io.encodings.8-bit.latin9" }  " vocabulary provides the " { $link latin9 } " encoding." ;
+
+ABOUT: "io.encodings.8-bit.latin9"
diff --git a/basis/io/encodings/8-bit/latin9/latin9.factor b/basis/io/encodings/8-bit/latin9/latin9.factor
new file mode 100644 (file)
index 0000000..b55ecb3
--- /dev/null
@@ -0,0 +1,6 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: io.encodings.8-bit ;
+IN: io.encodings.8-bit.latin9
+
+8-BIT: latin9 ISO-8859-15 8859-15
diff --git a/basis/io/encodings/8-bit/mac-roman/authors.txt b/basis/io/encodings/8-bit/mac-roman/authors.txt
new file mode 100644 (file)
index 0000000..b4bd0e7
--- /dev/null
@@ -0,0 +1 @@
+Doug Coleman
\ No newline at end of file
diff --git a/basis/io/encodings/8-bit/mac-roman/mac-roman-docs.factor b/basis/io/encodings/8-bit/mac-roman/mac-roman-docs.factor
new file mode 100644 (file)
index 0000000..3fd00fa
--- /dev/null
@@ -0,0 +1,13 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: help.markup help.syntax ;
+IN: io.encodings.8-bit.mac-roman
+
+HELP: mac-roman
+{ $var-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" } ;
+
+ARTICLE: "io.encodings.8-bit.mac-roman" "Mac Roman encoding"
+"The " { $vocab-link "io.encodings.8-bit.mac-roman" } " vocabulary provides the " { $link mac-roman } " encoding." ;
+
+ABOUT: "io.encodings.8-bit.mac-roman"
diff --git a/basis/io/encodings/8-bit/mac-roman/mac-roman.factor b/basis/io/encodings/8-bit/mac-roman/mac-roman.factor
new file mode 100644 (file)
index 0000000..0b70765
--- /dev/null
@@ -0,0 +1,6 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: io.encodings.8-bit ;
+IN: io.encodings.8-bit.mac-roman
+
+8-BIT: mac-roman macintosh ROMAN
diff --git a/basis/io/encodings/8-bit/thai/authors.txt b/basis/io/encodings/8-bit/thai/authors.txt
new file mode 100644 (file)
index 0000000..b4bd0e7
--- /dev/null
@@ -0,0 +1 @@
+Doug Coleman
\ No newline at end of file
diff --git a/basis/io/encodings/8-bit/thai/thai-docs.factor b/basis/io/encodings/8-bit/thai/thai-docs.factor
new file mode 100644 (file)
index 0000000..5d2640b
--- /dev/null
@@ -0,0 +1,13 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: help.markup help.syntax ;
+IN: io.encodings.8-bit.thai
+
+HELP: latin/thai
+{ $var-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" } ;
+
+ARTICLE: "io.encodings.8-bit.thai" "Thai encoding"
+"The " { $vocab-link "io.encodings.8-bit.thai" }  " vocabulary provides the " { $link latin/thai } " encoding." ;
+
+ABOUT: "io.encodings.8-bit.thai"
diff --git a/basis/io/encodings/8-bit/thai/thai.factor b/basis/io/encodings/8-bit/thai/thai.factor
new file mode 100644 (file)
index 0000000..8d119f6
--- /dev/null
@@ -0,0 +1,6 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: io.encodings.8-bit ;
+IN: io.encodings.8-bit.thai
+
+8-BIT: latin/thai TIS-620 8859-11
diff --git a/basis/io/encodings/8-bit/windows-1250/authors.txt b/basis/io/encodings/8-bit/windows-1250/authors.txt
new file mode 100644 (file)
index 0000000..b4bd0e7
--- /dev/null
@@ -0,0 +1 @@
+Doug Coleman
\ No newline at end of file
diff --git a/basis/io/encodings/8-bit/windows-1250/windows-1250.factor b/basis/io/encodings/8-bit/windows-1250/windows-1250.factor
new file mode 100644 (file)
index 0000000..745ebe4
--- /dev/null
@@ -0,0 +1,6 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: io.encodings.8-bit ;
+IN: io.encodings.8-bit.windows-1250
+
+8-BIT: windows-1250 windows-1250 CP1250
diff --git a/basis/io/encodings/8-bit/windows-1251/authors.txt b/basis/io/encodings/8-bit/windows-1251/authors.txt
new file mode 100644 (file)
index 0000000..b4bd0e7
--- /dev/null
@@ -0,0 +1 @@
+Doug Coleman
\ No newline at end of file
diff --git a/basis/io/encodings/8-bit/windows-1251/windows-1251.factor b/basis/io/encodings/8-bit/windows-1251/windows-1251.factor
new file mode 100644 (file)
index 0000000..3c50d3c
--- /dev/null
@@ -0,0 +1,6 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: io.encodings.8-bit ;
+IN: io.encodings.8-bit.windows-1251
+
+8-BIT: windows-1251 windows-1251 CP1251
diff --git a/basis/io/encodings/8-bit/windows-1252/authors.txt b/basis/io/encodings/8-bit/windows-1252/authors.txt
new file mode 100644 (file)
index 0000000..b4bd0e7
--- /dev/null
@@ -0,0 +1 @@
+Doug Coleman
\ No newline at end of file
diff --git a/basis/io/encodings/8-bit/windows-1252/windows-1252-docs.factor b/basis/io/encodings/8-bit/windows-1252/windows-1252-docs.factor
new file mode 100644 (file)
index 0000000..cd9461e
--- /dev/null
@@ -0,0 +1,13 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: help.markup help.syntax ;
+IN: io.encodings.8-bit.windows-1252
+
+HELP: windows-1252
+{ $var-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" } ;
+
+ARTICLE: "io.encodings.8-bit.windows-1252" "Windows 1252 encoding"
+"The " { $vocab-link "io.encodings.8-bit.windows-1252" } " vocabulary provides the " { $link windows-1252 } " encoding." ;
+
+ABOUT: "io.encodings.8-bit.windows-1252"
diff --git a/basis/io/encodings/8-bit/windows-1252/windows-1252.factor b/basis/io/encodings/8-bit/windows-1252/windows-1252.factor
new file mode 100644 (file)
index 0000000..ddcc4df
--- /dev/null
@@ -0,0 +1,6 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: io.encodings.8-bit ;
+IN: io.encodings.8-bit.windows-1252
+
+8-BIT: windows-1252 windows-1252 CP1252
diff --git a/basis/io/encodings/8-bit/windows-1253/authors.txt b/basis/io/encodings/8-bit/windows-1253/authors.txt
new file mode 100644 (file)
index 0000000..b4bd0e7
--- /dev/null
@@ -0,0 +1 @@
+Doug Coleman
\ No newline at end of file
diff --git a/basis/io/encodings/8-bit/windows-1253/windows-1253.factor b/basis/io/encodings/8-bit/windows-1253/windows-1253.factor
new file mode 100644 (file)
index 0000000..ba335be
--- /dev/null
@@ -0,0 +1,6 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: io.encodings.8-bit ;
+IN: io.encodings.8-bit.windows-1253
+
+8-BIT: windows-1253 windows-1253 CP1253
diff --git a/basis/io/encodings/8-bit/windows-1254/authors.txt b/basis/io/encodings/8-bit/windows-1254/authors.txt
new file mode 100644 (file)
index 0000000..b4bd0e7
--- /dev/null
@@ -0,0 +1 @@
+Doug Coleman
\ No newline at end of file
diff --git a/basis/io/encodings/8-bit/windows-1254/windows-1254.factor b/basis/io/encodings/8-bit/windows-1254/windows-1254.factor
new file mode 100644 (file)
index 0000000..982d21a
--- /dev/null
@@ -0,0 +1,6 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: io.encodings.8-bit ;
+IN: io.encodings.8-bit.windows-1254
+
+8-BIT: windows-1254 windows-1254 CP1254
diff --git a/basis/io/encodings/8-bit/windows-1255/authors.txt b/basis/io/encodings/8-bit/windows-1255/authors.txt
new file mode 100644 (file)
index 0000000..b4bd0e7
--- /dev/null
@@ -0,0 +1 @@
+Doug Coleman
\ No newline at end of file
diff --git a/basis/io/encodings/8-bit/windows-1255/windows-1255.factor b/basis/io/encodings/8-bit/windows-1255/windows-1255.factor
new file mode 100644 (file)
index 0000000..952e5fe
--- /dev/null
@@ -0,0 +1,6 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: io.encodings.8-bit ;
+IN: io.encodings.8-bit.windows-1255
+
+8-BIT: windows-1255 windows-1255 CP1255
diff --git a/basis/io/encodings/8-bit/windows-1256/authors.txt b/basis/io/encodings/8-bit/windows-1256/authors.txt
new file mode 100644 (file)
index 0000000..b4bd0e7
--- /dev/null
@@ -0,0 +1 @@
+Doug Coleman
\ No newline at end of file
diff --git a/basis/io/encodings/8-bit/windows-1256/windows-1256.factor b/basis/io/encodings/8-bit/windows-1256/windows-1256.factor
new file mode 100644 (file)
index 0000000..303d25c
--- /dev/null
@@ -0,0 +1,6 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: io.encodings.8-bit ;
+IN: io.encodings.8-bit.windows-1256
+
+8-BIT: windows-1256 windows-1256 CP1256
diff --git a/basis/io/encodings/8-bit/windows-1257/authors.txt b/basis/io/encodings/8-bit/windows-1257/authors.txt
new file mode 100644 (file)
index 0000000..b4bd0e7
--- /dev/null
@@ -0,0 +1 @@
+Doug Coleman
\ No newline at end of file
diff --git a/basis/io/encodings/8-bit/windows-1257/windows-1257.factor b/basis/io/encodings/8-bit/windows-1257/windows-1257.factor
new file mode 100644 (file)
index 0000000..80b21e8
--- /dev/null
@@ -0,0 +1,6 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: io.encodings.8-bit ;
+IN: io.encodings.8-bit.windows-1257
+
+8-BIT: windows-1257 windows-1257 CP1257
diff --git a/basis/io/encodings/8-bit/windows-1258/authors.txt b/basis/io/encodings/8-bit/windows-1258/authors.txt
new file mode 100644 (file)
index 0000000..b4bd0e7
--- /dev/null
@@ -0,0 +1 @@
+Doug Coleman
\ No newline at end of file
diff --git a/basis/io/encodings/8-bit/windows-1258/windows-1258.factor b/basis/io/encodings/8-bit/windows-1258/windows-1258.factor
new file mode 100644 (file)
index 0000000..1c7bf63
--- /dev/null
@@ -0,0 +1,6 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: io.encodings.8-bit ;
+IN: io.encodings.8-bit.windows-1258
+
+8-BIT: windows-1258 windows-1258 CP1258
index 594e245a9c11328ac17ca1d22a97ca24890f8fad..a2a919da0db276e1eeb473b6420dc253ed0f3c36 100644 (file)
@@ -57,4 +57,4 @@ e>n-table [ initial-e>n ] initialize
 ascii "ANSI_X3.4-1968" register-encoding
 utf16be "UTF-16BE" register-encoding
 utf16le "UTF-16LE" register-encoding
-utf16 "UTF-16" register-encoding
\ No newline at end of file
+utf16 "UTF-16" register-encoding
index 17264267777486fc000ae91e6d7bd5daa0e7744b..7d4d7f1215f6fa89b43fd118c1e9d68faa238d6b 100644 (file)
@@ -18,7 +18,7 @@ VALUE: jis212
 "vocab:io/encodings/iso2022/212.txt" flat-file>biassoc to: jis212
 
 VALUE: ascii
-128 unique >biassoc to: ascii
+128 iota unique >biassoc to: ascii
 
 TUPLE: iso2022-state type ;
 
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 62837dae7e411cc75d30eec00e33ef1ec7ec765e..7b98788226bb53dc5dd7550d5f021425a2e2e448 100644 (file)
@@ -4,6 +4,18 @@ USING: classes help.markup help.syntax io.streams.string
 strings math calendar io.files.info io.files.info.unix ;
 IN: io.files.unix
 
+HELP: add-file-permissions
+{ $values
+     { "path" "a pathname string" }
+     { "n" integer } }
+{ $description "Ensures that the bits from " { $snippet "n" } " are set in the Unix file permissions for a given file." } ;
+
+HELP: remove-file-permissions
+{ $values
+     { "path" "a pathname string" }
+     { "n" integer } }
+{ $description "Ensures that the bits from " { $snippet "n" } " are cleared in the Unix file permissions for a given file." } ;
+
 HELP: file-group-id
 { $values
      { "path" "a pathname string" }
@@ -231,8 +243,12 @@ ARTICLE: "unix-file-permissions" "Unix file permissions"
     other-write?
     other-execute?
 }
-"Writing all file permissions:"
-{ $subsections set-file-permissions }
+"Changing file permissions:"
+{ $subsections
+    add-file-permissions
+    remove-file-permissions
+    set-file-permissions
+}
 "Writing individual file permissions:"
 { $subsections
     set-uid
index 0b52237a6d077eb3b7bbfb507a8d7a43c51d663b..eedf8de47ae35e93ef859a46bd6e359fd83902b2 100644 (file)
@@ -5,7 +5,7 @@ sequences combinators combinators.short-circuit alien.c-types
 vocabs.loader calendar calendar.unix io.files.info
 io.files.types io.backend io.directories unix unix.stat
 unix.time unix.users unix.groups classes.struct
-specialized-arrays ;
+specialized-arrays literals ;
 SPECIALIZED-ARRAY: timeval
 IN: io.files.info.unix
 
@@ -134,6 +134,9 @@ CONSTANT: OTHER-ALL     OCT: 0000007
 CONSTANT: OTHER-READ    OCT: 0000004
 CONSTANT: OTHER-WRITE   OCT: 0000002
 CONSTANT: OTHER-EXECUTE OCT: 0000001
+CONSTANT: ALL-READ      OCT: 0000444
+CONSTANT: ALL-WRITE     OCT: 0000222
+CONSTANT: ALL-EXECUTE   OCT: 0000111
 
 : uid? ( obj -- ? ) UID file-mode? ;
 : gid? ( obj -- ? ) GID file-mode? ;
@@ -176,6 +179,12 @@ CONSTANT: OTHER-EXECUTE OCT: 0000001
 : file-permissions ( path -- n )
     normalize-path file-info permissions>> ;
 
+: add-file-permissions ( path n -- )
+    over file-permissions bitor set-file-permissions ;
+
+: remove-file-permissions ( path n -- )
+    over file-permissions [ bitnot ] dip bitand set-file-permissions ;
+
 M: unix copy-file-and-info ( from to -- )
     [ copy-file ] [ swap file-permissions set-file-permissions ] 2bi ;
 
old mode 100755 (executable)
new mode 100644 (file)
index 5ae21fc..799b6dc
@@ -2,10 +2,11 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: byte-arrays math io.backend io.files.info
 io.files.windows io.files.windows.nt kernel windows.kernel32
-windows.time windows accessors alien.c-types combinators
-generalizations system alien.strings io.encodings.utf16n
-sequences splitting windows.errors fry continuations destructors
-calendar ascii combinators.short-circuit locals classes.struct
+windows.time windows.types windows accessors alien.c-types
+combinators generalizations system alien.strings
+io.encodings.utf16n sequences splitting windows.errors fry
+continuations destructors calendar ascii
+combinators.short-circuit locals classes.struct
 specialized-arrays alien.data ;
 SPECIALIZED-ARRAY: ushort
 IN: io.files.info.windows
@@ -20,7 +21,7 @@ IN: io.files.info.windows
 TUPLE: windows-file-info < file-info attributes ;
 
 : get-compressed-file-size ( path -- n )
-    "DWORD" <c-object> [ GetCompressedFileSize ] keep
+    DWORD <c-object> [ GetCompressedFileSize ] keep
     over INVALID_FILE_SIZE = [
         win32-error-string throw
     ] [
@@ -100,9 +101,9 @@ M: windows link-info ( path -- info )
 
 : volume-information ( normalized-path -- volume-name volume-serial max-component flags type )
     MAX_PATH 1 + [ <ushort-array> ] keep
-    "DWORD" <c-object>
-    "DWORD" <c-object>
-    "DWORD" <c-object>
+    DWORD <c-object>
+    DWORD <c-object>
+    DWORD <c-object>
     MAX_PATH 1 + [ <ushort-array> ] keep
     [ GetVolumeInformation win32-error=0/f ] 7 nkeep
     drop 5 nrot drop
@@ -110,9 +111,9 @@ M: windows link-info ( path -- info )
     utf16n alien>string ;
 
 : file-system-space ( normalized-path -- available-space total-space free-space )
-    "ULARGE_INTEGER" <c-object>
-    "ULARGE_INTEGER" <c-object>
-    "ULARGE_INTEGER" <c-object>
+    ULARGE_INTEGER <c-object>
+    ULARGE_INTEGER <c-object>
+    ULARGE_INTEGER <c-object>
     [ GetDiskFreeSpaceEx win32-error=0/f ] 3keep ;
 
 : calculate-file-system-info ( file-system-info -- file-system-info' )
@@ -151,13 +152,17 @@ PRIVATE>
 M: winnt file-system-info ( path -- file-system-info )
     normalize-path root-directory (file-system-info) ;
 
-: volume>paths ( string -- array )
-    16384 <ushort-array> tuck dup length
-    0 <uint> dup [ GetVolumePathNamesForVolumeName 0 = ] dip swap [
-        win32-error-string throw
+:: volume>paths ( string -- array )
+    16384 :> names-buf-length
+    names-buf-length <ushort-array> :> names
+    0 <uint> :> names-length
+
+    string names names-buf-length names-length GetVolumePathNamesForVolumeName :> ret
+    ret 0 = [
+        ret win32-error-string throw
     ] [
-        *uint "ushort" heap-size * head
-        utf16n alien>string CHAR: \0 split
+        names names-length *uint ushort heap-size * head
+        utf16n alien>string { CHAR: \0 } split
     ] if ;
 
 : find-first-volume ( -- string handle )
@@ -166,13 +171,16 @@ M: winnt file-system-info ( path -- file-system-info )
     FindFirstVolume dup win32-error=0/f
     [ utf16n alien>string ] dip ;
 
-: find-next-volume ( handle -- string/f )
-    MAX_PATH 1 + [ <ushort-array> tuck ] keep
-    FindNextVolume 0 = [
+:: find-next-volume ( handle -- string/f )
+    MAX_PATH 1 + :> buf-length
+    buf-length <ushort-array> :> buf
+
+    handle buf buf-length FindNextVolume :> ret
+    ret 0 = [
         GetLastError ERROR_NO_MORE_FILES =
-        [ drop f ] [ win32-error-string throw ] if
+        [ f ] [ win32-error-string throw ] if
     ] [
-        utf16n alien>string
+        buf utf16n alien>string
     ] if ;
 
 : find-volumes ( -- array )
index ef7d778abe7ae439b2ce4c35e6a81bc66b92b15c..23de95f519c591a9c83147d45b6e88e811e2905b 100644 (file)
@@ -4,7 +4,7 @@ io.pathnames namespaces ;
 IN: io.files.links.unix.tests
 
 : make-test-links ( n path -- )
-    [ '[ [ 1 + ] keep [ number>string _ prepend ] bi@ make-link ] each ]
+    [ '[ [ 1 + ] keep [ number>string _ prepend ] bi@ make-link ] each-integer ]
     [ [ number>string ] dip prepend touch-file ] 2bi ; inline
 
 [ t ] [
index f167b1e99ba32f387a454e03f379fe662c71ddde..07f7b25140bdc192da95247e2ae6b589c81e75ae 100644 (file)
@@ -35,8 +35,8 @@ SYMBOL: unique-retries
 : random-name ( -- string )
     unique-length get [ random-ch ] "" replicate-as ;
 
-: retry ( quot: ( -- ? )  n -- )
-    swap [ drop ] prepose attempt-all ; inline
+: retry ( quot: ( -- ? ) n -- )
+    iota swap [ drop ] prepose attempt-all ; inline
 
 : (make-unique-file) ( path prefix suffix -- path )
     '[
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index ca5c9b3..c4c848c
@@ -3,10 +3,10 @@
 USING: alien.c-types io.binary io.backend io.files
 io.files.types io.buffers io.encodings.utf16n io.ports
 io.backend.windows kernel math splitting fry alien.strings
-windows windows.kernel32 windows.time calendar combinators
-math.functions sequences namespaces make words system
-destructors accessors math.bitwise continuations windows.errors
-arrays byte-arrays generalizations alien.data ;
+windows windows.kernel32 windows.time windows.types calendar
+combinators math.functions sequences namespaces make words
+system destructors accessors math.bitwise continuations
+windows.errors arrays byte-arrays generalizations alien.data ;
 IN: io.files.windows
 
 : open-file ( path access-mode create-mode flags -- handle )
@@ -64,7 +64,7 @@ C: <FileArgs> FileArgs
         [ handle>> handle>> ]
         [ buffer>> ]
         [ buffer>> buffer-length ]
-        [ drop "DWORD" <c-object> ]
+        [ drop DWORD <c-object> ]
         [ FileArgs-overlapped ]
     } cleave <FileArgs> ;
 
old mode 100755 (executable)
new mode 100644 (file)
index 3432578..cb20f78
@@ -75,15 +75,13 @@ SYMBOL: wait-flag
 [
     H{ } clone processes set-global
     start-wait-thread
-] "io.launcher" add-init-hook
+] "io.launcher" add-startup-hook
 
 : process-started ( process handle -- )
     >>handle
     V{ } clone swap processes get set-at
     wait-flag get-global raise-flag ;
 
-M: process hashcode* handle>> hashcode* ;
-
 : pass-environment? ( process -- ? )
     dup environment>> assoc-empty? not
     swap environment-mode>> +replace-environment+ eq? or ;
index 7fa7f4b2c68d0357dd8ecb17ce6de04815130ba3..4304f5f62a07e7f707144bcc0325b13b33454c9d 100644 (file)
@@ -3,7 +3,7 @@ USING: io.files io.files.temp io.directories io.pathnames
 tools.test io.launcher arrays io namespaces continuations math
 io.encodings.binary io.encodings.ascii accessors kernel
 sequences io.encodings.utf8 destructors io.streams.duplex locals
-concurrency.promises threads unix.process ;
+concurrency.promises threads unix.process calendar ;
 
 [ ] [
     [ "launcher-test-1" temp-file delete-file ] ignore-errors
@@ -128,12 +128,13 @@ concurrency.promises threads unix.process ;
     [let 
         <promise> :> p
         <promise> :> s
+
         [
             "sleep 1000" run-detached
             [ p fulfill ] [ wait-for-process s fulfill ] bi
         ] in-thread
 
-        p ?promise handle>> 9 kill drop
+        p 1 seconds ?promise-timeout handle>> 9 kill drop
         s ?promise 0 =
     ]
 ] unit-test
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 6cae50b..8a80011
@@ -132,7 +132,7 @@ M: windows run-process* ( process -- handle )
         current-directory get absolute-path cd
 
         dup make-CreateProcess-args
-        tuck fill-redirection
+        [ fill-redirection ] keep
         dup call-CreateProcess
         lpProcessInformation>>
     ] with-destructors ;
index 33ba6850a531ce900935db4d7b37295fb99a897d..3eabfc4e7f488ffcfaba331647bca810e6c91eba 100644 (file)
@@ -87,7 +87,6 @@ ARTICLE: "io.mmap.examples" "Memory-mapped file examples"
 "Normalize a file containing packed quadrupes of floats:"
 { $code
     "USING: kernel io.mmap math.vectors math.vectors.simd" "sequences specialized-arrays ;"
-    "SIMD: float"
     "SPECIALIZED-ARRAY: float-4"
     ""
     "\"mydata.dat\" float-4 ["
old mode 100755 (executable)
new mode 100644 (file)
index cec03cf6d33364a19be7978d2f25f8efc61038bb..7fce8b4de22bcab96332a5205a7cc11922ab10cf 100644 (file)
@@ -35,7 +35,7 @@ IN: io.pipes.windows.nt
         "-" %
         32 random-bits #
         "-" %
-        micros #
+        nano-count #
     ] "" make ;
 
 M: winnt (pipe) ( -- pipe )
index 3ea4c105f5009a651450a88f1570e285a956a6fa..727d69adf8d2382415a1c18ff6962c6040c1159f 100644 (file)
@@ -27,7 +27,7 @@ TUPLE: buffered-port < port { buffer buffer } ;
 
 TUPLE: input-port < buffered-port ;
 
-M: input-port stream-element-type drop +byte+ ;
+M: input-port stream-element-type drop +byte+ ; inline
 
 : <input-port> ( handle -- input-port )
     input-port <buffered-port> ;
@@ -104,7 +104,7 @@ TUPLE: output-port < buffered-port ;
     [ nip ] [ buffer>> buffer-capacity <= ] 2bi
     [ drop ] [ stream-flush ] if ; inline
 
-M: output-port stream-element-type stream>> stream-element-type ;
+M: output-port stream-element-type stream>> stream-element-type ; inline
 
 M: output-port stream-write1
     dup check-disposed
index 345b739b613eb2bd28f550229e68c05c7b754658..fdd42352daca7cbf0e1b1beed7a51f0d76057980 100644 (file)
@@ -96,7 +96,7 @@ M: threaded-server handle-client* handler>> call( -- ) ;
         [ [ accept-connection ] with-semaphore ]
         [ accept-connection ]
         if*
-    ] [ accept-loop ] bi ; inline recursive
+    ] [ accept-loop ] bi ;
 
 : started-accept-loop ( threaded-server -- )
     threaded-server get
diff --git a/basis/io/servers/packet/authors.txt b/basis/io/servers/packet/authors.txt
deleted file mode 100755 (executable)
index 1901f27..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Slava Pestov
diff --git a/basis/io/servers/packet/packet.factor b/basis/io/servers/packet/packet.factor
deleted file mode 100644 (file)
index 2a346b4..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-USING: concurrency.combinators destructors fry
-io.sockets kernel logging ;
-IN: io.servers.packet
-
-<PRIVATE
-
-LOG: received-datagram NOTICE
-
-: datagram-loop ( quot datagram -- )
-    [
-        [ receive dup received-datagram [ swap call ] dip ] keep
-        pick [ send ] [ 3drop ] if
-    ] 2keep datagram-loop ; inline
-
-: spawn-datagrams ( quot addrspec -- )
-    <datagram> [ datagram-loop ] with-disposal ; inline
-
-\ spawn-datagrams NOTICE add-input-logging
-
-PRIVATE>
-
-: with-datagrams ( seq service quot -- )
-    '[ [ [ _ ] dip spawn-datagrams ] parallel-each ] with-logging ; inline
diff --git a/basis/io/servers/packet/summary.txt b/basis/io/servers/packet/summary.txt
deleted file mode 100644 (file)
index 29247a2..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Multi-threaded UDP/IP servers
diff --git a/basis/io/servers/packet/tags.txt b/basis/io/servers/packet/tags.txt
deleted file mode 100644 (file)
index 992ae12..0000000
+++ /dev/null
@@ -1 +0,0 @@
-network
index 12f907acb59c6b108158d92ee2ea54a2b9835bda..b3cf28a497909e1b22c91992d15e82157f3e10df 100644 (file)
@@ -5,7 +5,7 @@ math.order combinators init alien alien.c-types alien.data
 alien.strings libc continuations destructors summary splitting
 assocs random math.parser locals unicode.case openssl
 openssl.libcrypto openssl.libssl io.backend io.ports io.pathnames
-io.encodings.8-bit io.timeouts io.sockets.secure ;
+io.encodings.8-bit.latin1 io.timeouts io.sockets.secure ;
 IN: io.sockets.secure.openssl
 
 GENERIC: ssl-method ( symbol -- method )
index fb8332dffb3b41159e39f42e910c8a7ced46f3b2..8cc6ef731dfbc6da8eb17d5dd8ef25b493108dd2 100644 (file)
@@ -155,7 +155,7 @@ HELP: with-client
 HELP: <server>
 { $values  { "addrspec" "an address specifier" } { "encoding" "an encoding descriptor" } { "server" "a handle" } }
 { $description
-    "Begins listening for network connections to a local address. Server objects responds to two words:"
+    "Begins listening for network connections to a local address. Server objects respond to two words:"
     { $list
         { { $link dispose } " - stops listening on the port and frees all associated resources" }
         { { $link accept } " - blocks until there is a connection, and returns a stream of the encoding passed to the constructor" }
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 6bf62a0..cdf7e54
@@ -17,7 +17,7 @@ IN: io.sockets.unix
     0 socket dup io-error <fd> init-fd |dispose ;
 
 : set-socket-option ( fd level opt -- )
-    [ handle-fd ] 2dip 1 <int> "int" heap-size setsockopt io-error ;
+    [ handle-fd ] 2dip 1 <int> dup byte-length setsockopt io-error ;
 
 M: unix addrinfo-error ( n -- )
     [ gai_strerror throw ] unless-zero ;
@@ -117,7 +117,7 @@ SYMBOL: receive-buffer
 
 CONSTANT: packet-size 65536
 
-[ packet-size malloc receive-buffer set-global ] "io.sockets.unix" add-init-hook
+[ packet-size malloc &free receive-buffer set-global ] "io.sockets.unix" add-startup-hook
 
 :: do-receive ( port -- packet sockaddr )
     port addr>> empty-sockaddr/size :> ( sockaddr len )
old mode 100755 (executable)
new mode 100644 (file)
index 7cc21c9..0dd8595
@@ -3,7 +3,8 @@ continuations destructors io.ports io.timeouts io.sockets
 io.sockets.private io namespaces io.streams.duplex
 io.backend.windows io.sockets.windows io.backend.windows.nt
 windows.winsock kernel libc math sequences threads system
-combinators accessors classes.struct windows.kernel32 ;
+combinators accessors classes.struct windows.kernel32
+windows.types ;
 IN: io.sockets.windows.nt
 
 : malloc-int ( n -- alien )
@@ -16,10 +17,10 @@ M: winnt WSASocket-flags ( -- DWORD )
     SIO_GET_EXTENSION_FUNCTION_POINTER
     WSAID_CONNECTEX
     GUID heap-size
-    "void*" <c-object>
+    void* <c-object>
     [
-        "void*" heap-size
-        "DWORD" <c-object>
+        void* heap-size
+        DWORD <c-object>
         f
         f
         WSAIoctl SOCKET_ERROR = [
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 022d20eb5e9e1effb7b90aa4c20c68fb911b07ad..047cd117a02907da5c659f391a695d5bd8fcdea1 100644 (file)
@@ -1,8 +1,9 @@
 USING: accessors continuations destructors io io.encodings
-io.encodings.8-bit io.encodings.ascii io.encodings.binary
+io.encodings.ascii io.encodings.binary
 io.encodings.string io.encodings.utf8 io.files io.pipes
 io.streams.byte-array io.streams.limited io.streams.string
-kernel namespaces strings tools.test system ;
+kernel namespaces strings tools.test system
+io.encodings.8-bit.latin1 ;
 IN: io.streams.limited.tests
 
 [ ] [
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 88db135f447c24975117ee9a579dddb384bae4a1..994dcd9c501f81d07dfe571f8a4b0f6f29432936 100644 (file)
@@ -17,4 +17,4 @@ SYMBOL: io-thread-running?
 [\r
     t io-thread-running? set-global\r
     start-io-thread\r
-] "io.thread" add-init-hook\r
+] "io.thread" add-startup-hook\r
old mode 100755 (executable)
new mode 100644 (file)
index b3894d7b496dfe867554160baa3994c7a0f5cb31..ca339a78ef2c3ea8308464118187942a1d6f2b0b 100644 (file)
@@ -1,7 +1,7 @@
 USING: iokit alien alien.syntax alien.c-types kernel system
 core-foundation core-foundation.arrays core-foundation.data
 core-foundation.dictionaries core-foundation.run-loop
-core-foundation.strings core-foundation.time ;
+core-foundation.strings core-foundation.time unix.types ;
 IN: iokit.hid
 
 CONSTANT: kIOHIDDeviceKey "IOHIDDevice"
old mode 100755 (executable)
new mode 100644 (file)
index 529db6b..2b31e5c
@@ -1,6 +1,6 @@
 USING: alien.syntax alien.c-types core-foundation
 core-foundation.bundles core-foundation.dictionaries system
-combinators kernel sequences io accessors ;
+combinators kernel sequences io accessors unix.types ;
 IN: iokit
 
 <<
@@ -99,19 +99,6 @@ CONSTANT: kOSBuildVersionKey   "OS Build Version"
 
 CONSTANT: kNilOptions 0
 
-TYPEDEF: uint mach_port_t
-TYPEDEF: int kern_return_t
-TYPEDEF: int boolean_t
-TYPEDEF: mach_port_t io_object_t
-TYPEDEF: io_object_t io_iterator_t
-TYPEDEF: io_object_t io_registry_entry_t
-TYPEDEF: io_object_t io_service_t
-TYPEDEF: char[128] io_name_t
-TYPEDEF: char[512] io_string_t
-TYPEDEF: kern_return_t IOReturn
-
-TYPEDEF: uint IOOptionBits
-
 CONSTANT: MACH_PORT_NULL 0
 CONSTANT: KERN_SUCCESS 0
 
index 79a0e4b5af1bab825907a1ae831baf7aeb7825bc..390fce1f949e77a93e0ce6e5389f4bab6cb5a833 100644 (file)
@@ -1,4 +1,4 @@
-USING: arrays json.reader kernel strings tools.test
+USING: assocs arrays json.reader kernel strings tools.test
 hashtables json ;
 IN: json.reader.tests
 
@@ -58,3 +58,6 @@ IN: json.reader.tests
 { 0 } [ "      0" json> ] unit-test
 { 0 } [ "0      " json> ] unit-test
 { 0 } [ "   0   " json> ] unit-test
+
+! empty objects are allowed as values in objects
+{ H{ { "foo" H{ } } } } [ "{ \"foo\" : {}}" json> ] unit-test
index bdfeaa3e5126c01001a3dda8c60be3ba2f3a4bfb..082bbd84468be2943e70146ac5c346779f67e94d 100644 (file)
@@ -15,7 +15,7 @@ IN: json.reader
     ] dip ;
 
 DEFER: j-string
-    
+
 : convert-string ( str -- str )
     read1
     {
@@ -30,17 +30,17 @@ DEFER: j-string
     dup
     [ 1string append j-string append ]
     [ drop ] if ;
-    
+
 : j-string ( -- str )
     "\\\"" read-until CHAR: \" =
     [ convert-string ] unless ;
-    
+
 : second-last ( seq -- second-last )
     [ length 2 - ] keep nth ; inline
 
 : third-last ( seq -- third-last )
     [ length 3 - ] keep nth ; inline
-    
+
 : last2 ( seq -- second-last last )
     [ second-last ] [ last ] bi ; inline
 
@@ -68,12 +68,12 @@ DEFER: j-string
     dup pop >array over push ;
 
 : (close-hash) ( accum -- accum' )
-    dup length 3 >= [ v-over-push ] when
-    dup dup [ pop ] dip pop swap
+    dup [ length 3 >= ] [ last V{ } = not ] bi@ and [ v-over-push ] when
+    dup dup [ pop ] bi@ swap
     zip H{ } assoc-clone-like over push ;
-                                                 
+
 : scan ( accum char -- accum )
-    ! 2dup . . ! Great for debug...
+    ! 2dup 1string swap . . ! Great for debug...
     [
         {
             { CHAR: \" [ j-string over push ] }
@@ -91,13 +91,13 @@ DEFER: j-string
             { CHAR: f  [ 4 read drop f over push ] }
             { CHAR: n  [ 3 read drop json-null over push ] }
             [ value [ over push ] dip [ scan ] when*  ]
-        } case 
+        } case
     ] when* ;
 
 : (json-parser>) ( string -- object )
     [ V{ } clone [ read1 dup ] [ scan ] while drop first ] with-string-reader ;
-    
+
 PRIVATE>
-    
+
 : json> ( string -- object )
     (json-parser>) ;
index 0c2ed34f453b99958081ada4476fc5592c23d30e..2ee662c0ac5698fb2c65bcb80d4fa81cee53ee16 100644 (file)
@@ -3,4 +3,4 @@
 USING: lcs.diff2html lcs kernel tools.test strings sequences xml.writer ;
 IN: lcs.diff2html.tests
 
-[ ] [ "hello" "heyo" [ 1string ] { } map-as diff htmlize-diff xml>string drop ] unit-test
+[ ] [ "hello" "heyo" [ [ 1string ] { } map-as ] bi@ diff htmlize-diff xml>string drop ] unit-test
index ca9e48eb057623509324bba81db54a788ff0baeb..545610a0ea2a90c66bb7b521982fba57483f5811 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2008 Slava Pestov
+! Copyright (C) 2008, 2010 Slava Pestov
 ! See http://factorcode.org/license.txt for BSD license.
 USING: lcs xml.syntax xml.writer kernel strings ;
 FROM: accessors => item>> ;
index 38920f5764669daffbb2d6f07602de6dca37b27f..5861d90dc377492cff651147e6af2a8f65957aa8 100644 (file)
@@ -19,15 +19,15 @@ IN: lcs
     i 1 + j 1 + matrix nth set-nth ; inline\r
 \r
 : lcs-initialize ( |str1| |str2| -- matrix )\r
-    [ drop 0 <array> ] with map ;\r
+    iota [ drop 0 <array> ] with map ;\r
 \r
 : levenshtein-initialize ( |str1| |str2| -- matrix )\r
-    [ [ + ] curry map ] with map ;\r
+    [ iota ] bi@ [ [ + ] curry map ] with map ;\r
 \r
 :: run-lcs ( old new init step -- matrix )\r
     old length 1 + new length 1 + init call :> matrix\r
-    old length [| i |\r
-        new length\r
+    old length iota [| i |\r
+        new length iota\r
         [| j | i j matrix old new step loop-step ] each\r
     ] each matrix ; inline\r
 PRIVATE>\r
index 8fb638b8566992c52016260beeec9aa137d8b153..39f92158a68bbff851097c1b6a8f6fe70e2248ed 100644 (file)
@@ -35,5 +35,7 @@ IN: lists.lazy.tests
 [ [ drop ] leach ] must-infer
 [ lnth ] must-infer
 
+[ { 1 2 3 } ] [ { 1 2 3 4 5 } >list [ 2 > ] luntil list>array ] unit-test
+
 [ ] [ "resource:license.txt" utf8 <file-reader> llines list>array drop ] unit-test
 [ ] [ "resource:license.txt" utf8 <file-reader> lcontents list>array drop ] unit-test
index 7b386e9c819ea1acfc93988b97227fcfb8666355..122a2205dd27664e73877879862cfde7c8daf908 100644 (file)
@@ -111,14 +111,15 @@ C: <lazy-until> lazy-until
     over nil? [ drop ] [ <lazy-until> ] if ;
 
 M: lazy-until car ( lazy-until -- car )
-     cons>> car ;
+    cons>> car ;
 
 M: lazy-until cdr ( lazy-until -- cdr )
-     [ cons>> unswons ] keep quot>> tuck call( elt -- ? )
-     [ 2drop nil ] [ luntil ] if ;
+    [ [ cons>> cdr ] [ quot>> ] bi ]
+    [ [ cons>> car ] [ quot>> ] bi call( elt -- ? ) ] bi
+    [ 2drop nil ] [ luntil ] if ;
 
 M: lazy-until nil? ( lazy-until -- ? )
-     drop f ;
+    drop f ;
 
 TUPLE: lazy-while cons quot ;
 
@@ -128,13 +129,13 @@ C: <lazy-while> lazy-while
     over nil? [ drop ] [ <lazy-while> ] if ;
 
 M: lazy-while car ( lazy-while -- car )
-     cons>> car ;
+    cons>> car ;
 
 M: lazy-while cdr ( lazy-while -- cdr )
-     [ cons>> cdr ] keep quot>> lwhile ;
+    [ cons>> cdr ] keep quot>> lwhile ;
 
 M: lazy-while nil? ( lazy-while -- ? )
-     [ car ] keep quot>> call( elt -- ? ) not ;
+    [ car ] keep quot>> call( elt -- ? ) not ;
 
 TUPLE: lazy-filter cons quot ;
 
index 7fba57a4bbfb3421dfa998663449df73d29f1600..53fde946872390a1e3b7365477e89994247220f6 100644 (file)
@@ -44,7 +44,6 @@ ARTICLE: { "lists" "combinators" } "Combinators for lists"
     foldl
     foldr
     lmap>array
-    traverse
 } ;
 
 ARTICLE: { "lists" "manipulation" } "Manipulating lists"
@@ -151,12 +150,6 @@ HELP: list>array
 { $values { "list" list } { "array" array } }
 { $description "Convert a list into an array." } ;
 
-HELP: traverse    
-{ $values { "list"  list } { "pred" { $quotation "( list/elt -- ? )" } }
-          { "quot" { $quotation "( list/elt -- result)" } }  { "result" "a new cons object" } }
-{ $description "Recursively traverses the list object, replacing any elements (which can themselves be sublists) that pred" 
- " returns true for with the result of applying quot to." } ;
-
 HELP: list
 { $class-description "The class of lists. All lists are expected to conform to " { $link { "lists" "protocol" } } "." } ;
 
index ddf1ab91098e2e7abab454a4424775fbc4af404b..f3475f960b54077a42142167f7d01a0991e256d5 100644 (file)
@@ -93,11 +93,5 @@ PRIVATE>
 : list>array ( list -- array )  
     [ ] lmap>array ;
 
-:: traverse ( list pred quot: ( list/elt -- result ) -- result )
-    list [| elt |
-        elt dup pred call [ quot call ] when
-        dup list? [ pred quot traverse ] when
-    ] lmap ; inline recursive
-
 INSTANCE: cons list
 INSTANCE: +nil+ list
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index ff6a491a79d7e2d13e8df2687633fa71ac1dba71..a2a1a6c17820ea684203978cdba1e4544b9694fc 100644 (file)
@@ -1,18 +1,21 @@
 ! Copyright (C) 2007, 2008 Slava Pestov, Eduardo Cavazos.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors fry fry.private generalizations kernel
-locals.types make sequences ;
+locals.types sequences ;
 IN: locals.fry
 
 ! Support for mixing locals with fry
 
 M: let count-inputs body>> count-inputs ;
-
 M: lambda count-inputs body>> count-inputs ;
 
-M: lambda deep-fry
-    clone [ shallow-fry swap ] change-body
-    [ [ vars>> length ] keep '[ _ _ mnswap @ ] , ] [ drop [ncurry] % ] 2bi ;
+M: lambda fry
+    clone [ [ count-inputs ] [ fry ] bi ] change-body
+    [ [ vars>> length ] keep '[ _ _ mnswap _ call ] ]
+    [ drop [ncurry] curry [ call ] compose ] 2bi ;
+
+M: let fry
+    clone [ fry ] change-body ;
 
-M: let deep-fry
-    clone [ fry '[ @ call ] ] change-body , ;
+INSTANCE: lambda fried
+INSTANCE: let    fried
index 581ed5de33329912f4acbbf9710b790346cdc833..7aa8032cddeefbdaf7d0e5d2abd5716a79758d73 100644 (file)
@@ -389,7 +389,7 @@ M:: integer lambda-method-forget-test ( a -- b ) a ;
     eval( -- ) call
 ] [ error>> >r/r>-in-fry-error? ] must-fail-with
     
-:: (funny-macro-test) ( obj quot -- ? ) obj { quot } 1&& ; inline
+:: (funny-macro-test) ( obj quot -- ? ) obj { [ quot call ] } 1&& ; inline
 : funny-macro-test ( n -- ? ) [ odd? ] (funny-macro-test) ;
 
 \ funny-macro-test def>> must-infer
index e64693f2a364588820836f4a08215cfcf6cd2aec..1f9525e5ebbe42259eebc02c40036cc940a7d4e8 100644 (file)
@@ -14,4 +14,4 @@ M: let expand-macros* expand-macros literal ;
 
 M: lambda condomize? drop t ;
 
-M: lambda condomize '[ @ ] ;
+M: lambda condomize [ call ] curry ;
old mode 100755 (executable)
new mode 100644 (file)
index 848ad5d40e8d160b8001d780c4ff3e7b189b5e74..f5539b281325aeae295f86e3aa308bee4c254b12 100644 (file)
@@ -106,4 +106,4 @@ CONSTANT: keep-logs 10
 [\r
     H{ } clone log-files set-global\r
     log-server\r
-] "logging" add-init-hook\r
+] "logging" add-startup-hook\r
index 25f754e92af46ca874d2ed42f67f13d978cac1cf..3dab0c3cdb12a25a299b5aa0714356a178a44ca3 100644 (file)
@@ -49,7 +49,7 @@ M: wrapper expand-macros* wrapped>> literal ;
     stack get pop end
     [ [ expand-macros ] [ ] map-as '[ _ dip ] % ]
     [
-        length [ <reversed> ] keep
+        length iota [ <reversed> ] keep
         [ '[ _ ndrop _ nnip call ] [ ] like ] 2map , \ dispatch ,
     ] bi ;
 
old mode 100755 (executable)
new mode 100644 (file)
index 0e5ef30f51cf4a13d77a0071cb63a49bff5b75f9..0186f6181f802b18337c04204617cf71b1e96d0f 100644 (file)
@@ -1,7 +1,8 @@
 ! Copyright (C) 2007, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: parser kernel sequences words effects combinators assocs
-definitions quotations namespaces memoize accessors ;
+definitions quotations namespaces memoize accessors
+compiler.units ;
 IN: macros
 
 <PRIVATE
@@ -28,3 +29,5 @@ M: macro definition "macro" word-prop ;
 
 M: macro reset-word
     [ call-next-method ] [ f "macro" set-word-prop ] bi ;
+
+M: macro bump-effect-counter* drop t ;
old mode 100755 (executable)
new mode 100644 (file)
index d10e4ccc87df42a1f1599e01191420bd93a2f81a..a5919d3ec30bedca953e789e698b4ac60a4422e2 100644 (file)
@@ -41,7 +41,6 @@ CONSTANT: b 2
 [ 0 ] [ BIN: 0 bit-count ] unit-test
 [ 1 ] [ BIN: 1 bit-count ] unit-test
 
-SIMD: uint
 SPECIALIZED-ARRAY: uint
 SPECIALIZED-ARRAY: uint-4
 
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 8d057de..0834002
@@ -78,10 +78,10 @@ PRIVATE>
 : n*V+V ( alpha x y -- alpha*x+y ) clone n*V+V! ; inline
 : n*V ( alpha x -- alpha*x ) clone n*V! ; inline
 
-: V+ ( x y -- x+y )
-    1.0 -rot n*V+V ; inline
-: V- ( x y -- x-y )
-    -1.0 spin n*V+V ; inline
+:: V+ ( x y -- x+y )
+    1.0 x y n*V+V ; inline
+:: V- ( x y -- x-y )
+    -1.0 y x n*V+V ; inline
 
 : Vneg ( x -- -x )
     -1.0 swap n*V ; inline
@@ -117,7 +117,7 @@ M: blas-vector-base equal?
 
 M: blas-vector-base length
     length>> ;
-M: blas-vector-base virtual-seq
+M: blas-vector-base virtual-exemplar
     (blas-direct-array) ;
 M: blas-vector-base virtual@
     [ inc>> * ] [ nip (blas-direct-array) ] 2bi ;
index 10584f2004da48505c8061ff0b30cddc6bc1c218..ec3cd6ee76c9f96847106d463e918ded20e5dd24 100644 (file)
@@ -31,7 +31,7 @@ HELP: permutation
 { $notes "Permutations are 0-based and a bounds error will be thrown if " { $snippet "n" } " is larger than " { $snippet "seq length factorial 1 -" } "." }
 { $examples
     { $example "USING: math.combinatorics prettyprint ;"
-        "1 3 permutation ." "{ 0 2 1 }" }
+        "1 { 0 1 2 } permutation ." "{ 0 2 1 }" }
     { $example "USING: math.combinatorics prettyprint ;"
         "5 { \"apple\" \"banana\" \"orange\" } permutation ." "{ \"orange\" \"banana\" \"apple\" }" }
 } ;
@@ -41,7 +41,7 @@ HELP: all-permutations
 { $description "Outputs a sequence containing all permutations of " { $snippet "seq" } " in lexicographical order." }
 { $examples
     { $example "USING: math.combinatorics prettyprint ;"
-        "3 all-permutations ." "{ { 0 1 2 } { 0 2 1 } { 1 0 2 } { 1 2 0 } { 2 0 1 } { 2 1 0 } }" }
+        "{ 0 1 2 } all-permutations ." "{ { 0 1 2 } { 0 2 1 } { 1 0 2 } { 1 2 0 } { 2 0 1 } { 2 1 0 } }" }
 } ;
 
 HELP: each-permutation
index ca6ec9cb53c02d0d5722d8bf70eae70bfd3cd4b9..bbf5a1cb85bfaa08a35f581ae18faeb1288fe959 100644 (file)
@@ -56,7 +56,7 @@ IN: math.combinatorics.tests
 [ 0 ] [ 9 5 iota 3 <combo> dual-index ] unit-test
 [ 179 ] [ 72 10 iota 5 <combo> dual-index ] unit-test
 
-[ { 5 3 2 1 } ] [ 7 4 <combo> 8 combinadic ] unit-test
+[ { 5 3 2 1 } ] [ 7 iota 4 <combo> 8 combinadic ] unit-test
 [ { 4 3 2 1 0 } ] [ 10 iota 5 <combo> 0 combinadic ] unit-test
 [ { 8 6 3 1 0 } ] [ 10 iota 5 <combo> 72 combinadic ] unit-test
 [ { 9 8 7 6 5 } ] [ 10 iota 5 <combo> 251 combinadic ] unit-test
index bc09f9fe0fa9b609147c751e7eb01a8e05fba3bc..7c68aede094572249bf1049292b05b47ceca4a3a 100644 (file)
@@ -1,7 +1,7 @@
-! Copyright (c) 2007-2009 Slava Pestov, Doug Coleman, Aaron Schaefer.
+! Copyright (c) 2007-2010 Slava Pestov, Doug Coleman, Aaron Schaefer.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors assocs binary-search fry kernel locals math math.order
-    math.ranges mirrors namespaces sequences sorting ;
+    math.ranges namespaces sequences sorting ;
 IN: math.combinatorics
 
 <PRIVATE
@@ -15,7 +15,7 @@ IN: math.combinatorics
 PRIVATE>
 
 : factorial ( n -- n! )
-    1 [ 1 + * ] reduce ;
+    iota 1 [ 1 + * ] reduce ;
 
 : nPk ( n k -- nPk )
     2dup possible? [ dupd - [a,b) product ] [ 2drop 0 ] if ;
@@ -46,11 +46,11 @@ PRIVATE>
     [ permutation-indices ] keep nths ;
 
 : all-permutations ( seq -- seq )
-    [ length factorial ] keep
+    [ length factorial iota ] keep
     '[ _ permutation ] map ;
 
 : each-permutation ( seq quot -- )
-    [ [ length factorial ] keep ] dip
+    [ [ length factorial iota ] keep ] dip
     '[ _ permutation @ ] each ; inline
 
 : reduce-permutations ( seq identity quot -- result )
@@ -77,7 +77,7 @@ C: <combo> combo
     dup 0 = [
         drop 1 - nip
     ] [
-        [ [0,b) ] 2dip '[ _ nCk _ >=< ] search nip
+        [ iota ] 2dip '[ _ nCk _ >=< ] search nip
     ] if ;
 
 :: next-values ( a b x -- a' b' x' v )
@@ -96,30 +96,33 @@ C: <combo> combo
     initial-values [ over 0 > ] [ next-values ] produce
     [ 3drop ] dip ;
 
-: combination-indices ( m combo -- seq )
-    [ tuck dual-index combinadic ] keep
-    seq>> length 1 - swap [ - ] with map ;
+:: combination-indices ( m combo -- seq )
+    combo m combo dual-index combinadic
+    combo seq>> length 1 - swap [ - ] with map ;
 
 : apply-combination ( m combo -- seq )
     [ combination-indices ] keep seq>> nths ;
 
+: combinations-quot ( seq k quot -- seq quot )
+    [ <combo> [ choose iota ] keep ] dip
+    '[ _ apply-combination @ ] ; inline
+
 PRIVATE>
 
+: each-combination ( seq k quot -- )
+    combinations-quot each ; inline
+
+: map-combinations ( seq k quot -- )
+    combinations-quot map ; inline
+
+: map>assoc-combinations ( seq k quot exemplar -- )
+    [ combinations-quot ] dip map>assoc ; inline
+
 : combination ( m seq k -- seq )
     <combo> apply-combination ;
 
 : all-combinations ( seq k -- seq )
-    <combo> [ choose [0,b) ] keep
-    '[ _ apply-combination ] map ;
-
-: each-combination ( seq k quot -- )
-    [ <combo> [ choose [0,b) ] keep ] dip
-    '[ _ apply-combination @ ] each ; inline
-
-: map-combinations ( seq k quot -- )
-    [ <combo> [ choose [0,b) ] keep ] dip
-    '[ _ apply-combination @ ] map ; inline
+    [ ] combinations-quot map ;
 
 : reduce-combinations ( seq k identity quot -- result )
     [ -rot ] dip each-combination ; inline
-
index 4b0481eca1eb808d514736f37d97a4ed2fce8d1c..f85ec49f81d06e79b46dec824d18b8f9da1fcfa0 100644 (file)
@@ -70,4 +70,7 @@ IN: math.complex.tests
 [ ] [ C{ 1 4 } coth drop ] unit-test
 [ ] [ C{ 1 4 } cot drop ] unit-test
 
+[ t ] [ 0.0 pi rect> exp C{ -1 0 } 1.0e-7 ~ ] unit-test
+[ t ] [ 0 pi rect> exp C{ -1 0 } 1.0e-7 ~ ] unit-test
+
 [ "C{ 1/2 2/3 }" ] [ C{ 1/2 2/3 } unparse ] unit-test
diff --git a/basis/math/floats/env/x86/32/32.factor b/basis/math/floats/env/x86/32/32.factor
new file mode 100644 (file)
index 0000000..ea3bee4
--- /dev/null
@@ -0,0 +1,29 @@
+USING: alien alien.c-types cpu.x86.assembler
+cpu.x86.assembler.operands math.floats.env.x86 system ;
+IN: math.floats.env.x86.32
+
+M: x86.32 get-sse-env
+    void { void* } "cdecl" [
+        EAX ESP [] MOV
+        EAX [] STMXCSR
+    ] alien-assembly ;
+
+M: x86.32 set-sse-env
+    void { void* } "cdecl" [
+        EAX ESP [] MOV
+        EAX [] LDMXCSR
+    ] alien-assembly ;
+
+M: x86.32 get-x87-env
+    void { void* } "cdecl" [
+        EAX ESP [] MOV
+        EAX [] FNSTSW
+        EAX 2 [+] FNSTCW
+    ] alien-assembly ;
+
+M: x86.32 set-x87-env
+    void { void* } "cdecl" [
+        EAX ESP [] MOV
+        FNCLEX
+        EAX 2 [+] FLDCW
+    ] alien-assembly ;
diff --git a/basis/math/floats/env/x86/32/tags.txt b/basis/math/floats/env/x86/32/tags.txt
new file mode 100644 (file)
index 0000000..6bf6830
--- /dev/null
@@ -0,0 +1 @@
+unportable
diff --git a/basis/math/floats/env/x86/64/64.factor b/basis/math/floats/env/x86/64/64.factor
new file mode 100644 (file)
index 0000000..b6f8ee1
--- /dev/null
@@ -0,0 +1,25 @@
+USING: alien alien.c-types cpu.architecture cpu.x86.assembler
+cpu.x86.assembler.operands math.floats.env.x86 sequences system ;
+IN: math.floats.env.x86.64
+
+M: x86.64 get-sse-env
+    void { void* } "cdecl" [
+        int-regs param-regs first [] STMXCSR
+    ] alien-assembly ;
+
+M: x86.64 set-sse-env
+    void { void* } "cdecl" [
+        int-regs param-regs first [] LDMXCSR
+    ] alien-assembly ;
+
+M: x86.64 get-x87-env
+    void { void* } "cdecl" [
+        int-regs param-regs first [] FNSTSW
+        int-regs param-regs first 2 [+] FNSTCW
+    ] alien-assembly ;
+
+M: x86.64 set-x87-env
+    void { void* } "cdecl" [
+        FNCLEX
+        int-regs param-regs first 2 [+] FLDCW
+    ] alien-assembly ;
diff --git a/basis/math/floats/env/x86/64/tags.txt b/basis/math/floats/env/x86/64/tags.txt
new file mode 100644 (file)
index 0000000..6bf6830
--- /dev/null
@@ -0,0 +1 @@
+unportable
index 2b73628b4ce064b7c6074647d2ad801cd082fa8d..89dd402378dedb9138439b45f70312b79feedd48 100644 (file)
@@ -1,7 +1,7 @@
-USING: accessors alien.c-types alien.syntax arrays assocs
-biassocs classes.struct combinators cpu.x86.features kernel
-literals math math.bitwise math.floats.env
-math.floats.env.private system ;
+USING: accessors alien.c-types arrays assocs biassocs
+classes.struct combinators cpu.x86.features kernel literals
+math math.bitwise math.floats.env math.floats.env.private
+system vocabs.loader ;
 IN: math.floats.env.x86
 
 STRUCT: sse-env
@@ -11,24 +11,23 @@ STRUCT: x87-env
     { status ushort }
     { control ushort } ;
 
-! defined in the vm, cpu-x86*.S
-FUNCTION: void get_sse_env ( sse-env* env ) ;
-FUNCTION: void set_sse_env ( sse-env* env ) ;
+HOOK: get-sse-env cpu ( sse-env -- )
+HOOK: set-sse-env cpu ( sse-env -- )
 
-FUNCTION: void get_x87_env ( x87-env* env ) ;
-FUNCTION: void set_x87_env ( x87-env* env ) ;
+HOOK: get-x87-env cpu ( x87-env -- )
+HOOK: set-x87-env cpu ( x87-env -- )
 
 : <sse-env> ( -- sse-env )
-    sse-env (struct) [ get_sse_env ] keep ;
+    sse-env (struct) [ get-sse-env ] keep ;
 
 M: sse-env (set-fp-env-register)
-    set_sse_env ;
+    set-sse-env ;
 
 : <x87-env> ( -- x87-env )
-    x87-env (struct) [ get_x87_env ] keep ;
+    x87-env (struct) [ get-x87-env ] keep ;
 
 M: x87-env (set-fp-env-register)
-    set_x87_env ;
+    set-x87-env ;
 
 M: x86 (fp-env-registers)
     sse2? [ <sse-env> <x87-env> 2array ] [ <x87-env> 1array ] if ;
@@ -128,3 +127,7 @@ M: x87-env (get-denormal-mode) ( register -- mode )
 M: x87-env (set-denormal-mode) ( register mode -- register' )
     drop ;
 
+cpu {
+    { x86.32 [ "math.floats.env.x86.32" ] }
+    { x86.64 [ "math.floats.env.x86.64" ] }
+} case require
index d91b4b6b92a0c5904d418037be7a6999e573322c..a1466dd22cb587415a694cbf31b57517c2e8d67b 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2004, 2008 Slava Pestov.
+! Copyright (C) 2004, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: math kernel math.constants math.private math.bits
 math.libm combinators math.order sequences ;
@@ -62,7 +62,7 @@ M: float exp fexp ; inline
 
 M: real exp >float exp ; inline
 
-M: complex exp >rect swap fexp swap polar> ; inline
+M: complex exp >rect swap exp swap polar> ; inline
 
 <PRIVATE
 
index 1ee4e1e100f6c7285edb9a7f2ace547bdd95c0af..3fa3e97cbabedb8d9f0e0bb9d187abae3fc7869e 100644 (file)
@@ -79,7 +79,7 @@ IN: math.intervals.tests
 
 [ t ] [ 1 2 [a,b] dup empty-interval interval-union = ] unit-test
 
-[ t ] [ empty-interval 1 2 [a,b] tuck interval-union = ] unit-test
+[ t ] [ 1 2 [a,b] empty-interval over interval-union = ] unit-test
 
 [ t ] [
     0 1 (a,b) 0 1 [a,b] interval-union 0 1 [a,b] =
@@ -250,7 +250,7 @@ IN: math.intervals.tests
     dup full-interval eq? [
         drop 32 random-bits 31 2^ -
     ] [
-        dup to>> first over from>> first tuck - random +
+        [ ] [ from>> first ] [ to>> first ] tri over - random +
         2dup swap interval-contains? [
             nip
         ] [
@@ -291,7 +291,7 @@ IN: math.intervals.tests
     ] if ;
 
 unary-ops [
-    [ [ t ] ] dip '[ 8000 iota [ drop _ unary-test ] all? ] unit-test
+    [ [ t ] ] dip '[ 8000 [ drop _ unary-test ] all-integers? ] unit-test
 ] each
 
 : binary-ops ( -- alist )
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 8411447..c8d5bb7
@@ -1,7 +1,7 @@
-! Copyright (C) 2006, 2008 Slava Pestov.
+! Copyright (C) 2006, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel math math.vectors math.matrices namespaces
-sequences ;
+USING: kernel locals math math.vectors math.matrices
+namespaces sequences fry sorting ;
 IN: math.matrices.elimination
 
 SYMBOL: matrix
@@ -42,7 +42,7 @@ SYMBOL: matrix
     [ [ clear-scale ] 2keep [ n*v ] dip v+ ] change-row ;
 
 : rows-from ( row# -- slice )
-    rows dup <slice> ;
+    rows dup iota <slice> ;
 
 : clear-col ( col# row# rows -- )
     [ nth-row ] dip [ [ 2dup ] dip (clear-col) ] each 2drop ;
@@ -79,18 +79,17 @@ SYMBOL: matrix
 
 : reduced ( matrix' -- matrix'' )
     [
-        rows <reversed> [
+        rows iota <reversed> [
             dup nth-row leading drop
-            dup [ swap dup clear-col ] [ 2drop ] if
+            dup [ swap dup iota clear-col ] [ 2drop ] if
         ] each
     ] with-matrix ;
 
-: basis-vector ( row col# -- )
-    [ clone ] dip
-    [ swap nth neg recip ] 2keep
-    [ 0 spin set-nth ] 2keep
-    [ n*v ] dip
-    matrix get set-nth ;
+:: basis-vector ( row col# -- )
+    row clone :> row'
+    col# row' nth neg recip :> a
+    0 col# row' set-nth
+    a row n*v col# matrix get set-nth ;
 
 : nullspace ( matrix -- seq )
     echelon reduced dup empty? [
index 75b9be5caec547429b2ff10422bf45dafa9c6e97..bf14d7ba13ccff4bcf5eb55385f561a5543c0e3b 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2005, 2009 Slava Pestov.
+! Copyright (C) 2005, 2010 Slava Pestov, Joe Groff.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors arrays columns kernel locals math math.bits
 math.functions math.order math.vectors sequences
@@ -11,7 +11,7 @@ IN: math.matrices
 
 : identity-matrix ( n -- matrix )
     #! Make a nxn identity matrix.
-    dup [ [ = 1 0 ? ] with map ] curry map ;
+    iota dup [ [ = 1 0 ? ] with map ] curry map ;
 
 :: rotation-matrix3 ( axis theta -- matrix )
     theta cos :> c
index 0de18b6febc38320a9acc305edcf16681daa7036..99d77d0ce2216d66d66bad92c36592b69833f293 100644 (file)
@@ -32,7 +32,7 @@ PRIVATE>
     2dup [ length ] bi@ + 1 - 2pad-tail [ >vector ] bi@ ;
 
 : p* ( p q -- r )
-    2unempty pextend-conv <reversed> dup length
+    2unempty pextend-conv <reversed> dup length iota
     [ over length pick <slice> pick [ * ] 2map sum ] map 2nip reverse ;
 
 : p-sq ( p -- p^2 )
index c71fa18ab274b04f71987fffcfade2676247fb07..7cdfd552a1ab5c07de2824e5935f647b5976680c 100644 (file)
@@ -1,7 +1,8 @@
 ! Copyright (C) 2007-2009 Samuel Tardieu.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: arrays combinators kernel make math math.functions
-math.primes math.ranges sequences sequences.product sorting ;
+math.primes math.ranges sequences sequences.product sorting
+io math.parser ;
 IN: math.primes.factors
 
 <PRIVATE
@@ -49,3 +50,16 @@ PRIVATE>
         group-factors [ first2 [0,b] [ ^ ] with map ] map
         [ product ] product-map natural-sort
     ] if ;
+
+: unix-factor ( string -- )
+    dup string>number [
+        [ ": " append write ]
+        [ factors [ number>string ] map " " join print ] bi*
+    ] [
+        "factor: `" "' is not a valid positive integer" surround print
+    ] if* ;
+
+: run-unix-factor ( -- )
+    [ readln [ unix-factor t ] [ f ] if* ] loop ;
+
+MAIN: run-unix-factor
index d201abfef8f5705dbaa25320014cf187d79da6b4..f803b7db01aebdee0ba41f1c0edf71705a908637 100644 (file)
@@ -8,4 +8,4 @@ IN: math.primes.miller-rabin.tests
 [ t ] [ 37 miller-rabin ] unit-test
 [ t ] [ 2135623355842621559 miller-rabin ] unit-test
 
-[ f ] [ 1000 [ drop 15 miller-rabin ] any? ] unit-test
+[ f ] [ 1000 iota [ drop 15 miller-rabin ] any? ] unit-test
old mode 100755 (executable)
new mode 100644 (file)
index 04b1330..ac5c2df
@@ -10,7 +10,7 @@ IN: math.primes.miller-rabin
     n 1 - :> n-1
     n-1 factor-2s :> ( r s )
     0 :> a!
-    trials [
+    trials iota [
         drop
         2 n 2 - [a,b] random a!
         a s n ^mod 1 = [
old mode 100755 (executable)
new mode 100644 (file)
index 8124fcdd24610f39670c5af67cbe9d51ba753bb1..153d6509142437ec658c6cb95312b2cfe71624a1 100644 (file)
@@ -84,8 +84,8 @@ unit-test
 [ 1.0 ] [ 0.5 1/2 + ] unit-test
 [ 1.0 ] [ 1/2 0.5 + ] unit-test
 
-[ 1/268435456 ] [ -1 -268435456 >fixnum / ] unit-test
-[ 268435456 ] [ -268435456 >fixnum -1 / ] unit-test
+[ 1/134217728 ] [ -1 -134217728 >fixnum / ] unit-test
+[ 134217728 ] [ -134217728 >fixnum -1 / ] unit-test
 
 [ 5 ]
 [ "10/2" string>number ]
index 3b6e7d62ba5488a630bfad30d845656fe5c8e41a..bbfc787c0ffa4078335fd5f4a725b843abb54301 100644 (file)
@@ -38,7 +38,7 @@ HELP: range
 
 HELP: minmax
 { $values { "seq" sequence } { "min" real } { "max" real } }
-{ $description "Finds the minimum and maximum elements of " { $snippet "seq" } " in one pass." }
+{ $description "Finds the minimum and maximum elements of " { $snippet "seq" } " in one pass. Throws an error on an empty sequence." }
 { $examples
     { $example "USING: arrays math.statistics prettyprint ;"
         "{ 1 2 3 } minmax 2array ."
@@ -98,6 +98,19 @@ HELP: histogram*
 }
 { $description "Takes an existing hashtable and uses " { $link histogram } " to continue counting the number of occurences of each element." } ;
 
+HELP: sorted-histogram
+{ $values
+    { "seq" sequence }
+    { "alist" "an array of key/value pairs" }
+}
+{ $description "Outputs a " { $link histogram } " of a sequence sorted by number of occurences from lowest to highest." }
+{ $examples
+    { $example "USING: prettyprint math.statistics ;"
+        """"abababbbbbbc" sorted-histogram ."""
+        "{ { 99 1 } { 97 3 } { 98 8 } }"
+    }
+} ;
+
 HELP: sequence>assoc
 { $values
     { "seq" sequence } { "quot" quotation } { "exemplar" "an exemplar assoc" }
@@ -145,6 +158,7 @@ ARTICLE: "histogram" "Computing histograms"
 { $subsections
     histogram
     histogram*
+    sorted-histogram
 }
 "Combinators for implementing histogram:"
 { $subsections
index 9c72b848ca6ba9df7e7bbeccbf8dd67ed0fe6cac..c6a600a303555dcb30a5966623fcbc0dfde7d44f 100644 (file)
@@ -79,6 +79,9 @@ PRIVATE>
 : histogram ( seq -- hashtable )
     [ inc-at ] sequence>hashtable ;
 
+: sorted-histogram ( seq -- alist )
+    histogram >alist sort-values ;
+
 : collect-values ( seq quot: ( obj hashtable -- ) -- hash )
     '[ [ dup @ ] dip push-at ] sequence>hashtable ; inline
 
@@ -86,9 +89,14 @@ PRIVATE>
     histogram >alist
     [ ] [ [ [ second ] bi@ > ] 2keep ? ] map-reduce first ;
 
+ERROR: empty-sequence ;
+
 : minmax ( seq -- min max )
-    #! find the min and max of a seq in one pass
-    [ 1/0. -1/0. ] dip [ [ min ] [ max ] bi-curry bi* ] each ;
+    [
+        empty-sequence
+    ] [
+        [ first dup ] keep [ [ min ] [ max ] bi-curry bi* ] each
+    ] if-empty ;
 
 : range ( seq -- x )
     minmax swap - ;
diff --git a/basis/math/vectors/conversion/backend/backend.factor b/basis/math/vectors/conversion/backend/backend.factor
deleted file mode 100644 (file)
index d47fab1..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-! (c)Joe Groff bsd license
-USING: accessors alien.c-types arrays assocs classes combinators
-cords fry kernel math math.vectors sequences ;
-IN: math.vectors.conversion.backend
-
-: saturate-map-as ( v quot result -- w )
-    [ element-type '[ @ _ c-type-clamp ] ] keep map-as ; inline
-
-: (v>float) ( i to-type -- f )
-    [ >float ] swap new map-as ;
-: (v>integer) ( f to-type -- i )
-    [ >integer ] swap new map-as ;
-: (vpack-signed) ( a b to-type -- ab )
-    [ cord-append [ ] ] dip new saturate-map-as ;
-: (vpack-unsigned) ( a b to-type -- ab )
-    [ cord-append [ ] ] dip new saturate-map-as ;
-: (vunpack-head) ( ab to-type -- a )
-    [ dup length 2 /i head-slice ] dip new like ;
-: (vunpack-tail) ( ab to-type -- b )
-    [ dup length 2 /i tail-slice ] dip new like ;
-
index 9fe5ac4c1792f331e81bab125aa7bc937bb32926..7f2a349c5238ba8e0e2add3b638f4b99de616094 100644 (file)
@@ -22,7 +22,7 @@ HELP: vconvert
 }
 { $description "Converts SIMD vectors of " { $snippet "from-type" } " to " { $snippet "to-type" } ". The number of inputs and outputs depends on the relationship of the two types:"
 { $list
-{ "If " { $snippet "to-type" } " is a floating-point vector type with the same byte length and element count as the integer vector type " { $snippet "from-type" } " (for example, from " { $snippet "int-8" } " to " { $snippet "float-8" } " or from " { $snippet "longlong-2" } " to " { $snippet "double-2" } "), " { $snippet "vconvert" } " takes one vector of " { $snippet "from-type" } " and converts its elements to floating-point, outputting one vector of " { $snippet "to-type" } "." }
+{ "If " { $snippet "to-type" } " is a floating-point vector type with the same byte length and element count as the integer vector type " { $snippet "from-type" } " (for example, from " { $snippet "int-4" } " to " { $snippet "float-4" } " or from " { $snippet "longlong-2" } " to " { $snippet "double-2" } "), " { $snippet "vconvert" } " takes one vector of " { $snippet "from-type" } " and converts its elements to floating-point, outputting one vector of " { $snippet "to-type" } "." }
 { "Likewise, if " { $snippet "to-type" } " is an integer vector type with the same byte length and element count as the floating-point vector type " { $snippet "from-type" } ", " { $snippet "vconvert" } " takes one vector of " { $snippet "from-type" } " and truncates its elements to integers, outputting one vector of " { $snippet "to-type" } "." }
 { "If " { $snippet "to-type" } " is a vector type with the same byte length as and twice the element count of the vector type " { $snippet "from-type" } " (for example, from " { $snippet "int-4" } " to " { $snippet "ushort-8" } ", from " { $snippet "double-2" } " to " { $snippet "float-4" } ", or from " { $snippet "short-8" } " to " { $snippet "char-16" } "), " { $snippet "vconvert" } " takes two vectors of " { $snippet "from-type" } " and packs them into one vector of " { $snippet "to-type" } ", saturating values too large or small to be representable as elements of " { $snippet "to-type" } "." }
 { "If " { $snippet "to-type" } " is a vector type with the same byte length as and half the element count of the vector type " { $snippet "from-type" } " (for example, from " { $snippet "ushort-8" } " to " { $snippet "int-4" } ", from " { $snippet "float-4" } " to " { $snippet "double-2" } ", or from " { $snippet "char-16" } " to " { $snippet "short-8" } "), " { $snippet "vconvert" } " takes one vector of " { $snippet "from-type" } " and unpacks it into two vectors of " { $snippet "to-type" } "." }
@@ -39,26 +39,23 @@ HELP: vconvert
 "Conversion between integer and float vectors:"
 { $example """USING: alien.c-types math.vectors.conversion math.vectors.simd
 prettyprint ;
-SIMDS: int float longlong double ;
 
-int-8{ 0 1 2 3 4 5 6 7 } int-8 float-8 vconvert .
+int-4{ 0 1 2 3 } int-4 float-4 vconvert .
 double-2{ 1.25 3.75 } double-2 longlong-2 vconvert ."""
-"""float-8{ 0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 }
+"""float-4{ 0.0 1.0 2.0 3.0 }
 longlong-2{ 1 3 }""" }
 "Packing conversions:"
 { $example """USING: alien.c-types math.vectors.conversion math.vectors.simd
 prettyprint ;
-SIMDS: ushort int float double ;
 
 int-4{ -8 70000 6000 50 } int-4{ 4 3 2 -1 } int-4 ushort-8 vconvert .
-double-4{ 0.0 1.5 1.0e100 2.0 }
-double-4{ -1.0e100 0.0 1.0 2.0 } double-4 float-8 vconvert ."""
+double-2{ 0.0 1.0e100 }
+double-2{ -1.0e100 0.0 } double-2 float-4 vconvert ."""
 """ushort-8{ 0 65535 6000 50 4 3 2 0 }
-float-8{ 0.0 1.5 1/0. 2.0 -1/0. 0.0 1.0 2.0 }""" }
+float-4{ 0.0 1/0. -1/0. 0.0 }""" }
 "Unpacking conversions:"
 { $example """USING: alien.c-types kernel math.vectors.conversion
 math.vectors.simd prettyprint ;
-SIMDS: uchar short ;
 
 uchar-16{ 8 70 60 50 4 30 200 1 9 10 110 102 133 143 115 0 }
 uchar-16 short-8 vconvert [ . ] bi@"""
index 0f48b47756536a2d4181c92d220452e427012849..c91bdb369e015fd41dd7cd7e2a3cd7f150a508fa 100644 (file)
@@ -3,16 +3,6 @@ USING: accessors arrays compiler continuations generalizations
 kernel kernel.private locals math.vectors.conversion math.vectors.simd
 sequences stack-checker tools.test ;
 FROM: alien.c-types => char uchar short ushort int uint longlong ulonglong float double ;
-SIMD: uchar
-SIMD: char
-SIMD: ushort
-SIMD: short
-SIMD: uint
-SIMD: int
-SIMD: ulonglong
-SIMD: longlong
-SIMD: float
-SIMD: double
 IN: math.vectors.conversion.tests
 
 ERROR: optimized-vconvert-inconsistent
@@ -59,12 +49,12 @@ MACRO:: test-vconvert ( from-type to-type -- )
 [ double-2{ -5.0 1.0 } ]
 [ longlong-2{ -5 1 } longlong-2 double-2 test-vconvert ] unit-test
 
-[ longlong-4{ -5 1 2 6 } ]
-[ double-4{ -5.0 1.0 2.3 6.7 } double-4 longlong-4 test-vconvert ] unit-test
+[ longlong-2{ -5 1 } ]
+[ double-2{ -5.0 1.0 } double-2 longlong-2 test-vconvert ] unit-test
 
 ! TODO we should be able to do double->int pack
-! [ int-8{ -5 1 2 6 12 34 -56 78 } ]
-[ double-4{ -5.0 1.0 2.0 6.0 } double-4{ 12.0 34.0 -56.0 78.0 } double-4 int-8 test-vconvert ]
+! [ int-4{ -5 1 12 34 } ]
+[ double-2{ -5.0 1.0 } double-2{ 12.0 34.0 } double-2 int-4 test-vconvert ]
 [ error>> bad-vconvert? ] must-fail-with
 
 [ float-4{ -1.25 2.0 3.0 -4.0 } ]
@@ -76,10 +66,10 @@ MACRO:: test-vconvert ( from-type to-type -- )
 [ short-8{ -1 2 3 -32768 5 32767 -7 32767 } ]
 [ int-4{ -1 2 3 -40000 } int-4{ 5 60000 -7 80000 } int-4 short-8 test-vconvert ] unit-test
 
-[ short-16{ -1 2 3 -32768 3 2 1 0 5 32767 -7 32767 7 6 5 4 } ]
+[ short-8{ -1 2 3 -32768 5 32767 -7 32767 } ]
 [
-    int-8{ -1 2 3 -40000 3 2 1 0 }
-    int-8{ 5 60000 -7 80000 7 6 5 4 } int-8 short-16 test-vconvert
+    int-4{ -1 2 3 -40000 }
+    int-4{ 5 60000 -7 80000 } int-4 short-8 test-vconvert
 ] unit-test
 
 [ ushort-8{ 0 2 3 0 5 60000 0 65535 } ]
@@ -97,15 +87,6 @@ MACRO:: test-vconvert ( from-type to-type -- )
     uchar-16 ushort-8 test-vconvert
 ] unit-test
 
-! TODO we should be able to do 256->128 pack
-! [ float-4{ -1.25 2.0 3.0 -4.0 } ]
-[ double-4{ -1.25 2.0 3.0 -4.0 } double-4 float-4 test-vconvert ]
-[ error>> bad-vconvert? ] must-fail-with
-
-! [ int-4{ -1 2 3 -4 } ]
-[ longlong-4{ -1 2 3 -4 } longlong-4 int-4 test-vconvert ]
-[ error>> bad-vconvert? ] must-fail-with
-
 [ double-2{ -1.25 2.0 } double-2{ 3.0 -4.0 } ]
 [ float-4{ -1.25 2.0 3.0 -4.0 } float-4 double-2 test-vconvert ] unit-test
 
@@ -121,8 +102,8 @@ MACRO:: test-vconvert ( from-type to-type -- )
 [ ulonglong-2{ 1 2 } ulonglong-2{ 3 4 } ]
 [ uint-4{ 1 2 3 4 } uint-4 ulonglong-2 test-vconvert ] unit-test
 
-[ longlong-4{ 1 2 3 4 } longlong-4{ 3 4 5 6 } ]
-[ uint-8{ 1 2 3 4 3 4 5 6 } uint-8 longlong-4 test-vconvert ] unit-test
+[ longlong-2{ 1 2 } longlong-2{ 3 4 } ]
+[ uint-4{ 1 2 3 4 } uint-4 longlong-2 test-vconvert ] unit-test
 
 [ int-4{ 1 2 -3 -4 } int-4{ 5 -6 7 -8 } ]
 [ short-8{ 1 2 -3 -4 5 -6 7 -8 } short-8 int-4 test-vconvert ] unit-test
@@ -130,13 +111,8 @@ MACRO:: test-vconvert ( from-type to-type -- )
 [ uint-4{ 1 2 3 4 } uint-4{ 5 6 7 8 } ]
 [ ushort-8{ 1 2 3 4 5 6 7 8 } ushort-8 uint-4 test-vconvert ] unit-test
 
-[ longlong-4{ 1 2 3 4 } longlong-4{ 3 4 5 6 } ]
-[ uint-8{ 1 2 3 4 3 4 5 6 } uint-8 longlong-4 test-vconvert ] unit-test
-
-! TODO we should be able to do 128->256 unpack
-! [ longlong-4{ 1 2 3 4 } ]
-[ uint-4{ 1 2 3 4 } uint-4 longlong-4 test-vconvert ]
-[ error>> bad-vconvert? ] must-fail-with
+[ longlong-2{ 1 2 } longlong-2{ 3 4 } ]
+[ uint-4{ 1 2 3 4 } uint-4 longlong-2 test-vconvert ] unit-test
 
 ! TODO we should be able to do multi-tier pack/unpack
 ! [ longlong-2{ 1 2 } longlong-2{ 3 4 } longlong-2{ 5 6 } longlong-2{ 7 8 } ]
index fd58b11dc8a31526fc5498bec4721355e9a18da0..6148962ee0d5cc6dd5fc8808f1facd888196c4eb 100644 (file)
@@ -1,8 +1,10 @@
 ! (c)Joe Groff bsd license
 USING: accessors alien.c-types arrays assocs classes combinators
-combinators.short-circuit cords fry kernel locals math
-math.vectors math.vectors.conversion.backend sequences ;
-FROM: alien.c-types => char uchar short ushort int uint longlong ulonglong float double ;
+combinators.short-circuit fry kernel locals math
+math.vectors math.vectors.simd math.vectors.simd.intrinsics sequences ;
+FROM: alien.c-types =>
+    char uchar short ushort int uint longlong ulonglong
+    float double ;
 IN: math.vectors.conversion
 
 ERROR: bad-vconvert from-type to-type ;
@@ -30,11 +32,11 @@ ERROR: bad-vconvert-input value expected-type ;
         }
         {
             [ from-element float-type? ]
-            [ [ to-type (v>integer) ] ]
+            [ from-type new simd-rep '[ underlying>> _ (simd-v>integer) to-type boa ] ]
         }
         {
             [ to-element   float-type? ]
-            [ [ to-type (v>float)   ] ]
+            [ from-type new simd-rep '[ underlying>> _ (simd-v>float)   to-type boa ] ]
         }
     } cond
     [ from-type check-vconvert-type ] prepose ;
@@ -47,10 +49,18 @@ ERROR: bad-vconvert-input value expected-type ;
     } 0|| [ from-type to-type bad-vconvert ] when ;
 
 :: [[vpack-unsigned]] ( from-type to-type -- quot )
-    [ [ from-type check-vconvert-type ] bi@ to-type (vpack-unsigned) ] ;
+    from-type new simd-rep
+    '[
+        [ from-type check-vconvert-type underlying>> ] bi@
+        _ (simd-vpack-unsigned) to-type boa
+    ] ;
 
 :: [[vpack-signed]] ( from-type to-type -- quot )
-    [ [ from-type check-vconvert-type ] bi@ to-type (vpack-signed) ] ;
+    from-type new simd-rep
+    '[
+        [ from-type check-vconvert-type underlying>> ] bi@
+        _ (simd-vpack-signed)   to-type boa
+    ] ;
 
 :: [vpack] ( from-element to-element from-size to-size from-type to-type -- quot )
     from-size to-size /i log2 :> steps
@@ -68,9 +78,11 @@ ERROR: bad-vconvert-input value expected-type ;
     } 0|| [ from-type to-type bad-vconvert ] when ;
 
 :: [[vunpack]] ( from-type to-type -- quot )
-    [
-        from-type check-vconvert-type
-        [ to-type (vunpack-head) ] [ to-type (vunpack-tail) ] bi
+    from-type new simd-rep
+    '[
+        from-type check-vconvert-type underlying>> _
+        [ (simd-vunpack-head) to-type boa ]
+        [ (simd-vunpack-tail) to-type boa ] 2bi
     ] ;
 
 :: [vunpack] ( from-element to-element from-size to-size from-type to-type -- quot )
@@ -81,8 +93,8 @@ ERROR: bad-vconvert-input value expected-type ;
 PRIVATE>
 
 MACRO:: vconvert ( from-type to-type -- )
-    from-type new [ element-type ] [ byte-length ] bi :> ( from-element from-length )
-    to-type   new [ element-type ] [ byte-length ] bi :> ( to-element   to-length   )
+    from-type new [ simd-element-type ] [ byte-length ] bi :> ( from-element from-length )
+    to-type   new [ simd-element-type ] [ byte-length ] bi :> ( to-element   to-length   )
     from-element heap-size :> from-size
     to-element   heap-size :> to-size   
 
diff --git a/basis/math/vectors/simd/cords/cords.factor b/basis/math/vectors/simd/cords/cords.factor
new file mode 100644 (file)
index 0000000..815b34a
--- /dev/null
@@ -0,0 +1,87 @@
+USING: accessors alien.c-types arrays byte-arrays
+cpu.architecture effects functors generalizations kernel lexer
+math math.vectors.simd math.vectors.simd.intrinsics parser
+prettyprint.custom quotations sequences sequences.cords words ;
+IN: math.vectors.simd.cords
+
+<<
+<PRIVATE
+
+FUNCTOR: (define-simd-128-cord) ( A/2 A -- )
+
+A-rep    IS            ${A/2}-rep
+>A/2     IS            >${A/2}
+A/2-boa  IS            ${A/2}-boa
+A/2-with IS            ${A/2}-with
+A/2-cast IS            ${A/2}-cast
+
+>A     DEFINES       >${A}
+A-boa  DEFINES       ${A}-boa
+A-with DEFINES       ${A}-with
+A-cast DEFINES       ${A}-cast
+A{     DEFINES       ${A}{
+
+N       [ A-rep rep-length ]
+BOA-EFFECT [ N 2 * "n" <array> { "v" } <effect> ]
+
+WHERE
+
+: >A ( seq -- A )
+    [ N head >A/2 ]
+    [ N tail >A/2 ] bi cord-append ;
+
+\ A-boa
+{ N ndip A/2-boa cord-append } { A/2-boa } >quotation prefix >quotation
+BOA-EFFECT define-inline
+
+: A-with ( n -- v )
+    [ A/2-with ] [ A/2-with ] bi cord-append ;
+
+: A-cast ( v -- v' )
+    [ A/2-cast ] cord-map ;
+
+M: A >pprint-sequence ;
+M: A pprint* pprint-object ;
+
+M: A pprint-delims drop \ A{ \ } ;
+SYNTAX: A{ \ } [ >A ] parse-literal ;
+
+<c-type>
+    byte-array >>class
+    A >>boxed-class
+    [
+        [      A-rep alien-vector A/2 boa ]
+        [ 16 + A-rep alien-vector A/2 boa ] 2bi cord-append
+    ] >>getter
+    [
+        [ [ head>> underlying>> ] 2dip      A-rep set-alien-vector ]
+        [ [ tail>> underlying>> ] 2dip 16 + A-rep set-alien-vector ] 3bi
+    ] >>setter
+    32 >>size
+    16 >>align
+    A-rep >>rep
+\ A typedef
+
+;FUNCTOR
+
+: define-simd-128-cord ( A/2 T -- )
+    [ define-specialized-cord ]
+    [ create-in (define-simd-128-cord) ] 2bi ;
+
+SYNTAX: SIMD-128-CORD:
+    scan-word scan define-simd-128-cord ;
+
+PRIVATE>
+>>
+
+SIMD-128-CORD: char-16     char-32
+SIMD-128-CORD: uchar-16    uchar-32
+SIMD-128-CORD: short-8     short-16
+SIMD-128-CORD: ushort-8    ushort-16
+SIMD-128-CORD: int-4       int-8
+SIMD-128-CORD: uint-4      uint-8
+SIMD-128-CORD: longlong-2  longlong-4
+SIMD-128-CORD: ulonglong-2 ulonglong-4
+SIMD-128-CORD: float-4     float-8
+SIMD-128-CORD: double-2    double-4
+
diff --git a/basis/math/vectors/simd/functor/authors.txt b/basis/math/vectors/simd/functor/authors.txt
deleted file mode 100644 (file)
index d4f5d6b..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Slava Pestov
\ No newline at end of file
diff --git a/basis/math/vectors/simd/functor/functor.factor b/basis/math/vectors/simd/functor/functor.factor
deleted file mode 100644 (file)
index 44907df..0000000
+++ /dev/null
@@ -1,522 +0,0 @@
-! Copyright (C) 2009 Slava Pestov.
-! See http://factorcode.org/license.txt for BSD license.
-USING: accessors assocs byte-arrays classes classes.algebra effects fry
-functors generalizations kernel literals locals math math.functions
-math.vectors math.vectors.private math.vectors.simd.intrinsics
-math.vectors.conversion.backend
-math.vectors.specialization parser prettyprint.custom sequences
-sequences.private strings words definitions macros cpu.architecture
-namespaces arrays quotations combinators combinators.short-circuit sets
-layouts ;
-QUALIFIED-WITH: alien.c-types c
-QUALIFIED: math.private
-IN: math.vectors.simd.functor
-
-ERROR: bad-length got expected ;
-
-: vector-true-value ( class -- value )
-    {
-        { [ dup integer class<= ] [ drop -1 ] }
-        { [ dup float   class<= ] [ drop -1 bits>double ] }
-    } cond ; foldable
-
-: vector-false-value ( class -- value )
-    {
-        { [ dup integer class<= ] [ drop 0   ] }
-        { [ dup float   class<= ] [ drop 0.0 ] }
-    } cond ; foldable
-
-: boolean>element ( bool/elt class -- elt )
-    swap {
-        { t [ vector-true-value  ] }
-        { f [ vector-false-value ] }
-        [ nip ]
-    } case ; inline
-
-MACRO: simd-boa ( rep class -- simd-array )
-    [ rep-components ] [ new ] bi* '[ _ _ nsequence ] ;
-
-: can-be-unboxed? ( type -- ? )
-    {
-        { c:float [ \ math.private:float+ "intrinsic" word-prop ] }
-        { c:double [ \ math.private:float+ "intrinsic" word-prop ] }
-        [ c:heap-size cell < ]
-    } case ;
-
-: simd-boa-fast? ( rep -- ? )
-    [ dup rep-gather-word supported-simd-op? ]
-    [ rep-component-type can-be-unboxed? ]
-    bi and ;
-
-:: define-boa-custom-inlining ( word rep class -- )
-    word [
-        drop
-        rep simd-boa-fast? [
-            [ rep (simd-boa) class boa ]
-        ] [ word def>> ] if
-    ] "custom-inlining" set-word-prop ;
-
-: simd-with ( rep class x -- simd-array )
-    [ rep-components ] [ new ] [ '[ _ ] ] tri* swap replicate-as ; inline
-
-: simd-with/nth-fast? ( rep -- ? )
-    [ \ (simd-vshuffle-elements) supported-simd-op? ]
-    [ rep-component-type can-be-unboxed? ]
-    bi and ;
-
-:: define-with-custom-inlining ( word rep class -- )
-    word [
-        drop
-        rep simd-with/nth-fast? [
-            [ rep rep-coerce rep (simd-with) class boa ]
-        ] [ word def>> ] if
-    ] "custom-inlining" set-word-prop ;
-
-: simd-nth-fast ( rep -- quot )
-    [ rep-components ] keep
-    '[ swap _ '[ _ _ (simd-select) ] 2array ] map-index
-    '[ swap >fixnum _ case ] ;
-
-: simd-nth-slow ( rep -- quot )
-    rep-component-type dup c:c-type-getter-boxer c:array-accessor ;
-
-MACRO: simd-nth ( rep -- x )
-    dup simd-with/nth-fast? [ simd-nth-fast ] [ simd-nth-slow ] if ;
-
-: boa-effect ( rep n -- effect )
-    [ rep-components ] dip *
-    [ CHAR: a + 1string ] map
-    { "simd-vector" } <effect> ;
-
-: supported-simd-ops ( assoc rep -- assoc' )
-    [ simd-ops get ] dip 
-    '[ nip _ swap supported-simd-op? ] assoc-filter
-    '[ drop _ key? ] assoc-filter ;
-
-ERROR: bad-schema op schema ;
-
-:: op-wrapper ( op specials schemas -- wrapper )
-    op {
-        [ specials at ]
-        [ word-schema schemas at ]
-        [ dup word-schema bad-schema ]
-    } 1|| ;
-
-: low-level-ops ( simd-ops specials schemas -- alist )
-    '[ 1quotation over _ _ op-wrapper [ ] 2sequence ] assoc-map ;
-
-:: high-level-ops ( ctor elt-class -- assoc )
-    ! Some SIMD operations are defined in terms of others.
-    {
-        { vbroadcast [ swap nth ctor execute ] }
-        { n+v [ [ ctor execute ] dip v+ ] }
-        { v+n [ ctor execute v+ ] }
-        { n-v [ [ ctor execute ] dip v- ] }
-        { v-n [ ctor execute v- ] }
-        { n*v [ [ ctor execute ] dip v* ] }
-        { v*n [ ctor execute v* ] }
-        { n/v [ [ ctor execute ] dip v/ ] }
-        { v/n [ ctor execute v/ ] }
-        { norm-sq [ dup v. assert-positive ] }
-        { norm [ norm-sq sqrt ] }
-        { normalize [ dup norm v/n ] }
-    }
-    ! To compute dot product and distance with integer vectors, we
-    ! have to do things less efficiently, with integer overflow checks,
-    ! in the general case.
-    elt-class float = [ { distance [ v- norm ] } suffix ] when ;
-
-TUPLE: simd class elt-class ops special-wrappers schema-wrappers ctor rep ;
-
-: define-simd ( simd -- )
-    dup rep>> rep-component-type c:c-type-boxed-class >>elt-class
-    {
-        [ class>> ]
-        [ elt-class>> ]
-        [ [ ops>> ] [ special-wrappers>> ] [ schema-wrappers>> ] tri low-level-ops ]
-        [ rep>> supported-simd-ops ]
-        [ [ ctor>> ] [ elt-class>> ] bi high-level-ops assoc-union ]
-    } cleave
-    specialize-vector-words ;
-
-:: define-simd-128-type ( class rep -- )
-    c:<c-type>
-        byte-array >>class
-        class >>boxed-class
-        [ rep alien-vector class boa ] >>getter
-        [ [ underlying>> ] 2dip rep set-alien-vector ] >>setter
-        16 >>size
-        16 >>align
-        rep >>rep
-    class c:typedef ;
-
-: (define-simd-128) ( simd -- )
-    simd-ops get >>ops
-    [ define-simd ]
-    [ [ class>> ] [ rep>> ] bi define-simd-128-type ] bi ;
-
-FUNCTOR: define-simd-128 ( T -- )
-
-N            [ 16 T c:heap-size /i ]
-
-A            DEFINES-CLASS ${T}-${N}
-A-boa        DEFINES ${A}-boa
-A-with       DEFINES ${A}-with
-A-cast       DEFINES ${A}-cast
->A           DEFINES >${A}
-A{           DEFINES ${A}{
-
-SET-NTH      [ T dup c:c-setter c:array-accessor ]
-
-A-rep        [ A name>> "-rep" append "cpu.architecture" lookup ]
-A-vv->v-op   DEFINES-PRIVATE ${A}-vv->v-op
-A-vn->v-op   DEFINES-PRIVATE ${A}-vn->v-op
-A-vv->n-op   DEFINES-PRIVATE ${A}-vv->n-op
-A-v->v-op    DEFINES-PRIVATE ${A}-v->v-op
-A-v->n-op    DEFINES-PRIVATE ${A}-v->n-op
-A-v-conversion-op DEFINES-PRIVATE ${A}-v-conversion-op
-A-vv-conversion-op DEFINES-PRIVATE ${A}-vv-conversion-op
-
-A-element-class [ A-rep rep-component-type c:c-type-boxed-class ]
-
-WHERE
-
-TUPLE: A
-{ underlying byte-array read-only initial: $[ 16 <byte-array> ] } ;
-
-INSTANCE: A simd-128
-
-M: A clone underlying>> clone \ A boa ; inline
-
-M: A length drop N ; inline
-
-M: A equal?
-    over \ A instance? [ v= vall? ] [ 2drop f ] if ;
-
-M: A nth-unsafe underlying>> A-rep simd-nth ; inline
-
-M: A set-nth-unsafe
-    [ A-element-class boolean>element ] 2dip
-    underlying>> SET-NTH call ; inline
-
-: >A ( seq -- simd-array ) \ A new clone-like ;
-
-M: A like drop dup \ A instance? [ >A ] unless ; inline
-
-M: A new-underlying drop \ A boa ; inline
-
-M: A new-sequence
-    drop dup N =
-    [ drop 16 <byte-array> \ A boa ]
-    [ N bad-length ]
-    if ; inline
-
-M: A c:byte-length underlying>> length ; inline
-
-M: A element-type drop A-rep rep-component-type ;
-
-M: A pprint-delims drop \ A{ \ } ;
-
-M: A >pprint-sequence ;
-
-M: A pprint* pprint-object ;
-
-SYNTAX: A{ \ } [ >A ] parse-literal ;
-
-: A-with ( x -- simd-array ) [ A-rep A ] dip simd-with ;
-
-\ A-with \ A-rep \ A define-with-custom-inlining
-
-\ A-boa [ \ A-rep \ A simd-boa ] \ A-rep 1 boa-effect define-declared
-
-\ A-rep rep-gather-word [
-    \ A-boa \ A-rep \ A define-boa-custom-inlining
-] when
-
-: A-cast ( simd-array -- simd-array' )
-    underlying>> \ A boa ; inline
-
-INSTANCE: A sequence
-
-<PRIVATE
-
-: A-vv->v-op ( v1 v2 quot -- v3 )
-    [ [ underlying>> ] bi@ A-rep ] dip call \ A boa ; inline
-
-: A-vn->v-op ( v1 v2 quot -- v3 )
-    [ [ underlying>> ] dip A-rep ] dip call \ A boa ; inline
-
-: A-vv->n-op ( v1 v2 quot -- n )
-    [ [ underlying>> ] bi@ A-rep ] dip call ; inline
-
-: A-v->v-op ( v1 quot -- v2 )
-    [ underlying>> A-rep ] dip call \ A boa ; inline
-
-: A-v->n-op ( v quot -- n )
-    [ underlying>> A-rep ] dip call ; inline
-
-: A-v-conversion-op ( v1 to-type quot -- v2 )
-    swap [ underlying>> A-rep ] [ call ] [ '[ _ boa ] call( u -- v ) ] tri* ; inline
-
-: A-vv-conversion-op ( v1 v2 to-type quot -- v2 )
-    swap {
-        [ underlying>> ]
-        [ underlying>> A-rep ]
-        [ call ]
-        [ '[ _ boa ] call( u -- v ) ]
-    } spread ; inline
-
-simd new
-    \ A >>class
-    \ A-with >>ctor
-    \ A-rep >>rep
-    {
-        { (v>float) A-v-conversion-op }
-        { (v>integer) A-v-conversion-op }
-        { (vpack-signed) A-vv-conversion-op }
-        { (vpack-unsigned) A-vv-conversion-op }
-        { (vunpack-head) A-v-conversion-op }
-        { (vunpack-tail) A-v-conversion-op }
-    } >>special-wrappers
-    {
-        { { +vector+ +vector+ -> +vector+ } A-vv->v-op }
-        { { +vector+ +any-vector+ -> +vector+ } A-vv->v-op }
-        { { +vector+ +scalar+ -> +vector+ } A-vn->v-op }
-        { { +vector+ +literal+ -> +vector+ } A-vn->v-op }
-        { { +vector+ +vector+ -> +scalar+ } A-vv->n-op }
-        { { +vector+ +vector+ -> +boolean+ } A-vv->n-op }
-        { { +vector+ -> +vector+ } A-v->v-op }
-        { { +vector+ -> +scalar+ } A-v->n-op }
-        { { +vector+ -> +boolean+ } A-v->n-op }
-        { { +vector+ -> +nonnegative+ } A-v->n-op }
-    } >>schema-wrappers
-(define-simd-128)
-
-PRIVATE>
-
-;FUNCTOR
-
-! Synthesize 256-bit vectors from a pair of 128-bit vectors
-SLOT: underlying1
-SLOT: underlying2
-
-:: define-simd-256-type ( class rep -- )
-    c:<c-type>
-        class >>class
-        class >>boxed-class
-        [
-            [ rep alien-vector ]
-            [ 16 + >fixnum rep alien-vector ] 2bi
-            class boa
-        ] >>getter
-        [
-            [ [ underlying1>> ] 2dip rep set-alien-vector ]
-            [ [ underlying2>> ] 2dip 16 + >fixnum rep set-alien-vector ]
-            3bi
-        ] >>setter
-        32 >>size
-        16 >>align
-        rep >>rep
-    class c:typedef ;
-
-: (define-simd-256) ( simd -- )
-    simd-ops get { vshuffle-elements vshuffle-bytes hlshift hrshift } unique assoc-diff >>ops
-    [ define-simd ]
-    [ [ class>> ] [ rep>> ] bi define-simd-256-type ] bi ;
-
-FUNCTOR: define-simd-256 ( T -- )
-
-N            [ 32 T c:heap-size /i ]
-
-N/2          [ N 2 /i ]
-A/2          IS ${T}-${N/2}
-A/2-boa      IS ${A/2}-boa
-A/2-with     IS ${A/2}-with
-
-A            DEFINES-CLASS ${T}-${N}
-A-boa        DEFINES ${A}-boa
-A-with       DEFINES ${A}-with
-A-cast       DEFINES ${A}-cast
->A           DEFINES >${A}
-A{           DEFINES ${A}{
-
-A-deref      DEFINES-PRIVATE ${A}-deref
-
-A-rep        [ A/2 name>> "-rep" append "cpu.architecture" lookup ]
-A-vv->v-op   DEFINES-PRIVATE ${A}-vv->v-op
-A-vn->v-op   DEFINES-PRIVATE ${A}-vn->v-op
-A-v->v-op    DEFINES-PRIVATE ${A}-v->v-op
-A-v.-op      DEFINES-PRIVATE ${A}-v.-op
-(A-v->n-op)  DEFINES-PRIVATE (${A}-v->v-op)
-A-sum-op     DEFINES-PRIVATE ${A}-sum-op
-A-vany-op    DEFINES-PRIVATE ${A}-vany-op
-A-vall-op    DEFINES-PRIVATE ${A}-vall-op
-A-vmerge-head-op    DEFINES-PRIVATE ${A}-vmerge-head-op
-A-vmerge-tail-op    DEFINES-PRIVATE ${A}-vmerge-tail-op
-A-v-conversion-op   DEFINES-PRIVATE ${A}-v-conversion-op
-A-vpack-op          DEFINES-PRIVATE ${A}-vpack-op
-A-vunpack-head-op   DEFINES-PRIVATE ${A}-vunpack-head-op
-A-vunpack-tail-op   DEFINES-PRIVATE ${A}-vunpack-tail-op
-
-WHERE
-
-SLOT: underlying1
-SLOT: underlying2
-
-TUPLE: A
-{ underlying1 byte-array initial: $[ 16 <byte-array> ] read-only }
-{ underlying2 byte-array initial: $[ 16 <byte-array> ] read-only } ;
-
-INSTANCE: A simd-256
-
-M: A clone
-    [ underlying1>> clone ] [ underlying2>> clone ] bi
-    \ A boa ; inline
-
-M: A length drop N ; inline
-
-M: A equal?
-    over \ A instance? [ v= vall? ] [ 2drop f ] if ;
-
-: A-deref ( n seq -- n' seq' )
-    over N/2 < [ underlying1>> ] [ [ N/2 - ] dip underlying2>> ] if \ A/2 boa ; inline
-
-M: A nth-unsafe A-deref nth-unsafe ; inline
-
-M: A set-nth-unsafe A-deref set-nth-unsafe ; inline
-
-: >A ( seq -- simd-array ) \ A new clone-like ;
-
-M: A like drop dup \ A instance? [ >A ] unless ; inline
-
-M: A new-sequence
-    drop dup N =
-    [ drop 16 <byte-array> 16 <byte-array> \ A boa ]
-    [ N bad-length ]
-    if ; inline
-
-M: A c:byte-length drop 32 ; inline
-
-M: A element-type drop A-rep rep-component-type ;
-
-SYNTAX: A{ \ } [ >A ] parse-literal ;
-
-M: A pprint-delims drop \ A{ \ } ;
-
-M: A >pprint-sequence ;
-
-M: A pprint* pprint-object ;
-
-: A-with ( x -- simd-array )
-    [ A/2-with ] [ A/2-with ] bi [ underlying>> ] bi@
-    \ A boa ; inline
-
-: A-boa ( ... -- simd-array )
-    [ A/2-boa ] N/2 ndip A/2-boa [ underlying>> ] bi@
-    \ A boa ; inline
-
-\ A-rep 2 boa-effect \ A-boa set-stack-effect
-
-: A-cast ( simd-array -- simd-array' )
-    [ underlying1>> ] [ underlying2>> ] bi \ A boa ; inline
-
-INSTANCE: A sequence
-
-: A-vv->v-op ( v1 v2 quot -- v3 )
-    [ [ [ underlying1>> ] bi@ A-rep ] dip call ]
-    [ [ [ underlying2>> ] bi@ A-rep ] dip call ] 3bi
-    \ A boa ; inline
-
-: A-vn->v-op ( v1 v2 quot -- v3 )
-    [ [ [ underlying1>> ] dip A-rep ] dip call ]
-    [ [ [ underlying2>> ] dip A-rep ] dip call ] 3bi
-    \ A boa ; inline
-
-: A-v->v-op ( v1 combine-quot -- v2 )
-    [ [ underlying1>> A-rep ] dip call ]
-    [ [ underlying2>> A-rep ] dip call ] 2bi
-    \ A boa ; inline
-
-: A-v.-op ( v1 v2 quot -- n )
-    [ [ [ underlying1>> ] bi@ A-rep ] dip call ]
-    [ [ [ underlying2>> ] bi@ A-rep ] dip call ] 3bi
-    + ; inline
-
-: (A-v->n-op) ( v1 quot reduce-quot -- n )
-    '[ [ underlying1>> ] [ underlying2>> ] bi A-rep @ A-rep ] dip call ; inline
-
-: A-sum-op ( v1 quot -- n )
-    [ (simd-v+) ] (A-v->n-op) ; inline
-
-: A-vany-op ( v1 quot -- n )
-    [ (simd-vbitor) ] (A-v->n-op) ; inline
-: A-vall-op ( v1 quot -- n )
-    [ (simd-vbitand) ] (A-v->n-op) ; inline
-
-: A-vmerge-head-op ( v1 v2 quot -- v )
-    drop
-    [ underlying1>> ] bi@
-    [ A-rep (simd-(vmerge-head)) ]
-    [ A-rep (simd-(vmerge-tail)) ] 2bi
-    \ A boa ; inline
-    
-: A-vmerge-tail-op ( v1 v2 quot -- v )
-    drop
-    [ underlying2>> ] bi@
-    [ A-rep (simd-(vmerge-head)) ]
-    [ A-rep (simd-(vmerge-tail)) ] 2bi
-    \ A boa ; inline
-
-: A-v-conversion-op ( v1 to-type quot -- v )
-    swap [ 
-        [ [ underlying1>> A-rep ] dip call ]
-        [ [ underlying2>> A-rep ] dip call ] 2bi
-    ] dip '[ _ boa ] call( u1 u2 -- v ) ; inline
-
-: A-vpack-op ( v1 v2 to-type quot -- v )
-    swap [ 
-        '[ [ underlying1>> ] [ underlying2>> ] bi A-rep @ ] bi*
-    ] dip '[ _ boa ] call( u1 u2 -- v ) ; inline
-
-: A-vunpack-head-op ( v1 to-type quot -- v )
-    '[
-        underlying1>>
-        [ A-rep @ ]
-        [ A-rep (simd-(vunpack-tail)) ] bi
-    ] dip '[ _ boa ] call( u1 u2 -- v ) ; inline
-
-: A-vunpack-tail-op ( v1 to-type quot -- v )
-    '[
-        underlying2>>
-        [ A-rep (simd-(vunpack-head)) ]
-        [ A-rep @ ] bi
-    ] dip '[ _ boa ] call( u1 u2 -- v ) ; inline
-
-simd new
-    \ A >>class
-    \ A-with >>ctor
-    \ A-rep >>rep
-    {
-        { v.     A-v.-op   }
-        { sum    A-sum-op  }
-        { vnone? A-vany-op }
-        { vany?  A-vany-op }
-        { vall?  A-vall-op }
-        { (vmerge-head) A-vmerge-head-op }
-        { (vmerge-tail) A-vmerge-tail-op }
-        { (v>integer) A-v-conversion-op }
-        { (v>float) A-v-conversion-op }
-        { (vpack-signed) A-vpack-op }
-        { (vpack-unsigned) A-vpack-op }
-        { (vunpack-head) A-vunpack-head-op }
-        { (vunpack-tail) A-vunpack-tail-op }
-    } >>special-wrappers
-    {
-        { { +vector+ +vector+ -> +vector+ } A-vv->v-op }
-        { { +vector+ +scalar+ -> +vector+ } A-vn->v-op }
-        { { +vector+ +literal+ -> +vector+ } A-vn->v-op }
-        { { +vector+ -> +vector+ } A-v->v-op }
-    } >>schema-wrappers
-(define-simd-256)
-
-;FUNCTOR
diff --git a/basis/math/vectors/simd/intrinsics/authors.txt b/basis/math/vectors/simd/intrinsics/authors.txt
deleted file mode 100644 (file)
index d4f5d6b..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Slava Pestov
\ No newline at end of file
diff --git a/basis/math/vectors/simd/intrinsics/intrinsics-tests.factor b/basis/math/vectors/simd/intrinsics/intrinsics-tests.factor
deleted file mode 100644 (file)
index 84eee93..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-IN: math.vectors.simd.intrinsics.tests
-USING: math.vectors.simd.intrinsics cpu.architecture tools.test ;
-
-[ 16 ] [ uchar-16-rep rep-components ] unit-test
-[ 16 ] [ char-16-rep rep-components ] unit-test
-[ 8 ] [ ushort-8-rep rep-components ] unit-test
-[ 8 ] [ short-8-rep rep-components ] unit-test
-[ 4 ] [ uint-4-rep rep-components ] unit-test
-[ 4 ] [ int-4-rep rep-components ] unit-test
-[ 4 ] [ float-4-rep rep-components ] unit-test
-[ 2 ] [ double-2-rep rep-components ] unit-test
-
-{ 4 1 } [ uint-4-rep (simd-boa) ] must-infer-as
-{ 4 1 } [ int-4-rep (simd-boa) ] must-infer-as
-{ 4 1 } [ float-4-rep (simd-boa) ] must-infer-as
-{ 2 1 } [ double-2-rep (simd-boa) ] must-infer-as
-
-
index 003b42fe83f28b19d2f77226e9e64be1a0ed22d5..d80755a6a5c2cb24b37f1c6e5cf142ee0d33096d 100644 (file)
-! Copyright (C) 2009 Slava Pestov.
-! See http://factorcode.org/license.txt for BSD license.
-USING: alien alien.c-types alien.data assocs combinators
-cpu.architecture compiler.cfg.comparisons fry generalizations
-kernel libc macros math
-math.vectors.conversion.backend
-sequences sets effects accessors namespaces
-lexer parser vocabs.parser words arrays math.vectors ;
+! (c)2009 Slava Pestov, Joe Groff bsd license
+USING: accessors alien alien.c-types alien.data combinators
+sequences.cords cpu.architecture fry generalizations grouping
+kernel libc locals math math.libm math.order math.ranges
+math.vectors sequences sequences.private specialized-arrays
+vocabs.loader ;
+QUALIFIED-WITH: alien.c-types c
+SPECIALIZED-ARRAYS:
+    c:char c:short c:int c:longlong
+    c:uchar c:ushort c:uint c:ulonglong
+    c:float c:double ;
 IN: math.vectors.simd.intrinsics
 
-ERROR: bad-simd-call word ;
-
-<<
-
-: simd-effect ( word -- effect )
-    stack-effect [ in>> "rep" suffix ] [ out>> ] bi <effect> ;
-: simd-conversion-effect ( word -- effect )
-    stack-effect [ in>> but-last "rep" suffix ] [ out>> ] bi <effect> ;
-
-SYMBOL: simd-ops
-
-V{ } clone simd-ops set-global
-
-: (SIMD-OP:) ( accum quot -- accum )
-    [
-        scan-word dup name>> "(simd-" ")" surround create-in
-        [ nip dup '[ _ bad-simd-call ] define ]
-    ] dip
-    '[ _ dip set-stack-effect ]
-    [ 2array simd-ops get push ]
-    2tri ; inline
-
-SYNTAX: SIMD-OP:
-    [ simd-effect ] (SIMD-OP:) ;
-
-SYNTAX: SIMD-CONVERSION-OP:
-    [ simd-conversion-effect ] (SIMD-OP:) ;
-
->>
-
-SIMD-OP: v+
-SIMD-OP: v-
-SIMD-OP: vneg
-SIMD-OP: v+-
-SIMD-OP: vs+
-SIMD-OP: vs-
-SIMD-OP: vs*
-SIMD-OP: v*
-SIMD-OP: v/
-SIMD-OP: vmin
-SIMD-OP: vmax
-SIMD-OP: v.
-SIMD-OP: vsqrt
-SIMD-OP: sum
-SIMD-OP: vabs
-SIMD-OP: vbitand
-SIMD-OP: vbitandn
-SIMD-OP: vbitor
-SIMD-OP: vbitxor
-SIMD-OP: vbitnot
-SIMD-OP: vand
-SIMD-OP: vandn
-SIMD-OP: vor
-SIMD-OP: vxor
-SIMD-OP: vnot
-SIMD-OP: vlshift
-SIMD-OP: vrshift
-SIMD-OP: hlshift
-SIMD-OP: hrshift
-SIMD-OP: vshuffle-elements
-SIMD-OP: vshuffle-bytes
-SIMD-OP: (vmerge-head)
-SIMD-OP: (vmerge-tail)
-SIMD-OP: v<=
-SIMD-OP: v<
-SIMD-OP: v=
-SIMD-OP: v>
-SIMD-OP: v>=
-SIMD-OP: vunordered?
-SIMD-OP: vany?
-SIMD-OP: vall?
-SIMD-OP: vnone?
-
-SIMD-CONVERSION-OP: (v>float)
-SIMD-CONVERSION-OP: (v>integer)
-SIMD-CONVERSION-OP: (vpack-signed)
-SIMD-CONVERSION-OP: (vpack-unsigned)
-SIMD-CONVERSION-OP: (vunpack-head)
-SIMD-CONVERSION-OP: (vunpack-tail)
-
-: (simd-with) ( x rep -- v ) bad-simd-call ;
-: (simd-gather-2) ( a b rep -- v ) bad-simd-call ;
-: (simd-gather-4) ( a b c d rep -- v ) bad-simd-call ;
-: (simd-select) ( v n rep -- x ) bad-simd-call ;
-
 : assert-positive ( x -- y ) ;
 
-: alien-vector ( c-ptr n rep -- value )
-    ! Inefficient version for when intrinsics are missing
-    [ swap <displaced-alien> ] dip rep-size memory>byte-array ;
-
-: set-alien-vector ( value c-ptr n rep -- )
-    ! Inefficient version for when intrinsics are missing
-    [ swap <displaced-alien> swap ] dip rep-size memcpy ;
-
-<<
+<PRIVATE
 
-: rep-components ( rep -- n )
-    16 swap rep-component-type heap-size /i ; foldable
-
-: rep-coercer ( rep -- quot )
+: >bitwise-vector-rep ( rep -- rep' )
     {
-        { [ dup int-vector-rep? ] [ [ >fixnum ] ] }
-        { [ dup float-vector-rep? ] [ [ >float ] ] }
-    } cond nip ; foldable
-
-: rep-coerce ( value rep -- value' )
-    rep-coercer call( value -- value' ) ; inline
-
-CONSTANT: rep-gather-words
-    {
-        { 2 (simd-gather-2) }
-        { 4 (simd-gather-4) }
-    }
-
-: rep-gather-word ( rep -- word )
-    rep-components rep-gather-words at ;
-
->>
+        { float-4-rep    [ uint-4-rep      ] }
+        { double-2-rep   [ ulonglong-2-rep ] }
+        [ ]
+    } case ; foldable
 
-MACRO: (simd-boa) ( rep -- quot )
+: >uint-vector-rep ( rep -- rep' )
     {
-        [ rep-coercer ]
-        [ rep-components ]
+        { longlong-2-rep [ ulonglong-2-rep ] }
+        { int-4-rep      [ uint-4-rep      ] }
+        { short-8-rep    [ ushort-8-rep    ] }
+        { char-16-rep    [ uchar-16-rep    ] }
         [ ]
-        [ rep-gather-word ]
-    } cleave
-    '[ _ _ napply _ _ execute ] ;
+    } case ; foldable
 
-GENERIC# supported-simd-op? 1 ( rep intrinsic -- ? )
+: >int-vector-rep ( rep -- rep' )
+    {
+        { float-4-rep  [ int-4-rep      ] }
+        { double-2-rep [ longlong-2-rep ] }
+    } case ; foldable
 
-: (%unpack-reps) ( -- reps )
-    %merge-vector-reps [ int-vector-rep? ] filter
-    %unpack-vector-head-reps union ;
+: >float-vector-rep ( rep -- rep' )
+    {
+        { int-4-rep      [ float-4-rep  ] }
+        { longlong-2-rep [ double-2-rep ] }
+    } case ; foldable
 
-: (%abs-reps) ( -- reps )
-    cc> %compare-vector-reps [ int-vector-rep? ] filter
-    %xor-vector-reps [ float-vector-rep? ] filter
-    union
-    [ { } ] [ { uchar-16-rep ushort-8-rep uint-4-rep ulonglong-2-rep } union ] if-empty ;
+: [byte>rep-array] ( rep -- class )
+    {
+        { char-16-rep      [ [ byte-array>char-array      ] ] }
+        { uchar-16-rep     [ [ byte-array>uchar-array     ] ] }
+        { short-8-rep      [ [ byte-array>short-array     ] ] }
+        { ushort-8-rep     [ [ byte-array>ushort-array    ] ] }
+        { int-4-rep        [ [ byte-array>int-array       ] ] }
+        { uint-4-rep       [ [ byte-array>uint-array      ] ] }
+        { longlong-2-rep   [ [ byte-array>longlong-array  ] ] }
+        { ulonglong-2-rep  [ [ byte-array>ulonglong-array ] ] }
+        { float-4-rep      [ [ byte-array>float-array     ] ] }
+        { double-2-rep     [ [ byte-array>double-array    ] ] }
+    } case ; foldable
+
+: [>rep-array] ( rep -- class )
+    {
+        { char-16-rep      [ [ >char-array      ] ] }
+        { uchar-16-rep     [ [ >uchar-array     ] ] }
+        { short-8-rep      [ [ >short-array     ] ] }
+        { ushort-8-rep     [ [ >ushort-array    ] ] }
+        { int-4-rep        [ [ >int-array       ] ] }
+        { uint-4-rep       [ [ >uint-array      ] ] }
+        { longlong-2-rep   [ [ >longlong-array  ] ] }
+        { ulonglong-2-rep  [ [ >ulonglong-array ] ] }
+        { float-4-rep      [ [ >float-array     ] ] }
+        { double-2-rep     [ [ >double-array    ] ] }
+    } case ; foldable
+
+: [<rep-array>] ( rep -- class )
+    {
+        { char-16-rep      [ [ 16 (char-array)      ] ] }
+        { uchar-16-rep     [ [ 16 (uchar-array)     ] ] }
+        { short-8-rep      [ [  8 (short-array)     ] ] }
+        { ushort-8-rep     [ [  8 (ushort-array)    ] ] }
+        { int-4-rep        [ [  4 (int-array)       ] ] }
+        { uint-4-rep       [ [  4 (uint-array)      ] ] }
+        { longlong-2-rep   [ [  2 (longlong-array)  ] ] }
+        { ulonglong-2-rep  [ [  2 (ulonglong-array) ] ] }
+        { float-4-rep      [ [  4 (float-array)     ] ] }
+        { double-2-rep     [ [  2 (double-array)    ] ] }
+    } case ; foldable
+
+: rep-tf-values ( rep -- t f )
+    float-vector-rep? [ -1 bits>double 0.0 ] [ -1 0 ] if ;
+
+: >rep-array ( a rep -- a' )
+    [byte>rep-array] call( a -- a' ) ; inline
+: 2>rep-array ( a b rep -- a' b' )
+    [byte>rep-array] '[ _ call( a -- a' ) ] bi@ ; inline
+: <rep-array> ( rep -- a' )
+    [<rep-array>] call( -- a' ) ; inline
+
+: components-map ( a rep quot -- c )
+    [ >rep-array ] dip map underlying>> ; inline
+: components-2map ( a b rep quot -- c )
+    [ 2>rep-array ] dip 2map underlying>> ; inline
+: components-reduce ( a rep quot -- x )
+    [ >rep-array [ ] ] dip map-reduce ; inline
+
+: bitwise-components-map ( a rep quot -- c )
+    [ >bitwise-vector-rep >rep-array ] dip map underlying>> ; inline
+: bitwise-components-2map ( a b rep quot -- c )
+    [ >bitwise-vector-rep 2>rep-array ] dip 2map underlying>> ; inline
+: bitwise-components-reduce ( a rep quot -- x )
+    [ >bitwise-vector-rep >rep-array [ ] ] dip map-reduce ; inline
+
+:: (vshuffle) ( a elts rep -- c )
+    a rep >rep-array :> a'
+    rep <rep-array> :> c'
+    elts [| from to |
+        from rep rep-length 1 - bitand
+           a' nth-unsafe
+        to c' set-nth-unsafe
+    ] each-index
+    c' underlying>> ; inline
+
+PRIVATE>
+
+: (simd-v+)                ( a b rep -- c ) [ + ] components-2map ;
+: (simd-v-)                ( a b rep -- c ) [ - ] components-2map ;
+: (simd-vneg)              ( a   rep -- c ) [ neg ] components-map ;
+:: (simd-v+-)              ( a b rep -- c ) 
+    a b rep 2>rep-array :> ( a' b' )
+    rep <rep-array> :> c'
+    0  rep rep-length 1 -  2 <range> [| n |
+        n     a' nth-unsafe n     b' nth-unsafe -
+        n     c' set-nth-unsafe
+
+        n 1 + a' nth-unsafe n 1 + b' nth-unsafe +
+        n 1 + c' set-nth-unsafe
+    ] each
+    c' underlying>> ;
+: (simd-vs+)               ( a b rep -- c )
+    dup rep-component-type '[ + _ c-type-clamp ] components-2map ;
+: (simd-vs-)               ( a b rep -- c )
+    dup rep-component-type '[ - _ c-type-clamp ] components-2map ;
+: (simd-vs*)               ( a b rep -- c )
+    dup rep-component-type '[ * _ c-type-clamp ] components-2map ;
+: (simd-v*)                ( a b rep -- c ) [ * ] components-2map ;
+: (simd-v*high)            ( a b rep -- c )
+    dup rep-component-type heap-size -8 * '[ * _ shift ] components-2map ;
+:: (simd-v*hs+)            ( a b rep -- c )
+    rep { char-16-rep uchar-16-rep } member-eq?
+    [ uchar-16-rep char-16-rep ]
+    [ rep rep ] if :> ( a-rep b-rep )
+    b-rep widen-vector-rep signed-rep :> wide-rep
+    wide-rep rep-component-type :> wide-type
+    a a-rep >rep-array 2 <groups> :> a'
+    b b-rep >rep-array 2 <groups> :> b'
+    a' b' [
+        [ [ first  ] bi@ * ]
+        [ [ second ] bi@ * ] 2bi +
+        wide-type c-type-clamp
+    ] wide-rep <rep-array> 2map-as underlying>> ;
+: (simd-v/)                ( a b rep -- c ) [ / ] components-2map ;
+: (simd-vavg)              ( a b rep -- c )
+    [ + dup integer? [ 1 + -1 shift ] [ 0.5 * ] if ] components-2map ;
+: (simd-vmin)              ( a b rep -- c ) [ min ] components-2map ;
+: (simd-vmax)              ( a b rep -- c ) [ max ] components-2map ;
+: (simd-v.)                ( a b rep -- n )
+    [ 2>rep-array [ [ first ] bi@ * ] 2keep ] keep
+    1 swap rep-length [a,b) [ '[ _ swap nth-unsafe ] bi@ * + ] with with each ;
+: (simd-vsqrt)             ( a   rep -- c ) [ fsqrt ] components-map ;
+: (simd-vsad)              ( a b rep -- c ) 2>rep-array [ - abs ] [ + ] 2map-reduce ;
+: (simd-sum)               ( a   rep -- n ) [ + ] components-reduce ;
+: (simd-vabs)              ( a   rep -- c ) [ abs ] components-map ;
+: (simd-vbitand)           ( a b rep -- c ) [ bitand ] bitwise-components-2map ;
+: (simd-vbitandn)          ( a b rep -- c ) [ [ bitnot ] dip bitand ] bitwise-components-2map ;
+: (simd-vbitor)            ( a b rep -- c ) [ bitor ] bitwise-components-2map ;
+: (simd-vbitxor)           ( a b rep -- c ) [ bitxor ] bitwise-components-2map ;
+: (simd-vbitnot)           ( a   rep -- c ) [ bitnot ] bitwise-components-map ;
+: (simd-vand)              ( a b rep -- c ) [ bitand ] bitwise-components-2map ;
+: (simd-vandn)             ( a b rep -- c ) [ [ bitnot ] dip bitand ] bitwise-components-2map ;
+: (simd-vor)               ( a b rep -- c ) [ bitor ] bitwise-components-2map ;
+: (simd-vxor)              ( a b rep -- c ) [ bitxor ] bitwise-components-2map ;
+: (simd-vnot)              ( a   rep -- c ) [ bitnot ] bitwise-components-map ;
+: (simd-vlshift)           ( a n rep -- c ) swap '[ _ shift ] bitwise-components-map ;
+: (simd-vrshift)           ( a n rep -- c ) swap '[ _ neg shift ] bitwise-components-map ;
+: (simd-hlshift)           ( a n rep -- c )
+    drop head-slice* 16 0 pad-head ;
+: (simd-hrshift)           ( a n rep -- c )
+    drop tail-slice 16 0 pad-tail ;
+: (simd-vshuffle-elements) ( a n rep -- c ) [ rep-length 0 pad-tail ] keep (vshuffle) ;
+: (simd-vshuffle-bytes)    ( a b rep -- c ) drop uchar-16-rep (vshuffle) ;
+:: (simd-vmerge-head)      ( a b rep -- c )
+    a b rep 2>rep-array :> ( a' b' )
+    rep <rep-array> :> c'
+    rep rep-length 2 /i iota [| n |
+        n a' nth-unsafe n 2 *     c' set-nth-unsafe
+        n b' nth-unsafe n 2 * 1 + c' set-nth-unsafe
+    ] each
+    c' underlying>> ;
+:: (simd-vmerge-tail)      ( a b rep -- c )
+    a b rep 2>rep-array :> ( a' b' )
+    rep <rep-array> :> c'
+    rep rep-length 2 /i :> len
+    len iota [| n |
+        n len + a' nth-unsafe n 2 *     c' set-nth-unsafe
+        n len + b' nth-unsafe n 2 * 1 + c' set-nth-unsafe
+    ] each
+    c' underlying>> ;
+: (simd-v<=)               ( a b rep -- c )
+    dup rep-tf-values '[ <= _ _ ? ] components-2map ; 
+: (simd-v<)                ( a b rep -- c )
+    dup rep-tf-values '[ <  _ _ ? ] components-2map ;
+: (simd-v=)                ( a b rep -- c )
+    dup rep-tf-values '[ =  _ _ ? ] components-2map ;
+: (simd-v>)                ( a b rep -- c )
+    dup rep-tf-values '[ >  _ _ ? ] components-2map ;
+: (simd-v>=)               ( a b rep -- c )
+    dup rep-tf-values '[ >= _ _ ? ] components-2map ;
+: (simd-vunordered?)       ( a b rep -- c )
+    dup rep-tf-values '[ unordered? _ _ ? ] components-2map ;
+: (simd-vany?)             ( a   rep -- ? ) [ bitor  ] bitwise-components-reduce zero? not ;
+: (simd-vall?)             ( a   rep -- ? ) [ bitand ] bitwise-components-reduce zero? not ;
+: (simd-vnone?)            ( a   rep -- ? ) [ bitor  ] bitwise-components-reduce zero?     ;
+: (simd-v>float)           ( a   rep -- c )
+    [ >rep-array [ >float ] ] [ >float-vector-rep <rep-array> ] bi map-as underlying>> ;
+: (simd-v>integer)         ( a   rep -- c )
+    [ >rep-array [ >integer ] ] [ >int-vector-rep <rep-array> ] bi map-as underlying>> ;
+: (simd-vpack-signed)      ( a b rep -- c )
+    [ 2>rep-array cord-append ]
+    [ narrow-vector-rep [ <rep-array> ] [ rep-component-type ] bi ] bi
+    '[ _ c-type-clamp ] swap map-as underlying>> ;
+: (simd-vpack-unsigned)    ( a b rep -- c )
+    [ 2>rep-array cord-append ]
+    [ narrow-vector-rep >uint-vector-rep [ <rep-array> ] [ rep-component-type ] bi ] bi
+    '[ _ c-type-clamp ] swap map-as underlying>> ;
+: (simd-vunpack-head)      ( a   rep -- c ) 
+    [ >rep-array ] [ widen-vector-rep [ rep-length ] [ [>rep-array] ] bi ] bi
+    [ head-slice ] dip call( a' -- c' ) underlying>> ;
+: (simd-vunpack-tail)      ( a   rep -- c )
+    [ >rep-array ] [ widen-vector-rep [ rep-length ] [ [>rep-array] ] bi ] bi
+    [ tail-slice ] dip call( a' -- c' ) underlying>> ;
+: (simd-with)              (   n rep -- v )
+    [ rep-length swap '[ _ ] ] [ <rep-array> ] bi replicate-as 
+    underlying>> ;
+: (simd-gather-2)          ( m n rep -- v ) <rep-array> [ 2 set-firstn ] keep underlying>> ;
+: (simd-gather-4)          ( m n o p rep -- v ) <rep-array> [ 4 set-firstn ] keep underlying>> ;
+: (simd-select)            ( a n rep -- x ) [ swap ] dip >rep-array nth-unsafe ;
+
+: alien-vector     (       c-ptr n rep -- value )
+    [ swap <displaced-alien> ] dip rep-size memory>byte-array ;
+: set-alien-vector ( value c-ptr n rep --       )
+    [ swap <displaced-alien> swap ] dip rep-size memcpy ;
 
-: (%shuffle-imm-reps) ( -- reps )
-    %shuffle-vector-reps %shuffle-vector-imm-reps union ;
+"compiler.cfg.intrinsics.simd" require
+"compiler.tree.propagation.simd" require
+"compiler.cfg.value-numbering.simd" require
 
-M: vector-rep supported-simd-op?
-    {
-        { \ (simd-v+)            [ %add-vector-reps            ] }
-        { \ (simd-vs+)           [ %saturated-add-vector-reps  ] }
-        { \ (simd-v+-)           [ %add-sub-vector-reps        ] }
-        { \ (simd-v-)            [ %sub-vector-reps            ] }
-        { \ (simd-vs-)           [ %saturated-sub-vector-reps  ] }
-        { \ (simd-vneg)          [ %sub-vector-reps            ] }
-        { \ (simd-v*)            [ %mul-vector-reps            ] }
-        { \ (simd-vs*)           [ %saturated-mul-vector-reps  ] }
-        { \ (simd-v/)            [ %div-vector-reps            ] }
-        { \ (simd-vmin)          [ %min-vector-reps cc< %compare-vector-reps union ] }
-        { \ (simd-vmax)          [ %max-vector-reps cc> %compare-vector-reps union ] }
-        { \ (simd-v.)            [ %dot-vector-reps            ] }
-        { \ (simd-vsqrt)         [ %sqrt-vector-reps           ] }
-        { \ (simd-sum)           [ %horizontal-add-vector-reps ] }
-        { \ (simd-vabs)          [ (%abs-reps)                 ] }
-        { \ (simd-vbitand)       [ %and-vector-reps            ] }
-        { \ (simd-vbitandn)      [ %andn-vector-reps           ] }
-        { \ (simd-vbitor)        [ %or-vector-reps             ] }
-        { \ (simd-vbitxor)       [ %xor-vector-reps            ] }
-        { \ (simd-vbitnot)       [ %xor-vector-reps            ] }
-        { \ (simd-vand)          [ %and-vector-reps            ] }
-        { \ (simd-vandn)         [ %andn-vector-reps           ] }
-        { \ (simd-vor)           [ %or-vector-reps             ] }
-        { \ (simd-vxor)          [ %xor-vector-reps            ] }
-        { \ (simd-vnot)          [ %xor-vector-reps            ] }
-        { \ (simd-vlshift)       [ %shl-vector-reps            ] }
-        { \ (simd-vrshift)       [ %shr-vector-reps            ] }
-        { \ (simd-hlshift)       [ %horizontal-shl-vector-imm-reps ] }
-        { \ (simd-hrshift)       [ %horizontal-shr-vector-imm-reps ] }
-        { \ (simd-vshuffle-elements) [ (%shuffle-imm-reps)         ] }
-        { \ (simd-vshuffle-bytes)    [ %shuffle-vector-reps        ] }
-        { \ (simd-(vmerge-head)) [ %merge-vector-reps          ] }
-        { \ (simd-(vmerge-tail)) [ %merge-vector-reps          ] }
-        { \ (simd-(v>float))        [ %integer>float-vector-reps ] }
-        { \ (simd-(v>integer))      [ %float>integer-vector-reps ] }
-        { \ (simd-(vpack-signed))   [ %signed-pack-vector-reps   ] }
-        { \ (simd-(vpack-unsigned)) [ %unsigned-pack-vector-reps ] }
-        { \ (simd-(vunpack-head))   [ (%unpack-reps)             ] }
-        { \ (simd-(vunpack-tail))   [ (%unpack-reps)             ] }
-        { \ (simd-v<=)           [ unsign-rep cc<= %compare-vector-reps   ] }
-        { \ (simd-v<)            [ unsign-rep cc< %compare-vector-reps    ] }
-        { \ (simd-v=)            [ unsign-rep cc= %compare-vector-reps    ] }
-        { \ (simd-v>)            [ unsign-rep cc> %compare-vector-reps    ] }
-        { \ (simd-v>=)           [ unsign-rep cc>= %compare-vector-reps   ] }
-        { \ (simd-vunordered?)   [ unsign-rep cc/<>= %compare-vector-reps ] }
-        { \ (simd-gather-2)      [ %gather-vector-2-reps       ] }
-        { \ (simd-gather-4)      [ %gather-vector-4-reps       ] }
-        { \ (simd-vany?)         [ %test-vector-reps           ] }
-        { \ (simd-vall?)         [ %test-vector-reps           ] }
-        { \ (simd-vnone?)        [ %test-vector-reps           ] }
-    } case member? ;
diff --git a/basis/math/vectors/simd/mirrors/mirrors.factor b/basis/math/vectors/simd/mirrors/mirrors.factor
new file mode 100644 (file)
index 0000000..e8a103d
--- /dev/null
@@ -0,0 +1,3 @@
+USING: math.vectors.simd mirrors ;
+IN: math.vectors.simd.mirrors
+INSTANCE: simd-128          enumerated-sequence
index 2fbe8239655663c6289b5e4b1f1de15bea6789d4..540838bdd5b1705b8970a64a4f84c1ad1b4cf731 100644 (file)
@@ -1,6 +1,6 @@
 USING: classes.tuple.private cpu.architecture help.markup
-help.syntax kernel.private math math.vectors
-math.vectors.simd.intrinsics sequences ;
+help.syntax kernel.private math math.vectors math.vectors.simd.intrinsics
+sequences ;
 IN: math.vectors.simd
 
 ARTICLE: "math.vectors.simd.intro" "Introduction to SIMD support"
@@ -19,11 +19,11 @@ $nl
 ARTICLE: "math.vectors.simd.support" "Supported SIMD instruction sets and operations"
 "At present, the SIMD support makes use of a subset of SSE up to SSE4.1. The subset used depends on the current CPU type."
 $nl
-"SSE1 only supports single-precision SIMD (" { $snippet "float-4" } " and " { $snippet "float-8" } ")."
+"SSE1 only supports single-precision SIMD (" { $snippet "float-4" } ")."
 $nl
-"SSE2 introduces double-precision SIMD (" { $snippet "double-2" } " and " { $snippet "double-4" } ") and integer SIMD (all types). Integer SIMD is missing a few features, in particular the " { $link vmin } " and " { $link vmax } " operations only work on " { $snippet "uchar-16" } " and " { $snippet "short-8" } "."
+"SSE2 introduces double-precision SIMD (" { $snippet "double-2" } ") and integer SIMD (all types). Integer SIMD is missing a few features; in particular, the " { $link vmin } " and " { $link vmax } " operations only work on " { $snippet "uchar-16" } " and " { $snippet "short-8" } "."
 $nl
-"SSE3 introduces horizontal adds (summing all components of a single vector register), which is useful for computing dot products. Where available, SSE3 operations are used to speed up " { $link sum } ", " { $link v. } ", " { $link norm-sq } ", " { $link norm } ", and " { $link distance } "."
+"SSE3 introduces horizontal adds (summing all components of a single vector register), which are useful for computing dot products. Where available, SSE3 operations are used to speed up " { $link sum } ", " { $link v. } ", " { $link norm-sq } ", " { $link norm } ", and " { $link distance } "."
 $nl
 "SSSE3 introduces " { $link vabs } " for " { $snippet "char-16" } ", " { $snippet "short-8" } " and " { $snippet "int-4" } "."
 $nl
@@ -36,47 +36,18 @@ $nl
 ARTICLE: "math.vectors.simd.types" "SIMD vector types"
 "Each SIMD vector type is named " { $snippet "scalar-count" } ", where " { $snippet "scalar" } " is a scalar C type and " { $snippet "count" } " is a vector dimension."
 $nl
-"To use a SIMD vector type, a parsing word is used to generate the relevant code and bring it into the vocabulary search path; this is the same idea as with " { $link "specialized-arrays" } ":"
-{ $subsections
-    POSTPONE: SIMD:
-    POSTPONE: SIMDS:
-}
-"The following scalar types are supported:"
-{ $code
-    "char"
-    "uchar"
-    "short"
-    "ushort"
-    "int"
-    "uint"
-    "longlong"
-    "ulonglong"
-    "float"
-    "double"
-}
-
-"The following vector types are generated from the above scalar types:"
+"The following vector types are available:"
 { $code
     "char-16"
     "uchar-16"
-    "char-32"
-    "uchar-32"
     "short-8"
     "ushort-8"
-    "short-16"
-    "ushort-16"
     "int-4"
     "uint-4"
-    "int-8"
-    "uint-8"
     "longlong-2"
     "ulonglong-2"
-    "longlong-4"
-    "ulonglong-4"
     "float-4"
-    "float-8"
     "double-2"
-    "double-4"
 } ;
 
 ARTICLE: "math.vectors.simd.words" "SIMD vector words"
@@ -103,19 +74,17 @@ $nl
 { $code
 """USING: compiler.tree.debugger math.vectors
 math.vectors.simd ;
-SIMD: double
 SYMBOLS: x y ;
 
 [
-    double-4{ 1.5 2.0 3.7 0.4 } x set
-    double-4{ 1.5 2.0 3.7 0.4 } y set
+    float-4{ 1.5 2.0 3.7 0.4 } x set
+    float-4{ 1.5 2.0 3.7 0.4 } y set
     x get y get v+
 ] optimizer-report.""" }
 "The following word benefits from SIMD optimization, because it begins with an unsafe declaration:"
 { $code
 """USING: compiler.tree.debugger kernel.private
 math.vectors math.vectors.simd ;
-SIMD: float
 IN: simd-demo
 
 : interpolate ( v a b -- w )
@@ -129,7 +98,6 @@ $nl
 { $code
 """USING: compiler.tree.debugger hints
 math.vectors math.vectors.simd ;
-SIMD: float
 IN: simd-demo
 
 : interpolate ( v a b -- w )
@@ -145,7 +113,6 @@ $nl
 "In the " { $snippet "interpolate" } " word, there is still a call to the " { $link <tuple-boa> } " primitive, because the return value at the end is being boxed on the heap. In the next example, no memory allocation occurs at all because the SIMD vectors are stored inside a struct class (see " { $link "classes.struct" } "); also note the use of inlining:"
 { $code
 """USING: compiler.tree.debugger math.vectors math.vectors.simd ;
-SIMD: float
 IN: simd-demo
 
 STRUCT: actor
@@ -182,7 +149,6 @@ ARTICLE: "math.vectors.simd.intrinsics" "Low-level SIMD primitives"
 { $list
     "They operate on raw byte arrays, with a separate “representation” parameter passed in to determine the type of the operands and result."
     "They are unsafe; passing values which are not byte arrays, or byte arrays with the wrong size, will dereference invalid memory and possibly crash Factor."
-    { "They do not have software fallbacks; if the current CPU does not have SIMD support, a " { $link bad-simd-call } " error will be thrown." }
 }
 "The compiler converts " { $link "math-vectors" } " into SIMD primitives automatically in cases where it is safe; this means that the input types are known to be SIMD vectors, and the CPU supports SIMD."
 $nl
@@ -203,7 +169,7 @@ $nl
 ARTICLE: "math.vectors.simd.accuracy" "Numerical accuracy of SIMD primitives"
 "No guarantees are made that " { $vocab-link "math.vectors.simd" } " words will give identical results on different SSE versions, or between the hardware intrinsics and the software fallbacks."
 $nl
-"In particular, horizontal operations on " { $snippet "float-4" } " and " { $snippet "float-8" } " are affected by this. They are computed with lower precision in intrinsics than the software fallback. Horizontal operations include anything involving adding together the components of a vector, such as " { $link sum } " or " { $link normalize } "." ;
+"In particular, horizontal operations on " { $snippet "float-4" } " vectors are affected by this. They are computed with lower precision in intrinsics than the software fallback. Horizontal operations include anything involving adding together the components of a vector, such as " { $link sum } " or " { $link normalize } "." ;
 
 ARTICLE: "math.vectors.simd" "Hardware vector arithmetic (SIMD)"
 "The " { $vocab-link "math.vectors.simd" } " vocabulary extends the " { $vocab-link "math.vectors" } " vocabulary to support efficient vector arithmetic on small, fixed-size vectors."
@@ -218,16 +184,4 @@ ARTICLE: "math.vectors.simd" "Hardware vector arithmetic (SIMD)"
     "math.vectors.simd.intrinsics"
 } ;
 
-HELP: SIMD:
-{ $syntax "SIMD: type" }
-{ $values { "type" "a scalar C type" } }
-{ $description "Defines 128-bit and 256-bit SIMD arrays for holding elements of " { $snippet "type" } " into the vocabulary search path. The allowed scalar types, and the auto-generated type/length vector combinations that result, are listed in " { $link "math.vectors.simd.types" } ". Generated words are documented in " { $link "math.vectors.simd.words" } "." } ;
-
-HELP: SIMDS:
-{ $syntax "SIMDS: type type type ... ;" }
-{ $values { "type" "a scalar C type" } }
-{ $description "Defines 128-bit and 256-bit SIMD arrays for holding elements of each " { $snippet "type" } " into the vocabulary search path. The possible type/length combinations are listed in " { $link "math.vectors.simd.types" } " and the generated words are documented in " { $link "math.vectors.simd.words" } "." } ;
-
-{ POSTPONE: SIMD: POSTPONE: SIMDS: } related-words
-
 ABOUT: "math.vectors.simd"
index 396b8da22a5660bdf5ccbc0f68d9359be0e291c5..342c565dcebe16590a4ac58b76835b3dd3616ef5 100644 (file)
@@ -3,22 +3,14 @@ effects fry io kernel kernel.private math math.functions
 math.private math.vectors math.vectors.simd
 math.vectors.simd.private prettyprint random sequences system
 tools.test vocabs assocs compiler.cfg.debugger words
-locals math.vectors.specialization combinators cpu.architecture
-math.vectors.conversion.backend
-math.vectors.simd.intrinsics namespaces byte-arrays alien
+locals combinators cpu.architecture namespaces byte-arrays alien
 specialized-arrays classes.struct eval classes.algebra sets
-quotations math.constants compiler.units ;
+quotations math.constants compiler.units splitting ;
+FROM: math.vectors.simd.intrinsics => alien-vector set-alien-vector ;
 QUALIFIED-WITH: alien.c-types c
 SPECIALIZED-ARRAY: c:float
-SIMD: c:char
-SIMDS: c:uchar c:short c:ushort c:int c:uint c:longlong c:ulonglong c:float c:double ;
 IN: math.vectors.simd.tests
 
-! Make sure the functor doesn't generate bogus vocabularies
-2 [ [ "USE: math.vectors.simd SIMD: rubinius" eval( -- ) ] must-fail ] times
-
-[ f ] [ "math.vectors.simd.instances.rubinius" vocab ] unit-test
-
 ! Test type propagation
 [ V{ float } ] [ [ { float-4 } declare norm-sq ] final-classes ] unit-test
 
@@ -38,10 +30,6 @@ IN: math.vectors.simd.tests
 
 [ V{ integer } ] [ [ { longlong-2 } declare second ] final-classes ] unit-test
 
-[ V{ int-8 } ] [ [ { int-8 int-8 } declare v+ ] final-classes ] unit-test
-
-[ t ] [ [ { int-8 } declare second ] final-classes first integer class<= ] unit-test
-
 ! Test puns; only on x86
 cpu x86? [
     [ double-2{ 4 1024 } ] [
@@ -55,26 +43,80 @@ CONSTANT: simd-classes
     {
         char-16
         uchar-16
-        char-32
-        uchar-32
         short-8
         ushort-8
-        short-16
-        ushort-16
         int-4
         uint-4
-        int-8
-        uint-8
         longlong-2
         ulonglong-2
-        longlong-4
-        ulonglong-4
         float-4
-        float-8
         double-2
-        double-4
     }
 
+SYMBOLS: -> +vector+ +any-vector+ +scalar+ +boolean+ +nonnegative+ +literal+ ;
+
+CONSTANT: vector-words
+    H{
+        { [v-] { +vector+ +vector+ -> +vector+ } }
+        { distance { +vector+ +vector+ -> +nonnegative+ } }
+        { n*v { +scalar+ +vector+ -> +vector+ } }
+        { n+v { +scalar+ +vector+ -> +vector+ } }
+        { n-v { +scalar+ +vector+ -> +vector+ } }
+        { n/v { +scalar+ +vector+ -> +vector+ } }
+        { norm { +vector+ -> +nonnegative+ } }
+        { norm-sq { +vector+ -> +nonnegative+ } }
+        { normalize { +vector+ -> +vector+ } }
+        { v* { +vector+ +vector+ -> +vector+ } }
+        { vs* { +vector+ +vector+ -> +vector+ } }
+        { v*n { +vector+ +scalar+ -> +vector+ } }
+        { v*high { +vector+ +vector+ -> +vector+ } }
+        { v*hs+ { +vector+ +vector+ -> +vector+ } }
+        { v+ { +vector+ +vector+ -> +vector+ } }
+        { vs+ { +vector+ +vector+ -> +vector+ } }
+        { v+- { +vector+ +vector+ -> +vector+ } }
+        { v+n { +vector+ +scalar+ -> +vector+ } }
+        { v- { +vector+ +vector+ -> +vector+ } }
+        { vneg { +vector+ -> +vector+ } }
+        { vs- { +vector+ +vector+ -> +vector+ } }
+        { v-n { +vector+ +scalar+ -> +vector+ } }
+        { v. { +vector+ +vector+ -> +scalar+ } }
+        { vsad { +vector+ +vector+ -> +scalar+ } }
+        { v/ { +vector+ +vector+ -> +vector+ } }
+        { v/n { +vector+ +scalar+ -> +vector+ } }
+        { vceiling { +vector+ -> +vector+ } }
+        { vfloor { +vector+ -> +vector+ } }
+        { vmax { +vector+ +vector+ -> +vector+ } }
+        { vmin { +vector+ +vector+ -> +vector+ } }
+        { vavg { +vector+ +vector+ -> +vector+ } }
+        { vneg { +vector+ -> +vector+ } }
+        { vtruncate { +vector+ -> +vector+ } }
+        { sum { +vector+ -> +scalar+ } }
+        { vabs { +vector+ -> +vector+ } }
+        { vsqrt { +vector+ -> +vector+ } }
+        { vbitand { +vector+ +vector+ -> +vector+ } }
+        { vbitandn { +vector+ +vector+ -> +vector+ } }
+        { vbitor { +vector+ +vector+ -> +vector+ } }
+        { vbitxor { +vector+ +vector+ -> +vector+ } }
+        { vbitnot { +vector+ -> +vector+ } }
+        { vand { +vector+ +vector+ -> +vector+ } }
+        { vandn { +vector+ +vector+ -> +vector+ } }
+        { vor { +vector+ +vector+ -> +vector+ } }
+        { vxor { +vector+ +vector+ -> +vector+ } }
+        { vnot { +vector+ -> +vector+ } }
+        { vlshift { +vector+ +scalar+ -> +vector+ } }
+        { vrshift { +vector+ +scalar+ -> +vector+ } }
+        { (vmerge-head) { +vector+ +vector+ -> +vector+ } }
+        { (vmerge-tail) { +vector+ +vector+ -> +vector+ } }
+        { v<= { +vector+ +vector+ -> +vector+ } }
+        { v< { +vector+ +vector+ -> +vector+ } }
+        { v= { +vector+ +vector+ -> +vector+ } }
+        { v> { +vector+ +vector+ -> +vector+ } }
+        { v>= { +vector+ +vector+ -> +vector+ } }
+        { vunordered? { +vector+ +vector+ -> +vector+ } }
+    }
+
+: vector-word-inputs ( schema -- seq ) { -> } split first ;
+
 : with-ctors ( -- seq )
     simd-classes [ [ name>> "-with" append ] [ vocabulary>> ] bi lookup ] map ;
 
@@ -82,16 +124,17 @@ CONSTANT: simd-classes
     simd-classes [ [ name>> "-boa" append ] [ vocabulary>> ] bi lookup ] map ;
 
 : check-optimizer ( seq quot eq-quot -- failures )
-    '[
+    dup '[
         @
         [ dup [ class ] { } map-as ] dip '[ _ declare @ ]
         {
             [ "print-mr" get [ nip test-mr mr. ] [ 2drop ] if ]
             [ "print-checks" get [ [ . ] bi@ ] [ 2drop ] if ]
-            [ [ call ] dip call ]
-            [ [ call ] dip compile-call ]
+            [ [ [ call ] dip call ] call( quot quot -- result ) ]
+            [ [ [ call ] dip compile-call ] call( quot quot -- result ) ]
+            [ [ t "always-inline-simd-intrinsics" [ [ call ] dip compile-call ] with-variable ] call( quot quot -- result ) ]
         } 2cleave
-        @ not
+        [ drop @ ] [ nip @ ] 3bi and not
     ] filter ; inline
 
 "== Checking -new constructors" print
@@ -132,7 +175,8 @@ CONSTANT: simd-classes
 "== Checking vector operations" print
 
 : random-int-vector ( class -- vec )
-    new [ drop 1,000 random ] map ;
+    new [ drop 1000 random ] map ;
+
 : random-float-vector ( class -- vec )
     new [
         drop
@@ -158,7 +202,7 @@ CONSTANT: simd-classes
     { vsqrt n/v v/n v/ normalize } unique assoc-diff ;
 
 : remove-integer-words ( alist -- alist' )
-    { vlshift vrshift } unique assoc-diff ;
+    { vlshift vrshift v*high v*hs+ } unique assoc-diff ;
 
 : boolean-ops ( -- words )
     { vand vandn vor vxor vnot } ;
@@ -166,26 +210,15 @@ CONSTANT: simd-classes
 : remove-boolean-words ( alist -- alist' )
     boolean-ops unique assoc-diff ;
 
-: remove-special-words ( alist -- alist' )
-    ! These have their own tests later
-    {
-        hlshift hrshift vshuffle-bytes vshuffle-elements vbroadcast
-        vany? vall? vnone?
-        (v>float) (v>integer)
-        (vpack-signed) (vpack-unsigned)
-        (vunpack-head) (vunpack-tail)
-    } unique assoc-diff ;
-
 : ops-to-check ( elt-class -- alist )
     [ vector-words >alist ] dip
     float = [ remove-integer-words ] [ remove-float-words ] if
-    remove-boolean-words
-    remove-special-words ;
+    remove-boolean-words ;
 
 : check-vector-ops ( class elt-class compare-quot -- )
     [
         [ nip ops-to-check ] 2keep
-        '[ first2 inputs _ _ check-vector-op ]
+        '[ first2 vector-word-inputs _ _ check-vector-op ]
     ] dip check-optimizer ; inline
 
 : (approx=) ( x y -- ? )
@@ -233,10 +266,10 @@ simd-classes&reps [
     ] [ ] map-as
     word '[ _ execute ] ;
 
-: check-boolean-ops ( class elt-class compare-quot -- )
+: check-boolean-ops ( class elt-class compare-quot -- seq )
     [
-        [ boolean-ops [ dup word-schema ] { } map>assoc ] 2dip
-        '[ first2 inputs _ _ check-boolean-op ]
+        [ boolean-ops [ dup vector-words at ] { } map>assoc ] 2dip
+        '[ first2 vector-word-inputs _ _ check-boolean-op ]
     ] dip check-optimizer ; inline
 
 simd-classes&reps [
@@ -357,13 +390,15 @@ simd-classes [
     new [ drop 16 random ] map ;
 
 :: test-shift-vector ( class -- ? )
-    class random-int-vector :> src
-    char-16 random-shift-vector :> perm
-    { class char-16 } :> decl
-
-    src perm vshuffle
-    src perm [ decl declare vshuffle ] compile-call
-    = ; inline
+    [
+        class random-int-vector :> src
+        char-16 random-shift-vector :> perm
+        { class char-16 } :> decl
+    
+        src perm vshuffle
+        src perm [ decl declare vshuffle ] compile-call
+        =
+    ] call( -- ? ) ;
 
 { char-16 uchar-16 short-8 ushort-8 int-4 uint-4 longlong-2 ulonglong-2 }
 [ 10 swap '[ [ t ] [ _ test-shift-vector ] unit-test ] times ] each
@@ -371,19 +406,23 @@ simd-classes [
 "== Checking vector tests" print
 
 :: test-vector-tests-bool ( vector declaration -- none? any? all? )
-    vector
-    [ [ declaration declare vnone? ] compile-call ]
-    [ [ declaration declare vany?  ] compile-call ]
-    [ [ declaration declare vall?  ] compile-call ] tri ; inline
+    [
+        vector
+        [ [ declaration declare vnone? ] compile-call ]
+        [ [ declaration declare vany?  ] compile-call ]
+        [ [ declaration declare vall?  ] compile-call ] tri
+    ] call( -- none? any? all? ) ;
 
 : yes ( -- x ) t ;
 : no ( -- x ) f ;
 
 :: test-vector-tests-branch ( vector declaration -- none? any? all? )
-    vector
-    [ [ declaration declare vnone? [ yes ] [ no ] if ] compile-call ]
-    [ [ declaration declare vany?  [ yes ] [ no ] if ] compile-call ]
-    [ [ declaration declare vall?  [ yes ] [ no ] if ] compile-call ] tri ; inline
+    [
+        vector
+        [ [ declaration declare vnone? [ yes ] [ no ] if ] compile-call ]
+        [ [ declaration declare vany?  [ yes ] [ no ] if ] compile-call ]
+        [ [ declaration declare vall?  [ yes ] [ no ] if ] compile-call ] tri
+    ] call( -- none? any? all? ) ;
 
 TUPLE: inconsistent-vector-test bool branch ;
 
@@ -391,12 +430,14 @@ TUPLE: inconsistent-vector-test bool branch ;
     2dup = [ drop ] [ inconsistent-vector-test boa ] if ;
 
 :: test-vector-tests ( vector decl -- none? any? all? )
-    vector decl test-vector-tests-bool :> ( bool-none bool-any bool-all )
-    vector decl test-vector-tests-branch :> ( branch-none branch-any branch-all )
-    
-    bool-none branch-none ?inconsistent
-    bool-any  branch-any  ?inconsistent
-    bool-all  branch-all  ?inconsistent ; inline
+    [
+        vector decl test-vector-tests-bool :> ( bool-none bool-any bool-all )
+        vector decl test-vector-tests-branch :> ( branch-none branch-any branch-all )
+        
+        bool-none branch-none ?inconsistent
+        bool-any  branch-any  ?inconsistent
+        bool-all  branch-all  ?inconsistent
+    ] call( -- none? any? all? ) ;
 
 [ f t t ]
 [ float-4{ t t t t } { float-4 } test-vector-tests ] unit-test
@@ -419,32 +460,11 @@ TUPLE: inconsistent-vector-test bool branch ;
 [ t f f ]
 [ int-4{ f f f f } { int-4 } test-vector-tests ] unit-test
 
-[ f t t ]
-[ float-8{ t t t t t t t t } { float-8 } test-vector-tests ] unit-test
-[ f t f ]
-[ float-8{ f t t t t f t t } { float-8 } test-vector-tests ] unit-test
-[ t f f ]
-[ float-8{ f f f f f f f f } { float-8 } test-vector-tests ] unit-test
-
-[ f t t ]
-[ double-4{ t t t t } { double-4 } test-vector-tests ] unit-test
-[ f t f ]
-[ double-4{ f t t f } { double-4 } test-vector-tests ] unit-test
-[ t f f ]
-[ double-4{ f f f f } { double-4 } test-vector-tests ] unit-test
-
-[ f t t ]
-[ int-8{ t t t t t t t t } { int-8 } test-vector-tests ] unit-test
-[ f t f ]
-[ int-8{ f t t t t f f f } { int-8 } test-vector-tests ] unit-test
-[ t f f ]
-[ int-8{ f f f f f f f f } { int-8 } test-vector-tests ] unit-test
-
 "== Checking element access" print
 
 ! Test element access -- it should box bignums for int-4 on x86
 : test-accesses ( seq -- failures )
-    [ length >array ] keep
+    [ length iota >array ] keep
     '[ [ _ 1quotation ] dip '[ _ swap nth ] ] [ = ] check-optimizer ; inline
 
 [ { } ] [ float-4{ 1.0 2.0 3.0 4.0 } test-accesses ] unit-test
@@ -459,18 +479,10 @@ TUPLE: inconsistent-vector-test bool branch ;
 [ { } ] [ longlong-2{ 1 2 } test-accesses ] unit-test
 [ { } ] [ ulonglong-2{ 1 2 } test-accesses ] unit-test
 
-[ { } ] [ float-8{ 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 } test-accesses ] unit-test
-[ { } ] [ int-8{ 1 2 3 4 5 6 7 8 } test-accesses ] unit-test
-[ { } ] [ uint-8{ 1 2 3 4 5 6 7 8 } test-accesses ] unit-test
-
-[ { } ] [ double-4{ 1.0 2.0 3.0 4.0 } test-accesses ] unit-test
-[ { } ] [ longlong-4{ 1 2 3 4 } test-accesses ] unit-test
-[ { } ] [ ulonglong-4{ 1 2 3 4 } test-accesses ] unit-test
-
 "== Checking broadcast" print
 : test-broadcast ( seq -- failures )
-    [ length >array ] keep
-    '[ [ _ 1quotation ] dip '[ _ vbroadcast ] ] [ = ] check-optimizer ; inline
+    [ length iota >array ] keep
+    '[ [ _ 1quotation ] dip '[ _ vbroadcast ] ] [ = ] check-optimizer ;
 
 [ { } ] [ float-4{ 1.0 2.0 3.0 4.0 } test-broadcast ] unit-test
 [ { } ] [ int-4{ HEX: 7fffffff 3 4 -8 } test-broadcast ] unit-test
@@ -480,14 +492,6 @@ TUPLE: inconsistent-vector-test bool branch ;
 [ { } ] [ longlong-2{ 1 2 } test-broadcast ] unit-test
 [ { } ] [ ulonglong-2{ 1 2 } test-broadcast ] unit-test
 
-[ { } ] [ float-8{ 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 } test-broadcast ] unit-test
-[ { } ] [ int-8{ 1 2 3 4 5 6 7 8 } test-broadcast ] unit-test
-[ { } ] [ uint-8{ 1 2 3 4 5 6 7 8 } test-broadcast ] unit-test
-
-[ { } ] [ double-4{ 1.0 2.0 3.0 4.0 } test-broadcast ] unit-test
-[ { } ] [ longlong-4{ 1 2 3 4 } test-broadcast ] unit-test
-[ { } ] [ ulonglong-4{ 1 2 3 4 } test-broadcast ] unit-test
-
 ! Make sure we use the fallback in the correct situations
 [ int-4{ 3 3 3 3 } ] [ int-4{ 12 34 3 17 } 2 [ { int-4 fixnum } declare vbroadcast ] compile-call ] unit-test
 
@@ -521,37 +525,37 @@ TUPLE: inconsistent-vector-test bool branch ;
 STRUCT: simd-struct
 { x float-4 }
 { y longlong-2 }
-{ z double-4 }
-{ w int-8 } ;
+{ z double-2 }
+{ w int-4 } ;
 
 [ t ] [ [ simd-struct <struct> ] compile-call >c-ptr [ 0 = ] all? ] unit-test
 
 [
     float-4{ 1 2 3 4 }
     longlong-2{ 2 1 }
-    double-4{ 4 3 2 1 }
-    int-8{ 1 2 3 4 5 6 7 8 }
+    double-2{ 4 3 }
+    int-4{ 1 2 3 4 }
 ] [
     simd-struct <struct>
     float-4{ 1 2 3 4 } >>x
     longlong-2{ 2 1 } >>y
-    double-4{ 4 3 2 1 } >>z
-    int-8{ 1 2 3 4 5 6 7 8 } >>w
+    double-2{ 4 3 } >>z
+    int-4{ 1 2 3 4 } >>w
     { [ x>> ] [ y>> ] [ z>> ] [ w>> ] } cleave
 ] unit-test
 
 [
     float-4{ 1 2 3 4 }
     longlong-2{ 2 1 }
-    double-4{ 4 3 2 1 }
-    int-8{ 1 2 3 4 5 6 7 8 }
+    double-2{ 4 3 }
+    int-4{ 1 2 3 4 }
 ] [
     [
         simd-struct <struct>
         float-4{ 1 2 3 4 } >>x
         longlong-2{ 2 1 } >>y
-        double-4{ 4 3 2 1 } >>z
-        int-8{ 1 2 3 4 5 6 7 8 } >>w
+        double-2{ 4 3 } >>z
+        int-4{ 1 2 3 4 } >>w
         { [ x>> ] [ y>> ] [ z>> ] [ w>> ] } cleave
     ] compile-call
 ] unit-test
@@ -561,9 +565,9 @@ STRUCT: simd-struct
 [ ] [ char-16 new 1array stack. ] unit-test
 
 ! CSSA bug
-[ 8000000 ] [
-    int-8{ 1000 1000 1000 1000 1000 1000 1000 1000 }
-    [ { int-8 } declare dup [ * ] [ + ] 2map-reduce ] compile-call
+[ 4000000 ] [
+    int-4{ 1000 1000 1000 1000 }
+    [ { int-4 } declare dup [ * ] [ + ] 2map-reduce ] compile-call
 ] unit-test
 
 ! Coalescing was too aggressive
index 388fed5f31cee345692a202f09c12e698c49e01c..acf13599c1f059552a8671ca323531e09370a7ce 100644 (file)
-! Copyright (C) 2009 Slava Pestov.
-! See http://factorcode.org/license.txt for BSD license.
-USING: alien.c-types combinators fry kernel parser math math.parser
-math.vectors.simd.functor sequences splitting vocabs.generated
-vocabs.loader vocabs.parser words accessors vocabs compiler.units
-definitions ;
+USING: accessors alien.c-types arrays byte-arrays classes combinators
+cpu.architecture effects fry functors generalizations generic
+generic.parser kernel lexer literals macros math math.functions
+math.vectors math.vectors.private math.vectors.simd.intrinsics namespaces parser
+prettyprint.custom quotations sequences sequences.private vocabs
+vocabs.loader words ;
 QUALIFIED-WITH: alien.c-types c
 IN: math.vectors.simd
 
-ERROR: bad-base-type type ;
+ERROR: bad-simd-length got expected ;
+
+ERROR: bad-simd-vector obj ;
+
+<<
+<PRIVATE
+! Primitive SIMD constructors
+
+GENERIC: new-underlying ( underlying seq -- seq' )
+
+: make-underlying ( seq quot -- seq' )
+    dip new-underlying ; inline
+: change-underlying ( seq quot -- seq' )
+    '[ underlying>> @ ] keep new-underlying ; inline
+PRIVATE>
+>>
+
+<PRIVATE
+
+! Helper for boolean vector literals
+
+: vector-true-value ( class -- value )
+    { c:float c:double } member? [ -1 bits>double ] [ -1 ] if ; foldable
+
+: vector-false-value ( type -- value )
+    { c:float c:double } member? [ 0.0 ] [ 0 ] if ; foldable
+
+: boolean>element ( bool/elt type -- elt )
+    swap {
+        { t [ vector-true-value  ] }
+        { f [ vector-false-value ] }
+        [ nip ]
+    } case ; inline
+
+PRIVATE>
+
+! SIMD base type
+
+TUPLE: simd-128
+    { underlying byte-array read-only initial: $[ 16 <byte-array> ] } ;
+
+GENERIC: simd-element-type ( obj -- c-type )
+GENERIC: simd-rep ( simd -- rep )
+GENERIC: simd-with ( n exemplar -- v )
+
+M: object simd-element-type drop f ;
+M: object simd-rep drop f ;
+
+<<
+<PRIVATE
+
+DEFER: simd-construct-op
+
+! Unboxers for SIMD operations
+: if-both-vectors ( a b rep t f -- )
+    [ 2over [ simd-128? ] both? ] 2dip if ; inline
+
+: if-both-vectors-match ( a b rep t f -- )
+    [ 3dup [ drop [ simd-128? ] both? ] [ '[ simd-rep _ eq? ] both? ] 3bi and ]
+    2dip if ; inline
+
+: simd-unbox ( a -- a (a) )
+    [ ] [ underlying>> ] bi ; inline
+
+: v->v-op ( a rep quot: ( (a) rep -- (c) ) fallback-quot -- c )
+    drop [ simd-unbox ] 2dip 2curry make-underlying ; inline
+
+: vn->v-op ( a n rep quot: ( (a) n rep -- (c) ) fallback-quot -- c )
+    drop [ simd-unbox ] 3dip 3curry make-underlying ; inline
+
+: vn->n-op ( a n rep quot: ( (a) n rep -- n ) fallback-quot -- n )
+    drop [ underlying>> ] 3dip call ; inline
+
+: v->n-op ( a rep quot: ( (a) rep -- n ) fallback-quot -- n )
+    drop [ underlying>> ] 2dip call ; inline
+
+: (vv->v-op) ( a b rep quot: ( (a) (b) rep -- (c) ) -- c )
+    [ [ simd-unbox ] [ underlying>> ] bi* ] 2dip 3curry make-underlying ; inline
+
+: (vv->n-op) ( a b rep quot: ( (a) (b) rep -- n ) -- n )
+    [ [ underlying>> ] bi@ ] 2dip 3curry call ; inline
+    
+: vv->v-op ( a b rep quot: ( (a) (b) rep -- (c) ) fallback-quot -- c )
+    [ '[ _ (vv->v-op) ] ] [ '[ drop @ ] ] bi* if-both-vectors-match ; inline
+
+: vv'->v-op ( a b rep quot: ( (a) (b) rep -- (c) ) fallback-quot -- c )
+    [ '[ _ (vv->v-op) ] ] [ '[ drop @ ] ] bi* if-both-vectors ; inline
+
+: vv->n-op ( a b rep quot: ( (a) (b) rep -- n ) fallback-quot -- n )
+    [ '[ _ (vv->n-op) ] ] [ '[ drop @ ] ] bi* if-both-vectors-match ; inline
+
+PRIVATE>
+>>
+
+<<
+
+! SIMD vectors as sequences
+
+M: simd-128 hashcode* underlying>> hashcode* ; inline
+M: simd-128 clone [ clone ] change-underlying ; inline
+M: simd-128 c:byte-length drop 16 ; inline
+
+M: simd-128 new-sequence
+    2dup length =
+    [ nip [ 16 (byte-array) ] make-underlying ]
+    [ length bad-simd-length ] if ; inline
+
+M: simd-128 equal?
+    dup simd-rep [ drop v= vall? ] [ 3drop f ] if-both-vectors-match ; inline
+
+! SIMD primitive operations
+
+M: simd-128 v+
+    dup simd-rep [ (simd-v+)                ] [ call-next-method ] vv->v-op ; inline
+M: simd-128 v-
+    dup simd-rep [ (simd-v-)                ] [ call-next-method ] vv->v-op ; inline
+M: simd-128 vneg
+    dup simd-rep [ (simd-vneg)              ] [ call-next-method ] v->v-op  ; inline
+M: simd-128 v+-
+    dup simd-rep [ (simd-v+-)               ] [ call-next-method ] vv->v-op ; inline
+M: simd-128 vs+
+    dup simd-rep [ (simd-vs+)               ] [ call-next-method ] vv->v-op ; inline
+M: simd-128 vs-
+    dup simd-rep [ (simd-vs-)               ] [ call-next-method ] vv->v-op ; inline
+M: simd-128 vs*
+    dup simd-rep [ (simd-vs*)               ] [ call-next-method ] vv->v-op ; inline
+M: simd-128 v*
+    dup simd-rep [ (simd-v*)                ] [ call-next-method ] vv->v-op ; inline
+M: simd-128 v*high
+    dup simd-rep [ (simd-v*high)            ] [ call-next-method ] vv->v-op ; inline
+M: simd-128 v/
+    dup simd-rep [ (simd-v/)                ] [ call-next-method ] vv->v-op ; inline
+M: simd-128 vavg
+    dup simd-rep [ (simd-vavg)              ] [ call-next-method ] vv->v-op ; inline
+M: simd-128 vmin
+    dup simd-rep [ (simd-vmin)              ] [ call-next-method ] vv->v-op ; inline
+M: simd-128 vmax
+    dup simd-rep [ (simd-vmax)              ] [ call-next-method ] vv->v-op ; inline
+M: simd-128 v.
+    dup simd-rep [ (simd-v.)                ] [ call-next-method ] vv->n-op ; inline
+M: simd-128 vsad
+    dup simd-rep [ (simd-vsad)              ] [ call-next-method ] vv->n-op ; inline
+M: simd-128 vsqrt
+    dup simd-rep [ (simd-vsqrt)             ] [ call-next-method ] v->v-op  ; inline
+M: simd-128 sum
+    dup simd-rep [ (simd-sum)               ] [ call-next-method ] v->n-op  ; inline
+M: simd-128 vabs
+    dup simd-rep [ (simd-vabs)              ] [ call-next-method ] v->v-op  ; inline
+M: simd-128 vbitand
+    dup simd-rep [ (simd-vbitand)           ] [ call-next-method ] vv->v-op ; inline
+M: simd-128 vbitandn
+    dup simd-rep [ (simd-vbitandn)          ] [ call-next-method ] vv->v-op ; inline
+M: simd-128 vbitor
+    dup simd-rep [ (simd-vbitor)            ] [ call-next-method ] vv->v-op ; inline
+M: simd-128 vbitxor
+    dup simd-rep [ (simd-vbitxor)           ] [ call-next-method ] vv->v-op ; inline
+M: simd-128 vbitnot
+    dup simd-rep [ (simd-vbitnot)           ] [ call-next-method ] v->v-op  ; inline
+M: simd-128 vand
+    dup simd-rep [ (simd-vand)              ] [ call-next-method ] vv->v-op ; inline
+M: simd-128 vandn
+    dup simd-rep [ (simd-vandn)             ] [ call-next-method ] vv->v-op ; inline
+M: simd-128 vor
+    dup simd-rep [ (simd-vor)               ] [ call-next-method ] vv->v-op ; inline
+M: simd-128 vxor
+    dup simd-rep [ (simd-vxor)              ] [ call-next-method ] vv->v-op ; inline
+M: simd-128 vnot
+    dup simd-rep [ (simd-vnot)              ] [ call-next-method ] v->v-op  ; inline
+M: simd-128 vlshift
+    over simd-rep [ (simd-vlshift)           ] [ call-next-method ] vn->v-op ; inline
+M: simd-128 vrshift
+    over simd-rep [ (simd-vrshift)           ] [ call-next-method ] vn->v-op ; inline
+M: simd-128 hlshift
+    over simd-rep [ (simd-hlshift)           ] [ call-next-method ] vn->v-op ; inline
+M: simd-128 hrshift
+    over simd-rep [ (simd-hrshift)           ] [ call-next-method ] vn->v-op ; inline
+M: simd-128 vshuffle-elements
+    over simd-rep [ (simd-vshuffle-elements) ] [ call-next-method ] vn->v-op ; inline
+M: simd-128 vshuffle-bytes
+    dup simd-rep [ (simd-vshuffle-bytes)    ] [ call-next-method ] vv'->v-op ; inline
+M: simd-128 (vmerge-head)
+    dup simd-rep [ (simd-vmerge-head)       ] [ call-next-method ] vv->v-op ; inline
+M: simd-128 (vmerge-tail)
+    dup simd-rep [ (simd-vmerge-tail)       ] [ call-next-method ] vv->v-op ; inline
+M: simd-128 v<=
+    dup simd-rep [ (simd-v<=)               ] [ call-next-method ] vv->v-op ; inline
+M: simd-128 v<
+    dup simd-rep [ (simd-v<)                ] [ call-next-method ] vv->v-op ; inline
+M: simd-128 v=
+    dup simd-rep [ (simd-v=)                ] [ call-next-method ] vv->v-op ; inline
+M: simd-128 v>
+    dup simd-rep [ (simd-v>)                ] [ call-next-method ] vv->v-op ; inline
+M: simd-128 v>=
+    dup simd-rep [ (simd-v>=)               ] [ call-next-method ] vv->v-op ; inline
+M: simd-128 vunordered?
+    dup simd-rep [ (simd-vunordered?)       ] [ call-next-method ] vv->v-op ; inline
+M: simd-128 vany?
+    dup simd-rep [ (simd-vany?)             ] [ call-next-method ] v->n-op  ; inline
+M: simd-128 vall?
+    dup simd-rep [ (simd-vall?)             ] [ call-next-method ] v->n-op  ; inline
+M: simd-128 vnone?
+    dup simd-rep [ (simd-vnone?)            ] [ call-next-method ] v->n-op  ; inline
+
+! SIMD high-level specializations
+
+M: simd-128 vbroadcast swap [ nth ] [ simd-with ] bi ; inline
+M: simd-128 n+v [ simd-with ] keep v+ ; inline
+M: simd-128 n-v [ simd-with ] keep v- ; inline
+M: simd-128 n*v [ simd-with ] keep v* ; inline
+M: simd-128 n/v [ simd-with ] keep v/ ; inline
+M: simd-128 v+n over simd-with v+ ; inline
+M: simd-128 v-n over simd-with v- ; inline
+M: simd-128 v*n over simd-with v* ; inline
+M: simd-128 v/n over simd-with v/ ; inline
+M: simd-128 norm-sq dup v. assert-positive ; inline
+M: simd-128 distance v- norm ; inline
+
+M: simd-128 >pprint-sequence ;
+M: simd-128 pprint* pprint-object ;
 
 <PRIVATE
 
-: simd-vocab ( base-type -- vocab )
-    name>> "math.vectors.simd.instances." prepend ;
+! SIMD concrete type functor
+
+FUNCTOR: define-simd-128 ( T -- )
+
+A      DEFINES-CLASS ${T}
+A-rep  IS            ${T}-rep
+>A     DEFINES       >${T}
+A-boa  DEFINES       ${T}-boa
+A-with DEFINES       ${T}-with
+A-cast DEFINES       ${T}-cast
+A{     DEFINES       ${T}{
+
+ELT     [ A-rep rep-component-type ]
+N       [ A-rep rep-length ]
+COERCER [ ELT c-type-class "coercer" word-prop [ ] or ]
+
+SET-NTH [ ELT dup c:c-setter c:array-accessor ]
 
-: parse-base-type ( c-type -- c-type )
-    dup { c:char c:uchar c:short c:ushort c:int c:uint c:longlong c:ulonglong c:float c:double } member-eq?
-    [ bad-base-type ] unless ;
+BOA-EFFECT [ N "n" <array> { "v" } <effect> ]
 
-: forget-instances ( -- )
-    [
-        "math.vectors.simd.instances" child-vocabs
-        [ forget-vocab ] each
-    ] with-compilation-unit ;
+WHERE
+
+TUPLE: A < simd-128 ;
+
+M: A new-underlying    drop \ A boa ; inline
+M: A simd-rep          drop A-rep ; inline
+M: A simd-element-type drop ELT ; inline
+M: A simd-with         drop A-with ; inline
+
+M: A nth-unsafe
+    swap \ A-rep [ (simd-select) ] [ call-next-method ] vn->n-op ; inline
+M: A set-nth-unsafe
+    [ ELT boolean>element ] 2dip
+    underlying>> SET-NTH call ; inline
+
+: >A ( seq -- simd ) \ A new clone-like ; inline
+
+M: A like drop dup \ A instance? [ >A ] unless ; inline
+
+: A-with ( n -- v ) COERCER call \ A-rep (simd-with) \ A boa ; inline
+: A-cast ( v -- v' ) underlying>> \ A boa ; inline
+
+M: A length drop N ; inline
+
+\ A-boa
+[ COERCER N napply ] N {
+    { 2 [ [ A-rep (simd-gather-2) A boa ] ] }
+    { 4 [ [ A-rep (simd-gather-4) A boa ] ] }
+    [ \ A new '[ _ _ nsequence ] ]
+} case compose
+BOA-EFFECT define-inline
+
+M: A pprint-delims drop \ A{ \ } ;
+SYNTAX: A{ \ } [ >A ] parse-literal ;
+
+INSTANCE: A sequence
+
+c:<c-type>
+    byte-array >>class
+    A >>boxed-class
+    { A-rep alien-vector A boa } >quotation >>getter
+    {
+        [ dup simd-128? [ bad-simd-vector ] unless underlying>> ] 2dip
+        A-rep set-alien-vector
+    } >quotation >>setter
+    16 >>size
+    16 >>align
+    A-rep >>rep
+\ A c:typedef
+
+;FUNCTOR
+
+SYNTAX: SIMD-128:
+    scan define-simd-128 ;
 
 PRIVATE>
 
-: define-simd-vocab ( type -- vocab )
-    parse-base-type
-    [ simd-vocab ] keep '[
-        _
-        [ define-simd-128 ]
-        [ define-simd-256 ] bi
-    ] generate-vocab ;
+>>
+
+! SIMD instances
+
+SIMD-128: char-16
+SIMD-128: uchar-16
+SIMD-128: short-8
+SIMD-128: ushort-8
+SIMD-128: int-4
+SIMD-128: uint-4
+SIMD-128: longlong-2
+SIMD-128: ulonglong-2
+SIMD-128: float-4
+SIMD-128: double-2
+
+! misc
 
-SYNTAX: SIMD:
-    scan-word define-simd-vocab use-vocab ;
+M: simd-128 vshuffle ( u perm -- v )
+    vshuffle-bytes ; inline
 
-SYNTAX: SIMDS:
-    \ ; parse-until [ define-simd-vocab use-vocab ] each ;
+M: uchar-16 v*hs+
+    uchar-16-rep [ (simd-v*hs+) ] [ call-next-method ] vv->v-op short-8-cast ; inline
+M: ushort-8 v*hs+
+    ushort-8-rep [ (simd-v*hs+) ] [ call-next-method ] vv->v-op uint-4-cast ; inline
+M: uint-4 v*hs+
+    uint-4-rep [ (simd-v*hs+) ] [ call-next-method ] vv->v-op ulonglong-2-cast ; inline
+M: char-16 v*hs+
+    char-16-rep [ (simd-v*hs+) ] [ call-next-method ] vv->v-op short-8-cast ; inline
+M: short-8 v*hs+
+    short-8-rep [ (simd-v*hs+) ] [ call-next-method ] vv->v-op int-4-cast ; inline
+M: int-4 v*hs+
+    int-4-rep [ (simd-v*hs+) ] [ call-next-method ] vv->v-op longlong-2-cast ; inline
 
+"mirrors" vocab [
+    "math.vectors.simd.mirrors" require
+] when
diff --git a/basis/math/vectors/specialization/specialization-tests.factor b/basis/math/vectors/specialization/specialization-tests.factor
deleted file mode 100644 (file)
index f4d4fd9..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-IN: math.vectors.specialization.tests
-USING: compiler.tree.debugger math.vectors tools.test kernel
-kernel.private math specialized-arrays ;
-QUALIFIED-WITH: alien.c-types c
-QUALIFIED-WITH: alien.complex c
-SPECIALIZED-ARRAY: c:double
-SPECIALIZED-ARRAY: c:complex-float
-SPECIALIZED-ARRAY: c:float
-
-[ V{ t } ] [
-    [ { double-array double-array } declare distance 0.0 < not ] final-literals
-] unit-test
-
-[ V{ float } ] [
-    [ { float-array float } declare v*n norm ] final-classes
-] unit-test
-
-[ V{ complex } ] [
-    [ { complex-float-array complex-float-array } declare v. ] final-classes
-] unit-test
-
-[ V{ float } ] [
-    [ { float-array float } declare v*n norm ] final-classes
-] unit-test
-
-[ V{ float } ] [
-    [ { complex-float-array complex } declare v*n norm ] final-classes
-] unit-test
\ No newline at end of file
diff --git a/basis/math/vectors/specialization/specialization.factor b/basis/math/vectors/specialization/specialization.factor
deleted file mode 100644 (file)
index 602fd98..0000000
+++ /dev/null
@@ -1,207 +0,0 @@
-! Copyright (C) 2009 Slava Pestov.
-! See http://factorcode.org/license.txt for BSD license.
-USING: words kernel make sequences effects sets kernel.private
-accessors combinators math math.intervals math.vectors
-math.vectors.conversion.backend namespaces assocs fry splitting
-classes.algebra generalizations locals
-compiler.tree.propagation.info ;
-IN: math.vectors.specialization
-
-SYMBOLS: -> +vector+ +any-vector+ +scalar+ +boolean+ +nonnegative+ +literal+ ;
-
-: parent-vector-class ( type -- type' )
-    {
-        { [ dup simd-128 class<= ] [ drop simd-128 ] }
-        { [ dup simd-256 class<= ] [ drop simd-256 ] }
-        [ "Not a vector class" throw ]
-    } cond ;
-
-: signature-for-schema ( array-type elt-type schema -- signature )
-    [
-        {
-            { +vector+ [ drop ] }
-            { +any-vector+ [ drop parent-vector-class ] }
-            { +scalar+ [ nip ] }
-            { +boolean+ [ 2drop boolean ] }
-            { +nonnegative+ [ nip ] }
-            { +literal+ [ 2drop f ] }
-        } case
-    ] with with map ;
-
-: (specialize-vector-word) ( word array-type elt-type schema -- word' )
-    signature-for-schema
-    [ [ name>> ] [ [ name>> ] map "," join ] bi* "=>" glue f <word> ]
-    [ [ , \ declare , def>> % ] [ ] make ]
-    [ drop stack-effect ]
-    2tri
-    [ define-declared ] [ 2drop ] 3bi ;
-
-: output-infos ( array-type elt-type schema -- value-infos )
-    [
-        {
-            { +vector+ [ drop <class-info> ] }
-            { +any-vector+ [ drop parent-vector-class <class-info> ] }
-            { +scalar+ [ nip <class-info> ] }
-            { +boolean+ [ 2drop boolean <class-info> ] }
-            {
-                +nonnegative+
-                [
-                    nip
-                    dup complex class<= [ drop float ] when
-                    [0,inf] <class/interval-info>
-                ]
-            }
-        } case
-    ] with with map ;
-
-: record-output-signature ( word array-type elt-type schema -- word )
-    output-infos
-    [ drop ]
-    [ drop ]
-    [ [ stack-effect in>> length '[ _ ndrop ] ] dip append ] 2tri
-    "outputs" set-word-prop ;
-
-CONSTANT: vector-words
-H{
-    { [v-] { +vector+ +vector+ -> +vector+ } }
-    { distance { +vector+ +vector+ -> +nonnegative+ } }
-    { n*v { +scalar+ +vector+ -> +vector+ } }
-    { n+v { +scalar+ +vector+ -> +vector+ } }
-    { n-v { +scalar+ +vector+ -> +vector+ } }
-    { n/v { +scalar+ +vector+ -> +vector+ } }
-    { norm { +vector+ -> +nonnegative+ } }
-    { norm-sq { +vector+ -> +nonnegative+ } }
-    { normalize { +vector+ -> +vector+ } }
-    { v* { +vector+ +vector+ -> +vector+ } }
-    { vs* { +vector+ +vector+ -> +vector+ } }
-    { v*n { +vector+ +scalar+ -> +vector+ } }
-    { v+ { +vector+ +vector+ -> +vector+ } }
-    { vs+ { +vector+ +vector+ -> +vector+ } }
-    { v+- { +vector+ +vector+ -> +vector+ } }
-    { v+n { +vector+ +scalar+ -> +vector+ } }
-    { v- { +vector+ +vector+ -> +vector+ } }
-    { vneg { +vector+ -> +vector+ } }
-    { vs- { +vector+ +vector+ -> +vector+ } }
-    { v-n { +vector+ +scalar+ -> +vector+ } }
-    { v. { +vector+ +vector+ -> +scalar+ } }
-    { v/ { +vector+ +vector+ -> +vector+ } }
-    { v/n { +vector+ +scalar+ -> +vector+ } }
-    { vceiling { +vector+ -> +vector+ } }
-    { vfloor { +vector+ -> +vector+ } }
-    { vmax { +vector+ +vector+ -> +vector+ } }
-    { vmin { +vector+ +vector+ -> +vector+ } }
-    { vneg { +vector+ -> +vector+ } }
-    { vtruncate { +vector+ -> +vector+ } }
-    { sum { +vector+ -> +scalar+ } }
-    { vabs { +vector+ -> +vector+ } }
-    { vsqrt { +vector+ -> +vector+ } }
-    { vbitand { +vector+ +vector+ -> +vector+ } }
-    { vbitandn { +vector+ +vector+ -> +vector+ } }
-    { vbitor { +vector+ +vector+ -> +vector+ } }
-    { vbitxor { +vector+ +vector+ -> +vector+ } }
-    { vbitnot { +vector+ -> +vector+ } }
-    { vand { +vector+ +vector+ -> +vector+ } }
-    { vandn { +vector+ +vector+ -> +vector+ } }
-    { vor { +vector+ +vector+ -> +vector+ } }
-    { vxor { +vector+ +vector+ -> +vector+ } }
-    { vnot { +vector+ -> +vector+ } }
-    { vlshift { +vector+ +scalar+ -> +vector+ } }
-    { vrshift { +vector+ +scalar+ -> +vector+ } }
-    { hlshift { +vector+ +literal+ -> +vector+ } }
-    { hrshift { +vector+ +literal+ -> +vector+ } }
-    { vshuffle-elements { +vector+ +literal+ -> +vector+ } }
-    { vshuffle-bytes    { +vector+ +any-vector+  -> +vector+ } }
-    { vbroadcast { +vector+ +literal+ -> +vector+ } }
-    { (vmerge-head) { +vector+ +vector+ -> +vector+ } }
-    { (vmerge-tail) { +vector+ +vector+ -> +vector+ } }
-    { (v>float) { +vector+ +literal+ -> +vector+ } }
-    { (v>integer) { +vector+ +literal+ -> +vector+ } }
-    { (vpack-signed) { +vector+ +vector+ +literal+ -> +vector+ } }
-    { (vpack-unsigned) { +vector+ +vector+ +literal+ -> +vector+ } }
-    { (vunpack-head) { +vector+ +literal+ -> +vector+ } }
-    { (vunpack-tail) { +vector+ +literal+ -> +vector+ } }
-    { v<= { +vector+ +vector+ -> +vector+ } }
-    { v< { +vector+ +vector+ -> +vector+ } }
-    { v= { +vector+ +vector+ -> +vector+ } }
-    { v> { +vector+ +vector+ -> +vector+ } }
-    { v>= { +vector+ +vector+ -> +vector+ } }
-    { vunordered? { +vector+ +vector+ -> +vector+ } }
-    { vany?  { +vector+ -> +boolean+ } }
-    { vall?  { +vector+ -> +boolean+ } }
-    { vnone? { +vector+ -> +boolean+ } }
-}
-
-PREDICATE: vector-word < word vector-words key? ;
-
-: specializations ( word -- assoc )
-    dup "specializations" word-prop
-    [ ] [ V{ } clone [ "specializations" set-word-prop ] keep ] ?if ;
-
-M: vector-word subwords specializations values [ word? ] filter ;
-
-: add-specialization ( new-word signature word -- )
-    specializations set-at ;
-
-ERROR: bad-vector-word word ;
-
-: word-schema ( word -- schema )
-    vector-words ?at [ bad-vector-word ] unless ;
-
-: inputs ( schema -- seq ) { -> } split first ;
-
-: outputs ( schema -- seq ) { -> } split second ;
-
-: loop-vector-op ( word array-type elt-type -- word' )
-    pick word-schema
-    [ inputs (specialize-vector-word) ]
-    [ outputs record-output-signature ] 3bi ;
-
-:: specialize-vector-word ( word array-type elt-type simd -- word/quot' )
-    word simd key? [ word simd at ] [ word array-type elt-type loop-vector-op ] if ;
-
-:: input-signature ( word array-type elt-type -- signature )
-    array-type elt-type word word-schema inputs signature-for-schema ;
-
-: vector-words-for-type ( elt-type -- words )
-    {
-        ! Can't do shifts on floats
-        { [ dup float class<= ] [ vector-words keys { vlshift vrshift } diff ] }
-        ! Can't divide integers
-        { [ dup integer class<= ] [ vector-words keys { vsqrt n/v v/n v/ normalize } diff ] }
-        ! Can't compute square root of complex numbers (vsqrt uses fsqrt not sqrt)
-        { [ dup complex class<= ] [ vector-words keys { vsqrt } diff ] }
-        [ { } ]
-    } cond
-    ! Don't specialize horizontal shifts, shuffles, and conversions at all, they're only for SIMD
-    {
-        hlshift hrshift vshuffle-elements vshuffle-bytes vbroadcast
-        (v>integer) (v>float)
-        (vpack-signed) (vpack-unsigned)
-        (vunpack-head) (vunpack-tail)
-    } diff
-    nip ;
-
-:: specialize-vector-words ( array-type elt-type simd -- )
-    elt-type vector-words-for-type simd keys union [
-        [ array-type elt-type simd specialize-vector-word ]
-        [ array-type elt-type input-signature ]
-        [ ]
-        tri add-specialization
-    ] each ;
-
-: specialization-matches? ( value-infos signature -- ? )
-    [ [ [ class>> ] dip class<= ] [ literal?>> ] if* ] 2all? ;
-
-: find-specialization ( classes word -- word/f )
-    specializations
-    [ first specialization-matches? ] with find
-    swap [ second ] when ;
-
-: vector-word-custom-inlining ( #call -- word/f )
-    [ in-d>> [ value-info ] map ] [ word>> ] bi
-    find-specialization ;
-
-vector-words keys [
-    [ vector-word-custom-inlining ]
-    "custom-inlining" set-word-prop
-] each
index b831ac7dbe116c7e5450c2ad6a12126cc0f5068d..59246a6e64503c169b07b50fd46009fbb23b39ef 100644 (file)
@@ -125,8 +125,6 @@ ARTICLE: "math-vectors-simd-logic" "Componentwise logic with SIMD vectors"
 "Processor SIMD units supported by the " { $vocab-link "math.vectors.simd" } " vocabulary represent boolean values as bitmasks, where a true result's binary representation is all ones and a false representation is all zeroes. This is the format in which results from comparison words such as " { $link v= } " return their results and in which logic and test words such as " { $link vand } " and " { $link vall? } " take their inputs when working with SIMD types. For a float vector, false will manifest itself as " { $snippet "0.0" } " and true as a " { $link POSTPONE: NAN: } " literal with a string of set bits in its payload:"
 { $example
 """USING: math.vectors math.vectors.simd prettyprint ;
-FROM: alien.c-types => float ;
-SIMD: float
 
 float-4{ 1.0 2.0 3.0 0/0. } float-4{ 1.0 -2.0 3.0 0/0. } v= ."""
 """float-4{ NAN: fffffe0000000 0.0 NAN: fffffe0000000 0.0 }"""
@@ -134,8 +132,6 @@ float-4{ 1.0 2.0 3.0 0/0. } float-4{ 1.0 -2.0 3.0 0/0. } v= ."""
 "For an integer vector, false will manifest as " { $snippet "0" } " and true as " { $snippet "-1" } " (for signed vectors) or the largest representable value of the element type (for unsigned vectors):"
 { $example
 """USING: math.vectors math.vectors.simd prettyprint alien.c-types ;
-SIMD: int
-SIMD: uchar
 
 int-4{ 1 2 3 0 } int-4{ 1 -2 3 4 } v=
 uchar-16{  0  1  2  3  4  5 6 7 8 9 10 11 12 13 14 15 }
@@ -147,7 +143,6 @@ uchar-16{ 255 255 255 255 255 255 255 255 0 0 0 0 0 0 0 0 }"""
 "This differs from Factor's native representation of boolean values, where " { $link f } " is false and every other value (including " { $snippet "0" } " and " { $snippet "0.0" } ") is true. To make it easy to construct literal SIMD masks, " { $link t } " and " { $link f } " are accepted inside SIMD literal syntax and expand to the proper true or false representation for the underlying type:"
 { $example
 """USING: math.vectors math.vectors.simd prettyprint alien.c-types ;
-SIMD: int
 
 int-4{ f f t f } ."""
 """int-4{ 0 0 -1 0 }""" }
@@ -216,36 +211,36 @@ HELP: vtruncate
 { $description "Truncates each element of " { $snippet "u" } "." } ;
 
 HELP: n+v
-{ $values { "n" "a number" } { "u" "a sequence of numbers" } { "v" "a sequence of numbers" } }
+{ $values { "n" "a number" } { "v" "a sequence of numbers" } { "w" "a sequence of numbers" } }
 { $description "Adds " { $snippet "n" } " to each element of " { $snippet "u" } "." } ;
 
 HELP: v+n
-{ $values { "u" "a sequence of numbers" } { "n" "a number" } { "v" "a sequence of numbers" } }
+{ $values { "u" "a sequence of numbers" } { "n" "a number" } { "w" "a sequence of numbers" } }
 { $description "Adds " { $snippet "n" } " to each element of " { $snippet "u" } "." } ;
 
 HELP: n-v
-{ $values { "n" "a number" } { "u" "a sequence of numbers" } { "v" "a sequence of numbers" } }
+{ $values { "n" "a number" } { "v" "a sequence of numbers" } { "w" "a sequence of numbers" } }
 { $description "Subtracts each element of " { $snippet "u" } " from " { $snippet "n" } "." } ;
 
 HELP: v-n
-{ $values { "u" "a sequence of numbers" } { "n" "a number" } { "v" "a sequence of numbers" } }
+{ $values { "u" "a sequence of numbers" } { "n" "a number" } { "w" "a sequence of numbers" } }
 { $description "Subtracts " { $snippet "n" } " from each element of " { $snippet "u" } "." } ;
 
 HELP: n*v
-{ $values { "n" "a number" } { "u" "a sequence of numbers" } { "v" "a sequence of numbers" } }
+{ $values { "n" "a number" } { "v" "a sequence of numbers" } { "w" "a sequence of numbers" } }
 { $description "Multiplies each element of " { $snippet "u" } " by " { $snippet "n" } "." } ;
 
 HELP: v*n
-{ $values { "u" "a sequence of numbers" } { "n" "a number" } { "v" "a sequence of numbers" } }
+{ $values { "u" "a sequence of numbers" } { "n" "a number" } { "w" "a sequence of numbers" } }
 { $description "Multiplies each element of " { $snippet "u" } " by " { $snippet "n" } "." } ;
 
 HELP: n/v
-{ $values { "n" "a number" } { "u" "a sequence of numbers" } { "v" "a sequence of numbers" } }
+{ $values { "n" "a number" } { "v" "a sequence of numbers" } { "w" "a sequence of numbers" } }
 { $description "Divides " { $snippet "n" } " by each element of " { $snippet "u" } "." }
 { $errors "May throw an error if a division by zero occurs; see " { $link "division-by-zero" } "." } ;
 
 HELP: v/n
-{ $values { "u" "a sequence of numbers" } { "n" "a number" } { "v" "a sequence of numbers" } }
+{ $values { "u" "a sequence of numbers" } { "n" "a number" } { "w" "a sequence of numbers" } }
 { $description "Divides each element of " { $snippet "u" } " by " { $snippet "n" } "." }
 { $errors "May throw an error if a division by zero occurs; see " { $link "division-by-zero" } "." } ;
 
@@ -259,7 +254,7 @@ HELP: v-
 
 HELP: v+-
 { $values { "u" "a sequence of numbers" } { "v" "a sequence of numbers" } { "w" "a sequence of numbers" } }
-{ $description "Adds and subtracts alternate elements of " { $snippet "v" } " and " { $snippet "u" } " component-wise." }
+{ $description "Adds and subtracts alternate elements of " { $snippet "v" } " and " { $snippet "u" } " component-wise. Elements at even indexes are subtracted, while elements at odd indexes are added." }
 { $examples
     { $example
         "USING: math.vectors prettyprint ;"
@@ -413,7 +408,6 @@ HELP: vbroadcast
 { $examples
     { $example
         "USING: alien.c-types math.vectors math.vectors.simd" "prettyprint ;"
-        "SIMD: int"
         "int-4{ 69 42 911 13 } 2 vbroadcast ."
         "int-4{ 911 911 911 911 }"
     }
@@ -429,14 +423,12 @@ HELP: vshuffle
 { $examples
     { $example
         "USING: alien.c-types math.vectors math.vectors.simd" "prettyprint ;"
-        "SIMD: int"
         "int-4{ 69 42 911 13 } { 1 3 2 3 } vshuffle ."
         "int-4{ 42 13 911 13 }"
     }
     { $example
         "USING: alien.c-types combinators math.vectors math.vectors.simd"
         "namespaces prettyprint prettyprint.config ;"
-        "SIMDS: int uchar ;"
         "IN: scratchpad"
         ""
         ": endian-swap ( size -- vector )"
index 63564f064d5756bd226e23d72ab40c07a52f49bc..6cb16e5efc5f5f96180c9b953583bb4692c9405f 100644 (file)
-! Copyright (C) 2005, 2009 Slava Pestov.
+! Copyright (C) 2005, 2010 Slava Pestov, Joe Groff.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: arrays alien.c-types assocs kernel sequences math math.functions
-hints math.order math.libm math.floats.private fry combinators
-byte-arrays accessors locals ;
+USING: arrays alien.c-types assocs kernel sequences math
+math.functions grouping math.order math.libm math.floats.private
+fry combinators byte-arrays accessors locals ;
 QUALIFIED-WITH: alien.c-types c
 IN: math.vectors
 
-MIXIN: simd-128
-MIXIN: simd-256
+GENERIC: vneg ( u -- v )
+M: object vneg [ neg ] map ; inline
 
-GENERIC: element-type ( obj -- c-type )
-M: object element-type drop f ; inline
+GENERIC# v+n 1 ( u n -- w )
+M: object v+n [ + ] curry map ; inline
 
-: vneg ( u -- v ) [ neg ] map ;
+GENERIC: n+v ( n v -- w )
+M: object n+v [ + ] with map ; inline
 
-: v+n ( u n -- v ) [ + ] curry map ;
-: n+v ( n u -- v ) [ + ] with map ;
-: v-n ( u n -- v ) [ - ] curry map ;
-: n-v ( n u -- v ) [ - ] with map ;
+GENERIC# v-n 1 ( u n -- w )
+M: object v-n [ - ] curry map ; inline
 
-: v*n ( u n -- v ) [ * ] curry map ;
-: n*v ( n u -- v ) [ * ] with map ;
-: v/n ( u n -- v ) [ / ] curry map ;
-: n/v ( n u -- v ) [ / ] with map ;
+GENERIC: n-v ( n v -- w )
+M: object n-v [ - ] with map ; inline
 
-: v+   ( u v -- w ) [ + ] 2map ;
-: v-   ( u v -- w ) [ - ] 2map ;
-: [v-] ( u v -- w ) [ [-] ] 2map ;
-: v*   ( u v -- w ) [ * ] 2map ;
-: v/   ( u v -- w ) [ / ] 2map ;
+GENERIC# v*n 1 ( u n -- w )
+M: object v*n [ * ] curry map ; inline
 
-<PRIVATE
+GENERIC: n*v ( n v -- w )
+M: object n*v [ * ] with map ; inline
 
-: if-both-floats ( x y p q -- )
-    [ 2dup [ float? ] both? ] 2dip if ; inline
+GENERIC# v/n 1 ( u n -- w )
+M: object v/n [ / ] curry map ; inline
 
-PRIVATE>
+GENERIC: n/v ( n v -- w )
+M: object n/v [ / ] with map ; inline
 
-: vmax ( u v -- w ) [ [ float-max ] [ max ] if-both-floats ] 2map ;
-: vmin ( u v -- w ) [ [ float-min ] [ min ] if-both-floats ] 2map ;
+GENERIC: v+  ( u v -- w )
+M: object v+ [ + ] 2map ; inline
 
-: v+- ( u v -- w )
-    [ t ] 2dip
-    [ [ not ] 2dip pick [ + ] [ - ] if ] 2map
-    nip ;
+GENERIC: v-  ( u v -- w )
+M: object v- [ - ] 2map ; inline
 
-<PRIVATE
+GENERIC: [v-] ( u v -- w )
+M: object [v-] [ [-] ] 2map ; inline
 
-: 2saturate-map ( u v quot -- w )
-    pick element-type '[ @ _ c-type-clamp ] 2map ; inline
+GENERIC: v* ( u v -- w )
+M: object v* [ * ] 2map ; inline
 
+GENERIC: v*high ( u v -- w )
+
+<PRIVATE
+: (h+) ( u -- w ) 2 <groups> [ first2 + ] map ;
+: (h-) ( u -- w ) 2 <groups> [ first2 - ] map ;
 PRIVATE>
 
-: vs+ ( u v -- w ) [ + ] 2saturate-map ;
-: vs- ( u v -- w ) [ - ] 2saturate-map ;
-: vs* ( u v -- w ) [ * ] 2saturate-map ;
+GENERIC: v*hs+ ( u v -- w )
+M: object v*hs+ [ * ] 2map (h+) ; inline
 
-: vabs ( u -- v ) [ abs ] map ;
-: vsqrt ( u -- v ) [ >float fsqrt ] map ;
+GENERIC: v/ ( u v -- w )
+M: object v/ [ / ] 2map ; inline
 
-<PRIVATE
+GENERIC: vavg ( u v -- w )
+M: object vavg [ + 2 / ] 2map ; inline
 
-: fp-bitwise-op ( x y seq quot -- z )
-    swap element-type {
-        { c:double [ [ [ double>bits ] bi@ ] dip call bits>double ] }
-        { c:float  [ [ [ float>bits ] bi@ ] dip call bits>float   ] }
-        [ drop call ]
-    } case ; inline
+GENERIC: vmax ( u v -- w )
+M: object vmax [ max ] 2map ; inline
 
-: fp-bitwise-unary ( x seq quot -- z )
-    swap element-type {
-        { c:double [ [ double>bits ] dip call bits>double ] }
-        { c:float  [ [ float>bits  ] dip call bits>float  ] }
-        [ drop call ]
-    } case ; inline
+GENERIC: vmin ( u v -- w )
+M: object vmin [ min ] 2map ; inline
 
-: element>bool ( x seq -- ? )
-    element-type [ [ f ] when-zero ] when ; inline
+GENERIC: v+- ( u v -- w )
+M: object v+-
+    [ t ] 2dip
+    [ [ not ] 2dip pick [ + ] [ - ] if ] 2map
+    nip ; inline
 
-: bitandn ( x y -- z ) [ bitnot ] dip bitand ; inline
+GENERIC: vs+ ( u v -- w )
+M: object vs+ [ + ] 2map ; inline
 
-GENERIC: new-underlying ( underlying seq -- seq' )
+GENERIC: vs- ( u v -- w )
+M: object vs- [ - ] 2map ; inline
 
-: change-underlying ( seq quot -- seq' )
-    '[ underlying>> @ ] keep new-underlying ; inline
+GENERIC: vs* ( u v -- w )
+M: object vs* [ * ] 2map ; inline
 
-PRIVATE>
+GENERIC: vabs ( u -- v )
+M: object vabs [ abs ] map ; inline
+
+GENERIC: vsqrt ( u -- v )
+M: object vsqrt [ >float fsqrt ] map ; inline
 
-: vbitand ( u v -- w ) over '[ _ [ bitand ] fp-bitwise-op ] 2map ;
-: vbitandn ( u v -- w ) over '[ _ [ bitandn ] fp-bitwise-op ] 2map ;
-: vbitor ( u v -- w ) over '[ _ [ bitor ] fp-bitwise-op ] 2map ;
-: vbitxor ( u v -- w ) over '[ _ [ bitxor ] fp-bitwise-op ] 2map ;
-: vbitnot ( u -- w ) dup '[ _ [ bitnot ] fp-bitwise-unary ] map ;
+GENERIC: vsad ( u v -- n )
+M: object vsad [ - abs ] [ + ] 2map-reduce ; inline
 
-:: vbroadcast ( u n -- v ) u length n u nth <repetition> u like ;
+<PRIVATE
+
+: bitandn ( x y -- z ) [ bitnot ] dip bitand ; inline
 
-: vshuffle-elements ( u perm -- v )
+PRIVATE>
+
+GENERIC: vbitand ( u v -- w )
+M: object vbitand [ bitand ] 2map ; inline
+GENERIC: vbitandn ( u v -- w )
+M: object vbitandn [ bitandn ] 2map ; inline
+GENERIC: vbitor ( u v -- w )
+M: object vbitor [ bitor ] 2map ; inline
+GENERIC: vbitxor ( u v -- w )
+M: object vbitxor [ bitxor ] 2map ; inline
+GENERIC: vbitnot ( u -- w )
+M: object vbitnot [ bitnot ] map ; inline
+
+GENERIC# vbroadcast 1 ( u n -- v )
+M:: object vbroadcast ( u n -- v ) u length n u nth <repetition> u like ; inline
+
+GENERIC# vshuffle-elements 1 ( u perm -- v )
+M: object vshuffle-elements
     over length 0 pad-tail
-    swap [ '[ _ nth ] ] keep map-as ;
+    swap [ '[ _ nth ] ] keep map-as ; inline
 
-: vshuffle-bytes ( u perm -- v )
-    underlying>> [
-        swap [ '[ 15 bitand _ nth ] ] keep map-as
-    ] curry change-underlying ;
+GENERIC# vshuffle-bytes 1 ( u perm -- v )
 
 GENERIC: vshuffle ( u perm -- v )
 M: array vshuffle ( u perm -- v )
     vshuffle-elements ; inline
-M: simd-128 vshuffle ( u perm -- v )
-    vshuffle-bytes ; inline
 
-: vlshift ( u n -- w ) '[ _ shift ] map ;
-: vrshift ( u n -- w ) neg '[ _ shift ] map ;
+GENERIC# vlshift 1 ( u n -- w )
+M: object vlshift '[ _ shift ] map ; inline
+GENERIC# vrshift 1 ( u n -- w )
+M: object vrshift neg '[ _ shift ] map ; inline
 
-: hlshift ( u n -- w ) '[ _ <byte-array> prepend 16 head ] change-underlying ;
-: hrshift ( u n -- w ) '[ _ <byte-array> append 16 tail* ] change-underlying ;
+GENERIC# hlshift 1 ( u n -- w )
+GENERIC# hrshift 1 ( u n -- w )
 
-: (vmerge-head) ( u v -- h )
-    over length 2 /i '[ _ head-slice ] bi@ [ zip ] keep concat-as ;
-: (vmerge-tail) ( u v -- t )
-    over length 2 /i '[ _ tail-slice ] bi@ [ zip ] keep concat-as ;
+GENERIC: (vmerge-head) ( u v -- h )
+M: object (vmerge-head) over length 2 /i '[ _ head-slice ] bi@ [ zip ] keep concat-as ; inline
+GENERIC: (vmerge-tail) ( u v -- t )
+M: object (vmerge-tail) over length 2 /i '[ _ tail-slice ] bi@ [ zip ] keep concat-as ; inline
 
-: (vmerge) ( u v -- h t )
+GENERIC: (vmerge) ( u v -- h t )
+M: object (vmerge)
     [ (vmerge-head) ] [ (vmerge-tail) ] 2bi ; inline
 
-: vmerge ( u v -- w ) [ zip ] keep concat-as ;
+GENERIC: vmerge ( u v -- w )
+M: object vmerge [ zip ] keep concat-as ; inline
+
+GENERIC: vand ( u v -- w )
+M: object vand [ and ] 2map ; inline
+
+GENERIC: vandn ( u v -- w )
+M: object vandn [ [ not ] dip and ] 2map ; inline
+
+GENERIC: vor  ( u v -- w )
+M: object vor  [ or  ] 2map ; inline
+
+GENERIC: vxor ( u v -- w )
+M: object vxor [ xor ] 2map ; inline
+
+GENERIC: vnot ( u -- w )
+M: object vnot [ not ] map ; inline
+
+GENERIC: vall? ( v -- ? )
+M: object vall? [ ] all? ; inline
+
+GENERIC: vany? ( v -- ? )
+M: object vany? [ ] any? ; inline
 
-: vand ( u v -- w )  over '[ [ _ element>bool ] bi@ and ] 2map ;
-: vandn ( u v -- w ) over '[ [ _ element>bool ] bi@ [ not ] dip and ] 2map ;
-: vor  ( u v -- w )  over '[ [ _ element>bool ] bi@ or  ] 2map ;
-: vxor ( u v -- w )  over '[ [ _ element>bool ] bi@ xor ] 2map ;
-: vnot ( u -- w )    dup '[ _ element>bool not ] map ;
+GENERIC: vnone? ( v -- ? )
+M: object vnone? [ not ] all? ; inline
 
-: vall? ( v -- ? ) dup '[ _ element>bool ] all? ;
-: vany? ( v -- ? ) dup '[ _ element>bool ] any? ;
-: vnone? ( v -- ? ) dup '[ _ element>bool not ] all? ;
+GENERIC: v<  ( u v -- w )
+M: object v<  [ <   ] 2map ; inline
 
-: v<  ( u v -- w ) [ <   ] 2map ;
-: v<= ( u v -- w ) [ <=  ] 2map ;
-: v>= ( u v -- w ) [ >=  ] 2map ;
-: v>  ( u v -- w ) [ >   ] 2map ;
-: vunordered? ( u v -- w ) [ unordered? ] 2map ;
-: v=  ( u v -- w ) [ =   ] 2map ;
+GENERIC: v<= ( u v -- w )
+M: object v<= [ <=  ] 2map ; inline
 
-: v? ( mask true false -- result )
+GENERIC: v>= ( u v -- w )
+M: object v>= [ >=  ] 2map ; inline
+
+GENERIC: v>  ( u v -- w )
+M: object v>  [ >   ] 2map ; inline
+
+GENERIC: vunordered? ( u v -- w )
+M: object vunordered? [ unordered? ] 2map ; inline
+
+GENERIC: v=  ( u v -- w )
+M: object v=  [ =   ] 2map ; inline
+
+GENERIC: v? ( mask true false -- result )
+M: object v? 
     [ vand ] [ vandn ] bi-curry* bi vor ; inline
 
 :: vif ( mask true-quot false-quot -- result )
@@ -157,15 +199,21 @@ M: simd-128 vshuffle ( u perm -- v )
 : vceiling  ( u -- v ) [ ceiling ] map ;
 : vtruncate ( u -- v ) [ truncate ] map ;
 
-: vsupremum ( seq -- vmax ) [ ] [ vmax ] map-reduce ; 
-: vinfimum ( seq -- vmin ) [ ] [ vmin ] map-reduce ; 
+: vsupremum ( seq -- vmax ) [ ] [ vmax ] map-reduce ; inline
+: vinfimum ( seq -- vmin ) [ ] [ vmin ] map-reduce ; inline
 
-: v. ( u v -- x ) [ conjugate * ] [ + ] 2map-reduce ;
-: norm-sq ( v -- x ) [ absq ] [ + ] map-reduce ;
-: norm ( v -- x ) norm-sq sqrt ;
-: normalize ( u -- v ) dup norm v/n ;
+GENERIC: v. ( u v -- x )
+M: object v. [ conjugate * ] [ + ] 2map-reduce ; inline
 
-: distance ( u v -- x ) [ - absq ] [ + ] 2map-reduce sqrt ;
+GENERIC: norm-sq ( v -- x )
+M: object norm-sq [ absq ] [ + ] map-reduce ; inline
+
+: norm ( v -- x ) norm-sq sqrt ; inline
+
+: normalize ( u -- v ) dup norm v/n ; inline
+
+GENERIC: distance ( u v -- x )
+M: object distance [ - absq ] [ + ] 2map-reduce sqrt ; inline
 
 : set-axis ( u v axis -- w )
     [ [ zero? 2over ? ] dip swap nth ] map-index 2nip ;
@@ -197,28 +245,3 @@ PRIVATE>
 
 : v~ ( a b epsilon -- ? )
     [ ~ ] curry 2all? ; inline
-
-HINTS: vneg { array } ;
-HINTS: norm-sq { array } ;
-HINTS: norm { array } ;
-HINTS: normalize { array } ;
-HINTS: distance { array array } ;
-
-HINTS: n*v { object array } ;
-HINTS: v*n { array object } ;
-HINTS: n/v { array } ;
-HINTS: v/n { array object } ;
-
-HINTS: v+ { array array } ;
-HINTS: v- { array array } ;
-HINTS: v* { array array } ;
-HINTS: v/ { array array } ;
-HINTS: vmax { array array } ;
-HINTS: vmin { array array } ;
-HINTS: v. { array array } ;
-
-HINTS: vlerp { array array array } ;
-HINTS: vnlerp { array array object } ;
-
-HINTS: bilerp { object object object object array } ;
-HINTS: trilerp { object object object object object object object object array } ;
old mode 100755 (executable)
new mode 100644 (file)
index 257a2bb1ea059be27a418b4eb4f72d15c8493f82..7c29310a97716c9764422170e19e8f58cd37aac2 100644 (file)
@@ -1,9 +1,9 @@
-! Copyright (C) 2009 Slava Pestov.
+! Copyright (C) 2009, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: models.arrow models.product stack-checker accessors fry
-generalizations macros kernel ;
+generalizations combinators.smart macros kernel ;
 IN: models.arrow.smart
 
 MACRO: <smart-arrow> ( quot -- quot' )
-    [ infer in>> dup ] keep
+    [ inputs dup ] keep
     '[ _ narray <product> [ _ firstn @ ] <arrow> ] ;
\ No newline at end of file
diff --git a/basis/models/illusion/authors.txt b/basis/models/illusion/authors.txt
deleted file mode 100644 (file)
index ce0899f..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Sam Anklesaria
\ No newline at end of file
diff --git a/basis/models/illusion/illusion.factor b/basis/models/illusion/illusion.factor
deleted file mode 100644 (file)
index 0016979..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-USING: accessors models models.arrow inverse kernel ;
-IN: models.illusion
-
-TUPLE: illusion < arrow ;
-
-: <illusion> ( model quot -- illusion )
-    illusion new V{ } clone >>connections V{ } clone >>dependencies 0 >>ref
-    swap >>quot over >>model [ add-dependency ] keep ;
-
-: <activated-illusion> ( model quot -- illusion ) <illusion> dup activate-model ;
-
-: backtalk ( value object -- )
-   [ quot>> [undo] call( a -- b ) ] [ model>> ] bi set-model ;
-
-M: illusion update-model ( model -- ) [ [ value>> ] keep backtalk ] with-locked-model ;
\ No newline at end of file
diff --git a/basis/models/illusion/summary.txt b/basis/models/illusion/summary.txt
deleted file mode 100644 (file)
index 8ea7cf1..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Two Way Arrows
\ No newline at end of file
index 1c03bb224c0e5a57850efe78e558d6de3bcffde2..f9927cfd4cc181b1f549a59a904117c525498cff 100644 (file)
@@ -17,8 +17,6 @@ value connections dependencies ref locked? ;
 : <model> ( value -- model )
     model new-model ;
 
-M: model hashcode* drop model hashcode* ;
-
 : add-dependency ( dep model -- )
     dependencies>> push ;
 
index 2a0eef7227aed299377fd41e4bdd9a473db950ad..363f30678dadefff30c3522fda26915c563ce31d 100644 (file)
@@ -1,6 +1,6 @@
 USING: nibble-arrays tools.test sequences kernel math ;
 IN: nibble-arrays.tests
 
-[ t ] [ 16 dup >nibble-array sequence= ] unit-test
+[ t ] [ 16 iota dup >nibble-array sequence= ] unit-test
 [ N{ 4 2 1 3 } ] [ N{ 3 1 2 4 } reverse ] unit-test
 [ N{ 1 4 9 0 9 4 } ] [ N{ 1 2 3 4 5 6 } [ sq ] map ] unit-test
old mode 100755 (executable)
new mode 100644 (file)
index 6292a683e3066d4e44d928cff397ceb2a27018c5..540fba40f0294d84173e03437001bab8702d8f4d 100644 (file)
@@ -19,7 +19,7 @@ SYMBOL: +gl-function-pointers+
 : reset-gl-function-pointers ( -- )
     100 <hashtable> +gl-function-pointers+ set-global ;
     
-[ reset-gl-function-pointers ] "opengl.gl" add-init-hook
+[ reset-gl-function-pointers ] "opengl.gl" add-startup-hook
 reset-gl-function-pointers
 reset-gl-function-number-counter
 
old mode 100755 (executable)
new mode 100644 (file)
diff --git a/basis/opengl/opengl-tests.factor b/basis/opengl/opengl-tests.factor
new file mode 100644 (file)
index 0000000..818d0db
--- /dev/null
@@ -0,0 +1,6 @@
+USING: tools.test math opengl opengl.gl ;
+IN: opengl.tests
+
+{ 2 1 } [ { GL_TEXTURE_2D } [ + ] all-enabled ] must-infer-as
+
+{ 2 1 } [ { GL_TEXTURE_2D } [ + ] all-enabled-client-state ] must-infer-as
old mode 100755 (executable)
new mode 100644 (file)
index 513ed91..1f6205e
@@ -56,7 +56,9 @@ TUPLE: gl-error function code string ;
     [ ?execute ] map ;
 
 : (all-enabled) ( seq quot -- )
-    over [ glEnable ] each dip [ glDisable ] each ; inline
+    [ dup [ glEnable ] each ] dip
+    dip
+    [ glDisable ] each ; inline
 
 : (all-enabled-client-state) ( seq quot -- )
     [ dup [ glEnableClientState ] each ] dip
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 8f14c60e14abf4bda8766efc662bd932d5d43654..76806f9523c0151a1d0500ff17abbc6dbcb5c314 100644 (file)
@@ -34,4 +34,4 @@ SYMBOL: ssl-initialized?
         t ssl-initialized? set-global
     ] unless ;
 
-[ f ssl-initialized? set-global ] "openssl" add-init-hook
+[ f ssl-initialized? set-global ] "openssl" add-startup-hook
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 6fd8d57893183c9855b8a62acfed36ea752d2046..d6baaffe2e77da6557751c3b40d320e5ff6819e1 100644 (file)
@@ -240,4 +240,4 @@ SYMBOL: cached-layouts
 : cached-line ( font string -- line )
     cached-layout layout>> first-line ;
 
-[ <cache-assoc> cached-layouts set-global ] "pango.cairo" add-init-hook
+[ <cache-assoc> cached-layouts set-global ] "pango.cairo" add-startup-hook
index 280ddd20d6257881971dc915d05200bbe3ff9d8d..31a51e3f128013f8f6bac3a2bb2eb57c493464ba 100644 (file)
@@ -111,4 +111,4 @@ MEMO: (cache-font-description) ( font -- description )
 : cache-font-description ( font -- description )
     strip-font-colors (cache-font-description) ;
 
-[ \ (cache-font-description) reset-memoized ] "pango.fonts" add-init-hook
+[ \ (cache-font-description) reset-memoized ] "pango.fonts" add-startup-hook
index 9bfd8ce49936f120ceb42694ac18cb4b67bd3b66..6895a2bd7bc37c055d0dbe78fe846f4cf76644b5 100644 (file)
@@ -435,9 +435,11 @@ ARTICLE: "peg.ebnf" "EBNF"
 "The " { $vocab-link "peg.ebnf" } " vocabulary provides a DSL that allows writing PEG parsers that look like "
 "EBNF syntax. It provides three parsing words described below. These words all "
 "accept the same EBNF syntax. The difference is in how they are used. "
-{ $subsection POSTPONE: <EBNF }
-{ $subsection POSTPONE: [EBNF }
-{ $subsection POSTPONE: EBNF: }
+{ $subsections
+    POSTPONE: <EBNF
+    POSTPONE: [EBNF
+    POSTPONE: EBNF:
+}
 "The EBNF syntax is composed of a series of rules of the form: "
 { $code 
   "rule1 = ..."
@@ -447,20 +449,20 @@ ARTICLE: "peg.ebnf" "EBNF"
 "and it is expected that the remaining rules are used by that rule. Rules may be "
 "left recursive. "
 "Each rule can contain the following: "
-{ $subsection "peg.ebnf.strings" }
-{ $subsection "peg.ebnf.any" }
-{ $subsection "peg.ebnf.sequence" }
-{ $subsection "peg.ebnf.choice" }
-{ $subsection "peg.ebnf.option" }
-{ $subsection "peg.ebnf.one-or-more" }
-{ $subsection "peg.ebnf.zero-or-more" }
-{ $subsection "peg.ebnf.and" }
-{ $subsection "peg.ebnf.not" }
-{ $subsection "peg.ebnf.character-class" }
-{ $subsection "peg.ebnf.foreign-rules" }
-{ $subsection "peg.ebnf.action" }
-{ $subsection "peg.ebnf.semantic-action" }
-{ $subsection "peg.ebnf.variable" }
+{ $subsections "peg.ebnf.strings"
+"peg.ebnf.any"
+"peg.ebnf.sequence"
+"peg.ebnf.choice"
+"peg.ebnf.option"
+"peg.ebnf.one-or-more"
+"peg.ebnf.zero-or-more"
+"peg.ebnf.and"
+"peg.ebnf.not"
+"peg.ebnf.character-class"
+"peg.ebnf.foreign-rules"
+"peg.ebnf.action"
+"peg.ebnf.semantic-action"
+"peg.ebnf.variable" }
 "Grammars defined in EBNF need to handle each character, or sequence of "
 "characters in the input. This can be tedious for dealing with whitespace in "
 "grammars that have 'tokens' separated by whitespace. You can define your "
@@ -468,7 +470,7 @@ ARTICLE: "peg.ebnf" "EBNF"
 "those tokens, allowing you to ignore the whitespace issue. The tokenizer "
 "can be changed at various parts in the grammar as needed. The JavaScript grammar "
 "does this to define the optional semicolon rule for example." 
-{ $subsection "peg.ebnf.tokenizers" }
+{ $subsections "peg.ebnf.tokenizers" }
 ;
 
-ABOUT: "peg.ebnf"
\ No newline at end of file
+ABOUT: "peg.ebnf"
index 5ddd5f9bf08e04699ac9ce3bdf16b145553b762d..ffc4cb91ad78aa462b4abbf529ac615225179e80 100644 (file)
@@ -446,14 +446,14 @@ M: ebnf-sequence build-locals ( code ast -- code )
     ] [ \r
       [\r
         "FROM: locals => [let :> ; FROM: sequences => nth ; [let " %\r
-          dup length [\r
+          [\r
             over ebnf-var? [\r
               " " % # " over nth :> " %\r
               name>> % \r
             ] [\r
               2drop\r
             ] if\r
-          ] 2each\r
+          ] each-index\r
           " " %\r
           %  \r
           " nip ]" %     \r
index eea31dd34e700c5475d231658dea0468da04ae29..482367ad9cf0277bd6c27e692de3346e3e9a0969 100644 (file)
@@ -1,6 +1,6 @@
 IN: persistent.hashtables.tests
 USING: persistent.hashtables persistent.assocs hashtables assocs
-tools.test kernel namespaces random math.ranges sequences fry ;
+tools.test kernel locals namespaces random math.ranges sequences fry ;
 
 [ t ] [ PH{ } assoc-empty? ] unit-test
 
@@ -81,12 +81,13 @@ M: hash-0-b hashcode* 2drop 0 ;
 ] unit-test
 
 : random-string ( -- str )
-    1000000 random ; ! [ CHAR: a CHAR: z [a,b] random ] "" replicate-as ;
+    1000000 random ;
+    ! [ CHAR: a CHAR: z [a,b] random ] "" replicate-as ;
 
 : random-assocs ( n -- hash phash )
     [ random-string ] replicate
     [ H{ } clone [ '[ swap _ set-at ] each-index ] keep ]
-    [ PH{ } clone swap [ spin new-at ] each-index ]
+    [ PH{ } clone swap [| ph elt i | i elt ph new-at ] each-index ]
     bi ;
 
 : ok? ( assoc1 assoc2 -- ? )
index 0179216e62a7acc1f0a474e613695316dac56150..256baabd5ed825c457cf8b72a73cfad945286092 100644 (file)
@@ -1,7 +1,7 @@
 ! Based on Clojure's PersistentHashMap by Rich Hickey.
 
 USING: kernel math accessors assocs fry combinators parser
-prettyprint.custom make
+prettyprint.custom locals make
 persistent.assocs
 persistent.hashtables.nodes
 persistent.hashtables.nodes.empty
@@ -38,8 +38,8 @@ M: persistent-hash pluck-at
 
 M: persistent-hash >alist [ root>> >alist% ] { } make ;
 
-: >persistent-hash ( assoc -- phash )
-    T{ persistent-hash } swap [ spin new-at ] assoc-each ;
+:: >persistent-hash ( assoc -- phash )
+    T{ persistent-hash } assoc [| ph k v | v k ph new-at ] assoc-each ;
 
 M: persistent-hash equal?
     over persistent-hash? [ assoc= ] [ 2drop f ] if ;
index 95fa70558d0d6ed4feb5d17f8354fdb71074b8cc..6d340ca78a95b6575613c26caecdc81abfe7b84a 100644 (file)
@@ -18,14 +18,14 @@ vectors math math.order ;
 ] unit-test
 
 { 100 1060 2000 10000 100000 1000000 } [
-    [ t ] swap [ dup >persistent-vector sequence= ] curry unit-test
+    [ t ] swap [ iota dup >persistent-vector sequence= ] curry unit-test
 ] each
 
 [ ] [ 10000 [ 16 random-bits ] PV{ } replicate-as "1" set ] unit-test
 [ ] [ "1" get >vector "2" set ] unit-test
 
 [ t ] [
-    3000 [
+    3000 iota [
         drop
         16 random-bits 10000 random
         [ "1" [ new-nth ] change ]
@@ -56,11 +56,11 @@ vectors math math.order ;
 ] unit-test
 
 [ t ] [
-    10000 >persistent-vector 752 [ ppop ] times dup length sequence=
+    10000 iota >persistent-vector 752 [ ppop ] times dup length iota sequence=
 ] unit-test
 
 [ t ] [
-    100 [
+    100 iota [
         drop
         100 random [
             16 random-bits [ "1" [ ppush ] change ] [ "2" get push ] bi
index 2527959f325f0317cd6540a0c3ab2a625e45f2fe..b02604e9bd8ca02f856a2cd27d1d8c7697cef08a 100644 (file)
@@ -58,7 +58,7 @@ M: persistent-vector nth-unsafe
     [ 2array ] [ drop level>> 1 + ] 2bi node boa ;
 
 : new-child ( new-child node -- node' expansion/f )
-    dup full? [ tuck level>> 1node ] [ node-add f ] if ;
+    dup full? [ [ level>> 1node ] keep swap ] [ node-add f ] if ;
 
 : new-last ( val seq -- seq' )
     [ length 1 - ] keep new-nth ;
@@ -70,7 +70,7 @@ M: persistent-vector nth-unsafe
     dup level>> 1 = [
         new-child
     ] [
-        tuck children>> last (ppush-new-tail)
+        [ nip ] 2keep children>> last (ppush-new-tail)
         [ swap new-child ] [ swap node-set-last f ] ?if
     ] if ;
 
index 2e1a47b9512d50b75f68667c123483d1a3e84407..e3cb186bf8057f5d45f2a13faf59c4c2cd2f43af 100644 (file)
@@ -33,10 +33,10 @@ IN: porter-stemmer
     ] if ;
 
 : consonant-seq ( str -- n )
-    0 0 rot skip-consonants (consonant-seq) ;
+    [ 0 0 ] dip skip-consonants (consonant-seq) ;
 
 : stem-vowel? ( str -- ? )
-    [ length ] keep [ consonant? ] curry all? not ;
+    [ length iota ] keep [ consonant? ] curry all? not ;
 
 : double-consonant? ( i str -- ? )
     over 1 < [
index 0ba1d38ae62054b0f3522f1eab5030a5595daa8c..04617a6c672cfeed553a89cbcaede6f22bb91e0a 100644 (file)
@@ -116,8 +116,7 @@ M: pathname pprint*
 : check-recursion ( obj quot -- )
     nesting-limit? [
         drop
-        "~" over class name>> "~" 3append
-        swap present-text
+        [ class name>> "~" dup surround ] keep present-text 
     ] [
         over recursion-check get member-eq? [
             drop "~circularity~" swap present-text
@@ -175,7 +174,7 @@ M: tuple pprint*
 : pprint-elements ( seq -- )
     do-length-limit
     [ [ pprint* ] each ] dip
-    [ "~" swap number>string " more~" 3append text ] when* ;
+    [ number>string "~" " more~" surround text ] when* ;
 
 M: quotation pprint-delims drop \ [ \ ] ;
 M: curry pprint-delims drop \ [ \ ] ;
index 6cff3992019b36f43cac5645b7275a3c4091c9a4..65d25f1812f5d386a121e92b8cb5ab522e1fd2dc 100644 (file)
@@ -73,8 +73,8 @@ SYMBOL: ->
 
 : remove-breakpoints ( quot pos -- quot' )
     over quotation? [
-        1 + cut [ (remove-breakpoints) ] bi@
-        [ -> ] glue 
+        1 + short cut [ (remove-breakpoints) ] bi@
+        [ -> ] glue
     ] [
         drop
     ] if ;
index 040b6d8f7c23723f365e04e8bc002d56bb364cb7..6f5f61f688ef3ae019c6524e3e4b13099ec5a462 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2003, 2009 Slava Pestov.
+! Copyright (C) 2003, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: arrays generic hashtables io kernel math assocs
 namespaces make sequences strings io.styles vectors words
@@ -309,7 +309,7 @@ SYMBOL: next
 
 : group-flow ( seq -- newseq )
     [
-        dup length [
+        dup length iota [
             2dup 1 - swap ?nth prev set
             2dup 1 + swap ?nth next set
             swap nth dup split-before dup , split-after
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index e258cb9a96d48327369e8708662ca376cb4a1863..2a3239c72faa20d0c12e654b63a1162e46122220 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2009 Daniel Ehrenberg
 ! See http://factorcode.org/license.txt for BSD license.
 USING: tools.test quoted-printable io.encodings.string
-sequences io.encodings.8-bit splitting kernel ;
+sequences splitting kernel io.encodings.8-bit.latin2 ;
 IN: quoted-printable.tests
 
 [ """José was the
index b877af6f79bfd465addaaa700a269298a80faa26..ede3c92f517b60cd2acf4f2c5b2d7e3442a3c244 100644 (file)
@@ -5,7 +5,7 @@ IN: random.mersenne-twister.tests
 : check-random ( max -- ? )
     [ random 0 ] keep between? ;
 
-[ t ] [ 100 [ drop 674 check-random ] all? ] unit-test
+[ t ] [ 100 [ drop 674 check-random ] all-integers? ] unit-test
 
 : randoms ( -- seq )
     100 [ 100 random ] replicate ;
@@ -16,11 +16,11 @@ IN: random.mersenne-twister.tests
 [ f ] [ 1234 [ randoms 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-integer 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-integer random-generator get random-32* ] test-rng
 ] unit-test
 
 
index a0e40e5c382847d5b44a976b693b7097819fc8a6..9fd82a30626a10eb6b4b0985eeca45776bc83a62 100644 (file)
@@ -30,8 +30,8 @@ CONSTANT: a uint-array{ 0 HEX: 9908b0df }
 : mt-generate ( mt -- )
     [
         seq>>
-        [ [ n m - ] dip '[ [ m ] dip _ mt[k] ] each ]
-        [ [ m 1 - ] dip '[ [ m n - ] [ n m - + ] bi* _ mt[k] ] each ]
+        [ [ n m - ] dip '[ [ m ] dip _ mt[k] ] each-integer ]
+        [ [ m 1 - ] dip '[ [ m n - ] [ n m - + ] bi* _ mt[k] ] each-integer ]
         bi
     ] [ 0 >>i drop ] bi ; inline
 
@@ -41,7 +41,7 @@ CONSTANT: a uint-array{ 0 HEX: 9908b0df }
 : init-mt-rest ( seq -- )
     n 1 - swap '[
         _ [ init-mt-formula ] [ [ 1 + ] dip set-nth ] 2bi
-    ] each ; inline
+    ] each-integer ; inline
 
 : init-mt-seq ( seed -- seq )
     32 bits n <uint-array>
@@ -79,5 +79,5 @@ M: mersenne-twister random-32* ( mt -- r )
 
 [
     default-mersenne-twister random-generator set-global
-] "bootstrap.random" add-init-hook
+] "bootstrap.random" add-startup-hook
 
old mode 100755 (executable)
new mode 100644 (file)
index 788a6e7..2bf92f6
@@ -19,9 +19,8 @@ HELP: random-bytes*
 { $description "Generates a byte-array of random bytes." } ;
 
 HELP: random
-{ $values { "seq" sequence } { "elt" "a random element" } }
-{ $description "Outputs a random element of the input sequence. Outputs " { $link f } " if the sequence is empty." }
-{ $notes "Since integers are sequences, passing an integer " { $snippet "n" } " outputs an integer in the interval " { $snippet "[0,n)" } "." }
+{ $values { "obj" object } { "elt" "a random element" } }
+{ $description "Outputs a random element of the input object, or outputs " { $link f } " if the object contains no elements." }
 { $examples
     { $unchecked-example "USING: random prettyprint ;"
         "10 random ."
index 96dc8cc783c9fdf4d48bec12a58da076f439954f..9341b96b11499c604310cefd207658936882ce1e 100644 (file)
@@ -11,8 +11,8 @@ IN: random.tests
 [ 2 ] [ V{ 10 20 30 } [ delete-random drop ] keep length ] unit-test
 [ V{ } [ delete-random drop ] keep length ] must-fail
 
-[ t ] [ 10000 [ 0 [ drop 187 random + ] reduce ] keep / 2 * 187 10 ~ ] unit-test
-[ t ] [ 10000 [ 0 [ drop 400 random + ] reduce ] keep / 2 * 400 10 ~ ] unit-test
+[ t ] [ 10000 [ iota 0 [ drop 187 random + ] reduce ] keep / 2 * 187 10 ~ ] unit-test
+[ t ] [ 10000 [ iota 0 [ drop 400 random + ] reduce ] keep / 2 * 400 10 ~ ] unit-test
 
 [ t ] [ 1000 [ 400 random ] replicate prune length 256 > ] unit-test
 
@@ -29,7 +29,7 @@ IN: random.tests
 [ { 1 2 } 3 sample ] [ too-many-samples?  ] must-fail-with
 
 [ 3 ] [ { 1 2 3 4 } 3 sample prune length ] unit-test
-[ 99 ] [ 100 99 sample prune length ] unit-test
+[ 99 ] [ 100 iota 99 sample prune length ] unit-test
 
 [ ]
 [ [ 100 random-bytes ] with-system-random drop ] unit-test
old mode 100755 (executable)
new mode 100644 (file)
index bfd107d..1e54c56
@@ -50,7 +50,11 @@ PRIVATE>
 : random-bits* ( numbits -- n )
     1 - [ random-bits ] keep set-bit ;
 
-: random ( seq -- elt )
+GENERIC: random ( obj -- elt )
+
+M: integer random [ f ] [ random-integer ] if-zero ;
+
+M: sequence random
     [ f ] [
         [ length random-integer ] keep nth
     ] if-empty ;
@@ -59,7 +63,7 @@ PRIVATE>
 
 : randomize ( seq -- seq )
     dup length [ dup 1 > ]
-    [ [ iota random ] [ 1 - ] bi [ pick exchange ] keep ]
+    [ [ random ] [ 1 - ] bi [ pick exchange ] keep ]
     while drop ;
 
 ERROR: too-many-samples seq n ;
index 55606217c9219405a1088273bb12d115632863c5..146db911723fd149d6342a04809a43528e9a0745 100644 (file)
@@ -4,7 +4,6 @@ USING: accessors alien.c-types kernel locals math math.ranges
 math.bitwise math.vectors math.vectors.simd random
 sequences specialized-arrays sequences.private classes.struct
 combinators.short-circuit fry ;
-SIMDS: uchar uint ;
 SPECIALIZED-ARRAY: uint
 SPECIALIZED-ARRAY: uint-4
 IN: random.sfmt
index 599cd5e0ad6b3cbc03e1015e3eac9c324935ef5b..fd93d6492cc73336460f934ad9a9ca2202cf2823 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2008 Doug Coleman
 ! See http://factorcode.org/license.txt for BSD license.
 USING: alien.c-types io io.files kernel namespaces random
-io.encodings.binary init accessors system ;
+io.encodings.binary init accessors system destructors ;
 IN: random.unix
 
 TUPLE: unix-random reader ;
@@ -9,17 +9,19 @@ TUPLE: unix-random reader ;
 : <unix-random> ( path -- random )
     binary <file-reader> unix-random boa ;
 
+M: unix-random dispose reader>> dispose ;
+
 M: unix-random random-bytes* ( n tuple -- byte-array )
     reader>> stream-read ;
 
 os openbsd? [
     [
-        "/dev/srandom" <unix-random> secure-random-generator set-global
-        "/dev/arandom" <unix-random> system-random-generator set-global
-    ] "random.unix" add-init-hook
+        "/dev/srandom" <unix-random> &dispose secure-random-generator set-global
+        "/dev/arandom" <unix-random> &dispose system-random-generator set-global
+    ] "random.unix" add-startup-hook
 ] [
     [
-        "/dev/random" <unix-random> secure-random-generator set-global
-        "/dev/urandom" <unix-random> system-random-generator set-global
-    ] "random.unix" add-init-hook
+        "/dev/random" <unix-random> &dispose secure-random-generator set-global
+        "/dev/urandom" <unix-random> &dispose system-random-generator set-global
+    ] "random.unix" add-startup-hook
 ] if
index d959b191c9993170f017167e9f031332992b3c16..c1d3010c0f1e1ea7f605633d0db45fec7b0e4805 100644 (file)
@@ -1,7 +1,7 @@
 USING: accessors alien.c-types alien.data byte-arrays
 combinators.short-circuit continuations destructors init kernel
 locals namespaces random windows.advapi32 windows.errors
-windows.kernel32 math.bitwise ;
+windows.kernel32 windows.types math.bitwise ;
 IN: random.windows
 
 TUPLE: windows-rng provider type ;
@@ -16,7 +16,7 @@ M: windows-crypto-context dispose ( tuple -- )
 CONSTANT: factor-crypto-container "FactorCryptoContainer"
 
 :: (acquire-crypto-context) ( provider type flags -- handle ret )
-    "HCRYPTPROV" <c-object> :> handle
+    HCRYPTPROV <c-object> :> handle
     handle
     factor-crypto-container
     provider
@@ -65,5 +65,11 @@ M: windows-rng random-bytes* ( n tuple -- bytes )
     [ MS_STRONG_PROV PROV_RSA_FULL <windows-rng> ]
     [ drop MS_ENH_RSA_AES_PROV PROV_RSA_AES <windows-rng> ] recover
     secure-random-generator set-global
+] "random.windows" add-startup-hook
 
-] "random.windows" add-init-hook
+[
+    [
+        ! system-random-generator get-global &dispose drop
+        ! secure-random-generator get-global &dispose drop
+    ] with-destructors
+] "random.windows" add-shutdown-hook
old mode 100755 (executable)
new mode 100644 (file)
index 2de4e8b0e02322d7a3391c86f607944d18125ace..fa75232fd5c0b7472da6c765b6bca3b60a43aa8b 100644 (file)
@@ -25,7 +25,7 @@ IN: regexp.dfa
     ] unless ;
 
 : epsilon-table ( states nfa -- table )
-    [ H{ } clone tuck ] dip
+    [ [ H{ } clone ] dip over ] dip
     '[ _ _ t epsilon-loop ] each ;
 
 : find-epsilon-closure ( states nfa -- dfa-state )
index 876d898cb4e48ca36ad058bf5758b704bdbc7f4e..33b2ded448e53ad803265f0118ccc864c5449a79 100644 (file)
@@ -11,9 +11,7 @@ TUPLE: parts in out ;
     zip [ first ] partition [ values ] bi@ parts boa ;
 
 : powerset-partition ( sequence -- partitions )
-    [ length [ 2^ ] keep ] keep '[
-        _ <bits> _ make-partition
-    ] map rest ;
+    [ length [ 2^ iota ] keep ] keep '[ _ <bits> _ make-partition ] map rest ;
 
 : partition>class ( parts -- class )
     [ out>> [ <not-class> ] map ]
@@ -44,12 +42,12 @@ TUPLE: parts in out ;
         [ _ meaningful-integers ] keep add-out
     ] map ;
 
-: class-partitions ( classes -- assoc )
-    [ integer? ] partition [
-        dup powerset-partition spin add-integers
-        [ [ partition>class ] keep 2array ] map
-        [ first ] filter
-    ] [ '[ _ singleton-partition ] map ] 2bi append ;
+:: class-partitions ( classes -- assoc )
+    classes [ integer? ] partition :> ( integers classes )
+    
+    classes powerset-partition classes integers add-integers
+    [ [ partition>class ] keep 2array ] map [ first ] filter
+    integers [ classes singleton-partition ] map append ;
 
 : new-transitions ( transitions -- assoc ) ! assoc is class, partition
     values [ keys ] gather
index 1885144e6ccb45937d7aa3d8174fa37aa5870ff5..a6eb4f00a288dbf752ccd8a1d2fd74aa9b441321 100644 (file)
@@ -85,7 +85,7 @@ IN: regexp.minimize
     '[ _ delete-duplicates ] change-transitions ;
 
 : combine-state-transitions ( hash -- hash )
-    H{ } clone tuck '[
+    [ H{ } clone ] dip over '[
         _ [ 2array <or-class> ] change-at
     ] assoc-each [ swap ] assoc-map ;
 
index 50a057d7f400628f856cf48210022c4905d3c0ce..c81ed0ae42898c518dcc2c94bdaa12390098a912 100644 (file)
@@ -4,7 +4,7 @@ USING: help.markup help.syntax kernel math strings ;
 IN: roman
 
 HELP: >roman
-{ $values { "n" "an integer" } { "str" "a string" } }
+{ $values { "n" integer } { "str" string } }
 { $description "Converts a number to its lower-case Roman Numeral equivalent." }
 { $notes "The range for this word is 1-3999, inclusive." }
 { $examples 
@@ -15,7 +15,7 @@ HELP: >roman
 } ;
 
 HELP: >ROMAN
-{ $values { "n" "an integer" } { "str" "a string" } }
+{ $values { "n" integer } { "str" string } }
 { $description "Converts a number to its upper-case Roman numeral equivalent." }
 { $notes "The range for this word is 1-3999, inclusive." }
 { $examples 
@@ -26,7 +26,7 @@ HELP: >ROMAN
 } ;
 
 HELP: roman>
-{ $values { "str" "a string" } { "n" "an integer" } }
+{ $values { "str" string } { "n" integer } }
 { $description "Converts a Roman numeral to an integer." }
 { $notes "The range for this word is i-mmmcmxcix, inclusive." }
 { $examples 
@@ -39,7 +39,7 @@ HELP: roman>
 { >roman >ROMAN roman> } related-words
 
 HELP: roman+
-{ $values { "string" string } { "string" string } { "string" string } }
+{ $values { "x" string } { "x" string } { "x" string } }
 { $description "Adds two Roman numerals." }
 { $examples 
     { $example "USING: io roman ;"
@@ -49,7 +49,7 @@ HELP: roman+
 } ;
 
 HELP: roman-
-{ $values { "string" string } { "string" string } { "string" string } }
+{ $values { "x" string } { "x" string } { "x" string } }
 { $description "Subtracts two Roman numerals." }
 { $examples 
     { $example "USING: io roman ;"
@@ -61,7 +61,7 @@ HELP: roman-
 { roman+ roman- } related-words
 
 HELP: roman*
-{ $values { "string" string } { "string" string } { "string" string } }
+{ $values { "x" string } { "x" string } { "x" string } }
 { $description "Multiplies two Roman numerals." }
 { $examples 
     { $example "USING: io roman ;"
@@ -71,7 +71,7 @@ HELP: roman*
 } ;
 
 HELP: roman/i
-{ $values { "string" string } { "string" string } { "string" string } }
+{ $values { "x" string } { "x" string } { "x" string } }
 { $description "Computes the integer division of two Roman numerals." }
 { $examples 
     { $example "USING: io roman ;"
@@ -81,7 +81,7 @@ HELP: roman/i
 } ;
 
 HELP: roman/mod
-{ $values { "string" string } { "string" string } { "string" string } { "string" string } }
+{ $values { "x" string } { "x" string } { "x" string } { "x" string } }
 { $description "Computes the quotient and remainder of two Roman numerals." }
 { $examples 
     { $example "USING: kernel io roman ;"
index a510514e2344cbcd5e6c6f37eb8eb7c204301c7a..c7ab7fafd9177081f2407468dc5ae2bf86184326 100644 (file)
@@ -29,7 +29,7 @@ USING: arrays kernel math roman roman.private sequences tools.test ;
 [ 3444 ] [ 3444 >roman roman> ] unit-test
 [ 3999 ] [ 3999 >roman roman> ] unit-test
 [ 0 >roman ] must-fail
-[ 4000 >roman ] must-fail
+[ 40000 >roman ] must-fail
 [ "vi" ] [ "iii" "iii"  roman+ ] unit-test
 [ "viii" ] [ "x" "ii"  roman- ] unit-test
 [ "ix" ] [ "iii" "iii"  roman* ] unit-test
index f8c7da9ab46be6deb0d6391b5cf07d149ad16471..a783e7973c3193f1eb120a7381a967baaa125ff6 100644 (file)
@@ -17,7 +17,7 @@ CONSTANT: roman-values
 ERROR: roman-range-error n ;
 
 : roman-range-check ( n -- n )
-    dup 1 3999 between? [ roman-range-error ] unless ;
+    dup 1 10000 between? [ roman-range-error ] unless ;
 
 : roman-digit-index ( ch -- n )
     1string roman-digits index ; inline
@@ -48,7 +48,7 @@ PRIVATE>
 <PRIVATE
 
 MACRO: binary-roman-op ( quot -- quot' )
-    [ infer in>> ] [ ] [ infer out>> ] tri
+    [ inputs ] [ ] [ outputs ] tri
     '[ [ roman> ] _ napply @ [ >roman ] _ napply ] ;
 
 PRIVATE>
@@ -58,8 +58,7 @@ PRIVATE>
 SYNTAX: ROMAN-OP:
     scan-word [ name>> "roman" prepend create-in ] keep
     1quotation '[ _ binary-roman-op ]
-    dup infer [ in>> ] [ out>> ] bi
-    [ "string" <repetition> ] bi@ <effect> define-declared ;
+    dup infer define-declared ;
 
 >>
 
diff --git a/basis/sequences/cords/authors.txt b/basis/sequences/cords/authors.txt
new file mode 100644 (file)
index 0000000..1901f27
--- /dev/null
@@ -0,0 +1 @@
+Slava Pestov
diff --git a/basis/sequences/cords/cords-tests.factor b/basis/sequences/cords/cords-tests.factor
new file mode 100644 (file)
index 0000000..fb9c440
--- /dev/null
@@ -0,0 +1,4 @@
+USING: sequences.cords strings tools.test kernel sequences ;
+IN: sequences.cords.tests
+
+[ "hello world" ] [ "hello" " world" cord-append dup like ] unit-test
diff --git a/basis/sequences/cords/cords.factor b/basis/sequences/cords/cords.factor
new file mode 100644 (file)
index 0000000..fca005f
--- /dev/null
@@ -0,0 +1,112 @@
+! Copyright (C) 2008 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: accessors assocs sequences sorting binary-search fry math
+math.order arrays classes combinators kernel functors math.functions
+math.vectors ;
+IN: sequences.cords
+
+MIXIN: cord
+
+TUPLE: generic-cord
+    { head read-only } { tail read-only } ;
+INSTANCE: generic-cord cord
+
+M: cord length
+    [ head>> length ] [ tail>> length ] bi + ; inline
+
+M: cord virtual-exemplar head>> ; inline
+
+M: cord virtual@
+    2dup head>> length <
+    [ head>> ] [ [ head>> length - ] [ tail>> ] bi ] if ; inline
+
+INSTANCE: cord virtual-sequence
+
+GENERIC: cord-append ( seq1 seq2 -- cord )
+
+M: object cord-append
+    generic-cord boa ; inline
+
+FUNCTOR: define-specialized-cord ( T C -- )
+
+T-cord DEFINES-CLASS ${C}
+
+WHERE
+
+TUPLE: T-cord
+    { head T read-only } { tail T read-only } ;
+INSTANCE: T-cord cord
+
+M: T cord-append
+    2dup [ T instance? ] both?
+    [ T-cord boa ] [ generic-cord boa ] if ; inline
+
+;FUNCTOR
+
+: cord-map ( cord quot -- cord' )
+    [ [ head>> ] dip call ]
+    [ [ tail>> ] dip call ] 2bi cord-append ; inline
+
+: cord-2map ( cord cord quot -- cord' )
+    [ [ [ head>> ] bi@ ] dip call ]
+    [ [ [ tail>> ] bi@ ] dip call ] 3bi cord-append ; inline
+
+: cord-both ( cord quot -- h t )
+    [ [ head>> ] [ tail>> ] bi ] dip bi@ ; inline
+
+: cord-2both ( cord cord quot -- h t )
+    [ [ [ head>> ] bi@ ] dip call ]
+    [ [ [ tail>> ] bi@ ] dip call ] 3bi ; inline
+
+M: cord v+                [ v+                ] cord-2map ; inline
+M: cord v-                [ v-                ] cord-2map ; inline
+M: cord vneg              [ vneg              ] cord-map  ; inline
+M: cord v+-               [ v+-               ] cord-2map ; inline
+M: cord vs+               [ vs+               ] cord-2map ; inline
+M: cord vs-               [ vs-               ] cord-2map ; inline
+M: cord vs*               [ vs*               ] cord-2map ; inline
+M: cord v*                [ v*                ] cord-2map ; inline
+M: cord v/                [ v/                ] cord-2map ; inline
+M: cord vmin              [ vmin              ] cord-2map ; inline
+M: cord vmax              [ vmax              ] cord-2map ; inline
+M: cord v.                [ v.                ] cord-2both + ; inline
+M: cord vsqrt             [ vsqrt             ] cord-map  ; inline
+M: cord sum               [ sum               ] cord-both + ; inline
+M: cord vabs              [ vabs              ] cord-map  ; inline
+M: cord vbitand           [ vbitand           ] cord-2map ; inline
+M: cord vbitandn          [ vbitandn          ] cord-2map ; inline
+M: cord vbitor            [ vbitor            ] cord-2map ; inline
+M: cord vbitxor           [ vbitxor           ] cord-2map ; inline
+M: cord vbitnot           [ vbitnot           ] cord-map  ; inline
+M: cord vand              [ vand              ] cord-2map ; inline
+M: cord vandn             [ vandn             ] cord-2map ; inline
+M: cord vor               [ vor               ] cord-2map ; inline
+M: cord vxor              [ vxor              ] cord-2map ; inline
+M: cord vnot              [ vnot              ] cord-map  ; inline
+M: cord vlshift           '[ _ vlshift        ] cord-map  ; inline
+M: cord vrshift           '[ _ vrshift        ] cord-map  ; inline
+M: cord (vmerge-head)     [ head>> ] bi@ (vmerge) cord-append ; inline
+M: cord (vmerge-tail)     [ tail>> ] bi@ (vmerge) cord-append ; inline
+M: cord v<=               [ v<=               ] cord-2map ; inline
+M: cord v<                [ v<                ] cord-2map ; inline
+M: cord v=                [ v=                ] cord-2map ; inline
+M: cord v>                [ v>                ] cord-2map ; inline
+M: cord v>=               [ v>=               ] cord-2map ; inline
+M: cord vunordered?       [ vunordered?       ] cord-2map ; inline
+M: cord vany?             [ vany?             ] cord-both or  ; inline
+M: cord vall?             [ vall?             ] cord-both and ; inline
+M: cord vnone?            [ vnone?            ] cord-both and ; inline
+
+M: cord n+v [ n+v ] with cord-map ; inline
+M: cord n-v [ n-v ] with cord-map ; inline
+M: cord n*v [ n*v ] with cord-map ; inline
+M: cord n/v [ n/v ] with cord-map ; inline
+M: cord v+n '[ _ v+n ] cord-map ; inline
+M: cord v-n '[ _ v-n ] cord-map ; inline
+M: cord v*n '[ _ v*n ] cord-map ; inline
+M: cord v/n '[ _ v/n ] cord-map ; inline
+
+M: cord norm-sq [ norm-sq ] cord-both + ; inline
+M: cord distance v- norm ; inline
+
+
diff --git a/basis/sequences/cords/summary.txt b/basis/sequences/cords/summary.txt
new file mode 100644 (file)
index 0000000..3c69862
--- /dev/null
@@ -0,0 +1 @@
+Virtual sequence concatenation
diff --git a/basis/sequences/cords/tags.txt b/basis/sequences/cords/tags.txt
new file mode 100644 (file)
index 0000000..42d711b
--- /dev/null
@@ -0,0 +1 @@
+collections
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index da0d340126fd61e67638564048e5fc40258a9885..9b98cd1ed816e96a1e26494aa3df8d910beec535 100644 (file)
@@ -20,7 +20,7 @@ HELP: merged
 
 HELP: <merged> ( seqs -- merged )
 { $values { "seqs" "a sequence of sequences to merge" } { "merged" "a virtual sequence" } }
-{ $description "Creates an instance of the " { $link merged } " virtual sequence." }
+{ $description "Creates an instance of the " { $link merged } " virtual sequence. The length of the created virtual sequences is the minimum length of the input sequences times the number of input sequences." }
 { $see-also <2merged> <3merged> merge } ;
 
 HELP: <2merged> ( seq1 seq2 -- merged )
index 13a46f0b722009979fe4a386b05ab6abb97afb3e..cbd4176bef40bb649acb01e1cfbdfc09a70c4de4 100644 (file)
@@ -15,3 +15,6 @@ IN: sequences.merged.tests
 [ 6 ] [ 5 { 1 2 3 } { 4 5 6 } <2merged> nth ] unit-test
 
 [ 4 ] [ 4 { 1 2 } { 3 4 } { 5 6 } 3merge nth ] unit-test
+
+[ "" ] [ "abcdefg" "" 2merge ] unit-test
+[ "a1b2" ] [ "abc" "12" <2merged> "" like ] unit-test
index d64da6efe6ce6f5b1fd25ac982aff5e07dd4b2b3..c14ccf2f20e0e46274b6f9d6def6a3895595b70b 100644 (file)
@@ -1,6 +1,7 @@
 ! Copyright (C) 2008 Alex Chapman
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors arrays kernel math sequences ;
+USING: accessors arrays kernel math math.order sequences
+sequences.private ;
 IN: sequences.merged
 
 TUPLE: merged seqs ;
@@ -10,19 +11,21 @@ C: <merged> merged
 : <3merged> ( seq1 seq2 seq3 -- merged ) 3array <merged> ;
 
 : merge ( seqs -- seq )
-    dup <merged> swap first like ;
+    [ <merged> ] keep first like ;
 
 : 2merge ( seq1 seq2 -- seq )
-    dupd <2merged> swap like ;
+    [ <2merged> ] 2keep drop like ;
 
 : 3merge ( seq1 seq2 seq3 -- seq )
-    pick [ <3merged> ] dip like ;
+    [ <3merged> ] 3keep 2drop like ;
 
-M: merged length seqs>> [ length ] map sum ;
+M: merged length
+    seqs>> [ [ length ] [ min ] map-reduce ] [ length ] bi * ; inline
 
 M: merged virtual@ ( n seq -- n' seq' )
-    seqs>> [ length /mod ] [ nth ] bi ;
+    seqs>> [ length /mod ] [ nth-unsafe ] bi ; inline
 
-M: merged virtual-seq ( merged -- seq ) [ ] { } map-as ;
+M: merged virtual-exemplar ( merged -- seq )
+    seqs>> [ f ] [ first ] if-empty ; inline
 
 INSTANCE: merged virtual-sequence
diff --git a/basis/sequences/parser/authors.txt b/basis/sequences/parser/authors.txt
new file mode 100644 (file)
index 0000000..a07c427
--- /dev/null
@@ -0,0 +1,2 @@
+Daniel Ehrenberg
+Doug Coleman
diff --git a/basis/sequences/parser/parser-tests.factor b/basis/sequences/parser/parser-tests.factor
new file mode 100644 (file)
index 0000000..0c4f139
--- /dev/null
@@ -0,0 +1,106 @@
+USING: tools.test sequences.parser unicode.categories kernel
+accessors ;
+IN: sequences.parser.tests
+
+[ "hello" ]
+[ "hello" [ take-rest ] parse-sequence ] unit-test
+
+[ "hi" " how are you?" ]
+[
+    "hi how are you?"
+    [ [ [ current blank? ] take-until ] [ take-rest ] bi ] parse-sequence
+] unit-test
+
+[ "foo" ";bar" ]
+[
+    "foo;bar" [
+        [ CHAR: ; take-until-object ] [ take-rest ] bi
+    ] parse-sequence
+] unit-test
+
+[ "foo " "and bar" ]
+[
+    "foo and bar" [
+        [ "and" take-until-sequence ] [ take-rest ] bi 
+    ] parse-sequence
+] unit-test
+
+[ "foo " " bar" ]
+[
+    "foo and bar" [
+        [ "and" take-until-sequence ]
+        [ "and" take-sequence drop ]
+        [ take-rest ] tri
+    ] parse-sequence
+] unit-test
+
+[ "foo " " bar" ]
+[
+    "foo and bar" [
+        [ "and" take-until-sequence* ]
+        [ take-rest ] bi
+    ] parse-sequence
+] unit-test
+
+[ { 1 2 } ]
+[ { 1 2 3 4 } <sequence-parser> { 3 4 } take-until-sequence ] unit-test
+
+[ f "aaaa" ]
+[
+    "aaaa" <sequence-parser>
+    [ "b" take-until-sequence ] [ take-rest ] bi
+] unit-test
+
+[ 6 ]
+[
+    "      foo   " [ skip-whitespace n>> ] parse-sequence
+] unit-test
+
+[ { 1 2 } ]
+[ { 1 2 3 } <sequence-parser> [ current 3 = ] take-until ] unit-test
+
+[ "ab" ]
+[ "abcd" <sequence-parser> "ab" take-sequence ] unit-test
+
+[ f ]
+[ "abcd" <sequence-parser> "lol" take-sequence ] unit-test
+
+[ "ab" ]
+[
+    "abcd" <sequence-parser>
+    [ "lol" take-sequence drop ] [ "ab" take-sequence ] bi
+] unit-test
+
+[ "" ]
+[ "abcd" <sequence-parser> "" take-sequence ] unit-test
+
+[ "cd" ]
+[ "abcd" <sequence-parser> [ "ab" take-sequence drop ] [ "cd" take-sequence ] bi ] unit-test
+
+[ f ]
+[ "" <sequence-parser> take-rest ] unit-test
+
+[ f ]
+[ "abc" <sequence-parser> dup "abc" take-sequence drop take-rest ] unit-test
+
+[ f ]
+[ "abc" <sequence-parser> "abcdefg" take-sequence ] unit-test
+
+[ "1234" ]
+[ "1234f" <sequence-parser> take-integer ] unit-test
+
+[ "yes" ]
+[
+    "yes1234f" <sequence-parser>
+    [ take-integer drop ] [ "yes" take-sequence ] bi 
+] unit-test
+
+[ f ] [ "" <sequence-parser> 4 take-n ] unit-test
+[ "abcd" ] [ "abcd" <sequence-parser> 4 take-n ] unit-test
+[ "abcd" "efg" ] [ "abcdefg" <sequence-parser> [ 4 take-n ] [ take-rest ] bi ] unit-test
+
+[ f ]
+[ "\n" <sequence-parser> take-integer ] unit-test
+
+[ "\n" ] [ "\n" <sequence-parser> [ ] take-while ] unit-test
+[ f ] [ "\n" <sequence-parser> [ not ] take-while ] unit-test
diff --git a/basis/sequences/parser/parser.factor b/basis/sequences/parser/parser.factor
new file mode 100644 (file)
index 0000000..44fa752
--- /dev/null
@@ -0,0 +1,148 @@
+! Copyright (C) 2005, 2009 Daniel Ehrenberg, Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: accessors circular combinators.short-circuit fry io
+kernel locals math math.order sequences sorting.functor
+sorting.slots unicode.categories ;
+IN: sequences.parser
+
+TUPLE: sequence-parser sequence n ;
+
+: <sequence-parser> ( sequence -- sequence-parser )
+    sequence-parser new
+        swap >>sequence
+        0 >>n ;
+
+:: with-sequence-parser ( sequence-parser quot -- seq/f )
+    sequence-parser n>> :> n
+    sequence-parser quot call [
+        n sequence-parser (>>n) f
+    ] unless* ; inline
+
+: offset  ( sequence-parser offset -- char/f )
+    swap
+    [ n>> + ] [ sequence>> ?nth ] bi ; inline
+
+: current ( sequence-parser -- char/f ) 0 offset ; inline
+
+: previous ( sequence-parser -- char/f ) -1 offset ; inline
+
+: peek-next ( sequence-parser -- char/f ) 1 offset ; inline
+
+: advance ( sequence-parser -- sequence-parser )
+    [ 1 + ] change-n ; inline
+
+: advance* ( sequence-parser -- )
+    advance drop ; inline
+
+: next ( sequence-parser -- obj ) [ current ] [ advance* ] bi ;
+
+: get+increment ( sequence-parser -- char/f )
+    [ current ] [ advance drop ] bi ; inline
+
+:: skip-until ( sequence-parser quot: ( obj -- ? ) -- )
+    sequence-parser current [
+        sequence-parser quot call
+        [ sequence-parser advance quot skip-until ] unless
+    ] when ; inline recursive
+
+: sequence-parse-end? ( sequence-parser -- ? ) current not ;
+
+: take-until ( sequence-parser quot: ( obj -- ? ) -- sequence/f )
+    over sequence-parse-end? [
+        2drop f
+    ] [
+        [ drop n>> ]
+        [ skip-until ]
+        [ drop [ n>> ] [ sequence>> ] bi ] 2tri subseq f like
+    ] if ; inline
+
+: take-while ( sequence-parser quot: ( obj -- ? ) -- sequence/f )
+    [ not ] compose take-until ; inline
+
+: <safe-slice> ( from to seq -- slice/f )
+    3dup {
+        [ 2drop 0 < ]
+        [ [ drop ] 2dip length > ]
+        [ drop > ]
+    } 3|| [ 3drop f ] [ slice boa ] if ; inline
+
+:: take-sequence ( sequence-parser sequence -- obj/f )
+    sequence-parser [ n>> dup sequence length + ] [ sequence>> ] bi
+    <safe-slice> sequence sequence= [
+        sequence
+        sequence-parser [ sequence length + ] change-n drop
+    ] [
+        f
+    ] if ;
+
+: take-sequence* ( sequence-parser sequence -- )
+    take-sequence drop ;
+
+:: take-until-sequence ( sequence-parser sequence -- sequence'/f )
+    sequence-parser n>> :> saved
+    sequence length <growing-circular> :> growing
+    sequence-parser
+    [
+        current growing growing-circular-push
+        sequence growing sequence=
+    ] take-until :> found
+    growing sequence sequence= [
+        found dup length
+        growing length 1 - - head
+        sequence-parser [ growing length - 1 + ] change-n drop
+        ! sequence-parser advance drop
+    ] [
+        saved sequence-parser (>>n)
+        f
+    ] if ;
+
+:: take-until-sequence* ( sequence-parser sequence -- sequence'/f )
+    sequence-parser sequence take-until-sequence :> out
+    out [
+        sequence-parser [ sequence length + ] change-n drop
+    ] when out ;
+
+: skip-whitespace ( sequence-parser -- sequence-parser )
+    [ [ current blank? not ] take-until drop ] keep ;
+
+: skip-whitespace-eol ( sequence-parser -- sequence-parser )
+    [ [ current " \t\r" member? not ] take-until drop ] keep ;
+
+: take-rest-slice ( sequence-parser -- sequence/f )
+    [ sequence>> ] [ n>> ] bi
+    2dup [ length ] dip < [ 2drop f ] [ tail-slice ] if ; inline
+
+: take-rest ( sequence-parser -- sequence )
+    [ take-rest-slice ] [ sequence>> like ] bi f like ;
+
+: take-until-object ( sequence-parser obj -- sequence )
+    '[ current _ = ] take-until ;
+
+: parse-sequence ( sequence quot -- )
+    [ <sequence-parser> ] dip call ; inline
+
+: take-integer ( sequence-parser -- n/f )
+    [ current digit? ] take-while ;
+
+:: take-n ( sequence-parser n -- seq/f )
+    n sequence-parser [ n>> + ] [ sequence>> length ] bi > [
+        sequence-parser take-rest
+    ] [
+        sequence-parser n>> dup n + sequence-parser sequence>> subseq
+        sequence-parser [ n + ] change-n drop
+    ] if ;
+
+<< "length" [ length ] define-sorting >>
+
+: sort-tokens ( seq -- seq' )
+    { length>=< <=> } sort-by ;
+
+: take-first-matching ( sequence-parser seq -- seq )
+    swap
+    '[ _ [ swap take-sequence ] with-sequence-parser ] find nip ;
+
+: take-longest ( sequence-parser seq -- seq )
+    sort-tokens take-first-matching ;
+
+: write-full ( sequence-parser -- ) sequence>> write ;
+: write-rest ( sequence-parser -- ) take-rest write ;
index 0b6805eb71526f9a3d17049c44def9acfc63502d..06c99ab806f7299b3123ee541d489193877210f2 100644 (file)
@@ -1,5 +1,5 @@
 ! (c)2009 Joe Groff bsd license
-USING: help.markup help.syntax quotations sequences ;
+USING: assocs help.markup help.syntax quotations sequences ;
 IN: sequences.product
 
 HELP: product-sequence
@@ -44,6 +44,14 @@ HELP: product-map
 { $description "Calls " { $snippet "quot" } " for every element of the cartesian product of " { $snippet "sequences" } " and collects the results from " { $snippet "quot" } " into an output sequence." }
 { $notes { $snippet "[ ... ] product-map" } " is equivalent to, but more efficient than, " { $snippet "<product-sequence> [ ... ] map" } "." } ;
 
+HELP: product-map-as
+{ $values { "sequences" sequence } { "quot" { $quotation "( sequence -- value )" } } { "exemplar" sequence } { "sequence" sequence } }
+{ $description "Calls " { $snippet "quot" } " for every element of the cartesian product of " { $snippet "sequences" } " and collects the results from " { $snippet "quot" } " into an output sequence the same type as the " { $snippet "exemplar" } " sequence." } ;
+
+HELP: product-map>assoc
+{ $values { "sequences" sequence } { "quot" { $quotation "( sequence -- key value )" } } { "exemplar" assoc } { "assoc" assoc } }
+{ $description "Calls " { $snippet "quot" } " for every element of the cartesian product of " { $snippet "sequences" } " and collects the results from " { $snippet "quot" } " into an output assoc." } ;
+
 HELP: product-each
 { $values { "sequences" sequence } { "quot" { $quotation "( sequence -- )" } } }
 { $description "Calls " { $snippet "quot" } " for every element of the cartesian product of " { $snippet "sequences" } "." }
@@ -57,6 +65,8 @@ ARTICLE: "sequences.product" "Product sequences"
     product-sequence
     <product-sequence>
     product-map
+    product-map-as
+    product-map>assoc
     product-each
 } ;
 
index f783fad31204a3744ff21b8499aee057f787b5fc..42900854821f1a73b708776108b9f46ec346c61f 100644 (file)
@@ -1,5 +1,5 @@
 ! (c)2009 Joe Groff bsd license
-USING: accessors arrays kernel locals math sequences ;
+USING: accessors arrays assocs kernel locals math sequences ;
 IN: sequences.product
 
 TUPLE: product-sequence { sequences array read-only } { lengths array read-only } ;
@@ -55,11 +55,21 @@ M: product-sequence nth
         [ ns sequences nths quot call ns lengths product-iter ] until
     ] unless ; inline
 
-:: product-map ( sequences quot -- sequence )
+:: product-map-as ( sequences quot exemplar -- sequence )
     0 :> i!
-    sequences [ length ] [ * ] map-reduce sequences
+    sequences [ length ] [ * ] map-reduce exemplar
     [| result |
         sequences [ quot call i result set-nth i 1 + i! ] product-each
         result
     ] new-like ; inline
 
+: product-map ( sequences quot -- sequence )
+    over product-map-as ; inline
+
+:: product-map>assoc ( sequences quot exemplar -- assoc )
+    0 :> i!
+    sequences [ length ] [ * ] map-reduce { }
+    [| result |
+        sequences [ quot call 2array i result set-nth i 1 + i! ] product-each
+        result
+    ] new-like exemplar assoc-like ; inline
index 6dbc76386d1c4824f9546d3203d041a88e1cdec0..036356e137975eeeec2fa147007450d2cacb2659 100644 (file)
@@ -16,12 +16,12 @@ IN: serialize.tests
 [ t ] [
     100 [
         drop
-        40 [        test-serialize-cell ] all?
-         4 [ 40 *   test-serialize-cell ] all?
-         4 [ 400 *  test-serialize-cell ] all?
-         4 [ 4000 * test-serialize-cell ] all?
+        40 [        test-serialize-cell ] all-integers?
+         4 [ 40 *   test-serialize-cell ] all-integers?
+         4 [ 400 *  test-serialize-cell ] all-integers?
+         4 [ 4000 * test-serialize-cell ] all-integers?
         and and and
-    ] all?
+    ] all-integers?
 ] unit-test
 
 TUPLE: serialize-test a b ;
index 4de858e811182d63593e8e2b32bf0deb951d8cdd..0840c778d7923473d6a3c434b8c7aed0cded8ad7 100644 (file)
@@ -26,7 +26,7 @@ TUPLE: id obj ;
 
 C: <id> id
 
-M: id hashcode* obj>> hashcode* ;
+M: id hashcode* nip obj>> identity-hashcode ;
 
 M: id equal? over id? [ [ obj>> ] bi@ eq? ] [ 2drop f ] if ;
 
@@ -240,7 +240,7 @@ SYMBOL: deserialized
     [ ] tri ;
 
 : copy-seq-to-tuple ( seq tuple -- )
-    [ dup length ] dip [ set-array-nth ] curry 2each ;
+    [ set-array-nth ] curry each-index ;
 
 : deserialize-tuple ( -- array )
     #! Ugly because we have to intern the tuple before reading
index 15398450a7e63d238a22abe0e6cd0d933d5c731c..363727a6c5c75fa8916f860a4dd22ee72d774653 100644 (file)
@@ -1,5 +1,7 @@
 USING: help.markup help.syntax ;
 IN: shuffle
 
+HELP: spin  $complex-shuffle ;
 HELP: roll  $complex-shuffle ;
 HELP: -roll $complex-shuffle ;
+HELP: tuck  $complex-shuffle ;
index 43c0b75be1cd91b38cb90af537a04eeeaee82407..b826606df51f85070e4d9ddb17270b3a1e9625a4 100644 (file)
@@ -8,7 +8,7 @@ IN: shuffle
 <PRIVATE
 
 : >index-assoc ( sequence -- assoc )
-    dup length zip >hashtable ;
+    dup length iota zip >hashtable ;
 
 PRIVATE>
 
@@ -22,6 +22,10 @@ MACRO: shuffle-effect ( effect -- )
 SYNTAX: shuffle(
     ")" parse-effect suffix! \ shuffle-effect suffix! ;
 
+: tuck ( x y -- y x y ) swap over ; inline deprecated
+
+: spin ( x y z -- z y x ) swap rot ; inline deprecated
+
 : roll ( x y z t -- y z t x ) [ rot ] dip swap ; inline deprecated
 
 : -roll ( x y z t -- t x y z ) swap [ -rot ] dip ; inline deprecated
index 83457defa5350f066c0a1ecd2d936beff0fd6497..61ccd5c435c1d7401578927f2cdcd4ed1397d729 100644 (file)
@@ -187,7 +187,7 @@ ERROR: invalid-header-string string ;
         "<" %
         64 random-bits #
         "-" %
-        micros #
+        system-micros #
         "@" %
         smtp-domain get [ host-name ] unless* %
         ">" %
index 78b1493920cca026cde6aa54b8e9085f3e5cb462..b7fefcad635c9d04d381d34fa669a86069db073e 100644 (file)
@@ -13,4 +13,4 @@ PRIVATE>
 
 : insertion-sort ( seq quot -- )
     ! quot is a transformation on elements
-    over length [ insert ] with with each ; inline
+    over length [ insert ] with with each-integer ; inline
index 5ebd4438fe94e9ab757be475b56d4a4a2e3a8f46..08fc0e921d4a44b6881b3dff93a5dc0201cb49c4 100644 (file)
@@ -1,8 +1,7 @@
 ! Copyright (C) 2009 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors math.order sorting.slots tools.test
-sorting.human arrays sequences kernel assocs multiline
-sorting.functor ;
+arrays sequences kernel assocs multiline sorting.functor ;
 IN: sorting.literals.tests
 
 TUPLE: sort-test a b c tuple2 ;
@@ -42,7 +41,7 @@ TUPLE: tuple2 d ;
         T{ sort-test f 1 1 11 }
         T{ sort-test f 2 5 3 }
         T{ sort-test f 2 5 2 }
-    } { { a>> human<=> } { b>> human>=< } { c>> <=> } } sort-by
+    } { { a>> <=> } { b>> >=< } { c>> <=> } } sort-by
 ] unit-test
 
 [ { } ]
@@ -83,14 +82,14 @@ TUPLE: tuple2 d ;
     { length-test<=> <=> } sort-by
 ] unit-test
 
-[ { { 0 1 } { 1 2 } { 1 1 } { 3 2 } } ]
+[ { { { 0 } 1 } { { 1 } 2 } { { 1 } 1 } { { 3 1 } 2 } } ]
 [
-    { { 3 2 } { 1 2 } { 0 1 } { 1 1 } }
+    { { { 3 1 } 2 } { { 1 } 2 } { { 0 } 1 } { { 1 } 1 } }
     { length-test<=> <=> } sort-keys-by
 ] unit-test
 
-[ { { 0 1 } { 1 1 } { 3 2 } { 1 2 } } ]
+[ { { 0 { 1 } } { 1 { 1 } } { 3 { 2 4 } } { 1 { 2 0 0 0 } } } ]
 [
-    { { 3 2 } { 1 2 } { 0 1 } { 1 1 } }
+    { { 3 { 2 4 } } { 1 { 2 0 0 0 } } { 0 { 1 } } { 1 { 1 } } }
     { length-test<=> <=> } sort-values-by
 ] unit-test
index ee7953b501044d3f27cd16d47fecef9f8c9076c7..eea9e83b5832ab27fe0e11a38b68091baec5712b 100644 (file)
@@ -4,5 +4,3 @@ USING: mirrors specialized-arrays math.vectors ;
 IN: specialized-arrays.mirrors
 
 INSTANCE: specialized-array enumerated-sequence
-INSTANCE: simd-128          enumerated-sequence
-INSTANCE: simd-256          enumerated-sequence
old mode 100755 (executable)
new mode 100644 (file)
index bc293b1..c7e1285
@@ -10,8 +10,6 @@ FROM: alien.c-types => float ;
 SPECIALIZED-ARRAY: int
 SPECIALIZED-ARRAYS: bool ushort char uint float ulonglong ;
 
-[ ulonglong ] [ ulonglong-array{ } element-type ] unit-test
-
 [ t ] [ { 1 2 3 } >int-array int-array? ] unit-test
 
 [ t ] [ int-array{ 1 2 3 } int-array? ] unit-test
@@ -20,7 +18,7 @@ SPECIALIZED-ARRAYS: bool ushort char uint float ulonglong ;
 
 [ t ] [
     { t f t } >bool-array underlying>>
-    { 1 0 1 } "bool" heap-size {
+    { 1 0 1 } bool heap-size {
         { 1 [ >char-array ] }
         { 4 [ >uint-array ] }
     } case underlying>> =
@@ -153,3 +151,22 @@ SPECIALIZED-ARRAY: __does_not_exist__
         __does_not_exist__ specialized-array-vocab forget-vocab
     ] with-compilation-unit
 ] unit-test
+
+STRUCT: struct-resize-test { x int } ;
+
+SPECIALIZED-ARRAY: struct-resize-test
+
+[ 40 ] [ 10 <struct-resize-test-array> byte-length ] unit-test
+
+: struct-resize-test-usage ( seq -- seq )
+    [ struct-resize-test <struct> swap >>x ] map
+    >struct-resize-test-array
+    [ x>> ] { } map-as ;
+    
+[ { 10 20 30 } ] [ { 10 20 30 } struct-resize-test-usage ] unit-test
+
+[ ] [ "IN: specialized-arrays.tests USE: classes.struct USE: alien.c-types STRUCT: struct-resize-test { x int } { y int } ;" eval( -- ) ] unit-test
+
+[ 80 ] [ 10 <struct-resize-test-array> byte-length ] unit-test
+
+[ { 10 20 30 } ] [ { 10 20 30 } struct-resize-test-usage ] unit-test
old mode 100755 (executable)
new mode 100644 (file)
index 711354d..eda793f
@@ -2,8 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors alien alien.c-types alien.data alien.parser
 assocs byte-arrays classes compiler.units functors kernel lexer
-libc math math.vectors math.vectors.private
-math.vectors.specialization namespaces
+libc math math.vectors math.vectors.private namespaces
 parser prettyprint.custom sequences sequences.private strings
 summary vocabs vocabs.loader vocabs.parser vocabs.generated
 words fry combinators make ;
@@ -31,7 +30,6 @@ M: bad-byte-array-length summary
 FUNCTOR: define-array ( T -- )
 
 A            DEFINES-CLASS ${T}-array
-S            DEFINES-CLASS ${T}-sequence
 <A>          DEFINES <${A}>
 (A)          DEFINES (${A})
 <direct-A>   DEFINES <direct-${A}>
@@ -47,8 +45,6 @@ SET-NTH      [ T dup c-setter array-accessor ]
 
 WHERE
 
-MIXIN: S
-
 TUPLE: A
 { underlying c-ptr read-only }
 { length array-capacity read-only } ;
@@ -69,8 +65,6 @@ TUPLE: A
     [ drop \ T bad-byte-array-length ] unless
     <direct-A> ; inline
 
-M: A new-underlying drop byte-array>A ;
-
 M: A clone [ underlying>> clone ] [ length>> ] bi <direct-A> ; inline
 
 M: A length length>> ; inline
@@ -96,8 +90,6 @@ M: A resize
 
 M: A byte-length length \ T heap-size * ; inline
 
-M: A element-type drop \ T ; inline
-
 M: A direct-array-syntax drop \ A@ ;
 
 M: A pprint-delims drop \ A{ \ } ;
@@ -109,7 +101,11 @@ SYNTAX: A@ scan-object scan-object <direct-A> suffix! ;
 
 INSTANCE: A specialized-array
 
-A T c-type-boxed-class f specialize-vector-words
+M: A vs+ [ + \ T c-type-clamp ] 2map ; inline
+M: A vs- [ - \ T c-type-clamp ] 2map ; inline
+M: A vs* [ * \ T c-type-clamp ] 2map ; inline
+
+M: A v*high [ * \ T heap-size neg shift ] 2map ; inline
 
 ;FUNCTOR
 
index 75197d9ec0dc012d8177be238d2733b65358af67..f71e308ad148869be5fc238c69367c955f8ad6c8 100644 (file)
@@ -15,7 +15,6 @@ FUNCTOR: define-vector ( T -- )
 V   DEFINES-CLASS ${T}-vector
 
 A   IS      ${T}-array
-S   IS      ${T}-sequence
 <A> IS      <${A}>
 
 >V  DEFERS >${V}
@@ -38,7 +37,6 @@ M: V pprint* pprint-object ;
 SYNTAX: V{ \ } [ >V ] parse-literal ;
 
 INSTANCE: V growable
-INSTANCE: V S
 
 ;FUNCTOR
 
index 3641345a3ebd2bd9179e1224d9e8df1dbf69d146..32bb8b46c6edf5ff46297dc20c70ff820202e2d8 100644 (file)
@@ -26,7 +26,7 @@ PRIVATE>
 : (monotonic-slice) ( seq quot class -- slices )
     [
         dupd '[
-            [ length ] [ ] [ <circular> 1 over change-circular-start ] tri
+            [ length iota ] [ ] [ <circular> 1 over change-circular-start ] tri
             [ @ not [ , ] [ drop ] if ] 3each
         ] { } make
         dup empty? [ over length 1 - prefix ] when -1 prefix 2 clump
index 2a20ba74cd79b0ced07da1cb47eee363cd2bc556..fdfda6dd9e37ba417346be7b3bf6c92b1b36b4c0 100644 (file)
@@ -1,8 +1,9 @@
-! Copyright (C) 2008, 2009 Slava Pestov.
+! Copyright (C) 2008, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel sequences accessors combinators math namespaces
 init sets words assocs alien.libraries alien alien.c-types
-stack-checker.backend stack-checker.errors stack-checker.visitor ;
+cpu.architecture fry stack-checker.backend stack-checker.errors
+stack-checker.visitor ;
 IN: stack-checker.alien
 
 TUPLE: alien-node-params return parameters abi in-d out-d ;
@@ -11,6 +12,8 @@ TUPLE: alien-invoke-params < alien-node-params library function ;
 
 TUPLE: alien-indirect-params < alien-node-params ;
 
+TUPLE: alien-assembly-params < alien-node-params quot ;
+
 TUPLE: alien-callback-params < alien-node-params quot xt ;
 
 : param-prep-quot ( node -- quot )
@@ -49,7 +52,7 @@ TUPLE: alien-callback-params < alien-node-params quot xt ;
     pop-literal nip >>parameters
     pop-literal nip >>return
     ! Quotation which coerces parameters to required types
-    dup param-prep-quot [ dip ] curry infer-quot-here
+    dup param-prep-quot '[ _ dip ] infer-quot-here
     ! Magic #: consume the function pointer, too
     dup 1 alien-stack
     ! Add node to IR
@@ -57,11 +60,28 @@ TUPLE: alien-callback-params < alien-node-params quot xt ;
     ! Quotation which coerces return value to required type
     return-prep-quot infer-quot-here ;
 
-: callback-xt ( word -- alien )
-    callbacks get [ <callback> ] cache ;
+: infer-alien-assembly ( -- )
+    alien-assembly-params new
+    ! Compile-time parameters
+    pop-literal nip >>quot
+    pop-literal nip >>abi
+    pop-literal nip >>parameters
+    pop-literal nip >>return
+    ! Quotation which coerces parameters to required types
+    dup param-prep-quot infer-quot-here
+    ! Magic #: consume exactly the number of inputs
+    dup 0 alien-stack
+    ! Add node to IR
+    dup #alien-assembly,
+    ! Quotation which coerces return value to required type
+    return-prep-quot infer-quot-here ;
+
+: callback-xt ( word return-rewind -- alien )
+    [ callbacks get ] dip '[ _ <callback> ] cache ;
 
 : callback-bottom ( params -- )
-    xt>> [ callback-xt ] curry infer-quot-here ;
+    [ xt>> ] [ callback-return-rewind ] bi
+    '[ _ _ callback-xt ] infer-quot-here ;
 
 : infer-alien-callback ( -- )
     alien-callback-params new
@@ -69,6 +89,6 @@ TUPLE: alien-callback-params < alien-node-params quot xt ;
     pop-literal nip >>abi
     pop-literal nip >>parameters
     pop-literal nip >>return
-    "( callback )" f <word> >>xt
+    "( callback )" <uninterned-word> >>xt
     dup callback-bottom
     #alien-callback, ;
index 48cd10a7ee82243fd140efe8e35dc5efcbbcca30..b58998cb4904208e69b843995f3db6e6c4da02d1 100644 (file)
@@ -1,17 +1,21 @@
 USING: stack-checker.backend tools.test kernel namespaces
-stack-checker.state sequences ;
+stack-checker.state stack-checker.values sequences assocs ;
 IN: stack-checker.backend.tests
 
 [ ] [
     V{ } clone \ meta-d set
     V{ } clone \ meta-r set
     V{ } clone \ literals set
-    0 d-in set
+    H{ } clone known-values set
+    0 input-count set
 ] unit-test
 
 [ 0 ] [ 0 ensure-d length ] unit-test
 
 [ 2 ] [ 2 ensure-d length ] unit-test
+
+[ t ] [ meta-d [ known-values get at input-parameter? ] all? ] unit-test
+
 [ 2 ] [ meta-d length ] unit-test
 
 [ 3 ] [ 3 ensure-d length ] unit-test
old mode 100755 (executable)
new mode 100644 (file)
index 5411c88..b2a99f0
@@ -5,15 +5,19 @@ parser sequences strings vectors words quotations effects classes
 continuations assocs combinators compiler.errors accessors math.order
 definitions sets hints macros stack-checker.state
 stack-checker.visitor stack-checker.errors stack-checker.values
-stack-checker.recursive-state summary ;
+stack-checker.recursive-state stack-checker.dependencies summary ;
 IN: stack-checker.backend
 
 : push-d ( obj -- ) meta-d push ;
 
+: introduce-values ( values -- )
+    [ [ [ input-parameter ] dip set-known ] each ]
+    [ length input-count +@ ]
+    [ #introduce, ]
+    tri ;
+
 : pop-d  ( -- obj )
-    meta-d [
-        <value> dup 1array #introduce, d-in inc
-    ] [ pop ] if-empty ;
+    meta-d [ <value> dup 1array introduce-values ] [ pop ] if-empty ;
 
 : peek-d ( -- obj ) pop-d dup push-d ;
 
@@ -24,7 +28,7 @@ IN: stack-checker.backend
     meta-d 2dup length > [
         2dup
         [ nip >array ] [ length - make-values ] [ nip delete-all ] 2tri
-        [ length d-in +@ ] [ #introduce, ] [ meta-d push-all ] tri
+        [ introduce-values ] [ meta-d push-all ] bi
         meta-d push-all
     ] when swap tail* ;
 
old mode 100755 (executable)
new mode 100644 (file)
index 8b0665a..99e5a70
@@ -11,7 +11,7 @@ IN: stack-checker.branches
 
 SYMBOLS: +bottom+ +top+ ;
 
-: unify-inputs ( max-d-in d-in meta-d -- new-meta-d )
+: unify-inputs ( max-input-count input-count meta-d -- new-meta-d )
     ! Introduced values can be anything, and don't unify with
     ! literals.
     dup [ [ - +top+ <repetition> ] dip append ] [ 3drop f ] if ;
@@ -24,7 +24,7 @@ SYMBOLS: +bottom+ +top+ ;
         '[ _ +bottom+ pad-head ] map
     ] unless ;
 
-: phi-inputs ( max-d-in pairs -- newseq )
+: phi-inputs ( max-input-count pairs -- newseq )
     dup empty? [ nip ] [
         swap '[ [ _ ] dip first2 unify-inputs ] map
         pad-with-bottom
@@ -61,9 +61,9 @@ SYMBOL: quotations
     branch-variable ;
 
 : datastack-phi ( seq -- phi-in phi-out )
-    [ d-in branch-variable ] [ \ meta-d active-variable ] bi
+    [ input-count branch-variable ] [ \ meta-d active-variable ] bi
     unify-branches
-    [ d-in set ] [ ] [ dup >vector \ meta-d set ] tri* ;
+    [ input-count set ] [ ] [ dup >vector \ meta-d set ] tri* ;
 
 : terminated-phi ( seq -- terminated )
     terminated? branch-variable ;
@@ -80,7 +80,7 @@ SYMBOL: quotations
 : copy-inference ( -- )
     \ meta-d [ clone ] change
     literals [ clone ] change
-    d-in [ ] change ;
+    input-count [ ] change ;
 
 GENERIC: infer-branch ( literal -- namespace )
 
diff --git a/basis/stack-checker/dependencies/authors.txt b/basis/stack-checker/dependencies/authors.txt
new file mode 100644 (file)
index 0000000..d4f5d6b
--- /dev/null
@@ -0,0 +1 @@
+Slava Pestov
\ No newline at end of file
diff --git a/basis/stack-checker/dependencies/dependencies-tests.factor b/basis/stack-checker/dependencies/dependencies-tests.factor
new file mode 100644 (file)
index 0000000..9bcec64
--- /dev/null
@@ -0,0 +1,37 @@
+IN: stack-checker.dependencies.tests
+USING: tools.test stack-checker.dependencies words kernel namespaces
+definitions ;
+
+: computing-dependencies ( quot -- dependencies )
+    H{ } clone [ dependencies rot with-variable ] keep ;
+    inline
+
+SYMBOL: a
+SYMBOL: b
+
+[ ] [ a called-dependency depends-on ] unit-test
+
+[ H{ { a called-dependency } } ] [
+    [ a called-dependency depends-on ] computing-dependencies
+] unit-test
+
+[ H{ { a called-dependency } { b inlined-dependency } } ] [
+    [
+        a called-dependency depends-on b inlined-dependency depends-on
+    ] computing-dependencies
+] unit-test
+
+[ H{ { a inlined-dependency } { b inlined-dependency } } ] [
+    [
+        a inlined-dependency depends-on
+        a called-dependency depends-on
+        b inlined-dependency depends-on
+    ] computing-dependencies
+] unit-test
+
+[ flushed-dependency ] [ f flushed-dependency strongest-dependency ] unit-test
+[ flushed-dependency ] [ flushed-dependency f strongest-dependency ] unit-test
+[ inlined-dependency ] [ flushed-dependency inlined-dependency strongest-dependency ] unit-test
+[ inlined-dependency ] [ called-dependency inlined-dependency strongest-dependency ] unit-test
+[ flushed-dependency ] [ called-dependency flushed-dependency strongest-dependency ] unit-test
+[ called-dependency ] [ called-dependency f strongest-dependency ] unit-test
diff --git a/basis/stack-checker/dependencies/dependencies.factor b/basis/stack-checker/dependencies/dependencies.factor
new file mode 100644 (file)
index 0000000..f0c77b8
--- /dev/null
@@ -0,0 +1,37 @@
+! Copyright (C) 2009 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: assocs classes.algebra fry kernel math namespaces
+sequences words ;
+IN: stack-checker.dependencies
+
+! Words that the current quotation depends on
+SYMBOL: dependencies
+
+SYMBOLS: inlined-dependency flushed-dependency called-dependency ;
+
+: index>= ( obj1 obj2 seq -- ? )
+    [ index ] curry bi@ >= ;
+
+: dependency>= ( how1 how2 -- ? )
+    { called-dependency flushed-dependency inlined-dependency }
+    index>= ;
+
+: strongest-dependency ( how1 how2 -- how )
+    [ called-dependency or ] bi@ [ dependency>= ] most ;
+
+: depends-on ( word how -- )
+    over primitive? [ 2drop ] [
+        dependencies get dup [
+            swap '[ _ strongest-dependency ] change-at
+        ] [ 3drop ] if
+    ] if ;
+
+! Generic words that the current quotation depends on
+SYMBOL: generic-dependencies
+
+: ?class-or ( class/f class -- class' )
+    swap [ class-or ] when* ;
+
+: depends-on-generic ( generic class -- )
+    generic-dependencies get dup
+    [ swap '[ _ ?class-or ] change-at ] [ 3drop ] if ;
old mode 100755 (executable)
new mode 100644 (file)
index 5da5197..4b432e7
@@ -12,10 +12,10 @@ HELP: do-not-compile
     }
 } ;
 
-HELP: literal-expected
-{ $error-description "Thrown when inference encounters a combinator or macro being applied to a value which is not known to be a literal, or constructed in a manner which can be analyzed statically. Such code needs changes before it can compile and run. See " { $link "inference-combinators" } " and " { $link "inference-escape" } " for details." }
+HELP: unknown-macro-input
+{ $error-description "Thrown when inference encounters a combinator or macro being applied to an input parameter of a non-" { $link POSTPONE: inline } " word. The word needs to be declared " { $link POSTPONE: inline } " before its callers can compile and run. See " { $link "inference-combinators" } " and " { $link "inference-escape" } " for details." }
 { $examples
-    "In this example, the words being defined cannot be called, because they fail to compile with a " { $link literal-expected } " error:"
+    "In this example, the words being defined cannot be called, because they fail to compile with a " { $link unknown-macro-input } " error:"
     { $code
         ": bad-example ( quot -- )"
         "    [ call ] [ call ] bi ;"
@@ -41,6 +41,27 @@ HELP: literal-expected
     }
 } ;
 
+HELP: bad-macro-input
+{ $error-description "Thrown when inference encounters a combinator or macro being applied to a value which is not known at compile time. Such code needs changes before it can compile and run. See " { $link "inference-combinators" } " and " { $link "inference-escape" } " for details." }
+{ $examples
+    "In this example, the words being defined cannot be called, because they fail to compile with a " { $link bad-macro-input } " error:"
+    { $code
+        ": bad-example ( quot -- )"
+        "    [ . ] append call ; inline"
+        ""
+        ": usage ( -- )"
+        "    2 2 [ + ] bad-example ;"
+    }
+    "One fix is to use " { $link compose } " instead of " { $link append } ":"
+    { $code
+        ": good-example ( quot -- )"
+        "    [ . ] compose call ; inline"
+        ""
+        ": usage ( -- )"
+        "    2 2 [ + ] good-example ;"
+    }
+} ;
+
 HELP: unbalanced-branches-error
 { $values { "in" "a sequence of integers" } { "out" "a sequence of integers" } }
 { $description "Throws an " { $link unbalanced-branches-error } "." }
@@ -121,7 +142,8 @@ ARTICLE: "inference-errors" "Stack checker errors"
 "Errors thrown when insufficient information is available to calculate the stack effect of a call to a combinator or macro (see " { $link "inference-combinators" } "):"
 { $subsections
     do-not-compile
-    literal-expected
+    unknown-macro-input
+    bad-macro-input
 }
 "Error thrown when a word's stack effect declaration does not match the composition of the stack effects of its factors:"
 { $subsections effect-error }
index b1071df7080d16ab8cc4d45d65c6731ff8635257..ff06b2ac2749ca55ee190c2c449a437684372f70 100644 (file)
@@ -1,13 +1,14 @@
 ! Copyright (C) 2006, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel stack-checker.values ;
 IN: stack-checker.errors
 
 TUPLE: inference-error ;
 
 ERROR: do-not-compile < inference-error word ;
 
-ERROR: literal-expected < inference-error what ;
+ERROR: bad-macro-input < inference-error macro ;
+
+ERROR: unknown-macro-input < inference-error macro ;
 
 ERROR: unbalanced-branches-error < inference-error branches quots ;
 
@@ -29,10 +30,6 @@ ERROR: unbalanced-recursion-error < inference-error word height ;
 
 ERROR: inconsistent-recursive-call-error < inference-error word ;
 
-ERROR: unknown-primitive-error < inference-error ;
-
-ERROR: transform-expansion-error < inference-error word error ;
-
-ERROR: bad-declaration-error < inference-error declaration ;
+ERROR: transform-expansion-error < inference-error error continuation word ;
 
-M: object (literal) "literal value" literal-expected ;
\ No newline at end of file
+ERROR: bad-declaration-error < inference-error declaration ;
\ No newline at end of file
index 5be5722c23f675815c25aee32932513fbbce4ebc..f762e0559b11dd5545eb1bcdd5dac55f9a0a2000 100644 (file)
@@ -1,20 +1,21 @@
-! Copyright (C) 2008, 2009 Slava Pestov.
+! Copyright (C) 2008, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors kernel prettyprint io debugger
+USING: accessors arrays kernel prettyprint io debugger
 sequences assocs stack-checker.errors summary effects ;
 IN: stack-checker.errors.prettyprint
 
-M: literal-expected summary
-    what>> "Got a computed value where a " " was expected" surround ;
+M: unknown-macro-input summary
+    macro>> name>> "Cannot apply “" "” to an input parameter of a non-inline word" surround ;
 
-M: literal-expected error. summary print ;
+M: bad-macro-input summary
+    macro>> name>> "Cannot apply “" "” to a run-time computed value" surround ;
 
 M: unbalanced-branches-error summary
     drop "Unbalanced branches" ;
 
 M: unbalanced-branches-error error.
     dup summary print
-    [ quots>> ] [ branches>> [ length <effect> ] { } assoc>map ] bi zip
+    [ quots>> ] [ branches>> [ length [ "x" <array> ] bi@ <effect> ] { } assoc>map ] bi zip
     [ [ first pprint-short bl ] [ second effect>string print ] bi ] each ;
 
 M: too-many->r summary
@@ -49,14 +50,14 @@ M: inconsistent-recursive-call-error summary
     "The recursive word "
     " calls itself with a different set of quotation parameters than were input" surround ;
 
-M: unknown-primitive-error summary
-    word>> name>> "The " " word cannot be called from optimized words" surround ;
-
 M: transform-expansion-error summary
     word>> name>> "Macro expansion of " " threw an error" surround ;
 
 M: transform-expansion-error error.
-    [ summary print ] [ error>> error. ] bi ;
+    [ summary print ]
+    [ nl "The error was:" print error>> error. nl ]
+    [ continuation>> traceback-link. ]
+    tri ;
 
 M: do-not-compile summary
     word>> name>> "Cannot compile call to " prepend ;
\ No newline at end of file
index c99e0f02521032af919b3bd44407c3e9cd222b6e..20d61b9c3769cf829f64d519d88cb7a16fb8a931 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2008 Slava Pestov.
+! Copyright (C) 2008, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: fry namespaces assocs kernel sequences words accessors
 definitions math math.order effects classes arrays combinators
@@ -10,6 +10,7 @@ stack-checker.visitor
 stack-checker.backend
 stack-checker.branches
 stack-checker.known-words
+stack-checker.dependencies
 stack-checker.recursive-state ;
 IN: stack-checker.inlining
 
@@ -28,8 +29,6 @@ fixed-point
 introductions
 loop? ;
 
-M: inline-recursive hashcode* id>> hashcode* ;
-
 : inlined-block? ( word -- ? ) "inlined-block" word-prop ;
 
 : <inline-recursive> ( word -- label )
@@ -43,7 +42,7 @@ M: inline-recursive hashcode* id>> hashcode* ;
 : make-copies ( values effect-in -- values' )
     [ length cut* ] keep
     [ quotation-param? [ copy-value ] [ drop <value> ] if ] 2map
-    [ make-values ] dip append ;
+    [ length make-values ] dip append ;
 
 SYMBOL: enter-in
 SYMBOL: enter-out
@@ -81,7 +80,7 @@ SYMBOL: enter-out
     bi ;
 
 : recursive-word-inputs ( label -- n )
-    entry-stack-height d-in get + ;
+    entry-stack-height input-count get + ;
 
 : (inline-recursive-word) ( word -- label in out visitor terminated? )
     dup prepare-stack
index 2c0ce853aa569a33217b616431f1f6037f290628..9bc61c63536b6b046b1e15dbf376eeb8a0c42327 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2004, 2009 Slava Pestov, Daniel Ehrenberg.
+! Copyright (C) 2004, 2010 Slava Pestov, Daniel Ehrenberg.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: fry accessors alien alien.accessors arrays byte-arrays
 classes continuations.private effects generic hashtables
@@ -21,6 +21,7 @@ stack-checker.visitor
 stack-checker.backend
 stack-checker.branches
 stack-checker.transforms
+stack-checker.dependencies
 stack-checker.recursive-state ;
 IN: stack-checker.known-words
 
@@ -43,7 +44,6 @@ IN: stack-checker.known-words
     { swapd (( x y z -- y x z       )) }
     { nip   (( x y   -- y           )) }
     { 2nip  (( x y z -- z           )) }
-    { tuck  (( x y   -- y x y       )) }
     { over  (( x y   -- x y x       )) }
     { pick  (( x y z -- x y z x     )) }
     { swap  (( x y   -- y x         )) }
@@ -98,8 +98,8 @@ M: composed infer-call*
     1 infer->r infer-call
     terminated? get [ 1 infer-r> infer-call ] unless ;
 
-M: object infer-call*
-    "literal quotation" literal-expected ;
+M: input-parameter infer-call* \ call unknown-macro-input ;
+M: object infer-call* \ call bad-macro-input ;
 
 : infer-ndip ( word n -- )
     [ literals get ] 2dip
@@ -153,7 +153,7 @@ M: bad-executable summary
 
 : infer-<tuple-boa> ( -- )
     \ <tuple-boa>
-    peek-d literal value>> second 1 + { tuple } <effect>
+    peek-d literal value>> second 1 + "obj" <array> { tuple } <effect>
     apply-word/effect ;
 
 \ <tuple-boa> [ infer-<tuple-boa> ] "special" set-word-prop
@@ -221,17 +221,32 @@ M: bad-executable summary
     dup '[ _ infer-call-effect ] "special" set-word-prop
 ] each
 
-\ do-primitive [ unknown-primitive-error ] "special" set-word-prop
-
 \ if [ infer-if ] "special" set-word-prop
 \ dispatch [ infer-dispatch ] "special" set-word-prop
 
 \ alien-invoke [ infer-alien-invoke ] "special" set-word-prop
 \ alien-indirect [ infer-alien-indirect ] "special" set-word-prop
+\ alien-assembly [ infer-alien-assembly ] "special" set-word-prop
 \ alien-callback [ infer-alien-callback ] "special" set-word-prop
 
+{
+    do-primitive
+    mega-cache-miss
+    mega-cache-lookup
+    inline-cache-miss
+    inline-cache-miss-tail
+    unwind-native-frames
+    set-datastack
+    set-callstack
+    set-retainstack
+    unwind-native-frames
+    lazy-jit-compile
+    c-to-factor
+    call-clear
+} [ dup '[ _ do-not-compile ] "special" set-word-prop ] each
+
 : infer-special ( word -- )
-    "special" word-prop call( -- ) ;
+    [ current-word set ] [ "special" word-prop call( -- ) ] bi ;
 
 : infer-local-reader ( word -- )
     (( -- value )) apply-word/effect ;
@@ -485,13 +500,13 @@ M: bad-executable summary
 \ (word) { object object object } { word } define-primitive
 \ (word) make-flushable
 
-\ word-xt { word } { integer integer } define-primitive
-\ word-xt make-flushable
+\ word-code { word } { integer integer } define-primitive
+\ word-code make-flushable
 
-\ getenv { fixnum } { object } define-primitive
-\ getenv make-flushable
+\ special-object { fixnum } { object } define-primitive
+\ special-object make-flushable
 
-\ setenv { object fixnum } { } define-primitive
+\ set-special-object { object fixnum } { } define-primitive
 
 \ (exists?) { string } { object } define-primitive
 
@@ -511,8 +526,11 @@ M: bad-executable summary
 \ code-room { } { byte-array } define-primitive
 \ code-room  make-flushable
 
-\ micros { } { integer } define-primitive
-\ micros make-flushable
+\ system-micros { } { integer } define-primitive
+\ system-micros make-flushable
+
+\ nano-count { } { integer } define-primitive
+\ nano-count make-flushable
 
 \ tag { object } { fixnum } define-primitive
 \ tag make-foldable
@@ -623,11 +641,7 @@ M: bad-executable summary
 \ <array> { integer object } { array } define-primitive
 \ <array> make-flushable
 
-\ begin-scan { } { } define-primitive
-
-\ next-object { } { object } define-primitive
-
-\ end-scan { } { } define-primitive
+\ all-instances { } { array } define-primitive
 
 \ size { object } { fixnum } define-primitive
 \ size make-flushable
@@ -648,6 +662,8 @@ M: bad-executable summary
 
 \ fseek { alien integer integer } { } define-primitive
 
+\ ftell { alien } { integer } define-primitive
+
 \ fclose { alien } { } define-primitive
 
 \ <wrapper> { object } { wrapper } define-primitive
@@ -662,8 +678,8 @@ M: bad-executable summary
 \ array>quotation { array } { quotation } define-primitive
 \ array>quotation make-flushable
 
-\ quotation-xt { quotation } { integer } define-primitive
-\ quotation-xt make-flushable
+\ quotation-code { quotation } { integer integer } define-primitive
+\ quotation-code make-flushable
 
 \ <tuple> { tuple-layout } { tuple } define-primitive
 \ <tuple> make-flushable
@@ -704,15 +720,23 @@ M: bad-executable summary
 \ lookup-method { object array } { word } define-primitive
 
 \ reset-dispatch-stats { } { } define-primitive
-\ dispatch-stats { } { array } define-primitive
+\ dispatch-stats { } { byte-array } define-primitive
 
 \ optimized? { word } { object } define-primitive
 
 \ strip-stack-traces { } { } define-primitive
 
-\ <callback> { word } { alien } define-primitive
+\ <callback> { integer word } { alien } define-primitive
 
 \ enable-gc-events { } { } define-primitive
 \ disable-gc-events { } { object } define-primitive
 
 \ profiling { object } { } define-primitive
+
+\ (identity-hashcode) { object } { fixnum } define-primitive
+
+\ compute-identity-hashcode { object } { } define-primitive
+
+\ (exit) { integer } { } define-primitive
+
+\ quot-compiled? { quotation } { object } define-primitive
index c806f98e2ed1ae7688fb94ef72a3419fc17f7f1c..eb25b9be57d883173b4d49d77136011c64f4835a 100644 (file)
@@ -11,14 +11,14 @@ IN: stack-checker
 ARTICLE: "inference-simple" "Straight-line stack effects"
 "The simplest case is when a piece of code does not have any branches or recursion, and just pushes literals and calls words."
 $nl
-"Pushing a literal has stack effect " { $snippet "( -- object )" } ". The stack effect of a most words is always known statically from the declaration. Stack effects of " { $link POSTPONE: inline } " words and " { $link "macros" } ", may depend on literals pushed on the stack prior to the call, and this case is discussed in " { $link "inference-combinators" } "."
+"Pushing a literal has stack effect " { $snippet "( -- x )" } ". The stack effect of a most words is always known statically from the declaration. Stack effects of " { $link POSTPONE: inline } " words and " { $link "macros" } ", may depend on literals pushed on the stack prior to the call, and this case is discussed in " { $link "inference-combinators" } "."
 $nl
 "The stack effect of each element in a code snippet is composed. The result is then the stack effect of the snippet."
 $nl
 "An example:"
-{ $example "[ 1 2 3 ] infer." "( -- object object object )" }
+{ $example "[ 1 2 3 ] infer." "( -- x x x )" }
 "Another example:"
-{ $example "[ 2 + ] infer." "( object -- object )" } ;
+{ $example "[ 2 + ] infer." "( x -- x )" } ;
 
 ARTICLE: "inference-combinators" "Combinator stack effects"
 "If a word calls a combinator, one of the following two conditions must hold for the stack checker to succeed:"
@@ -26,19 +26,19 @@ ARTICLE: "inference-combinators" "Combinator stack effects"
   { "The combinator must be called with a quotation that is either literal or built from literal quotations, " { $link curry } ", and " { $link compose } ". (Note that quotations that use " { $vocab-link "fry" } " or " { $vocab-link "locals" } " use " { $link curry } " and " { $link compose } " from the perspective of the stack checker.)" }
   { "If the word is declared " { $link POSTPONE: inline } ", the combinator may additionally be called on one of the word's input parameters or with quotations built from the word's input parameters, literal quotations, " { $link curry } ", and " { $link compose } ". When inline, a word is itself considered to be a combinator, and its callers must in turn satisfy these conditions." }
 }
-"If neither condition holds, the stack checker throws a " { $link literal-expected } " error. To make the code compile, a runtime checking combinator such as " { $link POSTPONE: call( } " must be used instead. See " { $link "inference-escape" } " for details. An inline combinator can be called with an unknown quotation by " { $link curry } "ing the quotation onto a literal quotation that uses " { $link POSTPONE: call( } "."
+"If neither condition holds, the stack checker throws a " { $link unknown-macro-input } " or " { $link bad-macro-input } " error. To make the code compile, a runtime checking combinator such as " { $link POSTPONE: call( } " must be used instead. See " { $link "inference-escape" } " for details. An inline combinator can be called with an unknown quotation by " { $link curry } "ing the quotation onto a literal quotation that uses " { $link POSTPONE: call( } "."
 { $heading "Examples" }
 { $subheading "Calling a combinator" }
 "The following usage of " { $link map } " passes the stack checker, because the quotation is the result of " { $link curry } ":"
-{ $example "USING: math sequences ;" "[ [ + ] curry map ] infer." "( object object -- object )" }
+{ $example "USING: math sequences ;" "[ [ + ] curry map ] infer." "( x x -- x )" }
 "The equivalent code using " { $vocab-link "fry" } " and " { $vocab-link "locals" } " likewise passes the stack checker:"
-{ $example "USING: fry math sequences ;" "[ '[ _ + ] map ] infer." "( object object -- object )" }
-{ $example "USING: locals math sequences ;" "[| a | [ a + ] map ] infer." "( object object -- object )" }
+{ $example "USING: fry math sequences ;" "[ '[ _ + ] map ] infer." "( x x -- x )" }
+{ $example "USING: locals math sequences ;" "[| a | [ a + ] map ] infer." "( x x -- x )" }
 { $subheading "Defining an inline combinator" }
 "The following word calls a quotation twice; the word is declared " { $link POSTPONE: inline } ", since it invokes " { $link call } " on the result of " { $link compose } " on an input parameter:"
 { $code ": twice ( value quot -- result ) dup compose call ; inline" }
 "The following code now passes the stack checker; it would fail were " { $snippet "twice" } " not declared " { $link POSTPONE: inline } ":"
-{ $unchecked-example "USE: math.functions" "[ [ sqrt ] twice ] infer." "( object -- object )" }
+{ $unchecked-example "USE: math.functions" "[ [ sqrt ] twice ] infer." "( x -- x )" }
 { $subheading "Defining a combinator for unknown quotations" }
 "In the next example, " { $link POSTPONE: call( } " must be used because the quotation the result of calling a runtime accessor, and the compiler cannot make any static assumptions about this quotation at all:"
 { $code
@@ -51,24 +51,24 @@ ARTICLE: "inference-combinators" "Combinator stack effects"
 "However this fails to pass the stack checker since there is no guarantee the quotation has the right stack effect for " { $link map } ". It can be wrapped in a new quotation with a declaration:"
 { $code ": perform ( values action -- results )" "    quot>> [ call( value -- result ) ] curry map ;" }
 { $heading "Explanation" }
-"This restriction exists because without further information, one cannot say what the stack effect of " { $link call } " is; it depends on the given quotation. If the stack checker encounters a " { $link call } " without further information, a " { $link literal-expected } " error is raised."
+"This restriction exists because without further information, one cannot say what the stack effect of " { $link call } " is; it depends on the given quotation. If the stack checker encounters a " { $link call } " without further information, a " { $link unknown-macro-input } " or " { $link bad-macro-input } " error is raised."
 $nl
 "On the other hand, the stack effect of applying " { $link call } " to a literal quotation or a " { $link curry } " of a literal quotation is easy to compute; it behaves as if the quotation was substituted at that point."
 { $heading "Limitations" }
 "The stack checker cannot guarantee that a literal quotation is still literal if it is passed on the data stack to an inlined recursive combinator such as " { $link each } " or " { $link map } ". For example, the following will not infer:"
 { $example
-  "[ [ reverse ] swap [ reverse ] map swap call ] infer." "Got a computed value where a literal quotation was expected"
+  "[ [ reverse ] swap [ reverse ] map swap call ] infer." "Cannot apply “call” to a run-time computed value\nmacro call"
 }
 "To make this work, use " { $link dip } " to pass the quotation instead:"
 { $example
-  "[ [ reverse ] [ [ reverse ] map ] dip call ] infer." "( object -- object )"
+  "[ [ reverse ] [ [ reverse ] map ] dip call ] infer." "( x -- x )"
 } ;
 
 ARTICLE: "inference-branches" "Branch stack effects"
 "Conditionals such as " { $link if } " and combinators built on top have the same restrictions as " { $link POSTPONE: inline } " combinators (see " { $link "inference-combinators" } ") with the additional requirement that all branches leave the stack at the same height. If this is not the case, the stack checker throws a " { $link unbalanced-branches-error } "."
 $nl
 "If all branches leave the stack at the same height, then the stack effect of the conditional is just the maximum of the stack effect of each branch. For example,"
-{ $example "[ [ + ] [ drop ] if ] infer." "( object object object -- object )" }
+{ $example "[ [ + ] [ drop ] if ] infer." "( x x x -- x )" }
 "The call to " { $link if } " takes one value from the stack, a generalized boolean. The first branch " { $snippet "[ + ]" } " has stack effect " { $snippet "( x x -- x )" } " and the second has stack effect " { $snippet "( x -- )" } ". Since both branches decrease the height of the stack by one, we say that the stack effect of the two branches is " { $snippet "( x x -- x )" } ", and together with the boolean popped off the stack by " { $link if } ", this gives a total stack effect of " { $snippet "( x x x -- x )" } "." ;
 
 ARTICLE: "inference-recursive-combinators" "Recursive combinator stack effects"
@@ -77,7 +77,7 @@ $nl
 "Combinators which are recursive require additional care. In addition to being declared " { $link POSTPONE: inline } ", they must be declared " { $link POSTPONE: recursive } ". There are three restrictions that only apply to combinators with this declaration:"
 { $heading "Input quotation declaration" }
 "Input parameters which are quotations must be annotated as much in the stack effect. For example, the following will not infer:"
-{ $example ": bad ( quot -- ) [ call ] keep bad ; inline recursive" "[ [ ] bad ] infer." "Got a computed value where a literal quotation was expected" }
+{ $unchecked-example ": bad ( quot -- ) [ call ] keep bad ; inline recursive" "[ [ ] bad ] infer." "Cannot apply “call” to a run-time computed value\nmacro call" }
 "The following is correct:"
 { $example ": good ( quot: ( -- ) -- ) [ call ] keep good ; inline recursive" "[ [ ] good ] infer." "( -- )" }
 "The effect of the nested quotation itself is only present for documentation purposes; the mere presence of a nested effect is sufficient to mark that value as a quotation parameter."
@@ -85,9 +85,9 @@ $nl
 "The stack checker does not trace data flow in two instances."
 $nl
 "An inline recursive word cannot pass a quotation on the data stack through the recursive call. For example, the following will not infer:"
-{ $example ": bad ( ? quot: ( ? -- ) -- ) 2dup [ not ] dip bad call ; inline recursive" "[ [ drop ] bad ] infer." "Got a computed value where a literal quotation was expected" }
+{ $unchecked-example ": bad ( ? quot: ( ? -- ) -- ) 2dup [ not ] dip bad call ; inline recursive" "[ [ drop ] bad ] infer." "Cannot apply “call” to a run-time computed value\nmacro call" }
 "However a small change can be made:"
-{ $example ": good ( ? quot: ( ? -- ) -- ) [ good ] 2keep [ not ] dip call ; inline recursive" "[ [ drop ] good ] infer." "( object -- )" }
+{ $example ": good ( ? quot: ( ? -- ) -- ) [ good ] 2keep [ not ] dip call ; inline recursive" "[ [ drop ] good ] infer." "( x -- )" }
 "An inline recursive word must have a fixed stack effect in its base case. The following will not infer:"
 { $code
     ": foo ( quot ? -- ) [ f foo ] [ call ] if ; inline"
index 414bcaaffe95389c9f9b2ceffdd0bb138905e186..270e5695b33bcae60dbf4c7202594b05c3487693 100644 (file)
@@ -7,7 +7,7 @@ sorting assocs definitions prettyprint io inspector
 classes.tuple classes.union classes.predicate debugger
 threads.private io.streams.string io.timeouts io.thread
 sequences.private destructors combinators eval locals.backend
-system compiler.units shuffle ;
+system compiler.units shuffle vocabs ;
 IN: stack-checker.tests
 
 [ 1234 infer ] must-fail
@@ -16,14 +16,18 @@ IN: stack-checker.tests
 { 1 2 } [ dup ] must-infer-as
 
 { 1 2 } [ [ dup ] call ] must-infer-as
-[ [ call ] infer ] must-fail
+[ [ call ] infer ] [ T{ unknown-macro-input f call } = ] must-fail-with
+[ [ curry call ] infer ] [ T{ unknown-macro-input f call } = ] must-fail-with
+[ [ { } >quotation call ] infer ] [ T{ bad-macro-input f call } = ] must-fail-with
+[ [ append curry call ] infer ] [ T{ bad-macro-input f call } = ] must-fail-with
 
 { 2 4 } [ 2dup ] must-infer-as
 
 { 1 0 } [ [ ] [ ] if ] must-infer-as
-[ [ if ] infer ] must-fail
-[ [ [ ] if ] infer ] must-fail
-[ [ [ 2 ] [ ] if ] infer ] must-fail
+[ [ if ] infer ] [ T{ unknown-macro-input f if } = ] must-fail-with
+[ [ { } >quotation { } >quotation if ] infer ] [ T{ bad-macro-input f if } = ] must-fail-with
+[ [ [ ] if ] infer ] [ T{ unknown-macro-input f if } = ] must-fail-with
+[ [ [ 2 ] [ ] if ] infer ] [ unbalanced-branches-error? ] must-fail-with
 { 4 3 } [ [ rot ] [ -rot ] if ] must-infer-as
 
 { 4 3 } [
@@ -46,7 +50,7 @@ IN: stack-checker.tests
 
 [
     [ [ [ 2 2 fixnum+ ] ] [ [ 2 2 fixnum* ] ] if call ] infer
-] must-fail
+] [ T{ bad-macro-input f call } = ] must-fail-with
 
 ! Test inference of termination of control flow
 : termination-test-1 ( -- * ) "foo" throw ;
@@ -198,42 +202,42 @@ DEFER: blah4
 
 ! This used to hang
 [ [ [ dup call ] dup call ] infer ]
-[ inference-error? ] must-fail-with
+[ recursive-quotation-error? ] must-fail-with
 
 : m ( q -- ) dup call ; inline
 
-[ [ [ m ] m ] infer ] [ inference-error? ] must-fail-with
+[ [ [ m ] m ] infer ] [ recursive-quotation-error? ] must-fail-with
 
 : m' ( quot -- ) dup curry call ; inline
 
-[ [ [ m' ] m' ] infer ] [ inference-error? ] must-fail-with
+[ [ [ m' ] m' ] infer ] [ recursive-quotation-error? ] must-fail-with
 
 : m'' ( -- q ) [ dup curry ] ; inline
 
 : m''' ( -- ) m'' call call ; inline
 
-[ [ [ m''' ] m''' ] infer ] [ inference-error? ] must-fail-with
+[ [ [ m''' ] m''' ] infer ] [ recursive-quotation-error? ] must-fail-with
 
-: m-if ( a b c -- ) t over if ; inline
+: m-if ( a b c -- ) t over when ; inline
 
-[ [ [ m-if ] m-if ] infer ] [ inference-error? ] must-fail-with
+[ [ [ m-if ] m-if ] infer ] [ recursive-quotation-error? ] must-fail-with
 
 ! This doesn't hang but it's also an example of the
 ! undedicable case
 [ [ [ [ drop 3 ] swap call ] dup call ] infer ]
-[ inference-error? ] must-fail-with
+[ recursive-quotation-error? ] must-fail-with
 
-[ [ 1 drop-locals ] infer ] [ inference-error? ] must-fail-with
+[ [ 1 drop-locals ] infer ] [ too-many-r>? ] must-fail-with
 
 ! Regression
-[ [ cleave ] infer ] [ inference-error? ] must-fail-with
+[ [ cleave ] infer ] [ T{ unknown-macro-input f cleave } = ] must-fail-with
 
 ! Test some curry stuff
 { 1 1 } [ 3 [ ] curry 4 [ ] curry if ] must-infer-as
 
 { 2 1 } [ [ ] curry 4 [ ] curry if ] must-infer-as
 
-[ [ 3 [ ] curry 1 2 [ ] 2curry if ] infer ] must-fail
+[ [ 3 [ ] curry 1 2 [ ] 2curry if ] infer ] [ unbalanced-branches-error? ] must-fail-with
 
 { 1 3 } [ [ 2drop f ] assoc-find ] must-infer-as
 
@@ -285,26 +289,26 @@ DEFER: an-inline-word
 
 ERROR: custom-error ;
 
-[ T{ effect f 0 0 t } ] [
+[ T{ effect f { } { } t } ] [
     [ custom-error ] infer
 ] unit-test
 
 : funny-throw ( a -- * ) throw ; inline
 
-[ T{ effect f 0 0 t } ] [
+[ T{ effect f { } { } t } ] [
     [ 3 funny-throw ] infer
 ] unit-test
 
-[ T{ effect f 0 0 t } ] [
+[ T{ effect f { } { } t } ] [
     [ custom-error inference-error ] infer
 ] unit-test
 
-[ T{ effect f 1 2 t } ] [
+[ T{ effect f { "x" } { "x" "x" } t } ] [
     [ dup [ 3 throw ] dip ] infer
 ] unit-test
 
 ! Regression
-[ [ 1 load-locals ] infer ] must-fail
+[ [ 1 load-locals ] infer ] [ too-many->r? ] must-fail-with
 
 ! Corner case
 [ [ [ f dup ] [ dup ] produce ] infer ] must-fail
@@ -319,7 +323,7 @@ FORGET: erg's-inference-bug
 [ [ bad-recursion-3 ] infer ] must-fail
 FORGET: bad-recursion-3
 
-: bad-recursion-4 ( -- ) 4 [ dup call roll ] times ; inline recursive
+: bad-recursion-4 ( -- ) 4 [ dup call [ rot ] dip swap ] times ; inline recursive
 [ [ [ ] [ 1 2 3 ] over dup bad-recursion-4 ] infer ] must-fail
 
 : bad-recursion-5 ( obj quot: ( -- ) -- ) dup call swap bad-recursion-5 ; inline recursive
@@ -329,6 +333,8 @@ FORGET: bad-recursion-3
     dup bad-recursion-6 call ; inline recursive
 [ [ [ drop f ] bad-recursion-6 ] infer ] must-fail
 
+[ ] [ [ \ bad-recursion-6 forget ] with-compilation-unit ] unit-test
+
 { 3 0 } [ [ 2drop "A" throw ] [ ] if 2drop ] must-infer-as
 { 2 0 } [ drop f f [ 2drop "A" throw ] [ ] if 2drop ] must-infer-as
 
@@ -346,6 +352,9 @@ DEFER: eee'
 
 [ [ eee' ] infer ] [ inference-error? ] must-fail-with
 
+[ ] [ [ \ ddd' forget ] with-compilation-unit ] unit-test
+[ ] [ [ \ eee' forget ] with-compilation-unit ] unit-test
+
 : bogus-error ( x -- )
     dup "A" throw [ bogus-error ] [ drop ] if ; inline recursive
 
@@ -367,9 +376,9 @@ DEFER: eee'
 [ ] [ [ \ forget-test forget ] with-compilation-unit ] unit-test
 [ forget-test ] must-infer
 
-[ [ cond ] infer ] must-fail
-[ [ bi ] infer ] must-fail
-[ at ] must-infer
+[ [ cond ] infer ] [ T{ unknown-macro-input f cond } = ] must-fail-with
+[ [ bi ] infer ] [ T{ unknown-macro-input f call } = ] must-fail-with
+[ [ each ] infer ] [ T{ unknown-macro-input f call } = ] must-fail-with
 
 [ [ [ "OOPS" throw ] dip ] [ drop ] if ] must-infer
 
@@ -380,5 +389,16 @@ DEFER: eee'
 { 3 1 } [ call( a b -- c ) ] must-infer-as
 { 3 1 } [ execute( a b -- c ) ] must-infer-as
 
-[ [ call-effect ] infer ] must-fail
-[ [ execute-effect ] infer ] must-fail
+[ [ call-effect ] infer ] [ T{ unknown-macro-input f call-effect } = ] must-fail-with
+[ [ execute-effect ] infer ] [ T{ unknown-macro-input f execute-effect } = ] must-fail-with
+
+[ \ set-datastack def>> infer ] [ T{ do-not-compile f do-primitive } = ] must-fail-with
+[ ] [ [ \ set-datastack def>> infer ] try ] unit-test
+
+! Make sure all primitives are covered
+[ { } ] [
+    all-words [ primitive? ] filter
+    [ "default-output-classes" word-prop not ] filter
+    [ "special" word-prop not ] filter
+    [ "shuffle" word-prop not ] filter
+] unit-test
index fe52357f9ef95d7e9654bd7c796daeb50a61bbc7..12e86609004c992de19e056ff95352967b4d18df 100644 (file)
@@ -1,7 +1,8 @@
-! Copyright (C) 2004, 2009 Slava Pestov.
+! Copyright (C) 2004, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel io effects namespaces sequences quotations vocabs
-vocabs.loader generic words stack-checker.backend stack-checker.state
+USING: accessors kernel io effects namespaces sequences
+quotations vocabs vocabs.loader generic words
+stack-checker.backend stack-checker.state
 stack-checker.known-words stack-checker.transforms
 stack-checker.errors stack-checker.inlining
 stack-checker.visitor.dummy ;
@@ -15,3 +16,7 @@ M: callable infer ( quot -- effect )
 : infer. ( quot -- )
     #! Safe to call from inference transforms.
     infer effect>string print ;
+
+: inputs ( quot -- n ) infer in>> length ;
+
+: outputs ( quot -- n ) infer out>> length ;
diff --git a/basis/stack-checker/state/state-tests.factor b/basis/stack-checker/state/state-tests.factor
deleted file mode 100644 (file)
index a4dea99..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-IN: stack-checker.state.tests
-USING: tools.test stack-checker.state words kernel namespaces
-definitions ;
-
-: computing-dependencies ( quot -- dependencies )
-    H{ } clone [ dependencies rot with-variable ] keep ;
-    inline
-
-SYMBOL: a
-SYMBOL: b
-
-[ ] [ a called-dependency depends-on ] unit-test
-
-[ H{ { a called-dependency } } ] [
-    [ a called-dependency depends-on ] computing-dependencies
-] unit-test
-
-[ H{ { a called-dependency } { b inlined-dependency } } ] [
-    [
-        a called-dependency depends-on b inlined-dependency depends-on
-    ] computing-dependencies
-] unit-test
-
-[ H{ { a inlined-dependency } { b inlined-dependency } } ] [
-    [
-        a inlined-dependency depends-on
-        a called-dependency depends-on
-        b inlined-dependency depends-on
-    ] computing-dependencies
-] unit-test
index a76d302a7ea469f628c18fff73d24cc712e162a7..f0b595ebe5c2ebfa4f54be0a36f65fa7312ad223 100644 (file)
@@ -1,15 +1,16 @@
-! Copyright (C) 2008 Slava Pestov.
+! Copyright (C) 2008, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: assocs arrays namespaces sequences kernel definitions
 math effects accessors words fry classes.algebra
-compiler.units stack-checker.values stack-checker.visitor ;
+compiler.units stack-checker.values stack-checker.visitor
+stack-checker.errors ;
 IN: stack-checker.state
 
 ! Did the current control-flow path throw an error?
 SYMBOL: terminated?
 
 ! Number of inputs current word expects from the stack
-SYMBOL: d-in
+SYMBOL: input-count
 
 DEFER: commit-literals
 
@@ -34,33 +35,15 @@ SYMBOL: literals
         [ [ (push-literal) ] each ] [ delete-all ] bi
     ] unless-empty ;
 
-: current-stack-height ( -- n ) meta-d length d-in get - ;
+: current-stack-height ( -- n ) meta-d length input-count get - ;
 
 : current-effect ( -- effect )
-    d-in get meta-d length terminated? get effect boa ;
+    input-count get "x" <array>
+    meta-d length "x" <array>
+    terminated? get effect boa ;
 
 : init-inference ( -- )
     terminated? off
     V{ } clone \ meta-d set
     V{ } clone literals set
-    0 d-in set ;
-
-! Words that the current quotation depends on
-SYMBOL: dependencies
-
-: depends-on ( word how -- )
-    over primitive? [ 2drop ] [
-        dependencies get dup [
-            swap '[ _ strongest-dependency ] change-at
-        ] [ 3drop ] if
-    ] if ;
-
-! Generic words that the current quotation depends on
-SYMBOL: generic-dependencies
-
-: ?class-or ( class/f class -- class' )
-    swap [ class-or ] when* ;
-
-: depends-on-generic ( generic class -- )
-    generic-dependencies get dup
-    [ swap '[ _ ?class-or ] change-at ] [ 3drop ] if ;
+    0 input-count set ;
index 843083bd52b3c7735abc62cde31eef2c0094ff3c..bbe3cb2ed9a8959072060da2aa886d479846adfe 100644 (file)
@@ -1,15 +1,9 @@
 IN: stack-checker.transforms.tests
 USING: sequences stack-checker.transforms tools.test math kernel
-quotations stack-checker stack-checker.errors accessors combinators words arrays
-classes classes.tuple ;
+quotations stack-checker stack-checker.errors accessors
+combinators words arrays classes classes.tuple macros ;
 
-: compose-n ( quot n -- ) "OOPS" throw ;
-
-<<
-: compose-n-quot ( n word -- quot' ) <repetition> >quotation ;
-\ compose-n [ compose-n-quot ] 2 define-transform
-\ compose-n t "no-compile" set-word-prop
->>
+MACRO: compose-n ( n word -- quot' ) <repetition> >quotation ;
 
 : compose-n-test ( a b c -- x ) 2 \ + compose-n ;
 
@@ -64,14 +58,16 @@ DEFER: smart-combo ( quot -- )
 [ [ [ "a" "b" ] very-smart-combo "c" ] very-smart-combo ] must-infer
 
 ! Caveat found by Doug
-DEFER: curry-folding-test ( quot -- )
-
-\ curry-folding-test [ length \ drop <repetition> >quotation ] 1 define-transform
+MACRO: curry-folding-test ( quot -- )
+    length \ drop <repetition> >quotation ;
 
 { 3 0 } [ [ 1 2 3 ] curry-folding-test ] must-infer-as
 { 3 0 } [ 1 [ 2 3 ] curry curry-folding-test ] must-infer-as
 { 3 0 } [ [ 1 2 ] 3 [ ] curry compose curry-folding-test ] must-infer-as
 
+[ [ curry curry-folding-test ] infer ]
+[ T{ unknown-macro-input f curry-folding-test } = ] must-fail-with
+
 : member?-test ( a -- ? ) { 1 2 3 10 7 58 } member? ;
 
 [ f ] [ 1.0 member?-test ] unit-test
@@ -82,4 +78,8 @@ DEFER: curry-folding-test ( quot -- )
 
 \ bad-macro [ "OOPS" throw ] 0 define-transform
 
-[ [ bad-macro ] infer ] [ inference-error? ] must-fail-with
\ No newline at end of file
+[ [ bad-macro ] infer ] [ f >>continuation T{ transform-expansion-error f "OOPS" f bad-macro } = ] must-fail-with
+
+MACRO: two-params ( a b -- c ) + 1quotation ;
+
+[ [ 3 two-params ] infer ] [ T{ unknown-macro-input f two-params } = ] must-fail-with
\ No newline at end of file
old mode 100755 (executable)
new mode 100644 (file)
index 11534c5..3fdf29b
@@ -7,40 +7,49 @@ classes.tuple.private effects summary hashtables classes sets
 definitions generic.standard slots.private continuations locals
 sequences.private generalizations stack-checker.backend
 stack-checker.state stack-checker.visitor stack-checker.errors
-stack-checker.values stack-checker.recursive-state ;
+stack-checker.values stack-checker.recursive-state
+stack-checker.dependencies ;
 IN: stack-checker.transforms
 
-: call-transformer ( word stack quot -- newquot )
-    '[ _ _ with-datastack [ length 1 assert= ] [ first ] bi nip ]
-    [ transform-expansion-error ]
+: call-transformer ( stack quot -- newquot )
+    '[ _ _ with-datastack [ length 1 assert= ] [ first ] bi ]
+    [ error-continuation get current-word get transform-expansion-error ]
     recover ;
 
-:: ((apply-transform)) ( word quot values stack rstate -- )
-    rstate recursive-state
-    [ word stack quot call-transformer ] with-variable
-    [
-        values [ length meta-d shorten-by ] [ #drop, ] bi
-        rstate infer-quot
-    ] [ word infer-word ] if* ;
-
-: literals? ( values -- ? ) [ literal-value? ] all? ;
-
-: (apply-transform) ( word quot n -- )
-    ensure-d dup literals? [
-        dup empty? [ dup recursive-state get ] [
-            [ ]
-            [ [ literal value>> ] map ]
-            [ first literal recursion>> ] tri
-        ] if
-        ((apply-transform))
-    ] [ 2drop infer-word ] if ;
+:: ((apply-transform)) ( quot values stack rstate -- )
+    rstate recursive-state [ stack quot call-transformer ] with-variable
+    values [ length meta-d shorten-by ] [ #drop, ] bi
+    rstate infer-quot ;
+
+: literal-values? ( values -- ? ) [ literal-value? ] all? ;
+
+: input-values? ( values -- ? )
+    [ { [ literal-value? ] [ input-value? ] } 1|| ] all? ;
+
+: (apply-transform) ( quot n -- )
+    ensure-d {
+        { [ dup literal-values? ] [
+            dup empty? [ dup recursive-state get ] [
+                [ ]
+                [ [ literal value>> ] map ]
+                [ first literal recursion>> ] tri
+            ] if
+            ((apply-transform))
+        ] }
+        { [ dup input-values? ] [ drop current-word get unknown-macro-input ] }
+        [ drop current-word get bad-macro-input ]
+    } cond ;
 
 : apply-transform ( word -- )
-    [ ] [ "transform-quot" word-prop ] [ "transform-n" word-prop ] tri
+    [ current-word set ]
+    [ "transform-quot" word-prop ]
+    [ "transform-n" word-prop ] tri
     (apply-transform) ;
 
 : apply-macro ( word -- )
-    [ ] [ "macro" word-prop ] [ "declared-effect" word-prop in>> length ] tri
+    [ current-word set ]
+    [ "macro" word-prop ]
+    [ "declared-effect" word-prop in>> length ] tri
     (apply-transform) ;
 
 : define-transform ( word quot n -- )
index 19db441381d021f51ce2db78b63ee6d26af184d4..7e11ec3edb57a85f51f73e1219e2d5299bdc0eea 100644 (file)
@@ -1,7 +1,7 @@
-! Copyright (C) 2008 Slava Pestov.
+! Copyright (C) 2008, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors namespaces kernel assocs sequences
-stack-checker.recursive-state ;
+stack-checker.recursive-state stack-checker.errors ;
 IN: stack-checker.values
 
 ! Values
@@ -28,21 +28,25 @@ SYMBOL: known-values
 
 GENERIC: (literal-value?) ( value -- ? )
 
-M: object (literal-value?) drop f ;
+: literal-value? ( value -- ? ) known (literal-value?) ;
+
+GENERIC: (input-value?) ( value -- ? )
+
+: input-value? ( value -- ? ) known (input-value?) ;
 
-GENERIC: (literal) ( value -- literal )
+GENERIC: (literal) ( known -- literal )
 
 ! Literal value
-TUPLE: literal < identity-tuple value recursion hashcode ;
+TUPLE: literal < identity-tuple value recursion ;
 
 : literal ( value -- literal ) known (literal) ;
 
-: literal-value? ( value -- ? ) known (literal-value?) ;
-
-M: literal hashcode* nip hashcode>> ;
+M: literal hashcode* nip value>> identity-hashcode ;
 
 : <literal> ( obj -- value )
-    recursive-state get over hashcode \ literal boa ;
+    recursive-state get \ literal boa ;
+
+M: literal (input-value?) drop f ;
 
 M: literal (literal-value?) drop t ;
 
@@ -51,7 +55,7 @@ M: literal (literal) ;
 : curried/composed-literal ( input1 input2 quot -- literal )
     [ [ literal ] bi@ ] dip
     [ [ [ value>> ] bi@ ] dip call ] [ drop nip recursion>> ] 3bi
-    over hashcode \ literal boa ; inline
+    \ literal boa ; inline
 
 ! Result of curry
 TUPLE: curried obj quot ;
@@ -61,7 +65,10 @@ C: <curried> curried
 : >curried< ( curried -- obj quot )
     [ obj>> ] [ quot>> ] bi ; inline
 
+M: curried (input-value?) >curried< [ input-value? ] either? ;
+
 M: curried (literal-value?) >curried< [ literal-value? ] both? ;
+
 M: curried (literal) >curried< [ curry ] curried/composed-literal ;
 
 ! Result of compose
@@ -72,5 +79,27 @@ C: <composed> composed
 : >composed< ( composed -- quot1 quot2 )
     [ quot1>> ] [ quot2>> ] bi ; inline
 
+M: composed (input-value?)
+    [ quot1>> input-value? ] [ quot2>> input-value? ] bi or ;
+
 M: composed (literal-value?) >composed< [ literal-value? ] both? ;
-M: composed (literal) >composed< [ compose ] curried/composed-literal ;
\ No newline at end of file
+
+M: composed (literal) >composed< [ compose ] curried/composed-literal ;
+
+! Input parameters
+SINGLETON: input-parameter
+
+SYMBOL: current-word
+
+M: input-parameter (input-value?) drop t ;
+
+M: input-parameter (literal-value?) drop f ;
+
+M: input-parameter (literal) current-word get unknown-macro-input ;
+
+! Computed values
+M: f (input-value?) drop f ;
+
+M: f (literal-value?) drop f ;
+
+M: f (literal) current-word get bad-macro-input ;
\ No newline at end of file
index 5f05d97d1a4d1970f3eb75c736f61df467c77a28..871f79d320b949f4ea951e9ec243eb8db9ed76fa 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2008 Slava Pestov.
+! Copyright (C) 2008, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: stack-checker.visitor kernel ;
 IN: stack-checker.visitor.dummy
@@ -24,4 +24,5 @@ M: f #copy, 2drop ;
 M: f #drop, drop ;
 M: f #alien-invoke, drop ;
 M: f #alien-indirect, drop ;
+M: f #alien-assembly, drop ;
 M: f #alien-callback, drop ;
index 6093cd008af0d077157283e51eae0bb6903cfc1e..d4207caf5bb5396da2d475d7b0f3a2043df8bf0a 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2008 Slava Pestov.
+! Copyright (C) 2008, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel arrays namespaces ;
 IN: stack-checker.visitor
@@ -29,4 +29,5 @@ HOOK: #recursive, stack-visitor ( label inputs visitor -- )
 HOOK: #copy, stack-visitor ( inputs outputs -- )
 HOOK: #alien-invoke, stack-visitor ( params -- )
 HOOK: #alien-indirect, stack-visitor ( params -- )
+HOOK: #alien-assembly, stack-visitor ( params -- )
 HOOK: #alien-callback, stack-visitor ( params -- )
index 51032264c7ad4c50aafdf4f50e8b02afcd6334c1..19d0051d176a6008fd92b0f955bee142a236adb2 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2009 Slava Pestov.
+! Copyright (C) 2009, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel sequences fry math.order splitting ;
 IN: strings.tables
@@ -6,7 +6,7 @@ IN: strings.tables
 <PRIVATE
 
 : map-last ( seq quot -- seq )
-    [ dup length <reversed> ] dip '[ 0 = @ ] 2map ; inline
+    [ dup length iota <reversed> ] dip '[ 0 = @ ] 2map ; inline
 
 : max-length ( seq -- n )
     [ length ] [ max ] map-reduce ;
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 931cb36..134c144
@@ -7,7 +7,7 @@ IN: suffix-arrays
 <PRIVATE
 
 : suffixes ( string -- suffixes-seq )
-    dup length [ tail-slice ] with map ;
+    dup length iota [ tail-slice ] with map ;
 
 : prefix<=> ( begin seq -- <=> )
     [ <=> ] [ swap head? ] 2bi [ drop +eq+ ] when ;
@@ -22,8 +22,7 @@ IN: suffix-arrays
 
 : <funky-slice> ( from/f to/f seq -- slice )
     [
-        tuck
-        [ drop 0 or ] [ length or ] 2bi*
+        [ drop 0 or ] [ length or ] bi-curry bi*
         [ min ] keep
     ] keep <slice> ; inline
 
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 8956051b251fd27634aeef7aeef4b40b8b3426e0..995fc867e71c94f9160fa25f607187ff032d241e 100644 (file)
@@ -1,6 +1,6 @@
 USING: help.markup help.syntax kernel kernel.private io
 threads.private continuations init quotations strings
-assocs heaps boxes namespaces deques dlists ;
+assocs heaps boxes namespaces deques dlists system ;
 IN: threads
 
 ARTICLE: "threads-start/stop" "Starting and stopping threads"
@@ -16,7 +16,7 @@ ARTICLE: "threads-start/stop" "Starting and stopping threads"
 }
 "Threads stop either when the quotation given to " { $link spawn } " returns, or when the following word is called:"
 { $subsections stop }
-"If the image is saved and started again, all runnable threads are stopped. Vocabularies wishing to have a background thread always running should use " { $link add-init-hook } "." ;
+"If the image is saved and started again, all runnable threads are stopped. Vocabularies wishing to have a background thread always running should use " { $link add-startup-hook } "." ;
 
 ARTICLE: "threads-yield" "Yielding and suspending threads"
 "Yielding to other threads:"
@@ -113,8 +113,8 @@ HELP: sleep-queue
 { $var-description "A " { $link min-heap } " storing the queue of sleeping threads." } ;
 
 HELP: sleep-time
-{ $values { "us/f" "a non-negative integer or " { $link f } } }
-{ $description "Outputs the time until the next sleeping thread is scheduled to wake up, which could be zero if there are threads in the run queue, or threads which need to wake up right now. If there are no runnable or sleeping threads, outputs " { $link f } "." } ;
+{ $values { "nanos/f" "a non-negative integer or " { $link f } } }
+{ $description "Returns the time until the next sleeping thread is scheduled to wake up, which could be zero if there are threads in the run queue, or threads which need to wake up right now. If there are no runnable or sleeping threads, returns " { $link f } "." } ;
 
 HELP: stop
 { $description "Stops the current thread. The thread may be started again from another thread using " { $link (spawn) } "." } ;
@@ -123,8 +123,8 @@ HELP: yield
 { $description "Adds the current thread to the end of the run queue, and switches to the next runnable thread." } ;
 
 HELP: sleep-until
-{ $values { "time/f" "a non-negative integer or " { $link f } } }
-{ $description "Suspends the current thread until the given time, or indefinitely if a value of " { $link f } " is passed in."
+{ $values { "n/f" "a non-negative integer or " { $link f } } }
+{ $description "Suspends the current thread until the given nanosecond count, returned by " { $link nano-count } ", is reached, or indefinitely if a value of " { $link f } " is passed in."
 $nl
 "Other threads may interrupt the sleep by calling " { $link interrupt } "." } ;
 
index 79aad20b856b0e875dbdf222b96b43b530b7de37..4568b7c491c76cf73b077f5ffdd3108107ed076c 100644 (file)
@@ -1,6 +1,6 @@
 USING: namespaces io tools.test threads kernel
 concurrency.combinators concurrency.promises locals math
-words ;
+words calendar sequences ;
 IN: threads.tests
 
 3 "x" set
@@ -20,7 +20,7 @@ yield
 [ f ] [ f get-global ] unit-test
 
 { { 0 3 6 9 12 15 18 21 24 27 } } [
-    10 [
+    10 iota [
         0 "i" tset
         [
             "i" [ yield 3 + ] tchange
@@ -42,3 +42,5 @@ yield
 [ t ] [ spawn-namespace-test ] unit-test
 
 [ "a" [ 1 1 + ] spawn 100 sleep ] must-fail
+
+[ ] [ 0.1 seconds sleep ] unit-test
index dec44625f72a74b10a023942b46fcc9cabc5183f..952652d801dbeeb036e200ef1337694732eb4165 100644 (file)
@@ -21,7 +21,7 @@ mailbox
 variables
 sleep-entry ;
 
-: self ( -- thread ) 63 getenv ; inline
+: self ( -- thread ) 63 special-object ; inline
 
 ! Thread-local storage
 : tnamespace ( -- assoc )
@@ -36,7 +36,7 @@ sleep-entry ;
 : tchange ( key quot -- )
     tnamespace swap change-at ; inline
 
-: threads ( -- assoc ) 64 getenv ;
+: threads ( -- assoc ) 64 special-object ;
 
 : thread ( id -- thread ) threads at ;
 
@@ -61,7 +61,7 @@ ERROR: not-running thread ;
 : unregister-thread ( thread -- )
     check-registered id>> threads delete-at ;
 
-: set-self ( thread -- ) 63 setenv ; inline
+: set-self ( thread -- ) 63 set-special-object ; inline
 
 PRIVATE>
 
@@ -75,9 +75,9 @@ PRIVATE>
 : <thread> ( quot name -- thread )
     \ thread new-thread ;
 
-: run-queue ( -- dlist ) 65 getenv ;
+: run-queue ( -- dlist ) 65 special-object ;
 
-: sleep-queue ( -- heap ) 66 getenv ;
+: sleep-queue ( -- heap ) 66 special-object ;
 
 : resume ( thread -- )
     f >>state
@@ -91,11 +91,11 @@ PRIVATE>
     f >>state
     check-registered 2array run-queue push-front ;
 
-: sleep-time ( -- us/f )
+: sleep-time ( -- nanos/f )
     {
         { [ run-queue deque-empty? not ] [ 0 ] }
         { [ sleep-queue heap-empty? ] [ f ] }
-        [ sleep-queue heap-peek nip micros [-] ]
+        [ sleep-queue heap-peek nip nano-count [-] ]
     } cond ;
 
 DEFER: stop
@@ -108,7 +108,7 @@ DEFER: stop
 
 : expire-sleep? ( heap -- ? )
     dup heap-empty?
-    [ drop f ] [ heap-peek nip micros <= ] if ;
+    [ drop f ] [ heap-peek nip nano-count <= ] if ;
 
 : expire-sleep ( thread -- )
     f >>sleep-entry resume ;
@@ -140,7 +140,11 @@ DEFER: next
     !
     ! And if sleep-time outputs f, there are no sleeping
     ! threads either... so WTF.
-    sleep-time [ die 0 ] unless* (sleep) next ;
+    sleep-time {
+        { [ dup not ] [ drop die ] }
+        { [ dup 0 = ] [ drop ] }
+        [ (sleep) ]
+    } cond next ;
 
 : (next) ( arg thread -- * )
     f >>state
@@ -173,7 +177,7 @@ PRIVATE>
 
 : yield ( -- ) [ resume ] f suspend drop ;
 
-GENERIC: sleep-until ( time/f -- )
+GENERIC: sleep-until ( n/f -- )
 
 M: integer sleep-until
     '[ _ schedule-sleep ] "sleep" suspend drop ;
@@ -184,7 +188,7 @@ M: f sleep-until
 GENERIC: sleep ( dt -- )
 
 M: real sleep
-    micros + >integer sleep-until ;
+    >integer nano-count + sleep-until ;
 
 : interrupt ( thread -- )
     dup state>> [
@@ -212,9 +216,9 @@ GENERIC: error-in-thread ( error thread -- )
 <PRIVATE
 
 : init-threads ( -- )
-    H{ } clone 64 setenv
-    <dlist> 65 setenv
-    <min-heap> 66 setenv
+    H{ } clone 64 set-special-object
+    <dlist> 65 set-special-object
+    <min-heap> 66 set-special-object
     initial-thread global
     [ drop [ ] "Initial" <thread> ] cache
     <box> >>continuation
@@ -225,4 +229,4 @@ GENERIC: error-in-thread ( error thread -- )
 
 PRIVATE>
 
-[ init-threads ] "threads" add-init-hook
+[ init-threads ] "threads" add-startup-hook
index c21e9e0c60ea9b90244de909042d0c0b79054af4..dcfc6ae5229e9c812e75285fc3e889f54f1cd189 100644 (file)
@@ -1,5 +1,5 @@
 USING: tools.test tools.annotations tools.time math parser eval
-io.streams.string kernel strings ;
+io.streams.string kernel strings sequences memory ;
 IN: tools.annotations.tests
 
 : foo ( -- ) ;
@@ -60,3 +60,10 @@ M: object my-generic ;
     f my-generic drop ;
 
 [ ] [ some-code ] unit-test
+
+! Make sure annotations work on primitives
+\ gc watch
+
+[ f ] [ [ gc ] with-string-writer empty? ] unit-test
+
+\ gc reset
old mode 100755 (executable)
new mode 100644 (file)
index 90fe7e8e9daee1a6715b8b55c2a56f066e1b8804..134395f1a85881e02a047c8f90f2fd3e8fa9659f 100644 (file)
@@ -135,6 +135,6 @@ SINGLETON: invalidate-crossref
 
 M: invalidate-crossref definitions-changed 2drop crossref global delete-at ;
 
-[ invalidate-crossref add-definition-observer ] "tools.crossref" add-init-hook
+[ invalidate-crossref add-definition-observer ] "tools.crossref" add-startup-hook
 
 PRIVATE>
old mode 100755 (executable)
new mode 100644 (file)
index bd58c75..fe8049e
@@ -71,6 +71,7 @@ DEFER: ?make-staging-image
         "-output-image=" over staging-image-name append ,
         "-include=" swap " " join append ,
         "-no-user-init" ,
+        "-pic=0" ,
     ] { } make ;
 
 : run-factor ( vm flags -- )
@@ -99,6 +100,7 @@ DEFER: ?make-staging-image
             [ "-deploy-vocab=" prepend , ]
             [ make-deploy-config "-deploy-config=" prepend , ] bi
             "-output-image=" prepend ,
+            "-pic=0" ,
         ] { } make
     ] bind ;
 
index 784b034665a68462193c223238b4cd08c1258fb0..1412e65f95f487a291598d5f94bbd43ba2e7b572 100644 (file)
@@ -5,32 +5,32 @@ io.launcher arrays namespaces continuations layouts accessors
 urls math.parser io.directories tools.deploy.test ;\r
 IN: tools.deploy.tests\r
 \r
-[ ] [ "hello-world" shake-and-bake 500000 small-enough? ] unit-test\r
+[ ] [ "hello-world" shake-and-bake 500000 small-enough? ] unit-test\r
 \r
-[ ] [ "sudoku" shake-and-bake 800000 small-enough? ] unit-test\r
+[ ] [ "sudoku" shake-and-bake 800000 small-enough? ] unit-test\r
 \r
-[ ] [ "hello-ui" shake-and-bake 1300000 small-enough? ] unit-test\r
+[ ] [ "hello-ui" shake-and-bake 1300000 small-enough? ] unit-test\r
 \r
 [ "staging.math-threads-compiler-ui.image" ] [\r
     "hello-ui" deploy-config\r
     [ bootstrap-profile staging-image-name file-name ] bind\r
 ] unit-test\r
 \r
-[ ] [ "maze" shake-and-bake 1200000 small-enough? ] unit-test\r
+[ ] [ "maze" shake-and-bake 1200000 small-enough? ] unit-test\r
 \r
-[ ] [ "tetris" shake-and-bake 1500000 small-enough? ] unit-test\r
+[ ] [ "tetris" shake-and-bake 1500000 small-enough? ] unit-test\r
 \r
-[ ] [ "spheres" shake-and-bake 1500000 small-enough? ] unit-test\r
+[ ] [ "spheres" shake-and-bake 1500000 small-enough? ] unit-test\r
 \r
-[ ] [ "terrain" shake-and-bake 1700000 small-enough? ] unit-test\r
+[ ] [ "terrain" shake-and-bake 1700000 small-enough? ] unit-test\r
 \r
-[ ] [ "bunny" shake-and-bake 2500000 small-enough? ] unit-test\r
+[ ] [ "bunny" shake-and-bake 2500000 small-enough? ] unit-test\r
 \r
 os macosx? [\r
-    [ ] [ "webkit-demo" shake-and-bake 500000 small-enough? ] unit-test\r
+    [ ] [ "webkit-demo" shake-and-bake 500000 small-enough? ] unit-test\r
 ] when\r
 \r
-[ ] [ "benchmark.regex-dna" shake-and-bake 900000 small-enough? ] unit-test\r
+[ ] [ "benchmark.regex-dna" shake-and-bake 900000 small-enough? ] unit-test\r
 \r
 {\r
     "tools.deploy.test.1"\r
@@ -115,3 +115,5 @@ os macosx? [
 ] unit-test\r
 \r
 [ ] [ "tools.deploy.test.16" shake-and-bake run-temp-image ] unit-test\r
+\r
+[ ] [ "tools.deploy.test.17" shake-and-bake run-temp-image ] unit-test\r
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index e42f478..0600999
@@ -9,6 +9,7 @@ compiler.units definitions generic generic.standard
 generic.single tools.deploy.config combinators classes
 classes.builtin slots.private grouping command-line ;
 QUALIFIED: bootstrap.stage2
+QUALIFIED: compiler.crossref
 QUALIFIED: compiler.errors
 QUALIFIED: continuations
 QUALIFIED: definitions
@@ -23,28 +24,27 @@ IN: tools.deploy.shaker
 
 : add-command-line-hook ( -- )
     [ (command-line) command-line set-global ] "command-line"
-    init-hooks get set-at ;
+    startup-hooks get set-at ;
 
-: strip-init-hooks ( -- )
+: strip-startup-hooks ( -- )
     "Stripping startup hooks" show
     {
         "alien.strings"
         "cpu.x86"
-        "destructors"
         "environment"
         "libc"
     }
-    [ init-hooks get delete-at ] each
+    [ startup-hooks get delete-at ] each
     deploy-threads? get [
-        "threads" init-hooks get delete-at
+        "threads" startup-hooks get delete-at
     ] unless
     native-io? [
-        "io.thread" init-hooks get delete-at
+        "io.thread" startup-hooks get delete-at
     ] unless
     strip-io? [
-        "io.files" init-hooks get delete-at
-        "io.backend" init-hooks get delete-at
-        "io.thread" init-hooks get delete-at
+        "io.files" startup-hooks get delete-at
+        "io.backend" startup-hooks get delete-at
+        "io.thread" startup-hooks get delete-at
     ] when
     strip-dictionary? [
         {
@@ -52,7 +52,7 @@ IN: tools.deploy.shaker
             "vocabs"
             "vocabs.cache"
             "source-files.errors"
-        } [ init-hooks get delete-at ] each
+        } [ startup-hooks get delete-at ] each
     ] when ;
 
 : strip-debugger ( -- )
@@ -180,7 +180,6 @@ IN: tools.deploy.shaker
                 "slots"
                 "special"
                 "specializer"
-                "specializations"
                 "struct-slots"
                 ! UI needs this
                 ! "superclass"
@@ -293,7 +292,7 @@ IN: tools.deploy.shaker
             continuations:error-continuation
             continuations:error-thread
             continuations:restarts
-            init:init-hooks
+            init:startup-hooks
             source-files:source-files
             input-stream
             output-stream
@@ -340,8 +339,8 @@ IN: tools.deploy.shaker
                 implementors-map
                 update-map
                 main-vocab-hook
-                compiled-crossref
-                compiled-generic-crossref
+                compiler.crossref:compiled-crossref
+                compiler.crossref:compiled-generic-crossref
                 compiler-impl
                 compiler.errors:compiler-errors
                 lexer-factory
@@ -394,7 +393,7 @@ IN: tools.deploy.shaker
         '[ drop _ member? not ] assoc-filter
         [ drop string? not ] assoc-filter ! strip CLI args
         sift-assoc
-        21 setenv
+        21 set-special-object
     ] [ drop ] if ;
 
 : strip-c-io ( -- )
@@ -445,10 +444,10 @@ SYMBOL: deploy-vocab
 
 : [print-error] ( -- word ) "print-error" "debugger" lookup ;
 
-: deploy-boot-quot ( word -- )
+: deploy-startup-quot ( word -- )
     [
         [ boot ] %
-        init-hooks get values concat %
+        startup-hooks get values concat %
         strip-debugger? [ , ] [
             ! Don't reference 'try' directly since we don't want
             ! to pull in the debugger and prettyprinter into every
@@ -465,9 +464,9 @@ SYMBOL: deploy-vocab
         strip-io? [ [ flush ] % ] unless
         [ 0 exit ] %
     ] [ ] make
-    set-boot-quot ;
+    set-startup-quot ;
 
-: init-stripper ( -- )
+: startup-stripper ( -- )
     t "quiet" set-global
     f output-stream set-global ;
 
@@ -506,7 +505,7 @@ SYMBOL: deploy-vocab
     [ clear-megamorphic-cache ] each ;
 
 : strip ( -- )
-    init-stripper
+    startup-stripper
     strip-libc
     strip-destructors
     strip-call
@@ -514,13 +513,13 @@ SYMBOL: deploy-vocab
     strip-debugger
     strip-specialized-arrays
     compute-next-methods
-    strip-init-hooks
+    strip-startup-hooks
     add-command-line-hook
     strip-c-io
     strip-default-methods
     strip-compiler-classes
-    f 5 setenv ! we can't use the Factor debugger or Factor I/O anymore
-    deploy-vocab get vocab-main deploy-boot-quot
+    f 5 set-special-object ! we can't use the Factor debugger or Factor I/O anymore
+    deploy-vocab get vocab-main deploy-startup-quot
     find-megamorphic-caches
     stripped-word-props
     stripped-globals strip-globals
index 133308b7329858a4f26656c6cce3d7933e5a7efb..7bb2f651dc2da794c00c92814f3b3ba460365008 100644 (file)
@@ -17,7 +17,7 @@ IN: cocoa.application
 
 : objc-error ( error -- ) die ;
 
-[ [ die ] 19 setenv ] "cocoa.application" add-init-hook
+[ [ die ] 19 set-special-object ] "cocoa.application" add-startup-hook
 
 H{ } clone \ pool [
     global [
@@ -46,4 +46,4 @@ H{ } clone \ pool [
 \ make-prepare-send reset-memoized
 \ <selector> reset-memoized
 
-\ (send) def>> second clear-assoc
\ No newline at end of file
+\ (send) def>> second clear-assoc
diff --git a/basis/tools/deploy/test/17/17.factor b/basis/tools/deploy/test/17/17.factor
new file mode 100644 (file)
index 0000000..a7cb0d2
--- /dev/null
@@ -0,0 +1,31 @@
+USING: accessors calendar db db.sqlite db.tuples db.types
+io.files.temp kernel urls ;
+IN: tools.deploy.test.17
+
+TUPLE: person name birthday homepage occupation ;
+
+person "PEOPLE" {
+    { "name" "NAME" { VARCHAR 256 } +not-null+ +user-assigned-id+ }
+    { "birthday" "BIRTHDAY" DATETIME +not-null+ }
+    { "homepage" "HOMEPAGE" URL +not-null+ }
+    { "occupation" "OCCUPATION" { VARCHAR 256 } +not-null+ }
+} define-persistent
+
+: db-deploy-test ( -- )
+    "test.db" temp-file <sqlite-db> [
+        person recreate-table
+        
+        person new
+            "Stephen Hawking" >>name
+            timestamp new 8 >>day 0 >>month 1942 >>year >>birthday
+            "http://en.wikipedia.org/wiki/Stephen_Hawking" >url >>homepage
+            "Dope MC" >>occupation
+        dup
+        insert-tuple
+        person new
+            "Stephen Hawking" >>name
+        select-tuple
+        assert=
+    ] with-db ;
+
+MAIN: db-deploy-test
diff --git a/basis/tools/deploy/test/17/deploy.factor b/basis/tools/deploy/test/17/deploy.factor
new file mode 100644 (file)
index 0000000..62cc2ca
--- /dev/null
@@ -0,0 +1,14 @@
+USING: tools.deploy.config ;
+H{
+    { deploy-name "tools.deploy.test.17" }
+    { deploy-ui? f }
+    { deploy-c-types? f }
+    { deploy-unicode? f }
+    { "stop-after-last-window?" t }
+    { deploy-io 3 }
+    { deploy-reflection 5 }
+    { deploy-word-props? f }
+    { deploy-math? t }
+    { deploy-threads? t }
+    { deploy-word-defs? f }
+}
index a9ee71131ceb70e74c8a487cbebced7308d240c0..fb005d2a4683b9aae04bfd13274641b542998653 100644 (file)
@@ -1,5 +1,5 @@
+USING: io.encodings.string kernel io.encodings.8-bit.latin7 ;
 IN: tools.deploy.test.4
-USING: io.encodings.8-bit io.encodings.string kernel ;
 
 : deploy-test-4 ( -- )
     "xyzthg" \ latin7 encode drop ;
index 3f9b7f15995be44007dbf86d4560e9356965755d..74f3a6942b8fcfa96007919f5aecdfafa6b70db4 100644 (file)
@@ -1,13 +1,14 @@
 USING: tools.deploy.config ;
 H{
-    { deploy-threads? t }
-    { deploy-c-types? f }
+    { deploy-name "tools.deploy.test.5" }
     { deploy-ui? f }
+    { deploy-c-types? f }
+    { deploy-unicode? f }
+    { "stop-after-last-window?" t }
+    { deploy-io 3 }
+    { deploy-reflection 2 }
     { deploy-word-props? f }
-    { deploy-word-defs? f }
     { deploy-math? t }
-    { deploy-io 3 }
-    { deploy-name "tools.deploy.test.5" }
-    { deploy-reflection 1 }
-    { "stop-after-last-window?" t }
+    { deploy-threads? t }
+    { deploy-word-defs? f }
 }
old mode 100755 (executable)
new mode 100644 (file)
index c799ec6..d8414ba
@@ -10,14 +10,16 @@ IN: tools.deploy.test
         dup deploy-config make-deploy-image
     ] with-directory ;
 
-: small-enough? ( n -- ? )
+ERROR: image-too-big actual-size max-size ;
+
+: small-enough? ( n -- )
     [ "test.image" temp-file file-info size>> ]
     [
         cell 4 / *
         cpu ppc? [ 100000 + ] when
         os windows? [ 150000 + ] when
     ] bi*
-    <= ;
+    2dup <= [ 2drop ] [ image-too-big ] if ;
 
 : deploy-test-command ( -- args )
     os macosx?
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 0ee60b06b5168c471797c88d562012a47169c4dc..8dbfda3011204cf9a06bfebfb0a6eac7dea3e808 100644 (file)
@@ -73,6 +73,6 @@ M: deprecation-observer definitions-changed
     [ drop initialize-deprecation-notes ] if ;
 
 [ \ deprecation-observer add-definition-observer ] 
-"tools.deprecation" add-init-hook
+"tools.deprecation" add-startup-hook
 
 initialize-deprecation-notes
old mode 100755 (executable)
new mode 100644 (file)
index 4aec909..c0b3c9a
@@ -7,12 +7,16 @@ IN: tools.disassembler
 
 GENERIC: disassemble ( obj -- )
 
+<PRIVATE
+
 SYMBOL: disassembler-backend
 
 HOOK: disassemble* disassembler-backend ( from to -- lines )
 
 TR: tabs>spaces "\t" "\s" ;
 
+PRIVATE>
+
 M: byte-array disassemble 
     [
         [ malloc-byte-array &free alien-address dup ]
@@ -22,7 +26,7 @@ M: byte-array disassemble
 
 M: pair disassemble first2 disassemble* [ tabs>spaces print ] each ;
 
-M: word disassemble word-xt 2array disassemble ;
+M: word disassemble word-code 2array disassemble ;
 
 M: quotation disassemble [ dup infer define-temp ] with-compilation-unit disassemble ;
 
old mode 100755 (executable)
new mode 100644 (file)
index c4c724b..dda666c
@@ -1,9 +1,9 @@
-! Copyright (C) 2008 Slava Pestov, Jorge Acereda Macia.
+! Copyright (C) 2008, 2010 Slava Pestov, Jorge Acereda Macia.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: io.files io.files.temp io words alien kernel math.parser
-alien.syntax io.launcher assocs arrays sequences
-namespaces make system math io.encodings.ascii
-accessors tools.disassembler ;
+alien.syntax io.launcher assocs arrays sequences namespaces make
+system math io.encodings.ascii accessors tools.disassembler
+tools.disassembler.private ;
 IN: tools.disassembler.gdb
 
 SINGLETON: gdb-disassembler
index 9ad3dbbcc21f9999151cef79cd41218f1b80f110..df3ef413650ee23edb290071ae650936f4d56800 100644 (file)
@@ -2,8 +2,8 @@ IN: tools.disassembler.udis.tests
 USING: tools.disassembler.udis tools.test alien.c-types system combinators kernel ;
 
 {
-    { [ os linux? cpu x86.64? and ] [ [ 656 ] [ "ud" heap-size ] unit-test ] }
-    { [ os macosx? cpu x86.32? and ] [ [ 592 ] [ "ud" heap-size ] unit-test ] }
-    { [ os macosx? cpu x86.64? and ] [ [ 656 ] [ "ud" heap-size ] unit-test ] }
+    { [ os linux? cpu x86.64? and ] [ [ 656 ] [ ud heap-size ] unit-test ] }
+    { [ os macosx? cpu x86.32? and ] [ [ 592 ] [ ud heap-size ] unit-test ] }
+    { [ os macosx? cpu x86.64? and ] [ [ 656 ] [ ud heap-size ] unit-test ] }
     [ ]
 } cond
\ No newline at end of file
old mode 100755 (executable)
new mode 100644 (file)
index effb2d6..82c47a5
@@ -1,11 +1,11 @@
-! Copyright (C) 2008 Slava Pestov, Jorge Acereda Macia.
+! Copyright (C) 2008, 2010 Slava Pestov, Jorge Acereda Macia.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: tools.disassembler namespaces combinators
 alien alien.syntax alien.c-types lexer parser kernel
 sequences layouts math math.order alien.libraries
 math.parser system make fry arrays libc destructors
-tools.disassembler.utils splitting alien.data
-classes.struct ;
+tools.disassembler.utils tools.disassembler.private splitting
+alien.data classes.struct ;
 IN: tools.disassembler.udis
 
 <<
@@ -105,7 +105,7 @@ FUNCTION: char* ud_lookup_mnemonic ( int c ) ;
     dup UD_SYN_INTEL ud_set_syntax ;
 
 : with-ud ( quot: ( ud -- ) -- )
-    [ [ [ <ud> ] dip call ] with-destructors ] with-words-xt ; inline
+    [ [ [ <ud> ] dip call ] with-destructors ] with-word-entry-points ; inline
 
 SINGLETON: udis-disassembler
 
index fb936cf08a780f0f7068386c004b49dc1322cb41..60e094ac34e9e42e12c089376bf342b21b62d698 100644 (file)
@@ -2,13 +2,13 @@ USING: accessors arrays binary-search kernel math math.order
 math.parser namespaces sequences sorting splitting vectors vocabs words ;
 IN: tools.disassembler.utils
 
-SYMBOL: words-xt
+SYMBOL: word-entry-points
 SYMBOL: smallest-xt
 SYMBOL: greatest-xt
 
-: (words-xt) ( -- assoc )
-    vocabs [ words ] map concat [ [ word-xt ] keep 3array ] map
-    [ [ first ] bi@ <=> ] sort >vector ;
+: (word-entry-points) ( -- assoc )
+    vocabs [ words ] map concat [ [ word-code ] keep 3array ] map
+    [ first ] sort-with ;
 
 : complete-address ( n seq -- str )
     [ first - ] [ third name>> ] bi
@@ -18,7 +18,7 @@ SYMBOL: greatest-xt
     dup [ smallest-xt get < ] [ greatest-xt get > ] bi or [
         drop f
     ] [
-        words-xt get over [ swap first <=> ] curry search nip
+        word-entry-points get over [ swap first <=> ] curry search nip
         2dup second <= [
             [ complete-address ] [ drop f ] if*
         ] [
@@ -33,9 +33,11 @@ SYMBOL: greatest-xt
 : resolve-call ( str -- str' )
     "0x" split1-last [ resolve-xt "0x" glue ] when* ;
 
-: with-words-xt ( quot -- )
-    [ (words-xt)
-      [ words-xt set ]
-      [ first first smallest-xt set ]
-      [ last second greatest-xt set ] tri
-    ] prepose with-scope ; inline
+: with-word-entry-points ( quot -- )
+    [
+        (word-entry-points)
+        [ word-entry-points set ]
+        [ first first smallest-xt set ]
+        [ last second greatest-xt set ] tri
+        call
+    ] with-scope ; inline
index c874363fe68f49f449ecfb7f6e0894567cb14c27..b41d236fd7b89a36e0bf5bf2640f82cb43250776 100644 (file)
@@ -14,5 +14,5 @@ SINGLETON: updater
 
 M: updater errors-changed drop f (error-list-model) get-global set-model ;
 
-[ updater add-error-observer ] "ui.tools.error-list" add-init-hook
+[ updater add-error-observer ] "ui.tools.error-list" add-startup-hook
 
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index f729e8945f5ab73db3e84e599c5ed6d138e491ce..b18396538f3f09c1034fb694286a6cacb4832352 100644 (file)
@@ -13,11 +13,8 @@ ARTICLE: "tools.memory" "Object memory tools"
     data-room
     code-room
 }
-"There are a pair of combinators, analogous to " { $link each } " and " { $link filter } ", which operate on the entire collection of objects in the object heap:"
-{ $subsections
-    each-object
-    instances
-}
+"A combinator to get objects from the heap:"
+{ $subsections instances }
 "You can check an object's the heap memory usage:"
 { $subsections size }
 "The garbage collector can be invoked manually:"
index c147426a6fa8132c0d44491e88a9ec51d55f8648..6746031a3d1085d8bd3227ce77ccdcd99853d2d2 100644 (file)
@@ -4,8 +4,7 @@ USING: accessors arrays assocs classes classes.struct
 combinators combinators.smart continuations fry generalizations
 generic grouping io io.styles kernel make math math.parser
 math.statistics memory namespaces parser prettyprint sequences
-sorting specialized-arrays splitting strings system vm words ;
-SPECIALIZED-ARRAY: gc-event
+sorting splitting strings system vm words ;
 IN: tools.memory
 
 <PRIVATE
@@ -19,8 +18,8 @@ IN: tools.memory
 : kilobytes ( n -- str )
     1024 /i commas " KB" append ;
 
-: micros>string ( n -- str )
-    commas " µs" append ;
+: nanos>string ( n -- str )
+    1000 /i commas " µs" append ;
 
 : copying-room. ( copying-sizes -- )
     {
@@ -101,7 +100,7 @@ SYMBOL: gc-events
 : collect-gc-events ( quot -- )
     enable-gc-events
     [ ] [ disable-gc-events drop ] cleanup
-    disable-gc-events byte-array>gc-event-array gc-events set ; inline
+    disable-gc-events [ gc-event memory>struct ] map gc-events set ; inline
 
 <PRIVATE
 
@@ -154,11 +153,11 @@ TUPLE: gc-stats collections times ;
             [ collections>> ]
             [
                 times>> {
-                    [ sum micros>string ]
-                    [ mean >integer micros>string ]
-                    [ median >integer micros>string ]
-                    [ infimum micros>string ]
-                    [ supremum micros>string ]
+                    [ sum nanos>string ]
+                    [ mean >integer nanos>string ]
+                    [ median >integer nanos>string ]
+                    [ infimum nanos>string ]
+                    [ supremum nanos>string ]
                 } cleave
             ] bi
         ] bi
@@ -173,7 +172,7 @@ PRIVATE>
 : gc-event. ( event -- )
     {
         { "Event type:" [ op>> gc-op-string ] }
-        { "Total time:" [ total-time>> micros>string ] }
+        { "Total time:" [ total-time>> nanos>string ] }
         { "Space reclaimed:" [ space-reclaimed kilobytes ] }
     } object-table. ;
 
@@ -189,10 +188,10 @@ PRIVATE>
         { "Cards scanned:" [ [ cards-scanned>> ] map-sum commas ] }
         { "Decks scanned:" [ [ decks-scanned>> ] map-sum commas ] }
         { "Code blocks scanned:" [ [ code-blocks-scanned>> ] map-sum commas ] }
-        { "Total time:" [ [ total-time>> ] map-sum micros>string ] }
-        { "Card scan time:" [ [ card-scan-time>> ] map-sum micros>string ] }
-        { "Code block scan time:" [ [ code-scan-time>> ] map-sum micros>string ] }
-        { "Data heap sweep time:" [ [ data-sweep-time>> ] map-sum micros>string ] }
-        { "Code heap sweep time:" [ [ code-sweep-time>> ] map-sum micros>string ] }
-        { "Compaction time:" [ [ compaction-time>> ] map-sum micros>string ] }
+        { "Total time:" [ [ total-time>> ] map-sum nanos>string ] }
+        { "Card scan time:" [ [ card-scan-time>> ] map-sum nanos>string ] }
+        { "Code block scan time:" [ [ code-scan-time>> ] map-sum nanos>string ] }
+        { "Data heap sweep time:" [ [ data-sweep-time>> ] map-sum nanos>string ] }
+        { "Code heap sweep time:" [ [ code-sweep-time>> ] map-sum nanos>string ] }
+        { "Compaction time:" [ [ compaction-time>> ] map-sum nanos>string ] }
     } object-table. ;
index 7f44a6138c2e6d8822c435a3af5687490a559755..8f3260d649bfbe40ebe9cd7eac11f0f1077c4da4 100644 (file)
@@ -60,7 +60,15 @@ IN: tools.profiler.tests
 
 [ [ gensym execute ] profile ] [ T{ undefined } = ] must-fail-with
 
-: crash-bug-1 ( -- x ) "hi" "bye" <word> ;
+: crash-bug-1 ( -- x ) "hi" <uninterned-word> ;
 : crash-bug-2 ( -- ) 100000 [ crash-bug-1 drop ] times ;
 
 [ ] [ [ crash-bug-2 ] profile ] unit-test
+
+[ 1 ] [
+    [
+        [ [ ] (( -- )) define-temp ] with-compilation-unit
+        dup execute( -- )
+    ] profile
+    counter>>
+] unit-test
index 626fdab826475b3d3122974cce7cb195015e2585..8279a905147003a2260b37f46117cd1d1350c349 100644 (file)
@@ -1,9 +1,10 @@
 ! Copyright (C) 2007, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors words sequences math prettyprint kernel arrays io
-io.styles namespaces assocs kernel.private strings combinators
-sorting math.parser vocabs definitions tools.profiler.private
-tools.crossref continuations generic compiler.units sets classes fry ;
+USING: accessors words sequences math prettyprint kernel arrays
+io io.styles namespaces assocs kernel.private strings
+combinators sorting math.parser vocabs definitions
+tools.profiler.private tools.crossref continuations generic
+compiler.units compiler.crossref sets classes fry ;
 IN: tools.profiler
 
 : profile ( quot -- )
old mode 100755 (executable)
new mode 100644 (file)
index 089bad3..936d388
@@ -98,7 +98,7 @@ M: bad-developer-name summary
     [ main-file-string ] dip utf8 set-file-contents ;
 
 : scaffold-main ( vocab-root vocab -- )
-    tuck ".factor" vocab-root/vocab/suffix>path scaffolding? [
+    [ ".factor" vocab-root/vocab/suffix>path ] keep swap scaffolding? [
         set-scaffold-main-file
     ] [
         2drop
old mode 100755 (executable)
new mode 100644 (file)
index 009789a739aba4561725934c46a636741fb9fac5..559b1357c80ac34188d9e962d94a244444e071ba 100644 (file)
@@ -121,9 +121,6 @@ SYNTAX: TEST:
         vocab-tests [ run-test-file ] each
     ] [ drop ] if ;
 
-: traceback-button. ( failure -- )
-    "[" write [ "Traceback" ] dip continuation>> write-object "]" print ;
-
 PRIVATE>
 
 TEST: unit-test
@@ -137,7 +134,7 @@ M: test-failure error. ( error -- )
         [ error-location print nl ]
         [ asset>> [ experiment. nl ] when* ]
         [ error>> error. ]
-        [ traceback-button. ]
+        [ continuation>> traceback-link. ]
     } cleave ;
 
 : :test-failures ( -- ) test-failures get errors. ;
index 18dd8ce2b793a53228686eb6cbd77a18a5b9c6f4..ea85fb1129c3e02ecb8e29bf39abed0784e02f8f 100644 (file)
@@ -14,8 +14,8 @@ IN: tools.threads
     ] with-cell\r
     [\r
         sleep-entry>> [\r
-            key>> micros [-] number>string write\r
-            " us" write\r
+            key>> nano-count [-] number>string write\r
+            " nanos" write\r
         ] when*\r
     ] with-cell ;\r
 \r
index 9e892c33eccf24f2834f64704358971253602706..d28202f8440a20c0b23a84f0ba7c1f8a41e8ce85 100644 (file)
@@ -9,8 +9,7 @@ ARTICLE: "timing" "Timing code and collecting statistics"
 { $subsections dispatch-stats. gc-events. gc-stats. gc-summary. }
 "A lower-level word puts timings on the stack, intead of printing:"
 { $subsections benchmark }
-"You can also read the system clock directly:"
-{ $subsections micros }
+"You can also read the system clock directly; see " { $link "system" } "."
 { $see-also "profiling" "calendar" } ;
 
 ABOUT: "timing"
@@ -25,7 +24,7 @@ HELP: time
 { $values { "quot" quotation } }
 { $description "Runs a quotation, gathering statistics about method dispatch and garbage collection, and then prints the total run time." } ;
 
-{ benchmark micros time } related-words
+{ benchmark system-micros time } related-words
 
 HELP: collect-gc-events
 { $values { "quot" quotation } }
diff --git a/basis/tools/time/time-tests.factor b/basis/tools/time/time-tests.factor
new file mode 100644 (file)
index 0000000..00c7746
--- /dev/null
@@ -0,0 +1,4 @@
+IN: tools.time.tests
+USING: tools.time tools.test compiler ;
+
+[ ] [ [ [ ] time ] compile-call ] unit-test
index 3724a741b7f6e068e5b8173961cdecff20a03efc..0bd97f563dbf3bbc5b0e8468f21446938bb54675 100644 (file)
@@ -5,10 +5,10 @@ tools.dispatch ;
 IN: tools.time
 
 : benchmark ( quot -- runtime )
-    micros [ call micros ] dip - ; inline
+    nano-count [ call nano-count ] dip - ; inline
 
 : time. ( time -- )
-    "Running time: " write 1000000 /f pprint " seconds" print ;
+    "Running time: " write 1000000000 /f pprint " seconds" print ;
 
 : time-banner. ( -- )
     "Additional information was collected." print
index f75adcbf04d6944b670346f7813ef0a921b2e819..690103edf5eeb2a0ca8ee22e1c62d805188182ed 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2008 Slava Pestov.
+! Copyright (C) 2008, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: byte-arrays strings sequences sequences.private ascii
 fry kernel words parser lexer assocs math math.order summary ;
@@ -17,7 +17,7 @@ M: bad-tr summary
     [ [ ascii? ] all? ] both? [ bad-tr ] unless ;
 
 : compute-tr ( quot from to -- mapping )
-    [ 128 ] 3dip zip
+    [ 128 iota ] 3dip zip
     '[ [ _ call( x -- y ) _ at ] keep or ] B{ } map-as ; inline
 
 : tr-hints ( word -- )
index 92e7541616f3507d05075fa5a7ec5d04d38db358..1bc62705247606841eb01af36b34cc9593d375fe 100644 (file)
@@ -10,7 +10,7 @@ IN: tuple-arrays
 
 MACRO: boa-unsafe ( class -- quot ) tuple-layout '[ _ <tuple-boa> ] ;
 
-MACRO: infer-in ( class -- quot ) infer in>> '[ _ ] ;
+MACRO: infer-in ( class -- quot ) inputs '[ _ ] ;
 
 : tuple-arity ( class -- quot ) '[ _ boa ] infer-in ; inline
 
@@ -28,7 +28,7 @@ MACRO: infer-in ( class -- quot ) infer in>> '[ _ ] ;
 
 MACRO: write-tuple ( class -- quot )
     [ '[ [ _ boa ] undo ] ]
-    [ tuple-arity <reversed> [ '[ [ _ ] dip set-nth-unsafe ] ] map '[ _ cleave ] ]
+    [ tuple-arity iota <reversed> [ '[ [ _ ] dip set-nth-unsafe ] ] map '[ _ cleave ] ]
     bi '[ _ dip @ ] ;
 
 PRIVATE>
index ec96902d727de909e6a84f0ec4ea53fa97b28bff..0b3ac9d5f8f96107a4261e9c6e50d91e146badf3 100644 (file)
@@ -3,7 +3,7 @@ USING: accessors arrays classes classes.tuple combinators
 combinators.short-circuit definitions effects fry hints
 math kernel kernel.private namespaces parser quotations
 sequences slots words locals 
-locals.parser macros stack-checker.state ;
+locals.parser macros stack-checker.dependencies ;
 IN: typed
 
 ERROR: type-mismatch-error word expected-types ;
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 9759dbf..8eeca89
@@ -225,9 +225,9 @@ CLASS: {
 : install-app-delegate ( -- )
     NSApp FactorApplicationDelegate install-delegate ;
 
-SYMBOL: cocoa-init-hook
+SYMBOL: cocoa-startup-hook
 
-cocoa-init-hook [
+cocoa-startup-hook [
     [ "MiniFactor.nib" load-nib install-app-delegate ]
 ] initialize
 
@@ -235,7 +235,7 @@ M: cocoa-ui-backend (with-ui)
     "UI" assert.app [
         [
             init-clipboard
-            cocoa-init-hook get call( -- )
+            cocoa-startup-hook get call( -- )
             start-ui
             f io-thread-running? set-global
             init-thread-timer
index d04bcededac38e52d8f0fe4f4dff7b091523cdb5..00c1ad35831b3cbf639eb60daa864e574076f9d3 100644 (file)
@@ -101,4 +101,4 @@ FUNCTION: void NSUpdateDynamicServices ;
     install-app-delegate
     "Factor.nib" load-nib
     register-services
-] cocoa-init-hook set-global
+] cocoa-startup-hook set-global
old mode 100755 (executable)
new mode 100644 (file)
index a6d73ca..fdd3c06
@@ -170,6 +170,8 @@ PRIVATE>
 : lo-word ( wparam -- lo ) <short> *short ; inline
 : hi-word ( wparam -- hi ) -16 shift lo-word ; inline
 : >lo-hi ( WORD -- array ) [ lo-word ] [ hi-word ] bi 2array ;
+: GET_APPCOMMAND_LPARAM ( lParam -- appCommand )
+    hi-word FAPPCOMMAND_MASK lo-word bitnot bitand ; inline
 
 : crlf>lf ( str -- str' )
     CHAR: \r swap remove ;
@@ -495,6 +497,13 @@ SYMBOL: nc-buttons
     ReleaseCapture win32-error=0/f
     mouse-captured off ;
 
+: handle-app-command ( hWnd uMsg wParam lParam -- )
+    GET_APPCOMMAND_LPARAM
+    {
+        { APPCOMMAND_BROWSER_BACKWARD [ pick window left-action send-action ] }
+        { APPCOMMAND_BROWSER_FORWARD [ pick window right-action send-action ] }
+    } case 3drop ;
+    
 : handle-wm-buttondown ( hWnd uMsg wParam lParam -- )
     [
         over set-capture
@@ -571,6 +580,8 @@ H{ } clone wm-handlers set-global
 [ handle-wm-set-focus 0  ] WM_SETFOCUS add-wm-handler
 [ handle-wm-kill-focus 0 ] WM_KILLFOCUS add-wm-handler
 
+[ handle-app-command 0 ] WM_APPCOMMAND add-wm-handler
+
 [ handle-wm-buttondown 0 ] WM_LBUTTONDOWN add-wm-handler
 [ handle-wm-buttondown 0 ] WM_MBUTTONDOWN add-wm-handler
 [ handle-wm-buttondown 0 ] WM_RBUTTONDOWN add-wm-handler
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index cee38dbd7838fbf90c74917ff6d330341af4a5cd..f39d45b97809c14e339eab024985ed04fa36653a 100644 (file)
@@ -33,10 +33,10 @@ HELP: button-pen
         { { $snippet "plain"    } " - the button is inactive" }
         { { $snippet "rollover" } " - the button is under the mouse" }
         { { $snippet "pressed"  } " - the button is under the mouse and a mouse button is held down" }
-        { { $snippet "selected" } " - the button is selected (see " { $link checkbox }  }
-        { { $snippet "selected" } " - the button is selected and a mouse button is being held down (see " { $link checkbox }  }
+        { { $snippet "selected" } " - the button is selected (see " { $link checkbox } ")" }
+        { { $snippet "pressed-selected" } " - the button is selected and a mouse button is being held down (see " { $link checkbox } ")" }
     }
-"The " { $link <roll-button> } " and " { $link <border-button> } " words create " { $link button } " instances with specific " { $link button-pen } "." } ;
+"The " { $link <roll-button> } " and " { $link <border-button> } " words create " { $link button } " instances with specific " { $link button-pen } "s." } ;
 
 HELP: <command-button>
 { $values { "target" object } { "gesture" "a gesture" } { "command" "a command" } { "button" "a new " { $link button } } }
old mode 100755 (executable)
new mode 100644 (file)
index d7f77d9e549301c9bd19ce58b763ac47165eda80..ea16abb9bae6ba80697f68042a5e483800086216 100644 (file)
@@ -123,7 +123,7 @@ M: mock-gadget ungraft*
             <mock-gadget> over <model> >>model
             "g" get over add-gadget drop
             swap 1 + number>string set
-        ] each ;
+        ] each-integer ;
 
     : status-flags ( -- seq )
         { "g" "1" "2" "3" } [ get graft-state>> ] map prune ;
index 12d0ef580d68419d06625a5a50e0a4109f34016d..8eb11a7753c7ca8e802de6246bdd01c301b4e199 100644 (file)
@@ -11,7 +11,6 @@ CONSTANT: horizontal { 1 0 }
 CONSTANT: vertical { 0 1 }
 
 TUPLE: gadget < rect
-id
 pref-dim
 parent
 children
@@ -29,7 +28,7 @@ model ;
 
 M: gadget equal? 2drop f ;
 
-M: gadget hashcode* nip [ [ \ gadget counter ] unless* ] change-id id>> ;
+M: gadget hashcode* nip identity-hashcode ;
 
 M: gadget model-changed 2drop ;
 
old mode 100755 (executable)
new mode 100644 (file)
index b49f46c05a9e4429533f9a0c4cc8fdcd45f9f743..7ca83ce465c1ba3e6fd8ebb24d661a53f3e15ff7 100644 (file)
@@ -1,14 +1,14 @@
 USING: ui.gadgets.packs ui.gadgets.packs.private
 ui.gadgets.labels ui.gadgets ui.gadgets.debug ui.render
 ui.baseline-alignment kernel namespaces tools.test math.parser
-sequences math.rectangles accessors ;
+sequences math.rectangles accessors math ;
 IN: ui.gadgets.packs.tests
 
 [ t ] [
     { 0 0 } { 100 100 } <rect> clip set
 
     <pile>
-        100 [ number>string <label> add-gadget ] each
+        100 [ number>string <label> add-gadget ] each-integer
     dup layout
 
     visible-children [ label? ] all?
index 01abe8b3d958c0175ee1f81b2a7be511fc65a917..847e14df8a07aba9da31061cfa505085710951ae 100644 (file)
@@ -12,7 +12,7 @@ IN: ui.gadgets.panes.tests
 [ ] [ #children "num-children" set ] unit-test
 
 [ ] [
-    "pane" get <pane-stream> [ 100 [ . ] each ] with-output-stream*
+    "pane" get <pane-stream> [ 100 [ . ] each-integer ] with-output-stream*
 ] unit-test
 
 [ t ] [ #children "num-children" get = ] unit-test
index 5f5cc91846cd1a5649a550ff03b6bd81f0910d14..c89461cd5ab01d218238199692632e35a46c6072 100644 (file)
@@ -70,7 +70,7 @@ dup layout
 "s" set
 
 [ t ] [
-    10 [
+    10 iota [
         drop
         "g2" get scroll>gadget
         "s" get layout
index 5a627286f93858f785ab4076f0e15d3683b597c0..5f729249547e91019bd49df13e1a4730bcad142b 100644 (file)
@@ -1,3 +1,7 @@
 IN: ui.gadgets.search-tables.tests
-USING: ui.gadgets.search-tables sequences tools.test ;
+USING: ui.gadgets.search-tables ui.gadgets.tables ui.gadgets models
+arrays sequences tools.test ;
+
 [ [ second ] <search-table> ] must-infer
+
+[ t ] [ f <model> trivial-renderer [ second ] <search-table> pref-dim pair? ] unit-test
index 9f55c7a67df0d11617777c32cf7a744633486cd2..dd2232df60895c1132498c7eebe9fbd6c4b334a4 100644 (file)
@@ -51,7 +51,6 @@ renderer
 action
 hook
 font
-gap
 selection-color
 focus-border-color
 mouse-color
index e49c60a3ed21458d264e0b24abc5c5be21b6bcb3..f1b856949c05024b16b91318d67161504a96d930 100644 (file)
@@ -1,4 +1,4 @@
 IN: ui.gadgets.slots.tests
 USING: assocs ui.gadgets.slots tools.test refs ;
 
-[ t ] [ [ ] [ ] { 1 2 3 } 2 <value-ref> <slot-editor> slot-editor? ] unit-test
+[ t ] [ [ ] [ ] { { 1 1 } { 2 2 } { 3 3 } } 2 <value-ref> <slot-editor> slot-editor? ] unit-test
index 387f41a6a4e461144315a25f0c5ffd82a3af53cb..89389485b24832e4c0b8e5be83fe2d2097a09651 100644 (file)
@@ -39,7 +39,8 @@ TUPLE: track < pack sizes ;
 M: track layout* ( track -- ) dup track-layout pack-layout ;
 
 : track-pref-dims-1 ( track -- dim )
-    children>> pref-dims max-dim ;
+    [ children>> pref-dims max-dim ]
+    [ pref-dim>> { 0 0 } or ] bi vmax ;
 
 : track-pref-dims-2 ( track -- dim )
     [
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 8f38cee..7e54b82
@@ -50,7 +50,8 @@ TUPLE: world-attributes
     status
     gadgets
     { pixel-format-attributes initial: $ default-world-pixel-format-attributes }
-    { window-controls initial: $ default-world-window-controls } ;
+    { window-controls initial: $ default-world-window-controls }
+    pref-dim ;
 
 : <world-attributes> ( -- world-attributes )
     world-attributes new ; inline
@@ -124,7 +125,8 @@ M: world request-focus-on ( child gadget -- )
     [ T{ rgba f 0.0 0.0 0.0 0.0 } ]
     [ T{ rgba f 1.0 1.0 1.0 1.0 } ] if ;
 
-: apply-world-attributes ( world attributes -- world )
+GENERIC# apply-world-attributes 1 ( world attributes -- world )
+M: world apply-world-attributes
     {
         [ title>> >>title ]
         [ status>> >>status ]
@@ -132,7 +134,8 @@ M: world request-focus-on ( child gadget -- )
         [ window-controls>> >>window-controls ]
         [ initial-background-color >>background-color ]
         [ grab-input?>> >>grab-input? ]
-        [ gadgets>> [ 1 track-add ] each ]
+        [ gadgets>> dup sequence? [ [ 1 track-add ] each ] [ 1 track-add ] if ]
+        [ pref-dim>> >>pref-dim ]
     } cleave ;
 
 : <world> ( world-attributes -- world )
index 3deb0c619dfca0610ae1d4095d68a5317688e9bc..bb33e28da3c281060772b3ac57abbb8dbf81bc1d 100644 (file)
@@ -174,7 +174,7 @@ HELP: hand-last-button
 { $var-description "Global variable. The mouse button most recently pressed." } ;
 
 HELP: hand-last-time
-{ $var-description "Global variable. The timestamp of the most recent mouse button click. This timestamp has the same format as the output value of " { $link micros } "." } ;
+{ $var-description "Global variable. The timestamp of the most recent mouse button click. This timestamp has the same format as the output value of " { $link system-micros } "." } ;
 
 HELP: hand-buttons
 { $var-description "Global variable. A vector of mouse buttons currently held down." } ;
index 8e982f8e4596e7322d361117997989fe878aff98..f33b6ec6da8ebb38cf21cec403e38ed90c23fc7e 100644 (file)
@@ -156,7 +156,7 @@ SYMBOL: hand-click#
 SYMBOL: hand-last-button
 SYMBOL: hand-last-time
 0 hand-last-button set-global
-<zero> hand-last-time set-global
+0 hand-last-time set-global
 
 SYMBOL: hand-buttons
 V{ } clone hand-buttons set-global
@@ -184,7 +184,7 @@ SYMBOL: drag-timer
 : start-drag-timer ( -- )
     hand-buttons get-global empty? [
         [ drag-gesture ]
-        300 milliseconds hence
+        300 milliseconds
         100 milliseconds
         add-alarm drag-timer get-global >box
     ] when ;
@@ -246,7 +246,8 @@ SYMBOL: drag-timer
     hand-click-loc get-global swap screen-loc v- ;
 
 : multi-click-timeout? ( -- ? )
-    now hand-last-time get time- double-click-timeout get before=? ;
+    nano-count hand-last-time get - nanoseconds
+    double-click-timeout get before=? ;
 
 : multi-click-button? ( button -- button ? )
     dup hand-last-button get = ;
@@ -269,7 +270,7 @@ SYMBOL: drag-timer
             1 hand-click# set
         ] if
         hand-last-button set
-        now hand-last-time set
+        nano-count hand-last-time set
     ] bind ;
 
 : update-clicked ( -- )
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 63134b3c8e6a91026031f9430b08f8ebf1a07f5a..22802d39aee565d29a34af5f8e8843fd669cc3f0 100644 (file)
@@ -1,4 +1,24 @@
-! Copyright (C) 2009 Slava Pestov.
-! See http://factorcode.org/license.txt for BSD license.
-USING: tools.test ui.pens.gradient ;
+USING: tools.test ui.pens.gradient ui.pens.gradient.private
+colors.constants specialized-arrays alien.c-types ;
+SPECIALIZED-ARRAY: float
 IN: ui.pens.gradient.tests
+
+[
+    float-array{
+        0.0
+        0.0
+        0.0
+        100.0
+        50.0
+        0.0
+        50.0
+        100.0
+        100.0
+        0.0
+        100.0
+        100.0
+    }
+] [
+    { 1 0 } { 100 100 } { COLOR: red COLOR: green COLOR: blue }
+    gradient-vertices
+] unit-test
index 7f7bd02204884598504d9fc1644108186b3adec8..fbf190a218fcf4a7e5d22495a4d906c4368e0167 100644 (file)
@@ -16,7 +16,7 @@ TUPLE: gradient < caching-pen colors last-vertices last-colors ;
 
 :: gradient-vertices ( direction dim colors -- seq )
     direction dim v* dim over v- swap
-    colors length dup 1 - v/n [ v*n ] with map
+    colors length [ iota ] [ 1 - ] bi v/n [ v*n ] with map
     swap [ over v+ 2array ] curry map
     concat concat >float-array ;
 
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 8cef10b06fc089b45bc3b0b29da1aebc7b2e66e1..b762e036e6c87bac6d0061e78c30b764e0d95b58 100644 (file)
@@ -36,7 +36,7 @@ TIP: "You can read documentation by pressing F1." ;
 
 TIP: "The listener tool remembers previous lines of input. Press " { $command interactor "completion" recall-previous } " and " { $command interactor "completion" recall-next } " to cycle through them." ;
 
-TIP: "When you mouse over certain objects, a block border will appear. Left-clicking on such an object will perform the default operation. Right-clicking will show a menu with all operations." ;
+TIP: "When you mouse over certain objects, a black border will appear. Left-clicking on such an object will perform the default operation. Right-clicking will show a menu with all operations." ;
 
 TIP: "The status bar displays stack effects of recognized words as they are being typed in." ;
 
index 11c2a48a2a5408900b03b538f9390eae9f4a36bb..5a92a4cea211c4d711cd7ad7f46b3ec4d8743f97 100644 (file)
@@ -20,8 +20,9 @@ TUPLE: node value children ;
         ] [
             [
                 [ children>> swap first head-slice % ]
-                [ tuck traverse-step traverse-to-path ]
-                2bi
+                [ nip ]
+                [ traverse-step traverse-to-path ]
+                2tri
             ] make-node
         ] if
     ] if ;
@@ -35,7 +36,9 @@ TUPLE: node value children ;
         ] [
             [
                 [ traverse-step traverse-from-path ]
-                [ tuck children>> swap first 1 + tail-slice % ] 2bi
+                [ nip ]
+                [ children>> swap first 1 + tail-slice % ]
+                2tri
             ] make-node
         ] if
     ] if ;
index 51ff4c2609c2fe1924dad9b0970486b680267bae..b55ea44c6bc8474082096191ae3a3cd6ef3eeae1 100644 (file)
@@ -2,7 +2,7 @@ USING: help.markup help.syntax strings quotations debugger
 namespaces ui.backend ui.gadgets ui.gadgets.worlds
 ui.gadgets.tracks ui.gadgets.packs ui.gadgets.grids
 ui.gadgets.private math.rectangles colors ui.text fonts
-kernel ui.private classes sequences ;
+kernel ui.private vocabs.loader classes sequences ;
 IN: ui
 
 HELP: windows
@@ -150,7 +150,9 @@ ARTICLE: "ui-windows" "Top-level windows"
 "When the gadget is removed from a parent shown in a top-level window, or when the top-level window is closed, a corresponding generic word is called to clean up:"
 { $subsections ungraft* }
 "The root of the gadget hierarchy in a window is a special gadget which is rarely operated on directly, but it is helpful to know it exists:"
-{ $subsections world } ;
+{ $subsections world }
+"There is also syntax for defining a main window as the entry point for a vocabulary:"
+{ $subsections POSTPONE: MAIN-WINDOW: } ;
 
 ARTICLE: "ui-backend" "Developing UI backends"
 "None of the words documented in this section should be called directly by user code. They are only of interest when developing new UI backends."
@@ -325,6 +327,20 @@ HELP: normal-title-bar
 HELP: textured-background
 { $description "Asks for a window to have a background that blends seamlessly with the window frame. Factor will leave the window background transparent and pass mouse button gestures not handled directly by a gadget through to the window system so that the window can be dragged from anywhere on its background." } ;
 
+HELP: MAIN-WINDOW:
+{ $syntax "MAIN-WINDOW: window-word { attributes }
+    attribute-code ;" }
+{ $description "Defines a " { $link POSTPONE: MAIN: } " word for the current vocabulary named " { $snippet "window-word" } " that opens a UI window when the vocabulary is " { $link run } ". The " { $snippet "attributes" } " specify the key-value pairs of the window's " { $link world-attributes } ". The " { $snippet "attribute-code" } " is run with the " { $snippet "world-attributes" } " on the stack; this allows the word to construct gadget objects to place in the " { $snippet "gadget" } " slot or set other runtime-dependent world attributes." }
+{ $examples
+"From the " { $vocab-link "hello-ui" } " vocabulary. Creates a window with the title \"Hi\" containing a label reading \"Hello world\":"
+{ $code
+"""USING: accessors ui ui.gadgets.labels ;
+IN: hello-ui
+
+MAIN-WINDOW: hello { { title "Hi" } }
+    "Hello world" <label> >>gadgets ;"""
+} } ;
+
 ARTICLE: "ui.gadgets.worlds-window-controls" "Window controls"
 "The following window controls can be placed in a " { $link world } " window:"
 { $subsections
index 6de303089efcde3e71f1ed38f1e18999e2090660..e0fa560935f35b551040fbb2c1cafe3d96a45011 100644 (file)
@@ -5,7 +5,7 @@ deques sequences threads words continuations init
 combinators combinators.short-circuit hashtables concurrency.flags
 sets accessors calendar fry destructors ui.gadgets ui.gadgets.private
 ui.gadgets.worlds ui.gadgets.tracks ui.gestures ui.backend ui.render
-strings ;
+strings classes.tuple classes.tuple.parser lexer vocabs.parser parser ;
 IN: ui
 
 <PRIVATE
@@ -236,9 +236,23 @@ M: object close-window
 [
     f \ ui-running set-global
     <flag> ui-notify-flag set-global
-] "ui" add-init-hook
+] "ui" add-startup-hook
 
 : with-ui ( quot -- )
     ui-running? [ call( -- ) ] [ '[ init-ui @ ] (with-ui) ] if ;
 
 HOOK: beep ui-backend ( -- )
+
+: parse-main-window-attributes ( class -- attributes )
+    "{" expect dup all-slots parse-tuple-literal-slots ;
+
+: define-main-window ( word attributes quot -- )
+    [
+        '[ [ f _ clone @ open-window ] with-ui ] (( -- )) define-declared
+    ] [ 2drop current-vocab (>>main) ] 3bi ;
+
+SYNTAX: MAIN-WINDOW:
+    CREATE
+    world-attributes parse-main-window-attributes
+    parse-definition
+    define-main-window ;
index bbce857681bd17540a928ce624a8eff2ffae4fd5..0311b43474860111105d812f62fe4b5eec0c9f97 100644 (file)
@@ -27,7 +27,12 @@ IN: unicode.breaks.tests
     utf8 file-lines
     [ "#" split1 drop ] map harvest [
         "÷" split
-        [ "×" split [ [ blank? ] trim hex> ] map harvest >string ] map
+        [
+            "×" split
+            [ [ blank? ] trim hex> ] map
+            [ { f 0 } member? not ] filter
+            >string
+        ] map
         harvest
     ] map ;
 
@@ -46,4 +51,4 @@ IN: unicode.breaks.tests
 grapheme-break-test parse-test-file [ >graphemes ] test
 word-break-test parse-test-file [ >words ] test
 
-[ { t f t t f t } ] [ 6 [ "as df" word-break-at? ] map ] unit-test
+[ { t f t t f t } ] [ 6 iota [ "as df" word-break-at? ] map ] unit-test
index 7c7b8a1f50771499672eb752680021570141ccd4..46651bd7de8c1f2a345c7dc742e115d3f403ce95 100644 (file)
@@ -74,14 +74,14 @@ SYMBOL: table
   
 : make-grapheme-table ( -- )
     { CR } { LF } connect
-    { Control CR LF } graphemes disconnect
-    graphemes { Control CR LF } disconnect
+    { Control CR LF } graphemes iota disconnect
+    graphemes iota { Control CR LF } disconnect
     { L } { L V LV LVT } connect
     { LV V } { V T } connect
     { LVT T } { T } connect
-    graphemes { Extend } connect
-    graphemes { SpacingMark } connect
-    { Prepend } graphemes connect ;
+    graphemes iota { Extend } connect
+    graphemes iota { SpacingMark } connect
+    { Prepend } graphemes iota connect ;
 
 VALUE: grapheme-table
 
@@ -154,8 +154,8 @@ SYMBOL: check-number-after
 
 : make-word-table ( -- )
     { wCR } { wLF } connect
-    { wNewline wCR wLF } words disconnect
-    words { wNewline wCR wLF } disconnect
+    { wNewline wCR wLF } words iota disconnect
+    words iota { wNewline wCR wLF } disconnect
     { wALetter } { wMidLetter wMidNumLet } check-letter-after set-table
     { wMidLetter wMidNumLet } { wALetter } check-letter-before set-table
     { wNumeric wALetter } { wNumeric wALetter } connect
@@ -252,7 +252,7 @@ PRIVATE>
     over tail-slice first-word + ;
 
 : last-word ( str -- i )
-    [ length ] keep '[ _ word-break-at? ] find-last drop 0 or ;
+    [ length iota ] keep '[ _ word-break-at? ] find-last drop 0 or ;
 
 : last-word-from ( end str -- i )
     swap head-slice last-word ;
old mode 100755 (executable)
new mode 100644 (file)
index ea0487c..dc3cd89
@@ -82,7 +82,7 @@ ducet insert-helpers
 \r
 : add ( char -- )\r
     dup blocked? [ 1string , ] [\r
-        dup possible-bases dup length\r
+        dup possible-bases dup length iota\r
         [ ?combine ] with with any?\r
         [ drop ] [ 1string , ] if\r
     ] if ;\r
index 1c6c6afdf35711473774469afc0cc9e116e0a907..24dfba6be02dab57ec4a1f89bd091c22d67b7529 100644 (file)
@@ -108,7 +108,8 @@ PRIVATE>
 
 : exclusions ( -- set )
     exclusions-file utf8 file-lines
-    [ "#" split1 drop [ blank? ] trim-tail hex> ] map harvest ;
+    [ "#" split1 drop [ blank? ] trim-tail hex> ] map
+    [ 0 = not ] filter ;
 
 : remove-exclusions ( alist -- alist )
     exclusions [ dup ] H{ } map>assoc assoc-diff ;
index 15b173c311d32095fb536132deb6533dfeb9cab2..6bef08abe3dc18224126c42c5bd7699d574825e2 100644 (file)
@@ -130,7 +130,7 @@ CONSTANT: _UTX_HOSTSIZE   256
 CONSTANT: _SS_MAXSIZE 128
 
 : _SS_ALIGNSIZE ( -- n )
-    "__int64_t" heap-size ; inline
+    __int64_t heap-size ; inline
     
 : _SS_PAD1SIZE ( -- n )
     _SS_ALIGNSIZE 2 - ; inline
index c4392c4c6da9ec3fb009c9d995fb4b58c992940a..02d9f370236d4d0135da2c688af99ebbdbd8e0d4 100644 (file)
@@ -23,7 +23,7 @@ GENERIC: group-struct ( obj -- group/f )
     gr_mem>> utf8 alien>strings ;
 
 : (group-struct) ( id -- group-struct id group-struct byte-array length void* )
-    \ unix:group <struct> tuck 4096
+    [ \ unix:group <struct> ] dip over 4096
     [ <byte-array> ] keep f <void*> ;
 
 : check-group-struct ( group-struct ptr -- group-struct/f )
index 4f5ac9930966cd4ee5acfebf1d58a285b79e928a..0a63965c20179fda605ac448a88183708c923ac9 100644 (file)
@@ -18,8 +18,8 @@ STRUCT: timespec
         swap >>usec
         swap >>sec ;
 
-: make-timespec ( us -- timespec )
-    1000000 /mod 1000 *
+: make-timespec ( nanos -- timespec )
+    1000000000 /mod
     timespec <struct>
         swap >>nsec
         swap >>sec ;
index 421efa60bc6d66d62f227f675366ca97bc7f207b..2bebc981f95baf00e39b5fae00747624ac972052 100644 (file)
@@ -21,5 +21,19 @@ TYPEDEF: __int32_t  blksize_t
 TYPEDEF: long       ssize_t
 TYPEDEF: __int32_t  pid_t
 TYPEDEF: long       time_t
+TYPEDEF: uint mach_port_t
+TYPEDEF: int kern_return_t
+TYPEDEF: int boolean_t
+TYPEDEF: mach_port_t io_object_t
+TYPEDEF: io_object_t io_iterator_t
+TYPEDEF: io_object_t io_registry_entry_t
+TYPEDEF: io_object_t io_service_t
+TYPEDEF: char[128] io_name_t
+TYPEDEF: char[512] io_string_t
+TYPEDEF: kern_return_t IOReturn
 
-ALIAS: <time_t> <long>
\ No newline at end of file
+TYPEDEF: uint IOOptionBits
+
+
+
+ALIAS: <time_t> <long>
index 7650e9962f64af74f762d0e4b6af93d02e777916..ec638e6f31933885128257c56c6ecdc9cbd0a9d4 100644 (file)
@@ -36,6 +36,7 @@ TYPEDEF: __uint64_t fsfilcnt_t
 TYPEDEF: fsfilcnt_t __fsfilcnt_t
 TYPEDEF: __uint64_t rlim_t
 TYPEDEF: uint32_t id_t
+TYPEDEF: long clockid_t
 
 C-TYPE: DIR
 C-TYPE: FILE
index 11792d91a72320eb80065fdcd0d7e6bd0ee12a31..e9cb9d59188aca5fc0ab8a95a883df54fffe770f 100644 (file)
@@ -1,11 +1,11 @@
-! Copyright (C) 2005, 2008 Slava Pestov.
+! Copyright (C) 2005, 2010 Slava Pestov.
 ! Copyright (C) 2008 Eduardo Cavazos.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: alien alien.c-types alien.syntax kernel libc
-sequences continuations byte-arrays strings math namespaces
-system combinators vocabs.loader accessors
-stack-checker macros locals generalizations unix.types
-io vocabs classes.struct unix.time ;
+USING: alien alien.c-types alien.syntax kernel libc sequences
+continuations byte-arrays strings math namespaces system
+combinators combinators.smart vocabs.loader accessors
+stack-checker macros locals generalizations unix.types io vocabs
+classes.struct unix.time alien.libraries ;
 IN: unix
 
 CONSTANT: PROT_NONE   0
@@ -48,7 +48,7 @@ ERROR: unix-error errno message ;
 ERROR: unix-system-call-error args errno message word ;
 
 MACRO:: unix-system-call ( quot -- )
-    quot infer in>> :> n
+    quot inputs :> n
     quot first :> word
     [
         n ndup quot call dup 0 < [
@@ -220,3 +220,4 @@ FUNCTION: int utimes ( char* path, timeval[2] times ) ;
 
 FUNCTION: ssize_t write ( int fd, void* buf, size_t nbytes ) ;
 
+"librt" "librt.so" "cdecl" add-library
index 89eb1cdebd48a923595818bfee3d8194d601ea93..8eadfb9cbfebff667807a7980f124ea31858522a 100644 (file)
@@ -1,5 +1,5 @@
 USING: unrolled-lists tools.test deques kernel sequences
-random prettyprint grouping ;
+random prettyprint grouping math ;
 IN: unrolled-lists.tests
 
 [ 1 ] [ <unrolled-list> 1 over push-front pop-front ] unit-test
@@ -35,14 +35,14 @@ IN: unrolled-lists.tests
 
 [ { 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 } ] [
     <unrolled-list>
-    32 [ over push-front ] each
+    32 [ over push-front ] each-integer
     32 [ dup pop-back ] replicate
     nip
 ] unit-test
 
 [ { 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 } ] [
     <unrolled-list>
-    32 [ over push-front ] each
+    32 [ over push-front ] each-integer
     32 [ dup pop-front ] replicate reverse
     nip
 ] unit-test
@@ -51,7 +51,7 @@ IN: unrolled-lists.tests
     <unrolled-list>
     1000 [ 1000 random ] replicate
     [ [ over push-front ] each ]
-    [ [ dup pop-back ] replicate ]
+    [ length [ dup pop-back ] replicate ]
     [ ]
     tri
     =
@@ -64,7 +64,7 @@ IN: unrolled-lists.tests
     [
         10 group [
             [ [ over push-front ] each ]
-            [ [ dup pop-back ] replicate ]
+            [ length [ dup pop-back ] replicate ]
             bi 
         ] map concat
     ] keep
index 4d284a1a40653ddeedbf61871bb57e50c654c7e1..118db67d907eed15410fa524f4dbe932637d6b70 100644 (file)
@@ -12,7 +12,7 @@ IN: uuid
     ! 0x01b21dd213814000L is the number of 100-ns intervals
     ! between the UUID epoch 1582-10-15 00:00:00 and the 
     ! Unix epoch 1970-01-01 00:00:00.
-    micros 10 * HEX: 01b21dd213814000 +
+    system-micros 10 * HEX: 01b21dd213814000 +
     [ -48 shift HEX: 0fff bitand ] 
     [ -32 shift HEX: ffff bitand ]
     [ HEX: ffffffff bitand ]
index f0ee13dd382c205cd55806fc3097a290463cc5ee..f2c5691452458497180028612a5185d87aeaf571 100644 (file)
@@ -9,7 +9,7 @@ IN: validators
     >lower "on" = ;
 
 : v-default ( str def -- str/def )
-    over empty? spin ? ;
+    [ nip empty? ] 2keep ? ;
 
 : v-required ( str -- str )
     dup empty? [ "required" throw ] when ;
index ba057edffa8f4a7ce4e6fc9ab4017d7e49e19921..cc4a291a8b089922fda2dd93bb77174c2e827e1d 100644 (file)
@@ -1,10 +1,23 @@
-! Copyright (C) 2009 Phil Dawes.
+! Copyright (C) 2009, 2010 Phil Dawes, Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: classes.struct alien.c-types alien.syntax ;
 IN: vm
 
-TYPEDEF: intptr_t cell
-C-TYPE: context
+TYPEDEF: uintptr_t cell
+
+STRUCT: context
+{ callstack-top void* }
+{ callstack-bottom void* }
+{ datastack cell }
+{ retainstack cell }
+{ magic-frame void* }
+{ datastack-region void* }
+{ retainstack-region void* }
+{ catchstack-save cell }
+{ current-callback-save cell }
+{ next context* } ;
+
+: context-field-offset ( field -- offset ) context offset-of ; inline
 
 STRUCT: zone
 { start cell }
@@ -13,11 +26,11 @@ STRUCT: zone
 { end cell } ;
 
 STRUCT: vm
-{ stack_chain context* }
+{ ctx context* }
 { nursery zone }
-{ cards_offset cell }
-{ decks_offset cell }
-{ userenv cell[70] } ;
+{ cards-offset cell }
+{ decks-offset cell }
+{ special-objects cell[70] } ;
 
 : vm-field-offset ( field -- offset ) vm offset-of ; inline
 
@@ -65,7 +78,7 @@ STRUCT: gc-event
 { data-sweep-time cell }
 { code-sweep-time cell }
 { compaction-time cell }
-{ temp-time cell } ;
+{ temp-time ulonglong } ;
 
 STRUCT: dispatch-statistics
 { megamorphic-cache-hits cell }
index 24ccd391f19dd00d4d93edee04cc4f3254f40cd6..1f62f02ddee23d0924f6231efc06309bf5abf67c 100644 (file)
@@ -18,4 +18,4 @@ M: cache-observer vocabs-changed drop reset-cache ;
 [
     f changed-vocabs set-global
     cache-observer add-vocab-observer
-] "vocabs.cache" add-init-hook
\ No newline at end of file
+] "vocabs.cache" add-startup-hook
index 1445b9f882e8788902a6ac15e6044b284a1a69e6..1bf73862e6b58b0da3dcff4cbe08a0c22d331df0 100644 (file)
@@ -56,4 +56,4 @@ TR: convert-separators "/\\" ".." ;
 [\r
     "-no-monitors" (command-line) member?\r
     [ start-monitor-thread ] unless\r
-] "vocabs.refresh.monitor" add-init-hook\r
+] "vocabs.refresh.monitor" add-startup-hook\r
old mode 100755 (executable)
new mode 100644 (file)
index ae8ef62c1631d7272efe80fa532ab3b76a33e789..329a84ef137de327c06e94e8734c5fd2ed094df7 100644 (file)
@@ -1,7 +1,7 @@
 USING: kernel windows.com windows.com.syntax windows.ole32
-alien alien.syntax tools.test libc alien.c-types 
+alien alien.syntax tools.test libc alien.c-types
 namespaces arrays continuations accessors math windows.com.wrapper
-windows.com.wrapper.private destructors effects ;
+windows.com.wrapper.private destructors effects compiler.units ;
 IN: windows.com.tests
 
 COM-INTERFACE: ISimple IUnknown {216fb341-0eb2-44b1-8edb-60b76e353abc}
@@ -34,68 +34,70 @@ SYMBOL: +orig-wrapped-objects+
 +wrapped-objects+ get-global clone +orig-wrapped-objects+ set-global
 
 TUPLE: test-implementation x ;
-C: <test-implementation> test-implementation 
-
-{
-    { IInherited {
-        [ drop S_OK ] ! ISimple::returnOK
-        [ drop E_FAIL ] ! ISimple::returnError
-        [ x>> ] ! IInherited::getX
-        [ >>x drop ] ! IInherited::setX
-    } }
-    { IUnrelated {
-        [ swap x>> + ] ! IUnrelated::xPlus
-        [ spin x>> * + ] ! IUnrelated::xMulAdd
-    } }
-} <com-wrapper>
-dup +test-wrapper+ set [
-
-    0 <test-implementation> swap com-wrap
-    dup +guinea-pig-implementation+ set [ drop
-
-        S_OK 1array [ +guinea-pig-implementation+ get ISimple::returnOK ] unit-test
-        E_FAIL <long> *long 1array [ +guinea-pig-implementation+ get ISimple::returnError ] unit-test
-        20 1array [
-            +guinea-pig-implementation+ get
-            [ 20 IInherited::setX ]
-            [ IInherited::getX ] bi
-        ] unit-test
-        420 1array [
-            +guinea-pig-implementation+ get
-            IUnrelated-iid com-query-interface
-            [ 20 20 IUnrelated::xMulAdd ] with-com-interface
-        ] unit-test
-        40 1array [
-            +guinea-pig-implementation+ get
-            IUnrelated-iid com-query-interface
-            [ 20 IUnrelated::xPlus ] with-com-interface
-        ] unit-test
-
-        +guinea-pig-implementation+ get 1array [
-            +guinea-pig-implementation+ get com-add-ref
-        ] unit-test
-
-        { } [ +guinea-pig-implementation+ get com-release ] unit-test
-
-        +guinea-pig-implementation+ get 1array [
-            +guinea-pig-implementation+ get IUnknown-iid com-query-interface
-            dup com-release
-        ] unit-test
-        +guinea-pig-implementation+ get 1array [
-            +guinea-pig-implementation+ get ISimple-iid com-query-interface
-            dup com-release
-        ] unit-test
-        void* heap-size +guinea-pig-implementation+ get <displaced-alien>
-        +guinea-pig-implementation+ get
-        2array [
-            +guinea-pig-implementation+ get IUnrelated-iid com-query-interface
-            dup ISimple-iid com-query-interface
-            over com-release dup com-release
-        ] unit-test
-
-    ] with-com-interface
-
-] with-disposal
+C: <test-implementation> test-implementation
+
+[
+    {
+        { IInherited {
+            [ drop S_OK ] ! ISimple::returnOK
+            [ drop E_FAIL ] ! ISimple::returnError
+            [ x>> ] ! IInherited::getX
+            [ >>x drop ] ! IInherited::setX
+        } }
+        { IUnrelated {
+            [ [ x>> ] [ + ] bi* ] ! IUnrelated::xPlus
+            [ [ x>> ] [ * ] [ + ] tri* ] ! IUnrelated::xMulAdd
+        } }
+    } <com-wrapper>
+    dup +test-wrapper+ set [
+
+        0 <test-implementation> swap com-wrap
+        dup +guinea-pig-implementation+ set [ drop
+
+            S_OK 1array [ +guinea-pig-implementation+ get ISimple::returnOK ] unit-test
+            E_FAIL <long> *long 1array [ +guinea-pig-implementation+ get ISimple::returnError ] unit-test
+            20 1array [
+                +guinea-pig-implementation+ get
+                [ 20 IInherited::setX ]
+                [ IInherited::getX ] bi
+            ] unit-test
+            420 1array [
+                +guinea-pig-implementation+ get
+                IUnrelated-iid com-query-interface
+                [ 20 20 IUnrelated::xMulAdd ] with-com-interface
+            ] unit-test
+            40 1array [
+                +guinea-pig-implementation+ get
+                IUnrelated-iid com-query-interface
+                [ 20 IUnrelated::xPlus ] with-com-interface
+            ] unit-test
+
+            +guinea-pig-implementation+ get 1array [
+                +guinea-pig-implementation+ get com-add-ref
+            ] unit-test
+
+            { } [ +guinea-pig-implementation+ get com-release ] unit-test
+
+            +guinea-pig-implementation+ get 1array [
+                +guinea-pig-implementation+ get IUnknown-iid com-query-interface
+                dup com-release
+            ] unit-test
+            +guinea-pig-implementation+ get 1array [
+                +guinea-pig-implementation+ get ISimple-iid com-query-interface
+                dup com-release
+            ] unit-test                                              
+            void* heap-size +guinea-pig-implementation+ get <displaced-alien>
+            +guinea-pig-implementation+ get                                           
+            2array [
+                +guinea-pig-implementation+ get IUnrelated-iid com-query-interface
+                dup ISimple-iid com-query-interface
+                over com-release dup com-release
+            ] unit-test
+
+        ] with-com-interface
+
+    ] with-disposal
+] with-compilation-unit
 
 ! Ensure that we freed +guinea-pig-implementation
 +orig-wrapped-objects+ get-global 1array [ +wrapped-objects+ get-global ] unit-test
old mode 100755 (executable)
new mode 100644 (file)
index 9628b89..33164f5
@@ -35,7 +35,7 @@ FUNCTION: void ReleaseStgMedium ( LPSTGMEDIUM pmedium ) ;
 
 : com-query-interface ( interface iid -- interface' )
     [
-        "void*" malloc-object &free
+        void* malloc-object &free
         [ IUnknown::QueryInterface ole32-error ] keep *void*
     ] with-destructors ;
 
old mode 100755 (executable)
new mode 100644 (file)
index 6a6f6f2bb44ec8dd73699a55e786fc36d37a3fbd..0298e80445fb27436bbc003c72329404e3db2dc9 100644 (file)
@@ -27,8 +27,8 @@ COM-INTERFACE: IUnrelated IUnknown {b06ac3f4-30e4-406b-a7cd-c29cead4552c}
         [ >>x drop ]     ! IInherited::setX\r
     } }\r
     { "IUnrelated" {\r
-        [ swap x>> + ]   ! IUnrelated::xPlus\r
-        [ spin x>> * + ] ! IUnrealted::xMulAdd\r
+        [ [ x>> ] [ + ] bi* ]   ! IUnrelated::xPlus\r
+        [ [ x>> ] [ * ] [ + ] tri* ] ! IUnrealted::xMulAdd\r
     } }\r
 } <com-wrapper>""" } ;\r
 \r
old mode 100755 (executable)
new mode 100644 (file)
index 39f5ce1..6969024
@@ -141,11 +141,11 @@ unless
     dup callbacks>> (callbacks>vtbls) >>vtbls
     f >>disposed drop ;
 
-: (init-hook) ( -- )
+: com-startup-hook ( -- )
     +live-wrappers+ get-global [ (allocate-wrapper) ] each
     H{ } +wrapped-objects+ set-global ;
 
-[ (init-hook) ] "windows.com.wrapper" add-init-hook
+[ com-startup-hook ] "windows.com.wrapper" add-startup-hook
 
 PRIVATE>
 
diff --git a/basis/windows/dinput/authors.txt b/basis/windows/dinput/authors.txt
deleted file mode 100755 (executable)
index f13c9c1..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Joe Groff
diff --git a/basis/windows/dinput/constants/constants-tests.factor b/basis/windows/dinput/constants/constants-tests.factor
deleted file mode 100644 (file)
index 6778584..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-IN: windows.dinput.constants.tests
-USING: tools.test windows.dinput.constants.private ;
-
-[ ] [ define-constants ] unit-test
-[ ] [ free-dinput-constants ] unit-test
\ No newline at end of file
diff --git a/basis/windows/dinput/constants/constants.factor b/basis/windows/dinput/constants/constants.factor
deleted file mode 100755 (executable)
index adbf29d..0000000
+++ /dev/null
@@ -1,853 +0,0 @@
-USING: windows.dinput windows.kernel32 windows.ole32 windows.com
-windows.com.syntax alien alien.c-types alien.data alien.syntax
-kernel system namespaces combinators sequences fry math accessors
-macros words quotations libc continuations generalizations
-splitting locals assocs init specialized-arrays memoize
-classes.struct strings arrays ;
-SPECIALIZED-ARRAY: DIOBJECTDATAFORMAT
-IN: windows.dinput.constants
-
-! Some global variables aren't provided by the DirectInput DLL (they're in the
-! dinput8.lib import library), so we lovingly hand-craft equivalent values here
-
-SYMBOLS:
-    GUID_XAxis_malloced GUID_YAxis_malloced GUID_ZAxis_malloced
-    GUID_RxAxis_malloced GUID_RyAxis_malloced GUID_RzAxis_malloced
-    GUID_Slider_malloced GUID_Button_malloced GUID_Key_malloced GUID_POV_malloced GUID_Unknown_malloced
-    GUID_SysMouse_malloced GUID_SysKeyboard_malloced GUID_Joystick_malloced GUID_SysMouseEm_malloced
-    GUID_SysMouseEm2_malloced GUID_SysKeyboardEm_malloced GUID_SysKeyboardEm2_malloced
-    c_dfDIKeyboard c_dfDIKeyboard_HID c_dfDIMouse2 c_dfDIJoystick2 ;
-
-<PRIVATE
-
-MEMO: c-type* ( name -- c-type ) c-type ;
-MEMO: heap-size* ( c-type -- n ) heap-size ;
-
-GENERIC: array-base-type ( c-type -- c-type' )
-M: object array-base-type ;
-M: string array-base-type "[" split1 drop ;
-M: array array-base-type first ;
-
-: (field-spec-of) ( field struct -- field-spec )
-    c-type* fields>> [ name>> = ] with find nip ;
-: (offsetof) ( field struct -- offset )
-    [ (field-spec-of) offset>> ] [ drop 0 ] if* ;
-: (sizeof) ( field struct -- size )
-    [ (field-spec-of) type>> array-base-type heap-size* ] [ drop 1 ] if* ;
-
-: (flag) ( thing -- integer )
-    {
-        { [ dup word? ] [ execute( -- value ) ] }
-        { [ dup callable? ] [ call( -- value ) ] }
-        [ ]
-    } cond ;
-
-: (flags) ( array -- n )
-    0 [ (flag) bitor ] reduce ;
-
-: <DIOBJECTDATAFORMAT> ( struct {pguid-var,field,index,dwType-flags,dwFlags} -- alien )
-    {
-        [ first dup word? [ get ] when ]
-        [ second rot [ (offsetof) ] [ (sizeof) ] 2bi ]
-        [ third * + ]
-        [ fourth (flags) ]
-        [ 4 swap nth (flag) ]
-    } cleave
-    DIOBJECTDATAFORMAT <struct-boa> ;
-
-:: make-DIOBJECTDATAFORMAT-array ( struct array -- alien )
-    array length malloc-DIOBJECTDATAFORMAT-array :> alien
-    array [| args i |
-        struct args <DIOBJECTDATAFORMAT>
-        i alien set-nth
-    ] each-index
-    alien ;
-
-: <DIDATAFORMAT> ( dwFlags dwDataSize struct rgodf-array -- alien )
-    [ DIDATAFORMAT heap-size DIOBJECTDATAFORMAT heap-size ] 4 ndip
-    [ nip length ] [ make-DIOBJECTDATAFORMAT-array ] 2bi
-    DIDATAFORMAT <struct-boa> ;
-
-: initialize ( symbol quot -- )
-    call swap set-global ; inline
-
-: (malloc-guid-symbol) ( symbol guid -- )
-    '[
-        _ execute( -- value )
-        [ byte-length malloc ] [ over byte-array>memory ] bi
-    ] initialize ;
-
-: define-guid-constants ( -- )
-    {
-        { GUID_XAxis_malloced          GUID_XAxis }
-        { GUID_YAxis_malloced          GUID_YAxis }
-        { GUID_ZAxis_malloced          GUID_ZAxis }
-        { GUID_RxAxis_malloced         GUID_RxAxis }
-        { GUID_RyAxis_malloced         GUID_RyAxis }
-        { GUID_RzAxis_malloced         GUID_RzAxis }
-        { GUID_Slider_malloced         GUID_Slider }
-        { GUID_Button_malloced         GUID_Button }
-        { GUID_Key_malloced            GUID_Key }
-        { GUID_POV_malloced            GUID_POV }
-        { GUID_Unknown_malloced        GUID_Unknown }
-        { GUID_SysMouse_malloced       GUID_SysMouse }
-        { GUID_SysKeyboard_malloced    GUID_SysKeyboard }
-        { GUID_Joystick_malloced       GUID_Joystick }
-        { GUID_SysMouseEm_malloced     GUID_SysMouseEm }
-        { GUID_SysMouseEm2_malloced    GUID_SysMouseEm2 }
-        { GUID_SysKeyboardEm_malloced  GUID_SysKeyboardEm }
-        { GUID_SysKeyboardEm2_malloced GUID_SysKeyboardEm2 }
-    } [ first2 (malloc-guid-symbol) ] each ;
-
-: define-joystick-format-constant ( -- )
-    c_dfDIJoystick2 [
-        DIDF_ABSAXIS
-        "DIJOYSTATE2" heap-size
-        "DIJOYSTATE2" {
-            { GUID_XAxis_malloced  "lX"           0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
-            { GUID_YAxis_malloced  "lY"           0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
-            { GUID_ZAxis_malloced  "lZ"           0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
-            { GUID_RxAxis_malloced "lRx"          0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
-            { GUID_RyAxis_malloced "lRy"          0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
-            { GUID_RzAxis_malloced "lRz"          0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
-            { GUID_Slider_malloced "rglSlider"    0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
-            { GUID_Slider_malloced "rglSlider"    1 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
-            { GUID_POV_malloced    "rgdwPOV"      0 { DIDFT_OPTIONAL DIDFT_POV    DIDFT_ANYINSTANCE } 0 }
-            { GUID_POV_malloced    "rgdwPOV"      1 { DIDFT_OPTIONAL DIDFT_POV    DIDFT_ANYINSTANCE } 0 }
-            { GUID_POV_malloced    "rgdwPOV"      2 { DIDFT_OPTIONAL DIDFT_POV    DIDFT_ANYINSTANCE } 0 }
-            { GUID_POV_malloced    "rgdwPOV"      3 { DIDFT_OPTIONAL DIDFT_POV    DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"   0 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"   1 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"   2 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"   3 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"   4 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"   5 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"   6 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"   7 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"   8 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"   9 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  10 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  11 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  12 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  13 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  14 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  15 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  16 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  17 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  18 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  19 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  20 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  21 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  22 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  23 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  24 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  25 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  26 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  27 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  28 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  29 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  30 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  31 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  32 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  33 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  34 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  35 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  36 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  37 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  38 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  39 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  40 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  41 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  42 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  43 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  44 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  45 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  46 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  47 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  48 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  49 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  50 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  51 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  52 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  53 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  54 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  55 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  56 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  57 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  58 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  59 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  60 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  61 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  62 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  63 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  64 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  65 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  66 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  67 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  68 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  69 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  70 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  71 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  72 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  73 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  74 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  75 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  76 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  77 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  78 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  79 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  80 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  81 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  82 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  83 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  84 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  85 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  86 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  87 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  88 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  89 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  90 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  91 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  92 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  93 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  94 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  95 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  96 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  97 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  98 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons"  99 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons" 100 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons" 101 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons" 102 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons" 103 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons" 104 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons" 105 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons" 106 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons" 107 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons" 108 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons" 109 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons" 110 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons" 111 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons" 112 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons" 113 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons" 114 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons" 115 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons" 116 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons" 117 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons" 118 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons" 119 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons" 120 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons" 121 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons" 122 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons" 123 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons" 124 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons" 125 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons" 126 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { f           "rgbButtons" 127 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
-            { GUID_XAxis_malloced  "lVX"          0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } DIDOI_ASPECTVELOCITY }
-            { GUID_YAxis_malloced  "lVY"          0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } DIDOI_ASPECTVELOCITY }
-            { GUID_ZAxis_malloced  "lVZ"          0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } DIDOI_ASPECTVELOCITY }
-            { GUID_RxAxis_malloced "lVRx"         0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } DIDOI_ASPECTVELOCITY }
-            { GUID_RyAxis_malloced "lVRy"         0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } DIDOI_ASPECTVELOCITY }
-            { GUID_RzAxis_malloced "lVRz"         0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } DIDOI_ASPECTVELOCITY }
-            { GUID_Slider_malloced "rglVSlider"   0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } DIDOI_ASPECTVELOCITY }
-            { GUID_Slider_malloced "rglVSlider"   1 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } DIDOI_ASPECTVELOCITY }
-            { GUID_XAxis_malloced  "lAX"          0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } DIDOI_ASPECTACCEL }
-            { GUID_YAxis_malloced  "lAY"          0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } DIDOI_ASPECTACCEL }
-            { GUID_ZAxis_malloced  "lAZ"          0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } DIDOI_ASPECTACCEL }
-            { GUID_RxAxis_malloced "lARx"         0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } DIDOI_ASPECTACCEL }
-            { GUID_RyAxis_malloced "lARy"         0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } DIDOI_ASPECTACCEL }
-            { GUID_RzAxis_malloced "lARz"         0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } DIDOI_ASPECTACCEL }
-            { GUID_Slider_malloced "rglASlider"   0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } DIDOI_ASPECTACCEL }
-            { GUID_Slider_malloced "rglASlider"   1 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } DIDOI_ASPECTACCEL }
-            { GUID_XAxis_malloced  "lFX"          0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } DIDOI_ASPECTFORCE }
-            { GUID_YAxis_malloced  "lFY"          0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } DIDOI_ASPECTFORCE }
-            { GUID_ZAxis_malloced  "lFZ"          0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } DIDOI_ASPECTFORCE }
-            { GUID_RxAxis_malloced "lFRx"         0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } DIDOI_ASPECTFORCE }
-            { GUID_RyAxis_malloced "lFRy"         0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } DIDOI_ASPECTFORCE }
-            { GUID_RzAxis_malloced "lFRz"         0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } DIDOI_ASPECTFORCE }
-            { GUID_Slider_malloced "rglFSlider"   0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } DIDOI_ASPECTFORCE }
-            { GUID_Slider_malloced "rglFSlider"   1 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } DIDOI_ASPECTFORCE }
-        } <DIDATAFORMAT>
-    ] initialize ;
-
-: define-mouse-format-constant ( -- )
-    c_dfDIMouse2 [
-        DIDF_RELAXIS
-        "DIMOUSESTATE2" heap-size
-        "DIMOUSESTATE2" {
-            { GUID_XAxis_malloced  "lX"         0 {                DIDFT_ANYINSTANCE DIDFT_AXIS   } 0 }
-            { GUID_YAxis_malloced  "lY"         0 {                DIDFT_ANYINSTANCE DIDFT_AXIS   } 0 }
-            { GUID_ZAxis_malloced  "lZ"         0 { DIDFT_OPTIONAL DIDFT_ANYINSTANCE DIDFT_AXIS   } 0 }
-            { GUID_Button_malloced "rgbButtons" 0 {                DIDFT_ANYINSTANCE DIDFT_BUTTON } 0 }
-            { GUID_Button_malloced "rgbButtons" 1 {                DIDFT_ANYINSTANCE DIDFT_BUTTON } 0 }
-            { GUID_Button_malloced "rgbButtons" 2 { DIDFT_OPTIONAL DIDFT_ANYINSTANCE DIDFT_BUTTON } 0 }
-            { GUID_Button_malloced "rgbButtons" 3 { DIDFT_OPTIONAL DIDFT_ANYINSTANCE DIDFT_BUTTON } 0 }
-            { GUID_Button_malloced "rgbButtons" 4 { DIDFT_OPTIONAL DIDFT_ANYINSTANCE DIDFT_BUTTON } 0 }
-            { GUID_Button_malloced "rgbButtons" 5 { DIDFT_OPTIONAL DIDFT_ANYINSTANCE DIDFT_BUTTON } 0 }
-            { GUID_Button_malloced "rgbButtons" 6 { DIDFT_OPTIONAL DIDFT_ANYINSTANCE DIDFT_BUTTON } 0 }
-            { GUID_Button_malloced "rgbButtons" 7 { DIDFT_OPTIONAL DIDFT_ANYINSTANCE DIDFT_BUTTON } 0 }
-        } <DIDATAFORMAT>
-    ] initialize ;
-
-! Not a standard DirectInput format. Included for cross-platform niceness.
-! This format returns the keyboard keys in USB HID order rather than Windows
-! order
-: define-hid-keyboard-format-constant ( -- )
-    c_dfDIKeyboard_HID [
-        DIDF_RELAXIS
-        256
-        f {
-            { GUID_Key_malloced f   0 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f   1 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f   2 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f   3 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f   4 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_A DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f   5 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_B DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f   6 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_C DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f   7 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_D DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f   8 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_E DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f   9 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_F DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  10 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_G DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  11 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_H DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  12 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_I DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  13 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_J DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  14 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_K DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  15 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_L DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  16 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_M DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  17 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_N DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  18 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_O DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  19 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_P DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  20 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_Q DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  21 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_R DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  22 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_S DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  23 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_T DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  24 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_U DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  25 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_V DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  26 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_W DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  27 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_X DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  28 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_Y DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  29 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_Z DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  30 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_1 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  31 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_2 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  32 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_3 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  33 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_4 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  34 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_5 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  35 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_6 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  36 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_7 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  37 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_8 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  38 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_9 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  39 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  40 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_RETURN DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  41 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_ESCAPE DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  42 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_BACK DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  43 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_TAB DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  44 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_SPACE DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  45 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_MINUS DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  46 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_EQUALS DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  47 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_LBRACKET DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  48 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_RBRACKET DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  49 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_BACKSLASH DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  50 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  51 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_SEMICOLON DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  52 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_APOSTROPHE DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  53 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_GRAVE DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  54 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_COMMA  DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  55 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_PERIOD DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  56 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_SLASH  DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  57 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_CAPITAL DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  58 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_F1 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  59 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_F2 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  60 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_F3 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  61 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_F4 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  62 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_F5 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  63 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_F6 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  64 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_F7 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  65 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_F8 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  66 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_F9 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  67 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_F10 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  68 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_F11 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  69 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_F12 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  70 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_SYSRQ DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  71 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_SCROLL DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  72 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_PAUSE DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  73 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_INSERT DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  74 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_HOME DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  75 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_PRIOR DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  76 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_DELETE DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  77 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_END DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  78 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_NEXT DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  79 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_RIGHT DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  80 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_LEFT DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  81 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_DOWN DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  82 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_UP DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  83 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_NUMLOCK DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  84 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_DIVIDE DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  85 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_MULTIPLY DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  86 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_SUBTRACT DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  87 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_ADD DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  88 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_NUMPADENTER DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  89 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_NUMPAD1 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  90 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_NUMPAD2 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  91 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_NUMPAD3 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  92 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_NUMPAD4 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  93 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_NUMPAD5 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  94 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_NUMPAD6 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  95 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_NUMPAD7 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  96 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_NUMPAD8 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  97 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_NUMPAD9 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  98 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_NUMPAD0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  99 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_DECIMAL DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 100 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_OEM_102 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 101 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_APPS DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 102 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_POWER DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 103 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_NUMPADEQUALS DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 104 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_F13 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 105 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_F14 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 106 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_F15 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 107 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 108 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 109 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 110 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 111 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 112 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 113 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 114 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 115 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 116 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 117 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 118 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 119 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 120 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 121 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 122 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 123 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 124 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 125 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 126 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 127 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_MUTE DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 128 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_VOLUMEUP DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 129 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_VOLUMEDOWN DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 130 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 131 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 132 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 133 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_ABNT_C2 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 134 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 135 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_ABNT_C1 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 136 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_KANA DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 137 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_YEN DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 138 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_CONVERT DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 139 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_NOCONVERT DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 140 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 141 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 142 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 143 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 144 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 145 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 146 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 147 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 148 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 149 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 150 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 151 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 152 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 153 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 154 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 155 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 156 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 157 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 158 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 159 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 160 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 161 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 162 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 163 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 164 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 165 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 166 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 167 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 168 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 169 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 170 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 171 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 172 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 173 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 174 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 175 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 176 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 177 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 178 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 179 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 180 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 181 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 182 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 183 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 184 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 185 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 186 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 187 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 188 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 189 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 190 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 191 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 192 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 193 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 194 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 195 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 196 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 197 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 198 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 199 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 200 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 201 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 202 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 203 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 204 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 205 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 206 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 207 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 208 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 209 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 210 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 211 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 212 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 213 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 214 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 215 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 216 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 217 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 218 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 219 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 220 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 221 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 222 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 223 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 224 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_LCONTROL DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 225 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_LSHIFT DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 226 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_LMENU DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 227 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_LWIN DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 228 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_RCONTROL DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 229 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_RSHIFT DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 230 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_RMENU DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 231 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_RWIN DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 232 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 233 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 234 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 235 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 236 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 237 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 238 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 239 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 240 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 241 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 242 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 243 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 244 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 245 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 246 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 247 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 248 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 249 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 250 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 251 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 252 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 253 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 254 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 255 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
-        } <DIDATAFORMAT>
-    ] initialize ;
-
-: define-keyboard-format-constant ( -- )
-    c_dfDIKeyboard [
-        DIDF_RELAXIS
-        256
-        f {
-            { GUID_Key_malloced f   0 { DIDFT_OPTIONAL DIDFT_BUTTON [   0 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f   1 { DIDFT_OPTIONAL DIDFT_BUTTON [   1 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f   2 { DIDFT_OPTIONAL DIDFT_BUTTON [   2 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f   3 { DIDFT_OPTIONAL DIDFT_BUTTON [   3 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f   4 { DIDFT_OPTIONAL DIDFT_BUTTON [   4 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f   5 { DIDFT_OPTIONAL DIDFT_BUTTON [   5 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f   6 { DIDFT_OPTIONAL DIDFT_BUTTON [   6 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f   7 { DIDFT_OPTIONAL DIDFT_BUTTON [   7 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f   8 { DIDFT_OPTIONAL DIDFT_BUTTON [   8 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f   9 { DIDFT_OPTIONAL DIDFT_BUTTON [   9 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  10 { DIDFT_OPTIONAL DIDFT_BUTTON [  10 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  11 { DIDFT_OPTIONAL DIDFT_BUTTON [  11 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  12 { DIDFT_OPTIONAL DIDFT_BUTTON [  12 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  13 { DIDFT_OPTIONAL DIDFT_BUTTON [  13 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  14 { DIDFT_OPTIONAL DIDFT_BUTTON [  14 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  15 { DIDFT_OPTIONAL DIDFT_BUTTON [  15 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  16 { DIDFT_OPTIONAL DIDFT_BUTTON [  16 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  17 { DIDFT_OPTIONAL DIDFT_BUTTON [  17 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  18 { DIDFT_OPTIONAL DIDFT_BUTTON [  18 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  19 { DIDFT_OPTIONAL DIDFT_BUTTON [  19 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  20 { DIDFT_OPTIONAL DIDFT_BUTTON [  20 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  21 { DIDFT_OPTIONAL DIDFT_BUTTON [  21 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  22 { DIDFT_OPTIONAL DIDFT_BUTTON [  22 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  23 { DIDFT_OPTIONAL DIDFT_BUTTON [  23 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  24 { DIDFT_OPTIONAL DIDFT_BUTTON [  24 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  25 { DIDFT_OPTIONAL DIDFT_BUTTON [  25 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  26 { DIDFT_OPTIONAL DIDFT_BUTTON [  26 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  27 { DIDFT_OPTIONAL DIDFT_BUTTON [  27 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  28 { DIDFT_OPTIONAL DIDFT_BUTTON [  28 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  29 { DIDFT_OPTIONAL DIDFT_BUTTON [  29 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  30 { DIDFT_OPTIONAL DIDFT_BUTTON [  30 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  31 { DIDFT_OPTIONAL DIDFT_BUTTON [  31 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  32 { DIDFT_OPTIONAL DIDFT_BUTTON [  32 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  33 { DIDFT_OPTIONAL DIDFT_BUTTON [  33 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  34 { DIDFT_OPTIONAL DIDFT_BUTTON [  34 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  35 { DIDFT_OPTIONAL DIDFT_BUTTON [  35 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  36 { DIDFT_OPTIONAL DIDFT_BUTTON [  36 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  37 { DIDFT_OPTIONAL DIDFT_BUTTON [  37 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  38 { DIDFT_OPTIONAL DIDFT_BUTTON [  38 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  39 { DIDFT_OPTIONAL DIDFT_BUTTON [  39 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  40 { DIDFT_OPTIONAL DIDFT_BUTTON [  40 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  41 { DIDFT_OPTIONAL DIDFT_BUTTON [  41 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  42 { DIDFT_OPTIONAL DIDFT_BUTTON [  42 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  43 { DIDFT_OPTIONAL DIDFT_BUTTON [  43 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  44 { DIDFT_OPTIONAL DIDFT_BUTTON [  44 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  45 { DIDFT_OPTIONAL DIDFT_BUTTON [  45 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  46 { DIDFT_OPTIONAL DIDFT_BUTTON [  46 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  47 { DIDFT_OPTIONAL DIDFT_BUTTON [  47 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  48 { DIDFT_OPTIONAL DIDFT_BUTTON [  48 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  49 { DIDFT_OPTIONAL DIDFT_BUTTON [  49 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  50 { DIDFT_OPTIONAL DIDFT_BUTTON [  50 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  51 { DIDFT_OPTIONAL DIDFT_BUTTON [  51 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  52 { DIDFT_OPTIONAL DIDFT_BUTTON [  52 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  53 { DIDFT_OPTIONAL DIDFT_BUTTON [  53 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  54 { DIDFT_OPTIONAL DIDFT_BUTTON [  54 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  55 { DIDFT_OPTIONAL DIDFT_BUTTON [  55 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  56 { DIDFT_OPTIONAL DIDFT_BUTTON [  56 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  57 { DIDFT_OPTIONAL DIDFT_BUTTON [  57 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  58 { DIDFT_OPTIONAL DIDFT_BUTTON [  58 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  59 { DIDFT_OPTIONAL DIDFT_BUTTON [  59 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  60 { DIDFT_OPTIONAL DIDFT_BUTTON [  60 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  61 { DIDFT_OPTIONAL DIDFT_BUTTON [  61 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  62 { DIDFT_OPTIONAL DIDFT_BUTTON [  62 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  63 { DIDFT_OPTIONAL DIDFT_BUTTON [  63 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  64 { DIDFT_OPTIONAL DIDFT_BUTTON [  64 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  65 { DIDFT_OPTIONAL DIDFT_BUTTON [  65 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  66 { DIDFT_OPTIONAL DIDFT_BUTTON [  66 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  67 { DIDFT_OPTIONAL DIDFT_BUTTON [  67 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  68 { DIDFT_OPTIONAL DIDFT_BUTTON [  68 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  69 { DIDFT_OPTIONAL DIDFT_BUTTON [  69 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  70 { DIDFT_OPTIONAL DIDFT_BUTTON [  70 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  71 { DIDFT_OPTIONAL DIDFT_BUTTON [  71 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  72 { DIDFT_OPTIONAL DIDFT_BUTTON [  72 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  73 { DIDFT_OPTIONAL DIDFT_BUTTON [  73 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  74 { DIDFT_OPTIONAL DIDFT_BUTTON [  74 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  75 { DIDFT_OPTIONAL DIDFT_BUTTON [  75 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  76 { DIDFT_OPTIONAL DIDFT_BUTTON [  76 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  77 { DIDFT_OPTIONAL DIDFT_BUTTON [  77 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  78 { DIDFT_OPTIONAL DIDFT_BUTTON [  78 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  79 { DIDFT_OPTIONAL DIDFT_BUTTON [  79 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  80 { DIDFT_OPTIONAL DIDFT_BUTTON [  80 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  81 { DIDFT_OPTIONAL DIDFT_BUTTON [  81 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  82 { DIDFT_OPTIONAL DIDFT_BUTTON [  82 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  83 { DIDFT_OPTIONAL DIDFT_BUTTON [  83 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  84 { DIDFT_OPTIONAL DIDFT_BUTTON [  84 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  85 { DIDFT_OPTIONAL DIDFT_BUTTON [  85 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  86 { DIDFT_OPTIONAL DIDFT_BUTTON [  86 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  87 { DIDFT_OPTIONAL DIDFT_BUTTON [  87 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  88 { DIDFT_OPTIONAL DIDFT_BUTTON [  88 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  89 { DIDFT_OPTIONAL DIDFT_BUTTON [  89 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  90 { DIDFT_OPTIONAL DIDFT_BUTTON [  90 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  91 { DIDFT_OPTIONAL DIDFT_BUTTON [  91 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  92 { DIDFT_OPTIONAL DIDFT_BUTTON [  92 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  93 { DIDFT_OPTIONAL DIDFT_BUTTON [  93 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  94 { DIDFT_OPTIONAL DIDFT_BUTTON [  94 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  95 { DIDFT_OPTIONAL DIDFT_BUTTON [  95 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  96 { DIDFT_OPTIONAL DIDFT_BUTTON [  96 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  97 { DIDFT_OPTIONAL DIDFT_BUTTON [  97 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  98 { DIDFT_OPTIONAL DIDFT_BUTTON [  98 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f  99 { DIDFT_OPTIONAL DIDFT_BUTTON [  99 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 100 { DIDFT_OPTIONAL DIDFT_BUTTON [ 100 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 101 { DIDFT_OPTIONAL DIDFT_BUTTON [ 101 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 102 { DIDFT_OPTIONAL DIDFT_BUTTON [ 102 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 103 { DIDFT_OPTIONAL DIDFT_BUTTON [ 103 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 104 { DIDFT_OPTIONAL DIDFT_BUTTON [ 104 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 105 { DIDFT_OPTIONAL DIDFT_BUTTON [ 105 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 106 { DIDFT_OPTIONAL DIDFT_BUTTON [ 106 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 107 { DIDFT_OPTIONAL DIDFT_BUTTON [ 107 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 108 { DIDFT_OPTIONAL DIDFT_BUTTON [ 108 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 109 { DIDFT_OPTIONAL DIDFT_BUTTON [ 109 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 110 { DIDFT_OPTIONAL DIDFT_BUTTON [ 110 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 111 { DIDFT_OPTIONAL DIDFT_BUTTON [ 111 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 112 { DIDFT_OPTIONAL DIDFT_BUTTON [ 112 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 113 { DIDFT_OPTIONAL DIDFT_BUTTON [ 113 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 114 { DIDFT_OPTIONAL DIDFT_BUTTON [ 114 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 115 { DIDFT_OPTIONAL DIDFT_BUTTON [ 115 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 116 { DIDFT_OPTIONAL DIDFT_BUTTON [ 116 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 117 { DIDFT_OPTIONAL DIDFT_BUTTON [ 117 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 118 { DIDFT_OPTIONAL DIDFT_BUTTON [ 118 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 119 { DIDFT_OPTIONAL DIDFT_BUTTON [ 119 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 120 { DIDFT_OPTIONAL DIDFT_BUTTON [ 120 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 121 { DIDFT_OPTIONAL DIDFT_BUTTON [ 121 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 122 { DIDFT_OPTIONAL DIDFT_BUTTON [ 122 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 123 { DIDFT_OPTIONAL DIDFT_BUTTON [ 123 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 124 { DIDFT_OPTIONAL DIDFT_BUTTON [ 124 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 125 { DIDFT_OPTIONAL DIDFT_BUTTON [ 125 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 126 { DIDFT_OPTIONAL DIDFT_BUTTON [ 126 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 127 { DIDFT_OPTIONAL DIDFT_BUTTON [ 127 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 128 { DIDFT_OPTIONAL DIDFT_BUTTON [ 128 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 129 { DIDFT_OPTIONAL DIDFT_BUTTON [ 129 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 130 { DIDFT_OPTIONAL DIDFT_BUTTON [ 130 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 131 { DIDFT_OPTIONAL DIDFT_BUTTON [ 131 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 132 { DIDFT_OPTIONAL DIDFT_BUTTON [ 132 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 133 { DIDFT_OPTIONAL DIDFT_BUTTON [ 133 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 134 { DIDFT_OPTIONAL DIDFT_BUTTON [ 134 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 135 { DIDFT_OPTIONAL DIDFT_BUTTON [ 135 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 136 { DIDFT_OPTIONAL DIDFT_BUTTON [ 136 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 137 { DIDFT_OPTIONAL DIDFT_BUTTON [ 137 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 138 { DIDFT_OPTIONAL DIDFT_BUTTON [ 138 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 139 { DIDFT_OPTIONAL DIDFT_BUTTON [ 139 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 140 { DIDFT_OPTIONAL DIDFT_BUTTON [ 140 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 141 { DIDFT_OPTIONAL DIDFT_BUTTON [ 141 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 142 { DIDFT_OPTIONAL DIDFT_BUTTON [ 142 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 143 { DIDFT_OPTIONAL DIDFT_BUTTON [ 143 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 144 { DIDFT_OPTIONAL DIDFT_BUTTON [ 144 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 145 { DIDFT_OPTIONAL DIDFT_BUTTON [ 145 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 146 { DIDFT_OPTIONAL DIDFT_BUTTON [ 146 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 147 { DIDFT_OPTIONAL DIDFT_BUTTON [ 147 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 148 { DIDFT_OPTIONAL DIDFT_BUTTON [ 148 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 149 { DIDFT_OPTIONAL DIDFT_BUTTON [ 149 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 150 { DIDFT_OPTIONAL DIDFT_BUTTON [ 150 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 151 { DIDFT_OPTIONAL DIDFT_BUTTON [ 151 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 152 { DIDFT_OPTIONAL DIDFT_BUTTON [ 152 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 153 { DIDFT_OPTIONAL DIDFT_BUTTON [ 153 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 154 { DIDFT_OPTIONAL DIDFT_BUTTON [ 154 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 155 { DIDFT_OPTIONAL DIDFT_BUTTON [ 155 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 156 { DIDFT_OPTIONAL DIDFT_BUTTON [ 156 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 157 { DIDFT_OPTIONAL DIDFT_BUTTON [ 157 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 158 { DIDFT_OPTIONAL DIDFT_BUTTON [ 158 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 159 { DIDFT_OPTIONAL DIDFT_BUTTON [ 159 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 160 { DIDFT_OPTIONAL DIDFT_BUTTON [ 160 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 161 { DIDFT_OPTIONAL DIDFT_BUTTON [ 161 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 162 { DIDFT_OPTIONAL DIDFT_BUTTON [ 162 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 163 { DIDFT_OPTIONAL DIDFT_BUTTON [ 163 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 164 { DIDFT_OPTIONAL DIDFT_BUTTON [ 164 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 165 { DIDFT_OPTIONAL DIDFT_BUTTON [ 165 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 166 { DIDFT_OPTIONAL DIDFT_BUTTON [ 166 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 167 { DIDFT_OPTIONAL DIDFT_BUTTON [ 167 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 168 { DIDFT_OPTIONAL DIDFT_BUTTON [ 168 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 169 { DIDFT_OPTIONAL DIDFT_BUTTON [ 169 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 170 { DIDFT_OPTIONAL DIDFT_BUTTON [ 170 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 171 { DIDFT_OPTIONAL DIDFT_BUTTON [ 171 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 172 { DIDFT_OPTIONAL DIDFT_BUTTON [ 172 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 173 { DIDFT_OPTIONAL DIDFT_BUTTON [ 173 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 174 { DIDFT_OPTIONAL DIDFT_BUTTON [ 174 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 175 { DIDFT_OPTIONAL DIDFT_BUTTON [ 175 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 176 { DIDFT_OPTIONAL DIDFT_BUTTON [ 176 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 177 { DIDFT_OPTIONAL DIDFT_BUTTON [ 177 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 178 { DIDFT_OPTIONAL DIDFT_BUTTON [ 178 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 179 { DIDFT_OPTIONAL DIDFT_BUTTON [ 179 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 180 { DIDFT_OPTIONAL DIDFT_BUTTON [ 180 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 181 { DIDFT_OPTIONAL DIDFT_BUTTON [ 181 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 182 { DIDFT_OPTIONAL DIDFT_BUTTON [ 182 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 183 { DIDFT_OPTIONAL DIDFT_BUTTON [ 183 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 184 { DIDFT_OPTIONAL DIDFT_BUTTON [ 184 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 185 { DIDFT_OPTIONAL DIDFT_BUTTON [ 185 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 186 { DIDFT_OPTIONAL DIDFT_BUTTON [ 186 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 187 { DIDFT_OPTIONAL DIDFT_BUTTON [ 187 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 188 { DIDFT_OPTIONAL DIDFT_BUTTON [ 188 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 189 { DIDFT_OPTIONAL DIDFT_BUTTON [ 189 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 190 { DIDFT_OPTIONAL DIDFT_BUTTON [ 190 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 191 { DIDFT_OPTIONAL DIDFT_BUTTON [ 191 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 192 { DIDFT_OPTIONAL DIDFT_BUTTON [ 192 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 193 { DIDFT_OPTIONAL DIDFT_BUTTON [ 193 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 194 { DIDFT_OPTIONAL DIDFT_BUTTON [ 194 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 195 { DIDFT_OPTIONAL DIDFT_BUTTON [ 195 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 196 { DIDFT_OPTIONAL DIDFT_BUTTON [ 196 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 197 { DIDFT_OPTIONAL DIDFT_BUTTON [ 197 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 198 { DIDFT_OPTIONAL DIDFT_BUTTON [ 198 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 199 { DIDFT_OPTIONAL DIDFT_BUTTON [ 199 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 200 { DIDFT_OPTIONAL DIDFT_BUTTON [ 200 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 201 { DIDFT_OPTIONAL DIDFT_BUTTON [ 201 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 202 { DIDFT_OPTIONAL DIDFT_BUTTON [ 202 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 203 { DIDFT_OPTIONAL DIDFT_BUTTON [ 203 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 204 { DIDFT_OPTIONAL DIDFT_BUTTON [ 204 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 205 { DIDFT_OPTIONAL DIDFT_BUTTON [ 205 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 206 { DIDFT_OPTIONAL DIDFT_BUTTON [ 206 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 207 { DIDFT_OPTIONAL DIDFT_BUTTON [ 207 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 208 { DIDFT_OPTIONAL DIDFT_BUTTON [ 208 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 209 { DIDFT_OPTIONAL DIDFT_BUTTON [ 209 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 210 { DIDFT_OPTIONAL DIDFT_BUTTON [ 210 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 211 { DIDFT_OPTIONAL DIDFT_BUTTON [ 211 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 212 { DIDFT_OPTIONAL DIDFT_BUTTON [ 212 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 213 { DIDFT_OPTIONAL DIDFT_BUTTON [ 213 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 214 { DIDFT_OPTIONAL DIDFT_BUTTON [ 214 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 215 { DIDFT_OPTIONAL DIDFT_BUTTON [ 215 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 216 { DIDFT_OPTIONAL DIDFT_BUTTON [ 216 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 217 { DIDFT_OPTIONAL DIDFT_BUTTON [ 217 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 218 { DIDFT_OPTIONAL DIDFT_BUTTON [ 218 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 219 { DIDFT_OPTIONAL DIDFT_BUTTON [ 219 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 220 { DIDFT_OPTIONAL DIDFT_BUTTON [ 220 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 221 { DIDFT_OPTIONAL DIDFT_BUTTON [ 221 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 222 { DIDFT_OPTIONAL DIDFT_BUTTON [ 222 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 223 { DIDFT_OPTIONAL DIDFT_BUTTON [ 223 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 224 { DIDFT_OPTIONAL DIDFT_BUTTON [ 224 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 225 { DIDFT_OPTIONAL DIDFT_BUTTON [ 225 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 226 { DIDFT_OPTIONAL DIDFT_BUTTON [ 226 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 227 { DIDFT_OPTIONAL DIDFT_BUTTON [ 227 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 228 { DIDFT_OPTIONAL DIDFT_BUTTON [ 228 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 229 { DIDFT_OPTIONAL DIDFT_BUTTON [ 229 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 230 { DIDFT_OPTIONAL DIDFT_BUTTON [ 230 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 231 { DIDFT_OPTIONAL DIDFT_BUTTON [ 231 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 232 { DIDFT_OPTIONAL DIDFT_BUTTON [ 232 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 233 { DIDFT_OPTIONAL DIDFT_BUTTON [ 233 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 234 { DIDFT_OPTIONAL DIDFT_BUTTON [ 234 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 235 { DIDFT_OPTIONAL DIDFT_BUTTON [ 235 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 236 { DIDFT_OPTIONAL DIDFT_BUTTON [ 236 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 237 { DIDFT_OPTIONAL DIDFT_BUTTON [ 237 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 238 { DIDFT_OPTIONAL DIDFT_BUTTON [ 238 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 239 { DIDFT_OPTIONAL DIDFT_BUTTON [ 239 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 240 { DIDFT_OPTIONAL DIDFT_BUTTON [ 240 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 241 { DIDFT_OPTIONAL DIDFT_BUTTON [ 241 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 242 { DIDFT_OPTIONAL DIDFT_BUTTON [ 242 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 243 { DIDFT_OPTIONAL DIDFT_BUTTON [ 243 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 244 { DIDFT_OPTIONAL DIDFT_BUTTON [ 244 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 245 { DIDFT_OPTIONAL DIDFT_BUTTON [ 245 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 246 { DIDFT_OPTIONAL DIDFT_BUTTON [ 246 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 247 { DIDFT_OPTIONAL DIDFT_BUTTON [ 247 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 248 { DIDFT_OPTIONAL DIDFT_BUTTON [ 248 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 249 { DIDFT_OPTIONAL DIDFT_BUTTON [ 249 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 250 { DIDFT_OPTIONAL DIDFT_BUTTON [ 250 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 251 { DIDFT_OPTIONAL DIDFT_BUTTON [ 251 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 252 { DIDFT_OPTIONAL DIDFT_BUTTON [ 252 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 253 { DIDFT_OPTIONAL DIDFT_BUTTON [ 253 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 254 { DIDFT_OPTIONAL DIDFT_BUTTON [ 254 DIDFT_MAKEINSTANCE ] } 0 }
-            { GUID_Key_malloced f 255 { DIDFT_OPTIONAL DIDFT_BUTTON [ 255 DIDFT_MAKEINSTANCE ] } 0 }
-        } <DIDATAFORMAT>
-    ] initialize ;
-
-: define-format-constants ( -- )
-    define-joystick-format-constant
-    define-mouse-format-constant
-    define-keyboard-format-constant
-    define-hid-keyboard-format-constant ;
-
-: define-constants ( -- )
-    define-guid-constants
-    define-format-constants ;
-
-[ define-constants ] "windows.dinput.constants" add-init-hook
-
-: uninitialize ( variable quot -- )
-    '[ _ when* f ] change-global ; inline
-
-: free-dinput-constants ( -- )
-    {
-        GUID_XAxis_malloced GUID_YAxis_malloced GUID_ZAxis_malloced
-        GUID_RxAxis_malloced GUID_RyAxis_malloced GUID_RzAxis_malloced
-        GUID_Slider_malloced GUID_Button_malloced GUID_Key_malloced GUID_POV_malloced GUID_Unknown_malloced
-        GUID_SysMouse_malloced GUID_SysKeyboard_malloced GUID_Joystick_malloced GUID_SysMouseEm_malloced
-        GUID_SysMouseEm2_malloced GUID_SysKeyboardEm_malloced GUID_SysKeyboardEm2_malloced
-    } [ [ free ] uninitialize ] each
-
-    {
-        c_dfDIKeyboard c_dfDIKeyboard_HID c_dfDIMouse2 c_dfDIJoystick2
-    } [ [ rgodf>> free ] uninitialize ] each ;
-
-PRIVATE>
-
diff --git a/basis/windows/dinput/constants/tags.txt b/basis/windows/dinput/constants/tags.txt
deleted file mode 100644 (file)
index 6bf6830..0000000
+++ /dev/null
@@ -1 +0,0 @@
-unportable
diff --git a/basis/windows/dinput/dinput.factor b/basis/windows/dinput/dinput.factor
deleted file mode 100755 (executable)
index 70d9500..0000000
+++ /dev/null
@@ -1,711 +0,0 @@
-USING: windows.kernel32 windows.ole32 windows.com windows.com.syntax
-alien alien.c-types alien.syntax kernel system namespaces math
-classes.struct windows.types ;
-IN: windows.dinput
-
-LIBRARY: dinput
-
-TYPEDEF: DWORD D3DCOLOR
-
-STRUCT: DIDEVICEINSTANCEW
-    { dwSize          DWORD      }
-    { guidInstance    GUID       }
-    { guidProduct     GUID       }
-    { dwDevType       DWORD      }
-    { tszInstanceName WCHAR[260] }
-    { tszProductName  WCHAR[260] }
-    { guidFFDriver    GUID       }
-    { wUsagePage      WORD       }
-    { wUsage          WORD       } ;
-TYPEDEF: DIDEVICEINSTANCEW* LPDIDEVICEINSTANCEW
-TYPEDEF: DIDEVICEINSTANCEW* LPCDIDEVICEINSTANCEW
-UNION-STRUCT: DIACTION-union
-    { lptszActionName LPCWSTR }
-    { uResIdString    UINT    } ;
-STRUCT: DIACTIONW
-    { uAppData     UINT_PTR       }
-    { dwSemantic   DWORD          }
-    { dwFlags      DWORD          }
-    { union        DIACTION-union }
-    { guidInstance GUID           }
-    { dwObjID      DWORD          }
-    { dwHow        DWORD          } ;
-TYPEDEF: DIACTIONW* LPDIACTIONW
-TYPEDEF: DIACTIONW* LPCDIACTIONW
-STRUCT: DIACTIONFORMATW
-    { dwSize        DWORD       }
-    { dwActionSize  DWORD       }
-    { dwDataSize    DWORD       }
-    { dwNumActions  DWORD       }
-    { rgoAction     LPDIACTIONW }
-    { guidActionMap GUID        }
-    { dwGenre       DWORD       }
-    { dwBufferSize  DWORD       }
-    { lAxisMin      LONG        }
-    { lAxisMax      LONG        }
-    { hInstString   HINSTANCE   }
-    { ftTimeStamp   FILETIME    }
-    { dwCRC         DWORD       }
-    { tszActionMap  WCHAR[260]  } ;
-TYPEDEF: DIACTIONFORMATW* LPDIACTIONFORMATW
-TYPEDEF: DIACTIONFORMATW* LPCDIACTIONFORMATW
-STRUCT: DICOLORSET
-    { dwSize            DWORD    }
-    { cTextFore         D3DCOLOR }
-    { cTextHighlight    D3DCOLOR }
-    { cCalloutLine      D3DCOLOR }
-    { cCalloutHighlight D3DCOLOR }
-    { cBorder           D3DCOLOR }
-    { cControlFill      D3DCOLOR }
-    { cHighlightFill    D3DCOLOR }
-    { cAreaFill         D3DCOLOR } ;
-TYPEDEF: DICOLORSET* LPDICOLORSET
-TYPEDEF: DICOLORSET* LPCDICOLORSET
-
-STRUCT: DICONFIGUREDEVICESPARAMSW
-    { dwSize         DWORD             }
-    { dwcUsers       DWORD             }
-    { lptszUserNames LPWSTR            }
-    { dwcFormats     DWORD             }
-    { lprgFormats    LPDIACTIONFORMATW }
-    { hwnd           HWND              }
-    { dics           DICOLORSET        }
-    { lpUnkDDSTarget IUnknown*         } ;
-TYPEDEF: DICONFIGUREDEVICESPARAMSW* LPDICONFIGUREDEVICESPARAMSW
-TYPEDEF: DICONFIGUREDEVICESPARAMSW* LPDICONFIGUREDEVICESPARAMSW
-
-STRUCT: DIDEVCAPS
-    { dwSize DWORD }
-    { dwFlags DWORD }
-    { dwDevType DWORD }
-    { dwAxes DWORD }
-    { dwButtons DWORD }
-    { dwPOVs DWORD }
-    { dwFFSamplePeriod DWORD }
-    { dwFFMinTimeResolution DWORD }
-    { dwFirmwareRevision DWORD }
-    { dwHardwareRevision DWORD }
-    { dwFFDriverVersion DWORD } ;
-TYPEDEF: DIDEVCAPS* LPDIDEVCAPS
-TYPEDEF: DIDEVCAPS* LPCDIDEVCAPS
-STRUCT: DIDEVICEOBJECTINSTANCEW
-    { dwSize DWORD }
-    { guidType GUID }
-    { dwOfs DWORD }
-    { dwType DWORD }
-    { dwFlags DWORD }
-    { tszName WCHAR[260] }
-    { dwFFMaxForce DWORD }
-    { dwFFForceResolution DWORD }
-    { wCollectionNumber WORD }
-    { wDesignatorIndex WORD }
-    { wUsagePage WORD }
-    { wUsage WORD }
-    { dwDimension DWORD }
-    { wExponent WORD }
-    { wReportId WORD } ;
-TYPEDEF: DIDEVICEOBJECTINSTANCEW* LPDIDEVICEOBJECTINSTANCEW
-TYPEDEF: DIDEVICEOBJECTINSTANCEW* LPCDIDEVICEOBJECTINSTANCEW
-STRUCT: DIDEVICEOBJECTDATA
-    { dwOfs DWORD    }
-    { dwData DWORD    }
-    { dwTimeStamp DWORD    }
-    { dwSequence DWORD    }
-    { uAppData UINT_PTR } ;
-TYPEDEF: DIDEVICEOBJECTDATA* LPDIDEVICEOBJECTDATA
-TYPEDEF: DIDEVICEOBJECTDATA* LPCDIDEVICEOBJECTDATA
-STRUCT: DIOBJECTDATAFORMAT
-    { pguid GUID* }
-    { dwOfs DWORD }
-    { dwType DWORD }
-    { dwFlags DWORD } ;
-TYPEDEF: DIOBJECTDATAFORMAT* LPDIOBJECTDATAFORMAT
-TYPEDEF: DIOBJECTDATAFORMAT* LPCDIOBJECTDATAFORMAT
-STRUCT: DIDATAFORMAT
-    { dwSize DWORD }
-    { dwObjSize DWORD }
-    { dwFlags DWORD }
-    { dwDataSize DWORD }
-    { dwNumObjs DWORD }
-    { rgodf LPDIOBJECTDATAFORMAT } ;
-TYPEDEF: DIDATAFORMAT* LPDIDATAFORMAT
-TYPEDEF: DIDATAFORMAT* LPCDIDATAFORMAT
-STRUCT: DIPROPHEADER
-    { dwSize DWORD }
-    { dwHeaderSize DWORD }
-    { dwObj DWORD }
-    { dwHow DWORD } ;
-TYPEDEF: DIPROPHEADER* LPDIPROPHEADER
-TYPEDEF: DIPROPHEADER* LPCDIPROPHEADER
-STRUCT: DIPROPDWORD
-    { diph DIPROPHEADER }
-    { dwData DWORD        } ;
-TYPEDEF: DIPROPDWORD* LPDIPROPDWORD
-TYPEDEF: DIPROPDWORD* LPCDIPROPDWORD
-STRUCT: DIPROPPOINTER
-    { diph DIPROPHEADER }
-    { uData UINT_PTR } ;
-TYPEDEF: DIPROPPOINTER* LPDIPROPPOINTER
-TYPEDEF: DIPROPPOINTER* LPCDIPROPPOINTER
-STRUCT: DIPROPRANGE
-    { diph DIPROPHEADER }
-    { lMin LONG }
-    { lMax LONG } ;
-TYPEDEF: DIPROPRANGE* LPDIPROPRANGE
-TYPEDEF: DIPROPRANGE* LPCDIPROPRANGE
-STRUCT: DIPROPCAL
-    { diph DIPROPHEADER }
-    { lMin LONG }
-    { lCenter LONG }
-    { lMax LONG } ;
-TYPEDEF: DIPROPCAL* LPDIPROPCAL
-TYPEDEF: DIPROPCAL* LPCDIPROPCAL
-STRUCT: DIPROPGUIDANDPATH
-    { diph DIPROPHEADER }
-    { guidClass GUID }
-    { wszPath WCHAR[260]   } ;
-TYPEDEF: DIPROPGUIDANDPATH* LPDIPROPGUIDANDPATH
-TYPEDEF: DIPROPGUIDANDPATH* LPCDIPROPGUIDANDPATH
-STRUCT: DIPROPSTRING
-    { diph DIPROPHEADER }
-    { wsz WCHAR[260]   } ;
-TYPEDEF: DIPROPSTRING* LPDIPROPSTRING
-TYPEDEF: DIPROPSTRING* LPCDIPROPSTRING
-STRUCT: CPOINT
-    { lP LONG }
-    { dwLog DWORD } ;
-STRUCT: DIPROPCPOINTS
-    { diph DIPROPHEADER }
-    { dwCPointsNum DWORD }
-    { cp CPOINT[8] } ;
-TYPEDEF: DIPROPCPOINTS* LPDIPROPCPOINTS
-TYPEDEF: DIPROPCPOINTS* LPCDIPROPCPOINTS
-STRUCT: DIENVELOPE
-    { dwSize DWORD }
-    { dwAttackLevel DWORD }
-    { dwAttackTime DWORD }
-    { dwFadeLevel DWORD }
-    { dwFadeTime DWORD } ;
-TYPEDEF: DIENVELOPE* LPDIENVELOPE
-TYPEDEF: DIENVELOPE* LPCDIENVELOPE
-STRUCT: DIEFFECT
-    { dwSize DWORD }
-    { dwFlags DWORD }
-    { dwDuration DWORD }
-    { dwSamplePeriod DWORD }
-    { dwGain DWORD }
-    { dwTriggerButton DWORD }
-    { dwTriggerRepeatInterval DWORD }
-    { cAxes DWORD }
-    { rgdwAxes LPDWORD }
-    { rglDirection LPLONG }
-    { lpEnvelope LPDIENVELOPE }
-    { cbTypeSpecificParams DWORD }
-    { lpvTypeSpecificParams LPVOID }
-    { dwStartDelay DWORD } ;
-TYPEDEF: DIEFFECT* LPDIEFFECT
-TYPEDEF: DIEFFECT* LPCDIEFFECT
-STRUCT: DIEFFECTINFOW
-    { dwSize          DWORD      }
-    { guid            GUID       }
-    { dwEffType       DWORD      }
-    { dwStaticParams  DWORD      }
-    { dwDynamicParams DWORD      }
-    { tszName         WCHAR[260] } ;
-TYPEDEF: DIEFFECTINFOW* LPDIEFFECTINFOW
-TYPEDEF: DIEFFECTINFOW* LPCDIEFFECTINFOW
-STRUCT: DIEFFESCAPE
-    { dwSize       DWORD  }
-    { dwCommand    DWORD  }
-    { lpvInBuffer  LPVOID }
-    { cbInBuffer   DWORD  }
-    { lpvOutBuffer LPVOID }
-    { cbOutBuffer  DWORD  } ;
-TYPEDEF: DIEFFESCAPE* LPDIEFFESCAPE
-TYPEDEF: DIEFFESCAPE* LPCDIEFFESCAPE
-STRUCT: DIFILEEFFECT
-    { dwSize         DWORD       }
-    { GuidEffect     GUID        }
-    { lpDiEffect     LPCDIEFFECT }
-    { szFriendlyName CHAR[260]   } ;
-TYPEDEF: DIFILEEFFECT* LPDIFILEEFFECT
-TYPEDEF: DIFILEEFFECT* LPCDIFILEEFFECT
-STRUCT: DIDEVICEIMAGEINFOW
-    { tszImagePath    WCHAR[260] }
-    { dwFlags         DWORD      }
-    { dwViewID        DWORD      }
-    { rcOverlay       RECT       }
-    { dwObjID         DWORD      }
-    { dwcValidPts     DWORD      }
-    { rgptCalloutLine POINT[5]   }
-    { rcCalloutRect   RECT       }
-    { dwTextAlign     DWORD      } ;
-TYPEDEF: DIDEVICEIMAGEINFOW* LPDIDEVICEIMAGEINFOW
-TYPEDEF: DIDEVICEIMAGEINFOW* LPCDIDEVICEIMAGEINFOW
-STRUCT: DIDEVICEIMAGEINFOHEADERW
-    { dwSize          DWORD }
-    { dwSizeImageInfo DWORD }
-    { dwcViews        DWORD }
-    { dwcButtons      DWORD }
-    { dwcAxes         DWORD }
-    { dwcPOVs         DWORD }
-    { dwBufferSize    DWORD }
-    { dwBufferUsed    DWORD }
-    { lprgImageInfoArray DIDEVICEIMAGEINFOW* } ;
-TYPEDEF: DIDEVICEIMAGEINFOHEADERW* LPDIDEVICEIMAGEINFOHEADERW
-TYPEDEF: DIDEVICEIMAGEINFOHEADERW* LPCDIDEVICEIMAGEINFOHEADERW
-
-STRUCT: DIMOUSESTATE2
-    { lX         LONG    }
-    { lY         LONG    }
-    { lZ         LONG    }
-    { rgbButtons BYTE[8] } ;
-TYPEDEF: DIMOUSESTATE2* LPDIMOUSESTATE2
-TYPEDEF: DIMOUSESTATE2* LPCDIMOUSESTATE2
-
-STRUCT: DIJOYSTATE2
-    { lX         LONG      }
-    { lY         LONG      }
-    { lZ         LONG      }
-    { lRx        LONG      }
-    { lRy        LONG      }
-    { lRz        LONG      }
-    { rglSlider  LONG[2]   }
-    { rgdwPOV    DWORD[4]  }
-    { rgbButtons BYTE[128] }
-    { lVX        LONG      }
-    { lVY        LONG      }
-    { lVZ        LONG      }
-    { lVRx       LONG      }
-    { lVRy       LONG      }
-    { lVRz       LONG      }
-    { rglVSlider LONG[2]   }
-    { lAX        LONG      }
-    { lAY        LONG      }
-    { lAZ        LONG      }
-    { lARx       LONG      }
-    { lARy       LONG      }
-    { lARz       LONG      }
-    { rglASlider LONG[2]   }
-    { lFX        LONG      }
-    { lFY        LONG      }
-    { lFZ        LONG      }
-    { lFRx       LONG      }
-    { lFRy       LONG      }
-    { lFRz       LONG      }
-    { rglFSlider LONG[2]   } ;
-TYPEDEF: DIJOYSTATE2* LPDIJOYSTATE2
-TYPEDEF: DIJOYSTATE2* LPCDIJOYSTATE2
-
-CALLBACK: BOOL LPDIENUMDEVICESCALLBACKW (
-    LPCDIDEVICEINSTANCEW lpddi,
-    LPVOID pvRef
-) ;
-CALLBACK: BOOL LPDICONFIGUREDEVICESCALLBACK (
-    IUnknown* lpDDSTarget,
-    LPVOID pvRef
-) ;
-CALLBACK: BOOL LPDIENUMEFFECTSCALLBACKW (
-    LPCDIEFFECTINFOW pdei,
-    LPVOID pvRef
-) ;
-CALLBACK: BOOL LPDIENUMEFFECTSINFILECALLBACK (
-    LPCDIFILEEFFECT lpDiFileEf,
-    LPVOID pvRef
-) ;
-CALLBACK: BOOL LPDIENUMDEVICEOBJECTSCALLBACKW (
-    LPCDIDEVICEOBJECTINSTANCEW lpddoi,
-    LPVOID pvRef
-) ;
-
-COM-INTERFACE: IDirectInputEffect IUnknown {E7E1F7C0-88D2-11D0-9AD0-00A0C9A06E35}
-    HRESULT Initialize ( HINSTANCE hinst, DWORD dwVersion, REFGUID rguid )
-    HRESULT GetEffectGuid ( LPGUID pguid )
-    HRESULT GetParameters ( LPDIEFFECT peff, DWORD dwFlags )
-    HRESULT SetParameters ( LPCDIEFFECT peff, DWORD dwFlags )
-    HRESULT Start ( DWORD dwIterations, DWORD dwFlags )
-    HRESULT Stop ( )
-    HRESULT GetEffectStatus ( LPDWORD pdwFlags )
-    HRESULT Download ( )
-    HRESULT Unload ( )
-    HRESULT Escape ( LPDIEFFESCAPE pesc ) ;
-
-CALLBACK: BOOL LPDIENUMCREATEDEFFECTOBJECTSCALLBACK (
-    IDirectInputEffect* peff,
-    LPVOID pvRef
-) ;
-
-COM-INTERFACE: IDirectInputDevice8W IUnknown {54D41081-DC15-4833-A41B-748F73A38179}
-    HRESULT GetCapabilities ( LPDIDEVCAPS lpDIDeviceCaps )
-    HRESULT EnumObjects ( LPDIENUMDEVICEOBJECTSCALLBACKW lpCallback, LPVOID pvRef, DWORD dwFlags )
-    HRESULT GetProperty ( REFGUID rguidProp, LPDIPROPHEADER pdiph )
-    HRESULT SetProperty ( REFGUID rguidProp, LPCDIPROPHEADER pdiph )
-    HRESULT Acquire ( )
-    HRESULT Unacquire ( )
-    HRESULT GetDeviceState ( DWORD cbData, LPVOID lpvData )
-    HRESULT GetDeviceData ( DWORD cbObjectData, LPDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD dwFlags )
-    HRESULT SetDataFormat ( LPCDIDATAFORMAT lpdf )
-    HRESULT SetEventNotification ( HANDLE hEvent )
-    HRESULT SetCooperativeLevel ( HWND hwnd, DWORD dwFlags )
-    HRESULT GetObjectInfo ( LPDIDEVICEOBJECTINSTANCEW rdidoi, DWORD dwObj, DWORD dwHow )
-    HRESULT GetDeviceInfo ( LPDIDEVICEINSTANCEW pdidi )
-    HRESULT RunControlPanel ( HWND hwndOwner, DWORD dwFlags )
-    HRESULT Initialize ( HINSTANCE hinst, DWORD dwVersion, REFGUID rguid )
-    HRESULT CreateEffect ( REFGUID rguid, LPCDIEFFECT lpeff, IDirectInputEffect** ppdeff, LPUNKNOWN punkOuter )
-    HRESULT EnumEffects ( LPDIENUMEFFECTSCALLBACKW lpCallback, LPVOID pvRef, DWORD dwEffType )
-    HRESULT GetEffectInfo ( LPDIEFFECTINFOW pdei, REFGUID rguid )
-    HRESULT GetForceFeedbackState ( LPDWORD pdwOut )
-    HRESULT SendForceFeedbackCommand ( DWORD dwFlags )
-    HRESULT EnumCreatedEffectObjects ( LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback, LPVOID pvRef, DWORD fl )
-    HRESULT Escape ( LPDIEFFESCAPE pesc )
-    HRESULT Poll ( )
-    HRESULT SendDeviceData ( DWORD cbObjectData, LPCDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD fl )
-    HRESULT EnumEffectsInFile ( LPCWSTR lpszFileName, LPDIENUMEFFECTSINFILECALLBACK lpCallback, LPVOID pvRef, DWORD dwFlags )
-    HRESULT WriteEffectToFile ( LPCWSTR lpszFileName, DWORD dwEntries, LPDIFILEEFFECT rgDiFileEffect, DWORD dwFlags )
-    HRESULT BuildActionMap ( LPDIACTIONFORMATW lpdiaf, LPCWSTR lpszUserName, DWORD dwFlags )
-    HRESULT SetActionMap ( LPDIACTIONFORMATW lpdiActionFormat, LPCWSTR lpwszUserName, DWORD dwFlags )
-    HRESULT GetImageInfo ( LPDIDEVICEIMAGEINFOHEADERW lpdiDeviceImageInfoHeader ) ;
-
-CALLBACK: BOOL LPDIENUMDEVICESBYSEMANTICSCBW (
-    LPCDIDEVICEINSTANCEW lpddi, 
-    IDirectInputDevice8W* lpdid,
-    DWORD dwFlags,
-    DWORD dwRemaining,
-    LPVOID pvRef
-) ;
-
-COM-INTERFACE: IDirectInput8W IUnknown {BF798031-483A-4DA2-AA99-5D64ED369700}
-    HRESULT CreateDevice ( REFGUID rguid, IDirectInputDevice8W** lplpDevice, LPUNKNOWN pUnkOuter )
-    HRESULT EnumDevices ( DWORD dwDevType, LPDIENUMDEVICESCALLBACKW lpCallback, LPVOID pvRef, DWORD dwFlags )
-    HRESULT GetDeviceStatus ( REFGUID rguidInstance )
-    HRESULT RunControlPanel ( HWND hwndOwner, DWORD dwFlags )
-    HRESULT Initialize ( HINSTANCE hinst, DWORD dwVersion )
-    HRESULT FindDevice ( REFGUID rguidClass, LPCWSTR pwszName, LPGUID pguidInstance )
-    HRESULT EnumDevicesBySemantics ( LPCWSTR pwszUserName, LPDIACTIONFORMATW lpdiActionFormat, LPDIENUMDEVICESBYSEMANTICSCBW lpCallback, LPVOID pvRef, DWORD dwFlags )
-    HRESULT ConfigureDevices ( LPDICONFIGUREDEVICESCALLBACK lpdiCallback, LPDICONFIGUREDEVICESPARAMSW lpdiCDParams, DWORD dwFlags, LPVOID pvRefData ) ;
-
-FUNCTION: HRESULT DirectInput8Create ( HINSTANCE hinst, DWORD dwVersion, REFIID riidtlf, LPVOID* ppvOut, LPUNKNOWN punkOuter ) ;
-
-CONSTANT: DIRECTINPUT_VERSION HEX: 0800
-                               
-CONSTANT: DI8DEVCLASS_ALL             0
-CONSTANT: DI8DEVCLASS_DEVICE          1
-CONSTANT: DI8DEVCLASS_POINTER         2
-CONSTANT: DI8DEVCLASS_KEYBOARD        3
-CONSTANT: DI8DEVCLASS_GAMECTRL        4
-
-CONSTANT: DIEDFL_ALLDEVICES       HEX: 00000000
-CONSTANT: DIEDFL_ATTACHEDONLY     HEX: 00000001
-CONSTANT: DIEDFL_FORCEFEEDBACK    HEX: 00000100
-CONSTANT: DIEDFL_INCLUDEALIASES   HEX: 00010000
-CONSTANT: DIEDFL_INCLUDEPHANTOMS  HEX: 00020000
-CONSTANT: DIEDFL_INCLUDEHIDDEN    HEX: 00040000
-                                               
-CONSTANT: DIENUM_STOP             0
-CONSTANT: DIENUM_CONTINUE         1
-
-CONSTANT: DIDF_ABSAXIS            1
-CONSTANT: DIDF_RELAXIS            2
-
-CONSTANT: DIDFT_ALL           HEX: 00000000
-         
-CONSTANT: DIDFT_RELAXIS       HEX: 00000001
-CONSTANT: DIDFT_ABSAXIS       HEX: 00000002
-CONSTANT: DIDFT_AXIS          HEX: 00000003
-         
-CONSTANT: DIDFT_PSHBUTTON     HEX: 00000004
-CONSTANT: DIDFT_TGLBUTTON     HEX: 00000008
-CONSTANT: DIDFT_BUTTON        HEX: 0000000C
-         
-CONSTANT: DIDFT_POV           HEX: 00000010
-CONSTANT: DIDFT_COLLECTION    HEX: 00000040
-CONSTANT: DIDFT_NODATA        HEX: 00000080
-         
-CONSTANT: DIDFT_ANYINSTANCE   HEX: 00FFFF00
-ALIAS: DIDFT_INSTANCEMASK  DIDFT_ANYINSTANCE
-: DIDFT_MAKEINSTANCE ( n -- instance ) 8 shift                   ; inline
-: DIDFT_GETTYPE      ( n -- type     ) HEX: FF bitand            ; inline
-: DIDFT_GETINSTANCE  ( n -- instance ) -8 shift HEX: FFFF bitand ; inline
-CONSTANT: DIDFT_FFACTUATOR        HEX: 01000000
-CONSTANT: DIDFT_FFEFFECTTRIGGER   HEX: 02000000
-CONSTANT: DIDFT_OUTPUT            HEX: 10000000
-CONSTANT: DIDFT_VENDORDEFINED     HEX: 04000000
-CONSTANT: DIDFT_ALIAS             HEX: 08000000
-CONSTANT: DIDFT_OPTIONAL          HEX: 80000000
-
-: DIDFT_ENUMCOLLECTION ( n -- instance ) 8 shift HEX: FFFF bitand ; inline
-CONSTANT: DIDFT_NOCOLLECTION      HEX: 00FFFF00
-
-CONSTANT: DIDOI_FFACTUATOR        HEX: 00000001
-CONSTANT: DIDOI_FFEFFECTTRIGGER   HEX: 00000002
-CONSTANT: DIDOI_POLLED            HEX: 00008000
-CONSTANT: DIDOI_ASPECTPOSITION    HEX: 00000100
-CONSTANT: DIDOI_ASPECTVELOCITY    HEX: 00000200
-CONSTANT: DIDOI_ASPECTACCEL       HEX: 00000300
-CONSTANT: DIDOI_ASPECTFORCE       HEX: 00000400
-CONSTANT: DIDOI_ASPECTMASK        HEX: 00000F00
-CONSTANT: DIDOI_GUIDISUSAGE       HEX: 00010000
-
-CONSTANT: DISCL_EXCLUSIVE     HEX: 00000001
-CONSTANT: DISCL_NONEXCLUSIVE  HEX: 00000002
-CONSTANT: DISCL_FOREGROUND    HEX: 00000004
-CONSTANT: DISCL_BACKGROUND    HEX: 00000008
-CONSTANT: DISCL_NOWINKEY      HEX: 00000010
-
-CONSTANT: DIMOFS_X        0
-CONSTANT: DIMOFS_Y        4
-CONSTANT: DIMOFS_Z        8
-CONSTANT: DIMOFS_BUTTON0 12
-CONSTANT: DIMOFS_BUTTON1 13
-CONSTANT: DIMOFS_BUTTON2 14
-CONSTANT: DIMOFS_BUTTON3 15
-CONSTANT: DIMOFS_BUTTON4 16
-CONSTANT: DIMOFS_BUTTON5 17
-CONSTANT: DIMOFS_BUTTON6 18
-CONSTANT: DIMOFS_BUTTON7 19
-
-CONSTANT: DIK_ESCAPE          HEX: 01
-CONSTANT: DIK_1               HEX: 02
-CONSTANT: DIK_2               HEX: 03
-CONSTANT: DIK_3               HEX: 04
-CONSTANT: DIK_4               HEX: 05
-CONSTANT: DIK_5               HEX: 06
-CONSTANT: DIK_6               HEX: 07
-CONSTANT: DIK_7               HEX: 08
-CONSTANT: DIK_8               HEX: 09
-CONSTANT: DIK_9               HEX: 0A
-CONSTANT: DIK_0               HEX: 0B
-CONSTANT: DIK_MINUS           HEX: 0C
-CONSTANT: DIK_EQUALS          HEX: 0D
-CONSTANT: DIK_BACK            HEX: 0E
-CONSTANT: DIK_TAB             HEX: 0F
-CONSTANT: DIK_Q               HEX: 10
-CONSTANT: DIK_W               HEX: 11
-CONSTANT: DIK_E               HEX: 12
-CONSTANT: DIK_R               HEX: 13
-CONSTANT: DIK_T               HEX: 14
-CONSTANT: DIK_Y               HEX: 15
-CONSTANT: DIK_U               HEX: 16
-CONSTANT: DIK_I               HEX: 17
-CONSTANT: DIK_O               HEX: 18
-CONSTANT: DIK_P               HEX: 19
-CONSTANT: DIK_LBRACKET        HEX: 1A
-CONSTANT: DIK_RBRACKET        HEX: 1B
-CONSTANT: DIK_RETURN          HEX: 1C
-CONSTANT: DIK_LCONTROL        HEX: 1D
-CONSTANT: DIK_A               HEX: 1E
-CONSTANT: DIK_S               HEX: 1F
-CONSTANT: DIK_D               HEX: 20
-CONSTANT: DIK_F               HEX: 21
-CONSTANT: DIK_G               HEX: 22
-CONSTANT: DIK_H               HEX: 23
-CONSTANT: DIK_J               HEX: 24
-CONSTANT: DIK_K               HEX: 25
-CONSTANT: DIK_L               HEX: 26
-CONSTANT: DIK_SEMICOLON       HEX: 27
-CONSTANT: DIK_APOSTROPHE      HEX: 28
-CONSTANT: DIK_GRAVE           HEX: 29
-CONSTANT: DIK_LSHIFT          HEX: 2A
-CONSTANT: DIK_BACKSLASH       HEX: 2B
-CONSTANT: DIK_Z               HEX: 2C
-CONSTANT: DIK_X               HEX: 2D
-CONSTANT: DIK_C               HEX: 2E
-CONSTANT: DIK_V               HEX: 2F
-CONSTANT: DIK_B               HEX: 30
-CONSTANT: DIK_N               HEX: 31
-CONSTANT: DIK_M               HEX: 32
-CONSTANT: DIK_COMMA           HEX: 33
-CONSTANT: DIK_PERIOD          HEX: 34
-CONSTANT: DIK_SLASH           HEX: 35
-CONSTANT: DIK_RSHIFT          HEX: 36
-CONSTANT: DIK_MULTIPLY        HEX: 37
-CONSTANT: DIK_LMENU           HEX: 38
-CONSTANT: DIK_SPACE           HEX: 39
-CONSTANT: DIK_CAPITAL         HEX: 3A
-CONSTANT: DIK_F1              HEX: 3B
-CONSTANT: DIK_F2              HEX: 3C
-CONSTANT: DIK_F3              HEX: 3D
-CONSTANT: DIK_F4              HEX: 3E
-CONSTANT: DIK_F5              HEX: 3F
-CONSTANT: DIK_F6              HEX: 40
-CONSTANT: DIK_F7              HEX: 41
-CONSTANT: DIK_F8              HEX: 42
-CONSTANT: DIK_F9              HEX: 43
-CONSTANT: DIK_F10             HEX: 44
-CONSTANT: DIK_NUMLOCK         HEX: 45
-CONSTANT: DIK_SCROLL          HEX: 46
-CONSTANT: DIK_NUMPAD7         HEX: 47
-CONSTANT: DIK_NUMPAD8         HEX: 48
-CONSTANT: DIK_NUMPAD9         HEX: 49
-CONSTANT: DIK_SUBTRACT        HEX: 4A
-CONSTANT: DIK_NUMPAD4         HEX: 4B
-CONSTANT: DIK_NUMPAD5         HEX: 4C
-CONSTANT: DIK_NUMPAD6         HEX: 4D
-CONSTANT: DIK_ADD             HEX: 4E
-CONSTANT: DIK_NUMPAD1         HEX: 4F
-CONSTANT: DIK_NUMPAD2         HEX: 50
-CONSTANT: DIK_NUMPAD3         HEX: 51
-CONSTANT: DIK_NUMPAD0         HEX: 52
-CONSTANT: DIK_DECIMAL         HEX: 53
-CONSTANT: DIK_OEM_102         HEX: 56
-CONSTANT: DIK_F11             HEX: 57
-CONSTANT: DIK_F12             HEX: 58
-CONSTANT: DIK_F13             HEX: 64
-CONSTANT: DIK_F14             HEX: 65
-CONSTANT: DIK_F15             HEX: 66
-CONSTANT: DIK_KANA            HEX: 70
-CONSTANT: DIK_ABNT_C1         HEX: 73
-CONSTANT: DIK_CONVERT         HEX: 79
-CONSTANT: DIK_NOCONVERT       HEX: 7B
-CONSTANT: DIK_YEN             HEX: 7D
-CONSTANT: DIK_ABNT_C2         HEX: 7E
-CONSTANT: DIK_NUMPADEQUALS    HEX: 8D
-CONSTANT: DIK_PREVTRACK       HEX: 90
-CONSTANT: DIK_AT              HEX: 91
-CONSTANT: DIK_COLON           HEX: 92
-CONSTANT: DIK_UNDERLINE       HEX: 93
-CONSTANT: DIK_KANJI           HEX: 94
-CONSTANT: DIK_STOP            HEX: 95
-CONSTANT: DIK_AX              HEX: 96
-CONSTANT: DIK_UNLABELED       HEX: 97
-CONSTANT: DIK_NEXTTRACK       HEX: 99
-CONSTANT: DIK_NUMPADENTER     HEX: 9C
-CONSTANT: DIK_RCONTROL        HEX: 9D
-CONSTANT: DIK_MUTE            HEX: A0
-CONSTANT: DIK_CALCULATOR      HEX: A1
-CONSTANT: DIK_PLAYPAUSE       HEX: A2
-CONSTANT: DIK_MEDIASTOP       HEX: A4
-CONSTANT: DIK_VOLUMEDOWN      HEX: AE
-CONSTANT: DIK_VOLUMEUP        HEX: B0
-CONSTANT: DIK_WEBHOME         HEX: B2
-CONSTANT: DIK_NUMPADCOMMA     HEX: B3
-CONSTANT: DIK_DIVIDE          HEX: B5
-CONSTANT: DIK_SYSRQ           HEX: B7
-CONSTANT: DIK_RMENU           HEX: B8
-CONSTANT: DIK_PAUSE           HEX: C5
-CONSTANT: DIK_HOME            HEX: C7
-CONSTANT: DIK_UP              HEX: C8
-CONSTANT: DIK_PRIOR           HEX: C9
-CONSTANT: DIK_LEFT            HEX: CB
-CONSTANT: DIK_RIGHT           HEX: CD
-CONSTANT: DIK_END             HEX: CF
-CONSTANT: DIK_DOWN            HEX: D0
-CONSTANT: DIK_NEXT            HEX: D1
-CONSTANT: DIK_INSERT          HEX: D2
-CONSTANT: DIK_DELETE          HEX: D3
-CONSTANT: DIK_LWIN            HEX: DB
-CONSTANT: DIK_RWIN            HEX: DC
-CONSTANT: DIK_APPS            HEX: DD
-CONSTANT: DIK_POWER           HEX: DE
-CONSTANT: DIK_SLEEP           HEX: DF
-CONSTANT: DIK_WAKE            HEX: E3
-CONSTANT: DIK_WEBSEARCH       HEX: E5
-CONSTANT: DIK_WEBFAVORITES    HEX: E6
-CONSTANT: DIK_WEBREFRESH      HEX: E7
-CONSTANT: DIK_WEBSTOP         HEX: E8
-CONSTANT: DIK_WEBFORWARD      HEX: E9
-CONSTANT: DIK_WEBBACK         HEX: EA
-CONSTANT: DIK_MYCOMPUTER      HEX: EB
-CONSTANT: DIK_MAIL            HEX: EC
-CONSTANT: DIK_MEDIASELECT     HEX: ED
-
-ALIAS: DIK_BACKSPACE       DIK_BACK
-ALIAS: DIK_NUMPADSTAR      DIK_MULTIPLY
-ALIAS: DIK_LALT            DIK_LMENU
-ALIAS: DIK_CAPSLOCK        DIK_CAPITAL
-ALIAS: DIK_NUMPADMINUS     DIK_SUBTRACT
-ALIAS: DIK_NUMPADPLUS      DIK_ADD
-ALIAS: DIK_NUMPADPERIOD    DIK_DECIMAL
-ALIAS: DIK_NUMPADSLASH     DIK_DIVIDE
-ALIAS: DIK_RALT            DIK_RMENU
-ALIAS: DIK_UPARROW         DIK_UP
-ALIAS: DIK_PGUP            DIK_PRIOR
-ALIAS: DIK_LEFTARROW       DIK_LEFT
-ALIAS: DIK_RIGHTARROW      DIK_RIGHT
-ALIAS: DIK_DOWNARROW       DIK_DOWN
-ALIAS: DIK_PGDN            DIK_NEXT
-
-ALIAS: DIK_CIRCUMFLEX      DIK_PREVTRACK
-
-CONSTANT: DI8DEVTYPE_DEVICE           HEX: 11
-CONSTANT: DI8DEVTYPE_MOUSE            HEX: 12
-CONSTANT: DI8DEVTYPE_KEYBOARD         HEX: 13
-CONSTANT: DI8DEVTYPE_JOYSTICK         HEX: 14
-CONSTANT: DI8DEVTYPE_GAMEPAD          HEX: 15
-CONSTANT: DI8DEVTYPE_DRIVING          HEX: 16
-CONSTANT: DI8DEVTYPE_FLIGHT           HEX: 17
-CONSTANT: DI8DEVTYPE_1STPERSON        HEX: 18
-CONSTANT: DI8DEVTYPE_DEVICECTRL       HEX: 19
-CONSTANT: DI8DEVTYPE_SCREENPOINTER    HEX: 1A
-CONSTANT: DI8DEVTYPE_REMOTE           HEX: 1B
-CONSTANT: DI8DEVTYPE_SUPPLEMENTAL     HEX: 1C
-
-: GET_DIDEVICE_TYPE ( dwType -- type ) HEX: FF bitand ; inline
-
-CONSTANT: DIPROPRANGE_NOMIN       HEX: 80000000
-CONSTANT: DIPROPRANGE_NOMAX       HEX: 7FFFFFFF
-CONSTANT: MAXCPOINTSNUM           8
-
-CONSTANT: DIPH_DEVICE             0
-CONSTANT: DIPH_BYOFFSET           1
-CONSTANT: DIPH_BYID               2
-CONSTANT: DIPH_BYUSAGE            3
-                                   
-: DIMAKEUSAGEDWORD ( UsagePage Usage -- DWORD ) 16 shift bitor ; inline
-
-: DIPROP_BUFFERSIZE ( -- alien ) 1 <alien> ; inline
-: DIPROP_AXISMODE   ( -- alien ) 2 <alien> ; inline
-
-CONSTANT: DIPROPAXISMODE_ABS      0
-CONSTANT: DIPROPAXISMODE_REL      1
-                                   
-: DIPROP_GRANULARITY ( -- alien ) 3 <alien> ; inline
-: DIPROP_RANGE       ( -- alien ) 4 <alien> ; inline
-: DIPROP_DEADZONE    ( -- alien ) 5 <alien> ; inline
-: DIPROP_SATURATION  ( -- alien ) 6 <alien> ; inline
-: DIPROP_FFGAIN      ( -- alien ) 7 <alien> ; inline
-: DIPROP_FFLOAD      ( -- alien ) 8 <alien> ; inline
-: DIPROP_AUTOCENTER  ( -- alien ) 9 <alien> ; inline
-
-CONSTANT: DIPROPAUTOCENTER_OFF    0
-CONSTANT: DIPROPAUTOCENTER_ON     1
-
-: DIPROP_CALIBRATIONMODE ( -- alien ) 10 <alien> ; inline
-
-CONSTANT: DIPROPCALIBRATIONMODE_COOKED    0
-CONSTANT: DIPROPCALIBRATIONMODE_RAW       1
-
-: DIPROP_CALIBRATION ( -- alien )        11 <alien> ; inline
-: DIPROP_GUIDANDPATH ( -- alien )        12 <alien> ; inline
-: DIPROP_INSTANCENAME ( -- alien )       13 <alien> ; inline
-: DIPROP_PRODUCTNAME ( -- alien )        14 <alien> ; inline
-: DIPROP_JOYSTICKID ( -- alien )         15 <alien> ; inline
-: DIPROP_GETPORTDISPLAYNAME ( -- alien ) 16 <alien> ; inline
-: DIPROP_PHYSICALRANGE ( -- alien )      18 <alien> ; inline
-: DIPROP_LOGICALRANGE ( -- alien )       19 <alien> ; inline
-: DIPROP_KEYNAME ( -- alien )            20 <alien> ; inline
-: DIPROP_CPOINTS ( -- alien )            21 <alien> ; inline
-: DIPROP_APPDATA ( -- alien )            22 <alien> ; inline
-: DIPROP_SCANCODE ( -- alien )           23 <alien> ; inline
-: DIPROP_VIDPID ( -- alien )             24 <alien> ; inline
-: DIPROP_USERNAME ( -- alien )           25 <alien> ; inline
-: DIPROP_TYPENAME ( -- alien )           26 <alien> ; inline
-
-CONSTANT: GUID_XAxis          GUID: {A36D02E0-C9F3-11CF-BFC7-444553540000}
-CONSTANT: GUID_YAxis          GUID: {A36D02E1-C9F3-11CF-BFC7-444553540000}
-CONSTANT: GUID_ZAxis          GUID: {A36D02E2-C9F3-11CF-BFC7-444553540000}
-CONSTANT: GUID_RxAxis         GUID: {A36D02F4-C9F3-11CF-BFC7-444553540000}
-CONSTANT: GUID_RyAxis         GUID: {A36D02F5-C9F3-11CF-BFC7-444553540000}
-CONSTANT: GUID_RzAxis         GUID: {A36D02E3-C9F3-11CF-BFC7-444553540000}
-CONSTANT: GUID_Slider         GUID: {A36D02E4-C9F3-11CF-BFC7-444553540000}
-CONSTANT: GUID_Button         GUID: {A36D02F0-C9F3-11CF-BFC7-444553540000}
-CONSTANT: GUID_Key            GUID: {55728220-D33C-11CF-BFC7-444553540000}
-CONSTANT: GUID_POV            GUID: {A36D02F2-C9F3-11CF-BFC7-444553540000}
-CONSTANT: GUID_Unknown        GUID: {A36D02F3-C9F3-11CF-BFC7-444553540000}
-CONSTANT: GUID_SysMouse       GUID: {6F1D2B60-D5A0-11CF-BFC7-444553540000}
-CONSTANT: GUID_SysKeyboard    GUID: {6F1D2B61-D5A0-11CF-BFC7-444553540000}
-CONSTANT: GUID_Joystick       GUID: {6F1D2B70-D5A0-11CF-BFC7-444553540000}
-CONSTANT: GUID_SysMouseEm     GUID: {6F1D2B80-D5A0-11CF-BFC7-444553540000}
-CONSTANT: GUID_SysMouseEm2    GUID: {6F1D2B81-D5A0-11CF-BFC7-444553540000}
-CONSTANT: GUID_SysKeyboardEm  GUID: {6F1D2B82-D5A0-11CF-BFC7-444553540000}
-CONSTANT: GUID_SysKeyboardEm2 GUID: {6F1D2B83-D5A0-11CF-BFC7-444553540000}
diff --git a/basis/windows/dinput/summary.txt b/basis/windows/dinput/summary.txt
deleted file mode 100755 (executable)
index 7747560..0000000
+++ /dev/null
@@ -1 +0,0 @@
-DirectInput bindings
diff --git a/basis/windows/dinput/tags.txt b/basis/windows/dinput/tags.txt
deleted file mode 100755 (executable)
index 2320bdd..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-unportable
-bindings
diff --git a/basis/windows/directx/audiodefs/audiodefs.factor b/basis/windows/directx/audiodefs/audiodefs.factor
new file mode 100644 (file)
index 0000000..13e5983
--- /dev/null
@@ -0,0 +1,105 @@
+USING: alien.c-types alien.syntax classes.struct
+windows.kernel32 windows.types ;
+IN: windows.directx.audiodefs
+
+STRUCT: WAVEFORMATEX
+    { wFormatTag      WORD  }
+    { nChannels       WORD  }
+    { nSamplesPerSec  DWORD }
+    { nAvgBytesPerSec DWORD }
+    { nBlockAlign     WORD  }
+    { wBitsPerSample  WORD  }
+    { cbSize          WORD  } ;
+
+TYPEDEF: WAVEFORMATEX* PWAVEFORMATEX
+TYPEDEF: WAVEFORMATEX* NPWAVEFORMATEX
+TYPEDEF: WAVEFORMATEX* LPWAVEFORMATEX
+TYPEDEF: WAVEFORMATEX* PCWAVEFORMATEX
+TYPEDEF: WAVEFORMATEX* LPCWAVEFORMATEX
+
+UNION-STRUCT: WAVEFORMATEXTENSIBLE_UNION
+    { wValidBitsPerSample WORD }
+    { wSamplesPerBlock    WORD }
+    { wReserved           WORD } ;
+
+STRUCT: WAVEFORMATEXTENSIBLE
+    { Format        WAVEFORMATEX               }
+    { Union         WAVEFORMATEXTENSIBLE_UNION }
+    { dwChannelMask DWORD                      }
+    { SubFormat     GUID                       } ;
+
+TYPEDEF: WAVEFORMATEXTENSIBLE* PWAVEFORMATEXTENSIBLE
+TYPEDEF: WAVEFORMATEXTENSIBLE* LPWAVEFORMATEXTENSIBLE
+TYPEDEF: WAVEFORMATEXTENSIBLE* PCWAVEFORMATEXTENSIBLE
+TYPEDEF: WAVEFORMATEXTENSIBLE* LPCWAVEFORMATEXTENSIBLE
+
+STRUCT: WAVEFORMAT
+    { wFormatTag      WORD  }
+    { nChannels       WORD  }
+    { nSamplesPerSec  DWORD }
+    { nAvgBytesPerSec DWORD }
+    { nBlockAlign     WORD  } ;
+TYPEDEF: WAVEFORMAT* PWAVEFORMAT
+TYPEDEF: WAVEFORMAT* NPWAVEFORMAT
+TYPEDEF: WAVEFORMAT* LPWAVEFORMAT
+
+STRUCT: PCMWAVEFORMAT
+    { wf             WAVEFORMAT }
+    { wBitsPerSample WORD       } ;
+TYPEDEF: PCMWAVEFORMAT* PPCMWAVEFORMAT
+TYPEDEF: PCMWAVEFORMAT* NPPCMWAVEFORMAT
+TYPEDEF: PCMWAVEFORMAT* LPPCMWAVEFORMAT
+
+CONSTANT: WAVE_FORMAT_PCM 1
+
+STRUCT: ADPCMCOEFSET
+    { iCoef1 short }
+    { iCoef2 short } ;
+
+STRUCT: ADPCMWAVEFORMAT
+    { wfx              WAVEFORMATEX    }
+    { wSamplesPerBlock WORD            }
+    { wNumCoef         WORD            }
+    { aCoef            ADPCMCOEFSET[7] } ;
+
+CONSTANT: WAVE_FORMAT_ADPCM           2
+CONSTANT: WAVE_FORMAT_UNKNOWN         0
+CONSTANT: WAVE_FORMAT_IEEE_FLOAT      3
+CONSTANT: WAVE_FORMAT_MPEGLAYER3      HEX: 0055
+CONSTANT: WAVE_FORMAT_DOLBY_AC3_SPDIF HEX: 0092
+CONSTANT: WAVE_FORMAT_WMAUDIO2        HEX: 0161
+CONSTANT: WAVE_FORMAT_WMAUDIO3        HEX: 0162
+CONSTANT: WAVE_FORMAT_WMASPDIF        HEX: 0164
+CONSTANT: WAVE_FORMAT_EXTENSIBLE      HEX: FFFE
+
+CONSTANT: SPEAKER_FRONT_LEFT            HEX: 00000001
+CONSTANT: SPEAKER_FRONT_RIGHT           HEX: 00000002
+CONSTANT: SPEAKER_FRONT_CENTER          HEX: 00000004
+CONSTANT: SPEAKER_LOW_FREQUENCY         HEX: 00000008
+CONSTANT: SPEAKER_BACK_LEFT             HEX: 00000010
+CONSTANT: SPEAKER_BACK_RIGHT            HEX: 00000020
+CONSTANT: SPEAKER_FRONT_LEFT_OF_CENTER  HEX: 00000040
+CONSTANT: SPEAKER_FRONT_RIGHT_OF_CENTER HEX: 00000080
+CONSTANT: SPEAKER_BACK_CENTER           HEX: 00000100
+CONSTANT: SPEAKER_SIDE_LEFT             HEX: 00000200
+CONSTANT: SPEAKER_SIDE_RIGHT            HEX: 00000400
+CONSTANT: SPEAKER_TOP_CENTER            HEX: 00000800
+CONSTANT: SPEAKER_TOP_FRONT_LEFT        HEX: 00001000
+CONSTANT: SPEAKER_TOP_FRONT_CENTER      HEX: 00002000
+CONSTANT: SPEAKER_TOP_FRONT_RIGHT       HEX: 00004000
+CONSTANT: SPEAKER_TOP_BACK_LEFT         HEX: 00008000
+CONSTANT: SPEAKER_TOP_BACK_CENTER       HEX: 00010000
+CONSTANT: SPEAKER_TOP_BACK_RIGHT        HEX: 00020000
+CONSTANT: SPEAKER_RESERVED              HEX: 7FFC0000
+CONSTANT: SPEAKER_ALL                   HEX: 80000000
+
+CONSTANT: SPEAKER_MONO             HEX: 00000004
+CONSTANT: SPEAKER_STEREO           HEX: 00000003
+CONSTANT: SPEAKER_2POINT1          HEX: 0000000B
+CONSTANT: SPEAKER_SURROUND         HEX: 00010007
+CONSTANT: SPEAKER_QUAD             HEX: 00028003
+CONSTANT: SPEAKER_4POINT1          HEX: 0002800B
+CONSTANT: SPEAKER_5POINT1          HEX: 0002800F
+CONSTANT: SPEAKER_7POINT1          HEX: 000280CF
+CONSTANT: SPEAKER_5POINT1_SURROUND HEX: 0000060F
+CONSTANT: SPEAKER_7POINT1_SURROUND HEX: 0002860F
diff --git a/basis/windows/directx/audiodefs/authors.txt b/basis/windows/directx/audiodefs/authors.txt
new file mode 100644 (file)
index 0000000..6f03a12
--- /dev/null
@@ -0,0 +1 @@
+Erik Charlebois
diff --git a/basis/windows/directx/audiodefs/summary.txt b/basis/windows/directx/audiodefs/summary.txt
new file mode 100644 (file)
index 0000000..3f80ea1
--- /dev/null
@@ -0,0 +1 @@
+DirectX audio bindings. Corresponds to audiodefs.h.
diff --git a/basis/windows/directx/audiodefs/tags.txt b/basis/windows/directx/audiodefs/tags.txt
new file mode 100644 (file)
index 0000000..2320bdd
--- /dev/null
@@ -0,0 +1,2 @@
+unportable
+bindings
diff --git a/basis/windows/directx/d2d1/authors.txt b/basis/windows/directx/d2d1/authors.txt
new file mode 100644 (file)
index 0000000..6f03a12
--- /dev/null
@@ -0,0 +1 @@
+Erik Charlebois
diff --git a/basis/windows/directx/d2d1/d2d1.factor b/basis/windows/directx/d2d1/d2d1.factor
new file mode 100644 (file)
index 0000000..fad8878
--- /dev/null
@@ -0,0 +1,563 @@
+USING: alien.c-types alien.syntax classes.struct windows.com
+windows.com.syntax windows.directx.d3dbasetypes windows.directx.dcommon
+windows.directx.dxgi windows.directx.dxgiformat windows.ole32 windows.types ;
+IN: windows.directx.d2d1
+
+LIBRARY: d2d1
+
+CONSTANT: D2D1_INVALID_TAG HEX: ffffffffffffffff
+CONSTANT: D2D1_DEFAULT_FLATTENING_TOLERANCE 0.25
+
+CONSTANT: D2D1_ALPHA_MODE_UNKNOWN       0
+CONSTANT: D2D1_ALPHA_MODE_PREMULTIPLIED 1
+CONSTANT: D2D1_ALPHA_MODE_STRAIGHT      2
+CONSTANT: D2D1_ALPHA_MODE_IGNORE        3
+CONSTANT: D2D1_ALPHA_MODE_FORCE_DWORD   HEX: ffffffff
+TYPEDEF: int D2D1_ALPHA_MODE
+
+CONSTANT: D2D1_GAMMA_2_2         0
+CONSTANT: D2D1_GAMMA_1_0         1
+CONSTANT: D2D1_GAMMA_FORCE_DWORD HEX: ffffffff
+TYPEDEF: int D2D1_GAMMA
+
+CONSTANT: D2D1_OPACITY_MASK_CONTENT_GRAPHICS            0
+CONSTANT: D2D1_OPACITY_MASK_CONTENT_TEXT_NATURAL        1
+CONSTANT: D2D1_OPACITY_MASK_CONTENT_TEXT_GDI_COMPATIBLE 2
+CONSTANT: D2D1_OPACITY_MASK_CONTENT_FORCE_DWORD         HEX: ffffffff
+TYPEDEF: int D2D1_OPACITY_MASK_CONTENT
+
+CONSTANT: D2D1_EXTEND_MODE_CLAMP       0
+CONSTANT: D2D1_EXTEND_MODE_WRAP        1
+CONSTANT: D2D1_EXTEND_MODE_MIRROR      2
+CONSTANT: D2D1_EXTEND_MODE_FORCE_DWORD HEX: ffffffff
+TYPEDEF: int D2D1_EXTEND_MODE
+
+CONSTANT: D2D1_ANTIALIAS_MODE_PER_PRIMITIVE 0
+CONSTANT: D2D1_ANTIALIAS_MODE_ALIASED       1
+CONSTANT: D2D1_ANTIALIAS_MODE_FORCE_DWORD   HEX: ffffffff
+TYPEDEF: int D2D1_ANTIALIAS_MODE
+
+CONSTANT: D2D1_TEXT_ANTIALIAS_MODE_DEFAULT     0
+CONSTANT: D2D1_TEXT_ANTIALIAS_MODE_CLEARTYPE   1
+CONSTANT: D2D1_TEXT_ANTIALIAS_MODE_GRAYSCALE   2
+CONSTANT: D2D1_TEXT_ANTIALIAS_MODE_ALIASED     3
+CONSTANT: D2D1_TEXT_ANTIALIAS_MODE_FORCE_DWORD HEX: ffffffff
+TYPEDEF: int D2D1_TEXT_ANTIALIAS_MODE
+
+CONSTANT: D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR 0
+CONSTANT: D2D1_BITMAP_INTERPOLATION_MODE_LINEAR           1
+CONSTANT: D2D1_BITMAP_INTERPOLATION_MODE_FORCE_DWORD      HEX: ffffffff
+TYPEDEF: int D2D1_BITMAP_INTERPOLATION_MODE
+
+CONSTANT: D2D1_DRAW_TEXT_OPTIONS_NO_SNAP     HEX: 00000001
+CONSTANT: D2D1_DRAW_TEXT_OPTIONS_CLIP        HEX: 00000002
+CONSTANT: D2D1_DRAW_TEXT_OPTIONS_NONE        HEX: 00000000
+CONSTANT: D2D1_DRAW_TEXT_OPTIONS_FORCE_DWORD HEX: ffffffff
+TYPEDEF: int D2D1_DRAW_TEXT_OPTIONS
+
+STRUCT: D2D1_PIXEL_FORMAT
+    { format    DXGI_FORMAT     }
+    { alphaMode D2D1_ALPHA_MODE } ;
+
+TYPEDEF: D2D_POINT_2U D2D1_POINT_2U
+TYPEDEF: D2D_POINT_2F D2D1_POINT_2F
+TYPEDEF: D2D_RECT_F D2D1_RECT_F
+TYPEDEF: D2D_RECT_U D2D1_RECT_U
+TYPEDEF: D2D_SIZE_F D2D1_SIZE_F
+TYPEDEF: D2D_SIZE_U D2D1_SIZE_U
+TYPEDEF: D2D_COLOR_F D2D1_COLOR_F
+TYPEDEF: D2D_MATRIX_3X2_F D2D1_MATRIX_3X2_F
+TYPEDEF: UINT64 D2D1_TAG
+
+STRUCT: D2D1_BITMAP_PROPERTIES
+    { pixelFormat D2D1_PIXEL_FORMAT }
+    { dpiX        FLOAT             }
+    { dpiY        FLOAT             } ;
+
+STRUCT: D2D1_GRADIENT_STOP
+    { position FLOAT        }
+    { color    D2D1_COLOR_F } ;
+
+STRUCT: D2D1_BRUSH_PROPERTIES
+    { opacity   FLOAT             }
+    { transform D2D1_MATRIX_3X2_F } ;
+
+STRUCT: D2D1_BITMAP_BRUSH_PROPERTIES
+    { extendModeX       D2D1_EXTEND_MODE               }
+    { extendModeY       D2D1_EXTEND_MODE               }
+    { interpolationMode D2D1_BITMAP_INTERPOLATION_MODE } ;
+
+STRUCT: D2D1_LINEAR_GRADIENT_BRUSH_PROPERTIES
+    { startPoint D2D1_POINT_2F }
+    { endPoint   D2D1_POINT_2F } ;
+
+STRUCT: D2D1_RADIAL_GRADIENT_BRUSH_PROPERTIES
+    { center               D2D1_POINT_2F }
+    { gradientOriginOffset D2D1_POINT_2F }
+    { radiusX              FLOAT         }
+    { radiusY              FLOAT         } ;
+
+CONSTANT: D2D1_ARC_SIZE_SMALL 0
+CONSTANT: D2D1_ARC_SIZE_LARGE 1
+CONSTANT: D2D1_ARC_SIZE_FORCE_DWORD HEX: ffffffff
+TYPEDEF: int D2D1_ARC_SIZE
+
+CONSTANT: D2D1_CAP_STYLE_FLAT        0
+CONSTANT: D2D1_CAP_STYLE_SQUARE      1
+CONSTANT: D2D1_CAP_STYLE_ROUND       2
+CONSTANT: D2D1_CAP_STYLE_TRIANGLE    3
+CONSTANT: D2D1_CAP_STYLE_FORCE_DWORD HEX: ffffffff
+TYPEDEF: int D2D1_CAP_STYLE
+
+CONSTANT: D2D1_DASH_STYLE_SOLID        0
+CONSTANT: D2D1_DASH_STYLE_DASH         1
+CONSTANT: D2D1_DASH_STYLE_DOT          2
+CONSTANT: D2D1_DASH_STYLE_DASH_DOT     3
+CONSTANT: D2D1_DASH_STYLE_DASH_DOT_DOT 4
+CONSTANT: D2D1_DASH_STYLE_CUSTOM       5
+CONSTANT: D2D1_DASH_STYLE_FORCE_DWORD  HEX: ffffffff
+TYPEDEF: int D2D1_DASH_STYLE
+
+CONSTANT: D2D1_LINE_JOIN_MITER          0
+CONSTANT: D2D1_LINE_JOIN_BEVEL          1
+CONSTANT: D2D1_LINE_JOIN_ROUND          2
+CONSTANT: D2D1_LINE_JOIN_MITER_OR_BEVEL 3
+CONSTANT: D2D1_LINE_JOIN_FORCE_DWORD    HEX: ffffffff
+TYPEDEF: int D2D1_LINE_JOIN
+
+CONSTANT: D2D1_COMBINE_MODE_UNION       0
+CONSTANT: D2D1_COMBINE_MODE_INTERSECT   1
+CONSTANT: D2D1_COMBINE_MODE_XOR         2
+CONSTANT: D2D1_COMBINE_MODE_EXCLUDE     3
+CONSTANT: D2D1_COMBINE_MODE_FORCE_DWORD HEX: ffffffff
+TYPEDEF: int D2D1_COMBINE_MODE
+
+CONSTANT: D2D1_GEOMETRY_RELATION_UNKNOWN      0
+CONSTANT: D2D1_GEOMETRY_RELATION_DISJOINT     1
+CONSTANT: D2D1_GEOMETRY_RELATION_IS_CONTAINED 2
+CONSTANT: D2D1_GEOMETRY_RELATION_CONTAINS     3
+CONSTANT: D2D1_GEOMETRY_RELATION_OVERLAP      4
+CONSTANT: D2D1_GEOMETRY_RELATION_FORCE_DWORD  HEX: ffffffff
+TYPEDEF: int D2D1_GEOMETRY_RELATION
+
+CONSTANT: D2D1_GEOMETRY_SIMPLIFICATION_OPTION_CUBICS_AND_LINES 0
+CONSTANT: D2D1_GEOMETRY_SIMPLIFICATION_OPTION_LINES            1
+CONSTANT: D2D1_GEOMETRY_SIMPLIFICATION_OPTION_FORCE_DWORD      HEX: ffffffff
+TYPEDEF: int D2D1_GEOMETRY_SIMPLIFICATION_OPTION
+
+CONSTANT: D2D1_FIGURE_BEGIN_FILLED      0
+CONSTANT: D2D1_FIGURE_BEGIN_HOLLOW      1
+CONSTANT: D2D1_FIGURE_BEGIN_FORCE_DWORD HEX: ffffffff
+TYPEDEF: int D2D1_FIGURE_BEGIN
+
+CONSTANT: D2D1_FIGURE_END_OPEN        0
+CONSTANT: D2D1_FIGURE_END_CLOSED      1
+CONSTANT: D2D1_FIGURE_END_FORCE_DWORD HEX: ffffffff
+TYPEDEF: int D2D1_FIGURE_END
+
+STRUCT: D2D1_BEZIER_SEGMENT
+    { point1 D2D1_POINT_2F }
+    { point2 D2D1_POINT_2F }
+    { point3 D2D1_POINT_2F } ;
+
+STRUCT: D2D1_TRIANGLE
+    { point1 D2D1_POINT_2F }
+    { point2 D2D1_POINT_2F }
+    { point3 D2D1_POINT_2F } ;
+
+CONSTANT: D2D1_PATH_SEGMENT_NONE                  HEX: 00000000
+CONSTANT: D2D1_PATH_SEGMENT_FORCE_UNSTROKED       HEX: 00000001
+CONSTANT: D2D1_PATH_SEGMENT_FORCE_ROUND_LINE_JOIN HEX: 00000002
+CONSTANT: D2D1_PATH_SEGMENT_FORCE_DWORD           HEX: ffffffff
+TYPEDEF: int D2D1_PATH_SEGMENT
+
+CONSTANT: D2D1_SWEEP_DIRECTION_COUNTER_CLOCKWISE 0
+CONSTANT: D2D1_SWEEP_DIRECTION_CLOCKWISE         1
+CONSTANT: D2D1_SWEEP_DIRECTION_FORCE_DWORD       HEX: ffffffff
+TYPEDEF: int D2D1_SWEEP_DIRECTION
+
+CONSTANT: D2D1_FILL_MODE_ALTERNATE   0
+CONSTANT: D2D1_FILL_MODE_WINDING     1
+CONSTANT: D2D1_FILL_MODE_FORCE_DWORD HEX: ffffffff
+TYPEDEF: int D2D1_FILL_MODE
+
+STRUCT: D2D1_ARC_SEGMENT
+    { point          D2D1_POINT_2F        }
+    { size           D2D1_SIZE_F          }
+    { rotationAngle  FLOAT                }
+    { sweepDirection D2D1_SWEEP_DIRECTION }
+    { arcSize        D2D1_ARC_SIZE        } ;
+
+STRUCT: D2D1_QUADRATIC_BEZIER_SEGMENT
+    { point1 D2D1_POINT_2F }
+    { point2 D2D1_POINT_2F } ;
+
+STRUCT: D2D1_ELLIPSE
+    { point   D2D1_POINT_2F }
+    { radiusX FLOAT         }
+    { radiusY FLOAT         } ;
+
+STRUCT: D2D1_ROUNDED_RECT
+    { rect    D2D1_RECT_F }
+    { radiusX FLOAT       }
+    { radiusY FLOAT       } ;
+
+STRUCT: D2D1_STROKE_STYLE_PROPERTIES
+    { startCap   D2D1_CAP_STYLE  }
+    { endCap     D2D1_CAP_STYLE  }
+    { dashCap    D2D1_CAP_STYLE  }
+    { lineJoin   D2D1_LINE_JOIN  }
+    { miterLimit FLOAT           }
+    { dashStyle  D2D1_DASH_STYLE }
+    { dashOffset FLOAT           } ;
+
+CONSTANT: D2D1_LAYER_OPTIONS_NONE                     HEX: 00000000
+CONSTANT: D2D1_LAYER_OPTIONS_INITIALIZE_FOR_CLEARTYPE HEX: 00000001
+CONSTANT: D2D1_LAYER_OPTIONS_FORCE_DWORD              HEX: ffffffff
+TYPEDEF: int D2D1_LAYER_OPTIONS
+
+C-TYPE: ID2D1Geometry
+C-TYPE: ID2D1Brush
+C-TYPE: ID2D1RenderTarget
+
+STRUCT: D2D1_LAYER_PARAMETERS
+    { contentBounds     D2D1_RECT_F         }
+    { geometricMask     ID2D1Geometry*      }
+    { maskAntialiasMode D2D1_ANTIALIAS_MODE }
+    { maskTransform     D2D1_MATRIX_3X2_F   }
+    { opacity           FLOAT               }
+    { opacityBrush      ID2D1Brush*         }
+    { layerOptions      D2D1_LAYER_OPTIONS  } ;
+
+CONSTANT: D2D1_WINDOW_STATE_NONE        HEX: 00000000
+CONSTANT: D2D1_WINDOW_STATE_OCCLUDED    HEX: 00000001
+CONSTANT: D2D1_WINDOW_STATE_FORCE_DWORD HEX: ffffffff
+TYPEDEF: int D2D1_WINDOW_STATE
+
+CONSTANT: D2D1_RENDER_TARGET_TYPE_DEFAULT     0
+CONSTANT: D2D1_RENDER_TARGET_TYPE_SOFTWARE    1
+CONSTANT: D2D1_RENDER_TARGET_TYPE_HARDWARE    2
+CONSTANT: D2D1_RENDER_TARGET_TYPE_FORCE_DWORD HEX: ffffffff
+TYPEDEF: int D2D1_RENDER_TARGET_TYPE
+
+CONSTANT: D2D1_FEATURE_LEVEL_DEFAULT     0
+CONSTANT: D2D1_FEATURE_LEVEL_9           HEX: 9100
+CONSTANT: D2D1_FEATURE_LEVEL_10          HEX: a000
+CONSTANT: D2D1_FEATURE_LEVEL_FORCE_DWORD HEX: ffffffff
+TYPEDEF: int D2D1_FEATURE_LEVEL
+
+CONSTANT: D2D1_RENDER_TARGET_USAGE_NONE                  HEX: 00000000
+CONSTANT: D2D1_RENDER_TARGET_USAGE_FORCE_BITMAP_REMOTING HEX: 00000001
+CONSTANT: D2D1_RENDER_TARGET_USAGE_GDI_COMPATIBLE        HEX: 00000002
+CONSTANT: D2D1_RENDER_TARGET_USAGE_FORCE_DWORD           HEX: ffffffff
+TYPEDEF: int D2D1_RENDER_TARGET_USAGE
+
+CONSTANT: D2D1_PRESENT_OPTIONS_NONE            HEX: 00000000
+CONSTANT: D2D1_PRESENT_OPTIONS_RETAIN_CONTENTS HEX: 00000001
+CONSTANT: D2D1_PRESENT_OPTIONS_IMMEDIATELY     HEX: 00000002
+CONSTANT: D2D1_PRESENT_OPTIONS_FORCE_DWORD     HEX: ffffffff
+TYPEDEF: int D2D1_PRESENT_OPTIONS
+
+STRUCT: D2D1_RENDER_TARGET_PROPERTIES
+    { type        D2D1_RENDER_TARGET_TYPE  }
+    { pixelFormat D2D1_PIXEL_FORMAT        }
+    { dpiX        FLOAT                    }
+    { dpiY        FLOAT                    }
+    { usage       D2D1_RENDER_TARGET_USAGE }
+    { minLevel    D2D1_FEATURE_LEVEL       } ;
+
+STRUCT: D2D1_HWND_RENDER_TARGET_PROPERTIES
+    { hwnd           HWND                 }
+    { pixelSize      D2D1_SIZE_U          }
+    { presentOptions D2D1_PRESENT_OPTIONS } ;
+
+CONSTANT: D2D1_COMPATIBLE_RENDER_TARGET_OPTIONS_NONE           HEX: 00000000
+CONSTANT: D2D1_COMPATIBLE_RENDER_TARGET_OPTIONS_GDI_COMPATIBLE HEX: 00000001
+CONSTANT: D2D1_COMPATIBLE_RENDER_TARGET_OPTIONS_FORCE_DWORD    HEX: ffffffff
+TYPEDEF: int D2D1_COMPATIBLE_RENDER_TARGET_OPTIONS
+
+STRUCT: D2D1_DRAWING_STATE_DESCRIPTION
+    { antialiasMode     D2D1_ANTIALIAS_MODE      }
+    { textAntialiasMode D2D1_TEXT_ANTIALIAS_MODE }
+    { tag1              D2D1_TAG                 }
+    { tag2              D2D1_TAG                 }
+    { transform         D2D1_MATRIX_3X2_F        } ;
+
+CONSTANT: D2D1_DC_INITIALIZE_MODE_COPY        0
+CONSTANT: D2D1_DC_INITIALIZE_MODE_CLEAR       1
+CONSTANT: D2D1_DC_INITIALIZE_MODE_FORCE_DWORD HEX: ffffffff
+TYPEDEF: int D2D1_DC_INITIALIZE_MODE
+
+CONSTANT: D2D1_DEBUG_LEVEL_NONE        0
+CONSTANT: D2D1_DEBUG_LEVEL_ERROR       1
+CONSTANT: D2D1_DEBUG_LEVEL_WARNING     2
+CONSTANT: D2D1_DEBUG_LEVEL_INFORMATION 3
+CONSTANT: D2D1_DEBUG_LEVEL_FORCE_DWORD HEX: ffffffff
+TYPEDEF: int D2D1_DEBUG_LEVEL
+
+CONSTANT: D2D1_FACTORY_TYPE_SINGLE_THREADED 0
+CONSTANT: D2D1_FACTORY_TYPE_MULTI_THREADED  1
+CONSTANT: D2D1_FACTORY_TYPE_FORCE_DWORD     HEX: ffffffff
+TYPEDEF: int D2D1_FACTORY_TYPE
+
+STRUCT: D2D1_FACTORY_OPTIONS
+    { debugLevel D2D1_DEBUG_LEVEL } ;
+
+COM-INTERFACE: ID2D1Resource IUnknown {2cd90691-12e2-11dc-9fed-001143a055f9}
+    void GetFactory ( ID2D1Factory** factory ) ;
+
+COM-INTERFACE: ID2D1Bitmap ID2D1Resource {a2296057-ea42-4099-983b-539fb6505426}
+    D2D1_SIZE_F GetSize ( )
+    D2D1_SIZE_U GetPixelSize ( )
+    D2D1_PIXEL_FORMAT GetPixelFormat ( )
+    void GetDpi ( FLOAT* dpiX, FLOAT* dpiY )
+    HRESULT CopyFromBitmap ( D2D1_POINT_2U* destPoint, ID2D1Bitmap* bitmap, D2D1_RECT_U* srcRect )
+    HRESULT CopyFromRenderTarget ( D2D1_POINT_2U* destPoint, ID2D1RenderTarget* renderTarget, D2D1_RECT_U* srcRect )
+    HRESULT CopyFromMemory ( D2D1_RECT_U* dstRect, void* srcData, UINT32 pitch ) ;
+
+COM-INTERFACE: ID2D1GradientStopCollection ID2D1Resource {2cd906a7-12e2-11dc-9fed-001143a055f9}
+    UINT32 GetGradientStopCount ( )
+    void GetGradientStops ( D2D1_GRADIENT_STOP* gradientStops, UINT gradientStopsCount )
+    D2D1_GAMMA GetColorInterpolationGamma ( )
+    D2D1_EXTEND_MODE GetExtendMode ( ) ;
+
+COM-INTERFACE: ID2D1Brush ID2D1Resource {2cd906a8-12e2-11dc-9fed-001143a055f9}
+    void SetOpacity ( FLOAT opacity )
+    void SetTransform ( D2D1_MATRIX_3X2_F* transform )
+    FLOAT GetOpacity ( )
+    void GetTransform ( D2D1_MATRIX_3X2_F* transform ) ;
+
+COM-INTERFACE: ID2D1BitmapBrush ID2D1Brush {2cd906aa-12e2-11dc-9fed-001143a055f9}
+    void SetExtendModeX ( D2D1_EXTEND_MODE extendModeX )
+    void SetExtendModeY ( D2D1_EXTEND_MODE extendModeY )
+    void SetInterpolationMode ( D2D1_BITMAP_INTERPOLATION_MODE interpolationMode )
+    void SetBitmap ( ID2D1Bitmap* bitmap )
+    D2D1_EXTEND_MODE GetExtendModeX ( )
+    D2D1_EXTEND_MODE GetExtendModeY ( )
+    D2D1_BITMAP_INTERPOLATION_MODE GetInterpolationMode ( )
+    void GetBitmap ( ID2D1Bitmap** bitmap ) ;
+
+COM-INTERFACE: ID2D1SolidColorBrush ID2D1Brush {2cd906a9-12e2-11dc-9fed-001143a055f9}
+    void SetColor ( D2D1_COLOR_F* color )
+    D2D1_COLOR_F GetColor ( ) ;
+
+COM-INTERFACE: ID2D1LinearGradientBrush ID2D1Brush {2cd906ab-12e2-11dc-9fed-001143a055f9}
+    void SetStartPoint ( D2D1_POINT_2F startPoint )
+    void SetEndPoint ( D2D1_POINT_2F endPoint )
+    D2D1_POINT_2F GetStartPoint ( )
+    D2D1_POINT_2F GetEndPoint ( )
+    void GetGradientStopCollection ( ID2D1GradientStopCollection** gradientStopCollection ) ;
+
+COM-INTERFACE: ID2D1RadialGradientBrush ID2D1Brush {2cd906ac-12e2-11dc-9fed-001143a055f9}
+    void SetCenter ( D2D1_POINT_2F center )
+    void SetGradientOriginOffset ( D2D1_POINT_2F gradientOriginOffset )
+    void SetRadiusX ( FLOAT radiusX )
+    void SetRadiusY ( FLOAT radiusY )
+    D2D1_POINT_2F GetCenter ( )
+    D2D1_POINT_2F GetGradientOriginOffset ( )
+    FLOAT GetRadiusX ( )
+    FLOAT GetRadiusY ( )
+    void GetGradientStopCollection ( ID2D1GradientStopCollection** gradientStopCollection ) ;
+
+COM-INTERFACE: ID2D1StrokeStyle ID2D1Resource {2cd9069d-12e2-11dc-9fed-001143a055f9}
+    D2D1_CAP_STYLE GetStartCap ( )
+    D2D1_CAP_STYLE GetEndCap ( )
+    D2D1_CAP_STYLE GetDashCap ( )
+    FLOAT GetMiterLimit ( )
+    D2D1_LINE_JOIN GetLineJoin ( )
+    FLOAT GetDashOffset ( )
+    D2D1_DASH_STYLE GetDashStyle ( )
+    UINT32 GetDashesCount ( )
+    void GetDashes ( FLOAT* dashes, UINT dashesCount ) ;
+
+C-TYPE: ID2D1SimplifiedGeometrySink
+C-TYPE: ID2D1TessellationSink
+
+COM-INTERFACE: ID2D1Geometry ID2D1Resource {2cd906a1-12e2-11dc-9fed-001143a055f9}
+    HRESULT GetBounds ( D2D1_MATRIX_3X2_F* worldTransform, D2D1_RECT_F* bounds )
+    HRESULT GetWidenedBounds ( FLOAT strokeWidth, ID2D1StrokeStyle* strokeStyle, D2D1_MATRIX_3X2_F* worldTransform, FLOAT flatteningTolerance, D2D1_RECT_F* bounds )
+    HRESULT StrokeContainsPoint ( D2D1_POINT_2F point, FLOAT strokeWidth, ID2D1StrokeStyle* strokeStyle, D2D1_MATRIX_3X2_F* worldTransform, FLOAT flatteningTolerance, BOOL* contains )
+    HRESULT FillContainsPoint ( D2D1_POINT_2F point, D2D1_MATRIX_3X2_F* worldTransform, FLOAT flatteningTolerance, BOOL* contains )
+    HRESULT CompareWithGeometry ( ID2D1Geometry* inputGeometry, D2D1_MATRIX_3X2_F* inputGeometryTransform, FLOAT flatteningTolerance, D2D1_GEOMETRY_RELATION* relation )
+    HRESULT Simplify ( D2D1_GEOMETRY_SIMPLIFICATION_OPTION simplificationOption, D2D1_MATRIX_3X2_F* worldTransform, FLOAT flatteningTolerance, ID2D1SimplifiedGeometrySink* geometrySink )
+    HRESULT Tessellate ( D2D1_MATRIX_3X2_F* worldTransform, FLOAT flatteningTolerance, ID2D1TessellationSink* tessellationSink )
+    HRESULT CombineWithGeometry ( ID2D1Geometry* inputGeometry, D2D1_COMBINE_MODE combineMode, D2D1_MATRIX_3X2_F* inputGeometryTransform, FLOAT flatteningTolerance, ID2D1SimplifiedGeometrySink* geometrySink )
+    HRESULT Outline ( D2D1_MATRIX_3X2_F* worldTransform, FLOAT flatteningTolerance, ID2D1SimplifiedGeometrySink* geometrySink )
+    HRESULT ComputeArea ( D2D1_MATRIX_3X2_F* worldTransform, FLOAT flatteningTolerance, FLOAT* area )
+    HRESULT ComputeLength ( D2D1_MATRIX_3X2_F* worldTransform, FLOAT flatteningTolerance, FLOAT* length )
+    HRESULT ComputePointAtLength ( FLOAT length, D2D1_MATRIX_3X2_F* worldTransform, FLOAT flatteningTolerance, D2D1_POINT_2F* point, D2D1_POINT_2F* unitTangentVector )
+    HRESULT Widen ( FLOAT strokeWidth, ID2D1StrokeStyle* strokeStyle, D2D1_MATRIX_3X2_F* worldTransform, FLOAT flatteningTolerance, ID2D1SimplifiedGeometrySink* geometrySink ) ;
+
+COM-INTERFACE: ID2D1RectangleGeometry ID2D1Geometry {2cd906a2-12e2-11dc-9fed-001143a055f9}
+    void GetRect ( D2D1_RECT_F* rect ) ;
+
+COM-INTERFACE: ID2D1RoundedRectangleGeometry ID2D1Geometry {2cd906a3-12e2-11dc-9fed-001143a055f9}
+    void GetRoundedRect ( D2D1_ROUNDED_RECT* roundedRect ) ;
+
+COM-INTERFACE: ID2D1EllipseGeometry ID2D1Geometry {2cd906a4-12e2-11dc-9fed-001143a055f9}
+    void GetEllipse ( D2D1_ELLIPSE* ellipse ) ;
+
+COM-INTERFACE: ID2D1GeometryGroup ID2D1Geometry {2cd906a6-12e2-11dc-9fed-001143a055f9}
+    D2D1_FILL_MODE GetFillMode ( )
+    UINT32 GetSourceGeometryCount ( )
+    void GetSourceGeometries ( ID2D1Geometry** geometries, UINT geometriesCount ) ;
+
+COM-INTERFACE: ID2D1TransformedGeometry ID2D1Geometry {2cd906bb-12e2-11dc-9fed-001143a055f9}
+    void GetSourceGeometry ( ID2D1Geometry** sourceGeometry )
+    void GetTransform ( D2D1_MATRIX_3X2_F* transform ) ;
+
+COM-INTERFACE: ID2D1SimplifiedGeometrySink IUnknown {2cd9069e-12e2-11dc-9fed-001143a055f9}
+    void SetFillMode ( D2D1_FILL_MODE fillMode )
+    void SetSegmentFlags ( D2D1_PATH_SEGMENT vertexFlags )
+    void BeginFigure ( D2D1_POINT_2F startPoint, D2D1_FIGURE_BEGIN figureBegin )
+    void AddLines ( D2D1_POINT_2F* points, UINT pointsCount )
+    void AddBeziers ( D2D1_BEZIER_SEGMENT* beziers, UINT beziersCount )
+    void EndFigure ( D2D1_FIGURE_END figureEnd )
+    HRESULT Close ( ) ;
+
+COM-INTERFACE: ID2D1GeometrySink ID2D1SimplifiedGeometrySink {2cd9069f-12e2-11dc-9fed-001143a055f9}
+    void AddLine ( D2D1_POINT_2F point )
+    void AddBezier ( D2D1_BEZIER_SEGMENT* bezier )
+    void AddQuadraticBezier ( D2D1_QUADRATIC_BEZIER_SEGMENT* bezier )
+    void AddQuadraticBeziers ( D2D1_QUADRATIC_BEZIER_SEGMENT* beziers, UINT beziersCount )
+    void AddArc ( D2D1_ARC_SEGMENT* arc ) ;
+
+COM-INTERFACE: ID2D1TessellationSink IUnknown {2cd906c1-12e2-11dc-9fed-001143a055f9}
+    void AddTriangles ( D2D1_TRIANGLE* triangles, UINT trianglesCount )
+    HRESULT Close ( ) ;
+
+COM-INTERFACE: ID2D1PathGeometry ID2D1Geometry {2cd906a5-12e2-11dc-9fed-001143a055f9}
+    HRESULT Open ( ID2D1GeometrySink** geometrySink )
+    HRESULT Stream ( ID2D1GeometrySink* geometrySink )
+    HRESULT GetSegmentCount ( UINT32* count )
+    HRESULT GetFigureCount ( UINT32* count ) ;
+
+COM-INTERFACE: ID2D1Mesh ID2D1Resource {2cd906c2-12e2-11dc-9fed-001143a055f9}
+    HRESULT Open ( ID2D1TessellationSink** tessellationSink ) ;
+
+COM-INTERFACE: ID2D1Layer ID2D1Resource {2cd9069b-12e2-11dc-9fed-001143a055f9}
+    D2D1_SIZE_F GetSize ( ) ;
+
+C-TYPE: IDWriteRenderingParams
+
+COM-INTERFACE: ID2D1DrawingStateBlock ID2D1Resource {28506e39-ebf6-46a1-bb47-fd85565ab957}
+    void GetDescription ( D2D1_DRAWING_STATE_DESCRIPTION* stateDescription )
+    void SetDescription ( D2D1_DRAWING_STATE_DESCRIPTION* stateDescription )
+    void SetTextRenderingParams ( IDWriteRenderingParams* textRenderingParams )
+    void GetTextRenderingParams ( IDWriteRenderingParams** textRenderingParams ) ;
+
+C-TYPE: IWICBitmapSource
+C-TYPE: IWICBitmap
+C-TYPE: IDWriteTextFormat
+C-TYPE: IDWriteTextLayout
+C-TYPE: DWRITE_GLYPH_RUN
+
+COM-INTERFACE: ID2D1RenderTarget ID2D1Resource {2cd90694-12e2-11dc-9fed-001143a055f9}
+    HRESULT CreateBitmap ( D2D1_SIZE_U size, void* srcData, UINT32 pitch, D2D1_BITMAP_PROPERTIES* bitmapProperties, ID2D1Bitmap** bitmap )
+    HRESULT CreateBitmapFromWicBitmap ( IWICBitmapSource* wicBitmapSource, D2D1_BITMAP_PROPERTIES* bitmapProperties, ID2D1Bitmap** bitmap )
+    HRESULT CreateSharedBitmap ( REFIID riid, void* data, D2D1_BITMAP_PROPERTIES* bitmapProperties, ID2D1Bitmap** bitmap )
+    HRESULT CreateBitmapBrush ( ID2D1Bitmap* bitmap, D2D1_BITMAP_BRUSH_PROPERTIES* bitmapBrushProperties, D2D1_BRUSH_PROPERTIES* brushProperties, ID2D1BitmapBrush** bitmapBrush )
+    HRESULT CreateSolidColorBrush ( D2D1_COLOR_F* color, D2D1_BRUSH_PROPERTIES* brushProperties, ID2D1SolidColorBrush** solidColorBrush )
+    HRESULT CreateGradientStopCollection ( D2D1_GRADIENT_STOP* gradientStops, UINT gradientStopsCount, D2D1_GAMMA colorInterpolationGamma, D2D1_EXTEND_MODE extendMode, ID2D1GradientStopCollection** gradientStopCollection )
+    HRESULT CreateLinearGradientBrush ( D2D1_LINEAR_GRADIENT_BRUSH_PROPERTIES* linearGradientBrushProperties, D2D1_BRUSH_PROPERTIES* brushProperties, ID2D1GradientStopCollection* gradientStopCollection, ID2D1LinearGradientBrush** linearGradientBrush )
+    HRESULT CreateRadialGradientBrush ( D2D1_RADIAL_GRADIENT_BRUSH_PROPERTIES* radialGradientBrushProperties, D2D1_BRUSH_PROPERTIES* brushProperties, ID2D1GradientStopCollection* gradientStopCollection, ID2D1RadialGradientBrush** radialGradientBrush )
+    HRESULT CreateCompatibleRenderTarget ( D2D1_SIZE_F* desiredSize, D2D1_SIZE_U* desiredPixelSize, D2D1_PIXEL_FORMAT* desiredFormat, D2D1_COMPATIBLE_RENDER_TARGET_OPTIONS options, ID2D1BitmapRenderTarget** bitmapRenderTarget )
+    HRESULT CreateLayer ( D2D1_SIZE_F* size, ID2D1Layer** layer )
+    HRESULT CreateMesh ( ID2D1Mesh** mesh )
+    void DrawLine ( D2D1_POINT_2F point0, D2D1_POINT_2F point1, ID2D1Brush* brush, FLOAT strokeWidth, ID2D1StrokeStyle* strokeStyle )
+    void DrawRectangle ( D2D1_RECT_F* rect, ID2D1Brush* brush, FLOAT strokeWidth, ID2D1StrokeStyle* strokeStyle )
+    void FillRectangle ( D2D1_RECT_F* rect, ID2D1Brush* brush )
+    void DrawRoundedRectangle ( D2D1_ROUNDED_RECT* roundedRect, ID2D1Brush* brush, FLOAT strokeWidth, ID2D1StrokeStyle* strokeStyle )
+    void FillRoundedRectangle ( D2D1_ROUNDED_RECT* roundedRect, ID2D1Brush* brush )
+    void DrawEllipse ( D2D1_ELLIPSE* ellipse, ID2D1Brush* brush, FLOAT strokeWidth, ID2D1StrokeStyle* strokeStyle )
+    void FillEllipse ( D2D1_ELLIPSE* ellipse, ID2D1Brush* brush )
+    void DrawGeometry ( ID2D1Geometry* geometry, ID2D1Brush* brush, FLOAT strokeWidth, ID2D1StrokeStyle* strokeStyle )
+    void FillGeometry ( ID2D1Geometry* geometry, ID2D1Brush* brush, ID2D1Brush* opacityBrush )
+    void FillMesh ( ID2D1Mesh* mesh, ID2D1Brush* brush )
+    void FillOpacityMask ( ID2D1Bitmap* opacityMask, ID2D1Brush* brush, D2D1_OPACITY_MASK_CONTENT content, D2D1_RECT_F* destinationRectangle, D2D1_RECT_F* sourceRectangle )
+    void DrawBitmap ( ID2D1Bitmap* bitmap, D2D1_RECT_F* destinationRectangle, FLOAT opacity, D2D1_BITMAP_INTERPOLATION_MODE interpolationMode, D2D1_RECT_F* sourceRectangle )
+    void DrawText ( WCHAR* string, UINT stringLength, IDWriteTextFormat* textFormat, D2D1_RECT_F* layoutRect, ID2D1Brush* defaultForegroundBrush, D2D1_DRAW_TEXT_OPTIONS options, DWRITE_MEASURING_MODE measuringMode )
+    void DrawTextLayout ( D2D1_POINT_2F origin, IDWriteTextLayout* textLayout, ID2D1Brush* defaultForegroundBrush, D2D1_DRAW_TEXT_OPTIONS options )
+    void DrawGlyphRun ( D2D1_POINT_2F baselineOrigin, DWRITE_GLYPH_RUN* glyphRun, ID2D1Brush* foregroundBrush, DWRITE_MEASURING_MODE measuringMode )
+    void SetTransform ( D2D1_MATRIX_3X2_F* transform )
+    void GetTransform ( D2D1_MATRIX_3X2_F* transform )
+    void SetAntialiasMode ( D2D1_ANTIALIAS_MODE antialiasMode )
+    D2D1_ANTIALIAS_MODE GetAntialiasMode ( )
+    void SetTextAntialiasMode ( D2D1_TEXT_ANTIALIAS_MODE textAntialiasMode )
+    D2D1_TEXT_ANTIALIAS_MODE GetTextAntialiasMode ( )
+    void SetTextRenderingParams ( IDWriteRenderingParams* textRenderingParams )
+    void GetTextRenderingParams ( IDWriteRenderingParams** textRenderingParams )
+    void SetTags ( D2D1_TAG tag1, D2D1_TAG tag2 )
+    void GetTags ( D2D1_TAG* tag1, D2D1_TAG* tag2 )
+    void PushLayer ( D2D1_LAYER_PARAMETERS* layerParameters, ID2D1Layer* layer )
+    void PopLayer ( )
+    HRESULT Flush ( D2D1_TAG* tag1, D2D1_TAG* tag2 )
+    void SaveDrawingState ( ID2D1DrawingStateBlock* drawingStateBlock )
+    void RestoreDrawingState ( ID2D1DrawingStateBlock* drawingStateBlock )
+    void PushAxisAlignedClip ( D2D1_RECT_F* clipRect, D2D1_ANTIALIAS_MODE antialiasMode )
+    void PopAxisAlignedClip ( )
+    void Clear ( D2D1_COLOR_F* clearColor )
+    void BeginDraw ( )
+    HRESULT EndDraw ( D2D1_TAG* tag1, D2D1_TAG* tag2 )
+    D2D1_PIXEL_FORMAT GetPixelFormat ( )
+    void SetDpi ( FLOAT dpiX, FLOAT dpiY )
+    void GetDpi ( FLOAT* dpiX, FLOAT* dpiY )
+    D2D1_SIZE_F GetSize ( )
+    D2D1_SIZE_U GetPixelSize ( )
+    UINT32 GetMaximumBitmapSize ( )
+    BOOL IsSupported ( D2D1_RENDER_TARGET_PROPERTIES* renderTargetProperties ) ;
+
+COM-INTERFACE: ID2D1BitmapRenderTarget ID2D1RenderTarget {2cd90695-12e2-11dc-9fed-001143a055f9}
+    HRESULT GetBitmap ( ID2D1Bitmap** bitmap ) ;
+
+COM-INTERFACE: ID2D1HwndRenderTarget ID2D1RenderTarget {2cd90698-12e2-11dc-9fed-001143a055f9}
+    D2D1_WINDOW_STATE CheckWindowState ( )
+    HRESULT Resize ( D2D1_SIZE_U* pixelSize )
+    HWND GetHwnd ( ) ;
+
+COM-INTERFACE: ID2D1GdiInteropRenderTarget IUnknown {e0db51c3-6f77-4bae-b3d5-e47509b35838}
+    HRESULT GetDC ( D2D1_DC_INITIALIZE_MODE mode, HDC* hdc )
+    HRESULT ReleaseDC ( RECT* update ) ;
+
+COM-INTERFACE: ID2D1DCRenderTarget ID2D1RenderTarget {1c51bc64-de61-46fd-9899-63a5d8f03950}
+    HRESULT BindDC ( HDC hDC, RECT* pSubRect ) ;
+
+COM-INTERFACE: ID2D1Factory IUnknown {06152247-6f50-465a-9245-118bfd3b6007}
+    HRESULT ReloadSystemMetrics ( )
+    void GetDesktopDpi ( FLOAT* dpiX, FLOAT* dpiY )
+    HRESULT CreateRectangleGeometry ( D2D1_RECT_F* rectangle, ID2D1RectangleGeometry** rectangleGeometry )
+    HRESULT CreateRoundedRectangleGeometry ( D2D1_ROUNDED_RECT* roundedRectangle, ID2D1RoundedRectangleGeometry** roundedRectangleGeometry )
+    HRESULT CreateEllipseGeometry ( D2D1_ELLIPSE* ellipse, ID2D1EllipseGeometry** ellipseGeometry )
+    HRESULT CreateGeometryGroup ( D2D1_FILL_MODE fillMode, ID2D1Geometry** geometries, UINT geometriesCount, ID2D1GeometryGroup** geometryGroup )
+    HRESULT CreateTransformedGeometry ( ID2D1Geometry* sourceGeometry, D2D1_MATRIX_3X2_F* transform, ID2D1TransformedGeometry** transformedGeometry )
+    HRESULT CreatePathGeometry ( ID2D1PathGeometry** pathGeometry )
+    HRESULT CreateStrokeStyle ( D2D1_STROKE_STYLE_PROPERTIES* strokeStyleProperties, FLOAT* dashes, UINT dashesCount, ID2D1StrokeStyle** strokeStyle )
+    HRESULT CreateDrawingStateBlock ( D2D1_DRAWING_STATE_DESCRIPTION* drawingStateDescription, IDWriteRenderingParams* textRenderingParams, ID2D1DrawingStateBlock** drawingStateBlock )
+    HRESULT CreateWicBitmapRenderTarget ( IWICBitmap* target, D2D1_RENDER_TARGET_PROPERTIES* renderTargetProperties, ID2D1RenderTarget** renderTarget )
+    HRESULT CreateHwndRenderTarget ( D2D1_RENDER_TARGET_PROPERTIES* renderTargetProperties, D2D1_HWND_RENDER_TARGET_PROPERTIES* hwndRenderTargetProperties, ID2D1HwndRenderTarget** hwndRenderTarget )
+    HRESULT CreateDxgiSurfaceRenderTarget ( IDXGISurface* dxgiSurface, D2D1_RENDER_TARGET_PROPERTIES* renderTargetProperties, ID2D1RenderTarget** renderTarget )
+    HRESULT CreateDCRenderTarget ( D2D1_RENDER_TARGET_PROPERTIES* renderTargetProperties, ID2D1DCRenderTarget** dcRenderTarget ) ;
+
+FUNCTION: HRESULT D2D1CreateFactory (
+        D2D1_FACTORY_TYPE     factoryType,
+        REFIID                riid,
+        D2D1_FACTORY_OPTIONS* pFactoryOptions,
+        void**                ppIFactory ) ;
+
+FUNCTION: void D2D1MakeRotateMatrix (
+        FLOAT              angle,
+        D2D1_POINT_2F      center,
+        D2D1_MATRIX_3X2_F* matrix ) ;
+
+FUNCTION: void D2D1MakeSkewMatrix (
+        FLOAT              angleX,
+        FLOAT              angleY,
+        D2D1_POINT_2F      center,
+        D2D1_MATRIX_3X2_F* matrix ) ;
+
+FUNCTION: BOOL D2D1IsMatrixInvertible (
+        D2D1_MATRIX_3X2_F* matrix ) ;
+
+FUNCTION: BOOL D2D1InvertMatrix (
+        D2D1_MATRIX_3X2_F* matrix ) ;
+
diff --git a/basis/windows/directx/d2d1/summary.txt b/basis/windows/directx/d2d1/summary.txt
new file mode 100644 (file)
index 0000000..de9706e
--- /dev/null
@@ -0,0 +1 @@
+Direct2D bindings. Corresponds to d2d1.h.
diff --git a/basis/windows/directx/d2d1/tags.txt b/basis/windows/directx/d2d1/tags.txt
new file mode 100644 (file)
index 0000000..2320bdd
--- /dev/null
@@ -0,0 +1,2 @@
+unportable
+bindings
diff --git a/basis/windows/directx/d2dbasetypes/authors.txt b/basis/windows/directx/d2dbasetypes/authors.txt
new file mode 100644 (file)
index 0000000..6f03a12
--- /dev/null
@@ -0,0 +1 @@
+Erik Charlebois
diff --git a/basis/windows/directx/d2dbasetypes/d2dbasetypes.factor b/basis/windows/directx/d2dbasetypes/d2dbasetypes.factor
new file mode 100644 (file)
index 0000000..00f84e9
--- /dev/null
@@ -0,0 +1,46 @@
+USING: alien.syntax classes.struct windows.types ;
+IN: windows.directx.d3dbasetypes
+
+STRUCT: D3DCOLORVALUE
+    { r FLOAT } 
+    { g FLOAT }
+    { b FLOAT }
+    { a FLOAT } ;
+
+STRUCT: D2D_POINT_2U
+    { x UINT32 }
+    { y UINT32 } ;
+
+STRUCT: D2D_POINT_2F
+    { x FLOAT }
+    { y FLOAT } ;
+
+STRUCT: D2D_RECT_F
+    { left   FLOAT }
+    { top    FLOAT }
+    { right  FLOAT }
+    { bottom FLOAT } ;
+
+STRUCT: D2D_RECT_U
+    { left   UINT32 }
+    { top    UINT32 }
+    { right  UINT32 }
+    { bottom UINT32 } ;
+
+STRUCT: D2D_SIZE_F
+    { width  FLOAT }
+    { height FLOAT } ;
+
+STRUCT: D2D_SIZE_U
+    { width  UINT32 }
+    { height UINT32 } ;
+
+TYPEDEF: D3DCOLORVALUE D2D_COLOR_F
+
+STRUCT: D2D_MATRIX_3X2_F
+    { _11 FLOAT }
+    { _12 FLOAT }
+    { _21 FLOAT }
+    { _22 FLOAT }
+    { _31 FLOAT }
+    { _32 FLOAT } ;
diff --git a/basis/windows/directx/d2dbasetypes/summary.txt b/basis/windows/directx/d2dbasetypes/summary.txt
new file mode 100644 (file)
index 0000000..e40000d
--- /dev/null
@@ -0,0 +1 @@
+Direct2D bindings. Corresponds to d2dbasetypes.h.
diff --git a/basis/windows/directx/d2dbasetypes/tags.txt b/basis/windows/directx/d2dbasetypes/tags.txt
new file mode 100644 (file)
index 0000000..2320bdd
--- /dev/null
@@ -0,0 +1,2 @@
+unportable
+bindings
diff --git a/basis/windows/directx/d2derr/authors.txt b/basis/windows/directx/d2derr/authors.txt
new file mode 100644 (file)
index 0000000..6f03a12
--- /dev/null
@@ -0,0 +1 @@
+Erik Charlebois
diff --git a/basis/windows/directx/d2derr/d2derr.factor b/basis/windows/directx/d2derr/d2derr.factor
new file mode 100644 (file)
index 0000000..1e5d891
--- /dev/null
@@ -0,0 +1,34 @@
+USING: ;
+IN: windows.directx.d2derr
+
+CONSTANT: D2DERR_UNSUPPORTED_PIXEL_FORMAT            HEX: 88982f80
+CONSTANT: D2DERR_INSUFFICIENT_BUFFER                 HEX: 80007007a
+CONSTANT: D2DERR_WRONG_STATE                         HEX: 88990001
+CONSTANT: D2DERR_NOT_INITIALIZED                     HEX: 88990002
+CONSTANT: D2DERR_UNSUPPORTED_OPERATION               HEX: 88990003
+CONSTANT: D2DERR_SCANNER_FAILED                      HEX: 88990004
+CONSTANT: D2DERR_SCREEN_ACCESS_DENIED                HEX: 88990005
+CONSTANT: D2DERR_DISPLAY_STATE_INVALID               HEX: 88990006
+CONSTANT: D2DERR_ZERO_VECTOR                         HEX: 88990007
+CONSTANT: D2DERR_INTERNAL_ERROR                      HEX: 88990008
+CONSTANT: D2DERR_DISPLAY_FORMAT_NOT_SUPPORTED        HEX: 88990009
+CONSTANT: D2DERR_INVALID_CALL                        HEX: 8899000A
+CONSTANT: D2DERR_NO_HARDWARE_DEVICE                  HEX: 8899000B
+CONSTANT: D2DERR_RECREATE_TARGET                     HEX: 8899000C
+CONSTANT: D2DERR_TOO_MANY_SHADER_ELEMENTS            HEX: 8899000D
+CONSTANT: D2DERR_SHADER_COMPILE_FAILED               HEX: 8899000E
+CONSTANT: D2DERR_MAX_TEXTURE_SIZE_EXCEEDED           HEX: 8899000F
+CONSTANT: D2DERR_UNSUPPORTED_VERSION                 HEX: 88990010
+CONSTANT: D2DERR_BAD_NUMBER                          HEX: 88990011
+CONSTANT: D2DERR_WRONG_FACTORY                       HEX: 88990012
+CONSTANT: D2DERR_LAYER_ALREADY_IN_USE                HEX: 88990013
+CONSTANT: D2DERR_POP_CALL_DID_NOT_MATCH_PUSH         HEX: 88990014
+CONSTANT: D2DERR_WRONG_RESOURCE_DOMAIN               HEX: 88990015
+CONSTANT: D2DERR_PUSH_POP_UNBALANCED                 HEX: 88990016
+CONSTANT: D2DERR_RENDER_TARGET_HAS_LAYER_OR_CLIPRECT HEX: 88990017
+CONSTANT: D2DERR_INCOMPATIBLE_BRUSH_TYPES            HEX: 88990018
+CONSTANT: D2DERR_WIN32_ERROR                         HEX: 88990019
+CONSTANT: D2DERR_TARGET_NOT_GDI_COMPATIBLE           HEX: 8899001A
+CONSTANT: D2DERR_TEXT_EFFECT_IS_WRONG_TYPE           HEX: 8899001B
+CONSTANT: D2DERR_TEXT_RENDERER_NOT_RELEASED          HEX: 8899001C
+CONSTANT: D2DERR_EXCEEDS_MAX_BITMAP_SIZE             HEX: 8899001D
diff --git a/basis/windows/directx/d2derr/summary.txt b/basis/windows/directx/d2derr/summary.txt
new file mode 100644 (file)
index 0000000..a86f192
--- /dev/null
@@ -0,0 +1 @@
+Direct2D bindings. Corresponds to d2derr.h.
diff --git a/basis/windows/directx/d2derr/tags.txt b/basis/windows/directx/d2derr/tags.txt
new file mode 100644 (file)
index 0000000..2320bdd
--- /dev/null
@@ -0,0 +1,2 @@
+unportable
+bindings
diff --git a/basis/windows/directx/d3d10/authors.txt b/basis/windows/directx/d3d10/authors.txt
new file mode 100644 (file)
index 0000000..6f03a12
--- /dev/null
@@ -0,0 +1 @@
+Erik Charlebois
diff --git a/basis/windows/directx/d3d10/d3d10.factor b/basis/windows/directx/d3d10/d3d10.factor
new file mode 100644 (file)
index 0000000..561aa47
--- /dev/null
@@ -0,0 +1,1051 @@
+USING: alien.syntax alien.c-types classes.struct windows.types
+windows.directx.dxgiformat windows.com.syntax windows.com windows.ole32
+windows.directx.dxgitype ;
+IN: windows.directx.d3d10
+
+LIBRARY: d3d10
+
+CONSTANT: D3D10_16BIT_INDEX_STRIP_CUT_VALUE                                    HEX: ffff
+CONSTANT: D3D10_32BIT_INDEX_STRIP_CUT_VALUE                                    HEX: ffffffff
+CONSTANT: D3D10_8BIT_INDEX_STRIP_CUT_VALUE                                     HEX: ff
+CONSTANT: D3D10_ARRAY_AXIS_ADDRESS_RANGE_BIT_COUNT                             9
+CONSTANT: D3D10_CLIP_OR_CULL_DISTANCE_COUNT                                    8
+CONSTANT: D3D10_CLIP_OR_CULL_DISTANCE_ELEMENT_COUNT                            2
+CONSTANT: D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT                    14
+CONSTANT: D3D10_COMMONSHADER_CONSTANT_BUFFER_COMPONENTS                        4
+CONSTANT: D3D10_COMMONSHADER_CONSTANT_BUFFER_COMPONENT_BIT_COUNT               32
+CONSTANT: D3D10_COMMONSHADER_CONSTANT_BUFFER_HW_SLOT_COUNT                     15
+CONSTANT: D3D10_COMMONSHADER_CONSTANT_BUFFER_REGISTER_COMPONENTS               4
+CONSTANT: D3D10_COMMONSHADER_CONSTANT_BUFFER_REGISTER_COUNT                    15
+CONSTANT: D3D10_COMMONSHADER_CONSTANT_BUFFER_REGISTER_READS_PER_INST           1
+CONSTANT: D3D10_COMMONSHADER_CONSTANT_BUFFER_REGISTER_READ_PORTS               1
+CONSTANT: D3D10_COMMONSHADER_FLOWCONTROL_NESTING_LIMIT                         64
+CONSTANT: D3D10_COMMONSHADER_IMMEDIATE_CONSTANT_BUFFER_REGISTER_COMPONENTS     4
+CONSTANT: D3D10_COMMONSHADER_IMMEDIATE_CONSTANT_BUFFER_REGISTER_COUNT          1
+CONSTANT: D3D10_COMMONSHADER_IMMEDIATE_CONSTANT_BUFFER_REGISTER_READS_PER_INST 1
+CONSTANT: D3D10_COMMONSHADER_IMMEDIATE_CONSTANT_BUFFER_REGISTER_READ_PORTS     1
+CONSTANT: D3D10_COMMONSHADER_IMMEDIATE_VALUE_COMPONENT_BIT_COUNT               32
+CONSTANT: D3D10_COMMONSHADER_INPUT_RESOURCE_REGISTER_COMPONENTS                1
+CONSTANT: D3D10_COMMONSHADER_INPUT_RESOURCE_REGISTER_COUNT                     128
+CONSTANT: D3D10_COMMONSHADER_INPUT_RESOURCE_REGISTER_READS_PER_INST            1
+CONSTANT: D3D10_COMMONSHADER_INPUT_RESOURCE_REGISTER_READ_PORTS                1
+CONSTANT: D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT                         128
+CONSTANT: D3D10_COMMONSHADER_SAMPLER_REGISTER_COMPONENTS                       1
+CONSTANT: D3D10_COMMONSHADER_SAMPLER_REGISTER_COUNT                            16
+CONSTANT: D3D10_COMMONSHADER_SAMPLER_REGISTER_READS_PER_INST                   1
+CONSTANT: D3D10_COMMONSHADER_SAMPLER_REGISTER_READ_PORTS                       1
+CONSTANT: D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT                                16
+CONSTANT: D3D10_COMMONSHADER_SUBROUTINE_NESTING_LIMIT                          32
+CONSTANT: D3D10_COMMONSHADER_TEMP_REGISTER_COMPONENTS                          4
+CONSTANT: D3D10_COMMONSHADER_TEMP_REGISTER_COMPONENT_BIT_COUNT                 32
+CONSTANT: D3D10_COMMONSHADER_TEMP_REGISTER_COUNT                               4096
+CONSTANT: D3D10_COMMONSHADER_TEMP_REGISTER_READS_PER_INST                      3
+CONSTANT: D3D10_COMMONSHADER_TEMP_REGISTER_READ_PORTS                          3
+CONSTANT: D3D10_COMMONSHADER_TEXCOORD_RANGE_REDUCTION_MAX                      10
+CONSTANT: D3D10_COMMONSHADER_TEXCOORD_RANGE_REDUCTION_MIN                      -10
+CONSTANT: D3D10_COMMONSHADER_TEXEL_OFFSET_MAX_NEGATIVE                         -8
+CONSTANT: D3D10_COMMONSHADER_TEXEL_OFFSET_MAX_POSITIVE                         7
+CONSTANT: D3D10_DEFAULT_BLEND_FACTOR_ALPHA                                     1.0
+CONSTANT: D3D10_DEFAULT_BLEND_FACTOR_BLUE                                      1.0
+CONSTANT: D3D10_DEFAULT_BLEND_FACTOR_GREEN                                     1.0
+CONSTANT: D3D10_DEFAULT_BLEND_FACTOR_RED                                       1.0
+CONSTANT: D3D10_DEFAULT_BORDER_COLOR_COMPONENT                                 0.0
+CONSTANT: D3D10_DEFAULT_DEPTH_BIAS                                             0
+CONSTANT: D3D10_DEFAULT_DEPTH_BIAS_CLAMP                                       0.0
+CONSTANT: D3D10_DEFAULT_MAX_ANISOTROPY                                         16.0
+CONSTANT: D3D10_DEFAULT_MIP_LOD_BIAS                                           0.0
+CONSTANT: D3D10_DEFAULT_RENDER_TARGET_ARRAY_INDEX                              0
+CONSTANT: D3D10_DEFAULT_SAMPLE_MASK                                            HEX: ffffffff
+CONSTANT: D3D10_DEFAULT_SCISSOR_ENDX                                           0
+CONSTANT: D3D10_DEFAULT_SCISSOR_ENDY                                           0
+CONSTANT: D3D10_DEFAULT_SCISSOR_STARTX                                         0
+CONSTANT: D3D10_DEFAULT_SCISSOR_STARTY                                         0
+CONSTANT: D3D10_DEFAULT_SLOPE_SCALED_DEPTH_BIAS                                0.0
+CONSTANT: D3D10_DEFAULT_STENCIL_READ_MASK                                      HEX: ff
+CONSTANT: D3D10_DEFAULT_STENCIL_REFERENCE                                      0
+CONSTANT: D3D10_DEFAULT_STENCIL_WRITE_MASK                                     HEX: ff
+CONSTANT: D3D10_DEFAULT_VIEWPORT_AND_SCISSORRECT_INDEX                         0
+CONSTANT: D3D10_DEFAULT_VIEWPORT_HEIGHT                                        0
+CONSTANT: D3D10_DEFAULT_VIEWPORT_MAX_DEPTH                                     0.0
+CONSTANT: D3D10_DEFAULT_VIEWPORT_MIN_DEPTH                                     0.0
+CONSTANT: D3D10_DEFAULT_VIEWPORT_TOPLEFTX                                      0
+CONSTANT: D3D10_DEFAULT_VIEWPORT_TOPLEFTY                                      0
+CONSTANT: D3D10_DEFAULT_VIEWPORT_WIDTH                                         0
+CONSTANT: D3D10_FLOAT16_FUSED_TOLERANCE_IN_ULP                                 0.6
+CONSTANT: D3D10_FLOAT32_MAX                                                    3.402823466e+38
+CONSTANT: D3D10_FLOAT32_TO_INTEGER_TOLERANCE_IN_ULP                            0.6
+CONSTANT: D3D10_FLOAT_TO_SRGB_EXPONENT_DENOMINATOR                             2.4
+CONSTANT: D3D10_FLOAT_TO_SRGB_EXPONENT_NUMERATOR                               1.0
+CONSTANT: D3D10_FLOAT_TO_SRGB_OFFSET                                           0.055
+CONSTANT: D3D10_FLOAT_TO_SRGB_SCALE_1                                          12.92
+CONSTANT: D3D10_FLOAT_TO_SRGB_SCALE_2                                          1.055
+CONSTANT: D3D10_FLOAT_TO_SRGB_THRESHOLD                                        0.0031308
+CONSTANT: D3D10_FTOI_INSTRUCTION_MAX_INPUT                                     2147483647.999
+CONSTANT: D3D10_FTOI_INSTRUCTION_MIN_INPUT                                     -2147483648.999
+CONSTANT: D3D10_FTOU_INSTRUCTION_MAX_INPUT                                     4294967295.999
+CONSTANT: D3D10_FTOU_INSTRUCTION_MIN_INPUT                                     0.0
+CONSTANT: D3D10_GS_INPUT_PRIM_CONST_REGISTER_COMPONENTS                        1
+CONSTANT: D3D10_GS_INPUT_PRIM_CONST_REGISTER_COMPONENT_BIT_COUNT               32
+CONSTANT: D3D10_GS_INPUT_PRIM_CONST_REGISTER_COUNT                             1
+CONSTANT: D3D10_GS_INPUT_PRIM_CONST_REGISTER_READS_PER_INST                    2
+CONSTANT: D3D10_GS_INPUT_PRIM_CONST_REGISTER_READ_PORTS                        1
+CONSTANT: D3D10_GS_INPUT_REGISTER_COMPONENTS                                   4
+CONSTANT: D3D10_GS_INPUT_REGISTER_COMPONENT_BIT_COUNT                          32
+CONSTANT: D3D10_GS_INPUT_REGISTER_COUNT                                        16
+CONSTANT: D3D10_GS_INPUT_REGISTER_READS_PER_INST                               2
+CONSTANT: D3D10_GS_INPUT_REGISTER_READ_PORTS                                   1
+CONSTANT: D3D10_GS_INPUT_REGISTER_VERTICES                                     6
+CONSTANT: D3D10_GS_OUTPUT_ELEMENTS                                             32
+CONSTANT: D3D10_GS_OUTPUT_REGISTER_COMPONENTS                                  4
+CONSTANT: D3D10_GS_OUTPUT_REGISTER_COMPONENT_BIT_COUNT                         32
+CONSTANT: D3D10_GS_OUTPUT_REGISTER_COUNT                                       32
+CONSTANT: D3D10_IA_DEFAULT_INDEX_BUFFER_OFFSET_IN_BYTES                        0
+CONSTANT: D3D10_IA_DEFAULT_PRIMITIVE_TOPOLOGY                                  0
+CONSTANT: D3D10_IA_DEFAULT_VERTEX_BUFFER_OFFSET_IN_BYTES                       0
+CONSTANT: D3D10_IA_INDEX_INPUT_RESOURCE_SLOT_COUNT                             1
+CONSTANT: D3D10_IA_INSTANCE_ID_BIT_COUNT                                       32
+CONSTANT: D3D10_IA_INTEGER_ARITHMETIC_BIT_COUNT                                32
+CONSTANT: D3D10_IA_PRIMITIVE_ID_BIT_COUNT                                      32
+CONSTANT: D3D10_IA_VERTEX_ID_BIT_COUNT                                         32
+CONSTANT: D3D10_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT                            16
+CONSTANT: D3D10_IA_VERTEX_INPUT_STRUCTURE_ELEMENTS_COMPONENTS                  64
+CONSTANT: D3D10_IA_VERTEX_INPUT_STRUCTURE_ELEMENT_COUNT                        16
+CONSTANT: D3D10_INTEGER_DIVIDE_BY_ZERO_QUOTIENT                                HEX: ffffffff
+CONSTANT: D3D10_INTEGER_DIVIDE_BY_ZERO_REMAINDER                               HEX: ffffffff
+CONSTANT: D3D10_LINEAR_GAMMA                                                   1.0
+CONSTANT: D3D10_MAX_BORDER_COLOR_COMPONENT                                     1.0
+CONSTANT: D3D10_MAX_DEPTH                                                      1.0
+CONSTANT: D3D10_MAX_MAXANISOTROPY                                              16
+CONSTANT: D3D10_MAX_MULTISAMPLE_SAMPLE_COUNT                                   32
+CONSTANT: D3D10_MAX_POSITION_VALUE                                             3.402823466e+34
+CONSTANT: D3D10_MAX_TEXTURE_DIMENSION_2_TO_EXP                                 17
+CONSTANT: D3D10_MIN_BORDER_COLOR_COMPONENT                                     0.0
+CONSTANT: D3D10_MIN_DEPTH                                                      0.0
+CONSTANT: D3D10_MIN_MAXANISOTROPY                                              0
+CONSTANT: D3D10_MIP_LOD_BIAS_MAX                                               15.99
+CONSTANT: D3D10_MIP_LOD_BIAS_MIN                                               -16.0
+CONSTANT: D3D10_MIP_LOD_FRACTIONAL_BIT_COUNT                                   6
+CONSTANT: D3D10_MIP_LOD_RANGE_BIT_COUNT                                        8
+CONSTANT: D3D10_MULTISAMPLE_ANTIALIAS_LINE_WIDTH                               1.4
+CONSTANT: D3D10_NONSAMPLE_FETCH_OUT_OF_RANGE_ACCESS_RESULT                     0
+CONSTANT: D3D10_PIXEL_ADDRESS_RANGE_BIT_COUNT                                  13
+CONSTANT: D3D10_PRE_SCISSOR_PIXEL_ADDRESS_RANGE_BIT_COUNT                      15
+CONSTANT: D3D10_PS_FRONTFACING_DEFAULT_VALUE                                   HEX: ffffffff
+CONSTANT: D3D10_PS_FRONTFACING_FALSE_VALUE                                     0
+CONSTANT: D3D10_PS_FRONTFACING_TRUE_VALUE                                      HEX: ffffffff
+CONSTANT: D3D10_PS_INPUT_REGISTER_COMPONENTS                                   4
+CONSTANT: D3D10_PS_INPUT_REGISTER_COMPONENT_BIT_COUNT                          32
+CONSTANT: D3D10_PS_INPUT_REGISTER_COUNT                                        32
+CONSTANT: D3D10_PS_INPUT_REGISTER_READS_PER_INST                               2
+CONSTANT: D3D10_PS_INPUT_REGISTER_READ_PORTS                                   1
+CONSTANT: D3D10_PS_LEGACY_PIXEL_CENTER_FRACTIONAL_COMPONENT                    0.0
+CONSTANT: D3D10_PS_OUTPUT_DEPTH_REGISTER_COMPONENTS                            1
+CONSTANT: D3D10_PS_OUTPUT_DEPTH_REGISTER_COMPONENT_BIT_COUNT                   32
+CONSTANT: D3D10_PS_OUTPUT_DEPTH_REGISTER_COUNT                                 1
+CONSTANT: D3D10_PS_OUTPUT_REGISTER_COMPONENTS                                  4
+CONSTANT: D3D10_PS_OUTPUT_REGISTER_COMPONENT_BIT_COUNT                         32
+CONSTANT: D3D10_PS_OUTPUT_REGISTER_COUNT                                       8
+CONSTANT: D3D10_PS_PIXEL_CENTER_FRACTIONAL_COMPONENT                           0.5
+CONSTANT: D3D10_REQ_BLEND_OBJECT_COUNT_PER_CONTEXT                             4096
+CONSTANT: D3D10_REQ_BUFFER_RESOURCE_TEXEL_COUNT_2_TO_EXP                       27
+CONSTANT: D3D10_REQ_CONSTANT_BUFFER_ELEMENT_COUNT                              4096
+CONSTANT: D3D10_REQ_DEPTH_STENCIL_OBJECT_COUNT_PER_CONTEXT                     4096
+CONSTANT: D3D10_REQ_DRAWINDEXED_INDEX_COUNT_2_TO_EXP                           32
+CONSTANT: D3D10_REQ_DRAW_VERTEX_COUNT_2_TO_EXP                                 32
+CONSTANT: D3D10_REQ_FILTERING_HW_ADDRESSABLE_RESOURCE_DIMENSION                8192
+CONSTANT: D3D10_REQ_GS_INVOCATION_32BIT_OUTPUT_COMPONENT_LIMIT                 1024
+CONSTANT: D3D10_REQ_IMMEDIATE_CONSTANT_BUFFER_ELEMENT_COUNT                    4096
+CONSTANT: D3D10_REQ_MAXANISOTROPY                                              16
+CONSTANT: D3D10_REQ_MIP_LEVELS                                                 14
+CONSTANT: D3D10_REQ_MULTI_ELEMENT_STRUCTURE_SIZE_IN_BYTES                      2048
+CONSTANT: D3D10_REQ_RASTERIZER_OBJECT_COUNT_PER_CONTEXT                        4096
+CONSTANT: D3D10_REQ_RENDER_TO_BUFFER_WINDOW_WIDTH                              8192
+CONSTANT: D3D10_REQ_RESOURCE_SIZE_IN_MEGABYTES                                 128
+CONSTANT: D3D10_REQ_RESOURCE_VIEW_COUNT_PER_CONTEXT_2_TO_EXP                   20
+CONSTANT: D3D10_REQ_SAMPLER_OBJECT_COUNT_PER_CONTEXT                           4096
+CONSTANT: D3D10_REQ_TEXTURE1D_ARRAY_AXIS_DIMENSION                             512
+CONSTANT: D3D10_REQ_TEXTURE1D_U_DIMENSION                                      8192
+CONSTANT: D3D10_REQ_TEXTURE2D_ARRAY_AXIS_DIMENSION                             512
+CONSTANT: D3D10_REQ_TEXTURE2D_U_OR_V_DIMENSION                                 8192
+CONSTANT: D3D10_REQ_TEXTURE3D_U_V_OR_W_DIMENSION                               2048
+CONSTANT: D3D10_REQ_TEXTURECUBE_DIMENSION                                      8192
+CONSTANT: D3D10_RESINFO_INSTRUCTION_MISSING_COMPONENT_RETVAL                   0
+CONSTANT: D3D10_SHADER_MAJOR_VERSION                                           4
+CONSTANT: D3D10_SHADER_MINOR_VERSION                                           0
+CONSTANT: D3D10_SHIFT_INSTRUCTION_PAD_VALUE                                    0
+CONSTANT: D3D10_SHIFT_INSTRUCTION_SHIFT_VALUE_BIT_COUNT                        5
+CONSTANT: D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT                               8
+CONSTANT: D3D10_SO_BUFFER_MAX_STRIDE_IN_BYTES                                  2048
+CONSTANT: D3D10_SO_BUFFER_MAX_WRITE_WINDOW_IN_BYTES                            256
+CONSTANT: D3D10_SO_BUFFER_SLOT_COUNT                                           4
+CONSTANT: D3D10_SO_DDI_REGISTER_INDEX_DENOTING_GAP                             HEX: ffffffff
+CONSTANT: D3D10_SO_MULTIPLE_BUFFER_ELEMENTS_PER_BUFFER                         1
+CONSTANT: D3D10_SO_SINGLE_BUFFER_COMPONENT_LIMIT                               64
+CONSTANT: D3D10_SRGB_GAMMA                                                     2.2
+CONSTANT: D3D10_SRGB_TO_FLOAT_DENOMINATOR_1                                    12.92
+CONSTANT: D3D10_SRGB_TO_FLOAT_DENOMINATOR_2                                    1.055
+CONSTANT: D3D10_SRGB_TO_FLOAT_EXPONENT                                         2.4
+CONSTANT: D3D10_SRGB_TO_FLOAT_OFFSET                                           0.055
+CONSTANT: D3D10_SRGB_TO_FLOAT_THRESHOLD                                        0.04045
+CONSTANT: D3D10_SRGB_TO_FLOAT_TOLERANCE_IN_ULP                                 0.5
+CONSTANT: D3D10_STANDARD_COMPONENT_BIT_COUNT                                   32
+CONSTANT: D3D10_STANDARD_COMPONENT_BIT_COUNT_DOUBLED                           64
+CONSTANT: D3D10_STANDARD_MAXIMUM_ELEMENT_ALIGNMENT_BYTE_MULTIPLE               4
+CONSTANT: D3D10_STANDARD_PIXEL_COMPONENT_COUNT                                 128
+CONSTANT: D3D10_STANDARD_PIXEL_ELEMENT_COUNT                                   32
+CONSTANT: D3D10_STANDARD_VECTOR_SIZE                                           4
+CONSTANT: D3D10_STANDARD_VERTEX_ELEMENT_COUNT                                  16
+CONSTANT: D3D10_STANDARD_VERTEX_TOTAL_COMPONENT_COUNT                          64
+CONSTANT: D3D10_SUBPIXEL_FRACTIONAL_BIT_COUNT                                  8
+CONSTANT: D3D10_SUBTEXEL_FRACTIONAL_BIT_COUNT                                  6
+CONSTANT: D3D10_TEXEL_ADDRESS_RANGE_BIT_COUNT                                  18
+CONSTANT: D3D10_UNBOUND_MEMORY_ACCESS_RESULT                                   0
+CONSTANT: D3D10_VIEWPORT_AND_SCISSORRECT_MAX_INDEX                             15
+CONSTANT: D3D10_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE             16
+CONSTANT: D3D10_VIEWPORT_BOUNDS_MAX                                            16383
+CONSTANT: D3D10_VIEWPORT_BOUNDS_MIN                                            -16384
+CONSTANT: D3D10_VS_INPUT_REGISTER_COMPONENTS                                   4
+CONSTANT: D3D10_VS_INPUT_REGISTER_COMPONENT_BIT_COUNT                          32
+CONSTANT: D3D10_VS_INPUT_REGISTER_COUNT                                        16
+CONSTANT: D3D10_VS_INPUT_REGISTER_READS_PER_INST                               2
+CONSTANT: D3D10_VS_INPUT_REGISTER_READ_PORTS                                   1
+CONSTANT: D3D10_VS_OUTPUT_REGISTER_COMPONENTS                                  4
+CONSTANT: D3D10_VS_OUTPUT_REGISTER_COMPONENT_BIT_COUNT                         32
+CONSTANT: D3D10_VS_OUTPUT_REGISTER_COUNT                                       16
+CONSTANT: D3D10_WHQL_CONTEXT_COUNT_FOR_RESOURCE_LIMIT                          10
+CONSTANT: D3D10_WHQL_DRAWINDEXED_INDEX_COUNT_2_TO_EXP                          25
+CONSTANT: D3D10_WHQL_DRAW_VERTEX_COUNT_2_TO_EXP                                25
+CONSTANT: D3D_MAJOR_VERSION                                                    10
+CONSTANT: D3D_MINOR_VERSION                                                    0
+CONSTANT: D3D_SPEC_DATE_DAY                                                    8
+CONSTANT: D3D_SPEC_DATE_MONTH                                                  8
+CONSTANT: D3D_SPEC_DATE_YEAR                                                   2006
+CONSTANT: D3D_SPEC_VERSION                                                     1.050005
+
+CONSTANT: D3D10_1_IA_VERTEX_INPUT_STRUCTURE_ELEMENT_COUNT 16
+CONSTANT: D3D10_1_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT     16
+
+CONSTANT: _FACD3D10      HEX: 879
+CONSTANT: _FACD3D10DEBUG HEX: 87A
+
+CONSTANT: D3D10_ERROR_TOO_MANY_UNIQUE_STATE_OBJECTS HEX: 88790001
+CONSTANT: D3D10_ERROR_FILE_NOT_FOUND                HEX: 88790002
+
+CONSTANT: D3D10_INPUT_PER_VERTEX_DATA   0
+CONSTANT: D3D10_INPUT_PER_INSTANCE_DATA 1
+TYPEDEF: int D3D10_INPUT_CLASSIFICATION
+
+CONSTANT: D3D10_APPEND_ALIGNED_ELEMENT HEX: ffffffff
+
+STRUCT: D3D10_INPUT_ELEMENT_DESC
+    { SemanticName         LPCSTR                     }
+    { SemanticIndex        UINT                       }
+    { Format               DXGI_FORMAT                }
+    { InputSlot            UINT                       }
+    { AlignedByteOffset    UINT                       }
+    { InputSlotClass       D3D10_INPUT_CLASSIFICATION }
+    { InstanceDataStepRate UINT                       } ;
+
+CONSTANT: D3D10_FILL_WIREFRAME 2
+CONSTANT: D3D10_FILL_SOLID     3
+TYPEDEF: int D3D10_FILL_MODE
+
+CONSTANT: D3D10_PRIMITIVE_TOPOLOGY_UNDEFINED         0
+CONSTANT: D3D10_PRIMITIVE_TOPOLOGY_POINTLIST         1
+CONSTANT: D3D10_PRIMITIVE_TOPOLOGY_LINELIST          2
+CONSTANT: D3D10_PRIMITIVE_TOPOLOGY_LINESTRIP         3
+CONSTANT: D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST      4
+CONSTANT: D3D10_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP     5
+CONSTANT: D3D10_PRIMITIVE_TOPOLOGY_LINELIST_ADJ      10
+CONSTANT: D3D10_PRIMITIVE_TOPOLOGY_LINESTRIP_ADJ     11
+CONSTANT: D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST_ADJ  12
+CONSTANT: D3D10_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP_ADJ 13
+TYPEDEF: int D3D10_PRIMITIVE_TOPOLOGY
+
+CONSTANT: D3D10_PRIMITIVE_UNDEFINED    0
+CONSTANT: D3D10_PRIMITIVE_POINT        1
+CONSTANT: D3D10_PRIMITIVE_LINE         2
+CONSTANT: D3D10_PRIMITIVE_TRIANGLE     3
+CONSTANT: D3D10_PRIMITIVE_LINE_ADJ     6
+CONSTANT: D3D10_PRIMITIVE_TRIANGLE_ADJ 7
+TYPEDEF: int D3D10_PRIMITIVE
+
+CONSTANT: D3D10_CULL_NONE  1
+CONSTANT: D3D10_CULL_FRONT 2
+CONSTANT: D3D10_CULL_BACK  3
+TYPEDEF: int D3D10_CULL_MODE
+
+STRUCT: D3D10_SO_DECLARATION_ENTRY
+    { SemanticName   LPCSTR }
+    { SemanticIndex  UINT   }
+    { StartComponent BYTE   }
+    { ComponentCount BYTE   }
+    { OutputSlot     BYTE   } ;
+
+STRUCT: D3D10_VIEWPORT
+    { TopLeftX INT   }
+    { TopLeftY INT   }
+    { Width    UINT  }
+    { Height   UINT  }
+    { MinDepth FLOAT }
+    { MaxDepth FLOAT } ;
+
+CONSTANT: D3D10_RESOURCE_DIMENSION_UNKNOWN   0
+CONSTANT: D3D10_RESOURCE_DIMENSION_BUFFER    1
+CONSTANT: D3D10_RESOURCE_DIMENSION_TEXTURE1D 2
+CONSTANT: D3D10_RESOURCE_DIMENSION_TEXTURE2D 3
+CONSTANT: D3D10_RESOURCE_DIMENSION_TEXTURE3D 4
+TYPEDEF: int D3D10_RESOURCE_DIMENSION
+
+CONSTANT: D3D10_SRV_DIMENSION_UNKNOWN          0
+CONSTANT: D3D10_SRV_DIMENSION_BUFFER           1
+CONSTANT: D3D10_SRV_DIMENSION_TEXTURE1D        2
+CONSTANT: D3D10_SRV_DIMENSION_TEXTURE1DARRAY   3
+CONSTANT: D3D10_SRV_DIMENSION_TEXTURE2D        4
+CONSTANT: D3D10_SRV_DIMENSION_TEXTURE2DARRAY   5
+CONSTANT: D3D10_SRV_DIMENSION_TEXTURE2DMS      6
+CONSTANT: D3D10_SRV_DIMENSION_TEXTURE2DMSARRAY 7
+CONSTANT: D3D10_SRV_DIMENSION_TEXTURE3D        8
+CONSTANT: D3D10_SRV_DIMENSION_TEXTURECUBE      9
+TYPEDEF: int D3D10_SRV_DIMENSION
+
+CONSTANT: D3D10_DSV_DIMENSION_UNKNOWN          0
+CONSTANT: D3D10_DSV_DIMENSION_TEXTURE1D        1
+CONSTANT: D3D10_DSV_DIMENSION_TEXTURE1DARRAY   2
+CONSTANT: D3D10_DSV_DIMENSION_TEXTURE2D        3
+CONSTANT: D3D10_DSV_DIMENSION_TEXTURE2DARRAY   4
+CONSTANT: D3D10_DSV_DIMENSION_TEXTURE2DMS      5
+CONSTANT: D3D10_DSV_DIMENSION_TEXTURE2DMSARRAY 6
+TYPEDEF: int D3D10_DSV_DIMENSION
+
+CONSTANT: D3D10_RTV_DIMENSION_UNKNOWN          0
+CONSTANT: D3D10_RTV_DIMENSION_BUFFER           1
+CONSTANT: D3D10_RTV_DIMENSION_TEXTURE1D        2
+CONSTANT: D3D10_RTV_DIMENSION_TEXTURE1DARRAY   3
+CONSTANT: D3D10_RTV_DIMENSION_TEXTURE2D        4
+CONSTANT: D3D10_RTV_DIMENSION_TEXTURE2DARRAY   5
+CONSTANT: D3D10_RTV_DIMENSION_TEXTURE2DMS      6
+CONSTANT: D3D10_RTV_DIMENSION_TEXTURE2DMSARRAY 7
+CONSTANT: D3D10_RTV_DIMENSION_TEXTURE3D        8
+TYPEDEF: int D3D10_RTV_DIMENSION
+
+CONSTANT: D3D10_USAGE_DEFAULT   0
+CONSTANT: D3D10_USAGE_IMMUTABLE 1
+CONSTANT: D3D10_USAGE_DYNAMIC   2
+CONSTANT: D3D10_USAGE_STAGING   3
+TYPEDEF: int D3D10_USAGE
+
+CONSTANT: D3D10_BIND_VERTEX_BUFFER   HEX: 1
+CONSTANT: D3D10_BIND_INDEX_BUFFER    HEX: 2
+CONSTANT: D3D10_BIND_CONSTANT_BUFFER HEX: 4
+CONSTANT: D3D10_BIND_SHADER_RESOURCE HEX: 8
+CONSTANT: D3D10_BIND_STREAM_OUTPUT   HEX: 10
+CONSTANT: D3D10_BIND_RENDER_TARGET   HEX: 20
+CONSTANT: D3D10_BIND_DEPTH_STENCIL   HEX: 40
+TYPEDEF: int D3D10_BIND_FLAG
+
+CONSTANT: D3D10_CPU_ACCESS_WRITE HEX: 10000
+CONSTANT: D3D10_CPU_ACCESS_READ  HEX: 20000
+TYPEDEF: int D3D10_CPU_ACCESS_FLAG
+
+CONSTANT: D3D10_RESOURCE_MISC_GENERATE_MIPS     HEX: 1
+CONSTANT: D3D10_RESOURCE_MISC_SHARED            HEX: 2
+CONSTANT: D3D10_RESOURCE_MISC_TEXTURECUBE       HEX: 4
+CONSTANT: D3D10_RESOURCE_MISC_SHARED_KEYEDMUTEX HEX: 10
+CONSTANT: D3D10_RESOURCE_MISC_GDI_COMPATIBLE    HEX: 20
+TYPEDEF: int D3D10_RESOURCE_MISC_FLAG
+
+CONSTANT: D3D10_MAP_READ               1
+CONSTANT: D3D10_MAP_WRITE              2
+CONSTANT: D3D10_MAP_READ_WRITE         3
+CONSTANT: D3D10_MAP_WRITE_DISCARD      4
+CONSTANT: D3D10_MAP_WRITE_NO_OVERWRITE 5
+TYPEDEF: int D3D10_MAP
+
+CONSTANT: D3D10_MAP_FLAG_DO_NOT_WAIT HEX: 100000
+TYPEDEF: int D3D10_MAP_FLAG
+
+CONSTANT: D3D10_RAISE_FLAG_DRIVER_INTERNAL_ERROR HEX: 1
+TYPEDEF: int D3D10_RAISE_FLAG
+
+CONSTANT: D3D10_CLEAR_DEPTH   HEX: 1
+CONSTANT: D3D10_CLEAR_STENCIL HEX: 2
+TYPEDEF: int D3D10_CLEAR_FLAG
+
+TYPEDEF: RECT D3D10_RECT
+
+STRUCT: D3D10_BOX
+    { left   UINT }
+    { top    UINT }
+    { front  UINT }
+    { right  UINT }
+    { bottom UINT }
+    { back   UINT } ;
+
+COM-INTERFACE: ID3D10DeviceChild IUnknown {9B7E4C00-342C-4106-A19F-4F2704F689F0}
+    void GetDevice ( ID3D10Device** ppDevice )
+    HRESULT GetPrivateData ( LPGUID guid, UINT* pDataSize, void* pData )
+    HRESULT SetPrivateData ( LPGUID guid, UINT DataSize, void* pData )
+    HRESULT SetPrivateDataInterface ( LPGUID guid, IUnknown* pData ) ;
+
+CONSTANT: D3D10_COMPARISON_NEVER         1
+CONSTANT: D3D10_COMPARISON_LESS          2
+CONSTANT: D3D10_COMPARISON_EQUAL         3
+CONSTANT: D3D10_COMPARISON_LESS_EQUAL    4
+CONSTANT: D3D10_COMPARISON_GREATER       5
+CONSTANT: D3D10_COMPARISON_NOT_EQUAL     6
+CONSTANT: D3D10_COMPARISON_GREATER_EQUAL 7
+CONSTANT: D3D10_COMPARISON_ALWAYS        8
+TYPEDEF: int D3D10_COMPARISON_FUNC
+
+CONSTANT: D3D10_DEPTH_WRITE_MASK_ZERO 0
+CONSTANT: D3D10_DEPTH_WRITE_MASK_ALL  1
+TYPEDEF: int D3D10_DEPTH_WRITE_MASK
+
+CONSTANT: D3D10_STENCIL_OP_KEEP     1
+CONSTANT: D3D10_STENCIL_OP_ZERO     2
+CONSTANT: D3D10_STENCIL_OP_REPLACE  3
+CONSTANT: D3D10_STENCIL_OP_INCR_SAT 4
+CONSTANT: D3D10_STENCIL_OP_DECR_SAT 5
+CONSTANT: D3D10_STENCIL_OP_INVERT   6
+CONSTANT: D3D10_STENCIL_OP_INCR     7
+CONSTANT: D3D10_STENCIL_OP_DECR     8
+TYPEDEF: int D3D10_STENCIL_OP
+
+STRUCT: D3D10_DEPTH_STENCILOP_DESC
+    { StencilFailOp      D3D10_STENCIL_OP      }
+    { StencilDepthFailOp D3D10_STENCIL_OP      }
+    { StencilPassOp      D3D10_STENCIL_OP      }
+    { StencilFunc        D3D10_COMPARISON_FUNC } ;
+
+STRUCT: D3D10_DEPTH_STENCIL_DESC
+    { DepthEnable      BOOL                       }
+    { DepthWriteMask   D3D10_DEPTH_WRITE_MASK     }
+    { DepthFunc        D3D10_COMPARISON_FUNC      }
+    { StencilEnable    BOOL                       }
+    { StencilReadMask  BYTE                       }
+    { StencilWriteMask BYTE                       }
+    { FrontFace        D3D10_DEPTH_STENCILOP_DESC }
+    { BackFace         D3D10_DEPTH_STENCILOP_DESC } ;
+
+COM-INTERFACE: ID3D10DepthStencilState ID3D10DeviceChild {2B4B1CC8-A4AD-41f8-8322-CA86FC3EC675}
+    void GetDesc ( D3D10_DEPTH_STENCIL_DESC* pDesc ) ;
+
+CONSTANT: D3D10_BLEND_ZERO             1
+CONSTANT: D3D10_BLEND_ONE              2
+CONSTANT: D3D10_BLEND_SRC_COLOR        3
+CONSTANT: D3D10_BLEND_INV_SRC_COLOR    4
+CONSTANT: D3D10_BLEND_SRC_ALPHA        5
+CONSTANT: D3D10_BLEND_INV_SRC_ALPHA    6
+CONSTANT: D3D10_BLEND_DEST_ALPHA       7
+CONSTANT: D3D10_BLEND_INV_DEST_ALPHA   8
+CONSTANT: D3D10_BLEND_DEST_COLOR       9
+CONSTANT: D3D10_BLEND_INV_DEST_COLOR   10
+CONSTANT: D3D10_BLEND_SRC_ALPHA_SAT    11
+CONSTANT: D3D10_BLEND_BLEND_FACTOR     14
+CONSTANT: D3D10_BLEND_INV_BLEND_FACTOR 15
+CONSTANT: D3D10_BLEND_SRC1_COLOR       16
+CONSTANT: D3D10_BLEND_INV_SRC1_COLOR   17
+CONSTANT: D3D10_BLEND_SRC1_ALPHA       18
+CONSTANT: D3D10_BLEND_INV_SRC1_ALPHA   19
+TYPEDEF: int D3D10_BLEND
+
+CONSTANT: D3D10_BLEND_OP_ADD          1
+CONSTANT: D3D10_BLEND_OP_SUBTRACT     2
+CONSTANT: D3D10_BLEND_OP_REV_SUBTRACT 3
+CONSTANT: D3D10_BLEND_OP_MIN          4
+CONSTANT: D3D10_BLEND_OP_MAX          5
+TYPEDEF: int D3D10_BLEND_OP
+
+CONSTANT: D3D10_COLOR_WRITE_ENABLE_RED   1
+CONSTANT: D3D10_COLOR_WRITE_ENABLE_GREEN 2
+CONSTANT: D3D10_COLOR_WRITE_ENABLE_BLUE  4
+CONSTANT: D3D10_COLOR_WRITE_ENABLE_ALPHA 8
+CONSTANT: D3D10_COLOR_WRITE_ENABLE_ALL   15
+TYPEDEF: int D3D10_COLOR_WRITE_ENABLE
+
+STRUCT: D3D10_BLEND_DESC
+    { AlphaToCoverageEnable BOOL           }
+    { BlendEnable           BOOL[8]        }
+    { SrcBlend              D3D10_BLEND    }
+    { DestBlend             D3D10_BLEND    }
+    { BlendOp               D3D10_BLEND_OP }
+    { SrcBlendAlpha         D3D10_BLEND    }
+    { DestBlendAlpha        D3D10_BLEND    }
+    { BlendOpAlpha          D3D10_BLEND_OP }
+    { RenderTargetWriteMask BYTE[8]        } ;
+
+COM-INTERFACE: ID3D10BlendState ID3D10DeviceChild {EDAD8D19-8A35-4d6d-8566-2EA276CDE161}
+    void GetDesc ( D3D10_BLEND_DESC* pDesc ) ;
+
+STRUCT: D3D10_RASTERIZER_DESC
+    { FillMode              D3D10_FILL_MODE }
+    { CullMode              D3D10_CULL_MODE }
+    { FrontCounterClockwise BOOL            }
+    { DepthBias             INT             }
+    { DepthBiasClamp        FLOAT           }
+    { SlopeScaledDepthBias  FLOAT           }
+    { DepthClipEnable       BOOL            }
+    { ScissorEnable         BOOL            }
+    { MultisampleEnable     BOOL            }
+    { AntialiasedLineEnable BOOL            } ;
+
+COM-INTERFACE: ID3D10RasterizerState ID3D10DeviceChild {A2A07292-89AF-4345-BE2E-C53D9FBB6E9F}
+    void GetDesc ( D3D10_RASTERIZER_DESC* pDesc ) ;
+
+STRUCT: D3D10_SUBRESOURCE_DATA
+    { pSysMem          void* }
+    { SysMemPitch      UINT  }
+    { SysMemSlicePitch UINT  } ;
+
+
+COM-INTERFACE: ID3D10Resource ID3D10DeviceChild {9B7E4C01-342C-4106-A19F-4F2704F689F0}
+    void GetType ( D3D10_RESOURCE_DIMENSION* rType )
+    void SetEvictionPriority ( UINT EvictionPriority )
+    UINT GetEvictionPriority ( ) ;
+
+STRUCT: D3D10_BUFFER_DESC
+    { ByteWidth      UINT        }
+    { Usage          D3D10_USAGE }
+    { BindFlags      UINT        }
+    { CPUAccessFlags UINT        }
+    { MiscFlags      UINT        } ;
+
+COM-INTERFACE: ID3D10Buffer ID3D10Resource {9B7E4C02-342C-4106-A19F-4F2704F689F0}
+    HRESULT Map ( D3D10_MAP MapType, UINT MapFlags, void** ppData )
+    void Unmap ( )
+    void GetDesc ( D3D10_BUFFER_DESC* pDesc ) ;
+
+STRUCT: D3D10_TEXTURE1D_DESC
+    { Width          UINT        }
+    { MipLevels      UINT        }
+    { ArraySize      UINT        }
+    { Format         DXGI_FORMAT }
+    { Usage          D3D10_USAGE }
+    { BindFlags      UINT        }
+    { CPUAccessFlags UINT        }
+    { MiscFlags      UINT        } ;
+
+COM-INTERFACE: ID3D10Texture1D ID3D10Resource {9B7E4C03-342C-4106-A19F-4F2704F689F0}
+    HRESULT Map ( UINT Subresource, D3D10_MAP MapType, UINT MapFlags, void** ppData )
+    void Unmap ( UINT Subresource )
+    void GetDesc ( D3D10_TEXTURE1D_DESC* pDesc ) ;
+
+STRUCT: D3D10_TEXTURE2D_DESC
+    { Width          UINT             }
+    { Height         UINT             }
+    { MipLevels      UINT             }
+    { ArraySize      UINT             }
+    { Format         DXGI_FORMAT      }
+    { SampleDesc     DXGI_SAMPLE_DESC }
+    { Usage          D3D10_USAGE      }
+    { BindFlags      UINT             }
+    { CPUAccessFlags UINT             }
+    { MiscFlags      UINT             } ;
+
+STRUCT: D3D10_MAPPED_TEXTURE2D
+    { pData    void* }
+    { RowPitch UINT  } ;
+
+COM-INTERFACE: ID3D10Texture2D ID3D10Resource {9B7E4C04-342C-4106-A19F-4F2704F689F0}
+    HRESULT Map ( UINT Subresource, D3D10_MAP MapType, UINT MapFlags, D3D10_MAPPED_TEXTURE2D* pMappedTex2D )
+    void Unmap ( UINT Subresource )
+    void GetDesc ( D3D10_TEXTURE2D_DESC* pDesc ) ;
+
+STRUCT: D3D10_TEXTURE3D_DESC
+    { Width          UINT        }
+    { Height         UINT        }
+    { Depth          UINT        }
+    { MipLevels      UINT        }
+    { Format         DXGI_FORMAT }
+    { Usage          D3D10_USAGE }
+    { BindFlags      UINT        }
+    { CPUAccessFlags UINT        }
+    { MiscFlags      UINT        } ;
+
+STRUCT: D3D10_MAPPED_TEXTURE3D
+    { pData      void* }
+    { RowPitch   UINT  }
+    { DepthPitch UINT  } ;
+
+COM-INTERFACE: ID3D10Texture3D ID3D10Resource {9B7E4C05-342C-4106-A19F-4F2704F689F0}
+    HRESULT Map ( UINT Subresource, D3D10_MAP MapType, UINT MapFlags, D3D10_MAPPED_TEXTURE3D* pMappedTex3D )
+    void Unmap ( UINT Subresource )
+    void GetDesc ( D3D10_TEXTURE3D_DESC* pDesc ) ;
+
+CONSTANT: D3D10_TEXTURECUBE_FACE_POSITIVE_X 0
+CONSTANT: D3D10_TEXTURECUBE_FACE_NEGATIVE_X 1
+CONSTANT: D3D10_TEXTURECUBE_FACE_POSITIVE_Y 2
+CONSTANT: D3D10_TEXTURECUBE_FACE_NEGATIVE_Y 3
+CONSTANT: D3D10_TEXTURECUBE_FACE_POSITIVE_Z 4
+CONSTANT: D3D10_TEXTURECUBE_FACE_NEGATIVE_Z 5
+TYPEDEF: int D3D10_TEXTURECUBE_FACE
+
+COM-INTERFACE: ID3D10View ID3D10DeviceChild {C902B03F-60A7-49BA-9936-2A3AB37A7E33}
+    void GetResource ( ID3D10Resource** ppResource ) ;
+
+UNION-STRUCT: D3D10_BUFFER_SRV_UNION1
+    { FirstElement  UINT }
+    { ElementOffset UINT } ;
+
+UNION-STRUCT: D3D10_BUFFER_SRV_UNION2
+    { NumElements UINT }
+    { ElementWith UINT } ;
+
+STRUCT: D3D10_BUFFER_SRV
+    { First  D3D10_BUFFER_SRV_UNION1 }
+    { Second D3D10_BUFFER_SRV_UNION2 } ;
+
+STRUCT: D3D10_TEX1D_SRV
+    { MostDetailedMip UINT }
+    { MipLevels       UINT } ;
+
+STRUCT: D3D10_TEX1D_ARRAY_SRV
+    { MostDetailedMip UINT }
+    { MipLevels       UINT }
+    { FirstArraySlice UINT }
+    { ArraySize       UINT } ;
+
+STRUCT: D3D10_TEX2D_SRV
+    { MostDetailedMip UINT }
+    { MipLevels       UINT } ;
+
+STRUCT: D3D10_TEX2D_ARRAY_SRV
+    { MostDetailedMip UINT }
+    { MipLevels       UINT }
+    { FirstArraySlice UINT }
+    { ArraySize       UINT } ;
+
+STRUCT: D3D10_TEX3D_SRV
+    { MostDetailedMip UINT }
+    { MipLevels       UINT } ;
+
+STRUCT: D3D10_TEXCUBE_SRV
+    { MostDetailedMip UINT }
+    { MipLevels       UINT } ;
+
+STRUCT: D3D10_TEX2DMS_SRV
+    { UnusedField_NothingToDefine UINT } ;
+
+STRUCT: D3D10_TEX2DMS_ARRAY_SRV
+    { FirstArraySlice UINT }
+    { ArraySize       UINT } ;
+
+UNION-STRUCT: D3D10_SHADER_RESOURCE_VIEW_DESC_UNION
+    { Buffer           D3D10_BUFFER_SRV        }
+    { Texture1D        D3D10_TEX1D_SRV         }
+    { Texture1DArray   D3D10_TEX1D_ARRAY_SRV   }
+    { Texture2D        D3D10_TEX2D_SRV         }
+    { Texture2DArray   D3D10_TEX2D_ARRAY_SRV   }
+    { Texture2DMS      D3D10_TEX2DMS_SRV       }
+    { Texture2DMSArray D3D10_TEX2DMS_ARRAY_SRV }
+    { Texture3D        D3D10_TEX3D_SRV         }
+    { TextureCube      D3D10_TEXCUBE_SRV       } ;
+
+STRUCT: D3D10_SHADER_RESOURCE_VIEW_DESC
+    { Format        DXGI_FORMAT                           }
+    { ViewDimension D3D10_SRV_DIMENSION                   }
+    { View          D3D10_SHADER_RESOURCE_VIEW_DESC_UNION } ;
+
+COM-INTERFACE: ID3D10ShaderResourceView ID3D10View {9B7E4C07-342C-4106-A19F-4F2704F689F0}
+    void GetDesc ( D3D10_SHADER_RESOURCE_VIEW_DESC* pDesc ) ;
+
+UNION-STRUCT: D3D10_BUFFER_RTV_UNION1
+    { FirstElement  UINT }
+    { ElementOffset UINT } ;
+
+UNION-STRUCT: D3D10_BUFFER_RTV_UNION2
+    { NumElements  UINT }
+    { ElementWidth UINT } ;
+
+STRUCT: D3D10_BUFFER_RTV
+    { First  D3D10_BUFFER_RTV_UNION1 }
+    { Second D3D10_BUFFER_RTV_UNION2 } ;
+
+STRUCT: D3D10_TEX1D_RTV
+    { MipSlice UINT } ;
+
+STRUCT: D3D10_TEX1D_ARRAY_RTV
+    { MipSlice        UINT }
+    { FirstArraySlice UINT }
+    { ArraySize       UINT } ;
+
+STRUCT: D3D10_TEX2D_RTV
+    { MipSlice UINT } ;
+
+STRUCT: D3D10_TEX2DMS_RTV
+    { UnusedField_NothingToDefine UINT } ;
+
+STRUCT: D3D10_TEX2D_ARRAY_RTV
+    { MipSlice        UINT }
+    { FirstArraySlice UINT }
+    { ArraySize       UINT } ;
+    
+STRUCT: D3D10_TEX2DMS_ARRAY_RTV
+    { FirstArraySlice UINT }
+    { ArraySize       UINT } ;
+
+STRUCT: D3D10_TEX3D_RTV
+    { MipSlice    UINT }
+    { FirstWSlice UINT }
+    { WSize       UINT } ;
+
+UNION-STRUCT: D3D10_RENDER_TARGET_VIEW_DESC_UNION
+    { Buffer           D3D10_BUFFER_RTV        }
+    { Texture1D        D3D10_TEX1D_RTV         }
+    { Texture1DArray   D3D10_TEX1D_ARRAY_RTV   }
+    { Texture2D        D3D10_TEX2D_RTV         }
+    { Texture2DArray   D3D10_TEX2D_ARRAY_RTV   }
+    { Texture2DMS      D3D10_TEX2DMS_RTV       }
+    { Texture2DMSArray D3D10_TEX2DMS_ARRAY_RTV }
+    { Texture3D        D3D10_TEX3D_RTV         } ;
+
+STRUCT: D3D10_RENDER_TARGET_VIEW_DESC
+    { Format        DXGI_FORMAT                         }
+    { ViewDimension D3D10_RTV_DIMENSION                 }
+    { View          D3D10_RENDER_TARGET_VIEW_DESC_UNION } ;
+
+COM-INTERFACE: ID3D10RenderTargetView ID3D10View {9B7E4C08-342C-4106-A19F-4F2704F689F0}
+    void GetDesc ( D3D10_RENDER_TARGET_VIEW_DESC* pDesc ) ;
+
+STRUCT: D3D10_TEX1D_DSV
+    { MipSlice UINT } ;
+
+STRUCT: D3D10_TEX1D_ARRAY_DSV
+    { MipSlice        UINT }
+    { FirstArraySlice UINT }
+    { ArraySize       UINT } ;
+
+STRUCT: D3D10_TEX2D_DSV
+    { MipSlice UINT } ;
+
+STRUCT: D3D10_TEX2D_ARRAY_DSV
+    { MipSlice        UINT }
+    { FirstArraySlice UINT }
+    { ArraySize       UINT } ;
+
+STRUCT: D3D10_TEX2DMS_DSV
+    { UnusedField_NothingToDefine UINT } ;
+
+STRUCT: D3D10_TEX2DMS_ARRAY_DSV
+    { FirstArraySlice UINT }
+    { ArraySize       UINT } ;
+
+UNION-STRUCT: D3D10_DEPTH_STENCIL_VIEW_DESC_UNION
+    { Texture1D        D3D10_TEX1D_DSV         }
+    { Texture1DArray   D3D10_TEX1D_ARRAY_DSV   }
+    { Texture2D        D3D10_TEX2D_DSV         }
+    { Texture2DArray   D3D10_TEX2D_ARRAY_DSV   }
+    { Texture2DMS      D3D10_TEX2DMS_DSV       }
+    { Texture2DMSArray D3D10_TEX2DMS_ARRAY_DSV } ;
+
+STRUCT: D3D10_DEPTH_STENCIL_VIEW_DESC
+    { Format        DXGI_FORMAT                         }
+    { ViewDimension D3D10_DSV_DIMENSION                 }
+    { Union         D3D10_DEPTH_STENCIL_VIEW_DESC_UNION } ;
+
+COM-INTERFACE: ID3D10DepthStencilView ID3D10View {9B7E4C09-342C-4106-A19F-4F2704F689F0}
+    void GetDesc ( D3D10_DEPTH_STENCIL_VIEW_DESC* pDesc ) ;
+
+COM-INTERFACE: ID3D10VertexShader ID3D10DeviceChild {9B7E4C0A-342C-4106-A19F-4F2704F689F0} ;
+
+COM-INTERFACE: ID3D10GeometryShader ID3D10DeviceChild {16BE88-54CD-4040-AB44-20461BC81F68} ;
+
+COM-INTERFACE: ID3D10PixelShader ID3D10DeviceChild {68B601-9D00-4cde-8346-8E7F675819B6} ;
+
+COM-INTERFACE: ID3D10InputLayout ID3D10DeviceChild {7E4C0B-342C-4106-A19F-4F2704F689F0} ;
+
+CONSTANT: D3D10_FILTER_MIN_MAG_MIP_POINT                          0
+CONSTANT: D3D10_FILTER_MIN_MAG_POINT_MIP_LINEAR                   HEX: 1
+CONSTANT: D3D10_FILTER_MIN_POINT_MAG_LINEAR_MIP_POINT             HEX: 4
+CONSTANT: D3D10_FILTER_MIN_POINT_MAG_MIP_LINEAR                   HEX: 5
+CONSTANT: D3D10_FILTER_MIN_LINEAR_MAG_MIP_POINT                   HEX: 10
+CONSTANT: D3D10_FILTER_MIN_LINEAR_MAG_POINT_MIP_LINEAR            HEX: 11
+CONSTANT: D3D10_FILTER_MIN_MAG_LINEAR_MIP_POINT                   HEX: 14
+CONSTANT: D3D10_FILTER_MIN_MAG_MIP_LINEAR                         HEX: 15
+CONSTANT: D3D10_FILTER_ANISOTROPIC                                HEX: 55
+CONSTANT: D3D10_FILTER_COMPARISON_MIN_MAG_MIP_POINT               HEX: 80
+CONSTANT: D3D10_FILTER_COMPARISON_MIN_MAG_POINT_MIP_LINEAR        HEX: 81
+CONSTANT: D3D10_FILTER_COMPARISON_MIN_POINT_MAG_LINEAR_MIP_POINT  HEX: 84
+CONSTANT: D3D10_FILTER_COMPARISON_MIN_POINT_MAG_MIP_LINEAR        HEX: 85
+CONSTANT: D3D10_FILTER_COMPARISON_MIN_LINEAR_MAG_MIP_POINT        HEX: 90
+CONSTANT: D3D10_FILTER_COMPARISON_MIN_LINEAR_MAG_POINT_MIP_LINEAR HEX: 91
+CONSTANT: D3D10_FILTER_COMPARISON_MIN_MAG_LINEAR_MIP_POINT        HEX: 94
+CONSTANT: D3D10_FILTER_COMPARISON_MIN_MAG_MIP_LINEAR              HEX: 95
+CONSTANT: D3D10_FILTER_COMPARISON_ANISOTROPIC                     HEX: d5
+CONSTANT: D3D10_FILTER_TEXT_1BIT                                  HEX: 80000000
+TYPEDEF: int D3D10_FILTER
+
+CONSTANT: D3D10_FILTER_TYPE_POINT  0
+CONSTANT: D3D10_FILTER_TYPE_LINEAR 1
+TYPEDEF: int D3D10_FILTER_TYPE
+
+CONSTANT: D3D10_FILTER_TYPE_MASK          HEX: 3
+CONSTANT: D3D10_MIN_FILTER_SHIFT          4
+CONSTANT: D3D10_MAG_FILTER_SHIFT          2
+CONSTANT: D3D10_MIP_FILTER_SHIFT          0
+CONSTANT: D3D10_COMPARISON_FILTERING_BIT  HEX: 80
+CONSTANT: D3D10_ANISOTROPIC_FILTERING_BIT HEX: 40
+CONSTANT: D3D10_TEXT_1BIT_BIT             HEX: 80000000
+
+CONSTANT: D3D10_TEXTURE_ADDRESS_WRAP        1
+CONSTANT: D3D10_TEXTURE_ADDRESS_MIRROR      2
+CONSTANT: D3D10_TEXTURE_ADDRESS_CLAMP       3
+CONSTANT: D3D10_TEXTURE_ADDRESS_BORDER      4
+CONSTANT: D3D10_TEXTURE_ADDRESS_MIRROR_ONCE 5
+TYPEDEF: int D3D10_TEXTURE_ADDRESS_MODE
+
+STRUCT: D3D10_SAMPLER_DESC
+    { Filter         D3D10_FILTER               }
+    { AddressU       D3D10_TEXTURE_ADDRESS_MODE }
+    { AddressV       D3D10_TEXTURE_ADDRESS_MODE }
+    { AddressW       D3D10_TEXTURE_ADDRESS_MODE }
+    { MipLODBias     FLOAT                      }
+    { MaxAnisotropy  UINT                       }
+    { ComparisonFunc D3D10_COMPARISON_FUNC      }
+    { BorderColor    FLOAT[4]                   }
+    { MinLOD         FLOAT                      }
+    { MaxLOD         FLOAT                      } ;
+TYPEDEF: D3D10_SAMPLER_DESC D3D10SAMPLER_DESC
+
+COM-INTERFACE: ID3D10SamplerState ID3D10DeviceChild {9B7E4C0C-342C-4106-A19F-4F2704F689F0}
+    void GetDesc ( D3D10SAMPLER_DESC* pDesc ) ;
+
+CONSTANT: D3D10_FORMAT_SUPPORT_BUFFER                   HEX: 1
+CONSTANT: D3D10_FORMAT_SUPPORT_IA_VERTEX_BUFFER         HEX: 2
+CONSTANT: D3D10_FORMAT_SUPPORT_IA_INDEX_BUFFER          HEX: 4
+CONSTANT: D3D10_FORMAT_SUPPORT_SO_BUFFER                HEX: 8
+CONSTANT: D3D10_FORMAT_SUPPORT_TEXTURE1D                HEX: 10
+CONSTANT: D3D10_FORMAT_SUPPORT_TEXTURE2D                HEX: 20
+CONSTANT: D3D10_FORMAT_SUPPORT_TEXTURE3D                HEX: 40
+CONSTANT: D3D10_FORMAT_SUPPORT_TEXTURECUBE              HEX: 80
+CONSTANT: D3D10_FORMAT_SUPPORT_SHADER_LOAD              HEX: 100
+CONSTANT: D3D10_FORMAT_SUPPORT_SHADER_SAMPLE            HEX: 200
+CONSTANT: D3D10_FORMAT_SUPPORT_SHADER_SAMPLE_COMPARISON HEX: 400
+CONSTANT: D3D10_FORMAT_SUPPORT_SHADER_SAMPLE_MONO_TEXT  HEX: 800
+CONSTANT: D3D10_FORMAT_SUPPORT_MIP                      HEX: 1000
+CONSTANT: D3D10_FORMAT_SUPPORT_MIP_AUTOGEN              HEX: 2000
+CONSTANT: D3D10_FORMAT_SUPPORT_RENDER_TARGET            HEX: 4000
+CONSTANT: D3D10_FORMAT_SUPPORT_BLENDABLE                HEX: 8000
+CONSTANT: D3D10_FORMAT_SUPPORT_DEPTH_STENCIL            HEX: 10000
+CONSTANT: D3D10_FORMAT_SUPPORT_CPU_LOCKABLE             HEX: 20000
+CONSTANT: D3D10_FORMAT_SUPPORT_MULTISAMPLE_RESOLVE      HEX: 40000
+CONSTANT: D3D10_FORMAT_SUPPORT_DISPLAY                  HEX: 80000
+CONSTANT: D3D10_FORMAT_SUPPORT_CAST_WITHIN_BIT_LAYOUT   HEX: 100000
+CONSTANT: D3D10_FORMAT_SUPPORT_MULTISAMPLE_RENDERTARGET HEX: 200000
+CONSTANT: D3D10_FORMAT_SUPPORT_MULTISAMPLE_LOAD         HEX: 400000
+CONSTANT: D3D10_FORMAT_SUPPORT_SHADER_GATHER            HEX: 800000
+CONSTANT: D3D10_FORMAT_SUPPORT_BACK_BUFFER_CAST         HEX: 100000
+TYPEDEF: int D3D10_FORMAT_SUPPORT
+
+COM-INTERFACE: ID3D10Asynchronous ID3D10DeviceChild {9B7E4C0D-342C-4106-A19F-4F2704F689F0}
+    void Begin ( )
+    void End ( )
+    HRESULT GetData ( void* pData, UINT DataSize, UINT GetDataFlags )
+    UINT GetDataSize ( ) ;
+
+CONSTANT: D3D10_ASYNC_GETDATA_DONOTFLUSH 1
+TYPEDEF: int D3D10_ASYNC_GETDATA_FLAG
+
+CONSTANT: D3D10_QUERY_EVENT                 0
+CONSTANT: D3D10_QUERY_OCCLUSION             1
+CONSTANT: D3D10_QUERY_TIMESTAMP             2
+CONSTANT: D3D10_QUERY_TIMESTAMP_DISJOINT    3
+CONSTANT: D3D10_QUERY_PIPELINE_STATISTICS   4
+CONSTANT: D3D10_QUERY_OCCLUSION_PREDICATE   5
+CONSTANT: D3D10_QUERY_SO_STATISTICS         6
+CONSTANT: D3D10_QUERY_SO_OVERFLOW_PREDICATE 7
+TYPEDEF: int D3D10_QUERY
+
+CONSTANT: D3D10_QUERY_MISC_PREDICATEHINT 1
+TYPEDEF: int D3D10_QUERY_MISC_FLAG
+
+STRUCT: D3D10_QUERY_DESC
+    { Query     D3D10_QUERY }
+    { MiscFlags UINT        } ;
+
+COM-INTERFACE: ID3D10Query ID3D10Asynchronous {9B7E4C0E-342C-4106-A19F-4F2704F689F0}
+    void GetDesc ( D3D10_QUERY_DESC* pDesc ) ;
+
+COM-INTERFACE: ID3D10Predicate ID3D10Query {9B7E4C10-342C-4106-A19F-4F2704F689F0} ;
+
+STRUCT: D3D10_QUERY_DATA_TIMESTAMP_DISJOINT
+    { Frequency UINT64 }
+    { Disjoint  BOOL   } ;
+
+STRUCT: D3D10_QUERY_DATA_PIPELINE_STATISTICS
+    { IAVertices    UINT64 }
+    { IAPrimitives  UINT64 }
+    { VSInvocations UINT64 }
+    { GSInvocations UINT64 }
+    { GSPrimitives  UINT64 }
+    { CInvocations  UINT64 }
+    { CPrimitives   UINT64 }
+    { PSInvocations UINT64 } ;
+
+STRUCT: D3D10_QUERY_DATA_SO_STATISTICS
+    { NumPrimitivesWritten    UINT64 }
+    { PrimitivesStorageNeeded UINT64 } ;
+
+CONSTANT: D3D10_COUNTER_GPU_IDLE                              0
+CONSTANT: D3D10_COUNTER_VERTEX_PROCESSING                     1
+CONSTANT: D3D10_COUNTER_GEOMETRY_PROCESSING                   2
+CONSTANT: D3D10_COUNTER_PIXEL_PROCESSING                      3
+CONSTANT: D3D10_COUNTER_OTHER_GPU_PROCESSING                  4
+CONSTANT: D3D10_COUNTER_HOST_ADAPTER_BANDWIDTH_UTILIZATION    5
+CONSTANT: D3D10_COUNTER_LOCAL_VIDMEM_BANDWIDTH_UTILIZATION    6
+CONSTANT: D3D10_COUNTER_VERTEX_THROUGHPUT_UTILIZATION         7
+CONSTANT: D3D10_COUNTER_TRIANGLE_SETUP_THROUGHPUT_UTILIZATION 8
+CONSTANT: D3D10_COUNTER_FILLRATE_THROUGHPUT_UTILIZATION       9
+CONSTANT: D3D10_COUNTER_VS_MEMORY_LIMITED                     10
+CONSTANT: D3D10_COUNTER_VS_COMPUTATION_LIMITED                11
+CONSTANT: D3D10_COUNTER_GS_MEMORY_LIMITED                     12
+CONSTANT: D3D10_COUNTER_GS_COMPUTATION_LIMITED                13
+CONSTANT: D3D10_COUNTER_PS_MEMORY_LIMITED                     14
+CONSTANT: D3D10_COUNTER_PS_COMPUTATION_LIMITED                15
+CONSTANT: D3D10_COUNTER_POST_TRANSFORM_CACHE_HIT_RATE         16
+CONSTANT: D3D10_COUNTER_TEXTURE_CACHE_HIT_RATE                17
+CONSTANT: D3D10_COUNTER_DEVICE_DEPENDENT_0                    HEX: 40000000
+TYPEDEF: int D3D10_COUNTER
+
+CONSTANT: D3D10_COUNTER_TYPE_FLOAT32 0
+CONSTANT: D3D10_COUNTER_TYPE_UINT16  1
+CONSTANT: D3D10_COUNTER_TYPE_UINT32  2
+CONSTANT: D3D10_COUNTER_TYPE_UINT64  3
+TYPEDEF: int D3D10_COUNTER_TYPE
+
+STRUCT: D3D10_COUNTER_DESC
+    { Counter   D3D10_COUNTER }
+    { MiscFlags UINT          } ;
+
+STRUCT: D3D10_COUNTER_INFO
+    { LastDeviceDependentCounter D3D10_COUNTER }
+    { NumSimultaneousCounters    UINT          }
+    { NumDetectableParallelUnits BYTE          } ;
+
+COM-INTERFACE: ID3D10Counter ID3D10Asynchronous {9B7E4C11-342C-4106-A19F-4F2704F689F0}
+    void GetDesc ( D3D10_COUNTER_DESC* pDesc ) ;
+
+COM-INTERFACE: ID3D10Device IUnknown {9B7E4C0F-342C-4106-A19F-4F2704F689F0}
+    void VSSetConstantBuffers ( UINT StartSlot, UINT NumBuffers, ID3D10Buffer** ppConstantBuffers )
+    void PSSetShaderResources ( UINT StartSlot, UINT NumViews, ID3D10ShaderResourceView** ppShaderResourceView )
+    void PSSetShader ( ID3D10PixelShader* pPixelShader )
+    void PSSetSamplers ( UINT StartSlot, UINT NumSamplers, ID3D10SamplerState** ppSamplers )
+    void VSSetShader ( ID3D10VertexShader* pVertexShader )
+    void DrawIndexed ( UINT IndexCount, UINT StartIndexLocation, INT BaseVertexLocation )
+    void Draw ( UINT VertexCount, UINT StartVertexLocation )
+    void PSSetConstantBuffers ( UINT StartSlot, UINT NumBuffers, ID3D10Buffer** ppConstantBuffers )
+    void IASetInputLayout ( ID3D10InputLayout* pInputLayout )
+    void IASetVertexBuffers ( UINT StartSlot, UINT NumBuffers, ID3D10Buffer** ppVertexBuffers, UINT* pStrides, UINT* pOffsets )
+    void IASetIndexBuffer ( ID3D10Buffer* pIndexBuffer, DXGI_FORMAT Format, UINT Offset )
+    void DrawIndexedInstanced ( UINT IndexCountPerInstance, UINT InstanceCount, UINT StartIndexLocation, INT BaseVertexLocation, UINT StartInstanceLocation )
+    void DrawInstanced ( UINT VertexCountPerInstance, UINT InstanceCount, UINT StartVertexLocation, UINT StartInstanceLocation )
+    void GSSetConstantBuffers ( UINT StartSlot, UINT NumBuffers, ID3D10Buffer** ppConstantBuffers )
+    void GSSetShader ( ID3D10GeometryShader* pShader )
+    void IASetPrimitiveTopology ( D3D10_PRIMITIVE_TOPOLOGY Topology )
+    void VSSetShaderResources ( UINT StartSlot, UINT NumViews, ID3D10ShaderResourceView** ppShaderResourceViews )
+    void VSSetSamplers ( UINT StartSlot, UINT NumSamplers, ID3D10SamplerState** ppSamplers )
+    void SetPredication ( ID3D10Predicate* pPredicate, BOOL PredicateValue )
+    void GSSetShaderResources ( UINT StartSlot, UINT NumViews, ID3D10ShaderResourceView** ppShaderResourceViews )
+    void GSSetSamplers ( UINT StartSlot, UINT NumSamplers, ID3D10SamplerState** ppSamplers )
+    void OMSetRenderTargets ( UINT NumViews, ID3D10RenderTargetView** ppRenderTargetViews, ID3D10DepthStencilView* pDepthStencilView )
+    void OMSetBlendState ( ID3D10BlendState* pBlendState, FLOAT[4] BlendFactor, UINT SampleMask )
+    void OMSetDepthStencilState ( ID3D10DepthStencilState* pDepthStencilState, UINT StencilRef )
+    void SOSetTargets ( UINT NumBuffers, ID3D10Buffer** ppSOTargets, UINT* pOffsets )
+    void DrawAuto ( )
+    void RSSetState ( ID3D10RasterizerState* pRasterizerState )
+    void RSSetViewports ( UINT NumViewports, D3D10_VIEWPORT* pViewports )
+    void RSSetScissorRects ( UINT NumRects, D3D10_RECT* pRects )
+    void CopySubresourceRegion ( ID3D10Resource* pDstResource, UINT DstSubresource, UINT DstX, UINT DstY, UINT DstZ, ID3D10Resource* pSrcResource, UINT SrcSubresource, D3D10_BOX* pSrcBox )
+    void CopyResource ( ID3D10Resource* pDstResource, ID3D10Resource* pSrcResource )
+    void UpdateSubresource ( ID3D10Resource* pDstResource, UINT DstSubresource, D3D10_BOX* pDstBox, void* pSrcData, UINT SrcRowPitch, UINT SrcDepthPitch )
+    void ClearRenderTargetView ( ID3D10RenderTargetView* pRenderTargetView, FLOAT[4] ColorRGBA )
+    void ClearDepthStencilView ( ID3D10DepthStencilView* pDepthStencilView, UINT ClearFlags, FLOAT Depth, BYTE Stencil )
+    void GenerateMips ( ID3D10ShaderResourceView* pShaderResourceView )
+    void ResolveSubresource ( ID3D10Resource* pDstResource, UINT DstSubresource, ID3D10Resource* pSrcResource, UINT SrcSubresource, DXGI_FORMAT Format )
+    void VSGetConstantBuffers ( UINT StartSlot, UINT NumBuffers, ID3D10Buffer** ppConstantBuffers )
+    void PSGetShaderResources ( UINT StartSlot, UINT NumViews, ID3D10ShaderResourceView** ppShaderResourceViews )
+    void PSGetShader ( ID3D10PixelShader** ppPixelShader )
+    void PSGetSamplers ( UINT StartSlot, UINT NumSamplers, ID3D10SamplerState** ppSamplers )
+    void VSGetShader ( ID3D10VertexShader** ppVertexShader )
+    void PSGetConstantBuffers ( UINT StartSlot, UINT NumBuffers, ID3D10Buffer** ppConstantBuffers )
+    void IAGetInputLayout ( ID3D10InputLayout** ppInputLayout )
+    void IAGetVertexBuffers ( UINT StartSlot, UINT NumBuffers, ID3D10Buffer** ppVertexBuffers, UINT* pStrides, UINT* pOffsets )
+    void IAGetIndexBuffer ( ID3D10Buffer** pIndexBuffer, DXGI_FORMAT* Format, UINT* Offset )
+    void GSGetConstantBuffers ( UINT StartSlot, UINT NumBuffers, ID3D10Buffer** ppConstantBuffers )
+    void GSGetShader ( ID3D10GeometryShader** ppGeometryShader )
+    void IAGetPrimitiveTopology ( D3D10_PRIMITIVE_TOPOLOGY* pTopology )
+    void VSGetShaderResources ( UINT StartSlot, UINT NumViews, ID3D10ShaderResourceView** ppShaderResourceViews )
+    void VSGetSamplers ( UINT StartSlot, UINT NumSamplers, ID3D10SamplerState** ppSamplers )
+    void GetPredication ( ID3D10Predicate** ppPredicate, BOOL* pPredicateValue )
+    void GSGetShaderResources ( UINT StartSlot, UINT NumViews, ID3D10ShaderResourceView** ppShaderResourceViews )
+    void GSGetSamplers ( UINT StartSlot, UINT NumSamplers, ID3D10SamplerState** ppSamplers )
+    void OMGetRenderTargets ( UINT NumViews, ID3D10RenderTargetView** ppRenderTargetViews, ID3D10DepthStencilView** ppDepthStencilView )
+    void OMGetBlendState ( ID3D10BlendState** ppBlendState, FLOAT[4] BlendFactor, UINT* pSampleMask )
+    void OMGetDepthStencilState ( ID3D10DepthStencilState** ppDepthStencilState, UINT* pStencilRef )
+    void SOGetTargets ( UINT NumBuffers, ID3D10Buffer** ppSOTargets, UINT* pOffsets )
+    void RSGetState ( ID3D10RasterizerState** ppRasterizerState )
+    void RSGetViewports ( UINT* NumViewports, D3D10_VIEWPORT* pViewports )
+    void RSGetScissorRects ( UINT* NumRects, D3D10_RECT* pRects )
+    HRESULT GetDeviceRemovedReason ( )
+    HRESULT SetExceptionMode ( UINT RaiseFlags )
+    UINT GetExceptionMode ( )
+    HRESULT GetPrivateData ( REFGUID guid, UINT* pDataSize, void* pData )
+    HRESULT SetPrivateData ( REFGUID guid, UINT DataSize, void* pData )
+    HRESULT SetPrivateDataInterface ( REFGUID guid, IUnknown* pData )
+    void ClearState ( )
+    void Flush ( )
+    HRESULT CreateBuffer ( D3D10_BUFFER_DESC* pDesc, D3D10_SUBRESOURCE_DATA* pInitialData, ID3D10Buffer** ppBuffer )
+    HRESULT CreateTexture1D ( D3D10_TEXTURE1D_DESC* pDesc, D3D10_SUBRESOURCE_DATA* pInitialData, ID3D10Texture1D** ppTexture1D )
+    HRESULT CreateTexture2D ( D3D10_TEXTURE2D_DESC* pDesc, D3D10_SUBRESOURCE_DATA* pInitialData, ID3D10Texture2D** ppTexture2D )
+    HRESULT CreateTexture3D ( D3D10_TEXTURE3D_DESC* pDesc, D3D10_SUBRESOURCE_DATA* pInitialData, ID3D10Texture3D** ppTexture3D )
+    HRESULT CreateShaderResourceView ( ID3D10Resource* pResource, D3D10_SHADER_RESOURCE_VIEW_DESC* pDesc, ID3D10ShaderResourceView** ppSRView )
+    HRESULT CreateRenderTargetView ( ID3D10Resource* pResource, D3D10_RENDER_TARGET_VIEW_DESC* pDesc, ID3D10RenderTargetView** ppRTView )
+    HRESULT CreateDepthStencilView ( ID3D10Resource* pResource, D3D10_DEPTH_STENCIL_VIEW_DESC* pDesc, ID3D10DepthStencilView** ppDepthStencilView )
+    HRESULT CreateInputLayout ( D3D10_INPUT_ELEMENT_DESC* pInputElementDescs, UINT NumElements, void* pShaderBytecodeWithInputSignature, SIZE_T BytecodeLength, ID3D10InputLayout** ppInputLayout )
+    HRESULT CreateVertexShader ( void* pShaderBytecode, SIZE_T BytecodeLength, ID3D10VertexShader** ppVertexShader )
+    HRESULT CreateGeometryShader ( void* pShaderBytecode, SIZE_T BytecodeLength, ID3D10GeometryShader** ppGeometryShader )
+    HRESULT CreateGeometryShaderWithStreamOutput ( void* pShaderBytecode, SIZE_T BytecodeLength, D3D10_SO_DECLARATION_ENTRY* pSODeclaration, UINT NumEntries, UINT OutputStreamStride, ID3D10GeometryShader** ppGeometryShader )
+    HRESULT CreatePixelShader ( void* pShaderBytecode, SIZE_T BytecodeLength, ID3D10PixelShader** ppPixelShader )
+    HRESULT CreateBlendState ( D3D10_BLEND_DESC* pBlendStateDesc, ID3D10BlendState** ppBlendState )
+    HRESULT CreateDepthStencilState ( D3D10_DEPTH_STENCIL_DESC* pDepthStencilDesc, ID3D10DepthStencilState** ppDepthStencilState )
+    HRESULT CreateRasterizerState ( D3D10_RASTERIZER_DESC* pRasterizerDesc, ID3D10RasterizerState** ppRasterizerState )
+    HRESULT CreateSamplerState ( D3D10_SAMPLER_DESC* pSamplerDesc, ID3D10SamplerState** ppSamplerState )
+    HRESULT CreateQuery ( D3D10_QUERY_DESC* pQueryDesc, ID3D10Query** ppQuery )
+    HRESULT CreatePredicate ( D3D10_QUERY_DESC* pPredicateDesc, ID3D10Predicate** ppPredicate )
+    HRESULT CreateCounter ( D3D10_COUNTER_DESC* pCounterDesc, ID3D10Counter** ppCounter )
+    HRESULT CheckFormatSupport ( DXGI_FORMAT Format, UINT* pFormatSupport )
+    HRESULT CheckMultisampleQualityLevels ( DXGI_FORMAT Format, UINT SampleCount, UINT* pNumQualityLevels )
+    void CheckCounterInfo ( D3D10_COUNTER_INFO* pCounterInfo )
+    HRESULT CheckCounter ( D3D10_COUNTER_DESC* pDesc, D3D10_COUNTER_TYPE* pType, UINT* pActiveCounters, LPSTR szName, UINT* pNameLength, LPSTR szUnits, UINT* pUnitsLength, LPSTR szDescription, UINT* pDescriptionLength )
+    UINT GetCreationFlags ( )
+    HRESULT OpenSharedResource ( HANDLE hResource, REFIID ReturnedInterface, void** ppResource )
+    void SetTextFilterSize ( UINT Width, UINT Height )
+    void GetTextFilterSize ( UINT* pWidth, UINT* pHeight ) ;
+
+COM-INTERFACE: ID3D10Multithread IUnknown {9B7E4E00-342C-4106-A19F-4F2704F689F0}
+    void Enter ( )
+    void Leave ( )
+    BOOL SetMultithreadProtected ( BOOL bMTProtect )
+    BOOL GetMultithreadProtected ( ) ;
+
+CONSTANT: D3D10_CREATE_DEVICE_SINGLETHREADED                           HEX: 1
+CONSTANT: D3D10_CREATE_DEVICE_DEBUG                                    HEX: 2
+CONSTANT: D3D10_CREATE_DEVICE_SWITCH_TO_REF                            HEX: 4
+CONSTANT: D3D10_CREATE_DEVICE_PREVENT_INTERNAL_THREADING_OPTIMIZATIONS HEX: 8
+CONSTANT: D3D10_CREATE_DEVICE_ALLOW_NULL_FROM_MAP                      HEX: 10
+CONSTANT: D3D10_CREATE_DEVICE_BGRA_SUPPORT                             HEX: 20
+CONSTANT: D3D10_CREATE_DEVICE_STRICT_VALIDATION                        HEX: 200
+TYPEDEF: int D3D10_CREATE_DEVICE_FLAG
+
+CONSTANT: D3D10_SDK_VERSION 29
+
+CONSTANT: D3DX10_ERR_CANNOT_MODIFY_INDEX_BUFFER HEX: 88760B54
+CONSTANT: D3DX10_ERR_INVALID_MESH               HEX: 88760B55
+CONSTANT: D3DX10_ERR_CANNOT_ATTR_SORT           HEX: 88760B56
+CONSTANT: D3DX10_ERR_SKINNING_NOT_SUPPORTED     HEX: 88760B57
+CONSTANT: D3DX10_ERR_TOO_MANY_INFLUENCES        HEX: 88760B58
+CONSTANT: D3DX10_ERR_INVALID_DATA               HEX: 88760B59
+CONSTANT: D3DX10_ERR_LOADED_MESH_HAS_NO_DATA    HEX: 88760B5A
+CONSTANT: D3DX10_ERR_DUPLICATE_NAMED_FRAGMENT   HEX: 88760B5B
+CONSTANT: D3DX10_ERR_CANNOT_REMOVE_LAST_ITEM    HEX: 88760B5C
diff --git a/basis/windows/directx/d3d10/summary.txt b/basis/windows/directx/d3d10/summary.txt
new file mode 100644 (file)
index 0000000..93943ab
--- /dev/null
@@ -0,0 +1 @@
+Direct3D 10 bindings. Corresponds to D3D10.h.
diff --git a/basis/windows/directx/d3d10/tags.txt b/basis/windows/directx/d3d10/tags.txt
new file mode 100644 (file)
index 0000000..2320bdd
--- /dev/null
@@ -0,0 +1,2 @@
+unportable
+bindings
diff --git a/basis/windows/directx/d3d10_1/authors.txt b/basis/windows/directx/d3d10_1/authors.txt
new file mode 100644 (file)
index 0000000..6f03a12
--- /dev/null
@@ -0,0 +1 @@
+Erik Charlebois
diff --git a/basis/windows/directx/d3d10_1/d3d10_1.factor b/basis/windows/directx/d3d10_1/d3d10_1.factor
new file mode 100644 (file)
index 0000000..7d4db6e
--- /dev/null
@@ -0,0 +1,128 @@
+USING: alien.c-types alien.syntax classes.struct
+windows.com.syntax windows.directx.d3d10
+windows.directx.d3d10misc windows.directx.dxgi
+windows.directx.dxgiformat windows.types ;
+IN: windows.directx.d3d10_1
+
+LIBRARY: d3d10_1
+
+CONSTANT: D3D10_1_DEFAULT_SAMPLE_MASK                             HEX: ffffffff
+CONSTANT: D3D10_1_FLOAT16_FUSED_TOLERANCE_IN_ULP                  0.6
+CONSTANT: D3D10_1_FLOAT32_TO_INTEGER_TOLERANCE_IN_ULP             0.6
+CONSTANT: D3D10_1_GS_INPUT_REGISTER_COUNT                         32
+CONSTANT: D3D10_1_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT             32
+CONSTANT: D3D10_1_IA_VERTEX_INPUT_STRUCTURE_ELEMENTS_COMPONENTS   128
+CONSTANT: D3D10_1_IA_VERTEX_INPUT_STRUCTURE_ELEMENT_COUNT         32
+CONSTANT: D3D10_1_PS_OUTPUT_MASK_REGISTER_COMPONENTS              1
+CONSTANT: D3D10_1_PS_OUTPUT_MASK_REGISTER_COMPONENT_BIT_COUNT     32
+CONSTANT: D3D10_1_PS_OUTPUT_MASK_REGISTER_COUNT                   1
+CONSTANT: D3D10_1_SHADER_MAJOR_VERSION                            4
+CONSTANT: D3D10_1_SHADER_MINOR_VERSION                            1
+CONSTANT: D3D10_1_SO_BUFFER_MAX_STRIDE_IN_BYTES                   2048
+CONSTANT: D3D10_1_SO_BUFFER_MAX_WRITE_WINDOW_IN_BYTES             256
+CONSTANT: D3D10_1_SO_BUFFER_SLOT_COUNT                            4
+CONSTANT: D3D10_1_SO_MULTIPLE_BUFFER_ELEMENTS_PER_BUFFER          1
+CONSTANT: D3D10_1_SO_SINGLE_BUFFER_COMPONENT_LIMIT                64
+CONSTANT: D3D10_1_STANDARD_VERTEX_ELEMENT_COUNT                   32
+CONSTANT: D3D10_1_SUBPIXEL_FRACTIONAL_BIT_COUNT                   8
+CONSTANT: D3D10_1_VS_INPUT_REGISTER_COUNT                         32
+CONSTANT: D3D10_1_VS_OUTPUT_REGISTER_COUNT                        32
+
+CONSTANT: D3D10_FEATURE_LEVEL_10_0    HEX: a000
+CONSTANT: D3D10_FEATURE_LEVEL_10_1    HEX: a100
+CONSTANT: D3D10_FEATURE_LEVEL_9_1     HEX: 9100
+CONSTANT: D3D10_FEATURE_LEVEL_9_2     HEX: 9200
+CONSTANT: D3D10_FEATURE_LEVEL_9_3     HEX: 9300
+TYPEDEF: int D3D10_FEATURE_LEVEL1
+
+STRUCT: D3D10_RENDER_TARGET_BLEND_DESC1
+    { BlendEnable           BOOL           }
+    { SrcBlend              D3D10_BLEND    }
+    { DestBlend             D3D10_BLEND    }
+    { BlendOp               D3D10_BLEND_OP }
+    { SrcBlendAlpha         D3D10_BLEND    }
+    { DestBlendAlpha        D3D10_BLEND    }
+    { BlendOpAlpha          D3D10_BLEND_OP }
+    { RenderTargetWriteMask BYTE           } ;
+
+STRUCT: D3D10_BLEND_DESC1
+    { AlphaToCoverageEnable  BOOL                               }
+    { IndependentBlendEnable BOOL                               }
+    { RenderTarget           D3D10_RENDER_TARGET_BLEND_DESC1[8] } ;
+
+COM-INTERFACE: ID3D10BlendState1 ID3D10BlendState {EDAD8D99-8A35-4d6d-8566-2EA276CDE161}
+    void GetDesc1 ( D3D10_BLEND_DESC1* pDesc ) ;
+
+STRUCT: D3D10_TEXCUBE_ARRAY_SRV1
+    { MostDetailedMip  UINT }
+    { MipLevels        UINT }
+    { First2DArrayFace UINT }
+    { NumCubes         UINT } ;
+
+CONSTANT: D3D10_1_SRV_DIMENSION_UNKNOWN           0
+CONSTANT: D3D10_1_SRV_DIMENSION_BUFFER            1
+CONSTANT: D3D10_1_SRV_DIMENSION_TEXTURE1D         2
+CONSTANT: D3D10_1_SRV_DIMENSION_TEXTURE1DARRAY    3
+CONSTANT: D3D10_1_SRV_DIMENSION_TEXTURE2D         4
+CONSTANT: D3D10_1_SRV_DIMENSION_TEXTURE2DARRAY    5
+CONSTANT: D3D10_1_SRV_DIMENSION_TEXTURE2DMS       6
+CONSTANT: D3D10_1_SRV_DIMENSION_TEXTURE2DMSARRAY  7
+CONSTANT: D3D10_1_SRV_DIMENSION_TEXTURE3D         8
+CONSTANT: D3D10_1_SRV_DIMENSION_TEXTURECUBE       9
+CONSTANT: D3D10_1_SRV_DIMENSION_TEXTURECUBEARRAY  10
+TYPEDEF: int D3D10_SRV_DIMENSION1
+
+UNION-STRUCT: D3D10_SHADER_RESOURCE_VIEW_DESC1_UNION
+    { Buffer           D3D10_BUFFER_SRV         }
+    { Texture1D        D3D10_TEX1D_SRV          }
+    { Texture1DArray   D3D10_TEX1D_ARRAY_SRV    }
+    { Texture2D        D3D10_TEX2D_SRV          }
+    { Texture2DArray   D3D10_TEX2D_ARRAY_SRV    }
+    { Texture2DMS      D3D10_TEX2DMS_SRV        }
+    { Texture2DMSArray D3D10_TEX2DMS_ARRAY_SRV  }
+    { Texture3D        D3D10_TEX3D_SRV          }
+    { TextureCube      D3D10_TEXCUBE_SRV        }
+    { TextureCubeArray D3D10_TEXCUBE_ARRAY_SRV1 } ;
+STRUCT: D3D10_SHADER_RESOURCE_VIEW_DESC1
+    { Format        DXGI_FORMAT                            }
+    { ViewDimension D3D10_SRV_DIMENSION1                   }
+    { View          D3D10_SHADER_RESOURCE_VIEW_DESC1_UNION } ;
+
+COM-INTERFACE: ID3D10ShaderResourceView1 ID3D10ShaderResourceView {9B7E4C87-342C-4106-A19F-4F2704F689F0}
+    void GetDesc1 ( D3D10_SHADER_RESOURCE_VIEW_DESC1* pDesc ) ;
+
+CONSTANT: D3D10_STANDARD_MULTISAMPLE_PATTERN  HEX: ffffffff
+CONSTANT: D3D10_CENTER_MULTISAMPLE_PATTERN    HEX: fffffffe
+TYPEDEF: int D3D10_STANDARD_MULTISAMPLE_QUALITY_LEVELS
+
+COM-INTERFACE: ID3D10Device1 ID3D10Device {9B7E4C8F-342C-4106-A19F-4F2704F689F0}
+    HRESULT CreateShaderResourceView1 (
+        ID3D10Resource*                   pResource,
+        D3D10_SHADER_RESOURCE_VIEW_DESC1* pDesc,
+        ID3D10ShaderResourceView1**       ppSRView )
+    HRESULT CreateBlendState1 (
+        D3D10_BLEND_DESC1*  pBlendStateDesc,
+        ID3D10BlendState1** ppBlendState )
+    D3D10_FEATURE_LEVEL1 GetFeatureLevel ( ) ;
+
+CONSTANT: D3D10_1_SDK_VERSION HEX: 20
+
+FUNCTION: HRESULT D3D10CreateDevice1 (
+    IDXGIAdapter*        pAdapter,
+    D3D10_DRIVER_TYPE    DriverType,
+    HMODULE              Software,
+    UINT                 Flags,
+    D3D10_FEATURE_LEVEL1 HardwareLevel,
+    UINT                 SDKVersion,
+    ID3D10Device1**      ppDevice ) ;
+
+FUNCTION: HRESULT D3D10CreateDeviceAndSwapChain1 (
+    IDXGIAdapter*         pAdapter,
+    D3D10_DRIVER_TYPE     DriverType,
+    HMODULE               Software,
+    UINT                  Flags,
+    D3D10_FEATURE_LEVEL1  HardwareLevel,
+    UINT                  SDKVersion,
+    DXGI_SWAP_CHAIN_DESC* pSwapChainDesc,
+    IDXGISwapChain**      ppSwapChain,
+    ID3D10Device1**       ppDevice ) ;
diff --git a/basis/windows/directx/d3d10_1/summary.txt b/basis/windows/directx/d3d10_1/summary.txt
new file mode 100644 (file)
index 0000000..922e807
--- /dev/null
@@ -0,0 +1 @@
+Direct3D 10.1 bindings. Corresponds to d3d10_1.h.
diff --git a/basis/windows/directx/d3d10_1/tags.txt b/basis/windows/directx/d3d10_1/tags.txt
new file mode 100644 (file)
index 0000000..2320bdd
--- /dev/null
@@ -0,0 +1,2 @@
+unportable
+bindings
diff --git a/basis/windows/directx/d3d10_1shader/authors.txt b/basis/windows/directx/d3d10_1shader/authors.txt
new file mode 100644 (file)
index 0000000..6f03a12
--- /dev/null
@@ -0,0 +1 @@
+Erik Charlebois
diff --git a/basis/windows/directx/d3d10_1shader/d3d10_1shader.factor b/basis/windows/directx/d3d10_1shader/d3d10_1shader.factor
new file mode 100644 (file)
index 0000000..4664b90
--- /dev/null
@@ -0,0 +1,161 @@
+USING: alien.c-types alien.syntax classes.struct windows.com
+windows.com.syntax windows.directx.d3d10 windows.directx.d3d10shader
+windows.types ;
+IN: windows.directx.d3d10_1shader
+
+LIBRARY: d3d10_1
+
+CONSTANT: D3D10_SHADER_DEBUG_REG_INPUT              0
+CONSTANT: D3D10_SHADER_DEBUG_REG_OUTPUT             1
+CONSTANT: D3D10_SHADER_DEBUG_REG_CBUFFER            2
+CONSTANT: D3D10_SHADER_DEBUG_REG_TBUFFER            3
+CONSTANT: D3D10_SHADER_DEBUG_REG_TEMP               4
+CONSTANT: D3D10_SHADER_DEBUG_REG_TEMPARRAY          5
+CONSTANT: D3D10_SHADER_DEBUG_REG_TEXTURE            6
+CONSTANT: D3D10_SHADER_DEBUG_REG_SAMPLER            7
+CONSTANT: D3D10_SHADER_DEBUG_REG_IMMEDIATECBUFFER   8
+CONSTANT: D3D10_SHADER_DEBUG_REG_LITERAL            9
+CONSTANT: D3D10_SHADER_DEBUG_REG_UNUSED             10
+CONSTANT: D3D11_SHADER_DEBUG_REG_INTERFACE_POINTERS 11
+CONSTANT: D3D10_SHADER_DEBUG_REG_FORCE_DWORD        HEX: 7fffffff
+TYPEDEF: int D3D10_SHADER_DEBUG_REGTYPE
+
+CONSTANT: D3D10_SHADER_DEBUG_SCOPE_GLOBAL      0
+CONSTANT: D3D10_SHADER_DEBUG_SCOPE_BLOCK       1
+CONSTANT: D3D10_SHADER_DEBUG_SCOPE_FORLOOP     2
+CONSTANT: D3D10_SHADER_DEBUG_SCOPE_STRUCT      3
+CONSTANT: D3D10_SHADER_DEBUG_SCOPE_FUNC_PARAMS 4
+CONSTANT: D3D10_SHADER_DEBUG_SCOPE_STATEBLOCK  5    
+CONSTANT: D3D10_SHADER_DEBUG_SCOPE_NAMESPACE   6
+CONSTANT: D3D10_SHADER_DEBUG_SCOPE_ANNOTATION  7
+CONSTANT: D3D10_SHADER_DEBUG_SCOPE_FORCE_DWORD HEX: 7fffffff
+TYPEDEF: int D3D10_SHADER_DEBUG_SCOPETYPE
+
+CONSTANT: D3D10_SHADER_DEBUG_VAR_VARIABLE    0
+CONSTANT: D3D10_SHADER_DEBUG_VAR_FUNCTION    1
+CONSTANT: D3D10_SHADER_DEBUG_VAR_FORCE_DWORD HEX: 7fffffff
+TYPEDEF: int D3D10_SHADER_DEBUG_VARTYPE
+
+STRUCT: D3D10_SHADER_DEBUG_TOKEN_INFO
+    { File        UINT }
+    { Line        UINT }
+    { Column      UINT }
+    { TokenLength UINT }
+    { TokenId     UINT } ;
+
+STRUCT: D3D10_SHADER_DEBUG_VAR_INFO
+    { TokenId        UINT                       }
+    { Type           D3D10_SHADER_VARIABLE_TYPE }
+    { Register       UINT                       }
+    { Component      UINT                       }
+    { ScopeVar       UINT                       }
+    { ScopeVarOffset UINT                       } ;
+
+STRUCT: D3D10_SHADER_DEBUG_INPUT_INFO
+    { Var                UINT                       }
+    { InitialRegisterSet D3D10_SHADER_DEBUG_REGTYPE }
+    { InitialBank        UINT                       }
+    { InitialRegister    UINT                       }
+    { InitialComponent   UINT                       }
+    { InitialValue       UINT                       } ;
+
+STRUCT: D3D10_SHADER_DEBUG_SCOPEVAR_INFO
+    { TokenId           UINT                        }
+    { VarType           D3D10_SHADER_DEBUG_VARTYPE  }
+    { Class             D3D10_SHADER_VARIABLE_CLASS }
+    { Rows              UINT                        }
+    { Columns           UINT                        }
+    { StructMemberScope UINT                        }
+    { uArrayIndices     UINT                        }
+    { ArrayElements     UINT                        }
+    { ArrayStrides      UINT                        }
+    { uVariables        UINT                        }
+    { uFirstVariable    UINT                        } ;
+
+STRUCT: D3D10_SHADER_DEBUG_SCOPE_INFO
+    { ScopeType    D3D10_SHADER_DEBUG_SCOPETYPE }
+    { Name         UINT                         }
+    { uNameLen     UINT                         }
+    { uVariables   UINT                         }
+    { VariableData UINT                         } ;
+
+STRUCT: D3D10_SHADER_DEBUG_OUTPUTVAR
+    { Var           UINT  }
+    { uValueMin     UINT  }
+    { uValueMax     UINT  }
+    { iValueMin     INT   }
+    { iValueMax     INT   }
+    { fValueMin     FLOAT }
+    { fValueMax     FLOAT }
+    { bNaNPossible  BOOL  }
+    { bInfPossible  BOOL  } ;
+
+STRUCT: D3D10_SHADER_DEBUG_OUTPUTREG_INFO
+    { OutputRegisterSet D3D10_SHADER_DEBUG_REGTYPE      }
+    { OutputReg         UINT                            }
+    { TempArrayReg      UINT                            }
+    { OutputComponents  UINT[4]                         }
+    { OutputVars        D3D10_SHADER_DEBUG_OUTPUTVAR[4] }
+    { IndexReg          UINT                            }
+    { IndexComp         UINT                            } ;
+
+STRUCT: D3D10_SHADER_DEBUG_INST_INFO
+    { Id               UINT                                 }
+    { Opcode           UINT                                 }
+    { uOutputs         UINT                                 }
+    { pOutputs         D3D10_SHADER_DEBUG_OUTPUTREG_INFO[2] }
+    { TokenId          UINT                                 }
+    { NestingLevel     UINT                                 }
+    { Scopes           UINT                                 }
+    { ScopeInfo        UINT                                 }
+    { AccessedVars     UINT                                 }
+    { AccessedVarsInfo UINT                                 } ;
+
+STRUCT: D3D10_SHADER_DEBUG_FILE_INFO
+    { FileName    UINT }
+    { FileNameLen UINT }
+    { FileData    UINT }
+    { FileLen     UINT } ;
+
+STRUCT: D3D10_SHADER_DEBUG_INFO
+    { Size              UINT }
+    { Creator           UINT }
+    { EntrypointName    UINT }
+    { ShaderTarget      UINT }
+    { CompileFlags      UINT }
+    { Files             UINT }
+    { FileInfo          UINT }
+    { Instructions      UINT }
+    { InstructionInfo   UINT }
+    { Variables         UINT }
+    { VariableInfo      UINT }
+    { InputVariables    UINT }
+    { InputVariableInfo UINT }
+    { Tokens            UINT }
+    { TokenInfo         UINT }
+    { Scopes            UINT }
+    { ScopeInfo         UINT }
+    { ScopeVariables    UINT }
+    { ScopeVariableInfo UINT }
+    { UintOffset        UINT }
+    { StringOffset      UINT } ;
+
+C-TYPE: ID3D10ShaderReflection1
+TYPEDEF: ID3D10ShaderReflection1* LPD3D10SHADERREFLECTION1
+
+COM-INTERFACE: ID3D10ShaderReflection1 IUnknown {C3457783-A846-47CE-9520-CEA6F66E7447}
+    HRESULT GetDesc ( D3D10_SHADER_DESC* pDesc )
+    ID3D10ShaderReflectionConstantBuffer* GetConstantBufferByIndex ( UINT Index )
+    ID3D10ShaderReflectionConstantBuffer* GetConstantBufferByName ( LPCSTR Name )
+    HRESULT GetResourceBindingDesc ( UINT ResourceIndex, D3D10_SHADER_INPUT_BIND_DESC* pDesc )
+    HRESULT GetInputParameterDesc ( UINT ParameterIndex, D3D10_SIGNATURE_PARAMETER_DESC* pDesc )
+    HRESULT GetOutputParameterDesc ( UINT ParameterIndex, D3D10_SIGNATURE_PARAMETER_DESC* pDesc )
+    ID3D10ShaderReflectionVariable* GetVariableByName ( LPCSTR Name )
+    HRESULT GetResourceBindingDescByName ( LPCSTR Name, D3D10_SHADER_INPUT_BIND_DESC* pDesc )
+    HRESULT GetMovInstructionCount ( UINT* pCount )
+    HRESULT GetMovcInstructionCount ( UINT* pCount )
+    HRESULT GetConversionInstructionCount ( UINT* pCount )
+    HRESULT GetBitwiseInstructionCount ( UINT* pCount )
+    HRESULT GetGSInputPrimitive ( D3D10_PRIMITIVE* pPrim )
+    HRESULT IsLevel9Shader ( BOOL* pbLevel9Shader )
+    HRESULT IsSampleFrequencyShader ( BOOL* pbSampleFrequency ) ;
diff --git a/basis/windows/directx/d3d10_1shader/summary.txt b/basis/windows/directx/d3d10_1shader/summary.txt
new file mode 100644 (file)
index 0000000..9189058
--- /dev/null
@@ -0,0 +1 @@
+Direct3D 10.1 bindings. Corresponds to d3d10_1shader.h.
diff --git a/basis/windows/directx/d3d10_1shader/tags.txt b/basis/windows/directx/d3d10_1shader/tags.txt
new file mode 100644 (file)
index 0000000..2320bdd
--- /dev/null
@@ -0,0 +1,2 @@
+unportable
+bindings
diff --git a/basis/windows/directx/d3d10effect/authors.txt b/basis/windows/directx/d3d10effect/authors.txt
new file mode 100644 (file)
index 0000000..6f03a12
--- /dev/null
@@ -0,0 +1 @@
+Erik Charlebois
diff --git a/basis/windows/directx/d3d10effect/d3d10effect.factor b/basis/windows/directx/d3d10effect/d3d10effect.factor
new file mode 100644 (file)
index 0000000..5b4fbb4
--- /dev/null
@@ -0,0 +1,335 @@
+USING: alien.c-types alien.syntax classes.struct windows.com
+windows.com.syntax windows.directx.d3d10
+windows.directx.d3d10shader windows.types ;
+IN: windows.directx.d3d10effect
+
+LIBRARY: d3d10
+
+CONSTANT: D3D10_DST_SO_BUFFERS             1
+CONSTANT: D3D10_DST_OM_RENDER_TARGETS      2
+CONSTANT: D3D10_DST_OM_DEPTH_STENCIL_STATE 3
+CONSTANT: D3D10_DST_OM_BLEND_STATE         4
+CONSTANT: D3D10_DST_VS                     5
+CONSTANT: D3D10_DST_VS_SAMPLERS            6
+CONSTANT: D3D10_DST_VS_SHADER_RESOURCES    7
+CONSTANT: D3D10_DST_VS_CONSTANT_BUFFERS    8
+CONSTANT: D3D10_DST_GS                     9
+CONSTANT: D3D10_DST_GS_SAMPLERS            10
+CONSTANT: D3D10_DST_GS_SHADER_RESOURCES    11
+CONSTANT: D3D10_DST_GS_CONSTANT_BUFFERS    12
+CONSTANT: D3D10_DST_PS                     13
+CONSTANT: D3D10_DST_PS_SAMPLERS            14
+CONSTANT: D3D10_DST_PS_SHADER_RESOURCES    15
+CONSTANT: D3D10_DST_PS_CONSTANT_BUFFERS    16
+CONSTANT: D3D10_DST_IA_VERTEX_BUFFERS      17
+CONSTANT: D3D10_DST_IA_INDEX_BUFFER        18
+CONSTANT: D3D10_DST_IA_INPUT_LAYOUT        19
+CONSTANT: D3D10_DST_IA_PRIMITIVE_TOPOLOGY  20
+CONSTANT: D3D10_DST_RS_VIEWPORTS           21
+CONSTANT: D3D10_DST_RS_SCISSOR_RECTS       22
+CONSTANT: D3D10_DST_RS_RASTERIZER_STATE    23
+CONSTANT: D3D10_DST_PREDICATION            24
+TYPEDEF: int D3D10_DEVICE_STATE_TYPES
+
+STRUCT: D3D10_STATE_BLOCK_MASK
+    { VS                  BYTE    }
+    { VSSamplers          BYTE[2] }
+    { VSShaderResources   BYTE[8] }
+    { VSConstantBuffers   BYTE[2] }
+    { GS                  BYTE    }
+    { GSSamplers          BYTE[2] }
+    { GSShaderResources   BYTE[8] }
+    { GSConstantBuffers   BYTE[2] }
+    { PS                  BYTE    }
+    { PSSamplers          BYTE[2] }
+    { PSShaderResources   BYTE[8] }
+    { PSConstantBuffers   BYTE[2] }
+    { IAVertexBuffers     BYTE[2] }
+    { IAIndexBuffer       BYTE    }
+    { IAInputLayout       BYTE    }
+    { IAPrimitiveTopology BYTE    }
+    { OMRenderTargets     BYTE    }
+    { OMDepthStencilState BYTE    }
+    { OMBlendState        BYTE    }
+    { RSViewports         BYTE    }
+    { RSScissorRects      BYTE    }
+    { RSRasterizerState   BYTE    }
+    { SOBuffers           BYTE    }
+    { Predication         BYTE    } ;
+
+COM-INTERFACE: ID3D10StateBlock IUnknown {0803425A-57F5-4dd6-9465-A87570834A08}
+    HRESULT Capture ( )
+    HRESULT Apply ( )
+    HRESULT ReleaseAllDeviceObjects ( )
+    HRESULT GetDevice ( ID3D10Device** ppDevice ) ;
+TYPEDEF: ID3D10StateBlock* LPD3D10STATEBLOCK
+
+FUNCTION: HRESULT D3D10StateBlockMaskUnion ( D3D10_STATE_BLOCK_MASK* pA, D3D10_STATE_BLOCK_MASK* pB, D3D10_STATE_BLOCK_MASK* pResult ) ;
+FUNCTION: HRESULT D3D10StateBlockMaskIntersect ( D3D10_STATE_BLOCK_MASK* pA, D3D10_STATE_BLOCK_MASK* pB, D3D10_STATE_BLOCK_MASK* pResult ) ;
+FUNCTION: HRESULT D3D10StateBlockMaskDifference ( D3D10_STATE_BLOCK_MASK* pA, D3D10_STATE_BLOCK_MASK* pB, D3D10_STATE_BLOCK_MASK* pResult ) ;
+FUNCTION: HRESULT D3D10StateBlockMaskEnableCapture ( D3D10_STATE_BLOCK_MASK* pMask, D3D10_DEVICE_STATE_TYPES StateType, UINT RangeStart, UINT RangeLength ) ;
+FUNCTION: HRESULT D3D10StateBlockMaskDisableCapture ( D3D10_STATE_BLOCK_MASK* pMask, D3D10_DEVICE_STATE_TYPES StateType, UINT RangeStart, UINT RangeLength ) ;
+FUNCTION: HRESULT D3D10StateBlockMaskEnableAll ( D3D10_STATE_BLOCK_MASK* pMask ) ;
+FUNCTION: HRESULT D3D10StateBlockMaskDisableAll ( D3D10_STATE_BLOCK_MASK* pMask ) ;
+FUNCTION: BOOL    D3D10StateBlockMaskGetSetting ( D3D10_STATE_BLOCK_MASK* pMask, D3D10_DEVICE_STATE_TYPES StateType, UINT Entry ) ;
+
+FUNCTION: HRESULT D3D10CreateStateBlock ( ID3D10Device* pDevice, D3D10_STATE_BLOCK_MASK* pStateBlockMask, ID3D10StateBlock** ppStateBlock ) ;
+
+CONSTANT: D3D10_EFFECT_COMPILE_CHILD_EFFECT             1
+CONSTANT: D3D10_EFFECT_COMPILE_ALLOW_SLOW_OPS           2
+CONSTANT: D3D10_EFFECT_SINGLE_THREADED                  8
+
+CONSTANT: D3D10_EFFECT_VARIABLE_POOLED                  1
+CONSTANT: D3D10_EFFECT_VARIABLE_ANNOTATION              2
+CONSTANT: D3D10_EFFECT_VARIABLE_EXPLICIT_BIND_POINT     4
+
+STRUCT: D3D10_EFFECT_TYPE_DESC
+    { TypeName        LPCSTR                      }
+    { Class           D3D10_SHADER_VARIABLE_CLASS }
+    { Type            D3D10_SHADER_VARIABLE_TYPE  }
+    { Elements        UINT                        }
+    { Members         UINT                        }
+    { Rows            UINT                        }
+    { Columns         UINT                        }
+    { PackedSize      UINT                        }
+    { UnpackedSize    UINT                        }
+    { Stride          UINT                        } ;
+
+COM-INTERFACE: ID3D10EffectType f {4E9E1DDC-CD9D-4772-A837-00180B9B88FD}
+    BOOL IsValid ( )
+    HRESULT GetDesc ( D3D10_EFFECT_TYPE_DESC* pDesc )
+    ID3D10EffectType* GetMemberTypeByIndex ( UINT Index )
+    ID3D10EffectType* GetMemberTypeByName ( LPCSTR Name )
+    ID3D10EffectType* GetMemberTypeBySemantic ( LPCSTR Semantic )
+    LPCSTR GetMemberName ( UINT Index )
+    LPCSTR GetMemberSemantic ( UINT Index ) ;
+TYPEDEF: ID3D10EffectType* LPD3D10EFFECTTYPE
+
+STRUCT: D3D10_EFFECT_VARIABLE_DESC
+    { Name                 LPCSTR }
+    { Semantic             LPCSTR }
+    { Flags                UINT   }
+    { Annotations          UINT   }
+    { BufferOffset         UINT   }
+    { ExplicitBindPoint    UINT   } ;
+
+COM-INTERFACE: ID3D10EffectVariable f {AE897105-00E6-45bf-BB8E-281DD6DB8E1B}
+    BOOL IsValid ( )
+    ID3D10EffectType* GetType ( )
+    HRESULT GetDesc ( D3D10_EFFECT_VARIABLE_DESC* pDesc )
+    ID3D10EffectVariable* GetAnnotationByIndex ( UINT Index )
+    ID3D10EffectVariable* GetAnnotationByName ( LPCSTR Name )
+    ID3D10EffectVariable* GetMemberByIndex ( UINT Index )
+    ID3D10EffectVariable* GetMemberByName ( LPCSTR Name )
+    ID3D10EffectVariable* GetMemberBySemantic ( LPCSTR Semantic )
+    ID3D10EffectVariable* GetElement ( UINT Index )
+    ID3D10EffectConstantBuffer* GetParentConstantBuffer ( )
+    ID3D10EffectScalarVariable* AsScalar ( )
+    ID3D10EffectVectorVariable* AsVector ( )
+    ID3D10EffectMatrixVariable* AsMatrix ( )
+    ID3D10EffectStringVariable* AsString ( )
+    ID3D10EffectShaderResourceVariable* AsShaderResource ( )
+    ID3D10EffectRenderTargetViewVariable* AsRenderTargetView ( )
+    ID3D10EffectDepthStencilViewVariable* AsDepthStencilView ( )
+    ID3D10EffectConstantBuffer* AsConstantBuffer ( )
+    ID3D10EffectShaderVariable* AsShader ( )
+    ID3D10EffectBlendVariable* AsBlend ( )
+    ID3D10EffectDepthStencilVariable* AsDepthStencil ( )
+    ID3D10EffectRasterizerVariable* AsRasterizer ( )
+    ID3D10EffectSamplerVariable* AsSampler ( )
+    HRESULT SetRawValue ( void* pData, UINT Offset, UINT Count )
+    HRESULT GetRawValue ( void* pData, UINT Offset, UINT Count ) ;
+TYPEDEF: ID3D10EffectVariable* LPD3D10EFFECTVARIABLE
+
+COM-INTERFACE: ID3D10EffectScalarVariable ID3D10EffectVariable {00E48F7B-D2C8-49e8-A86C-022DEE53431F}
+    HRESULT SetFloat ( float Value )
+    HRESULT GetFloat ( float* pValue )
+    HRESULT SetFloatArray ( float* pData, UINT Offset, UINT Count )
+    HRESULT GetFloatArray ( float* pData, UINT Offset, UINT Count )
+    HRESULT SetInt ( int Value )
+    HRESULT GetInt ( int* pValue )
+    HRESULT SetIntArray ( int* pData, UINT Offset, UINT Count )
+    HRESULT GetIntArray ( int* pData, UINT Offset, UINT Count )
+    HRESULT SetBool ( BOOL Value )
+    HRESULT GetBool ( BOOL* pValue )
+    HRESULT SetBoolArray ( BOOL* pData, UINT Offset, UINT Count )
+    HRESULT GetBoolArray ( BOOL* pData, UINT Offset, UINT Count ) ;
+TYPEDEF: ID3D10EffectScalarVariable* LPD3D10EFFECTSCALARVARIABLE
+
+COM-INTERFACE: ID3D10EffectVectorVariable ID3D10EffectVariable {62B98C44-1F82-4c67-BCD0-72CF8F217E81}
+    HRESULT SetBoolVector ( BOOL* pData )
+    HRESULT SetIntVector  ( int* pData )
+    HRESULT SetFloatVector ( float* pData )
+    HRESULT GetBoolVector ( BOOL* pData )
+    HRESULT GetIntVector  ( int* pData )
+    HRESULT GetFloatVector ( float *pData )
+    HRESULT SetBoolVectorArray ( BOOL* pData, UINT Offset, UINT Count )
+    HRESULT SetIntVectorArray  ( int* pData, UINT Offset, UINT Count )
+    HRESULT SetFloatVectorArray ( float* pData, UINT Offset, UINT Count )
+    HRESULT GetBoolVectorArray ( BOOL* pData, UINT Offset, UINT Count )
+    HRESULT GetIntVectorArray  ( int* pData, UINT Offset, UINT Count )
+    HRESULT GetFloatVectorArray ( float* pData, UINT Offset, UINT Count ) ;
+TYPEDEF: ID3D10EffectVectorVariable* LPD3D10EFFECTVECTORVARIABLE
+
+COM-INTERFACE: ID3D10EffectMatrixVariable ID3D10EffectVariable {50666C24-B82F-4eed-A172-5B6E7E8522E0}
+    HRESULT SetMatrix ( float* pData )
+    HRESULT GetMatrix ( float* pData )
+    HRESULT SetMatrixArray ( float* pData, UINT Offset, UINT Count )
+    HRESULT GetMatrixArray ( float* pData, UINT Offset, UINT Count )
+    HRESULT SetMatrixTranspose ( float* pData )
+    HRESULT GetMatrixTranspose ( float* pData )
+    HRESULT SetMatrixTransposeArray ( float* pData, UINT Offset, UINT Count )
+    HRESULT GetMatrixTransposeArray ( float* pData, UINT Offset, UINT Count ) ;
+TYPEDEF: ID3D10EffectMatrixVariable* LPD3D10EFFECTMATRIXVARIABLE
+
+
+COM-INTERFACE: ID3D10EffectStringVariable ID3D10EffectVariable {71417501-8DF9-4e0a-A78A-255F9756BAFF}
+    HRESULT GetString ( LPCSTR* ppString )
+    HRESULT GetStringArray ( LPCSTR* ppStrings, UINT Offset, UINT Count ) ;
+TYPEDEF: ID3D10EffectStringVariable* LPD3D10EFFECTSTRINGVARIABLE
+
+COM-INTERFACE: ID3D10EffectShaderResourceVariable ID3D10EffectVariable {C0A7157B-D872-4b1d-8073-EFC2ACD4B1FC}
+    HRESULT SetResource ( ID3D10ShaderResourceView* pResource )
+    HRESULT GetResource ( ID3D10ShaderResourceView** ppResource )
+    HRESULT SetResourceArray ( ID3D10ShaderResourceView** ppResources, UINT Offset, UINT Count )
+    HRESULT GetResourceArray ( ID3D10ShaderResourceView** ppResources, UINT Offset, UINT Count ) ;
+TYPEDEF: ID3D10EffectShaderResourceVariable* LPD3D10EFFECTSHADERRESOURCEVARIABLE
+
+COM-INTERFACE: ID3D10EffectRenderTargetViewVariable ID3D10EffectVariable {28CA0CC3-C2C9-40bb-B57F-67B737122B17}
+    HRESULT SetRenderTarget ( ID3D10RenderTargetView* pResource )
+    HRESULT GetRenderTarget ( ID3D10RenderTargetView** ppResource )
+    HRESULT SetRenderTargetArray ( ID3D10RenderTargetView** ppResources, UINT Offset, UINT Count )
+    HRESULT GetRenderTargetArray ( ID3D10RenderTargetView** ppResources, UINT Offset, UINT Count ) ;
+TYPEDEF: ID3D10EffectRenderTargetViewVariable* LPD3D10EFFECTRENDERTARGETVIEWVARIABLE
+
+COM-INTERFACE: ID3D10EffectDepthStencilViewVariable ID3D10EffectVariable {3E02C918-CC79-4985-B622-2D92AD701623}
+    HRESULT SetDepthStencil ( ID3D10DepthStencilView* pResource )
+    HRESULT GetDepthStencil ( ID3D10DepthStencilView** ppResource )
+    HRESULT SetDepthStencilArray ( ID3D10DepthStencilView** ppResources, UINT Offset, UINT Count )
+    HRESULT GetDepthStencilArray ( ID3D10DepthStencilView** ppResources, UINT Offset, UINT Count ) ;
+TYPEDEF: ID3D10EffectDepthStencilViewVariable* LPD3D10EFFECTDEPTHSTENCILVIEWVARIABLE
+
+COM-INTERFACE: ID3D10EffectConstantBuffer ID3D10EffectVariable {56648F4D-CC8B-4444-A5AD-B5A3D76E91B3}
+    HRESULT SetConstantBuffer ( ID3D10Buffer* pConstantBuffer )
+    HRESULT GetConstantBuffer ( ID3D10Buffer** ppConstantBuffer )
+    HRESULT SetTextureBuffer ( ID3D10ShaderResourceView* pTextureBuffer )
+    HRESULT GetTextureBuffer ( ID3D10ShaderResourceView** ppTextureBuffer ) ;
+TYPEDEF: ID3D10EffectConstantBuffer* LPD3D10EFFECTCONSTANTBUFFER
+
+STRUCT: D3D10_EFFECT_SHADER_DESC
+    { pInputSignature           BYTE*  }
+    { IsInline                  BOOL   }
+    { pBytecode                 BYTE*  }
+    { BytecodeLength            UINT   }
+    { SODecl                    LPCSTR }
+    { NumInputSignatureEntries  UINT   }
+    { NumOutputSignatureEntries UINT   } ;
+
+COM-INTERFACE: ID3D10EffectShaderVariable ID3D10EffectVariable {80849279-C799-4797-8C33-0407A07D9E06}
+    HRESULT GetShaderDesc ( UINT ShaderIndex, D3D10_EFFECT_SHADER_DESC* pDesc )
+    HRESULT GetVertexShader ( UINT ShaderIndex, ID3D10VertexShader** ppVS )
+    HRESULT GetGeometryShader ( UINT ShaderIndex, ID3D10GeometryShader** ppGS )
+    HRESULT GetPixelShader ( UINT ShaderIndex, ID3D10PixelShader** ppPS )
+    HRESULT GetInputSignatureElementDesc ( UINT ShaderIndex, UINT Element, D3D10_SIGNATURE_PARAMETER_DESC* pDesc )
+    HRESULT GetOutputSignatureElementDesc ( UINT ShaderIndex, UINT Element, D3D10_SIGNATURE_PARAMETER_DESC* pDesc ) ;
+TYPEDEF: ID3D10EffectShaderVariable* LPD3D10EFFECTSHADERVARIABLE
+
+COM-INTERFACE: ID3D10EffectBlendVariable ID3D10EffectVariable {1FCD2294-DF6D-4eae-86B3-0E9160CFB07B}
+    HRESULT GetBlendState ( UINT Index, ID3D10BlendState** ppBlendState )
+    HRESULT GetBackingStore ( UINT Index, D3D10_BLEND_DESC* pBlendDesc ) ;
+TYPEDEF: ID3D10EffectBlendVariable* LPD3D10EFFECTBLENDVARIABLE
+
+COM-INTERFACE: ID3D10EffectDepthStencilVariable ID3D10EffectVariable {AF482368-330A-46a5-9A5C-01C71AF24C8D}
+    HRESULT GetDepthStencilState ( UINT Index, ID3D10DepthStencilState** ppDepthStencilState )
+    HRESULT GetBackingStore ( UINT Index, D3D10_DEPTH_STENCIL_DESC* pDepthStencilDesc ) ;
+TYPEDEF: ID3D10EffectDepthStencilVariable* LPD3D10EFFECTDEPTHSTENCILVARIABLE
+
+COM-INTERFACE: ID3D10EffectRasterizerVariable ID3D10EffectVariable {21AF9F0E-4D94-4ea9-9785-2CB76B8C0B34}
+    HRESULT GetRasterizerState ( UINT Index, ID3D10RasterizerState** ppRasterizerState )
+    HRESULT GetBackingStore ( UINT Index, D3D10_RASTERIZER_DESC* pRasterizerDesc ) ;
+TYPEDEF: ID3D10EffectRasterizerVariable* LPD3D10EFFECTRASTERIZERVARIABLE
+
+COM-INTERFACE: ID3D10EffectSamplerVariable ID3D10EffectVariable {6530D5C7-07E9-4271-A418-E7CE4BD1E480}
+    HRESULT GetSampler ( UINT Index, ID3D10SamplerState** ppSampler )
+    HRESULT GetBackingStore ( UINT Index, D3D10_SAMPLER_DESC* pSamplerDesc ) ;
+TYPEDEF: ID3D10EffectSamplerVariable* LPD3D10EFFECTSAMPLERVARIABLE
+    
+STRUCT: D3D10_PASS_DESC
+    { Name                 LPCSTR   }
+    { Annotations          UINT     }
+    { pIAInputSignature    BYTE*    }
+    { IAInputSignatureSize SIZE_T   }
+    { StencilRef           UINT     }
+    { SampleMask           UINT     }
+    { BlendFactor          FLOAT[4] } ;
+
+STRUCT: D3D10_PASS_SHADER_DESC
+    { pShaderVariable                    ID3D10EffectShaderVariable* }
+    { ShaderIndex                        UINT                        } ;
+
+COM-INTERFACE: ID3D10EffectPass f {5CFBEB89-1A06-46e0-B282-E3F9BFA36A54}
+    BOOL IsValid ( )
+    HRESULT GetDesc ( D3D10_PASS_DESC* pDesc )
+    HRESULT GetVertexShaderDesc ( D3D10_PASS_SHADER_DESC* pDesc )
+    HRESULT GetGeometryShaderDesc ( D3D10_PASS_SHADER_DESC* pDesc )
+    HRESULT GetPixelShaderDesc ( D3D10_PASS_SHADER_DESC* pDesc )
+    ID3D10EffectVariable* GetAnnotationByIndex ( UINT Index )
+    ID3D10EffectVariable* GetAnnotationByName ( LPCSTR Name )
+    HRESULT Apply ( UINT Flags )
+    HRESULT ComputeStateBlockMask ( D3D10_STATE_BLOCK_MASK* pStateBlockMask ) ;
+TYPEDEF: ID3D10EffectPass* LPD3D10EFFECTPASS
+
+STRUCT: D3D10_TECHNIQUE_DESC
+    { Name           LPCSTR }
+    { Passes         UINT   }
+    { Annotations    UINT   } ;
+
+COM-INTERFACE: ID3D10EffectTechnique f {DB122CE8-D1C9-4292-B237-24ED3DE8B175}
+    BOOL IsValid ( )
+    HRESULT GetDesc ( D3D10_TECHNIQUE_DESC* pDesc )
+    ID3D10EffectVariable* GetAnnotationByIndex ( UINT Index )
+    ID3D10EffectVariable* GetAnnotationByName ( LPCSTR Name )
+    ID3D10EffectPass* GetPassByIndex ( UINT Index )
+    ID3D10EffectPass* GetPassByName ( LPCSTR Name )
+    HRESULT ComputeStateBlockMask ( D3D10_STATE_BLOCK_MASK* pStateBlockMask ) ;
+TYPEDEF: ID3D10EffectTechnique* LPD3D10EFFECTTECHNIQUE
+
+STRUCT: D3D10_EFFECT_DESC
+    { IsChildEffect            BOOL }
+    { ConstantBuffers          UINT }
+    { SharedConstantBuffers    UINT }
+    { GlobalVariables          UINT }
+    { SharedGlobalVariables    UINT }
+    { Techniques               UINT } ;
+
+COM-INTERFACE: ID3D10Effect IUnknown {51B0CA8B-EC0B-4519-870D-8EE1CB5017C7}
+    BOOL IsValid ( )
+    BOOL IsPool ( )
+    HRESULT GetDevice ( ID3D10Device** ppDevice )
+    HRESULT GetDesc ( D3D10_EFFECT_DESC* pDesc )
+    ID3D10EffectConstantBuffer* GetConstantBufferByIndex ( UINT Index )
+    ID3D10EffectConstantBuffer* GetConstantBufferByName ( LPCSTR Name )
+    ID3D10EffectVariable* GetVariableByIndex ( UINT Index )
+    ID3D10EffectVariable* GetVariableByName ( LPCSTR Name )
+    ID3D10EffectVariable* GetVariableBySemantic ( LPCSTR Semantic )
+    ID3D10EffectTechnique* GetTechniqueByIndex ( UINT Index )
+    ID3D10EffectTechnique* GetTechniqueByName ( LPCSTR Name )
+    HRESULT Optimize ( )
+    BOOL IsOptimized ( ) ;
+TYPEDEF: ID3D10Effect* LPD3D10EFFECT
+
+COM-INTERFACE: ID3D10EffectPool IUnknown {9537AB04-3250-412e-8213-FCD2F8677933}
+    ID3D10Effect* AsEffect ( ) ;
+TYPEDEF: ID3D10EffectPool* LPD3D10EFFECTPOOL
+
+FUNCTION: HRESULT D3D10CompileEffectFromMemory ( void* pData, SIZE_T DataLength, LPCSTR pSrcFileName, D3D10_SHADER_MACRO* pDefines,
+    ID3D10Include* pInclude, UINT HLSLFlags, UINT FXFlags,
+    ID3D10Blob** ppCompiledEffect, ID3D10Blob** ppErrors ) ;
+
+FUNCTION: HRESULT D3D10CreateEffectFromMemory ( void* pData, SIZE_T DataLength, UINT FXFlags, ID3D10Device* pDevice,
+    ID3D10EffectPool* pEffectPool, ID3D10Effect** ppEffect ) ;
+
+FUNCTION: HRESULT D3D10CreateEffectPoolFromMemory ( void* pData, SIZE_T DataLength, UINT FXFlags, ID3D10Device* pDevice,
+    ID3D10EffectPool** ppEffectPool ) ;
+
+FUNCTION: HRESULT D3D10DisassembleEffect ( ID3D10Effect* pEffect, BOOL EnableColorCode, ID3D10Blob** ppDisassembly ) ;
diff --git a/basis/windows/directx/d3d10effect/summary.txt b/basis/windows/directx/d3d10effect/summary.txt
new file mode 100644 (file)
index 0000000..1fc06d8
--- /dev/null
@@ -0,0 +1 @@
+Direct3D 10 bindings. Corresponds to d3d10effect.h.
diff --git a/basis/windows/directx/d3d10effect/tags.txt b/basis/windows/directx/d3d10effect/tags.txt
new file mode 100644 (file)
index 0000000..2320bdd
--- /dev/null
@@ -0,0 +1,2 @@
+unportable
+bindings
diff --git a/basis/windows/directx/d3d10misc/authors.txt b/basis/windows/directx/d3d10misc/authors.txt
new file mode 100644 (file)
index 0000000..6f03a12
--- /dev/null
@@ -0,0 +1 @@
+Erik Charlebois
diff --git a/basis/windows/directx/d3d10misc/d3d10misc.factor b/basis/windows/directx/d3d10misc/d3d10misc.factor
new file mode 100644 (file)
index 0000000..b6f5f12
--- /dev/null
@@ -0,0 +1,39 @@
+USING: alien.c-types alien.syntax windows.com windows.com.syntax
+windows.directx.dxgi windows.types alien.libraries ;
+IN: windows.directx.d3d10misc
+
+LIBRARY: d3d10
+
+C-TYPE: ID3D10Blob
+TYPEDEF: ID3D10Blob* LPD3D10BLOB
+
+COM-INTERFACE: ID3D10Blob IUnknown {8BA5FB08-5195-40e2-AC58-0D989C3A0102}
+    LPVOID GetBufferPointer ( )
+    SIZE_T GetBufferSize ( ) ;
+
+CONSTANT: D3D10_DRIVER_TYPE_HARDWARE  0
+CONSTANT: D3D10_DRIVER_TYPE_REFERENCE 1
+CONSTANT: D3D10_DRIVER_TYPE_NULL      2
+CONSTANT: D3D10_DRIVER_TYPE_SOFTWARE  3
+CONSTANT: D3D10_DRIVER_TYPE_WARP      5
+TYPEDEF: int D3D10_DRIVER_TYPE
+
+FUNCTION: HRESULT D3D10CreateDevice (
+    IDXGIAdapter*     pAdapter,
+    D3D10_DRIVER_TYPE DriverType,
+    HMODULE           Software,
+    UINT              Flags,
+    UINT              SDKVersion,
+    ID3D10Device**    ppDevice ) ;
+
+FUNCTION: HRESULT D3D10CreateDeviceAndSwapChain (
+    IDXGIAdapter*         pAdapter,
+    D3D10_DRIVER_TYPE     DriverType,
+    HMODULE               Software,
+    UINT                  Flags,
+    UINT                  SDKVersion,
+    DXGI_SWAP_CHAIN_DESC* pSwapChainDesc,
+    IDXGISwapChain**      ppSwapChain,    
+    ID3D10Device**        ppDevice ) ;
+
+FUNCTION: HRESULT D3D10CreateBlob ( SIZE_T NumBytes, LPD3D10BLOB* ppBuffer ) ;
diff --git a/basis/windows/directx/d3d10misc/summary.txt b/basis/windows/directx/d3d10misc/summary.txt
new file mode 100644 (file)
index 0000000..3d283f4
--- /dev/null
@@ -0,0 +1 @@
+Direct3D 10 bindings. Corresponds to d3d10misc.h.
diff --git a/basis/windows/directx/d3d10misc/tags.txt b/basis/windows/directx/d3d10misc/tags.txt
new file mode 100644 (file)
index 0000000..2320bdd
--- /dev/null
@@ -0,0 +1,2 @@
+unportable
+bindings
diff --git a/basis/windows/directx/d3d10shader/authors.txt b/basis/windows/directx/d3d10shader/authors.txt
new file mode 100644 (file)
index 0000000..6f03a12
--- /dev/null
@@ -0,0 +1 @@
+Erik Charlebois
diff --git a/basis/windows/directx/d3d10shader/d3d10shader.factor b/basis/windows/directx/d3d10shader/d3d10shader.factor
new file mode 100644 (file)
index 0000000..4507441
--- /dev/null
@@ -0,0 +1,278 @@
+USING: alien.syntax alien.c-types classes.struct windows.types windows.com
+windows.com.syntax windows.directx.d3d10 ;
+IN: windows.directx.d3d10shader
+
+LIBRARY: d3d10
+
+CONSTANT: D3D10_SHADER_DEBUG                          1
+CONSTANT: D3D10_SHADER_SKIP_VALIDATION                2
+CONSTANT: D3D10_SHADER_SKIP_OPTIMIZATION              4
+CONSTANT: D3D10_SHADER_PACK_MATRIX_ROW_MAJOR          8
+CONSTANT: D3D10_SHADER_PACK_MATRIX_COLUMN_MAJOR       16
+CONSTANT: D3D10_SHADER_PARTIAL_PRECISION              32
+CONSTANT: D3D10_SHADER_FORCE_VS_SOFTWARE_NO_OPT       64
+CONSTANT: D3D10_SHADER_FORCE_PS_SOFTWARE_NO_OPT       128
+CONSTANT: D3D10_SHADER_NO_PRESHADER                   256
+CONSTANT: D3D10_SHADER_AVOID_FLOW_CONTROL             512
+CONSTANT: D3D10_SHADER_PREFER_FLOW_CONTROL            1024
+CONSTANT: D3D10_SHADER_ENABLE_STRICTNESS              2048
+CONSTANT: D3D10_SHADER_ENABLE_BACKWARDS_COMPATIBILITY 4096
+CONSTANT: D3D10_SHADER_IEEE_STRICTNESS                8192
+CONSTANT: D3D10_SHADER_WARNINGS_ARE_ERRORS            262144
+
+CONSTANT: D3D10_SHADER_OPTIMIZATION_LEVEL0 16384
+CONSTANT: D3D10_SHADER_OPTIMIZATION_LEVEL1 0
+CONSTANT: D3D10_SHADER_OPTIMIZATION_LEVEL2 49152
+CONSTANT: D3D10_SHADER_OPTIMIZATION_LEVEL3 32768
+
+STRUCT: D3D10_SHADER_MACRO
+    { Name       LPCSTR }
+    { Definition LPCSTR } ;
+TYPEDEF: D3D10_SHADER_MACRO* LPD3D10_SHADER_MACRO
+
+CONSTANT: D3D10_SVC_SCALAR            0
+CONSTANT: D3D10_SVC_VECTOR            1
+CONSTANT: D3D10_SVC_MATRIX_ROWS       2
+CONSTANT: D3D10_SVC_MATRIX_COLUMNS    3
+CONSTANT: D3D10_SVC_OBJECT            4
+CONSTANT: D3D10_SVC_STRUCT            5
+CONSTANT: D3D11_SVC_INTERFACE_CLASS   6
+CONSTANT: D3D11_SVC_INTERFACE_POINTER 7
+CONSTANT: D3D10_SVC_FORCE_DWORD       HEX: 7fffffff
+TYPEDEF: int D3D10_SHADER_VARIABLE_CLASS
+TYPEDEF: D3D10_SHADER_VARIABLE_CLASS* LPD3D10_SHADER_VARIABLE_CLASS
+
+CONSTANT: D3D10_SVF_USERPACKED        1
+CONSTANT: D3D10_SVF_USED              2
+CONSTANT: D3D11_SVF_INTERFACE_POINTER 4
+CONSTANT: D3D10_SVF_FORCE_DWORD       HEX: 7fffffff
+TYPEDEF: int D3D10_SHADER_VARIABLE_FLAGS
+TYPEDEF: D3D10_SHADER_VARIABLE_FLAGS* LPD3D10_SHADER_VARIABLE_FLAGS
+
+CONSTANT: D3D10_SVT_VOID              0
+CONSTANT: D3D10_SVT_BOOL              1
+CONSTANT: D3D10_SVT_INT               2
+CONSTANT: D3D10_SVT_FLOAT             3
+CONSTANT: D3D10_SVT_STRING            4
+CONSTANT: D3D10_SVT_TEXTURE           5
+CONSTANT: D3D10_SVT_TEXTURE1D         6
+CONSTANT: D3D10_SVT_TEXTURE2D         7
+CONSTANT: D3D10_SVT_TEXTURE3D         8
+CONSTANT: D3D10_SVT_TEXTURECUBE       9
+CONSTANT: D3D10_SVT_SAMPLER           10
+CONSTANT: D3D10_SVT_PIXELSHADER       15
+CONSTANT: D3D10_SVT_VERTEXSHADER      16
+CONSTANT: D3D10_SVT_UINT              19
+CONSTANT: D3D10_SVT_UINT8             20
+CONSTANT: D3D10_SVT_GEOMETRYSHADER    21
+CONSTANT: D3D10_SVT_RASTERIZER        22
+CONSTANT: D3D10_SVT_DEPTHSTENCIL      23
+CONSTANT: D3D10_SVT_BLEND             24
+CONSTANT: D3D10_SVT_BUFFER            25
+CONSTANT: D3D10_SVT_CBUFFER           26
+CONSTANT: D3D10_SVT_TBUFFER           27
+CONSTANT: D3D10_SVT_TEXTURE1DARRAY    28
+CONSTANT: D3D10_SVT_TEXTURE2DARRAY    29
+CONSTANT: D3D10_SVT_RENDERTARGETVIEW  30
+CONSTANT: D3D10_SVT_DEPTHSTENCILVIEW  31
+CONSTANT: D3D10_SVT_TEXTURE2DMS       32
+CONSTANT: D3D10_SVT_TEXTURE2DMSARRAY  33
+CONSTANT: D3D10_SVT_TEXTURECUBEARRAY  34
+CONSTANT: D3D11_SVT_HULLSHADER        35
+CONSTANT: D3D11_SVT_DOMAINSHADER      36
+CONSTANT: D3D11_SVT_INTERFACE_POINTER 37
+CONSTANT: D3D11_SVT_COMPUTESHADER     38
+CONSTANT: D3D11_SVT_DOUBLE            39
+CONSTANT: D3D10_SVT_FORCE_DWORD       HEX: 7ffffff
+TYPEDEF: int D3D10_SHADER_VARIABLE_TYPE
+TYPEDEF: D3D10_SHADER_VARIABLE_TYPE* LPD3D10_SHADER_VARIABLE_TYPE
+
+CONSTANT: D3D10_SIF_USERPACKED          1
+CONSTANT: D3D10_SIF_COMPARISON_SAMPLER  2
+CONSTANT: D3D10_SIF_TEXTURE_COMPONENT_0 4
+CONSTANT: D3D10_SIF_TEXTURE_COMPONENT_1 8
+CONSTANT: D3D10_SIF_TEXTURE_COMPONENTS  12
+CONSTANT: D3D10_SIF_FORCE_DWORD         HEX: 7ffffff
+TYPEDEF: int D3D10_SHADER_INPUT_FLAGS
+TYPEDEF: D3D10_SHADER_INPUT_FLAGS* LPD3D10_SHADER_INPUT_FLAGS
+
+CONSTANT: D3D10_SIT_CBUFFER                       0
+CONSTANT: D3D10_SIT_TBUFFER                       1
+CONSTANT: D3D10_SIT_TEXTURE                       2
+CONSTANT: D3D10_SIT_SAMPLER                       3
+CONSTANT: D3D11_SIT_UAV_RWTYPED                   4
+CONSTANT: D3D11_SIT_STRUCTURED                    5
+CONSTANT: D3D11_SIT_UAV_RWSTRUCTURED              6
+CONSTANT: D3D11_SIT_BYTEADDRESS                   7
+CONSTANT: D3D11_SIT_UAV_RWBYTEADDRESS             8
+CONSTANT: D3D11_SIT_UAV_APPEND_STRUCTURED         9
+CONSTANT: D3D11_SIT_UAV_CONSUME_STRUCTURED        10
+CONSTANT: D3D11_SIT_UAV_RWSTRUCTURED_WITH_COUNTER 11
+TYPEDEF: int D3D10_SHADER_INPUT_TYPE
+TYPEDEF: D3D10_SHADER_INPUT_TYPE* LPD3D10_SHADER_INPUT_TYPE
+
+CONSTANT: D3D10_CBF_USERPACKED  1
+CONSTANT: D3D10_CBF_FORCE_DWORD HEX: 7fffffff
+TYPEDEF: int D3D10_SHADER_CBUFFER_FLAGS
+TYPEDEF: D3D10_SHADER_CBUFFER_FLAGS* LPD3D10_SHADER_CBUFFER_FLAGS
+
+CONSTANT: D3D10_CT_CBUFFER 0
+CONSTANT: D3D10_CT_TBUFFER 1
+TYPEDEF: int D3D10_CBUFFER_TYPE
+TYPEDEF: D3D10_CBUFFER_TYPE* LPD3D10_CBUFFER_TYPE
+
+CONSTANT: D3D10_NAME_UNDEFINED                     0
+CONSTANT: D3D10_NAME_POSITION                      1
+CONSTANT: D3D10_NAME_CLIP_DISTANCE                 2
+CONSTANT: D3D10_NAME_CULL_DISTANCE                 3
+CONSTANT: D3D10_NAME_RENDER_TARGET_ARRAY_INDEX     4
+CONSTANT: D3D10_NAME_VIEWPORT_ARRAY_INDEX          5
+CONSTANT: D3D10_NAME_VERTEX_ID                     6
+CONSTANT: D3D10_NAME_PRIMITIVE_ID                  7
+CONSTANT: D3D10_NAME_INSTANCE_ID                   8
+CONSTANT: D3D10_NAME_IS_FRONT_FACE                 9
+CONSTANT: D3D10_NAME_SAMPLE_INDEX                  10
+CONSTANT: D3D11_NAME_FINAL_QUAD_EDGE_TESSFACTOR    11
+CONSTANT: D3D11_NAME_FINAL_QUAD_INSIDE_TESSFACTOR  12
+CONSTANT: D3D11_NAME_FINAL_TRI_EDGE_TESSFACTOR     13
+CONSTANT: D3D11_NAME_FINAL_TRI_INSIDE_TESSFACTOR   14
+CONSTANT: D3D11_NAME_FINAL_LINE_DETAIL_TESSFACTOR  15
+CONSTANT: D3D11_NAME_FINAL_LINE_DENSITY_TESSFACTOR 16
+CONSTANT: D3D10_NAME_TARGET                        64
+CONSTANT: D3D10_NAME_DEPTH                         65
+CONSTANT: D3D10_NAME_COVERAGE                      66
+CONSTANT: D3D11_NAME_DEPTH_GREATER_EQUAL           67
+CONSTANT: D3D11_NAME_DEPTH_LESS_EQUAL              68
+TYPEDEF: int D3D10_NAME
+
+CONSTANT: D3D10_RETURN_TYPE_UNORM 1
+CONSTANT: D3D10_RETURN_TYPE_SNORM 2
+CONSTANT: D3D10_RETURN_TYPE_SINT  3
+CONSTANT: D3D10_RETURN_TYPE_UINT  4
+CONSTANT: D3D10_RETURN_TYPE_FLOAT 5
+CONSTANT: D3D10_RETURN_TYPE_MIXED 6
+TYPEDEF: int D3D10_RESOURCE_RETURN_TYPE
+
+CONSTANT: D3D10_REGISTER_COMPONENT_UNKNOWN 0
+CONSTANT: D3D10_REGISTER_COMPONENT_UINT32  1
+CONSTANT: D3D10_REGISTER_COMPONENT_SINT32  2
+CONSTANT: D3D10_REGISTER_COMPONENT_FLOAT32 3
+TYPEDEF: int D3D10_REGISTER_COMPONENT_TYPE
+
+CONSTANT: D3D10_INCLUDE_LOCAL       0
+CONSTANT: D3D10_INCLUDE_SYSTEM      1
+CONSTANT: D3D10_INCLUDE_FORCE_DWORD HEX: 7fffffff
+TYPEDEF: int D3D10_INCLUDE_TYPE
+TYPEDEF: D3D10_INCLUDE_TYPE* LPD3D10_INCLUDE_TYPE
+
+COM-INTERFACE: ID3D10Include f {C530AD7D-9B16-4395-A979-BA2ECFF83ADD}
+    HRESULT Open ( D3D10_INCLUDE_TYPE IncludeType, LPCSTR pFileName, LPCVOID pParentData, LPCVOID* ppData, UINT* pBytes )
+    HRESULT Close ( LPCVOID pData ) ;
+TYPEDEF: ID3D10Include* LPD3D10INCLUDE
+
+STRUCT: D3D10_SHADER_DESC
+    { Version                     UINT                     }
+    { Creator                     LPCSTR                   }
+    { Flags                       UINT                     }
+    { ConstantBuffers             UINT                     }
+    { BoundResources              UINT                     }
+    { InputParameters             UINT                     }
+    { OutputParameters            UINT                     }
+    { InstructionCount            UINT                     }
+    { TempRegisterCount           UINT                     }
+    { TempArrayCount              UINT                     }
+    { DefCount                    UINT                     }
+    { DclCount                    UINT                     }
+    { TextureNormalInstructions   UINT                     }
+    { TextureLoadInstructions     UINT                     }
+    { TextureCompInstructions     UINT                     }
+    { TextureBiasInstructions     UINT                     }
+    { TextureGradientInstructions UINT                     }
+    { FloatInstructionCount       UINT                     }
+    { IntInstructionCount         UINT                     }
+    { UintInstructionCount        UINT                     }
+    { StaticFlowControlCount      UINT                     }
+    { DynamicFlowControlCount     UINT                     }
+    { MacroInstructionCount       UINT                     }
+    { ArrayInstructionCount       UINT                     }
+    { CutInstructionCount         UINT                     }
+    { EmitInstructionCount        UINT                     }
+    { GSOutputTopology            D3D10_PRIMITIVE_TOPOLOGY }
+    { GSMaxOutputVertexCount      UINT                     } ;
+
+STRUCT: D3D10_SHADER_BUFFER_DESC
+    { Name      LPCSTR             }
+    { Type      D3D10_CBUFFER_TYPE }
+    { Variables UINT               }
+    { Size      UINT               }
+    { uFlags    UINT               } ;
+
+STRUCT: D3D10_SHADER_VARIABLE_DESC
+    { Name         LPCSTR }
+    { StartOffset  UINT   }
+    { Size         UINT   }
+    { uFlags       UINT   }
+    { DefaultValue LPVOID } ;
+
+STRUCT: D3D10_SHADER_TYPE_DESC
+    { Class    D3D10_SHADER_VARIABLE_CLASS }
+    { Type     D3D10_SHADER_VARIABLE_TYPE  }
+    { Rows     UINT                        }
+    { Columns  UINT                        }
+    { Elements UINT                        }
+    { Members  UINT                        }
+    { Offset   UINT                        } ;
+
+STRUCT: D3D10_SHADER_INPUT_BIND_DESC
+    { Name       LPCSTR                     }
+    { Type       D3D10_SHADER_INPUT_TYPE    }
+    { BindPoint  UINT                       }
+    { BindCount  UINT                       }
+    { uFlags     UINT                       }
+    { ReturnType D3D10_RESOURCE_RETURN_TYPE }
+    { Dimension  D3D10_SRV_DIMENSION        }
+    { NumSamples UINT                       } ;
+
+STRUCT: D3D10_SIGNATURE_PARAMETER_DESC
+    { SemanticName    LPCSTR                        }
+    { SemanticIndex   UINT                          }
+    { Register        UINT                          }
+    { SystemValueType D3D10_NAME                    }
+    { ComponentType   D3D10_REGISTER_COMPONENT_TYPE }
+    { Mask            BYTE                          }
+    { ReadWriteMask   BYTE                          } ;
+
+COM-INTERFACE: ID3D10ShaderReflectionType f {C530AD7D-9B16-4395-A979-BA2ECFF83ADD}
+    HRESULT GetDesc ( D3D10_SHADER_TYPE_DESC* pDesc )
+    ID3D10ShaderReflectionType* GetMemberTypeByIndex ( UINT Index )
+    ID3D10ShaderReflectionType* GetMemberTypeByName ( LPCSTR Name )
+    LPCSTR GetMemberTypeName ( UINT Index ) ;
+
+COM-INTERFACE: ID3D10ShaderReflectionVariable f {1BF63C95-2650-405d-99C1-3636BD1DA0A1}
+    HRESULT GetDesc ( D3D10_SHADER_VARIABLE_DESC* pDesc )
+    ID3D10ShaderReflectionType* GetType ( ) ;
+
+COM-INTERFACE: ID3D10ShaderReflectionConstantBuffer f {66C66A94-DDDD-4b62-A66A-F0DA33C2B4D0}
+    HRESULT GetDesc ( D3D10_SHADER_BUFFER_DESC* pDesc )
+    ID3D10ShaderReflectionVariable* GetVariableByIndex ( UINT Index )
+    ID3D10ShaderReflectionVariable* GetVariableByName ( LPCSTR Name ) ;
+
+COM-INTERFACE: ID3D10ShaderReflection IUnknown {D40E20B6-F8F7-42ad-AB20-4BAF8F15DFAA}
+    HRESULT GetDesc ( D3D10_SHADER_DESC* pDesc )
+    ID3D10ShaderReflectionConstantBuffer* GetConstantBufferByIndex ( UINT Index )
+    ID3D10ShaderReflectionConstantBuffer* GetConstantBufferByName ( LPCSTR Name )
+    HRESULT GetResourceBindingDesc ( UINT ResourceIndex, D3D10_SHADER_INPUT_BIND_DESC* pDesc )
+    HRESULT GetInputParameterDesc ( UINT ParameterIndex, D3D10_SIGNATURE_PARAMETER_DESC* pDesc )
+    HRESULT GetOutputParameterDesc ( UINT ParameterIndex, D3D10_SIGNATURE_PARAMETER_DESC* pDesc ) ;
+
+FUNCTION: HRESULT D3D10CompileShader ( LPCSTR pSrcData, SIZE_T SrcDataLen, LPCSTR pFileName, D3D10_SHADER_MACRO* pDefines, ID3D10Include* pInclude, LPCSTR pFunctionName, LPCSTR pProfile, UINT Flags, ID3D10Blob** ppShader, ID3D10Blob** ppErrorMsgs ) ;
+FUNCTION: HRESULT D3D10DisassembleShader ( void* pShader, SIZE_T BytecodeLength, BOOL EnableColorCode, LPCSTR pComments, ID3D10Blob** ppDisassembly ) ;
+FUNCTION: LPCSTR D3D10GetPixelShaderProfile ( ID3D10Device* pDevice ) ;
+FUNCTION: LPCSTR D3D10GetVertexShaderProfile ( ID3D10Device* pDevice ) ;
+FUNCTION: LPCSTR D3D10GetGeometryShaderProfile ( ID3D10Device* pDevice ) ;
+FUNCTION: HRESULT D3D10ReflectShader ( void* pShaderBytecode, SIZE_T BytecodeLength, ID3D10ShaderReflection** ppReflector ) ;
+FUNCTION: HRESULT D3D10PreprocessShader ( LPCSTR pSrcData, SIZE_T SrcDataSize, LPCSTR pFileName, D3D10_SHADER_MACRO* pDefines, ID3D10Include* pInclude, ID3D10Blob** ppShaderText, ID3D10Blob** ppErrorMsgs ) ;
+FUNCTION: HRESULT D3D10GetInputSignatureBlob ( void* pShaderBytecode, SIZE_T BytecodeLength, ID3D10Blob** ppSignatureBlob ) ;
+FUNCTION: HRESULT D3D10GetOutputSignatureBlob ( void* pShaderBytecode, SIZE_T BytecodeLength, ID3D10Blob** ppSignatureBlob ) ;
+FUNCTION: HRESULT D3D10GetInputAndOutputSignatureBlob ( void* pShaderBytecode, SIZE_T BytecodeLength, ID3D10Blob** ppSignatureBlob ) ;
+FUNCTION: HRESULT D3D10GetShaderDebugInfo ( void* pShaderBytecode, SIZE_T BytecodeLength, ID3D10Blob** ppDebugInfo ) ;
diff --git a/basis/windows/directx/d3d10shader/summary.txt b/basis/windows/directx/d3d10shader/summary.txt
new file mode 100644 (file)
index 0000000..a38ed60
--- /dev/null
@@ -0,0 +1 @@
+Direct3D 10 bindings. Corresponds to D3D10shader.h.
diff --git a/basis/windows/directx/d3d10shader/tags.txt b/basis/windows/directx/d3d10shader/tags.txt
new file mode 100644 (file)
index 0000000..2320bdd
--- /dev/null
@@ -0,0 +1,2 @@
+unportable
+bindings
diff --git a/basis/windows/directx/d3d11/authors.txt b/basis/windows/directx/d3d11/authors.txt
new file mode 100644 (file)
index 0000000..6f03a12
--- /dev/null
@@ -0,0 +1 @@
+Erik Charlebois
diff --git a/basis/windows/directx/d3d11/d3d11.factor b/basis/windows/directx/d3d11/d3d11.factor
new file mode 100644 (file)
index 0000000..505ac4b
--- /dev/null
@@ -0,0 +1,1488 @@
+USING: alien.syntax alien.c-types classes.struct windows.types
+windows.directx.dxgiformat windows.com.syntax windows.com windows.ole32
+windows.directx.dxgitype windows.directx.dxgi windows.directx.d3dcommon ;
+IN: windows.directx.d3d11
+
+LIBRARY: d3d11
+
+CONSTANT: D3D11_16BIT_INDEX_STRIP_CUT_VALUE   HEX: ffff
+CONSTANT: D3D11_32BIT_INDEX_STRIP_CUT_VALUE   HEX: ffffffff
+CONSTANT: D3D11_8BIT_INDEX_STRIP_CUT_VALUE    HEX: ff
+
+CONSTANT: D3D11_ARRAY_AXIS_ADDRESS_RANGE_BIT_COUNT 9
+
+CONSTANT: D3D11_CLIP_OR_CULL_DISTANCE_COUNT           8
+CONSTANT: D3D11_CLIP_OR_CULL_DISTANCE_ELEMENT_COUNT   2
+
+CONSTANT: D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT                    14
+CONSTANT: D3D11_COMMONSHADER_CONSTANT_BUFFER_COMPONENTS                        4
+CONSTANT: D3D11_COMMONSHADER_CONSTANT_BUFFER_COMPONENT_BIT_COUNT               32
+CONSTANT: D3D11_COMMONSHADER_CONSTANT_BUFFER_HW_SLOT_COUNT                     15
+CONSTANT: D3D11_COMMONSHADER_CONSTANT_BUFFER_REGISTER_COMPONENTS               4
+CONSTANT: D3D11_COMMONSHADER_CONSTANT_BUFFER_REGISTER_COUNT                    15
+CONSTANT: D3D11_COMMONSHADER_CONSTANT_BUFFER_REGISTER_READS_PER_INST           1
+CONSTANT: D3D11_COMMONSHADER_CONSTANT_BUFFER_REGISTER_READ_PORTS               1
+CONSTANT: D3D11_COMMONSHADER_FLOWCONTROL_NESTING_LIMIT                         64
+CONSTANT: D3D11_COMMONSHADER_IMMEDIATE_CONSTANT_BUFFER_REGISTER_COMPONENTS     4
+CONSTANT: D3D11_COMMONSHADER_IMMEDIATE_CONSTANT_BUFFER_REGISTER_COUNT          1
+CONSTANT: D3D11_COMMONSHADER_IMMEDIATE_CONSTANT_BUFFER_REGISTER_READS_PER_INST 1
+CONSTANT: D3D11_COMMONSHADER_IMMEDIATE_CONSTANT_BUFFER_REGISTER_READ_PORTS     1
+CONSTANT: D3D11_COMMONSHADER_IMMEDIATE_VALUE_COMPONENT_BIT_COUNT               32
+CONSTANT: D3D11_COMMONSHADER_INPUT_RESOURCE_REGISTER_COMPONENTS                1
+CONSTANT: D3D11_COMMONSHADER_INPUT_RESOURCE_REGISTER_COUNT                     128
+CONSTANT: D3D11_COMMONSHADER_INPUT_RESOURCE_REGISTER_READS_PER_INST            1
+CONSTANT: D3D11_COMMONSHADER_INPUT_RESOURCE_REGISTER_READ_PORTS                1
+CONSTANT: D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT                         128
+CONSTANT: D3D11_COMMONSHADER_SAMPLER_REGISTER_COMPONENTS                       1
+CONSTANT: D3D11_COMMONSHADER_SAMPLER_REGISTER_COUNT                            16
+CONSTANT: D3D11_COMMONSHADER_SAMPLER_REGISTER_READS_PER_INST                   1
+CONSTANT: D3D11_COMMONSHADER_SAMPLER_REGISTER_READ_PORTS                       1
+CONSTANT: D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT                                16
+CONSTANT: D3D11_COMMONSHADER_SUBROUTINE_NESTING_LIMIT                          32
+CONSTANT: D3D11_COMMONSHADER_TEMP_REGISTER_COMPONENTS                          4
+CONSTANT: D3D11_COMMONSHADER_TEMP_REGISTER_COMPONENT_BIT_COUNT                 32
+CONSTANT: D3D11_COMMONSHADER_TEMP_REGISTER_COUNT                               4096
+CONSTANT: D3D11_COMMONSHADER_TEMP_REGISTER_READS_PER_INST                      3
+CONSTANT: D3D11_COMMONSHADER_TEMP_REGISTER_READ_PORTS                          3
+CONSTANT: D3D11_COMMONSHADER_TEXCOORD_RANGE_REDUCTION_MAX                      10
+CONSTANT: D3D11_COMMONSHADER_TEXCOORD_RANGE_REDUCTION_MIN                      -10
+CONSTANT: D3D11_COMMONSHADER_TEXEL_OFFSET_MAX_NEGATIVE                         -8
+CONSTANT: D3D11_COMMONSHADER_TEXEL_OFFSET_MAX_POSITIVE                         7
+
+CONSTANT: D3D11_CS_4_X_BUCKET00_MAX_BYTES_TGSM_WRITABLE_PER_THREAD    256
+CONSTANT: D3D11_CS_4_X_BUCKET00_MAX_NUM_THREADS_PER_GROUP             64
+CONSTANT: D3D11_CS_4_X_BUCKET01_MAX_BYTES_TGSM_WRITABLE_PER_THREAD    240
+CONSTANT: D3D11_CS_4_X_BUCKET01_MAX_NUM_THREADS_PER_GROUP             68
+CONSTANT: D3D11_CS_4_X_BUCKET02_MAX_BYTES_TGSM_WRITABLE_PER_THREAD    224
+CONSTANT: D3D11_CS_4_X_BUCKET02_MAX_NUM_THREADS_PER_GROUP             72
+CONSTANT: D3D11_CS_4_X_BUCKET03_MAX_BYTES_TGSM_WRITABLE_PER_THREAD    208
+CONSTANT: D3D11_CS_4_X_BUCKET03_MAX_NUM_THREADS_PER_GROUP             76
+CONSTANT: D3D11_CS_4_X_BUCKET04_MAX_BYTES_TGSM_WRITABLE_PER_THREAD    192
+CONSTANT: D3D11_CS_4_X_BUCKET04_MAX_NUM_THREADS_PER_GROUP             84
+CONSTANT: D3D11_CS_4_X_BUCKET05_MAX_BYTES_TGSM_WRITABLE_PER_THREAD    176
+CONSTANT: D3D11_CS_4_X_BUCKET05_MAX_NUM_THREADS_PER_GROUP             92
+CONSTANT: D3D11_CS_4_X_BUCKET06_MAX_BYTES_TGSM_WRITABLE_PER_THREAD    160
+CONSTANT: D3D11_CS_4_X_BUCKET06_MAX_NUM_THREADS_PER_GROUP             100
+CONSTANT: D3D11_CS_4_X_BUCKET07_MAX_BYTES_TGSM_WRITABLE_PER_THREAD    144
+CONSTANT: D3D11_CS_4_X_BUCKET07_MAX_NUM_THREADS_PER_GROUP             112
+CONSTANT: D3D11_CS_4_X_BUCKET08_MAX_BYTES_TGSM_WRITABLE_PER_THREAD    128
+CONSTANT: D3D11_CS_4_X_BUCKET08_MAX_NUM_THREADS_PER_GROUP             128
+CONSTANT: D3D11_CS_4_X_BUCKET09_MAX_BYTES_TGSM_WRITABLE_PER_THREAD    112
+CONSTANT: D3D11_CS_4_X_BUCKET09_MAX_NUM_THREADS_PER_GROUP             144
+CONSTANT: D3D11_CS_4_X_BUCKET10_MAX_BYTES_TGSM_WRITABLE_PER_THREAD    96
+CONSTANT: D3D11_CS_4_X_BUCKET10_MAX_NUM_THREADS_PER_GROUP             168
+CONSTANT: D3D11_CS_4_X_BUCKET11_MAX_BYTES_TGSM_WRITABLE_PER_THREAD    80
+CONSTANT: D3D11_CS_4_X_BUCKET11_MAX_NUM_THREADS_PER_GROUP             204
+CONSTANT: D3D11_CS_4_X_BUCKET12_MAX_BYTES_TGSM_WRITABLE_PER_THREAD    64
+CONSTANT: D3D11_CS_4_X_BUCKET12_MAX_NUM_THREADS_PER_GROUP             256
+CONSTANT: D3D11_CS_4_X_BUCKET13_MAX_BYTES_TGSM_WRITABLE_PER_THREAD    48
+CONSTANT: D3D11_CS_4_X_BUCKET13_MAX_NUM_THREADS_PER_GROUP             340
+CONSTANT: D3D11_CS_4_X_BUCKET14_MAX_BYTES_TGSM_WRITABLE_PER_THREAD    32
+CONSTANT: D3D11_CS_4_X_BUCKET14_MAX_NUM_THREADS_PER_GROUP             512
+CONSTANT: D3D11_CS_4_X_BUCKET15_MAX_BYTES_TGSM_WRITABLE_PER_THREAD    16
+CONSTANT: D3D11_CS_4_X_BUCKET15_MAX_NUM_THREADS_PER_GROUP             768
+CONSTANT: D3D11_CS_4_X_DISPATCH_MAX_THREAD_GROUPS_IN_Z_DIMENSION      1
+CONSTANT: D3D11_CS_4_X_RAW_UAV_BYTE_ALIGNMENT                         256
+CONSTANT: D3D11_CS_4_X_THREAD_GROUP_MAX_THREADS_PER_GROUP             768
+CONSTANT: D3D11_CS_4_X_THREAD_GROUP_MAX_X                             768
+CONSTANT: D3D11_CS_4_X_THREAD_GROUP_MAX_Y                             768
+CONSTANT: D3D11_CS_4_X_UAV_REGISTER_COUNT                             1
+CONSTANT: D3D11_CS_DISPATCH_MAX_THREAD_GROUPS_PER_DIMENSION           65535
+CONSTANT: D3D11_CS_TGSM_REGISTER_COUNT                                8192
+CONSTANT: D3D11_CS_TGSM_REGISTER_READS_PER_INST                       1
+CONSTANT: D3D11_CS_TGSM_RESOURCE_REGISTER_COMPONENTS                  1
+CONSTANT: D3D11_CS_TGSM_RESOURCE_REGISTER_READ_PORTS                  1
+CONSTANT: D3D11_CS_THREAD_GROUP_MAX_THREADS_PER_GROUP                 1024
+CONSTANT: D3D11_CS_THREAD_GROUP_MAX_X                                 1024
+CONSTANT: D3D11_CS_THREAD_GROUP_MAX_Y                                 1024
+CONSTANT: D3D11_CS_THREAD_GROUP_MAX_Z                                 64
+CONSTANT: D3D11_CS_THREAD_GROUP_MIN_X                                 1
+CONSTANT: D3D11_CS_THREAD_GROUP_MIN_Y                                 1
+CONSTANT: D3D11_CS_THREAD_GROUP_MIN_Z                                 1
+CONSTANT: D3D11_CS_THREAD_LOCAL_TEMP_REGISTER_POOL                    16384
+
+CONSTANT: D3D11_DEFAULT_BLEND_FACTOR_ALPHA                1.0
+CONSTANT: D3D11_DEFAULT_BLEND_FACTOR_GREEN                1.0
+CONSTANT: D3D11_DEFAULT_BORDER_COLOR_COMPONENT            0.0
+CONSTANT: D3D11_DEFAULT_DEPTH_BIAS_CLAMP                  0.0
+CONSTANT: D3D11_DEFAULT_MAX_ANISOTROPY                    16
+CONSTANT: D3D11_DEFAULT_MIP_LOD_BIAS                      0.0
+CONSTANT: D3D11_DEFAULT_RENDER_TARGET_ARRAY_INDEX         0
+CONSTANT: D3D11_DEFAULT_SAMPLE_MASK                       HEX: ffffffff
+CONSTANT: D3D11_DEFAULT_SCISSOR_ENDX                      0
+CONSTANT: D3D11_DEFAULT_SCISSOR_ENDY                      0
+CONSTANT: D3D11_DEFAULT_SCISSOR_STARTX                    0
+CONSTANT: D3D11_DEFAULT_SCISSOR_STARTY                    0
+CONSTANT: D3D11_DEFAULT_SLOPE_SCALED_DEPTH_BIAS           0.0
+CONSTANT: D3D11_DEFAULT_STENCIL_READ_MASK                 HEX: ff
+CONSTANT: D3D11_DEFAULT_STENCIL_REFERENCE                 0
+CONSTANT: D3D11_DEFAULT_STENCIL_WRITE_MASK                HEX: ff
+CONSTANT: D3D11_DEFAULT_VIEWPORT_AND_SCISSORRECT_INDEX    0
+CONSTANT: D3D11_DEFAULT_VIEWPORT_HEIGHT                   0
+CONSTANT: D3D11_DEFAULT_VIEWPORT_MAX_DEPTH                0.0
+CONSTANT: D3D11_DEFAULT_VIEWPORT_MIN_DEPTH                0.0
+CONSTANT: D3D11_DEFAULT_VIEWPORT_TOPLEFTX                 0
+CONSTANT: D3D11_DEFAULT_VIEWPORT_TOPLEFTY                 0
+CONSTANT: D3D11_DEFAULT_VIEWPORT_WIDTH                    0
+
+CONSTANT: D3D11_DS_INPUT_CONTROL_POINTS_MAX_TOTAL_SCALARS             3968
+CONSTANT: D3D11_DS_INPUT_CONTROL_POINT_REGISTER_COMPONENTS            4
+CONSTANT: D3D11_DS_INPUT_CONTROL_POINT_REGISTER_COMPONENT_BIT_COUNT   32
+CONSTANT: D3D11_DS_INPUT_CONTROL_POINT_REGISTER_COUNT                 32
+CONSTANT: D3D11_DS_INPUT_CONTROL_POINT_REGISTER_READS_PER_INST        2
+CONSTANT: D3D11_DS_INPUT_CONTROL_POINT_REGISTER_READ_PORTS            1
+CONSTANT: D3D11_DS_INPUT_DOMAIN_POINT_REGISTER_COMPONENTS             3
+CONSTANT: D3D11_DS_INPUT_DOMAIN_POINT_REGISTER_COMPONENT_BIT_COUNT    32
+CONSTANT: D3D11_DS_INPUT_DOMAIN_POINT_REGISTER_COUNT                  1
+CONSTANT: D3D11_DS_INPUT_DOMAIN_POINT_REGISTER_READS_PER_INST         2
+CONSTANT: D3D11_DS_INPUT_DOMAIN_POINT_REGISTER_READ_PORTS             1
+CONSTANT: D3D11_DS_INPUT_PATCH_CONSTANT_REGISTER_COMPONENTS           4
+CONSTANT: D3D11_DS_INPUT_PATCH_CONSTANT_REGISTER_COMPONENT_BIT_COUNT  32
+CONSTANT: D3D11_DS_INPUT_PATCH_CONSTANT_REGISTER_COUNT                32
+CONSTANT: D3D11_DS_INPUT_PATCH_CONSTANT_REGISTER_READS_PER_INST       2
+CONSTANT: D3D11_DS_INPUT_PATCH_CONSTANT_REGISTER_READ_PORTS           1
+CONSTANT: D3D11_DS_OUTPUT_REGISTER_COMPONENTS                         4
+CONSTANT: D3D11_DS_OUTPUT_REGISTER_COMPONENT_BIT_COUNT                32
+CONSTANT: D3D11_DS_OUTPUT_REGISTER_COUNT                              32
+
+CONSTANT: D3D11_FLOAT16_FUSED_TOLERANCE_IN_ULP        0.6
+CONSTANT: D3D11_FLOAT32_MAX                           3.402823466e+38
+CONSTANT: D3D11_FLOAT32_TO_INTEGER_TOLERANCE_IN_ULP   0.6
+CONSTANT: D3D11_FLOAT_TO_SRGB_EXPONENT_DENOMINATOR    2.4
+CONSTANT: D3D11_FLOAT_TO_SRGB_EXPONENT_NUMERATOR      1.0
+CONSTANT: D3D11_FLOAT_TO_SRGB_OFFSET                  0.055
+CONSTANT: D3D11_FLOAT_TO_SRGB_SCALE_1                 12.92
+CONSTANT: D3D11_FLOAT_TO_SRGB_SCALE_2                 1.055
+CONSTANT: D3D11_FLOAT_TO_SRGB_THRESHOLD               0.0031308
+
+CONSTANT: D3D11_FTOI_INSTRUCTION_MAX_INPUT    2147483647.999
+CONSTANT: D3D11_FTOI_INSTRUCTION_MIN_INPUT    -2147483648.999
+CONSTANT: D3D11_FTOU_INSTRUCTION_MAX_INPUT    4294967295.999
+CONSTANT: D3D11_FTOU_INSTRUCTION_MIN_INPUT    0.0
+
+CONSTANT: D3D11_GS_INPUT_INSTANCE_ID_READS_PER_INST               2
+CONSTANT: D3D11_GS_INPUT_INSTANCE_ID_READ_PORTS                   1
+CONSTANT: D3D11_GS_INPUT_INSTANCE_ID_REGISTER_COMPONENTS          1
+CONSTANT: D3D11_GS_INPUT_INSTANCE_ID_REGISTER_COMPONENT_BIT_COUNT 32
+CONSTANT: D3D11_GS_INPUT_INSTANCE_ID_REGISTER_COUNT               1
+CONSTANT: D3D11_GS_INPUT_PRIM_CONST_REGISTER_COMPONENTS           1
+CONSTANT: D3D11_GS_INPUT_PRIM_CONST_REGISTER_COMPONENT_BIT_COUNT  32
+CONSTANT: D3D11_GS_INPUT_PRIM_CONST_REGISTER_COUNT                1
+CONSTANT: D3D11_GS_INPUT_PRIM_CONST_REGISTER_READS_PER_INST       2
+CONSTANT: D3D11_GS_INPUT_PRIM_CONST_REGISTER_READ_PORTS           1
+CONSTANT: D3D11_GS_INPUT_REGISTER_COMPONENTS                      4
+CONSTANT: D3D11_GS_INPUT_REGISTER_COMPONENT_BIT_COUNT             32
+CONSTANT: D3D11_GS_INPUT_REGISTER_COUNT                           32
+CONSTANT: D3D11_GS_INPUT_REGISTER_READS_PER_INST                  2
+CONSTANT: D3D11_GS_INPUT_REGISTER_READ_PORTS                      1
+CONSTANT: D3D11_GS_INPUT_REGISTER_VERTICES                        32
+CONSTANT: D3D11_GS_MAX_INSTANCE_COUNT                             32
+CONSTANT: D3D11_GS_MAX_OUTPUT_VERTEX_COUNT_ACROSS_INSTANCES       1024
+CONSTANT: D3D11_GS_OUTPUT_ELEMENTS                                32
+CONSTANT: D3D11_GS_OUTPUT_REGISTER_COMPONENTS                     4
+CONSTANT: D3D11_GS_OUTPUT_REGISTER_COMPONENT_BIT_COUNT            32
+CONSTANT: D3D11_GS_OUTPUT_REGISTER_COUNT                          32
+
+CONSTANT: D3D11_HS_CONTROL_POINT_PHASE_INPUT_REGISTER_COUNT               32
+CONSTANT: D3D11_HS_CONTROL_POINT_PHASE_OUTPUT_REGISTER_COUNT              32
+CONSTANT: D3D11_HS_CONTROL_POINT_REGISTER_COMPONENTS                      4
+CONSTANT: D3D11_HS_CONTROL_POINT_REGISTER_COMPONENT_BIT_COUNT             32
+CONSTANT: D3D11_HS_CONTROL_POINT_REGISTER_READS_PER_INST                  2
+CONSTANT: D3D11_HS_CONTROL_POINT_REGISTER_READ_PORTS                      1
+CONSTANT: D3D11_HS_FORK_PHASE_INSTANCE_COUNT_UPPER_BOUND                  HEX: ffffffff
+CONSTANT: D3D11_HS_INPUT_FORK_INSTANCE_ID_REGISTER_COMPONENTS             1
+CONSTANT: D3D11_HS_INPUT_FORK_INSTANCE_ID_REGISTER_COMPONENT_BIT_COUNT    32
+CONSTANT: D3D11_HS_INPUT_FORK_INSTANCE_ID_REGISTER_COUNT                  1
+CONSTANT: D3D11_HS_INPUT_FORK_INSTANCE_ID_REGISTER_READS_PER_INST         2
+CONSTANT: D3D11_HS_INPUT_FORK_INSTANCE_ID_REGISTER_READ_PORTS             1
+CONSTANT: D3D11_HS_INPUT_JOIN_INSTANCE_ID_REGISTER_COMPONENTS             1
+CONSTANT: D3D11_HS_INPUT_JOIN_INSTANCE_ID_REGISTER_COMPONENT_BIT_COUNT    32
+CONSTANT: D3D11_HS_INPUT_JOIN_INSTANCE_ID_REGISTER_COUNT                  1
+CONSTANT: D3D11_HS_INPUT_JOIN_INSTANCE_ID_REGISTER_READS_PER_INST         2
+CONSTANT: D3D11_HS_INPUT_JOIN_INSTANCE_ID_REGISTER_READ_PORTS             1
+CONSTANT: D3D11_HS_INPUT_PRIMITIVE_ID_REGISTER_COMPONENTS                 1
+CONSTANT: D3D11_HS_INPUT_PRIMITIVE_ID_REGISTER_COMPONENT_BIT_COUNT        32
+CONSTANT: D3D11_HS_INPUT_PRIMITIVE_ID_REGISTER_COUNT                      1
+CONSTANT: D3D11_HS_INPUT_PRIMITIVE_ID_REGISTER_READS_PER_INST             2
+CONSTANT: D3D11_HS_INPUT_PRIMITIVE_ID_REGISTER_READ_PORTS                 1
+CONSTANT: D3D11_HS_JOIN_PHASE_INSTANCE_COUNT_UPPER_BOUND                  HEX: ffffffff
+CONSTANT: D3D11_HS_MAXTESSFACTOR_LOWER_BOUND                              1.0
+CONSTANT: D3D11_HS_MAXTESSFACTOR_UPPER_BOUND                              64.0
+CONSTANT: D3D11_HS_OUTPUT_CONTROL_POINTS_MAX_TOTAL_SCALARS                3968
+CONSTANT: D3D11_HS_OUTPUT_CONTROL_POINT_ID_REGISTER_COMPONENTS            1
+CONSTANT: D3D11_HS_OUTPUT_CONTROL_POINT_ID_REGISTER_COMPONENT_BIT_COUNT   32
+CONSTANT: D3D11_HS_OUTPUT_CONTROL_POINT_ID_REGISTER_COUNT                 1
+CONSTANT: D3D11_HS_OUTPUT_CONTROL_POINT_ID_REGISTER_READS_PER_INST        2
+CONSTANT: D3D11_HS_OUTPUT_CONTROL_POINT_ID_REGISTER_READ_PORTS            1
+CONSTANT: D3D11_HS_OUTPUT_PATCH_CONSTANT_REGISTER_COMPONENTS              4
+CONSTANT: D3D11_HS_OUTPUT_PATCH_CONSTANT_REGISTER_COMPONENT_BIT_COUNT     32
+CONSTANT: D3D11_HS_OUTPUT_PATCH_CONSTANT_REGISTER_COUNT                   32
+CONSTANT: D3D11_HS_OUTPUT_PATCH_CONSTANT_REGISTER_READS_PER_INST          2
+CONSTANT: D3D11_HS_OUTPUT_PATCH_CONSTANT_REGISTER_READ_PORTS              1
+
+CONSTANT: D3D11_IA_DEFAULT_INDEX_BUFFER_OFFSET_IN_BYTES       0
+CONSTANT: D3D11_IA_DEFAULT_PRIMITIVE_TOPOLOGY                 0
+CONSTANT: D3D11_IA_DEFAULT_VERTEX_BUFFER_OFFSET_IN_BYTES      0
+CONSTANT: D3D11_IA_INDEX_INPUT_RESOURCE_SLOT_COUNT            1
+CONSTANT: D3D11_IA_INSTANCE_ID_BIT_COUNT                      32
+CONSTANT: D3D11_IA_INTEGER_ARITHMETIC_BIT_COUNT               32
+CONSTANT: D3D11_IA_PATCH_MAX_CONTROL_POINT_COUNT              32
+CONSTANT: D3D11_IA_PRIMITIVE_ID_BIT_COUNT                     32
+CONSTANT: D3D11_IA_VERTEX_ID_BIT_COUNT                        32
+CONSTANT: D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT           32
+CONSTANT: D3D11_IA_VERTEX_INPUT_STRUCTURE_ELEMENTS_COMPONENTS 128
+CONSTANT: D3D11_IA_VERTEX_INPUT_STRUCTURE_ELEMENT_COUNT       32
+
+CONSTANT: D3D11_INTEGER_DIVIDE_BY_ZERO_QUOTIENT   HEX: ffffffff
+CONSTANT: D3D11_INTEGER_DIVIDE_BY_ZERO_REMAINDER  HEX: ffffffff
+
+CONSTANT: D3D11_KEEP_RENDER_TARGETS_AND_DEPTH_STENCIL HEX: ffffffff
+CONSTANT: D3D11_KEEP_UNORDERED_ACCESS_VIEWS           HEX: ffffffff
+
+CONSTANT: D3D11_LINEAR_GAMMA  1.0
+
+CONSTANT: D3D11_MAX_BORDER_COLOR_COMPONENT        1.0
+CONSTANT: D3D11_MAX_DEPTH                         1.0
+CONSTANT: D3D11_MAX_MAXANISOTROPY                 16
+CONSTANT: D3D11_MAX_MULTISAMPLE_SAMPLE_COUNT      32
+CONSTANT: D3D11_MAX_POSITION_VALUE                3.402823466e+34
+CONSTANT: D3D11_MAX_TEXTURE_DIMENSION_2_TO_EXP    17
+
+CONSTANT: D3D11_MAJOR_VERSION 11
+CONSTANT: D3D11_MINOR_VERSION 0
+
+CONSTANT: D3D11_MIN_BORDER_COLOR_COMPONENT    0.0
+CONSTANT: D3D11_MIN_DEPTH                     0.0
+CONSTANT: D3D11_MIN_MAXANISOTROPY             0
+
+CONSTANT: D3D11_MIP_LOD_BIAS_MAX                  15.99
+CONSTANT: D3D11_MIP_LOD_BIAS_MIN                  -16.0
+CONSTANT: D3D11_MIP_LOD_FRACTIONAL_BIT_COUNT      8
+CONSTANT: D3D11_MIP_LOD_RANGE_BIT_COUNT           8
+
+CONSTANT: D3D11_MULTISAMPLE_ANTIALIAS_LINE_WIDTH  1.4
+
+CONSTANT: D3D11_NONSAMPLE_FETCH_OUT_OF_RANGE_ACCESS_RESULT 0
+
+CONSTANT: D3D11_PIXEL_ADDRESS_RANGE_BIT_COUNT 15
+
+CONSTANT: D3D11_PRE_SCISSOR_PIXEL_ADDRESS_RANGE_BIT_COUNT 16
+
+CONSTANT: D3D11_PS_CS_UAV_REGISTER_COMPONENTS                 1
+CONSTANT: D3D11_PS_CS_UAV_REGISTER_COUNT                      8
+CONSTANT: D3D11_PS_CS_UAV_REGISTER_READS_PER_INST             1
+CONSTANT: D3D11_PS_CS_UAV_REGISTER_READ_PORTS                 1
+CONSTANT: D3D11_PS_FRONTFACING_DEFAULT_VALUE                  HEX: ffffffff
+CONSTANT: D3D11_PS_FRONTFACING_FALSE_VALUE                    0
+CONSTANT: D3D11_PS_FRONTFACING_TRUE_VALUE                     HEX: ffffffff
+CONSTANT: D3D11_PS_INPUT_REGISTER_COMPONENTS                  4
+CONSTANT: D3D11_PS_INPUT_REGISTER_COMPONENT_BIT_COUNT         32
+CONSTANT: D3D11_PS_INPUT_REGISTER_COUNT                       32
+CONSTANT: D3D11_PS_INPUT_REGISTER_READS_PER_INST              2
+CONSTANT: D3D11_PS_INPUT_REGISTER_READ_PORTS                  1
+CONSTANT: D3D11_PS_LEGACY_PIXEL_CENTER_FRACTIONAL_COMPONENT   0.0
+CONSTANT: D3D11_PS_OUTPUT_DEPTH_REGISTER_COMPONENTS           1
+CONSTANT: D3D11_PS_OUTPUT_DEPTH_REGISTER_COMPONENT_BIT_COUNT  32
+CONSTANT: D3D11_PS_OUTPUT_DEPTH_REGISTER_COUNT                1
+CONSTANT: D3D11_PS_OUTPUT_MASK_REGISTER_COMPONENTS            1
+CONSTANT: D3D11_PS_OUTPUT_MASK_REGISTER_COMPONENT_BIT_COUNT   32
+CONSTANT: D3D11_PS_OUTPUT_MASK_REGISTER_COUNT                 1
+CONSTANT: D3D11_PS_OUTPUT_REGISTER_COMPONENTS                 4
+CONSTANT: D3D11_PS_OUTPUT_REGISTER_COMPONENT_BIT_COUNT        32
+CONSTANT: D3D11_PS_OUTPUT_REGISTER_COUNT                      8
+CONSTANT: D3D11_PS_PIXEL_CENTER_FRACTIONAL_COMPONENT          0.5
+
+CONSTANT: D3D11_RAW_UAV_SRV_BYTE_ALIGNMENT 16
+
+CONSTANT: D3D11_REQ_BLEND_OBJECT_COUNT_PER_DEVICE                 4096
+CONSTANT: D3D11_REQ_BUFFER_RESOURCE_TEXEL_COUNT_2_TO_EXP          27
+CONSTANT: D3D11_REQ_CONSTANT_BUFFER_ELEMENT_COUNT                 4096
+CONSTANT: D3D11_REQ_DEPTH_STENCIL_OBJECT_COUNT_PER_DEVICE         4096
+CONSTANT: D3D11_REQ_DRAWINDEXED_INDEX_COUNT_2_TO_EXP              32
+CONSTANT: D3D11_REQ_DRAW_VERTEX_COUNT_2_TO_EXP                    32
+CONSTANT: D3D11_REQ_FILTERING_HW_ADDRESSABLE_RESOURCE_DIMENSION   16384
+CONSTANT: D3D11_REQ_GS_INVOCATION_32BIT_OUTPUT_COMPONENT_LIMIT    1024
+CONSTANT: D3D11_REQ_IMMEDIATE_CONSTANT_BUFFER_ELEMENT_COUNT       4096
+CONSTANT: D3D11_REQ_MAXANISOTROPY                                 16
+CONSTANT: D3D11_REQ_MIP_LEVELS                                    15
+CONSTANT: D3D11_REQ_MULTI_ELEMENT_STRUCTURE_SIZE_IN_BYTES         2048
+CONSTANT: D3D11_REQ_RASTERIZER_OBJECT_COUNT_PER_DEVICE            4096
+CONSTANT: D3D11_REQ_RENDER_TO_BUFFER_WINDOW_WIDTH                 16384
+CONSTANT: D3D11_REQ_RESOURCE_SIZE_IN_MEGABYTES_EXPRESSION_A_TERM  128
+CONSTANT: D3D11_REQ_RESOURCE_SIZE_IN_MEGABYTES_EXPRESSION_B_TERM  0.25
+CONSTANT: D3D11_REQ_RESOURCE_VIEW_COUNT_PER_DEVICE_2_TO_EXP       20
+CONSTANT: D3D11_REQ_SAMPLER_OBJECT_COUNT_PER_DEVICE               4096
+CONSTANT: D3D11_REQ_TEXTURE1D_ARRAY_AXIS_DIMENSION                2048
+CONSTANT: D3D11_REQ_TEXTURE1D_U_DIMENSION                         16384
+CONSTANT: D3D11_REQ_TEXTURE2D_ARRAY_AXIS_DIMENSION                2048
+CONSTANT: D3D11_REQ_TEXTURE2D_U_OR_V_DIMENSION                    16384
+CONSTANT: D3D11_REQ_TEXTURE3D_U_V_OR_W_DIMENSION                  2048
+CONSTANT: D3D11_REQ_TEXTURECUBE_DIMENSION                         16384
+
+CONSTANT: D3D11_RESINFO_INSTRUCTION_MISSING_COMPONENT_RETVAL 0
+
+CONSTANT: D3D11_SHADER_MAJOR_VERSION              5
+CONSTANT: D3D11_SHADER_MAX_INSTANCES              65535
+CONSTANT: D3D11_SHADER_MAX_INTERFACES             253
+CONSTANT: D3D11_SHADER_MAX_INTERFACE_CALL_SITES   4096
+CONSTANT: D3D11_SHADER_MAX_TYPES                  65535
+CONSTANT: D3D11_SHADER_MINOR_VERSION              0
+
+CONSTANT: D3D11_SHIFT_INSTRUCTION_PAD_VALUE               0
+CONSTANT: D3D11_SHIFT_INSTRUCTION_SHIFT_VALUE_BIT_COUNT   5
+
+CONSTANT: D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT 8
+
+CONSTANT: D3D11_SO_BUFFER_MAX_STRIDE_IN_BYTES         2048
+CONSTANT: D3D11_SO_BUFFER_MAX_WRITE_WINDOW_IN_BYTES   512
+CONSTANT: D3D11_SO_BUFFER_SLOT_COUNT                  4
+CONSTANT: D3D11_SO_DDI_REGISTER_INDEX_DENOTING_GAP    HEX: ffffffff
+CONSTANT: D3D11_SO_NO_RASTERIZED_STREAM               HEX: ffffffff
+CONSTANT: D3D11_SO_OUTPUT_COMPONENT_COUNT             128
+CONSTANT: D3D11_SO_STREAM_COUNT                       4
+
+CONSTANT: D3D11_SPEC_DATE_DAY     04
+CONSTANT: D3D11_SPEC_DATE_MONTH   06
+CONSTANT: D3D11_SPEC_DATE_YEAR    2009
+CONSTANT: D3D11_SPEC_VERSION      1.0
+
+CONSTANT: D3D11_SRGB_GAMMA                        2.2
+CONSTANT: D3D11_SRGB_TO_FLOAT_DENOMINATOR_1       12.92
+CONSTANT: D3D11_SRGB_TO_FLOAT_DENOMINATOR_2       1.055
+CONSTANT: D3D11_SRGB_TO_FLOAT_EXPONENT            2.4
+CONSTANT: D3D11_SRGB_TO_FLOAT_OFFSET              0.055
+CONSTANT: D3D11_SRGB_TO_FLOAT_THRESHOLD           0.04045
+CONSTANT: D3D11_SRGB_TO_FLOAT_TOLERANCE_IN_ULP    0.5
+
+CONSTANT: D3D11_STANDARD_COMPONENT_BIT_COUNT                      32
+CONSTANT: D3D11_STANDARD_COMPONENT_BIT_COUNT_DOUBLED              64
+CONSTANT: D3D11_STANDARD_MAXIMUM_ELEMENT_ALIGNMENT_BYTE_MULTIPLE  4
+CONSTANT: D3D11_STANDARD_PIXEL_COMPONENT_COUNT                    128
+CONSTANT: D3D11_STANDARD_PIXEL_ELEMENT_COUNT                      32
+CONSTANT: D3D11_STANDARD_VECTOR_SIZE                              4
+CONSTANT: D3D11_STANDARD_VERTEX_ELEMENT_COUNT                     32
+CONSTANT: D3D11_STANDARD_VERTEX_TOTAL_COMPONENT_COUNT             64
+
+CONSTANT: D3D11_SUBPIXEL_FRACTIONAL_BIT_COUNT 8
+CONSTANT: D3D11_SUBTEXEL_FRACTIONAL_BIT_COUNT 8
+
+CONSTANT: D3D11_TESSELLATOR_MAX_EVEN_TESSELLATION_FACTOR              64
+CONSTANT: D3D11_TESSELLATOR_MAX_ISOLINE_DENSITY_TESSELLATION_FACTOR   64
+CONSTANT: D3D11_TESSELLATOR_MAX_ODD_TESSELLATION_FACTOR               63
+CONSTANT: D3D11_TESSELLATOR_MAX_TESSELLATION_FACTOR                   64
+CONSTANT: D3D11_TESSELLATOR_MIN_EVEN_TESSELLATION_FACTOR              2
+CONSTANT: D3D11_TESSELLATOR_MIN_ISOLINE_DENSITY_TESSELLATION_FACTOR   1
+CONSTANT: D3D11_TESSELLATOR_MIN_ODD_TESSELLATION_FACTOR               1
+
+CONSTANT: D3D11_TEXEL_ADDRESS_RANGE_BIT_COUNT 16
+
+CONSTANT: D3D11_UNBOUND_MEMORY_ACCESS_RESULT 0
+
+CONSTANT: D3D11_VIEWPORT_AND_SCISSORRECT_MAX_INDEX                    15
+CONSTANT: D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE    16
+
+CONSTANT: D3D11_VIEWPORT_BOUNDS_MAX   32767
+CONSTANT: D3D11_VIEWPORT_BOUNDS_MIN   -32768
+
+CONSTANT: D3D11_VS_INPUT_REGISTER_COMPONENTS              4
+CONSTANT: D3D11_VS_INPUT_REGISTER_COMPONENT_BIT_COUNT     32
+CONSTANT: D3D11_VS_INPUT_REGISTER_COUNT                   32
+CONSTANT: D3D11_VS_INPUT_REGISTER_READS_PER_INST          2
+CONSTANT: D3D11_VS_INPUT_REGISTER_READ_PORTS              1
+CONSTANT: D3D11_VS_OUTPUT_REGISTER_COMPONENTS             4
+CONSTANT: D3D11_VS_OUTPUT_REGISTER_COMPONENT_BIT_COUNT    32
+CONSTANT: D3D11_VS_OUTPUT_REGISTER_COUNT                  32
+
+CONSTANT: D3D11_WHQL_CONTEXT_COUNT_FOR_RESOURCE_LIMIT 10
+CONSTANT: D3D11_WHQL_DRAWINDEXED_INDEX_COUNT_2_TO_EXP 25
+CONSTANT: D3D11_WHQL_DRAW_VERTEX_COUNT_2_TO_EXP       25
+
+CONSTANT: D3D11_ERROR_TOO_MANY_UNIQUE_STATE_OBJECTS                HEX: 887c0001
+CONSTANT: D3D11_ERROR_FILE_NOT_FOUND                               HEX: 887c0002
+CONSTANT: D3D11_ERROR_TOO_MANY_UNIQUE_VIEW_OBJECTS                 HEX: 887c003
+CONSTANT: D3D11_ERROR_DEFERRED_CONTEXT_MAP_WITHOUT_INITIAL_DISCARD HEX: 887c004
+
+CONSTANT: D3D11_INPUT_PER_VERTEX_DATA   0
+CONSTANT: D3D11_INPUT_PER_INSTANCE_DATA 1
+TYPEDEF: int D3D11_INPUT_CLASSIFICATION
+
+CONSTANT: D3D11_APPEND_ALIGNED_ELEMENT HEX: ffffffff
+
+STRUCT: D3D11_INPUT_ELEMENT_DESC
+    { SemanticName         LPCSTR                     }
+    { SemanticIndex        UINT                       }
+    { Format               DXGI_FORMAT                }
+    { InputSlot            UINT                       }
+    { AlignedByteOffset    UINT                       }
+    { InputSlotClass       D3D11_INPUT_CLASSIFICATION }
+    { InstanceDataStepRate UINT                       } ;
+
+CONSTANT: D3D11_FILL_WIREFRAME 2
+CONSTANT: D3D11_FILL_SOLID     3
+TYPEDEF: int D3D11_FILL_MODE
+
+CONSTANT: D3D11_PRIMITIVE_TOPOLOGY_UNDEFINED                  0
+CONSTANT: D3D11_PRIMITIVE_TOPOLOGY_POINTLIST                  1
+CONSTANT: D3D11_PRIMITIVE_TOPOLOGY_LINELIST                   2
+CONSTANT: D3D11_PRIMITIVE_TOPOLOGY_LINESTRIP                  3
+CONSTANT: D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST               4
+CONSTANT: D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP              5
+CONSTANT: D3D11_PRIMITIVE_TOPOLOGY_LINELIST_ADJ               10
+CONSTANT: D3D11_PRIMITIVE_TOPOLOGY_LINESTRIP_ADJ              11
+CONSTANT: D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST_ADJ           12
+CONSTANT: D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP_ADJ          13
+CONSTANT: D3D11_PRIMITIVE_TOPOLOGY_1_CONTROL_POINT_PATCHLIST  33
+CONSTANT: D3D11_PRIMITIVE_TOPOLOGY_2_CONTROL_POINT_PATCHLIST  34
+CONSTANT: D3D11_PRIMITIVE_TOPOLOGY_3_CONTROL_POINT_PATCHLIST  35
+CONSTANT: D3D11_PRIMITIVE_TOPOLOGY_4_CONTROL_POINT_PATCHLIST  36
+CONSTANT: D3D11_PRIMITIVE_TOPOLOGY_5_CONTROL_POINT_PATCHLIST  37
+CONSTANT: D3D11_PRIMITIVE_TOPOLOGY_6_CONTROL_POINT_PATCHLIST  38
+CONSTANT: D3D11_PRIMITIVE_TOPOLOGY_7_CONTROL_POINT_PATCHLIST  39
+CONSTANT: D3D11_PRIMITIVE_TOPOLOGY_8_CONTROL_POINT_PATCHLIST  40
+CONSTANT: D3D11_PRIMITIVE_TOPOLOGY_9_CONTROL_POINT_PATCHLIST  41
+CONSTANT: D3D11_PRIMITIVE_TOPOLOGY_10_CONTROL_POINT_PATCHLIST 42
+CONSTANT: D3D11_PRIMITIVE_TOPOLOGY_11_CONTROL_POINT_PATCHLIST 43
+CONSTANT: D3D11_PRIMITIVE_TOPOLOGY_12_CONTROL_POINT_PATCHLIST 44
+CONSTANT: D3D11_PRIMITIVE_TOPOLOGY_13_CONTROL_POINT_PATCHLIST 45
+CONSTANT: D3D11_PRIMITIVE_TOPOLOGY_14_CONTROL_POINT_PATCHLIST 46
+CONSTANT: D3D11_PRIMITIVE_TOPOLOGY_15_CONTROL_POINT_PATCHLIST 47
+CONSTANT: D3D11_PRIMITIVE_TOPOLOGY_16_CONTROL_POINT_PATCHLIST 48
+CONSTANT: D3D11_PRIMITIVE_TOPOLOGY_17_CONTROL_POINT_PATCHLIST 49
+CONSTANT: D3D11_PRIMITIVE_TOPOLOGY_18_CONTROL_POINT_PATCHLIST 50
+CONSTANT: D3D11_PRIMITIVE_TOPOLOGY_19_CONTROL_POINT_PATCHLIST 51
+CONSTANT: D3D11_PRIMITIVE_TOPOLOGY_20_CONTROL_POINT_PATCHLIST 52
+CONSTANT: D3D11_PRIMITIVE_TOPOLOGY_21_CONTROL_POINT_PATCHLIST 53
+CONSTANT: D3D11_PRIMITIVE_TOPOLOGY_22_CONTROL_POINT_PATCHLIST 54
+CONSTANT: D3D11_PRIMITIVE_TOPOLOGY_23_CONTROL_POINT_PATCHLIST 55
+CONSTANT: D3D11_PRIMITIVE_TOPOLOGY_24_CONTROL_POINT_PATCHLIST 56
+CONSTANT: D3D11_PRIMITIVE_TOPOLOGY_25_CONTROL_POINT_PATCHLIST 57
+CONSTANT: D3D11_PRIMITIVE_TOPOLOGY_26_CONTROL_POINT_PATCHLIST 58
+CONSTANT: D3D11_PRIMITIVE_TOPOLOGY_27_CONTROL_POINT_PATCHLIST 59
+CONSTANT: D3D11_PRIMITIVE_TOPOLOGY_28_CONTROL_POINT_PATCHLIST 60
+CONSTANT: D3D11_PRIMITIVE_TOPOLOGY_29_CONTROL_POINT_PATCHLIST 61
+CONSTANT: D3D11_PRIMITIVE_TOPOLOGY_30_CONTROL_POINT_PATCHLIST 62
+CONSTANT: D3D11_PRIMITIVE_TOPOLOGY_31_CONTROL_POINT_PATCHLIST 63
+CONSTANT: D3D11_PRIMITIVE_TOPOLOGY_32_CONTROL_POINT_PATCHLIST 64
+TYPEDEF: int D3D11_PRIMITIVE_TOPOLOGY
+
+CONSTANT: D3D11_PRIMITIVE_UNDEFINED               0
+CONSTANT: D3D11_PRIMITIVE_POINT                   1
+CONSTANT: D3D11_PRIMITIVE_LINE                    2
+CONSTANT: D3D11_PRIMITIVE_TRIANGLE                3
+CONSTANT: D3D11_PRIMITIVE_LINE_ADJ                6
+CONSTANT: D3D11_PRIMITIVE_TRIANGLE_ADJ            7
+CONSTANT: D3D11_PRIMITIVE_1_CONTROL_POINT_PATCH   8
+CONSTANT: D3D11_PRIMITIVE_2_CONTROL_POINT_PATCH   9
+CONSTANT: D3D11_PRIMITIVE_3_CONTROL_POINT_PATCH   10
+CONSTANT: D3D11_PRIMITIVE_4_CONTROL_POINT_PATCH   11
+CONSTANT: D3D11_PRIMITIVE_5_CONTROL_POINT_PATCH   12
+CONSTANT: D3D11_PRIMITIVE_6_CONTROL_POINT_PATCH   13
+CONSTANT: D3D11_PRIMITIVE_7_CONTROL_POINT_PATCH   14
+CONSTANT: D3D11_PRIMITIVE_8_CONTROL_POINT_PATCH   15
+CONSTANT: D3D11_PRIMITIVE_9_CONTROL_POINT_PATCH   16
+CONSTANT: D3D11_PRIMITIVE_10_CONTROL_POINT_PATCH  17
+CONSTANT: D3D11_PRIMITIVE_11_CONTROL_POINT_PATCH  18
+CONSTANT: D3D11_PRIMITIVE_12_CONTROL_POINT_PATCH  19
+CONSTANT: D3D11_PRIMITIVE_13_CONTROL_POINT_PATCH  20
+CONSTANT: D3D11_PRIMITIVE_14_CONTROL_POINT_PATCH  21
+CONSTANT: D3D11_PRIMITIVE_15_CONTROL_POINT_PATCH  22
+CONSTANT: D3D11_PRIMITIVE_16_CONTROL_POINT_PATCH  23
+CONSTANT: D3D11_PRIMITIVE_17_CONTROL_POINT_PATCH  24
+CONSTANT: D3D11_PRIMITIVE_18_CONTROL_POINT_PATCH  25
+CONSTANT: D3D11_PRIMITIVE_19_CONTROL_POINT_PATCH  26
+CONSTANT: D3D11_PRIMITIVE_20_CONTROL_POINT_PATCH  27
+CONSTANT: D3D11_PRIMITIVE_21_CONTROL_POINT_PATCH  28
+CONSTANT: D3D11_PRIMITIVE_22_CONTROL_POINT_PATCH  29
+CONSTANT: D3D11_PRIMITIVE_23_CONTROL_POINT_PATCH  30
+CONSTANT: D3D11_PRIMITIVE_24_CONTROL_POINT_PATCH  31
+CONSTANT: D3D11_PRIMITIVE_25_CONTROL_POINT_PATCH  32
+CONSTANT: D3D11_PRIMITIVE_26_CONTROL_POINT_PATCH  33
+CONSTANT: D3D11_PRIMITIVE_27_CONTROL_POINT_PATCH  34
+CONSTANT: D3D11_PRIMITIVE_28_CONTROL_POINT_PATCH  35
+CONSTANT: D3D11_PRIMITIVE_29_CONTROL_POINT_PATCH  36
+CONSTANT: D3D11_PRIMITIVE_30_CONTROL_POINT_PATCH  37
+CONSTANT: D3D11_PRIMITIVE_31_CONTROL_POINT_PATCH  38
+CONSTANT: D3D11_PRIMITIVE_32_CONTROL_POINT_PATCH  39
+TYPEDEF: int D3D11_PRIMITIVE
+
+CONSTANT: D3D11_CULL_NONE  1
+CONSTANT: D3D11_CULL_FRONT 2
+CONSTANT: D3D11_CULL_BACK  3
+TYPEDEF: int D3D11_CULL_MODE
+
+STRUCT: D3D11_SO_DECLARATION_ENTRY
+    { Stream UINT }
+    { SemanticName LPCSTR }
+    { SemanticIndex UINT }
+    { StartComponent BYTE }
+    { ComponentCount BYTE }
+    { OutputSlot BYTE } ;
+
+STRUCT: D3D11_VIEWPORT
+    { TopLeftX FLOAT }
+    { TopLeftY FLOAT }
+    { Width FLOAT }
+    { Height FLOAT }
+    { MinDepth FLOAT }
+    { MaxDepth FLOAT } ;
+
+CONSTANT: D3D11_RESOURCE_DIMENSION_UNKNOWN   0
+CONSTANT: D3D11_RESOURCE_DIMENSION_BUFFER    1
+CONSTANT: D3D11_RESOURCE_DIMENSION_TEXTURE1D 2
+CONSTANT: D3D11_RESOURCE_DIMENSION_TEXTURE2D 3
+CONSTANT: D3D11_RESOURCE_DIMENSION_TEXTURE3D 4
+TYPEDEF: int D3D11_RESOURCE_DIMENSION
+
+CONSTANT: D3D11_SRV_DIMENSION_UNKNOWN             0
+CONSTANT: D3D11_SRV_DIMENSION_BUFFER              1
+CONSTANT: D3D11_SRV_DIMENSION_TEXTURE1D           2
+CONSTANT: D3D11_SRV_DIMENSION_TEXTURE1DARRAY      3
+CONSTANT: D3D11_SRV_DIMENSION_TEXTURE2D           4
+CONSTANT: D3D11_SRV_DIMENSION_TEXTURE2DARRAY      5
+CONSTANT: D3D11_SRV_DIMENSION_TEXTURE2DMS         6
+CONSTANT: D3D11_SRV_DIMENSION_TEXTURE2DMSARRAY    7
+CONSTANT: D3D11_SRV_DIMENSION_TEXTURE3D           8
+CONSTANT: D3D11_SRV_DIMENSION_TEXTURECUBE         9
+CONSTANT: D3D11_SRV_DIMENSION_TEXTURECUBEARRAY    10
+CONSTANT: D3D11_SRV_DIMENSION_BUFFEREX            11
+TYPEDEF: int D3D11_SRV_DIMENSION
+
+CONSTANT: D3D11_DSV_DIMENSION_UNKNOWN             0
+CONSTANT: D3D11_DSV_DIMENSION_TEXTURE1D           1
+CONSTANT: D3D11_DSV_DIMENSION_TEXTURE1DARRAY      2
+CONSTANT: D3D11_DSV_DIMENSION_TEXTURE2D           3
+CONSTANT: D3D11_DSV_DIMENSION_TEXTURE2DARRAY      4
+CONSTANT: D3D11_DSV_DIMENSION_TEXTURE2DMS         5
+CONSTANT: D3D11_DSV_DIMENSION_TEXTURE2DMSARRAY    6
+TYPEDEF: int D3D11_DSV_DIMENSION
+
+CONSTANT: D3D11_RTV_DIMENSION_UNKNOWN             0
+CONSTANT: D3D11_RTV_DIMENSION_BUFFER              1
+CONSTANT: D3D11_RTV_DIMENSION_TEXTURE1D           2
+CONSTANT: D3D11_RTV_DIMENSION_TEXTURE1DARRAY      3
+CONSTANT: D3D11_RTV_DIMENSION_TEXTURE2D           4
+CONSTANT: D3D11_RTV_DIMENSION_TEXTURE2DARRAY      5
+CONSTANT: D3D11_RTV_DIMENSION_TEXTURE2DMS         6
+CONSTANT: D3D11_RTV_DIMENSION_TEXTURE2DMSARRAY    7
+CONSTANT: D3D11_RTV_DIMENSION_TEXTURE3D           8
+TYPEDEF: int D3D11_RTV_DIMENSION
+
+CONSTANT: D3D11_UAV_DIMENSION_UNKNOWN         0
+CONSTANT: D3D11_UAV_DIMENSION_BUFFER          1
+CONSTANT: D3D11_UAV_DIMENSION_TEXTURE1D       2
+CONSTANT: D3D11_UAV_DIMENSION_TEXTURE1DARRAY  3
+CONSTANT: D3D11_UAV_DIMENSION_TEXTURE2D       4
+CONSTANT: D3D11_UAV_DIMENSION_TEXTURE2DARRAY  5
+CONSTANT: D3D11_UAV_DIMENSION_TEXTURE3D       8
+TYPEDEF: int D3D11_UAV_DIMENSION
+
+CONSTANT: D3D11_USAGE_DEFAULT   0
+CONSTANT: D3D11_USAGE_IMMUTABLE 1
+CONSTANT: D3D11_USAGE_DYNAMIC   2
+CONSTANT: D3D11_USAGE_STAGING   3
+TYPEDEF: int D3D11_USAGE
+
+CONSTANT: D3D11_BIND_VERTEX_BUFFER    1
+CONSTANT: D3D11_BIND_INDEX_BUFFER     2
+CONSTANT: D3D11_BIND_CONSTANT_BUFFER  4
+CONSTANT: D3D11_BIND_SHADER_RESOURCE  8
+CONSTANT: D3D11_BIND_STREAM_OUTPUT    16
+CONSTANT: D3D11_BIND_RENDER_TARGET    32
+CONSTANT: D3D11_BIND_DEPTH_STENCIL    64
+CONSTANT: D3D11_BIND_UNORDERED_ACCESS 128
+TYPEDEF: int D3D11_BIND_FLAG
+
+CONSTANT: D3D11_CPU_ACCESS_WRITE  HEX: 10000
+CONSTANT: D3D11_CPU_ACCESS_READ   HEX: 20000
+TYPEDEF: int D3D11_CPU_ACCESS_FLAG
+
+CONSTANT: D3D11_RESOURCE_MISC_GENERATE_MIPS           1
+CONSTANT: D3D11_RESOURCE_MISC_SHARED                  2
+CONSTANT: D3D11_RESOURCE_MISC_TEXTURECUBE             4
+CONSTANT: D3D11_RESOURCE_MISC_DRAWINDIRECT_ARGS       16
+CONSTANT: D3D11_RESOURCE_MISC_BUFFER_ALLOW_RAW_VIEWS  32
+CONSTANT: D3D11_RESOURCE_MISC_BUFFER_STRUCTURED       64
+CONSTANT: D3D11_RESOURCE_MISC_RESOURCE_CLAMP          128
+CONSTANT: D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX       256
+CONSTANT: D3D11_RESOURCE_MISC_GDI_COMPATIBLE          512
+TYPEDEF: int D3D11_RESOURCE_MISC_FLAG
+
+CONSTANT: D3D11_MAP_READ                  1
+CONSTANT: D3D11_MAP_WRITE                 2
+CONSTANT: D3D11_MAP_READ_WRITE            3
+CONSTANT: D3D11_MAP_WRITE_DISCARD         4
+CONSTANT: D3D11_MAP_WRITE_NO_OVERWRITE    5
+TYPEDEF: int D3D11_MAP
+
+CONSTANT: D3D11_MAP_FLAG_DO_NOT_WAIT HEX: 100000
+TYPEDEF: int D3D11_MAP_FLAG
+
+CONSTANT: D3D11_RAISE_FLAG_DRIVER_INTERNAL_ERROR 1
+TYPEDEF: int D3D11_RAISE_FLAG
+
+CONSTANT: D3D11_CLEAR_DEPTH   1
+CONSTANT: D3D11_CLEAR_STENCIL 2
+TYPEDEF: int D3D11_CLEAR_FLAG
+
+TYPEDEF: RECT D3D11_RECT
+
+STRUCT: D3D11_BOX
+    { left   UINT }
+    { top    UINT }
+    { front  UINT }
+    { right  UINT }
+    { bottom UINT }
+    { back   UINT } ;
+
+COM-INTERFACE: ID3D11DeviceChild IUnknown {1841e5c8-16b0-489b-bcc8-44cfb0d5deae}
+    void GetDevice ( ID3D11Device** ppDevice )
+    HRESULT GetPrivateData ( REFGUID guid, UINT* pDataSize, void* pData )
+    HRESULT SetPrivateData ( REFGUID guid, UINT DataSize, void* pData )
+    HRESULT SetPrivateDataInterface ( REFGUID guid, IUnknown* pData ) ;
+
+CONSTANT: D3D11_COMPARISON_NEVER          1
+CONSTANT: D3D11_COMPARISON_LESS           2
+CONSTANT: D3D11_COMPARISON_EQUAL          3
+CONSTANT: D3D11_COMPARISON_LESS_EQUAL     4
+CONSTANT: D3D11_COMPARISON_GREATER        5
+CONSTANT: D3D11_COMPARISON_NOT_EQUAL      6
+CONSTANT: D3D11_COMPARISON_GREATER_EQUAL  7
+CONSTANT: D3D11_COMPARISON_ALWAYS         8
+TYPEDEF: int D3D11_COMPARISON_FUNC
+
+CONSTANT: D3D11_DEPTH_WRITE_MASK_ZERO 0
+CONSTANT: D3D11_DEPTH_WRITE_MASK_ALL  1
+TYPEDEF: int D3D11_DEPTH_WRITE_MASK
+
+CONSTANT: D3D11_STENCIL_OP_KEEP       1
+CONSTANT: D3D11_STENCIL_OP_ZERO       2
+CONSTANT: D3D11_STENCIL_OP_REPLACE    3
+CONSTANT: D3D11_STENCIL_OP_INCR_SAT   4
+CONSTANT: D3D11_STENCIL_OP_DECR_SAT   5
+CONSTANT: D3D11_STENCIL_OP_INVERT     6
+CONSTANT: D3D11_STENCIL_OP_INCR       7
+CONSTANT: D3D11_STENCIL_OP_DECR       8
+TYPEDEF: int D3D11_STENCIL_OP
+
+STRUCT: D3D11_DEPTH_STENCILOP_DESC
+    { StencilFailOp      D3D11_STENCIL_OP      }
+    { StencilDepthFailOp D3D11_STENCIL_OP      }
+    { StencilPassOp      D3D11_STENCIL_OP      }
+    { StencilFunc        D3D11_COMPARISON_FUNC } ;
+
+STRUCT: D3D11_DEPTH_STENCIL_DESC
+    { DepthEnable      BOOL                       }
+    { DepthWriteMask   D3D11_DEPTH_WRITE_MASK     }
+    { DepthFunc        D3D11_COMPARISON_FUNC      }
+    { StencilEnable    BOOL                       }
+    { StencilReadMask  BYTE                      }
+    { StencilWriteMask BYTE                      }
+    { FrontFace        D3D11_DEPTH_STENCILOP_DESC }
+    { BackFace         D3D11_DEPTH_STENCILOP_DESC } ;
+
+COM-INTERFACE: ID3D11DepthStencilState ID3D11DeviceChild {03823efb-8d8f-4e1c-9aa2-f64bb2cbfdf1}
+    void GetDesc ( D3D11_DEPTH_STENCIL_DESC* pDesc ) ;
+
+CONSTANT: D3D11_BLEND_ZERO                1
+CONSTANT: D3D11_BLEND_ONE                 2
+CONSTANT: D3D11_BLEND_SRC_COLOR           3
+CONSTANT: D3D11_BLEND_INV_SRC_COLOR       4
+CONSTANT: D3D11_BLEND_SRC_ALPHA           5
+CONSTANT: D3D11_BLEND_INV_SRC_ALPHA       6
+CONSTANT: D3D11_BLEND_DEST_ALPHA          7
+CONSTANT: D3D11_BLEND_INV_DEST_ALPHA      8
+CONSTANT: D3D11_BLEND_DEST_COLOR          9
+CONSTANT: D3D11_BLEND_INV_DEST_COLOR      10
+CONSTANT: D3D11_BLEND_SRC_ALPHA_SAT       11
+CONSTANT: D3D11_BLEND_BLEND_FACTOR        14
+CONSTANT: D3D11_BLEND_INV_BLEND_FACTOR    15
+CONSTANT: D3D11_BLEND_SRC1_COLOR          16
+CONSTANT: D3D11_BLEND_INV_SRC1_COLOR      17
+CONSTANT: D3D11_BLEND_SRC1_ALPHA          18
+CONSTANT: D3D11_BLEND_INV_SRC1_ALPHA      19
+TYPEDEF: int D3D11_BLEND
+
+CONSTANT: D3D11_BLEND_OP_ADD  1
+CONSTANT: D3D11_BLEND_OP_SUBTRACT 2
+CONSTANT: D3D11_BLEND_OP_REV_SUBTRACT 3
+CONSTANT: D3D11_BLEND_OP_MIN  4
+CONSTANT: D3D11_BLEND_OP_MAX  5
+TYPEDEF: int D3D11_BLEND_OP
+
+CONSTANT: D3D11_COLOR_WRITE_ENABLE_RED    1
+CONSTANT: D3D11_COLOR_WRITE_ENABLE_GREEN  2
+CONSTANT: D3D11_COLOR_WRITE_ENABLE_BLUE   4
+CONSTANT: D3D11_COLOR_WRITE_ENABLE_ALPHA  8
+CONSTANT: D3D11_COLOR_WRITE_ENABLE_ALL    15
+TYPEDEF: int D3D11_COLOR_WRITE_ENABLE
+
+STRUCT: D3D11_RENDER_TARGET_BLEND_DESC
+    { BlendEnable           BOOL           }
+    { SrcBlend              D3D11_BLEND    }
+    { DestBlend             D3D11_BLEND    }
+    { BlendOp               D3D11_BLEND_OP }
+    { SrcBlendAlpha         D3D11_BLEND    }
+    { DestBlendAlpha        D3D11_BLEND    }
+    { BlendOpAlpha          D3D11_BLEND_OP }
+    { RenderTargetWriteMask BYTE          } ;
+
+STRUCT: D3D11_BLEND_DESC
+    { AlphaToCoverageEnable BOOL }
+    { IndependentBlendEnable BOOL }
+    { RenderTarget D3D11_RENDER_TARGET_BLEND_DESC[8] } ;
+
+COM-INTERFACE: ID3D11BlendState ID3D11DeviceChild 75b68faa-347d-4159-8f45-a0640f01cd9a
+    void GetDesc ( D3D11_BLEND_DESC* pDesc ) ;
+
+STRUCT: D3D11_RASTERIZER_DESC
+    { FillMode              D3D11_FILL_MODE }
+    { CullMode              D3D11_CULL_MODE }
+    { FrontCounterClockwise BOOL            }
+    { DepthBias             INT             }
+    { DepthBiasClamp        FLOAT           }
+    { SlopeScaledDepthBias  FLOAT           }
+    { DepthClipEnable       BOOL            }
+    { ScissorEnable         BOOL            }
+    { MultisampleEnable     BOOL            }
+    { AntialiasedLineEnable BOOL            } ;
+
+COM-INTERFACE: ID3D11RasterizerState ID3D11DeviceChild {9bb4ab81-ab1a-4d8f-b506-fc04200b6ee7}
+    void GetDesc ( D3D11_RASTERIZER_DESC* pDesc ) ;
+
+STRUCT: D3D11_SUBRESOURCE_DATA
+    { pSysMem          void* }
+    { SysMemPitch      UINT  }
+    { SysMemSlicePitch UINT  } ;
+
+STRUCT: D3D11_MAPPED_SUBRESOURCE
+    { pData       void* }
+    { RowPitch    UINT  }
+    { DepthPitch  UINT  } ;
+
+COM-INTERFACE: ID3D11Resource ID3D11DeviceChild {dc8e63f3-d12b-4952-b47b-5e45026a862d}
+    void GetType ( D3D11_RESOURCE_DIMENSION* pResourceDimension )
+    void SetEvictionPriority ( UINT EvictionPriority )
+    UINT GetEvictionPriority ( ) ;
+
+STRUCT: D3D11_BUFFER_DESC
+    { ByteWidth           UINT        }
+    { Usage               D3D11_USAGE }
+    { BindFlags           UINT        }
+    { CPUAccessFlags      UINT        }
+    { MiscFlags           UINT        }
+    { StructureByteStride UINT        } ;
+
+COM-INTERFACE: ID3D11Buffer ID3D11Resource {48570b85-d1ee-4fcd-a250-eb350722b037}
+    void GetDesc ( D3D11_BUFFER_DESC* pDesc ) ;
+
+STRUCT: D3D11_TEXTURE1D_DESC
+    { Width          UINT        }
+    { MipLevels      UINT        }
+    { ArraySize      UINT        }
+    { Format         DXGI_FORMAT }
+    { Usage          D3D11_USAGE }
+    { BindFlags      UINT        }
+    { CPUAccessFlags UINT        }
+    { MiscFlags      UINT        } ;
+
+COM-INTERFACE: ID3D11Texture1D ID3D11Resource {f8fb5c27-c6b3-4f75-a4c8-439af2ef564c}
+    void GetDesc ( D3D11_TEXTURE1D_DESC* pDesc ) ;
+
+STRUCT: D3D11_TEXTURE2D_DESC
+    { Width          UINT             }
+    { Height         UINT             }
+    { MipLevels      UINT             }
+    { ArraySize      UINT             }
+    { Format         DXGI_FORMAT      }
+    { SampleDesc     DXGI_SAMPLE_DESC }
+    { Usage          D3D11_USAGE      }
+    { BindFlags      UINT             }
+    { CPUAccessFlags UINT             }
+    { MiscFlags      UINT             } ;
+
+COM-INTERFACE: ID3D11Texture2D ID3D11Resource {6f15aaf2-d208-4e89-9ab4-489535d34f9c}
+    void GetDesc ( D3D11_TEXTURE2D_DESC* pDesc ) ;
+
+STRUCT: D3D11_TEXTURE3D_DESC
+    { Width          UINT        }
+    { Height         UINT        }
+    { Depth          UINT        }
+    { MipLevels      UINT        }
+    { Format         DXGI_FORMAT }
+    { Usage          D3D11_USAGE }
+    { BindFlags      UINT        }
+    { CPUAccessFlags UINT        }
+    { MiscFlags      UINT        } ;
+
+COM-INTERFACE: ID3D11Texture3D ID3D11Resource {037e866e-f56d-4357-a8af-9dabbe6e250e}
+    void GetDesc ( D3D11_TEXTURE3D_DESC* pDesc ) ;
+
+CONSTANT: D3D11_TEXTURECUBE_FACE_POSITIVE_X   0
+CONSTANT: D3D11_TEXTURECUBE_FACE_NEGATIVE_X   1
+CONSTANT: D3D11_TEXTURECUBE_FACE_POSITIVE_Y   2
+CONSTANT: D3D11_TEXTURECUBE_FACE_NEGATIVE_Y   3
+CONSTANT: D3D11_TEXTURECUBE_FACE_POSITIVE_Z   4
+CONSTANT: D3D11_TEXTURECUBE_FACE_NEGATIVE_Z   5
+TYPEDEF: int D3D11_TEXTURECUBE_FACE
+
+COM-INTERFACE: ID3D11View ID3D11DeviceChild {839d1216-bb2e-412b-b7f4-a9dbebe08ed1}
+    void GetResource ( ID3D11Resource** ppResource ) ;
+
+UNION-STRUCT: D3D11_BUFFER_SRV_UNION1
+    { FirstElement  UINT }
+    { ElementOffset UINT } ;
+
+UNION-STRUCT: D3D11_BUFFER_SRV_UNION2
+    { NumElements UINT }
+    { ElementWith UINT } ;
+
+STRUCT: D3D11_BUFFER_SRV
+    { First  D3D11_BUFFER_SRV_UNION1 }
+    { Second D3D11_BUFFER_SRV_UNION2 } ;
+
+CONSTANT: D3D11_BUFFEREX_SRV_FLAG_RAW 1
+TYPEDEF: int D3D11_BUFFEREX_SRV_FLAG
+
+STRUCT: D3D11_BUFFEREX_SRV
+    { FirstElement UINT }
+    { NumElements  UINT }
+    { Flags        UINT } ;
+
+STRUCT: D3D11_TEX1D_SRV
+    { MostDetailedMip UINT }
+    { MipLevels       UINT } ;
+
+STRUCT: D3D11_TEX1D_ARRAY_SRV
+    { MostDetailedMip UINT }
+    { MipLevels       UINT }
+    { FirstArraySlice UINT }
+    { ArraySize       UINT } ;
+
+STRUCT: D3D11_TEX2D_SRV
+    { MostDetailedMip UINT }
+    { MipLevels       UINT } ;
+
+STRUCT: D3D11_TEX2D_ARRAY_SRV
+    { MostDetailedMip UINT }
+    { MipLevels       UINT }
+    { FirstArraySlice UINT }
+    { ArraySize       UINT } ;
+
+STRUCT: D3D11_TEX3D_SRV
+    { MostDetailedMip UINT }
+    { MipLevels       UINT } ;
+
+STRUCT: D3D11_TEXCUBE_SRV
+    { MostDetailedMip UINT }
+    { MipLevels       UINT } ;
+
+STRUCT: D3D11_TEXCUBE_ARRAY_SRV
+    { MostDetailedMip  UINT }
+    { MipLevels        UINT }
+    { First2DArrayFace UINT }
+    { NumCubes         UINT } ;
+
+STRUCT: D3D11_TEX2DMS_SRV
+    { UnusedField_NothingToDefine UINT } ;
+
+STRUCT: D3D11_TEX2DMS_ARRAY_SRV
+    { FirstArraySlice UINT }
+    { ArraySize       UINT } ;
+
+UNION-STRUCT: D3D11_SHADER_RESOURCE_VIEW_DESC_UNION
+    { Buffer           D3D11_BUFFER_SRV        }
+    { Texture1D        D3D11_TEX1D_SRV         }
+    { Texture1DArray   D3D11_TEX1D_ARRAY_SRV   }
+    { Texture2D        D3D11_TEX2D_SRV         }
+    { Texture2DArray   D3D11_TEX2D_ARRAY_SRV   }
+    { Texture2DMS      D3D11_TEX2DMS_SRV       }
+    { Texture2DMSArray D3D11_TEX2DMS_ARRAY_SRV }
+    { Texture3D        D3D11_TEX3D_SRV         }
+    { TextureCube      D3D11_TEXCUBE_SRV       }
+    { TextureCubeArray D3D11_TEXCUBE_ARRAY_SRV }
+    { BufferEx         D3D11_BUFFEREX_SRV      } ;
+
+STRUCT: D3D11_SHADER_RESOURCE_VIEW_DESC
+    { Format        DXGI_FORMAT                           }
+    { ViewDimension D3D11_SRV_DIMENSION                   }
+    { View          D3D11_SHADER_RESOURCE_VIEW_DESC_UNION } ;
+
+COM-INTERFACE: ID3D11ShaderResourceView ID3D11View {b0e06fe0-8192-4e1a-b1ca-36d7414710b2}
+    void GetDesc ( D3D11_SHADER_RESOURCE_VIEW_DESC* pDesc ) ;
+
+UNION-STRUCT: D3D11_BUFFER_RTV_UNION1
+    { FirstElement  UINT }
+    { ElementOffset UINT } ;
+
+UNION-STRUCT: D3D11_BUFFER_RTV_UNION2
+    { NumElements  UINT }
+    { ElementWidth UINT } ;
+
+STRUCT: D3D11_BUFFER_RTV
+    { First  D3D11_BUFFER_RTV_UNION1 }
+    { Second D3D11_BUFFER_RTV_UNION2 } ;
+
+STRUCT: D3D11_TEX1D_RTV
+    { MipSlice UINT } ;
+
+STRUCT: D3D11_TEX1D_ARRAY_RTV
+    { MipSlice        UINT }
+    { FirstArraySlice UINT }
+    { ArraySize       UINT } ;
+
+STRUCT: D3D11_TEX2D_RTV
+    { MipSlice UINT } ;
+
+STRUCT: D3D11_TEX2DMS_RTV
+    { UnusedField_NothingToDefine UINT } ;
+
+STRUCT: D3D11_TEX2D_ARRAY_RTV
+    { MipSlice        UINT }
+    { FirstArraySlice UINT }
+    { ArraySize       UINT } ;
+
+STRUCT: D3D11_TEX2DMS_ARRAY_RTV
+    { FirstArraySlice UINT }
+    { ArraySize       UINT } ;
+
+STRUCT: D3D11_TEX3D_RTV
+    { MipSlice    UINT }
+    { FirstWSlice UINT }
+    { WSize       UINT } ;
+
+UNION-STRUCT: D3D11_RENDER_TARGET_VIEW_DESC_UNION
+    { Buffer           D3D11_BUFFER_RTV        }
+    { Texture1D        D3D11_TEX1D_RTV         }
+    { Texture1DArray   D3D11_TEX1D_ARRAY_RTV   }
+    { Texture2D        D3D11_TEX2D_RTV         }
+    { Texture2DArray   D3D11_TEX2D_ARRAY_RTV   }
+    { Texture2DMS      D3D11_TEX2DMS_RTV       }
+    { Texture2DMSArray D3D11_TEX2DMS_ARRAY_RTV }
+    { Texture3D        D3D11_TEX3D_RTV         } ;
+
+STRUCT: D3D11_RENDER_TARGET_VIEW_DESC
+    { Format        DXGI_FORMAT                         }
+    { ViewDimension D3D11_RTV_DIMENSION                 }
+    { View          D3D11_RENDER_TARGET_VIEW_DESC_UNION } ;
+
+COM-INTERFACE: ID3D11RenderTargetView ID3D11View {dfdba067-0b8d-4865-875b-d7b4516cc164}
+    void GetDesc ( D3D11_RENDER_TARGET_VIEW_DESC* pDesc ) ;
+
+STRUCT: D3D11_TEX1D_DSV
+    { MipSlice UINT } ;
+
+STRUCT: D3D11_TEX1D_ARRAY_DSV
+    { MipSlice        UINT }
+    { FirstArraySlice UINT }
+    { ArraySize       UINT } ;
+
+STRUCT: D3D11_TEX2D_DSV
+    { MipSlice UINT } ;
+
+STRUCT: D3D11_TEX2D_ARRAY_DSV
+    { MipSlice        UINT }
+    { FirstArraySlice UINT }
+    { ArraySize       UINT } ;
+
+STRUCT: D3D11_TEX2DMS_DSV
+    { UnusedField_NothingToDefine UINT } ;
+
+STRUCT: D3D11_TEX2DMS_ARRAY_DSV
+    { FirstArraySlice UINT }
+    { ArraySize       UINT } ;
+
+CONSTANT: D3D11_DSV_READ_ONLY_DEPTH 1
+CONSTANT: D3D11_DSV_READ_ONLY_STENCIL 2
+TYPEDEF: int D3D11_DSV_FLAG
+
+UNION-STRUCT: D3D11_DEPTH_STENCIL_VIEW_DESC_UNION
+    { Texture1D        D3D11_TEX1D_DSV         }
+    { Texture1DArray   D3D11_TEX1D_ARRAY_DSV   }
+    { Texture2D        D3D11_TEX2D_DSV         }
+    { Texture2DArray   D3D11_TEX2D_ARRAY_DSV   }
+    { Texture2DMS      D3D11_TEX2DMS_DSV       }
+    { Texture2DMSArray D3D11_TEX2DMS_ARRAY_DSV } ;
+
+STRUCT: D3D11_DEPTH_STENCIL_VIEW_DESC
+    { Format        DXGI_FORMAT                         }
+    { ViewDimension D3D11_DSV_DIMENSION                 }
+    { Flags         UINT                                }
+    { View          D3D11_DEPTH_STENCIL_VIEW_DESC_UNION } ;
+
+COM-INTERFACE: ID3D11DepthStencilView ID3D11View {9fdac92a-1876-48c3-afad-25b94f84a9b6}
+    void GetDesc ( D3D11_DEPTH_STENCIL_VIEW_DESC* pDesc ) ;
+
+CONSTANT: D3D11_BUFFER_UAV_FLAG_RAW     1
+CONSTANT: D3D11_BUFFER_UAV_FLAG_APPEND  2
+CONSTANT: D3D11_BUFFER_UAV_FLAG_COUNTER 4
+TYPEDEF: int D3D11_BUFFER_UAV_FLAG
+
+STRUCT: D3D11_BUFFER_UAV
+    { FirstElement UINT }
+    { NumElements  UINT }
+    { Flags        UINT } ;
+
+STRUCT: D3D11_TEX1D_UAV
+    { MipSlice UINT } ;
+
+STRUCT: D3D11_TEX1D_ARRAY_UAV
+    { MipSlice        UINT }
+    { FirstArraySlice UINT }
+    { ArraySize       UINT } ;
+
+STRUCT: D3D11_TEX2D_UAV
+    { MipSlice UINT } ;
+
+STRUCT: D3D11_TEX2D_ARRAY_UAV
+    { MipSlice        UINT }
+    { FirstArraySlice UINT }
+    { ArraySize       UINT } ;
+
+STRUCT: D3D11_TEX3D_UAV
+    { MipSlice    UINT }
+    { FirstWSlice UINT }
+    { WSize       UINT } ;
+
+UNION-STRUCT: D3D11_UNORDERED_ACCESS_VIEW_DESC_UNION
+    { Buffer         D3D11_BUFFER_UAV      }
+    { Texture1D      D3D11_TEX1D_UAV       }
+    { Texture1DArray D3D11_TEX1D_ARRAY_UAV }
+    { Texture2D      D3D11_TEX2D_UAV       }
+    { Texture2DArray D3D11_TEX2D_ARRAY_UAV }
+    { Texture3D      D3D11_TEX3D_UAV       } ;
+
+STRUCT: D3D11_UNORDERED_ACCESS_VIEW_DESC
+    { Format        DXGI_FORMAT                            }
+    { ViewDimension D3D11_UAV_DIMENSION                    }
+    { View          D3D11_UNORDERED_ACCESS_VIEW_DESC_UNION } ;
+
+
+COM-INTERFACE: ID3D11UnorderedAccessView ID3D11View {28acf509-7f5c-48f6-8611-f316010a6380}
+    void GetDesc ( D3D11_UNORDERED_ACCESS_VIEW_DESC* pDesc ) ;
+
+COM-INTERFACE: ID3D11VertexShader ID3D11DeviceChild {3b301d64-d678-4289-8897-22f8928b72f3} ;
+
+COM-INTERFACE: ID3D11HullShader ID3D11DeviceChild {8e5c6061-628a-4c8e-8264-bbe45cb3d5dd} ;
+
+COM-INTERFACE: ID3D11DomainShader ID3D11DeviceChild {f582c508-0f36-490c-9977-31eece268cfa} ;
+
+COM-INTERFACE: ID3D11GeometryShader ID3D11DeviceChild {38325b96-effb-4022-ba02-2e795b70275c} ;
+
+COM-INTERFACE: ID3D11PixelShader ID3D11DeviceChild {ea82e40d-51dc-4f33-93d4-db7c9125ae8c} ;
+
+COM-INTERFACE: ID3D11ComputeShader ID3D11DeviceChild {4f5b196e-c2bd-495e-bd01-1fded38e4969} ;
+
+COM-INTERFACE: ID3D11InputLayout ID3D11DeviceChild {e4819ddc-4cf0-4025-bd26-5de82a3e07b7} ;
+
+CONSTANT: D3D11_FILTER_MIN_MAG_MIP_POINT                          HEX: 0
+CONSTANT: D3D11_FILTER_MIN_MAG_POINT_MIP_LINEAR                   HEX: 1
+CONSTANT: D3D11_FILTER_MIN_POINT_MAG_LINEAR_MIP_POINT             HEX: 4
+CONSTANT: D3D11_FILTER_MIN_POINT_MAG_MIP_LINEAR                   HEX: 5
+CONSTANT: D3D11_FILTER_MIN_LINEAR_MAG_MIP_POINT                   HEX: 10
+CONSTANT: D3D11_FILTER_MIN_LINEAR_MAG_POINT_MIP_LINEAR            HEX: 11
+CONSTANT: D3D11_FILTER_MIN_MAG_LINEAR_MIP_POINT                   HEX: 14
+CONSTANT: D3D11_FILTER_MIN_MAG_MIP_LINEAR                         HEX: 15
+CONSTANT: D3D11_FILTER_ANISOTROPIC                                HEX: 55
+CONSTANT: D3D11_FILTER_COMPARISON_MIN_MAG_MIP_POINT               HEX: 80
+CONSTANT: D3D11_FILTER_COMPARISON_MIN_MAG_POINT_MIP_LINEAR        HEX: 81
+CONSTANT: D3D11_FILTER_COMPARISON_MIN_POINT_MAG_LINEAR_MIP_POINT  HEX: 84
+CONSTANT: D3D11_FILTER_COMPARISON_MIN_POINT_MAG_MIP_LINEAR        HEX: 85
+CONSTANT: D3D11_FILTER_COMPARISON_MIN_LINEAR_MAG_MIP_POINT        HEX: 90
+CONSTANT: D3D11_FILTER_COMPARISON_MIN_LINEAR_MAG_POINT_MIP_LINEAR HEX: 91
+CONSTANT: D3D11_FILTER_COMPARISON_MIN_MAG_LINEAR_MIP_POINT        HEX: 94
+CONSTANT: D3D11_FILTER_COMPARISON_MIN_MAG_MIP_LINEAR              HEX: 95
+CONSTANT: D3D11_FILTER_COMPARISON_ANISOTROPIC                     HEX: d5
+TYPEDEF: int D3D11_FILTER
+
+CONSTANT: D3D11_FILTER_TYPE_POINT  0
+CONSTANT: D3D11_FILTER_TYPE_LINEAR 1
+TYPEDEF: int D3D11_FILTER_TYPE;
+
+CONSTANT: D3D11_FILTER_TYPE_MASK 3
+CONSTANT: D3D11_MIN_FILTER_SHIFT 4
+CONSTANT: D3D11_MAG_FILTER_SHIFT 2
+CONSTANT: D3D11_MIP_FILTER_SHIFT 0
+CONSTANT: D3D11_COMPARISON_FILTERING_BIT  HEX: 80
+CONSTANT: D3D11_ANISOTROPIC_FILTERING_BIT HEX: 40
+
+CONSTANT: D3D11_TEXTURE_ADDRESS_WRAP        1
+CONSTANT: D3D11_TEXTURE_ADDRESS_MIRROR      2
+CONSTANT: D3D11_TEXTURE_ADDRESS_CLAMP       3
+CONSTANT: D3D11_TEXTURE_ADDRESS_BORDER      4
+CONSTANT: D3D11_TEXTURE_ADDRESS_MIRROR_ONCE 5
+TYPEDEF: int D3D11_TEXTURE_ADDRESS_MODE
+
+STRUCT: D3D11_SAMPLER_DESC
+    { Filter         D3D11_FILTER               }
+    { AddressU       D3D11_TEXTURE_ADDRESS_MODE }
+    { AddressV       D3D11_TEXTURE_ADDRESS_MODE }
+    { AddressW       D3D11_TEXTURE_ADDRESS_MODE }
+    { MipLODBias     FLOAT                      }
+    { MaxAnisotropy  UINT                       }
+    { ComparisonFunc D3D11_COMPARISON_FUNC      }
+    { BorderColor    FLOAT[4]                   }
+    { MinLOD         FLOAT                      }
+    { MaxLOD         FLOAT                      } ;
+
+COM-INTERFACE: ID3D11SamplerState ID3D11DeviceChild {da6fea51-564c-4487-9810-f0d0f9b4e3a5}
+    void GetDesc ( D3D11_SAMPLER_DESC* pDesc ) ;
+
+CONSTANT: D3D11_FORMAT_SUPPORT_BUFFER                         HEX: 1
+CONSTANT: D3D11_FORMAT_SUPPORT_IA_VERTEX_BUFFER               HEX: 2
+CONSTANT: D3D11_FORMAT_SUPPORT_IA_INDEX_BUFFER                HEX: 4
+CONSTANT: D3D11_FORMAT_SUPPORT_SO_BUFFER                      HEX: 8
+CONSTANT: D3D11_FORMAT_SUPPORT_TEXTURE1D                      HEX: 10
+CONSTANT: D3D11_FORMAT_SUPPORT_TEXTURE2D                      HEX: 20
+CONSTANT: D3D11_FORMAT_SUPPORT_TEXTURE3D                      HEX: 40
+CONSTANT: D3D11_FORMAT_SUPPORT_TEXTURECUBE                    HEX: 80
+CONSTANT: D3D11_FORMAT_SUPPORT_SHADER_LOAD                    HEX: 100
+CONSTANT: D3D11_FORMAT_SUPPORT_SHADER_SAMPLE                  HEX: 200
+CONSTANT: D3D11_FORMAT_SUPPORT_SHADER_SAMPLE_COMPARISON       HEX: 400
+CONSTANT: D3D11_FORMAT_SUPPORT_SHADER_SAMPLE_MONO_TEXT        HEX: 800
+CONSTANT: D3D11_FORMAT_SUPPORT_MIP                            HEX: 1000
+CONSTANT: D3D11_FORMAT_SUPPORT_MIP_AUTOGEN                    HEX: 2000
+CONSTANT: D3D11_FORMAT_SUPPORT_RENDER_TARGET                  HEX: 4000
+CONSTANT: D3D11_FORMAT_SUPPORT_BLENDABLE                      HEX: 8000
+CONSTANT: D3D11_FORMAT_SUPPORT_DEPTH_STENCIL                  HEX: 10000
+CONSTANT: D3D11_FORMAT_SUPPORT_CPU_LOCKABLE                   HEX: 20000
+CONSTANT: D3D11_FORMAT_SUPPORT_MULTISAMPLE_RESOLVE            HEX: 40000
+CONSTANT: D3D11_FORMAT_SUPPORT_DISPLAY                        HEX: 80000
+CONSTANT: D3D11_FORMAT_SUPPORT_CAST_WITHIN_BIT_LAYOUT         HEX: 100000
+CONSTANT: D3D11_FORMAT_SUPPORT_MULTISAMPLE_RENDERTARGET       HEX: 200000
+CONSTANT: D3D11_FORMAT_SUPPORT_MULTISAMPLE_LOAD               HEX: 400000
+CONSTANT: D3D11_FORMAT_SUPPORT_SHADER_GATHER                  HEX: 800000
+CONSTANT: D3D11_FORMAT_SUPPORT_BACK_BUFFER_CAST               HEX: 1000000
+CONSTANT: D3D11_FORMAT_SUPPORT_TYPED_UNORDERED_ACCESS_VIEW    HEX: 2000000
+CONSTANT: D3D11_FORMAT_SUPPORT_SHADER_GATHER_COMPARISON       HEX: 4000000
+TYPEDEF: int D3D11_FORMAT_SUPPORT
+
+CONSTANT: D3D11_FORMAT_SUPPORT2_UAV_ATOMIC_ADD                                HEX: 1
+CONSTANT: D3D11_FORMAT_SUPPORT2_UAV_ATOMIC_BITWISE_OPS                        HEX: 2
+CONSTANT: D3D11_FORMAT_SUPPORT2_UAV_ATOMIC_COMPARE_STORE_OR_COMPARE_EXCHANGE  HEX: 4
+CONSTANT: D3D11_FORMAT_SUPPORT2_UAV_ATOMIC_EXCHANGE                           HEX: 8
+CONSTANT: D3D11_FORMAT_SUPPORT2_UAV_ATOMIC_SIGNED_MIN_OR_MAX                  HEX: 10
+CONSTANT: D3D11_FORMAT_SUPPORT2_UAV_ATOMIC_UNSIGNED_MIN_OR_MAX                HEX: 20
+CONSTANT: D3D11_FORMAT_SUPPORT2_UAV_TYPED_LOAD                                HEX: 40
+CONSTANT: D3D11_FORMAT_SUPPORT2_UAV_TYPED_STORE                               HEX: 80
+TYPEDEF: int D3D11_FORMAT_SUPPORT2
+
+COM-INTERFACE: ID3D11Asynchronous ID3D11DeviceChild {4b35d0cd-1e15-4258-9c98-1b1333f6dd3b}
+    UINT GetDataSize ( ) ;
+
+CONSTANT: D3D11_ASYNC_GETDATA_DONOTFLUSH 1
+TYPEDEF: int D3D11_ASYNC_GETDATA_FLAG
+
+CONSTANT: D3D11_QUERY_EVENT                           0
+CONSTANT: D3D11_QUERY_OCCLUSION                       1
+CONSTANT: D3D11_QUERY_TIMESTAMP                       2
+CONSTANT: D3D11_QUERY_TIMESTAMP_DISJOINT              3
+CONSTANT: D3D11_QUERY_PIPELINE_STATISTICS             4
+CONSTANT: D3D11_QUERY_OCCLUSION_PREDICATE             5
+CONSTANT: D3D11_QUERY_SO_STATISTICS                   6
+CONSTANT: D3D11_QUERY_SO_OVERFLOW_PREDICATE           7
+CONSTANT: D3D11_QUERY_SO_STATISTICS_STREAM0           8
+CONSTANT: D3D11_QUERY_SO_OVERFLOW_PREDICATE_STREAM0   9
+CONSTANT: D3D11_QUERY_SO_STATISTICS_STREAM1           10
+CONSTANT: D3D11_QUERY_SO_OVERFLOW_PREDICATE_STREAM1   11
+CONSTANT: D3D11_QUERY_SO_STATISTICS_STREAM2           12
+CONSTANT: D3D11_QUERY_SO_OVERFLOW_PREDICATE_STREAM2   13
+CONSTANT: D3D11_QUERY_SO_STATISTICS_STREAM3           14
+CONSTANT: D3D11_QUERY_SO_OVERFLOW_PREDICATE_STREAM3   15
+TYPEDEF: int D3D11_QUERY
+
+CONSTANT: D3D11_QUERY_MISC_PREDICATEHINT 1
+TYPEDEF: int D3D11_QUERY_MISC_FLAG
+
+STRUCT: D3D11_QUERY_DESC
+    { Query     D3D11_QUERY }
+    { MiscFlags UINT        } ;
+
+COM-INTERFACE: ID3D11Query ID3D11Asynchronous {d6c00747-87b7-425e-b84d-44d108560afd}
+    void GetDesc ( D3D11_QUERY_DESC* pDesc ) ;
+
+COM-INTERFACE: ID3D11Predicate ID3D11Query {9eb576dd-9f77-4d86-81aa-8bab5fe490e2} ;
+
+STRUCT: D3D11_QUERY_DATA_TIMESTAMP_DISJOINT
+    { Frequency UINT64 }
+    { Disjoint  BOOL   } ;
+
+STRUCT: D3D11_QUERY_DATA_PIPELINE_STATISTICS
+    { IAVertices    UINT64 }
+    { IAPrimitives  UINT64 }
+    { VSInvocations UINT64 }
+    { GSInvocations UINT64 }
+    { GSPrimitives  UINT64 }
+    { CInvocations  UINT64 }
+    { CPrimitives   UINT64 }
+    { PSInvocations UINT64 }
+    { HSInvocations UINT64 }
+    { DSInvocations UINT64 }
+    { CSInvocations UINT64 } ;
+
+STRUCT: D3D11_QUERY_DATA_SO_STATISTICS
+    { NumPrimitivesWritten    UINT64 }
+    { PrimitivesStorageNeeded UINT64 } ;
+
+CONSTANT: D3D11_COUNTER_DEVICE_DEPENDENT_0 HEX: 40000000
+TYPEDEF: int D3D11_COUNTER
+
+CONSTANT: D3D11_COUNTER_TYPE_FLOAT32 0
+CONSTANT: D3D11_COUNTER_TYPE_UINT16  1
+CONSTANT: D3D11_COUNTER_TYPE_UINT32  2
+CONSTANT: D3D11_COUNTER_TYPE_UINT64  3
+TYPEDEF: int D3D11_COUNTER_TYPE
+
+STRUCT: D3D11_COUNTER_DESC
+    { Counter   D3D11_COUNTER }
+    { MiscFlags UINT          } ;
+
+STRUCT: D3D11_COUNTER_INFO
+    { LastDeviceDependentCounter D3D11_COUNTER }
+    { NumSimultaneousCounters    UINT          }
+    { NumDetectableParallelUnits BYTE         } ;
+
+COM-INTERFACE: ID3D11Counter ID3D11Asynchronous {6e8c49fb-a371-4770-b440-29086022b741}
+    void GetDesc ( D3D11_COUNTER_DESC* pDesc ) ;
+
+CONSTANT: D3D11_STANDARD_MULTISAMPLE_PATTERN HEX: ffffffff
+CONSTANT: D3D11_CENTER_MULTISAMPLE_PATTERN   HEX: fffffffe
+TYPEDEF: int D3D11_STANDARD_MULTISAMPLE_QUALITY_LEVELS
+
+CONSTANT: D3D11_DEVICE_CONTEXT_IMMEDIATE 0
+CONSTANT: D3D11_DEVICE_CONTEXT_DEFERRED  1
+TYPEDEF: int D3D11_DEVICE_CONTEXT_TYPE
+
+STRUCT: D3D11_CLASS_INSTANCE_DESC
+    { InstanceId               UINT }
+    { InstanceIndex            UINT }
+    { TypeId                   UINT }
+    { ConstantBuffer           UINT }
+    { BaseConstantBufferOffset UINT }
+    { BaseTexture              UINT }
+    { BaseSampler              UINT }
+    { Created                  BOOL } ;
+
+COM-INTERFACE: ID3D11ClassInstance ID3D11DeviceChild {a6cd7faa-b0b7-4a2f-9436-8662a65797cb}
+    void GetClassLinkage ( ID3D11ClassLinkage** ppLinkage )
+    void GetDesc ( D3D11_CLASS_INSTANCE_DESC* pDesc )
+    void GetInstanceName ( LPSTR pInstanceName, SIZE_T* pBufferLength )
+    void GetTypeName ( LPSTR pTypeName, SIZE_T* pBufferLength ) ;
+
+COM-INTERFACE: ID3D11ClassLinkage ID3D11DeviceChild {ddf57cba-9543-46e4-a12b-f207a0fe7fed}
+    HRESULT GetClassInstance ( LPCSTR pClassInstanceName, UINT InstanceIndex, ID3D11ClassInstance** ppInstance )
+    HRESULT CreateClassInstance ( LPCSTR pClassTypeName, UINT ConstantBufferOffset, UINT ConstantVectorOffset, UINT TextureOffset, UINT SamplerOffset, ID3D11ClassInstance** ppInstance ) ;
+
+COM-INTERFACE: ID3D11CommandList ID3D11DeviceChild {a24bc4d1-769e-43f7-8013-98ff566c18e2}
+    UINT GetContextFlags ( ) ;
+
+CONSTANT: D3D11_FEATURE_THREADING                 0
+CONSTANT: D3D11_FEATURE_DOUBLES                   1
+CONSTANT: D3D11_FEATURE_FORMAT_SUPPORT            2
+CONSTANT: D3D11_FEATURE_FORMAT_SUPPORT2           3
+CONSTANT: D3D11_FEATURE_D3D10_X_HARDWARE_OPTIONS  4
+TYPEDEF: int D3D11_FEATURE
+
+STRUCT: D3D11_FEATURE_DATA_THREADING
+    { DriverConcurrentCreates BOOL }
+    { DriverCommandLists      BOOL } ;
+
+STRUCT: D3D11_FEATURE_DATA_DOUBLES
+    { DoublePrecisionFloatShaderOps BOOL } ;
+
+STRUCT: D3D11_FEATURE_DATA_FORMAT_SUPPORT
+    { InFormat         DXGI_FORMAT }
+    { OutFormatSupport UINT        } ;
+
+STRUCT: D3D11_FEATURE_DATA_FORMAT_SUPPORT2
+    { InFormat          DXGI_FORMAT }
+    { OutFormatSupport2 UINT        } ;
+
+STRUCT: D3D11_FEATURE_DATA_D3D10_X_HARDWARE_OPTIONS
+    { ComputeShaders_Plus_RawAndStructuredBuffers_Via_Shader_4_x BOOL } ;
+
+COM-INTERFACE: ID3D11DeviceContext ID3D11DeviceChild {c0bfa96c-e089-44fb-8eaf-26f8796190da}
+    void VSSetConstantBuffers ( UINT StartSlot, UINT NumBuffers, ID3D11Buffer** ppConstantBuffers )
+    void PSSetShaderResources ( UINT StartSlot, UINT NumViews, ID3D11ShaderResourceView** ppShaderResourceViews )
+    void PSSetShader ( ID3D11PixelShader* pPixelShader, ID3D11ClassInstance** ppClassInstances, UINT NumClassInstances )
+    void PSSetSamplers ( UINT StartSlot, UINT NumSamplers, ID3D11SamplerState** ppSamplers )
+    void VSSetShader ( ID3D11VertexShader* pVertexShader, ID3D11ClassInstance** ppClassInstances, UINT NumClassInstances )
+    void DrawIndexed ( UINT IndexCount, UINT StartIndexLocation, INT BaseVertexLocation )
+    void Draw ( UINT VertexCount, UINT StartVertexLocation )
+    HRESULT Map ( ID3D11Resource* pResource, UINT Subresource, D3D11_MAP MapType, UINT MapFlags, D3D11_MAPPED_SUBRESOURCE* pMappedResource )
+    void Unmap ( ID3D11Resource* pResource, UINT Subresource )
+    void PSSetConstantBuffers ( UINT StartSlot, UINT NumBuffers, ID3D11Buffer** ppConstantBuffers )
+    void IASetInputLayout ( ID3D11InputLayout* pInputLayout )
+    void IASetVertexBuffers ( UINT StartSlot, UINT NumBuffers, ID3D11Buffer** ppVertexBuffers, UINT* pStrides, UINT* pOffsets )
+    void IASetIndexBuffer ( ID3D11Buffer* pIndexBuffer, DXGI_FORMAT Format, UINT Offset )
+    void DrawIndexedInstanced ( UINT IndexCountPerInstance, UINT InstanceCount, UINT StartIndexLocation, INT BaseVertexLocation, UINT StartInstanceLocation )
+    void DrawInstanced ( UINT VertexCountPerInstance, UINT InstanceCount, UINT StartVertexLocation, UINT StartInstanceLocation )
+    void GSSetConstantBuffers ( UINT StartSlot, UINT NumBuffers, ID3D11Buffer** ppConstantBuffers )
+    void GSSetShader ( ID3D11GeometryShader* pShader, ID3D11ClassInstance** ppClassInstances, UINT NumClassInstances )
+    void IASetPrimitiveTopology ( D3D11_PRIMITIVE_TOPOLOGY Topology )
+    void VSSetShaderResources ( UINT StartSlot, UINT NumViews, ID3D11ShaderResourceView** ppShaderResourceViews )
+    void VSSetSamplers ( UINT StartSlot, UINT NumSamplers, ID3D11SamplerState** ppSamplers )
+    void Begin ( ID3D11Asynchronous* pAsync )
+    void End ( ID3D11Asynchronous* pAsync )
+    HRESULT GetData ( ID3D11Asynchronous* pAsync, void* pData, UINT DataSize, UINT GetDataFlags )
+    void SetPredication ( ID3D11Predicate* pPredicate, BOOL PredicateValue )
+    void GSSetShaderResources ( UINT StartSlot, UINT NumViews, ID3D11ShaderResourceView** ppShaderResourceViews )
+    void GSSetSamplers ( UINT StartSlot, UINT NumSamplers, ID3D11SamplerState** ppSamplers )
+    void OMSetRenderTargets ( UINT NumViews, ID3D11RenderTargetView** ppRenderTargetViews, ID3D11DepthStencilView* pDepthStencilView )
+    void OMSetRenderTargetsAndUnorderedAccessViews ( UINT NumRTVs, ID3D11RenderTargetView** ppRenderTargetViews, ID3D11DepthStencilView* pDepthStencilView, UINT UAVStartSlot, UINT NumUAVs, ID3D11UnorderedAccessView** ppUnorderedAccessViews, UINT* pUAVInitialCounts )
+    void OMSetBlendState ( ID3D11BlendState* pBlendState, FLOAT[4] BlendFactor, UINT SampleMask )
+    void OMSetDepthStencilState ( ID3D11DepthStencilState* pDepthStencilState, UINT StencilRef )
+    void SOSetTargets ( UINT NumBuffers, ID3D11Buffer** ppSOTargets, UINT* pOffsets )
+    void DrawAuto ( )
+    void DrawIndexedInstancedIndirect ( ID3D11Buffer* pBufferForArgs, UINT AlignedByteOffsetForArgs )
+    void DrawInstancedIndirect ( ID3D11Buffer* pBufferForArgs, UINT AlignedByteOffsetForArgs )
+    void Dispatch ( UINT ThreadGroupCountX, UINT ThreadGroupCountY, UINT ThreadGroupCountZ )
+    void DispatchIndirect ( ID3D11Buffer* pBufferForArgs, UINT AlignedByteOffsetForArgs )
+    void RSSetState ( ID3D11RasterizerState* pRasterizerState )
+    void RSSetViewports ( UINT NumViewports, D3D11_VIEWPORT* pViewports )
+    void RSSetScissorRects ( UINT NumRects, D3D11_RECT* pRects )
+    void CopySubresourceRegion ( ID3D11Resource* pDstResource, UINT DstSubresource, UINT DstX, UINT DstY, UINT DstZ, ID3D11Resource* pSrcResource, UINT SrcSubresource, D3D11_BOX* pSrcBox )
+    void CopyResource ( ID3D11Resource* pDstResource, ID3D11Resource* pSrcResource )
+    void UpdateSubresource ( ID3D11Resource* pDstResource, UINT DstSubresource, D3D11_BOX* pDstBox, void* pSrcData, UINT SrcRowPitch, UINT SrcDepthPitch )
+    void CopyStructureCount ( ID3D11Buffer* pDstBuffer, UINT DstAlignedByteOffset, ID3D11UnorderedAccessView* pSrcView )
+    void ClearRenderTargetView ( ID3D11RenderTargetView* pRenderTargetView, FLOAT[4] ColorRGBA )
+    void ClearUnorderedAccessViewUint ( ID3D11UnorderedAccessView* pUnorderedAccessView, UINT[4] Values )
+    void ClearUnorderedAccessViewFloat ( ID3D11UnorderedAccessView* pUnorderedAccessView, FLOAT[4] Values )
+    void ClearDepthStencilView ( ID3D11DepthStencilView* pDepthStencilView, UINT ClearFlags, FLOAT Depth, BYTE Stencil )
+    void GenerateMips ( ID3D11ShaderResourceView* pShaderResourceView )
+    void SetResourceMinLOD ( ID3D11Resource* pResource, FLOAT MinLOD )
+    FLOAT GetResourceMinLOD ( ID3D11Resource* pResource )
+    void ResolveSubresource ( ID3D11Resource* pDstResource, UINT DstSubresource, ID3D11Resource* pSrcResource, UINT SrcSubresource, DXGI_FORMAT Format )
+    void ExecuteCommandList ( ID3D11CommandList* pCommandList, BOOL RestoreContextState )
+    void HSSetShaderResources ( UINT StartSlot, UINT NumViews, ID3D11ShaderResourceView** ppShaderResourceViews )
+    void HSSetShader ( ID3D11HullShader* pHullShader, ID3D11ClassInstance** ppClassInstances, UINT NumClassInstances )
+    void HSSetSamplers ( UINT StartSlot, UINT NumSamplers, ID3D11SamplerState** ppSamplers )
+    void HSSetConstantBuffers ( UINT StartSlot, UINT NumBuffers, ID3D11Buffer** ppConstantBuffers )
+    void DSSetShaderResources ( UINT StartSlot, UINT NumViews, ID3D11ShaderResourceView** ppShaderResourceViews )
+    void DSSetShader ( ID3D11DomainShader* pDomainShader, ID3D11ClassInstance** ppClassInstances, UINT NumClassInstances )
+    void DSSetSamplers ( UINT StartSlot, UINT NumSamplers, ID3D11SamplerState** ppSamplers )
+    void DSSetConstantBuffers ( UINT StartSlot, UINT NumBuffers, ID3D11Buffer** ppConstantBuffers )
+    void CSSetShaderResources ( UINT StartSlot, UINT NumViews, ID3D11ShaderResourceView** ppShaderResourceViews )
+    void CSSetUnorderedAccessViews ( UINT StartSlot, UINT NumUAVs, ID3D11UnorderedAccessView** ppUnorderedAccessViews, UINT* pUAVInitialCounts )
+    void CSSetShader ( ID3D11ComputeShader* pComputeShader, ID3D11ClassInstance** ppClassInstances, UINT NumClassInstances )
+    void CSSetSamplers ( UINT StartSlot, UINT NumSamplers, ID3D11SamplerState** ppSamplers )
+    void CSSetConstantBuffers ( UINT StartSlot, UINT NumBuffers, ID3D11Buffer** ppConstantBuffers )
+    void VSGetConstantBuffers ( UINT StartSlot, UINT NumBuffers, ID3D11Buffer** ppConstantBuffers )
+    void PSGetShaderResources ( UINT StartSlot, UINT NumViews, ID3D11ShaderResourceView** ppShaderResourceViews )
+    void PSGetShader ( ID3D11PixelShader** ppPixelShader, ID3D11ClassInstance** ppClassInstances, UINT* pNumClassInstances )
+    void PSGetSamplers ( UINT StartSlot, UINT NumSamplers, ID3D11SamplerState** ppSamplers )
+    void VSGetShader ( ID3D11VertexShader** ppVertexShader, ID3D11ClassInstance** ppClassInstances, UINT* pNumClassInstances )
+    void PSGetConstantBuffers ( UINT StartSlot, UINT NumBuffers, ID3D11Buffer** ppConstantBuffers )
+    void IAGetInputLayout ( ID3D11InputLayout** ppInputLayout )
+    void IAGetVertexBuffers ( UINT StartSlot, UINT NumBuffers, ID3D11Buffer** ppVertexBuffers, UINT* pStrides, UINT* pOffsets )
+    void IAGetIndexBuffer ( ID3D11Buffer** pIndexBuffer, DXGI_FORMAT* Format, UINT* Offset )
+    void GSGetConstantBuffers ( UINT StartSlot, UINT NumBuffers, ID3D11Buffer** ppConstantBuffers )
+    void GSGetShader ( ID3D11GeometryShader** ppGeometryShader, ID3D11ClassInstance** ppClassInstances, UINT* pNumClassInstances )
+    void IAGetPrimitiveTopology ( D3D11_PRIMITIVE_TOPOLOGY* pTopology )
+    void VSGetShaderResources ( UINT StartSlot, UINT NumViews, ID3D11ShaderResourceView** ppShaderResourceViews )
+    void VSGetSamplers ( UINT StartSlot, UINT NumSamplers, ID3D11SamplerState** ppSamplers )
+    void GetPredication ( ID3D11Predicate** ppPredicate, BOOL* pPredicateValue )
+    void GSGetShaderResources ( UINT StartSlot, UINT NumViews, ID3D11ShaderResourceView** ppShaderResourceViews )
+    void GSGetSamplers ( UINT StartSlot, UINT NumSamplers, ID3D11SamplerState** ppSamplers )
+    void OMGetRenderTargets ( UINT NumViews, ID3D11RenderTargetView** ppRenderTargetViews, ID3D11DepthStencilView** ppDepthStencilView )
+    void OMGetRenderTargetsAndUnorderedAccessViews ( UINT NumRTVs, ID3D11RenderTargetView** ppRenderTargetViews, ID3D11DepthStencilView** ppDepthStencilView, UINT UAVStartSlot, UINT NumUAVs, ID3D11UnorderedAccessView** ppUnorderedAccessViews )
+    void OMGetBlendState ( ID3D11BlendState** ppBlendState, FLOAT[4] BlendFactor, UINT* pSampleMask )
+    void OMGetDepthStencilState ( ID3D11DepthStencilState** ppDepthStencilState, UINT* pStencilRef )
+    void SOGetTargets ( UINT NumBuffers, ID3D11Buffer** ppSOTargets )
+    void RSGetState ( ID3D11RasterizerState** ppRasterizerState )
+    void RSGetViewports ( UINT* pNumViewports, D3D11_VIEWPORT* pViewports )
+    void RSGetScissorRects ( UINT* pNumRects, D3D11_RECT* pRects )
+    void HSGetShaderResources ( UINT StartSlot, UINT NumViews, ID3D11ShaderResourceView** ppShaderResourceViews )
+    void HSGetShader ( ID3D11HullShader** ppHullShader, ID3D11ClassInstance** ppClassInstances, UINT* pNumClassInstances )
+    void HSGetSamplers ( UINT StartSlot, UINT NumSamplers, ID3D11SamplerState** ppSamplers )
+    void HSGetConstantBuffers ( UINT StartSlot, UINT NumBuffers, ID3D11Buffer** ppConstantBuffers )
+    void DSGetShaderResources ( UINT StartSlot, UINT NumViews, ID3D11ShaderResourceView** ppShaderResourceViews )
+    void DSGetShader ( ID3D11DomainShader** ppDomainShader, ID3D11ClassInstance** ppClassInstances, UINT* pNumClassInstances )
+    void DSGetSamplers ( UINT StartSlot, UINT NumSamplers, ID3D11SamplerState** ppSamplers )
+    void DSGetConstantBuffers ( UINT StartSlot, UINT NumBuffers, ID3D11Buffer** ppConstantBuffers )
+    void CSGetShaderResources ( UINT StartSlot, UINT NumViews, ID3D11ShaderResourceView** ppShaderResourceViews )
+    void CSGetUnorderedAccessViews ( UINT StartSlot, UINT NumUAVs, ID3D11UnorderedAccessView** ppUnorderedAccessViews )
+    void CSGetShader ( ID3D11ComputeShader** ppComputeShader, ID3D11ClassInstance** ppClassInstances, UINT* pNumClassInstances )
+    void CSGetSamplers ( UINT StartSlot, UINT NumSamplers, ID3D11SamplerState** ppSamplers )
+    void CSGetConstantBuffers ( UINT StartSlot, UINT NumBuffers, ID3D11Buffer** ppConstantBuffers )
+    void ClearState ( )
+    void Flush ( )
+    D3D11_DEVICE_CONTEXT_TYPE GetType ( )
+    UINT GetContextFlags ( )
+    HRESULT FinishCommandList ( BOOL RestoreDeferredContextState, ID3D11CommandList** ppCommandList ) ;
+
+COM-INTERFACE: ID3D11Device IUnknown {db6f6ddb-ac77-4e88-8253-819df9bbf140}
+    HRESULT CreateBuffer ( D3D11_BUFFER_DESC* pDesc, D3D11_SUBRESOURCE_DATA* pInitialData, ID3D11Buffer** ppBuffer )
+    HRESULT CreateTexture1D ( D3D11_TEXTURE1D_DESC* pDesc, D3D11_SUBRESOURCE_DATA* pInitialData, ID3D11Texture1D** ppTexture1D )
+    HRESULT CreateTexture2D ( D3D11_TEXTURE2D_DESC* pDesc, D3D11_SUBRESOURCE_DATA* pInitialData, ID3D11Texture2D** ppTexture2D )
+    HRESULT CreateTexture3D ( D3D11_TEXTURE3D_DESC* pDesc, D3D11_SUBRESOURCE_DATA* pInitialData, ID3D11Texture3D** ppTexture3D )
+    HRESULT CreateShaderResourceView ( ID3D11Resource* pResource, D3D11_SHADER_RESOURCE_VIEW_DESC* pDesc, ID3D11ShaderResourceView** ppSRView )
+    HRESULT CreateUnorderedAccessView ( ID3D11Resource* pResource, D3D11_UNORDERED_ACCESS_VIEW_DESC* pDesc, ID3D11UnorderedAccessView** ppUAView )
+    HRESULT CreateRenderTargetView ( ID3D11Resource* pResource, D3D11_RENDER_TARGET_VIEW_DESC* pDesc, ID3D11RenderTargetView** ppRTView )
+    HRESULT CreateDepthStencilView ( ID3D11Resource* pResource, D3D11_DEPTH_STENCIL_VIEW_DESC* pDesc, ID3D11DepthStencilView** ppDepthStencilView )
+    HRESULT CreateInputLayout ( D3D11_INPUT_ELEMENT_DESC* pInputElementDescs, UINT NumElements, void* pShaderBytecodeWithInputSignature, SIZE_T BytecodeLength, ID3D11InputLayout** ppInputLayout )
+    HRESULT CreateVertexShader ( void* pShaderBytecode, SIZE_T BytecodeLength, ID3D11ClassLinkage* pClassLinkage, ID3D11VertexShader** ppVertexShader )
+    HRESULT CreateGeometryShader ( void* pShaderBytecode, SIZE_T BytecodeLength, ID3D11ClassLinkage* pClassLinkage, ID3D11GeometryShader** ppGeometryShader )
+    HRESULT CreateGeometryShaderWithStreamOutput ( void* pShaderBytecode, SIZE_T BytecodeLength, D3D11_SO_DECLARATION_ENTRY* pSODeclaration, UINT NumEntries, UINT* pBufferStrides, UINT NumStrides, UINT RasterizedStream, ID3D11ClassLinkage* pClassLinkage, ID3D11GeometryShader** ppGeometryShader )
+    HRESULT CreatePixelShader ( void* pShaderBytecode, SIZE_T BytecodeLength, ID3D11ClassLinkage* pClassLinkage, ID3D11PixelShader** ppPixelShader )
+    HRESULT CreateHullShader ( void* pShaderBytecode, SIZE_T BytecodeLength, ID3D11ClassLinkage* pClassLinkage, ID3D11HullShader** ppHullShader )
+    HRESULT CreateDomainShader ( void* pShaderBytecode, SIZE_T BytecodeLength, ID3D11ClassLinkage* pClassLinkage, ID3D11DomainShader** ppDomainShader )
+    HRESULT CreateComputeShader ( void* pShaderBytecode, SIZE_T BytecodeLength, ID3D11ClassLinkage* pClassLinkage, ID3D11ComputeShader** ppComputeShader )
+    HRESULT CreateClassLinkage ( ID3D11ClassLinkage** ppLinkage )
+    HRESULT CreateBlendState ( D3D11_BLEND_DESC* pBlendStateDesc, ID3D11BlendState** ppBlendState )
+    HRESULT CreateDepthStencilState ( D3D11_DEPTH_STENCIL_DESC* pDepthStencilDesc, ID3D11DepthStencilState** ppDepthStencilState )
+    HRESULT CreateRasterizerState ( D3D11_RASTERIZER_DESC* pRasterizerDesc, ID3D11RasterizerState** ppRasterizerState )
+    HRESULT CreateSamplerState ( D3D11_SAMPLER_DESC* pSamplerDesc, ID3D11SamplerState** ppSamplerState )
+    HRESULT CreateQuery ( D3D11_QUERY_DESC* pQueryDesc, ID3D11Query** ppQuery )
+    HRESULT CreatePredicate ( D3D11_QUERY_DESC* pPredicateDesc, ID3D11Predicate** ppPredicate )
+    HRESULT CreateCounter ( D3D11_COUNTER_DESC* pCounterDesc, ID3D11Counter** ppCounter )
+    HRESULT CreateDeferredContext ( UINT ContextFlags, ID3D11DeviceContext** ppDeferredContext )
+    HRESULT OpenSharedResource ( HANDLE hResource, REFIID ReturnedInterface, void** ppResource )
+    HRESULT CheckFormatSupport ( DXGI_FORMAT Format, UINT* pFormatSupport )
+    HRESULT CheckMultisampleQualityLevels ( DXGI_FORMAT Format, UINT SampleCount, UINT* pNumQualityLevels )
+    void CheckCounterInfo ( D3D11_COUNTER_INFO* pCounterInfo )
+    HRESULT CheckCounter ( D3D11_COUNTER_DESC* pDesc, D3D11_COUNTER_TYPE* pType, UINT* pActiveCounters, LPSTR szName, UINT* pNameLength, LPSTR szUnits, UINT* pUnitsLength, LPSTR szDescription, UINT* pDescriptionLength )
+    HRESULT CheckFeatureSupport ( D3D11_FEATURE Feature, void* pFeatureSupportData, UINT FeatureSupportDataSize )
+    HRESULT GetPrivateData ( REFGUID guid, UINT* pDataSize, void* pData )
+    HRESULT SetPrivateData ( REFGUID guid, UINT DataSize, void* pData )
+    HRESULT SetPrivateDataInterface ( REFGUID guid, IUnknown* pData )
+    D3D_FEATURE_LEVEL GetFeatureLevel ( )
+    UINT GetCreationFlags ( )
+    HRESULT GetDeviceRemovedReason ( )
+    void GetImmediateContext ( ID3D11DeviceContext** ppImmediateContext )
+    HRESULT SetExceptionMode ( UINT RaiseFlags )
+    UINT GetExceptionMode ( ) ;
+
+CONSTANT: D3D11_CREATE_DEVICE_SINGLETHREADED                              1
+CONSTANT: D3D11_CREATE_DEVICE_DEBUG                                       2
+CONSTANT: D3D11_CREATE_DEVICE_SWITCH_TO_REF                               4
+CONSTANT: D3D11_CREATE_DEVICE_PREVENT_INTERNAL_THREADING_OPTIMIZATIONS    8
+CONSTANT: D3D11_CREATE_DEVICE_BGRA_SUPPORT                                32
+TYPEDEF: int D3D11_CREATE_DEVICE_FLAG;
+
+CONSTANT: D3D11_SDK_VERSION 7
+
+FUNCTION: HRESULT D3D11CreateDevice (
+    IDXGIAdapter*         pAdapter,
+    D3D_DRIVER_TYPE       DriverType,
+    HMODULE               Software,
+    UINT                  Flags,
+    D3D_FEATURE_LEVEL*    pFeatureLevels,
+    UINT                  FeatureLevels,
+    UINT                  SDKVersion,
+    ID3D11Device**        ppDevice,
+    D3D_FEATURE_LEVEL*    pFeatureLevel,
+    ID3D11DeviceContext** ppImmediateContext ) ;
+
+FUNCTION: HRESULT D3D11CreateDeviceAndSwapChain (
+    IDXGIAdapter*         pAdapter,
+    D3D_DRIVER_TYPE       DriverType,
+    HMODULE               Software,
+    UINT                  Flags,
+    D3D_FEATURE_LEVEL*    pFeatureLevels,
+    UINT                  FeatureLevels,
+    UINT                  SDKVersion,
+    DXGI_SWAP_CHAIN_DESC* pSwapChainDesc,
+    IDXGISwapChain**      ppSwapChain,
+    ID3D11Device**        ppDevice,
+    D3D_FEATURE_LEVEL*    pFeatureLevel,
+    ID3D11DeviceContext** ppImmediateContext ) ;
diff --git a/basis/windows/directx/d3d11/summary.txt b/basis/windows/directx/d3d11/summary.txt
new file mode 100644 (file)
index 0000000..5b3ba35
--- /dev/null
@@ -0,0 +1 @@
+Direct3D 11 bindings. Corresponds to D3D11.h.
diff --git a/basis/windows/directx/d3d11/tags.txt b/basis/windows/directx/d3d11/tags.txt
new file mode 100644 (file)
index 0000000..2320bdd
--- /dev/null
@@ -0,0 +1,2 @@
+unportable
+bindings
diff --git a/basis/windows/directx/d3d11shader/authors.txt b/basis/windows/directx/d3d11shader/authors.txt
new file mode 100644 (file)
index 0000000..6f03a12
--- /dev/null
@@ -0,0 +1 @@
+Erik Charlebois
diff --git a/basis/windows/directx/d3d11shader/d3d11shader.factor b/basis/windows/directx/d3d11shader/d3d11shader.factor
new file mode 100644 (file)
index 0000000..beb5392
--- /dev/null
@@ -0,0 +1,182 @@
+USING: alien.syntax alien.c-types classes.struct windows.types
+windows.directx.d3d10shader windows.directx.d3d10
+windows.directx.d3d11 windows.com windows.com.syntax ;
+IN: windows.directx.d3d11shader
+
+LIBRARY: d3d11
+
+CONSTANT: D3D11_SHVER_PIXEL_SHADER    0
+CONSTANT: D3D11_SHVER_VERTEX_SHADER   1
+CONSTANT: D3D11_SHVER_GEOMETRY_SHADER 2
+CONSTANT: D3D11_SHVER_HULL_SHADER     3
+CONSTANT: D3D11_SHVER_DOMAIN_SHADER   4
+CONSTANT: D3D11_SHVER_COMPUTE_SHADER  5
+TYPEDEF: int D3D11_SHADER_VERSION_TYPE
+
+CONSTANT: D3D11_RETURN_TYPE_UNORM     1
+CONSTANT: D3D11_RETURN_TYPE_SNORM     2
+CONSTANT: D3D11_RETURN_TYPE_SINT      3
+CONSTANT: D3D11_RETURN_TYPE_UINT      4
+CONSTANT: D3D11_RETURN_TYPE_FLOAT     5
+CONSTANT: D3D11_RETURN_TYPE_MIXED     6
+CONSTANT: D3D11_RETURN_TYPE_DOUBLE    7
+CONSTANT: D3D11_RETURN_TYPE_CONTINUED 8
+TYPEDEF: int D3D11_RESOURCE_RETURN_TYPE
+
+C-ENUM: D3D11_CT_CBUFFER
+        D3D11_CT_TBUFFER
+        D3D11_CT_INTERFACE_POINTERS
+        D3D11_CT_RESOURCE_BIND_INFO ;
+TYPEDEF: int D3D11_CBUFFER_TYPE
+TYPEDEF: D3D11_CBUFFER_TYPE* LPD3D11_CBUFFER_TYPE
+
+STRUCT: D3D11_SIGNATURE_PARAMETER_DESC
+    { SemanticName    LPCSTR                          }
+    { SemanticIndex   UINT                            }
+    { Register        UINT                            }
+    { SystemValueType D3D10_NAME                      }
+    { ComponentType   D3D10_REGISTER_COMPONENT_TYPE   }
+    { Mask            BYTE                            }
+    { ReadWriteMask   BYTE                            }
+    { Stream          UINT                            } ;
+
+STRUCT: D3D11_SHADER_BUFFER_DESC
+    { Name            LPCSTR                  }
+    { Type            D3D11_CBUFFER_TYPE      }
+    { Variables       UINT                    }
+    { Size            UINT                    }
+    { uFlags          UINT                    } ;
+
+STRUCT: D3D11_SHADER_VARIABLE_DESC
+    { Name            LPCSTR         }
+    { StartOffset     UINT           }
+    { Size            UINT           }
+    { uFlags          UINT           }
+    { DefaultValue    LPVOID         }
+    { StartTexture    UINT           }
+    { TextureSize     UINT           }
+    { StartSampler    UINT           }
+    { SamplerSize     UINT           } ;
+
+STRUCT: D3D11_SHADER_TYPE_DESC
+    { Class           D3D10_SHADER_VARIABLE_CLASS    }
+    { Type            D3D10_SHADER_VARIABLE_TYPE     }
+    { Rows            UINT                           }
+    { Columns         UINT                           }
+    { Elements        UINT                           }
+    { Members         UINT                           }
+    { Offset          UINT                           }
+    { Name            LPCSTR                         } ;
+
+CONSTANT: D3D11_TESSELLATOR_DOMAIN_UNDEFINED 0
+CONSTANT: D3D11_TESSELLATOR_DOMAIN_ISOLINE   1
+CONSTANT: D3D11_TESSELLATOR_DOMAIN_TRI       2
+CONSTANT: D3D11_TESSELLATOR_DOMAIN_QUAD      3
+TYPEDEF: int D3D11_TESSELLATOR_DOMAIN
+
+CONSTANT: D3D11_TESSELLATOR_PARTITIONING_UNDEFINED       0
+CONSTANT: D3D11_TESSELLATOR_PARTITIONING_INTEGER         1
+CONSTANT: D3D11_TESSELLATOR_PARTITIONING_POW2            2
+CONSTANT: D3D11_TESSELLATOR_PARTITIONING_FRACTIONAL_ODD  3
+CONSTANT: D3D11_TESSELLATOR_PARTITIONING_FRACTIONAL_EVEN 4
+TYPEDEF: int D3D11_TESSELLATOR_PARTITIONING
+
+CONSTANT: D3D11_TESSELLATOR_OUTPUT_UNDEFINED    0
+CONSTANT: D3D11_TESSELLATOR_OUTPUT_POINT        1
+CONSTANT: D3D11_TESSELLATOR_OUTPUT_LINE         2
+CONSTANT: D3D11_TESSELLATOR_OUTPUT_TRIANGLE_CW  3
+CONSTANT: D3D11_TESSELLATOR_OUTPUT_TRIANGLE_CCW 4
+TYPEDEF: int D3D11_TESSELLATOR_OUTPUT_PRIMITIVE
+
+STRUCT: D3D11_SHADER_DESC
+    { Version                     UINT                               }
+    { Creator                     LPCSTR                             }
+    { Flags                       UINT                               }
+    { ConstantBuffers             UINT                               }
+    { BoundResources              UINT                               }
+    { InputParameters             UINT                               }
+    { OutputParameters            UINT                               }
+    { InstructionCount            UINT                               }
+    { TempRegisterCount           UINT                               }
+    { TempArrayCount              UINT                               }
+    { DefCount                    UINT                               }
+    { DclCount                    UINT                               }
+    { TextureNormalInstructions   UINT                               }
+    { TextureLoadInstructions     UINT                               }
+    { TextureCompInstructions     UINT                               }
+    { TextureBiasInstructions     UINT                               }
+    { TextureGradientInstructions UINT                               }
+    { FloatInstructionCount       UINT                               }
+    { IntInstructionCount         UINT                               }
+    { UintInstructionCount        UINT                               }
+    { StaticFlowControlCount      UINT                               }
+    { DynamicFlowControlCount     UINT                               }
+    { MacroInstructionCount       UINT                               }
+    { ArrayInstructionCount       UINT                               }
+    { CutInstructionCount         UINT                               }
+    { EmitInstructionCount        UINT                               }
+    { GSOutputTopology            D3D10_PRIMITIVE_TOPOLOGY           }
+    { GSMaxOutputVertexCount      UINT                               }
+    { InputPrimitive              D3D11_PRIMITIVE                    }
+    { PatchConstantParameters     UINT                               }
+    { cGSInstanceCount            UINT                               }
+    { cControlPoints              UINT                               }
+    { HSOutputPrimitive           D3D11_TESSELLATOR_OUTPUT_PRIMITIVE }
+    { HSPartitioning              D3D11_TESSELLATOR_PARTITIONING     }
+    { TessellatorDomain           D3D11_TESSELLATOR_DOMAIN           }
+    { cBarrierInstructions        UINT                               }
+    { cInterlockedInstructions    UINT                               }
+    { cTextureStoreInstructions   UINT                               } ;
+
+STRUCT: D3D11_SHADER_INPUT_BIND_DESC
+    { Name                        LPCSTR                        }
+    { Type                        D3D10_SHADER_INPUT_TYPE       }
+    { BindPoint                   UINT                          }
+    { BindCount                   UINT                          }
+    { uFlags                      UINT                          }
+    { ReturnType                  D3D11_RESOURCE_RETURN_TYPE    }
+    { Dimension                   D3D10_SRV_DIMENSION           }
+    { NumSamples                  UINT                          } ;
+
+COM-INTERFACE: ID3D11ShaderReflectionType f {6E6FFA6A-9BAE-4613-A51E-91652D508C21}
+    HRESULT GetDesc ( D3D11_SHADER_TYPE_DESC* pDesc )
+    ID3D11ShaderReflectionType* GetMemberTypeByIndex ( UINT Index )
+    ID3D11ShaderReflectionType* GetMemberTypeByName ( LPCSTR Name )
+    LPCSTR GetMemberTypeName ( UINT Index )
+    HRESULT IsEqual ( ID3D11ShaderReflectionType* pType )
+    ID3D11ShaderReflectionType* GetSubType ( )
+    ID3D11ShaderReflectionType* GetBaseClass ( )
+    UINT GetNumInterfaces ( )
+    ID3D11ShaderReflectionType* GetInterfaceByIndex ( UINT uIndex )
+    HRESULT IsOfType ( ID3D11ShaderReflectionType* pType )
+    HRESULT ImplementsInterface ( ID3D11ShaderReflectionType* pBase ) ;
+
+COM-INTERFACE: ID3D11ShaderReflectionVariable f {51F23923-F3E5-4BD1-91CB-606177D8DB4C}
+    HRESULT GetDesc ( D3D11_SHADER_VARIABLE_DESC* pDesc )
+    ID3D11ShaderReflectionType* GetType ( )
+    ID3D11ShaderReflectionConstantBuffer* GetBuffer ( )
+    UINT GetInterfaceSlot ( UINT uArrayIndex ) ;
+
+COM-INTERFACE: ID3D11ShaderReflectionConstantBuffer f {EB62D63D-93DD-4318-8AE8-C6F83AD371B8}
+    HRESULT GetDesc ( D3D11_SHADER_BUFFER_DESC* pDesc )
+    ID3D11ShaderReflectionVariable* GetVariableByIndex ( UINT Index )
+    ID3D11ShaderReflectionVariable* GetVariableByName ( LPCSTR Name ) ;
+
+COM-INTERFACE: ID3D11ShaderReflection IUnknown {17F27486-A342-4D10-8842-AB0874E7F670}
+    HRESULT GetDesc ( D3D11_SHADER_DESC* pDesc )
+    ID3D11ShaderReflectionConstantBuffer* GetConstantBufferByIndex ( UINT Index )
+    ID3D11ShaderReflectionConstantBuffer* GetConstantBufferByName ( LPCSTR Name )
+    HRESULT GetResourceBindingDesc ( UINT ResourceIndex, D3D11_SHADER_INPUT_BIND_DESC* pDesc )
+    HRESULT GetInputParameterDesc ( UINT ParameterIndex, D3D11_SIGNATURE_PARAMETER_DESC* pDesc )
+    HRESULT GetOutputParameterDesc ( UINT ParameterIndex, D3D11_SIGNATURE_PARAMETER_DESC* pDesc )
+    HRESULT GetPatchConstantParameterDesc ( UINT ParameterIndex, D3D11_SIGNATURE_PARAMETER_DESC* pDesc )
+    ID3D11ShaderReflectionVariable* GetVariableByName ( LPCSTR Name )
+    HRESULT GetResourceBindingDescByName ( LPCSTR Name, D3D11_SHADER_INPUT_BIND_DESC* pDesc )
+    UINT GetMovInstructionCount ( )
+    UINT GetMovcInstructionCount ( )
+    UINT GetConversionInstructionCount ( )
+    UINT GetBitwiseInstructionCount ( )
+    D3D10_PRIMITIVE GetGSInputPrimitive ( )
+    BOOL IsSampleFrequencyShader ( )
+    UINT GetNumInterfaceSlots ( )
+    HRESULT GetMinFeatureLevel ( D3D_FEATURE_LEVEL* pLevel ) ;
diff --git a/basis/windows/directx/d3d11shader/summary.txt b/basis/windows/directx/d3d11shader/summary.txt
new file mode 100644 (file)
index 0000000..53576ea
--- /dev/null
@@ -0,0 +1 @@
+Direct3D 11 bindings. Corresponds to D3D11Shader.h.
diff --git a/basis/windows/directx/d3d11shader/tags.txt b/basis/windows/directx/d3d11shader/tags.txt
new file mode 100644 (file)
index 0000000..2320bdd
--- /dev/null
@@ -0,0 +1,2 @@
+unportable
+bindings
diff --git a/basis/windows/directx/d3d9/authors.txt b/basis/windows/directx/d3d9/authors.txt
new file mode 100644 (file)
index 0000000..6f03a12
--- /dev/null
@@ -0,0 +1 @@
+Erik Charlebois
diff --git a/basis/windows/directx/d3d9/d3d9.factor b/basis/windows/directx/d3d9/d3d9.factor
new file mode 100644 (file)
index 0000000..cedfefc
--- /dev/null
@@ -0,0 +1,473 @@
+USING: alien.syntax windows.types alien.c-types windows.directx.d3d9types
+windows.com.syntax windows.com windows.directx.d3d9caps windows.ole32
+windows.kernel32 ;
+IN: windows.directx.d3d9
+
+LIBRARY: d3d9
+
+CONSTANT: DIRECT3D_VERSION         HEX: 0900
+
+CONSTANT: D3D_SDK_VERSION   32
+CONSTANT: D3D9b_SDK_VERSION 31
+
+C-TYPE: IDirect3D9
+
+FUNCTION: IDirect3D9* Direct3DCreate9 ( UINT SDKVersion ) ;
+
+FUNCTION: int D3DPERF_BeginEvent ( D3DCOLOR col, LPCWSTR wszName ) ;
+FUNCTION: int D3DPERF_EndEvent ( ) ;
+FUNCTION: void D3DPERF_SetMarker ( D3DCOLOR col, LPCWSTR wszName ) ;
+FUNCTION: void D3DPERF_SetRegion ( D3DCOLOR col, LPCWSTR wszName ) ;
+FUNCTION: BOOL D3DPERF_QueryRepeatFrame ( ) ;
+
+FUNCTION: void D3DPERF_SetOptions ( DWORD dwOptions ) ;
+FUNCTION: DWORD D3DPERF_GetStatus ( ) ;
+
+COM-INTERFACE: IDirect3D9 IUnknown {81BDCBCA-64D4-426d-AE8D-AD0147F4275C}
+    HRESULT RegisterSoftwareDevice ( void* pInitializeFunction )
+    UINT GetAdapterCount ( )
+    HRESULT GetAdapterIdentifier ( UINT Adapter, DWORD Flags, D3DADAPTER_IDENTIFIER9* pIdentifier )
+    UINT GetAdapterModeCount ( UINT Adapter, D3DFORMAT Format )
+    HRESULT EnumAdapterModes ( UINT Adapter, D3DFORMAT Format, UINT Mode, D3DDISPLAYMODE* pMode )
+    HRESULT GetAdapterDisplayMode ( UINT Adapter, D3DDISPLAYMODE* pMode )
+    HRESULT CheckDeviceType ( UINT Adapter, D3DDEVTYPE DevType, D3DFORMAT AdapterFormat, D3DFORMAT BackBufferFormat, BOOL bWindowed )
+    HRESULT CheckDeviceFormat ( UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT CheckFormat )
+    HRESULT CheckDeviceMultiSampleType ( UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SurfaceFormat, BOOL Windowed, D3DMULTISAMPLE_TYPE MultiSampleType, DWORD* pQualityLevels )
+    HRESULT CheckDepthStencilMatch ( UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, D3DFORMAT RenderTargetFormat, D3DFORMAT DepthStencilFormat )
+    HRESULT CheckDeviceFormatConversion ( UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SourceFormat, D3DFORMAT TargetFormat )
+    HRESULT GetDeviceCaps ( UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS9* pCaps )
+    HMONITOR GetAdapterMonitor ( UINT Adapter )
+    HRESULT CreateDevice ( UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DDevice9** ppReturnedDeviceInterface ) ;
+
+TYPEDEF: IDirect3D9* LPDIRECT3D9
+TYPEDEF: IDirect3D9* PDIRECT3D9
+
+C-TYPE: IDirect3DSurface9
+C-TYPE: RGNDATA
+C-TYPE: IDirect3DBaseTexture9
+C-TYPE: PALETTEENTRY
+C-TYPE: IDirect3DVertexBuffer9
+C-TYPE: IDirect3DVertexDeclaration9
+C-TYPE: IDirect3DVertexShader9
+C-TYPE: IDirect3DIndexBuffer9
+C-TYPE: IDirect3DPixelShader9
+
+COM-INTERFACE: IDirect3DDevice9 IUnknown {D0223B96-BF7A-43fd-92BD-A43B0D82B9EB}
+    HRESULT TestCooperativeLevel ( )
+    UINT GetAvailableTextureMem ( )
+    HRESULT EvictManagedResources ( )
+    HRESULT GetDirect3D ( IDirect3D9** ppD3D9 )
+    HRESULT GetDeviceCaps ( D3DCAPS9* pCaps )
+    HRESULT GetDisplayMode ( UINT iSwapChain, D3DDISPLAYMODE* pMode )
+    HRESULT GetCreationParameters ( D3DDEVICE_CREATION_PARAMETERS *pParameters )
+    HRESULT SetCursorProperties ( UINT XHotSpot, UINT YHotSpot, IDirect3DSurface9* pCursorBitmap )
+    void SetCursorPosition ( int X, int Y, DWORD Flags )
+    BOOL ShowCursor ( BOOL bShow )
+    HRESULT CreateAdditionalSwapChain ( D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DSwapChain9** pSwapChain )
+    HRESULT GetSwapChain ( UINT iSwapChain, IDirect3DSwapChain9** pSwapChain )
+    UINT GetNumberOfSwapChains ( )
+    HRESULT Reset ( D3DPRESENT_PARAMETERS* pPresentationParameters )
+    HRESULT Present ( RECT* pSourceRect, RECT* pDestRect, HWND hDestWindowOverride, RGNDATA* pDirtyRegion )
+    HRESULT GetBackBuffer ( UINT iSwapChain, UINT iBackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface9** ppBackBuffer )
+    HRESULT GetRasterStatus ( UINT iSwapChain, D3DRASTER_STATUS* pRasterStatus )
+    HRESULT SetDialogBoxMode ( BOOL bEnableDialogs )
+    void SetGammaRamp ( UINT iSwapChain, DWORD Flags, D3DGAMMARAMP* pRamp )
+    void GetGammaRamp ( UINT iSwapChain, D3DGAMMARAMP* pRamp )
+    HRESULT CreateTexture ( UINT Width, UINT Height, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DTexture9** ppTexture, HANDLE* pSharedHandle )
+    HRESULT CreateVolumeTexture ( UINT Width, UINT Height, UINT Depth, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DVolumeTexture9** ppVolumeTexture, HANDLE* pSharedHandle )
+    HRESULT CreateCubeTexture ( UINT EdgeLength, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DCubeTexture9** ppCubeTexture, HANDLE* pSharedHandle )
+    HRESULT CreateVertexBuffer ( UINT Length, DWORD Usage, DWORD FVF, D3DPOOL Pool, IDirect3DVertexBuffer9** ppVertexBuffer, HANDLE* pSharedHandle )
+    HRESULT CreateIndexBuffer ( UINT Length, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DIndexBuffer9** ppIndexBuffer, HANDLE* pSharedHandle )
+    HRESULT CreateRenderTarget ( UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Lockable, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle )
+    HRESULT CreateDepthStencilSurface ( UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Discard, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle )
+    HRESULT UpdateSurface ( IDirect3DSurface9* pSourceSurface, RECT* pSourceRect, IDirect3DSurface9* pDestinationSurface, POINT* pDestPoint )
+    HRESULT UpdateTexture ( IDirect3DBaseTexture9* pSourceTexture, IDirect3DBaseTexture9* pDestinationTexture )
+    HRESULT GetRenderTargetData ( IDirect3DSurface9* pRenderTarget, IDirect3DSurface9* pDestSurface )
+    HRESULT GetFrontBufferData ( UINT iSwapChain, IDirect3DSurface9* pDestSurface )
+    HRESULT StretchRect ( IDirect3DSurface9* pSourceSurface, RECT* pSourceRect, IDirect3DSurface9* pDestSurface, RECT* pDestRect, D3DTEXTUREFILTERTYPE Filter )
+    HRESULT ColorFill ( IDirect3DSurface9* pSurface, RECT* pRect, D3DCOLOR color )
+    HRESULT CreateOffscreenPlainSurface ( UINT Width, UINT Height, D3DFORMAT Format, D3DPOOL Pool, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle )
+    HRESULT SetRenderTarget ( DWORD RenderTargetIndex, IDirect3DSurface9* pRenderTarget )
+    HRESULT GetRenderTarget ( DWORD RenderTargetIndex, IDirect3DSurface9** ppRenderTarget )
+    HRESULT SetDepthStencilSurface ( IDirect3DSurface9* pNewZStencil )
+    HRESULT GetDepthStencilSurface ( IDirect3DSurface9** ppZStencilSurface )
+    HRESULT BeginScene ( )
+    HRESULT EndScene ( )
+    HRESULT Clear ( DWORD Count, D3DRECT* pRects, DWORD Flags, D3DCOLOR Color, float Z, DWORD Stencil )
+    HRESULT SetTransform ( D3DTRANSFORMSTATETYPE State, D3DMATRIX* pMatrix )
+    HRESULT GetTransform ( D3DTRANSFORMSTATETYPE State, D3DMATRIX* pMatrix )
+    HRESULT MultiplyTransform ( D3DTRANSFORMSTATETYPE, D3DMATRIX* )
+    HRESULT SetViewport ( D3DVIEWPORT9* pViewport )
+    HRESULT GetViewport ( D3DVIEWPORT9* pViewport )
+    HRESULT SetMaterial ( D3DMATERIAL9* pMaterial )
+    HRESULT GetMaterial ( D3DMATERIAL9* pMaterial )
+    HRESULT SetLight ( DWORD Index, D3DLIGHT9* l )
+    HRESULT GetLight ( DWORD Index, D3DLIGHT9* l )
+    HRESULT LightEnable ( DWORD Index, BOOL Enable )
+    HRESULT GetLightEnable ( DWORD Index, BOOL* pEnable )
+    HRESULT SetClipPlane ( DWORD Index, float* pPlane )
+    HRESULT GetClipPlane ( DWORD Index, float* pPlane )
+    HRESULT SetRenderState ( D3DRENDERSTATETYPE State, DWORD Value )
+    HRESULT GetRenderState ( D3DRENDERSTATETYPE State, DWORD* pValue )
+    HRESULT CreateStateBlock ( D3DSTATEBLOCKTYPE Type, IDirect3DStateBlock9** ppSB )
+    HRESULT BeginStateBlock ( )
+    HRESULT EndStateBlock ( IDirect3DStateBlock9** ppSB )
+    HRESULT SetClipStatus ( D3DCLIPSTATUS9* pClipStatus )
+    HRESULT GetClipStatus ( D3DCLIPSTATUS9* pClipStatus )
+    HRESULT GetTexture ( DWORD Stage, IDirect3DBaseTexture9** ppTexture )
+    HRESULT SetTexture ( DWORD Stage, IDirect3DBaseTexture9* pTexture )
+    HRESULT GetTextureStageState ( DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD* pValue )
+    HRESULT SetTextureStageState ( DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value )
+    HRESULT GetSamplerState ( DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD* pValue )
+    HRESULT SetSamplerState ( DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD Value )
+    HRESULT ValidateDevice ( DWORD* pNumPasses )
+    HRESULT SetPaletteEntries ( UINT PaletteNumber, PALETTEENTRY* pEntries )
+    HRESULT GetPaletteEntries ( UINT PaletteNumber, PALETTEENTRY* pEntries )
+    HRESULT SetCurrentTexturePalette ( UINT PaletteNumber )
+    HRESULT GetCurrentTexturePalette ( UINT *PaletteNumber )
+    HRESULT SetScissorRect ( RECT* pRect )
+    HRESULT GetScissorRect ( RECT* pRect )
+    HRESULT SetSoftwareVertexProcessing ( BOOL bSoftware )
+    BOOL GetSoftwareVertexProcessing ( )
+    HRESULT SetNPatchMode ( float nSegments )
+    float GetNPatchMode ( )
+    HRESULT DrawPrimitive ( D3DPRIMITIVETYPE PrimitiveType, UINT StartVertex, UINT PrimitiveCount )
+    HRESULT DrawIndexedPrimitive ( D3DPRIMITIVETYPE x, INT BaseVertexIndex, UINT MinVertexIndex, UINT NumVertices, UINT startIndex, UINT primCount )
+    HRESULT DrawPrimitiveUP ( D3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount, void* pVertexStreamZeroData, UINT VertexStreamZeroStride )
+    HRESULT DrawIndexedPrimitiveUP ( D3DPRIMITIVETYPE PrimitiveType, UINT MinVertexIndex, UINT NumVertices, UINT PrimitiveCount, void* pIndexData, D3DFORMAT IndexDataFormat, void* pVertexStreamZeroData, UINT VertexStreamZeroStride )
+    HRESULT ProcessVertices ( UINT SrcStartIndex, UINT DestIndex, UINT VertexCount, IDirect3DVertexBuffer9* pDestBuffer, IDirect3DVertexDeclaration9* pVertexDecl, DWORD Flags )
+    HRESULT CreateVertexDeclaration ( D3DVERTEXELEMENT9* pVertexElements, IDirect3DVertexDeclaration9** ppDecl )
+    HRESULT SetVertexDeclaration ( IDirect3DVertexDeclaration9* pDecl )
+    HRESULT GetVertexDeclaration ( IDirect3DVertexDeclaration9** ppDecl )
+    HRESULT SetFVF ( DWORD FVF )
+    HRESULT GetFVF ( DWORD* pFVF )
+    HRESULT CreateVertexShader ( DWORD* pFunction, IDirect3DVertexShader9** ppShader )
+    HRESULT SetVertexShader ( IDirect3DVertexShader9* pShader )
+    HRESULT GetVertexShader ( IDirect3DVertexShader9** ppShader )
+    HRESULT SetVertexShaderConstantF ( UINT StartRegister, float* pConstantData, UINT Vector4fCount )
+    HRESULT GetVertexShaderConstantF ( UINT StartRegister, float* pConstantData, UINT Vector4fCount )
+    HRESULT SetVertexShaderConstantI ( UINT StartRegister, int* pConstantData, UINT Vector4iCount )
+    HRESULT GetVertexShaderConstantI ( UINT StartRegister, int* pConstantData, UINT Vector4iCount )
+    HRESULT SetVertexShaderConstantB ( UINT StartRegister, BOOL* pConstantData, UINT  BoolCount )
+    HRESULT GetVertexShaderConstantB ( UINT StartRegister, BOOL* pConstantData, UINT BoolCount )
+    HRESULT SetStreamSource ( UINT StreamNumber, IDirect3DVertexBuffer9* pStreamData, UINT OffsetInBytes, UINT Stride )
+    HRESULT GetStreamSource ( UINT StreamNumber, IDirect3DVertexBuffer9** ppStreamData, UINT* pOffsetInBytes, UINT* pStride )
+    HRESULT SetStreamSourceFreq ( UINT StreamNumber, UINT Setting )
+    HRESULT GetStreamSourceFreq ( UINT StreamNumber, UINT* pSetting )
+    HRESULT SetIndices ( IDirect3DIndexBuffer9* pIndexData )
+    HRESULT GetIndices ( IDirect3DIndexBuffer9** ppIndexData )
+    HRESULT CreatePixelShader ( DWORD* pFunction, IDirect3DPixelShader9** ppShader )
+    HRESULT SetPixelShader ( IDirect3DPixelShader9* pShader )
+    HRESULT GetPixelShader ( IDirect3DPixelShader9** ppShader )
+    HRESULT SetPixelShaderConstantF ( UINT StartRegister, float* pConstantData, UINT Vector4fCount )
+    HRESULT GetPixelShaderConstantF ( UINT StartRegister, float* pConstantData, UINT Vector4fCount )
+    HRESULT SetPixelShaderConstantI ( UINT StartRegister, int* pConstantData, UINT Vector4iCount )
+    HRESULT GetPixelShaderConstantI ( UINT StartRegister, int* pConstantData, UINT Vector4iCount )
+    HRESULT SetPixelShaderConstantB ( UINT StartRegister, BOOL* pConstantData, UINT  BoolCount )
+    HRESULT GetPixelShaderConstantB ( UINT StartRegister, BOOL* pConstantData, UINT BoolCount )
+    HRESULT DrawRectPatch ( UINT Handle, float* pNumSegs, D3DRECTPATCH_INFO* pRectPatchInfo )
+    HRESULT DrawTriPatch ( UINT Handle, float* pNumSegs, D3DTRIPATCH_INFO* pTriPatchInfo )
+    HRESULT DeletePatch ( UINT Handle )
+    HRESULT CreateQuery ( D3DQUERYTYPE Type, IDirect3DQuery9** ppQuery ) ;
+
+TYPEDEF: IDirect3DDevice9* LPDIRECT3DDEVICE9
+TYPEDEF: IDirect3DDevice9* PDIRECT3DDEVICE9
+
+COM-INTERFACE: IDirect3DStateBlock9 IUnknown {B07C4FE5-310D-4ba8-A23C-4F0F206F218B}
+    HRESULT GetDevice ( IDirect3DDevice9** ppDevice )
+    HRESULT Capture ( )
+    HRESULT Apply ( ) ;
+
+COM-INTERFACE: IDirect3DSwapChain9 IUnknown {794950F2-ADFC-458a-905E-10A10B0B503B}
+    HRESULT Present ( RECT* pSourceRect, RECT* pDestRect, HWND hDestWindowOverride, RGNDATA* pDirtyRegion, DWORD dwFlags )
+    HRESULT GetFrontBufferData ( IDirect3DSurface9* pDestSurface )
+    HRESULT GetBackBuffer ( UINT iBackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface9** ppBackBuffer )
+    HRESULT GetRasterStatus ( D3DRASTER_STATUS* pRasterStatus )
+    HRESULT GetDisplayMode ( D3DDISPLAYMODE* pMode )
+    HRESULT GetDevice ( IDirect3DDevice9** ppDevice )
+    HRESULT GetPresentParameters ( D3DPRESENT_PARAMETERS* pPresentationParameters ) ;
+
+TYPEDEF: IDirect3DSwapChain9* LPDIRECT3DSWAPCHAIN9
+TYPEDEF: IDirect3DSwapChain9* PDIRECT3DSWAPCHAIN9
+
+COM-INTERFACE: IDirect3DResource9 IUnknown {05EEC05D-8F7D-4362-B999-D1BAF357C704}
+    HRESULT GetDevice ( IDirect3DDevice9** ppDevice )
+    HRESULT SetPrivateData ( REFGUID refguid, void* pData, DWORD SizeOfData, DWORD Flags )
+    HRESULT GetPrivateData ( REFGUID refguid, void* pData, DWORD* pSizeOfData )
+    HRESULT FreePrivateData ( REFGUID refguid )
+    DWORD SetPriority ( DWORD PriorityNew )
+    DWORD GetPriority ( )
+    void PreLoad ( )
+    D3DRESOURCETYPE GetType ( ) ;
+
+TYPEDEF: IDirect3DResource9* LPDIRECT3DRESOURCE9
+TYPEDEF: IDirect3DResource9* PDIRECT3DRESOURCE9
+
+COM-INTERFACE: IDirect3DVertexDeclaration9 IUnknown {DD13C59C-36FA-4098-A8FB-C7ED39DC8546}
+    HRESULT GetDevice ( IDirect3DDevice9** ppDevice )
+    HRESULT GetDeclaration ( D3DVERTEXELEMENT9* pElement, UINT* pNumElements ) ;
+
+TYPEDEF: IDirect3DVertexDeclaration9* LPDIRECT3DVERTEXDECLARATION9
+TYPEDEF: IDirect3DVertexDeclaration9* PDIRECT3DVERTEXDECLARATION9
+
+COM-INTERFACE: IDirect3DVertexShader9 IUnknown {EFC5557E-6265-4613-8A94-43857889EB36}
+    HRESULT GetDevice ( IDirect3DDevice9** ppDevice )
+    HRESULT GetFunction ( void* x, UINT* pSizeOfData ) ;
+
+TYPEDEF: IDirect3DVertexShader9* LPDIRECT3DVERTEXSHADER9
+TYPEDEF: IDirect3DVertexShader9* PDIRECT3DVERTEXSHADER9
+
+COM-INTERFACE: IDirect3DPixelShader9 IUnknown {6D3BDBDC-5B02-4415-B852-CE5E8BCCB289}
+    HRESULT GetDevice ( IDirect3DDevice9** ppDevice )
+    HRESULT GetFunction ( void* x, UINT* pSizeOfData ) ;
+
+TYPEDEF: IDirect3DPixelShader9* LPDIRECT3DPIXELSHADER9
+TYPEDEF: IDirect3DPixelShader9* PDIRECT3DPIXELSHADER9
+
+COM-INTERFACE: IDirect3DBaseTexture9 IDirect3DResource9 {580CA87E-1D3C-4d54-991D-B7D3E3C298CE}
+    DWORD SetLOD ( DWORD LODNew )
+    DWORD GetLOD ( )
+    DWORD GetLevelCount ( )
+    HRESULT SetAutoGenFilterType ( D3DTEXTUREFILTERTYPE FilterType )
+    D3DTEXTUREFILTERTYPE GetAutoGenFilterType ( )
+    void GenerateMipSubLevels ( ) ;
+
+TYPEDEF: IDirect3DBaseTexture9* LPDIRECT3DBASETEXTURE9
+TYPEDEF: IDirect3DBaseTexture9* PDIRECT3DBASETEXTURE9
+
+COM-INTERFACE: IDirect3DTexture9 IDirect3DBaseTexture9 {85C31227-3DE5-4f00-9B3A-F11AC38C18B5}
+    HRESULT GetLevelDesc ( UINT Level, D3DSURFACE_DESC* pDesc )
+    HRESULT GetSurfaceLevel ( UINT Level, IDirect3DSurface9** ppSurfaceLevel )
+    HRESULT LockRect ( UINT Level, D3DLOCKED_RECT* pLockedRect, RECT* pRect, DWORD Flags )
+    HRESULT UnlockRect ( UINT Level ) ;
+    
+TYPEDEF: IDirect3DTexture9* LPDIRECT3DTEXTURE9
+TYPEDEF: IDirect3DTexture9* PDIRECT3DTEXTURE9
+
+COM-INTERFACE: IDirect3DVolumeTexture9 IDirect3DBaseTexture9 {2518526C-E789-4111-A7B9-47EF328D13E6}
+    HRESULT GetLevelDesc ( UINT Level, D3DVOLUME_DESC* pDesc )
+    HRESULT GetVolumeLevel ( UINT Level, IDirect3DVolume9** ppVolumeLevel )
+    HRESULT LockBox ( UINT Level, D3DLOCKED_BOX* pLockedVolume, D3DBOX* pBox, DWORD Flags )
+    HRESULT UnlockBox ( UINT Level )
+    HRESULT AddDirtyBox ( D3DBOX* pDirtyBox ) ;
+
+TYPEDEF: IDirect3DVolumeTexture9* LPDIRECT3DVOLUMETEXTURE9
+TYPEDEF: IDirect3DVolumeTexture9* PDIRECT3DVOLUMETEXTURE9
+
+COM-INTERFACE: IDirect3DCubeTexture9 IDirect3DBaseTexture9 {FFF32F81-D953-473a-9223-93D652ABA93F}
+    HRESULT GetLevelDesc ( UINT Level, D3DSURFACE_DESC* pDesc )
+    HRESULT GetCubeMapSurface ( D3DCUBEMAP_FACES FaceType, UINT Level, IDirect3DSurface9** ppCubeMapSurface )
+    HRESULT LockRect ( D3DCUBEMAP_FACES FaceType, UINT Level, D3DLOCKED_RECT* pLockedRect, RECT* pRect, DWORD Flags )
+    HRESULT UnlockRect ( D3DCUBEMAP_FACES FaceType, UINT Level )
+    HRESULT AddDirtyRect ( D3DCUBEMAP_FACES FaceType, RECT* pDirtyRect ) ;
+
+TYPEDEF: IDirect3DCubeTexture9* LPDIRECT3DCUBETEXTURE9
+TYPEDEF: IDirect3DCubeTexture9* PDIRECT3DCUBETEXTURE9
+
+COM-INTERFACE: IDirect3DVertexBuffer9 IDirect3DResource9 {B64BB1B5-FD70-4df6-BF91-19D0A12455E3}
+    HRESULT Lock ( UINT OffsetToLock, UINT SizeToLock, void** ppbData, DWORD Flags )
+    HRESULT Unlock ( )
+    HRESULT GetDesc ( D3DVERTEXBUFFER_DESC* pDesc ) ;
+
+TYPEDEF: IDirect3DVertexBuffer9* LPDIRECT3DVERTEXBUFFER9
+TYPEDEF: IDirect3DVertexBuffer9* PDIRECT3DVERTEXBUFFER9
+
+COM-INTERFACE: IDirect3DIndexBuffer9 IDirect3DResource9 {7C9DD65E-D3F7-4529-ACEE-785830ACDE35}
+    HRESULT Lock ( UINT OffsetToLock, UINT SizeToLock, void** ppbData, DWORD Flags )
+    HRESULT Unlock ( )
+    HRESULT GetDesc ( D3DINDEXBUFFER_DESC* pDesc ) ;
+
+TYPEDEF: IDirect3DIndexBuffer9* LPDIRECT3DINDEXBUFFER9
+TYPEDEF: IDirect3DIndexBuffer9* PDIRECT3DINDEXBUFFER9
+
+COM-INTERFACE: IDirect3DSurface9 IDirect3DResource9 {0CFBAF3A-9FF6-429a-99B3-A2796AF8B89B}
+    HRESULT GetContainer ( REFIID riid, void** ppContainer )
+    HRESULT GetDesc ( D3DSURFACE_DESC* pDesc )
+    HRESULT LockRect ( D3DLOCKED_RECT* pLockedRect, RECT* pRect, DWORD Flags )
+    HRESULT UnlockRect ( )
+    HRESULT GetDC ( HDC* phdc )
+    HRESULT ReleaseDC ( HDC hdc ) ;
+
+TYPEDEF: IDirect3DSurface9* LPDIRECT3DSURFACE9
+TYPEDEF: IDirect3DSurface9* PDIRECT3DSURFACE9
+
+COM-INTERFACE: IDirect3DVolume9 IUnknown {24F416E6-1F67-4aa7-B88E-D33F6F3128A1}
+    HRESULT GetDevice ( IDirect3DDevice9** ppDevice )
+    HRESULT SetPrivateData ( REFGUID refguid, void* pData, DWORD SizeOfData, DWORD Flags )
+    HRESULT GetPrivateData ( REFGUID refguid, void* pData, DWORD* pSizeOfData )
+    HRESULT FreePrivateData ( REFGUID refguid )
+    HRESULT GetContainer ( REFIID riid, void** ppContainer )
+    HRESULT GetDesc ( D3DVOLUME_DESC *pDesc )
+    HRESULT LockBox ( D3DLOCKED_BOX* pLockedVolume, D3DBOX* pBox, DWORD Flags )
+    HRESULT UnlockBox ( ) ;
+
+TYPEDEF: IDirect3DVolume9* LPDIRECT3DVOLUME9
+TYPEDEF: IDirect3DVolume9* PDIRECT3DVOLUME9
+
+COM-INTERFACE: IDirect3DQuery9 IUnknown {d9771460-a695-4f26-bbd3-27b840b541cc}
+    HRESULT GetDevice ( IDirect3DDevice9** ppDevice )
+    D3DQUERYTYPE GetType ( )
+    DWORD GetDataSize ( )
+    HRESULT Issue ( DWORD dwIssueFlags )
+    HRESULT GetData ( void* pData, DWORD dwSize, DWORD dwGetDataFlags ) ;
+
+TYPEDEF: IDirect3DQuery9* LPDIRECT3DQUERY9
+TYPEDEF: IDirect3DQuery9* PDIRECT3DQUERY9
+
+CONSTANT: D3DSPD_IUNKNOWN                         HEX: 00000001
+
+CONSTANT: D3DCREATE_FPU_PRESERVE                  HEX: 00000002
+CONSTANT: D3DCREATE_MULTITHREADED                 HEX: 00000004
+
+CONSTANT: D3DCREATE_PUREDEVICE                    HEX: 00000010
+CONSTANT: D3DCREATE_SOFTWARE_VERTEXPROCESSING     HEX: 00000020
+CONSTANT: D3DCREATE_HARDWARE_VERTEXPROCESSING     HEX: 00000040
+CONSTANT: D3DCREATE_MIXED_VERTEXPROCESSING        HEX: 00000080
+
+CONSTANT: D3DCREATE_DISABLE_DRIVER_MANAGEMENT     HEX: 00000100
+CONSTANT: D3DCREATE_ADAPTERGROUP_DEVICE           HEX: 00000200
+CONSTANT: D3DCREATE_DISABLE_DRIVER_MANAGEMENT_EX  HEX: 00000400
+
+CONSTANT: D3DCREATE_NOWINDOWCHANGES               HEX: 00000800
+
+CONSTANT: D3DCREATE_DISABLE_PSGP_THREADING        HEX: 00002000
+CONSTANT: D3DCREATE_ENABLE_PRESENTSTATS           HEX: 00004000
+CONSTANT: D3DCREATE_DISABLE_PRINTSCREEN           HEX: 00008000
+CONSTANT: D3DCREATE_SCREENSAVER                   HEX: 10000000
+
+CONSTANT: D3DADAPTER_DEFAULT                     0
+CONSTANT: D3DENUM_WHQL_LEVEL                     2
+CONSTANT: D3DENUM_NO_DRIVERVERSION               4
+CONSTANT: D3DPRESENT_BACK_BUFFERS_MAX            3
+CONSTANT: D3DPRESENT_BACK_BUFFERS_MAX_EX         30
+
+CONSTANT: D3DSGR_NO_CALIBRATION                  HEX: 00000000
+CONSTANT: D3DSGR_CALIBRATE                       HEX: 00000001
+
+CONSTANT: D3DCURSOR_IMMEDIATE_UPDATE             HEX: 00000001
+
+CONSTANT: D3DPRESENT_DONOTWAIT                   HEX: 00000001
+CONSTANT: D3DPRESENT_LINEAR_CONTENT              HEX: 00000002
+
+CONSTANT: D3DPRESENT_DONOTFLIP                   HEX: 00000004
+CONSTANT: D3DPRESENT_FLIPRESTART                 HEX: 00000008
+CONSTANT: D3DPRESENT_VIDEO_RESTRICT_TO_MONITOR   HEX: 00000010
+CONSTANT: D3DPRESENT_UPDATEOVERLAYONLY           HEX: 00000020
+CONSTANT: D3DPRESENT_HIDEOVERLAY                 HEX: 00000040
+CONSTANT: D3DPRESENT_UPDATECOLORKEY              HEX: 00000080
+CONSTANT: D3DPRESENT_FORCEIMMEDIATE              HEX: 00000100
+
+: D3D_OK ( -- n ) S_OK ; inline
+
+CONSTANT: D3DERR_WRONGTEXTUREFORMAT               HEX: 88760818
+CONSTANT: D3DERR_UNSUPPORTEDCOLOROPERATION        HEX: 88760819
+CONSTANT: D3DERR_UNSUPPORTEDCOLORARG              HEX: 8876081A
+CONSTANT: D3DERR_UNSUPPORTEDALPHAOPERATION        HEX: 8876081B
+CONSTANT: D3DERR_UNSUPPORTEDALPHAARG              HEX: 8876081C
+CONSTANT: D3DERR_TOOMANYOPERATIONS                HEX: 8876081D
+CONSTANT: D3DERR_CONFLICTINGTEXTUREFILTER         HEX: 8876081E
+CONSTANT: D3DERR_UNSUPPORTEDFACTORVALUE           HEX: 8876081F
+CONSTANT: D3DERR_CONFLICTINGRENDERSTATE           HEX: 88760820
+CONSTANT: D3DERR_UNSUPPORTEDTEXTUREFILTER         HEX: 88760821
+CONSTANT: D3DERR_CONFLICTINGTEXTUREPALETTE        HEX: 88760825
+CONSTANT: D3DERR_DRIVERINTERNALERROR              HEX: 88760826
+CONSTANT: D3DERR_NOTFOUND                         HEX: 88760866
+CONSTANT: D3DERR_MOREDATA                         HEX: 88760867
+CONSTANT: D3DERR_DEVICELOST                       HEX: 88760868
+CONSTANT: D3DERR_DEVICENOTRESET                   HEX: 88760869
+CONSTANT: D3DERR_NOTAVAILABLE                     HEX: 8876086A
+CONSTANT: D3DERR_OUTOFVIDEOMEMORY                 HEX: 8876017C
+CONSTANT: D3DERR_INVALIDDEVICE                    HEX: 8876086B
+CONSTANT: D3DERR_INVALIDCALL                      HEX: 8876086C
+CONSTANT: D3DERR_DRIVERINVALIDCALL                HEX: 8876086D
+CONSTANT: D3DERR_WASSTILLDRAWING                  HEX: 8876021C
+CONSTANT: D3DOK_NOAUTOGEN                         HEX: 0876086F
+CONSTANT: D3DERR_DEVICEREMOVED                    HEX: 88760870
+CONSTANT: S_NOT_RESIDENT                          HEX: 08760875
+CONSTANT: S_RESIDENT_IN_SHARED_MEMORY             HEX: 08760876
+CONSTANT: S_PRESENT_MODE_CHANGED                  HEX: 08760877
+CONSTANT: S_PRESENT_OCCLUDED                      HEX: 08760878
+CONSTANT: D3DERR_DEVICEHUNG                       HEX: 88760874
+CONSTANT: D3DERR_UNSUPPORTEDOVERLAY               HEX: 8876087C
+CONSTANT: D3DERR_UNSUPPORTEDOVERLAYFORMAT         HEX: 8876087D
+CONSTANT: D3DERR_CANNOTPROTECTCONTENT             HEX: 8876087E
+CONSTANT: D3DERR_UNSUPPORTEDCRYPTO                HEX: 8876087F
+CONSTANT: D3DERR_PRESENT_STATISTICS_DISJOINT      HEX: 88760884
+
+FUNCTION: HRESULT Direct3DCreate9Ex ( UINT SDKVersion, IDirect3D9Ex** out ) ;
+
+COM-INTERFACE: IDirect3D9Ex IDirect3D9 {02177241-69FC-400C-8FF1-93A44DF6861D}
+    UINT GetAdapterModeCountEx ( UINT Adapter, D3DDISPLAYMODEFILTER* pFilter  )
+    HRESULT EnumAdapterModesEx ( UINT Adapter, D3DDISPLAYMODEFILTER* pFilter, UINT Mode, D3DDISPLAYMODEEX* pMode )
+    HRESULT GetAdapterDisplayModeEx ( UINT Adapter, D3DDISPLAYMODEEX* pMode, D3DDISPLAYROTATION* pRotation )
+    HRESULT CreateDeviceEx ( UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS* pPresentationParameters, D3DDISPLAYMODEEX* pFullscreenDisplayMode, IDirect3DDevice9Ex** ppReturnedDeviceInterface )
+    HRESULT GetAdapterLUID ( UINT Adapter, LUID* pLUID ) ;
+
+TYPEDEF: IDirect3D9Ex* LPDIRECT3D9EX
+TYPEDEF: IDirect3D9Ex* PDIRECT3D9EX
+
+COM-INTERFACE: IDirect3DDevice9Ex IDirect3DDevice9 {B18B10CE-2649-405a-870F-95F777D4313A}
+    HRESULT SetConvolutionMonoKernel ( UINT width, UINT height, float* rows, float* columns )
+    HRESULT ComposeRects ( IDirect3DSurface9* pSrc, IDirect3DSurface9* pDst, IDirect3DVertexBuffer9* pSrcRectDescs, UINT NumRects, IDirect3DVertexBuffer9* pDstRectDescs, D3DCOMPOSERECTSOP Operation, int Xoffset, int Yoffset )
+    HRESULT PresentEx ( RECT* pSourceRect, RECT* pDestRect, HWND hDestWindowOverride, RGNDATA* pDirtyRegion, DWORD dwFlags )
+    HRESULT GetGPUThreadPriority ( INT* pPriority )
+    HRESULT SetGPUThreadPriority ( INT Priority )
+    HRESULT WaitForVBlank ( UINT iSwapChain )
+    HRESULT CheckResourceResidency ( IDirect3DResource9** pResourceArray, UINT32 NumResources )
+    HRESULT SetMaximumFrameLatency ( UINT MaxLatency )
+    HRESULT GetMaximumFrameLatency ( UINT* pMaxLatency )
+    HRESULT CheckDeviceState ( HWND hDestinationWindow )
+    HRESULT CreateRenderTargetEx ( UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Lockable, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle, DWORD Usage )
+    HRESULT CreateOffscreenPlainSurfaceEx ( UINT Width, UINT Height, D3DFORMAT Format, D3DPOOL Pool, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle, DWORD Usage )
+    HRESULT CreateDepthStencilSurfaceEx ( UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Discard, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle, DWORD Usage )
+    HRESULT ResetEx ( D3DPRESENT_PARAMETERS* pPresentationParameters, D3DDISPLAYMODEEX *pFullscreenDisplayMode )
+    HRESULT GetDisplayModeEx ( UINT iSwapChain, D3DDISPLAYMODEEX* pMode, D3DDISPLAYROTATION* pRotation ) ;
+
+TYPEDEF: IDirect3DDevice9Ex* LPDIRECT3DDEVICE9EX
+TYPEDEF: IDirect3DDevice9Ex* PDIRECT3DDEVICE9EX
+
+COM-INTERFACE: IDirect3DSwapChain9Ex IDirect3DSwapChain9 {91886CAF-1C3D-4d2e-A0AB-3E4C7D8D3303}
+    HRESULT GetLastPresentCount ( UINT* pLastPresentCount )
+    HRESULT GetPresentStats ( D3DPRESENTSTATS* pPresentationStatistics )
+    HRESULT GetDisplayModeEx ( D3DDISPLAYMODEEX* pMode, D3DDISPLAYROTATION* pRotation ) ;
+
+TYPEDEF: IDirect3DSwapChain9Ex* LPDIRECT3DSWAPCHAIN9EX
+TYPEDEF: IDirect3DSwapChain9Ex* PDIRECT3DSWAPCHAIN9EX
+
+COM-INTERFACE: IDirect3D9ExOverlayExtension IUnknown {187aeb13-aaf5-4c59-876d-e059088c0df8}
+    HRESULT CheckDeviceOverlayType ( UINT Adapter, D3DDEVTYPE DevType, UINT OverlayWidth, UINT OverlayHeight, D3DFORMAT OverlayFormat, D3DDISPLAYMODEEX* pDisplayMode, D3DDISPLAYROTATION DisplayRotation, D3DOVERLAYCAPS* pOverlayCaps ) ;
+
+TYPEDEF: IDirect3D9ExOverlayExtension* LPDIRECT3D9EXOVERLAYEXTENSION
+TYPEDEF: IDirect3D9ExOverlayExtension* PDIRECT3D9EXOVERLAYEXTENSION
+
+COM-INTERFACE: IDirect3DDevice9Video IUnknown {26DC4561-A1EE-4ae7-96DA-118A36C0EC95}
+    HRESULT GetContentProtectionCaps ( GUID* pCryptoType, GUID* pDecodeProfile, D3DCONTENTPROTECTIONCAPS* pCaps )
+    HRESULT CreateAuthenticatedChannel ( D3DAUTHENTICATEDCHANNELTYPE ChannelType, IDirect3DAuthenticatedChannel9** ppAuthenticatedChannel, HANDLE* pChannelHandle )
+    HRESULT CreateCryptoSession ( GUID* pCryptoType, GUID* pDecodeProfile, IDirect3DCryptoSession9** ppCryptoSession, HANDLE* pCryptoHandle ) ;
+
+TYPEDEF: IDirect3DDevice9Video* LPDIRECT3DDEVICE9VIDEO
+TYPEDEF: IDirect3DDevice9Video* PDIRECT3DDEVICE9VIDEO
+
+COM-INTERFACE: IDirect3DAuthenticatedChannel9 IUnknown {FF24BEEE-DA21-4beb-98B5-D2F899F98AF9}
+    HRESULT GetCertificateSize ( UINT* pCertificateSize )
+    HRESULT GetCertificate ( UINT CertifacteSize, BYTE* ppCertificate )
+    HRESULT NegotiateKeyExchange ( UINT DataSize, VOID* pData )
+    HRESULT Query ( UINT InputSize, VOID* pInput, UINT OutputSize, VOID* pOutput )
+    HRESULT Configure ( UINT InputSize, VOID* pInput, D3DAUTHENTICATEDCHANNEL_CONFIGURE_OUTPUT* pOutput ) ;
+
+TYPEDEF: IDirect3DAuthenticatedChannel9* LPDIRECT3DAUTHENTICATEDCHANNEL9
+TYPEDEF: IDirect3DAuthenticatedChannel9* PDIRECT3DAUTHENTICATEDCHANNEL9
+
+COM-INTERFACE: IDirect3DCryptoSession9 IUnknown {FA0AB799-7A9C-48ca-8C5B-237E71A54434}
+    HRESULT GetCertificateSize ( UINT* pCertificateSize )
+    HRESULT GetCertificate ( UINT CertifacteSize, BYTE* ppCertificate )
+    HRESULT NegotiateKeyExchange ( UINT DataSize, VOID* pData )
+    HRESULT EncryptionBlt ( IDirect3DSurface9* pSrcSurface, IDirect3DSurface9* pDstSurface, UINT DstSurfaceSize, VOID* pIV )
+    HRESULT DecryptionBlt ( IDirect3DSurface9* pSrcSurface, IDirect3DSurface9* pDstSurface, UINT SrcSurfaceSize, D3DENCRYPTED_BLOCK_INFO* pEncryptedBlockInfo, VOID* pContentKey, VOID* pIV )
+    HRESULT GetSurfacePitch ( IDirect3DSurface9* pSrcSurface, UINT* pSurfacePitch )
+    HRESULT StartSessionKeyRefresh ( VOID* pRandomNumber, UINT RandomNumberSize )
+    HRESULT FinishSessionKeyRefresh ( )
+    HRESULT GetEncryptionBltKey ( VOID* pReadbackKey, UINT KeySize ) ;
+
+TYPEDEF: IDirect3DCryptoSession9* LPDIRECT3DCRYPTOSESSION9
+TYPEDEF: IDirect3DCryptoSession9* PDIRECT3DCRYPTOSESSION9
diff --git a/basis/windows/directx/d3d9/summary.txt b/basis/windows/directx/d3d9/summary.txt
new file mode 100644 (file)
index 0000000..aafb26a
--- /dev/null
@@ -0,0 +1 @@
+DirectX 9 bindings. Corresponds to d3d9.h.
diff --git a/basis/windows/directx/d3d9/tags.txt b/basis/windows/directx/d3d9/tags.txt
new file mode 100644 (file)
index 0000000..2320bdd
--- /dev/null
@@ -0,0 +1,2 @@
+unportable
+bindings
diff --git a/basis/windows/directx/d3d9caps/authors.txt b/basis/windows/directx/d3d9caps/authors.txt
new file mode 100644 (file)
index 0000000..6f03a12
--- /dev/null
@@ -0,0 +1 @@
+Erik Charlebois
diff --git a/basis/windows/directx/d3d9caps/d3d9caps.factor b/basis/windows/directx/d3d9caps/d3d9caps.factor
new file mode 100644 (file)
index 0000000..5da1961
--- /dev/null
@@ -0,0 +1,386 @@
+USING: classes.struct windows.types windows.kernel32
+windows.directx.d3d9types alien.c-types ;
+IN: windows.directx.d3d9caps
+
+STRUCT: D3DVSHADERCAPS2_0
+    { Caps                    DWORD }
+    { DynamicFlowControlDepth INT   }
+    { NumTemps                INT   }
+    { StaticFlowControlDepth  INT   } ;
+
+CONSTANT: D3DVS20CAPS_PREDICATION 1
+
+CONSTANT: D3DVS20_MAX_DYNAMICFLOWCONTROLDEPTH  24
+CONSTANT: D3DVS20_MIN_DYNAMICFLOWCONTROLDEPTH  0
+CONSTANT: D3DVS20_MAX_NUMTEMPS    32
+CONSTANT: D3DVS20_MIN_NUMTEMPS    12
+CONSTANT: D3DVS20_MAX_STATICFLOWCONTROLDEPTH    4
+CONSTANT: D3DVS20_MIN_STATICFLOWCONTROLDEPTH    1
+
+STRUCT: D3DPSHADERCAPS2_0
+    { Caps                    DWORD }
+    { DynamicFlowControlDepth INT   }
+    { NumTemps                INT   }
+    { StaticFlowControlDepth  INT   }
+    { NumInstructionSlots     INT   } ;
+
+CONSTANT: D3DPS20CAPS_ARBITRARYSWIZZLE        1
+CONSTANT: D3DPS20CAPS_GRADIENTINSTRUCTIONS    2
+CONSTANT: D3DPS20CAPS_PREDICATION             4
+CONSTANT: D3DPS20CAPS_NODEPENDENTREADLIMIT    8
+CONSTANT: D3DPS20CAPS_NOTEXINSTRUCTIONLIMIT   16
+
+CONSTANT: D3DPS20_MAX_DYNAMICFLOWCONTROLDEPTH    24
+CONSTANT: D3DPS20_MIN_DYNAMICFLOWCONTROLDEPTH    0
+CONSTANT: D3DPS20_MAX_NUMTEMPS    32
+CONSTANT: D3DPS20_MIN_NUMTEMPS    12
+CONSTANT: D3DPS20_MAX_STATICFLOWCONTROLDEPTH    4
+CONSTANT: D3DPS20_MIN_STATICFLOWCONTROLDEPTH    0
+CONSTANT: D3DPS20_MAX_NUMINSTRUCTIONSLOTS    512
+CONSTANT: D3DPS20_MIN_NUMINSTRUCTIONSLOTS    96
+
+CONSTANT: D3DMIN30SHADERINSTRUCTIONS 512
+CONSTANT: D3DMAX30SHADERINSTRUCTIONS 32768
+
+STRUCT: D3DOVERLAYCAPS
+    { Caps                      UINT }
+    { MaxOverlayDisplayWidth    UINT }
+    { MaxOverlayDisplayHeight   UINT } ;
+
+CONSTANT: D3DOVERLAYCAPS_FULLRANGERGB          HEX: 00000001
+CONSTANT: D3DOVERLAYCAPS_LIMITEDRANGERGB       HEX: 00000002
+CONSTANT: D3DOVERLAYCAPS_YCbCr_BT601           HEX: 00000004
+CONSTANT: D3DOVERLAYCAPS_YCbCr_BT709           HEX: 00000008
+CONSTANT: D3DOVERLAYCAPS_YCbCr_BT601_xvYCC     HEX: 00000010
+CONSTANT: D3DOVERLAYCAPS_YCbCr_BT709_xvYCC     HEX: 00000020
+CONSTANT: D3DOVERLAYCAPS_STRETCHX              HEX: 00000040
+CONSTANT: D3DOVERLAYCAPS_STRETCHY              HEX: 00000080
+
+
+STRUCT: D3DCONTENTPROTECTIONCAPS
+    { Caps                      DWORD     }
+    { KeyExchangeType           GUID      }
+    { BufferAlignmentStart      UINT      }
+    { BlockAlignmentSize        UINT      }
+    { ProtectedMemorySize       ULONGLONG } ;
+CONSTANT: D3DCPCAPS_SOFTWARE              HEX: 00000001
+CONSTANT: D3DCPCAPS_HARDWARE              HEX: 00000002
+CONSTANT: D3DCPCAPS_PROTECTIONALWAYSON    HEX: 00000004
+CONSTANT: D3DCPCAPS_PARTIALDECRYPTION     HEX: 00000008
+CONSTANT: D3DCPCAPS_CONTENTKEY            HEX: 00000010
+CONSTANT: D3DCPCAPS_FRESHENSESSIONKEY     HEX: 00000020
+CONSTANT: D3DCPCAPS_ENCRYPTEDREADBACK     HEX: 00000040
+CONSTANT: D3DCPCAPS_ENCRYPTEDREADBACKKEY  HEX: 00000080
+CONSTANT: D3DCPCAPS_SEQUENTIAL_CTR_IV     HEX: 00000100
+CONSTANT: D3DCPCAPS_ENCRYPTSLICEDATAONLY  HEX: 00000200
+
+STRUCT: D3DCAPS9
+    { DeviceType                          D3DDEVTYPE        }
+    { AdapterOrdinal                      UINT              }
+    { Caps                                DWORD             }
+    { Caps2                               DWORD             }
+    { Caps3                               DWORD             }
+    { PresentationIntervals               DWORD             }
+    { CursorCaps                          DWORD             }
+    { DevCaps                             DWORD             }
+    { PrimitiveMiscCaps                   DWORD             }
+    { RasterCaps                          DWORD             }
+    { ZCmpCaps                            DWORD             }
+    { SrcBlendCaps                        DWORD             }
+    { DestBlendCaps                       DWORD             }
+    { AlphaCmpCaps                        DWORD             }
+    { ShadeCaps                           DWORD             }
+    { TextureCaps                         DWORD             }
+    { TextureFilterCaps                   DWORD             }
+    { CubeTextureFilterCaps               DWORD             }
+    { VolumeTextureFilterCaps             DWORD             }
+    { TextureAddressCaps                  DWORD             }
+    { VolumeTextureAddressCaps            DWORD             }
+    { LineCaps                            DWORD             }
+    { MaxTextureWidth                     DWORD             }
+    { MaxTextureHeight                    DWORD             }
+    { MaxVolumeExtent                     DWORD             }
+    { MaxTextureRepeat                    DWORD             }
+    { MaxTextureAspectRatio               DWORD             }
+    { MaxAnisotropy                       DWORD             }
+    { MaxVertexW                          float             }
+    { GuardBandLeft                       float             }
+    { GuardBandTop                        float             }
+    { GuardBandRight                      float             }
+    { GuardBandBottom                     float             }
+    { ExtentsAdjust                       float             }
+    { StencilCaps                         DWORD             }
+    { FVFCaps                             DWORD             }
+    { TextureOpCaps                       DWORD             }
+    { MaxTextureBlendStages               DWORD             }
+    { MaxSimultaneousTextures             DWORD             }
+    { VertexProcessingCaps                DWORD             }
+    { MaxActiveLights                     DWORD             }
+    { MaxUserClipPlanes                   DWORD             }
+    { MaxVertexBlendMatrices              DWORD             }
+    { MaxVertexBlendMatrixIndex           DWORD             }
+    { MaxPointSize                        float             }
+    { MaxPrimitiveCount                   DWORD             }
+    { MaxVertexIndex                      DWORD             }
+    { MaxStreams                          DWORD             }
+    { MaxStreamStride                     DWORD             }
+    { VertexShaderVersion                 DWORD             }
+    { MaxVertexShaderConst                DWORD             }
+    { PixelShaderVersion                  DWORD             }
+    { PixelShader1xMaxValue               float             }
+    { DevCaps2                            DWORD             }
+    { MaxNpatchTessellationLevel          float             }
+    { Reserved5                           DWORD             }
+    { MasterAdapterOrdinal                UINT              }
+    { AdapterOrdinalInGroup               UINT              }
+    { NumberOfAdaptersInGroup             UINT              }
+    { DeclTypes                           DWORD             }
+    { NumSimultaneousRTs                  DWORD             }
+    { StretchRectFilterCaps               DWORD             }
+    { VS20Caps                            D3DVSHADERCAPS2_0 }
+    { PS20Caps                            D3DPSHADERCAPS2_0 }
+    { VertexTextureFilterCaps             DWORD             }
+    { MaxVShaderInstructionsExecuted      DWORD             }
+    { MaxPShaderInstructionsExecuted      DWORD             }
+    { MaxVertexShader30InstructionSlots   DWORD             }
+    { MaxPixelShader30InstructionSlots    DWORD             } ;
+
+CONSTANT: D3DCAPS_OVERLAY                 HEX: 00000800
+CONSTANT: D3DCAPS_READ_SCANLINE           HEX: 00020000
+
+CONSTANT: D3DCAPS2_FULLSCREENGAMMA        HEX: 00020000
+CONSTANT: D3DCAPS2_CANCALIBRATEGAMMA      HEX: 00100000
+CONSTANT: D3DCAPS2_RESERVED               HEX: 02000000
+CONSTANT: D3DCAPS2_CANMANAGERESOURCE      HEX: 10000000
+CONSTANT: D3DCAPS2_DYNAMICTEXTURES        HEX: 20000000
+CONSTANT: D3DCAPS2_CANAUTOGENMIPMAP       HEX: 40000000
+
+CONSTANT: D3DCAPS2_CANSHARERESOURCE       HEX: 80000000
+
+CONSTANT: D3DCAPS3_RESERVED               HEX: 8000001f
+
+CONSTANT: D3DCAPS3_ALPHA_FULLSCREEN_FLIP_OR_DISCARD   HEX: 00000020
+
+CONSTANT: D3DCAPS3_LINEAR_TO_SRGB_PRESENTATION HEX: 00000080
+
+CONSTANT: D3DCAPS3_COPY_TO_VIDMEM         HEX: 00000100
+CONSTANT: D3DCAPS3_COPY_TO_SYSTEMMEM      HEX: 00000200
+CONSTANT: D3DCAPS3_DXVAHD                 HEX: 00000400
+
+CONSTANT: D3DPRESENT_INTERVAL_DEFAULT     HEX: 00000000
+CONSTANT: D3DPRESENT_INTERVAL_ONE         HEX: 00000001
+CONSTANT: D3DPRESENT_INTERVAL_TWO         HEX: 00000002
+CONSTANT: D3DPRESENT_INTERVAL_THREE       HEX: 00000004
+CONSTANT: D3DPRESENT_INTERVAL_FOUR        HEX: 00000008
+CONSTANT: D3DPRESENT_INTERVAL_IMMEDIATE   HEX: 80000000
+
+CONSTANT: D3DCURSORCAPS_COLOR             HEX: 00000001
+CONSTANT: D3DCURSORCAPS_LOWRES            HEX: 00000002
+
+CONSTANT: D3DDEVCAPS_EXECUTESYSTEMMEMORY  HEX: 00000010
+CONSTANT: D3DDEVCAPS_EXECUTEVIDEOMEMORY   HEX: 00000020
+CONSTANT: D3DDEVCAPS_TLVERTEXSYSTEMMEMORY HEX: 00000040
+CONSTANT: D3DDEVCAPS_TLVERTEXVIDEOMEMORY  HEX: 00000080
+CONSTANT: D3DDEVCAPS_TEXTURESYSTEMMEMORY  HEX: 00000100
+CONSTANT: D3DDEVCAPS_TEXTUREVIDEOMEMORY   HEX: 00000200
+CONSTANT: D3DDEVCAPS_DRAWPRIMTLVERTEX     HEX: 00000400
+CONSTANT: D3DDEVCAPS_CANRENDERAFTERFLIP   HEX: 00000800
+CONSTANT: D3DDEVCAPS_TEXTURENONLOCALVIDMEM HEX: 00001000
+CONSTANT: D3DDEVCAPS_DRAWPRIMITIVES2      HEX: 00002000
+CONSTANT: D3DDEVCAPS_SEPARATETEXTUREMEMORIES HEX: 00004000
+CONSTANT: D3DDEVCAPS_DRAWPRIMITIVES2EX    HEX: 00008000
+CONSTANT: D3DDEVCAPS_HWTRANSFORMANDLIGHT  HEX: 00010000
+CONSTANT: D3DDEVCAPS_CANBLTSYSTONONLOCAL  HEX: 00020000
+CONSTANT: D3DDEVCAPS_HWRASTERIZATION      HEX: 00080000
+CONSTANT: D3DDEVCAPS_PUREDEVICE           HEX: 00100000
+CONSTANT: D3DDEVCAPS_QUINTICRTPATCHES     HEX: 00200000
+CONSTANT: D3DDEVCAPS_RTPATCHES            HEX: 00400000
+CONSTANT: D3DDEVCAPS_RTPATCHHANDLEZERO    HEX: 00800000
+CONSTANT: D3DDEVCAPS_NPATCHES             HEX: 01000000
+
+CONSTANT: D3DPMISCCAPS_MASKZ              HEX: 00000002
+CONSTANT: D3DPMISCCAPS_CULLNONE           HEX: 00000010
+CONSTANT: D3DPMISCCAPS_CULLCW             HEX: 00000020
+CONSTANT: D3DPMISCCAPS_CULLCCW            HEX: 00000040
+CONSTANT: D3DPMISCCAPS_COLORWRITEENABLE   HEX: 00000080
+CONSTANT: D3DPMISCCAPS_CLIPPLANESCALEDPOINTS HEX: 00000100
+CONSTANT: D3DPMISCCAPS_CLIPTLVERTS        HEX: 00000200
+CONSTANT: D3DPMISCCAPS_TSSARGTEMP         HEX: 00000400
+CONSTANT: D3DPMISCCAPS_BLENDOP            HEX: 00000800
+CONSTANT: D3DPMISCCAPS_NULLREFERENCE      HEX: 00001000
+CONSTANT: D3DPMISCCAPS_INDEPENDENTWRITEMASKS     HEX: 00004000
+CONSTANT: D3DPMISCCAPS_PERSTAGECONSTANT   HEX: 00008000
+CONSTANT: D3DPMISCCAPS_FOGANDSPECULARALPHA   HEX: 00010000
+CONSTANT: D3DPMISCCAPS_SEPARATEALPHABLEND         HEX: 00020000
+CONSTANT: D3DPMISCCAPS_MRTINDEPENDENTBITDEPTHS    HEX: 00040000
+CONSTANT: D3DPMISCCAPS_MRTPOSTPIXELSHADERBLENDING HEX: 00080000
+CONSTANT: D3DPMISCCAPS_FOGVERTEXCLAMPED           HEX: 00100000
+
+CONSTANT: D3DPMISCCAPS_POSTBLENDSRGBCONVERT       HEX: 00200000
+
+CONSTANT: D3DLINECAPS_TEXTURE             HEX: 00000001
+CONSTANT: D3DLINECAPS_ZTEST               HEX: 00000002
+CONSTANT: D3DLINECAPS_BLEND               HEX: 00000004
+CONSTANT: D3DLINECAPS_ALPHACMP            HEX: 00000008
+CONSTANT: D3DLINECAPS_FOG                 HEX: 00000010
+CONSTANT: D3DLINECAPS_ANTIALIAS           HEX: 00000020
+
+CONSTANT: D3DPRASTERCAPS_DITHER                 HEX: 00000001
+CONSTANT: D3DPRASTERCAPS_ZTEST                  HEX: 00000010
+CONSTANT: D3DPRASTERCAPS_FOGVERTEX              HEX: 00000080
+CONSTANT: D3DPRASTERCAPS_FOGTABLE               HEX: 00000100
+CONSTANT: D3DPRASTERCAPS_MIPMAPLODBIAS          HEX: 00002000
+CONSTANT: D3DPRASTERCAPS_ZBUFFERLESSHSR         HEX: 00008000
+CONSTANT: D3DPRASTERCAPS_FOGRANGE               HEX: 00010000
+CONSTANT: D3DPRASTERCAPS_ANISOTROPY             HEX: 00020000
+CONSTANT: D3DPRASTERCAPS_WBUFFER                HEX: 00040000
+CONSTANT: D3DPRASTERCAPS_WFOG                   HEX: 00100000
+CONSTANT: D3DPRASTERCAPS_ZFOG                   HEX: 00200000
+CONSTANT: D3DPRASTERCAPS_COLORPERSPECTIVE       HEX: 00400000
+CONSTANT: D3DPRASTERCAPS_SCISSORTEST            HEX: 01000000
+CONSTANT: D3DPRASTERCAPS_SLOPESCALEDEPTHBIAS    HEX: 02000000
+CONSTANT: D3DPRASTERCAPS_DEPTHBIAS              HEX: 04000000 
+CONSTANT: D3DPRASTERCAPS_MULTISAMPLE_TOGGLE     HEX: 08000000
+
+CONSTANT: D3DPCMPCAPS_NEVER               HEX: 00000001
+CONSTANT: D3DPCMPCAPS_LESS                HEX: 00000002
+CONSTANT: D3DPCMPCAPS_EQUAL               HEX: 00000004
+CONSTANT: D3DPCMPCAPS_LESSEQUAL           HEX: 00000008
+CONSTANT: D3DPCMPCAPS_GREATER             HEX: 00000010
+CONSTANT: D3DPCMPCAPS_NOTEQUAL            HEX: 00000020
+CONSTANT: D3DPCMPCAPS_GREATEREQUAL        HEX: 00000040
+CONSTANT: D3DPCMPCAPS_ALWAYS              HEX: 00000080
+
+CONSTANT: D3DPBLENDCAPS_ZERO              HEX: 00000001
+CONSTANT: D3DPBLENDCAPS_ONE               HEX: 00000002
+CONSTANT: D3DPBLENDCAPS_SRCCOLOR          HEX: 00000004
+CONSTANT: D3DPBLENDCAPS_INVSRCCOLOR       HEX: 00000008
+CONSTANT: D3DPBLENDCAPS_SRCALPHA          HEX: 00000010
+CONSTANT: D3DPBLENDCAPS_INVSRCALPHA       HEX: 00000020
+CONSTANT: D3DPBLENDCAPS_DESTALPHA         HEX: 00000040
+CONSTANT: D3DPBLENDCAPS_INVDESTALPHA      HEX: 00000080
+CONSTANT: D3DPBLENDCAPS_DESTCOLOR         HEX: 00000100
+CONSTANT: D3DPBLENDCAPS_INVDESTCOLOR      HEX: 00000200
+CONSTANT: D3DPBLENDCAPS_SRCALPHASAT       HEX: 00000400
+CONSTANT: D3DPBLENDCAPS_BOTHSRCALPHA      HEX: 00000800
+CONSTANT: D3DPBLENDCAPS_BOTHINVSRCALPHA   HEX: 00001000
+CONSTANT: D3DPBLENDCAPS_BLENDFACTOR       HEX: 00002000
+
+CONSTANT: D3DPBLENDCAPS_SRCCOLOR2         HEX: 00004000
+CONSTANT: D3DPBLENDCAPS_INVSRCCOLOR2      HEX: 00008000
+
+CONSTANT: D3DPSHADECAPS_COLORGOURAUDRGB       HEX: 00000008
+CONSTANT: D3DPSHADECAPS_SPECULARGOURAUDRGB    HEX: 00000200
+CONSTANT: D3DPSHADECAPS_ALPHAGOURAUDBLEND     HEX: 00004000
+CONSTANT: D3DPSHADECAPS_FOGGOURAUD            HEX: 00080000
+
+CONSTANT: D3DPTEXTURECAPS_PERSPECTIVE         HEX: 00000001
+CONSTANT: D3DPTEXTURECAPS_POW2                HEX: 00000002
+CONSTANT: D3DPTEXTURECAPS_ALPHA               HEX: 00000004
+CONSTANT: D3DPTEXTURECAPS_SQUAREONLY          HEX: 00000020
+CONSTANT: D3DPTEXTURECAPS_TEXREPEATNOTSCALEDBYSIZE HEX: 00000040
+CONSTANT: D3DPTEXTURECAPS_ALPHAPALETTE        HEX: 00000080
+
+CONSTANT: D3DPTEXTURECAPS_NONPOW2CONDITIONAL  HEX: 00000100
+CONSTANT: D3DPTEXTURECAPS_PROJECTED           HEX: 00000400
+CONSTANT: D3DPTEXTURECAPS_CUBEMAP             HEX: 00000800
+CONSTANT: D3DPTEXTURECAPS_VOLUMEMAP           HEX: 00002000
+CONSTANT: D3DPTEXTURECAPS_MIPMAP              HEX: 00004000
+CONSTANT: D3DPTEXTURECAPS_MIPVOLUMEMAP        HEX: 00008000
+CONSTANT: D3DPTEXTURECAPS_MIPCUBEMAP          HEX: 00010000
+CONSTANT: D3DPTEXTURECAPS_CUBEMAP_POW2        HEX: 00020000
+CONSTANT: D3DPTEXTURECAPS_VOLUMEMAP_POW2      HEX: 00040000
+CONSTANT: D3DPTEXTURECAPS_NOPROJECTEDBUMPENV  HEX: 00200000
+
+CONSTANT: D3DPTFILTERCAPS_MINFPOINT           HEX: 00000100
+CONSTANT: D3DPTFILTERCAPS_MINFLINEAR          HEX: 00000200
+CONSTANT: D3DPTFILTERCAPS_MINFANISOTROPIC     HEX: 00000400
+CONSTANT: D3DPTFILTERCAPS_MINFPYRAMIDALQUAD   HEX: 00000800
+CONSTANT: D3DPTFILTERCAPS_MINFGAUSSIANQUAD    HEX: 00001000
+CONSTANT: D3DPTFILTERCAPS_MIPFPOINT           HEX: 00010000
+CONSTANT: D3DPTFILTERCAPS_MIPFLINEAR          HEX: 00020000
+
+CONSTANT: D3DPTFILTERCAPS_CONVOLUTIONMONO     HEX: 00040000
+
+CONSTANT: D3DPTFILTERCAPS_MAGFPOINT           HEX: 01000000
+CONSTANT: D3DPTFILTERCAPS_MAGFLINEAR          HEX: 02000000
+CONSTANT: D3DPTFILTERCAPS_MAGFANISOTROPIC     HEX: 04000000
+CONSTANT: D3DPTFILTERCAPS_MAGFPYRAMIDALQUAD   HEX: 08000000
+CONSTANT: D3DPTFILTERCAPS_MAGFGAUSSIANQUAD    HEX: 10000000
+
+CONSTANT: D3DPTADDRESSCAPS_WRAP           HEX: 00000001
+CONSTANT: D3DPTADDRESSCAPS_MIRROR         HEX: 00000002
+CONSTANT: D3DPTADDRESSCAPS_CLAMP          HEX: 00000004
+CONSTANT: D3DPTADDRESSCAPS_BORDER         HEX: 00000008
+CONSTANT: D3DPTADDRESSCAPS_INDEPENDENTUV  HEX: 00000010
+CONSTANT: D3DPTADDRESSCAPS_MIRRORONCE     HEX: 00000020
+
+CONSTANT: D3DSTENCILCAPS_KEEP             HEX: 00000001
+CONSTANT: D3DSTENCILCAPS_ZERO             HEX: 00000002
+CONSTANT: D3DSTENCILCAPS_REPLACE          HEX: 00000004
+CONSTANT: D3DSTENCILCAPS_INCRSAT          HEX: 00000008
+CONSTANT: D3DSTENCILCAPS_DECRSAT          HEX: 00000010
+CONSTANT: D3DSTENCILCAPS_INVERT           HEX: 00000020
+CONSTANT: D3DSTENCILCAPS_INCR             HEX: 00000040
+CONSTANT: D3DSTENCILCAPS_DECR             HEX: 00000080
+CONSTANT: D3DSTENCILCAPS_TWOSIDED         HEX: 00000100
+
+CONSTANT: D3DTEXOPCAPS_DISABLE                    HEX: 00000001
+CONSTANT: D3DTEXOPCAPS_SELECTARG1                 HEX: 00000002
+CONSTANT: D3DTEXOPCAPS_SELECTARG2                 HEX: 00000004
+CONSTANT: D3DTEXOPCAPS_MODULATE                   HEX: 00000008
+CONSTANT: D3DTEXOPCAPS_MODULATE2X                 HEX: 00000010
+CONSTANT: D3DTEXOPCAPS_MODULATE4X                 HEX: 00000020
+CONSTANT: D3DTEXOPCAPS_ADD                        HEX: 00000040
+CONSTANT: D3DTEXOPCAPS_ADDSIGNED                  HEX: 00000080
+CONSTANT: D3DTEXOPCAPS_ADDSIGNED2X                HEX: 00000100
+CONSTANT: D3DTEXOPCAPS_SUBTRACT                   HEX: 00000200
+CONSTANT: D3DTEXOPCAPS_ADDSMOOTH                  HEX: 00000400
+CONSTANT: D3DTEXOPCAPS_BLENDDIFFUSEALPHA          HEX: 00000800
+CONSTANT: D3DTEXOPCAPS_BLENDTEXTUREALPHA          HEX: 00001000
+CONSTANT: D3DTEXOPCAPS_BLENDFACTORALPHA           HEX: 00002000
+CONSTANT: D3DTEXOPCAPS_BLENDTEXTUREALPHAPM        HEX: 00004000
+CONSTANT: D3DTEXOPCAPS_BLENDCURRENTALPHA          HEX: 00008000
+CONSTANT: D3DTEXOPCAPS_PREMODULATE                HEX: 00010000
+CONSTANT: D3DTEXOPCAPS_MODULATEALPHA_ADDCOLOR     HEX: 00020000
+CONSTANT: D3DTEXOPCAPS_MODULATECOLOR_ADDALPHA     HEX: 00040000
+CONSTANT: D3DTEXOPCAPS_MODULATEINVALPHA_ADDCOLOR  HEX: 00080000
+CONSTANT: D3DTEXOPCAPS_MODULATEINVCOLOR_ADDALPHA  HEX: 00100000
+CONSTANT: D3DTEXOPCAPS_BUMPENVMAP                 HEX: 00200000
+CONSTANT: D3DTEXOPCAPS_BUMPENVMAPLUMINANCE        HEX: 00400000
+CONSTANT: D3DTEXOPCAPS_DOTPRODUCT3                HEX: 00800000
+CONSTANT: D3DTEXOPCAPS_MULTIPLYADD                HEX: 01000000
+CONSTANT: D3DTEXOPCAPS_LERP                       HEX: 02000000
+
+CONSTANT: D3DFVFCAPS_TEXCOORDCOUNTMASK    HEX: 0000ffff
+CONSTANT: D3DFVFCAPS_DONOTSTRIPELEMENTS   HEX: 00080000
+CONSTANT: D3DFVFCAPS_PSIZE                HEX: 00100000
+
+CONSTANT: D3DVTXPCAPS_TEXGEN              HEX: 00000001
+CONSTANT: D3DVTXPCAPS_MATERIALSOURCE7     HEX: 00000002
+CONSTANT: D3DVTXPCAPS_DIRECTIONALLIGHTS   HEX: 00000008
+CONSTANT: D3DVTXPCAPS_POSITIONALLIGHTS    HEX: 00000010
+CONSTANT: D3DVTXPCAPS_LOCALVIEWER         HEX: 00000020
+CONSTANT: D3DVTXPCAPS_TWEENING            HEX: 00000040
+CONSTANT: D3DVTXPCAPS_TEXGEN_SPHEREMAP    HEX: 00000100
+CONSTANT: D3DVTXPCAPS_NO_TEXGEN_NONLOCALVIEWER   HEX: 00000200
+
+CONSTANT: D3DDEVCAPS2_STREAMOFFSET                        HEX: 00000001
+CONSTANT: D3DDEVCAPS2_DMAPNPATCH                          HEX: 00000002
+CONSTANT: D3DDEVCAPS2_ADAPTIVETESSRTPATCH                 HEX: 00000004
+CONSTANT: D3DDEVCAPS2_ADAPTIVETESSNPATCH                  HEX: 00000008
+CONSTANT: D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES       HEX: 00000010
+CONSTANT: D3DDEVCAPS2_PRESAMPLEDDMAPNPATCH                HEX: 00000020
+CONSTANT: D3DDEVCAPS2_VERTEXELEMENTSCANSHARESTREAMOFFSET  HEX: 00000040
+
+CONSTANT: D3DDTCAPS_UBYTE4     HEX: 00000001
+CONSTANT: D3DDTCAPS_UBYTE4N    HEX: 00000002
+CONSTANT: D3DDTCAPS_SHORT2N    HEX: 00000004
+CONSTANT: D3DDTCAPS_SHORT4N    HEX: 00000008
+CONSTANT: D3DDTCAPS_USHORT2N   HEX: 00000010
+CONSTANT: D3DDTCAPS_USHORT4N   HEX: 00000020
+CONSTANT: D3DDTCAPS_UDEC3      HEX: 00000040
+CONSTANT: D3DDTCAPS_DEC3N      HEX: 00000080
+CONSTANT: D3DDTCAPS_FLOAT16_2  HEX: 00000100
+CONSTANT: D3DDTCAPS_FLOAT16_4  HEX: 00000200
diff --git a/basis/windows/directx/d3d9caps/summary.txt b/basis/windows/directx/d3d9caps/summary.txt
new file mode 100644 (file)
index 0000000..52f7cef
--- /dev/null
@@ -0,0 +1 @@
+DirectX 9 bindings. Corresponds to d3d9caps.h.
diff --git a/basis/windows/directx/d3d9caps/tags.txt b/basis/windows/directx/d3d9caps/tags.txt
new file mode 100644 (file)
index 0000000..2320bdd
--- /dev/null
@@ -0,0 +1,2 @@
+unportable
+bindings
diff --git a/basis/windows/directx/d3d9types/authors.txt b/basis/windows/directx/d3d9types/authors.txt
new file mode 100644 (file)
index 0000000..6f03a12
--- /dev/null
@@ -0,0 +1 @@
+Erik Charlebois
diff --git a/basis/windows/directx/d3d9types/d3d9types.factor b/basis/windows/directx/d3d9types/d3d9types.factor
new file mode 100644 (file)
index 0000000..9f4358f
--- /dev/null
@@ -0,0 +1,1520 @@
+USING: alien.syntax windows.types classes.struct math alien.c-types
+math.bitwise kernel locals windows.kernel32 ;
+IN: windows.directx.d3d9types
+
+TYPEDEF: DWORD D3DCOLOR
+
+STRUCT: D3DVECTOR
+    { x FLOAT }
+    { y FLOAT }
+    { z FLOAT } ;
+
+STRUCT: D3DCOLORVALUE
+    { r FLOAT }
+    { g FLOAT }
+    { b FLOAT }
+    { a FLOAT } ;
+
+STRUCT: D3DRECT
+    { x1 LONG }
+    { y1 LONG }
+    { x2 LONG }
+    { y2 LONG } ;
+
+STRUCT: D3DMATRIX
+    { m FLOAT[4][4] } ;
+
+STRUCT: D3DVIEWPORT9
+    { X            DWORD }
+    { Y            DWORD }
+    { Width        DWORD }
+    { Height       DWORD }
+    { MinZ         FLOAT }
+    { MaxZ         FLOAT } ;
+
+CONSTANT: D3DMAXUSERCLIPPLANES 32
+
+CONSTANT: D3DCLIPPLANE0 1
+CONSTANT: D3DCLIPPLANE1 2
+CONSTANT: D3DCLIPPLANE2 4
+CONSTANT: D3DCLIPPLANE3 8
+CONSTANT: D3DCLIPPLANE4 16
+CONSTANT: D3DCLIPPLANE5 32
+
+CONSTANT: D3DCS_LEFT        HEX: 00000001
+CONSTANT: D3DCS_RIGHT       HEX: 00000002
+CONSTANT: D3DCS_TOP         HEX: 00000004
+CONSTANT: D3DCS_BOTTOM      HEX: 00000008
+CONSTANT: D3DCS_FRONT       HEX: 00000010
+CONSTANT: D3DCS_BACK        HEX: 00000020
+CONSTANT: D3DCS_PLANE0      HEX: 00000040
+CONSTANT: D3DCS_PLANE1      HEX: 00000080
+CONSTANT: D3DCS_PLANE2      HEX: 00000100
+CONSTANT: D3DCS_PLANE3      HEX: 00000200
+CONSTANT: D3DCS_PLANE4      HEX: 00000400
+CONSTANT: D3DCS_PLANE5      HEX: 00000800
+
+: D3DCS_ALL ( -- n )
+    { D3DCS_LEFT
+      D3DCS_RIGHT
+      D3DCS_TOP
+      D3DCS_BOTTOM
+      D3DCS_FRONT
+      D3DCS_BACK
+      D3DCS_PLANE0
+      D3DCS_PLANE1
+      D3DCS_PLANE2
+      D3DCS_PLANE3
+      D3DCS_PLANE4
+      D3DCS_PLANE5 } flags ; inline
+
+STRUCT: D3DCLIPSTATUS9
+    { ClipUnion        DWORD }
+    { ClipIntersection DWORD } ;
+
+STRUCT: D3DMATERIAL9
+    { Diffuse         D3DCOLORVALUE }
+    { Ambient         D3DCOLORVALUE }
+    { Specular        D3DCOLORVALUE }
+    { Emissive        D3DCOLORVALUE }
+    { Power           FLOAT         } ;
+
+TYPEDEF: int D3DLIGHTTYPE
+CONSTANT: D3DLIGHT_POINT          1
+CONSTANT: D3DLIGHT_SPOT           2
+CONSTANT: D3DLIGHT_DIRECTIONAL    3
+CONSTANT: D3DLIGHT_FORCE_DWORD    HEX: 7fffffff
+
+STRUCT: D3DLIGHT9
+    { Type                   D3DLIGHTTYPE  }
+    { Diffuse                D3DCOLORVALUE }
+    { Specular               D3DCOLORVALUE }
+    { Ambient                D3DCOLORVALUE }
+    { Position               D3DVECTOR     }
+    { Direction              D3DVECTOR     }
+    { Range                  FLOAT         }
+    { Falloff                FLOAT         }
+    { Attenuation0           FLOAT         }
+    { Attenuation1           FLOAT         }
+    { Attenuation2           FLOAT         }
+    { Theta                  FLOAT         }
+    { Phi                    FLOAT         } ;
+
+CONSTANT: D3DCLEAR_TARGET            HEX: 00000001
+CONSTANT: D3DCLEAR_ZBUFFER           HEX: 00000002
+CONSTANT: D3DCLEAR_STENCIL           HEX: 00000004
+
+TYPEDEF: int D3DSHADEMODE
+CONSTANT: D3DSHADE_FLAT               1
+CONSTANT: D3DSHADE_GOURAUD            2
+CONSTANT: D3DSHADE_PHONG              3
+CONSTANT: D3DSHADE_FORCE_DWORD        HEX: 7fffffff
+
+TYPEDEF: int D3DFILLMODE
+CONSTANT: D3DFILL_POINT               1
+CONSTANT: D3DFILL_WIREFRAME           2
+CONSTANT: D3DFILL_SOLID               3
+CONSTANT: D3DFILL_FORCE_DWORD         HEX: 7fffffff
+
+TYPEDEF: int D3DBLEND
+CONSTANT: D3DBLEND_ZERO               1
+CONSTANT: D3DBLEND_ONE                2
+CONSTANT: D3DBLEND_SRCCOLOR           3
+CONSTANT: D3DBLEND_INVSRCCOLOR        4
+CONSTANT: D3DBLEND_SRCALPHA           5
+CONSTANT: D3DBLEND_INVSRCALPHA        6
+CONSTANT: D3DBLEND_DESTALPHA          7
+CONSTANT: D3DBLEND_INVDESTALPHA       8
+CONSTANT: D3DBLEND_DESTCOLOR          9
+CONSTANT: D3DBLEND_INVDESTCOLOR       10
+CONSTANT: D3DBLEND_SRCALPHASAT        11
+CONSTANT: D3DBLEND_BOTHSRCALPHA       12
+CONSTANT: D3DBLEND_BOTHINVSRCALPHA    13
+CONSTANT: D3DBLEND_BLENDFACTOR        14
+CONSTANT: D3DBLEND_INVBLENDFACTOR     15
+CONSTANT: D3DBLEND_SRCCOLOR2          16
+CONSTANT: D3DBLEND_INVSRCCOLOR2       17
+CONSTANT: D3DBLEND_FORCE_DWORD        HEX: 7fffffff
+
+TYPEDEF: int D3DBLENDOP
+CONSTANT: D3DBLENDOP_ADD              1
+CONSTANT: D3DBLENDOP_SUBTRACT         2
+CONSTANT: D3DBLENDOP_REVSUBTRACT      3
+CONSTANT: D3DBLENDOP_MIN              4
+CONSTANT: D3DBLENDOP_MAX              5
+CONSTANT: D3DBLENDOP_FORCE_DWORD      HEX: 7fffffff
+
+TYPEDEF: int D3DTEXTUREADDRESS
+CONSTANT: D3DTADDRESS_WRAP            1
+CONSTANT: D3DTADDRESS_MIRROR          2
+CONSTANT: D3DTADDRESS_CLAMP           3
+CONSTANT: D3DTADDRESS_BORDER          4
+CONSTANT: D3DTADDRESS_MIRRORONCE      5
+CONSTANT: D3DTADDRESS_FORCE_DWORD     HEX: 7fffffff
+
+TYPEDEF: int D3DCULL
+CONSTANT: D3DCULL_NONE                1
+CONSTANT: D3DCULL_CW                  2
+CONSTANT: D3DCULL_CCW                 3
+CONSTANT: D3DCULL_FORCE_DWORD         HEX: 7fffffff
+
+TYPEDEF: int D3DCMPFUNC
+CONSTANT: D3DCMP_NEVER                1
+CONSTANT: D3DCMP_LESS                 2
+CONSTANT: D3DCMP_EQUAL                3
+CONSTANT: D3DCMP_LESSEQUAL            4
+CONSTANT: D3DCMP_GREATER              5
+CONSTANT: D3DCMP_NOTEQUAL             6
+CONSTANT: D3DCMP_GREATEREQUAL         7
+CONSTANT: D3DCMP_ALWAYS               8
+CONSTANT: D3DCMP_FORCE_DWORD          HEX: 7fffffff
+
+TYPEDEF: int D3DSTENCILOP
+CONSTANT: D3DSTENCILOP_KEEP           1
+CONSTANT: D3DSTENCILOP_ZERO           2
+CONSTANT: D3DSTENCILOP_REPLACE        3
+CONSTANT: D3DSTENCILOP_INCRSAT        4
+CONSTANT: D3DSTENCILOP_DECRSAT        5
+CONSTANT: D3DSTENCILOP_INVERT         6
+CONSTANT: D3DSTENCILOP_INCR           7
+CONSTANT: D3DSTENCILOP_DECR           8
+CONSTANT: D3DSTENCILOP_FORCE_DWORD    HEX: 7fffffff
+
+TYPEDEF: int D3DFOGMODE
+CONSTANT: D3DFOG_NONE                 0
+CONSTANT: D3DFOG_EXP                  1
+CONSTANT: D3DFOG_EXP2                 2
+CONSTANT: D3DFOG_LINEAR               3
+CONSTANT: D3DFOG_FORCE_DWORD          HEX: 7fffffff
+
+TYPEDEF: int D3DZBUFFERTYPE
+CONSTANT: D3DZB_FALSE                 0
+CONSTANT: D3DZB_TRUE                  1
+CONSTANT: D3DZB_USEW                  2
+CONSTANT: D3DZB_FORCE_DWORD           HEX: 7fffffff
+
+TYPEDEF: int D3DPRIMITIVETYPE
+CONSTANT: D3DPT_POINTLIST             1
+CONSTANT: D3DPT_LINELIST              2
+CONSTANT: D3DPT_LINESTRIP             3
+CONSTANT: D3DPT_TRIANGLELIST          4
+CONSTANT: D3DPT_TRIANGLESTRIP         5
+CONSTANT: D3DPT_TRIANGLEFAN           6
+CONSTANT: D3DPT_FORCE_DWORD           HEX: 7fffffff
+
+TYPEDEF: int D3DTRANSFORMSTATETYPE
+CONSTANT: D3DTS_VIEW          2
+CONSTANT: D3DTS_PROJECTION    3
+CONSTANT: D3DTS_TEXTURE0      16
+CONSTANT: D3DTS_TEXTURE1      17
+CONSTANT: D3DTS_TEXTURE2      18
+CONSTANT: D3DTS_TEXTURE3      19
+CONSTANT: D3DTS_TEXTURE4      20
+CONSTANT: D3DTS_TEXTURE5      21
+CONSTANT: D3DTS_TEXTURE6      22
+CONSTANT: D3DTS_TEXTURE7      23
+CONSTANT: D3DTS_FORCE_DWORD   HEX: 7fffffff
+
+TYPEDEF: int D3DRENDERSTATETYPE
+CONSTANT: D3DRS_ZENABLE                   7
+CONSTANT: D3DRS_FILLMODE                  8
+CONSTANT: D3DRS_SHADEMODE                 9
+CONSTANT: D3DRS_ZWRITEENABLE              14
+CONSTANT: D3DRS_ALPHATESTENABLE           15
+CONSTANT: D3DRS_LASTPIXEL                 16
+CONSTANT: D3DRS_SRCBLEND                  19
+CONSTANT: D3DRS_DESTBLEND                 20
+CONSTANT: D3DRS_CULLMODE                  22
+CONSTANT: D3DRS_ZFUNC                     23
+CONSTANT: D3DRS_ALPHAREF                  24
+CONSTANT: D3DRS_ALPHAFUNC                 25
+CONSTANT: D3DRS_DITHERENABLE              26
+CONSTANT: D3DRS_ALPHABLENDENABLE          27
+CONSTANT: D3DRS_FOGENABLE                 28
+CONSTANT: D3DRS_SPECULARENABLE            29
+CONSTANT: D3DRS_FOGCOLOR                  34
+CONSTANT: D3DRS_FOGTABLEMODE              35
+CONSTANT: D3DRS_FOGSTART                  36
+CONSTANT: D3DRS_FOGEND                    37
+CONSTANT: D3DRS_FOGDENSITY                38
+CONSTANT: D3DRS_RANGEFOGENABLE            48
+CONSTANT: D3DRS_STENCILENABLE             52
+CONSTANT: D3DRS_STENCILFAIL               53
+CONSTANT: D3DRS_STENCILZFAIL              54
+CONSTANT: D3DRS_STENCILPASS               55
+CONSTANT: D3DRS_STENCILFUNC               56
+CONSTANT: D3DRS_STENCILREF                57
+CONSTANT: D3DRS_STENCILMASK               58
+CONSTANT: D3DRS_STENCILWRITEMASK          59
+CONSTANT: D3DRS_TEXTUREFACTOR             60
+CONSTANT: D3DRS_WRAP0                     128
+CONSTANT: D3DRS_WRAP1                     129
+CONSTANT: D3DRS_WRAP2                     130
+CONSTANT: D3DRS_WRAP3                     131
+CONSTANT: D3DRS_WRAP4                     132
+CONSTANT: D3DRS_WRAP5                     133
+CONSTANT: D3DRS_WRAP6                     134
+CONSTANT: D3DRS_WRAP7                     135
+CONSTANT: D3DRS_CLIPPING                  136
+CONSTANT: D3DRS_LIGHTING                  137
+CONSTANT: D3DRS_AMBIENT                   139
+CONSTANT: D3DRS_FOGVERTEXMODE             140
+CONSTANT: D3DRS_COLORVERTEX               141
+CONSTANT: D3DRS_LOCALVIEWER               142
+CONSTANT: D3DRS_NORMALIZENORMALS          143
+CONSTANT: D3DRS_DIFFUSEMATERIALSOURCE     145
+CONSTANT: D3DRS_SPECULARMATERIALSOURCE    146
+CONSTANT: D3DRS_AMBIENTMATERIALSOURCE     147
+CONSTANT: D3DRS_EMISSIVEMATERIALSOURCE    148
+CONSTANT: D3DRS_VERTEXBLEND               151
+CONSTANT: D3DRS_CLIPPLANEENABLE           152
+CONSTANT: D3DRS_POINTSIZE                 154
+CONSTANT: D3DRS_POINTSIZE_MIN             155
+CONSTANT: D3DRS_POINTSPRITEENABLE         156
+CONSTANT: D3DRS_POINTSCALEENABLE          157
+CONSTANT: D3DRS_POINTSCALE_A              158
+CONSTANT: D3DRS_POINTSCALE_B              159
+CONSTANT: D3DRS_POINTSCALE_C              160
+CONSTANT: D3DRS_MULTISAMPLEANTIALIAS      161
+CONSTANT: D3DRS_MULTISAMPLEMASK           162
+CONSTANT: D3DRS_PATCHEDGESTYLE            163
+CONSTANT: D3DRS_DEBUGMONITORTOKEN         165
+CONSTANT: D3DRS_POINTSIZE_MAX             166
+CONSTANT: D3DRS_INDEXEDVERTEXBLENDENABLE  167
+CONSTANT: D3DRS_COLORWRITEENABLE          168
+CONSTANT: D3DRS_TWEENFACTOR               170
+CONSTANT: D3DRS_BLENDOP                   171
+CONSTANT: D3DRS_POSITIONDEGREE            172
+CONSTANT: D3DRS_NORMALDEGREE              173
+CONSTANT: D3DRS_SCISSORTESTENABLE         174
+CONSTANT: D3DRS_SLOPESCALEDEPTHBIAS       175
+CONSTANT: D3DRS_ANTIALIASEDLINEENABLE     176
+CONSTANT: D3DRS_MINTESSELLATIONLEVEL      178
+CONSTANT: D3DRS_MAXTESSELLATIONLEVEL      179
+CONSTANT: D3DRS_ADAPTIVETESS_X            180
+CONSTANT: D3DRS_ADAPTIVETESS_Y            181
+CONSTANT: D3DRS_ADAPTIVETESS_Z            182
+CONSTANT: D3DRS_ADAPTIVETESS_W            183
+CONSTANT: D3DRS_ENABLEADAPTIVETESSELLATION 184
+CONSTANT: D3DRS_TWOSIDEDSTENCILMODE       185
+CONSTANT: D3DRS_CCW_STENCILFAIL           186
+CONSTANT: D3DRS_CCW_STENCILZFAIL          187
+CONSTANT: D3DRS_CCW_STENCILPASS           188
+CONSTANT: D3DRS_CCW_STENCILFUNC           189
+CONSTANT: D3DRS_COLORWRITEENABLE1         190
+CONSTANT: D3DRS_COLORWRITEENABLE2         191
+CONSTANT: D3DRS_COLORWRITEENABLE3         192
+CONSTANT: D3DRS_BLENDFACTOR               193
+CONSTANT: D3DRS_SRGBWRITEENABLE           194
+CONSTANT: D3DRS_DEPTHBIAS                 195
+CONSTANT: D3DRS_WRAP8                     198
+CONSTANT: D3DRS_WRAP9                     199
+CONSTANT: D3DRS_WRAP10                    200
+CONSTANT: D3DRS_WRAP11                    201
+CONSTANT: D3DRS_WRAP12                    202
+CONSTANT: D3DRS_WRAP13                    203
+CONSTANT: D3DRS_WRAP14                    204
+CONSTANT: D3DRS_WRAP15                    205
+CONSTANT: D3DRS_SEPARATEALPHABLENDENABLE  206
+CONSTANT: D3DRS_SRCBLENDALPHA             207
+CONSTANT: D3DRS_DESTBLENDALPHA            208
+CONSTANT: D3DRS_BLENDOPALPHA              209
+CONSTANT: D3DRS_FORCE_DWORD               HEX: 7fffffff
+
+CONSTANT: D3D_MAX_SIMULTANEOUS_RENDERTARGETS 4
+
+TYPEDEF: int D3DMATERIALCOLORSOURCE
+CONSTANT: D3DMCS_MATERIAL         0
+CONSTANT: D3DMCS_COLOR1           1
+CONSTANT: D3DMCS_COLOR2           2
+CONSTANT: D3DMCS_FORCE_DWORD      HEX: 7fffffff
+
+CONSTANT: D3DRENDERSTATE_WRAPBIAS                 128
+
+CONSTANT: D3DWRAP_U   HEX: 00000001
+CONSTANT: D3DWRAP_V   HEX: 00000002
+CONSTANT: D3DWRAP_W   HEX: 00000004
+
+CONSTANT: D3DWRAPCOORD_0   HEX: 00000001
+CONSTANT: D3DWRAPCOORD_1   HEX: 00000002
+CONSTANT: D3DWRAPCOORD_2   HEX: 00000004
+CONSTANT: D3DWRAPCOORD_3   HEX: 00000008
+
+CONSTANT: D3DCOLORWRITEENABLE_RED     1
+CONSTANT: D3DCOLORWRITEENABLE_GREEN   2
+CONSTANT: D3DCOLORWRITEENABLE_BLUE    4
+CONSTANT: D3DCOLORWRITEENABLE_ALPHA   8
+
+TYPEDEF: int D3DTEXTURESTAGESTATETYPE
+CONSTANT: D3DTSS_COLOROP        1
+CONSTANT: D3DTSS_COLORARG1      2
+CONSTANT: D3DTSS_COLORARG2      3
+CONSTANT: D3DTSS_ALPHAOP        4
+CONSTANT: D3DTSS_ALPHAARG1      5
+CONSTANT: D3DTSS_ALPHAARG2      6
+CONSTANT: D3DTSS_BUMPENVMAT00   7
+CONSTANT: D3DTSS_BUMPENVMAT01   8
+CONSTANT: D3DTSS_BUMPENVMAT10   9
+CONSTANT: D3DTSS_BUMPENVMAT11   10
+CONSTANT: D3DTSS_TEXCOORDINDEX  11
+CONSTANT: D3DTSS_BUMPENVLSCALE  22
+CONSTANT: D3DTSS_BUMPENVLOFFSET 23
+CONSTANT: D3DTSS_TEXTURETRANSFORMFLAGS 24
+CONSTANT: D3DTSS_COLORARG0      26
+CONSTANT: D3DTSS_ALPHAARG0      27
+CONSTANT: D3DTSS_RESULTARG      28
+CONSTANT: D3DTSS_CONSTANT       32
+CONSTANT: D3DTSS_FORCE_DWORD   HEX: 7fffffff
+
+TYPEDEF: int D3DSAMPLERSTATETYPE
+CONSTANT: D3DSAMP_ADDRESSU       1
+CONSTANT: D3DSAMP_ADDRESSV       2
+CONSTANT: D3DSAMP_ADDRESSW       3
+CONSTANT: D3DSAMP_BORDERCOLOR    4
+CONSTANT: D3DSAMP_MAGFILTER      5
+CONSTANT: D3DSAMP_MINFILTER      6
+CONSTANT: D3DSAMP_MIPFILTER      7
+CONSTANT: D3DSAMP_MIPMAPLODBIAS  8
+CONSTANT: D3DSAMP_MAXMIPLEVEL    9
+CONSTANT: D3DSAMP_MAXANISOTROPY  10
+CONSTANT: D3DSAMP_SRGBTEXTURE    11
+CONSTANT: D3DSAMP_ELEMENTINDEX   12
+CONSTANT: D3DSAMP_DMAPOFFSET     13
+CONSTANT: D3DSAMP_FORCE_DWORD   HEX: 7fffffff
+
+CONSTANT: D3DDMAPSAMPLER 256
+
+CONSTANT: D3DVERTEXTEXTURESAMPLER0 257
+CONSTANT: D3DVERTEXTEXTURESAMPLER1 258
+CONSTANT: D3DVERTEXTEXTURESAMPLER2 259
+CONSTANT: D3DVERTEXTEXTURESAMPLER3 260
+
+CONSTANT: D3DTSS_TCI_PASSTHRU                             HEX: 00000000
+CONSTANT: D3DTSS_TCI_CAMERASPACENORMAL                    HEX: 00010000
+CONSTANT: D3DTSS_TCI_CAMERASPACEPOSITION                  HEX: 00020000
+CONSTANT: D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR          HEX: 00030000
+CONSTANT: D3DTSS_TCI_SPHEREMAP                            HEX: 00040000
+
+TYPEDEF: int D3DTEXTUREOP
+CONSTANT: D3DTOP_DISABLE              1
+CONSTANT: D3DTOP_SELECTARG1           2
+CONSTANT: D3DTOP_SELECTARG2           3
+CONSTANT: D3DTOP_MODULATE             4
+CONSTANT: D3DTOP_MODULATE2X           5
+CONSTANT: D3DTOP_MODULATE4X           6
+CONSTANT: D3DTOP_ADD                  7
+CONSTANT: D3DTOP_ADDSIGNED            8
+CONSTANT: D3DTOP_ADDSIGNED2X          9
+CONSTANT: D3DTOP_SUBTRACT             10
+CONSTANT: D3DTOP_ADDSMOOTH            11
+CONSTANT: D3DTOP_BLENDDIFFUSEALPHA    12
+CONSTANT: D3DTOP_BLENDTEXTUREALPHA    13
+CONSTANT: D3DTOP_BLENDFACTORALPHA     14
+CONSTANT: D3DTOP_BLENDTEXTUREALPHAPM  15
+CONSTANT: D3DTOP_BLENDCURRENTALPHA    16
+CONSTANT: D3DTOP_PREMODULATE            17
+CONSTANT: D3DTOP_MODULATEALPHA_ADDCOLOR 18
+CONSTANT: D3DTOP_MODULATECOLOR_ADDALPHA 19
+CONSTANT: D3DTOP_MODULATEINVALPHA_ADDCOLOR 20
+CONSTANT: D3DTOP_MODULATEINVCOLOR_ADDALPHA 21
+CONSTANT: D3DTOP_BUMPENVMAP           22
+CONSTANT: D3DTOP_BUMPENVMAPLUMINANCE  23
+CONSTANT: D3DTOP_DOTPRODUCT3          24
+CONSTANT: D3DTOP_MULTIPLYADD          25
+CONSTANT: D3DTOP_LERP                 26
+CONSTANT: D3DTOP_FORCE_DWORD HEX: 7fffffff
+
+CONSTANT: D3DTA_SELECTMASK        HEX: 0000000f
+CONSTANT: D3DTA_DIFFUSE           HEX: 00000000
+CONSTANT: D3DTA_CURRENT           HEX: 00000001
+CONSTANT: D3DTA_TEXTURE           HEX: 00000002
+CONSTANT: D3DTA_TFACTOR           HEX: 00000003
+CONSTANT: D3DTA_SPECULAR          HEX: 00000004
+CONSTANT: D3DTA_TEMP              HEX: 00000005
+CONSTANT: D3DTA_CONSTANT          HEX: 00000006
+CONSTANT: D3DTA_COMPLEMENT        HEX: 00000010
+CONSTANT: D3DTA_ALPHAREPLICATE    HEX: 00000020
+
+TYPEDEF: int D3DTEXTUREFILTERTYPE
+CONSTANT: D3DTEXF_NONE            0
+CONSTANT: D3DTEXF_POINT           1
+CONSTANT: D3DTEXF_LINEAR          2
+CONSTANT: D3DTEXF_ANISOTROPIC     3
+CONSTANT: D3DTEXF_PYRAMIDALQUAD   6
+CONSTANT: D3DTEXF_GAUSSIANQUAD    7
+CONSTANT: D3DTEXF_CONVOLUTIONMONO 8
+CONSTANT: D3DTEXF_FORCE_DWORD     HEX: 7fffffff
+
+CONSTANT: D3DPV_DONOTCOPYDATA     1
+
+CONSTANT: D3DFVF_RESERVED0        HEX: 001
+CONSTANT: D3DFVF_POSITION_MASK    HEX: 400E
+CONSTANT: D3DFVF_XYZ              HEX: 002
+CONSTANT: D3DFVF_XYZRHW           HEX: 004
+CONSTANT: D3DFVF_XYZB1            HEX: 006
+CONSTANT: D3DFVF_XYZB2            HEX: 008
+CONSTANT: D3DFVF_XYZB3            HEX: 00a
+CONSTANT: D3DFVF_XYZB4            HEX: 00c
+CONSTANT: D3DFVF_XYZB5            HEX: 00e
+CONSTANT: D3DFVF_XYZW             HEX: 4002
+
+CONSTANT: D3DFVF_NORMAL           HEX: 010
+CONSTANT: D3DFVF_PSIZE            HEX: 020
+CONSTANT: D3DFVF_DIFFUSE          HEX: 040
+CONSTANT: D3DFVF_SPECULAR         HEX: 080
+
+CONSTANT: D3DFVF_TEXCOUNT_MASK    HEX: f00
+CONSTANT: D3DFVF_TEXCOUNT_SHIFT   8
+CONSTANT: D3DFVF_TEX0             HEX: 000
+CONSTANT: D3DFVF_TEX1             HEX: 100
+CONSTANT: D3DFVF_TEX2             HEX: 200
+CONSTANT: D3DFVF_TEX3             HEX: 300
+CONSTANT: D3DFVF_TEX4             HEX: 400
+CONSTANT: D3DFVF_TEX5             HEX: 500
+CONSTANT: D3DFVF_TEX6             HEX: 600
+CONSTANT: D3DFVF_TEX7             HEX: 700
+CONSTANT: D3DFVF_TEX8             HEX: 800
+
+CONSTANT: D3DFVF_LASTBETA_UBYTE4   HEX: 1000
+CONSTANT: D3DFVF_LASTBETA_D3DCOLOR HEX: 8000
+
+CONSTANT: D3DFVF_RESERVED2         HEX: 6000
+
+TYPEDEF: int D3DDECLUSAGE
+CONSTANT: D3DDECLUSAGE_POSITION     0
+CONSTANT: D3DDECLUSAGE_BLENDWEIGHT  1
+CONSTANT: D3DDECLUSAGE_BLENDINDICES 2
+CONSTANT: D3DDECLUSAGE_NORMAL       3
+CONSTANT: D3DDECLUSAGE_PSIZE        4
+CONSTANT: D3DDECLUSAGE_TEXCOORD     5
+CONSTANT: D3DDECLUSAGE_TANGENT      6
+CONSTANT: D3DDECLUSAGE_BINORMAL     7
+CONSTANT: D3DDECLUSAGE_TESSFACTOR   8
+CONSTANT: D3DDECLUSAGE_POSITIONT    9
+CONSTANT: D3DDECLUSAGE_COLOR        10
+CONSTANT: D3DDECLUSAGE_FOG          11
+CONSTANT: D3DDECLUSAGE_DEPTH        12
+CONSTANT: D3DDECLUSAGE_SAMPLE       13
+
+CONSTANT: MAXD3DDECLUSAGE         13
+CONSTANT: MAXD3DDECLUSAGEINDEX    15
+CONSTANT: MAXD3DDECLLENGTH        64
+
+TYPEDEF: int D3DDECLMETHOD
+C-ENUM:
+    D3DDECLMETHOD_DEFAULT
+    D3DDECLMETHOD_PARTIALU
+    D3DDECLMETHOD_PARTIALV
+    D3DDECLMETHOD_CROSSUV
+    D3DDECLMETHOD_UV
+    D3DDECLMETHOD_LOOKUP
+    D3DDECLMETHOD_LOOKUPPRESAMPLED ;
+
+: MAXD3DDECLMETHOD ( -- n ) D3DDECLMETHOD_LOOKUPPRESAMPLED ; inline
+
+TYPEDEF: int D3DDECLTYPE
+CONSTANT: D3DDECLTYPE_FLOAT1    0
+CONSTANT: D3DDECLTYPE_FLOAT2    1
+CONSTANT: D3DDECLTYPE_FLOAT3    2
+CONSTANT: D3DDECLTYPE_FLOAT4    3
+CONSTANT: D3DDECLTYPE_D3DCOLOR  4
+CONSTANT: D3DDECLTYPE_UBYTE4    5
+CONSTANT: D3DDECLTYPE_SHORT2    6
+CONSTANT: D3DDECLTYPE_SHORT4    7
+CONSTANT: D3DDECLTYPE_UBYTE4N   8
+CONSTANT: D3DDECLTYPE_SHORT2N   9
+CONSTANT: D3DDECLTYPE_SHORT4N   10
+CONSTANT: D3DDECLTYPE_USHORT2N  11
+CONSTANT: D3DDECLTYPE_USHORT4N  12
+CONSTANT: D3DDECLTYPE_UDEC3     13
+CONSTANT: D3DDECLTYPE_DEC3N     14
+CONSTANT: D3DDECLTYPE_FLOAT16_2 15
+CONSTANT: D3DDECLTYPE_FLOAT16_4 16
+CONSTANT: D3DDECLTYPE_UNUSED    17
+
+: MAXD3DDECLTYPE ( -- n ) D3DDECLTYPE_UNUSED ; inline
+
+STRUCT: D3DVERTEXELEMENT9
+    { Stream        WORD }
+    { Offset        WORD }
+    { Type          BYTE }
+    { Method        BYTE }
+    { Usage         BYTE }
+    { UsageIndex    BYTE } ;
+TYPEDEF: D3DVERTEXELEMENT9* LPD3DVERTEXELEMENT9
+
+CONSTANT: D3DDP_MAXTEXCOORD   8
+
+CONSTANT: D3DSTREAMSOURCE_INDEXEDDATA  HEX: 40000000
+CONSTANT: D3DSTREAMSOURCE_INSTANCEDATA HEX: 80000000
+
+CONSTANT: D3DSI_OPCODE_MASK       HEX: 0000FFFF
+CONSTANT: D3DSI_INSTLENGTH_MASK   HEX: 0F000000
+CONSTANT: D3DSI_INSTLENGTH_SHIFT  24
+
+TYPEDEF: int D3DSHADER_INSTRUCTION_OPCODE_TYPE
+CONSTANT: D3DSIO_NOP          0
+CONSTANT: D3DSIO_MOV          1
+CONSTANT: D3DSIO_ADD          2
+CONSTANT: D3DSIO_SUB          3
+CONSTANT: D3DSIO_MAD          4
+CONSTANT: D3DSIO_MUL          5
+CONSTANT: D3DSIO_RCP          6
+CONSTANT: D3DSIO_RSQ          7
+CONSTANT: D3DSIO_DP3          8
+CONSTANT: D3DSIO_DP4          9
+CONSTANT: D3DSIO_MIN          10
+CONSTANT: D3DSIO_MAX          11
+CONSTANT: D3DSIO_SLT          12
+CONSTANT: D3DSIO_SGE          13
+CONSTANT: D3DSIO_EXP          14
+CONSTANT: D3DSIO_LOG          15
+CONSTANT: D3DSIO_LIT          16
+CONSTANT: D3DSIO_DST          17
+CONSTANT: D3DSIO_LRP          18
+CONSTANT: D3DSIO_FRC          19
+CONSTANT: D3DSIO_M4x4         20
+CONSTANT: D3DSIO_M4x3         21
+CONSTANT: D3DSIO_M3x4         22
+CONSTANT: D3DSIO_M3x3         23
+CONSTANT: D3DSIO_M3x2         24
+CONSTANT: D3DSIO_CALL         25
+CONSTANT: D3DSIO_CALLNZ       26
+CONSTANT: D3DSIO_LOOP         27
+CONSTANT: D3DSIO_RET          28
+CONSTANT: D3DSIO_ENDLOOP      29
+CONSTANT: D3DSIO_LABEL        30
+CONSTANT: D3DSIO_DCL          31
+CONSTANT: D3DSIO_POW          32
+CONSTANT: D3DSIO_CRS          33
+CONSTANT: D3DSIO_SGN          34
+CONSTANT: D3DSIO_ABS          35
+CONSTANT: D3DSIO_NRM          36
+CONSTANT: D3DSIO_SINCOS       37
+CONSTANT: D3DSIO_REP          38
+CONSTANT: D3DSIO_ENDREP       39
+CONSTANT: D3DSIO_IF           40
+CONSTANT: D3DSIO_IFC          41
+CONSTANT: D3DSIO_ELSE         42
+CONSTANT: D3DSIO_ENDIF        43
+CONSTANT: D3DSIO_BREAK        44
+CONSTANT: D3DSIO_BREAKC       45
+CONSTANT: D3DSIO_MOVA         46
+CONSTANT: D3DSIO_DEFB         47
+CONSTANT: D3DSIO_DEFI         48
+CONSTANT: D3DSIO_TEXCOORD     64
+CONSTANT: D3DSIO_TEXKILL      65
+CONSTANT: D3DSIO_TEX          66
+CONSTANT: D3DSIO_TEXBEM       67
+CONSTANT: D3DSIO_TEXBEML      68
+CONSTANT: D3DSIO_TEXREG2AR    69
+CONSTANT: D3DSIO_TEXREG2GB    70
+CONSTANT: D3DSIO_TEXM3x2PAD   71
+CONSTANT: D3DSIO_TEXM3x2TEX   72
+CONSTANT: D3DSIO_TEXM3x3PAD   73
+CONSTANT: D3DSIO_TEXM3x3TEX   74
+CONSTANT: D3DSIO_RESERVED0    75
+CONSTANT: D3DSIO_TEXM3x3SPEC  76
+CONSTANT: D3DSIO_TEXM3x3VSPEC 77
+CONSTANT: D3DSIO_EXPP         78
+CONSTANT: D3DSIO_LOGP         79
+CONSTANT: D3DSIO_CND          80
+CONSTANT: D3DSIO_DEF          81
+CONSTANT: D3DSIO_TEXREG2RGB   82
+CONSTANT: D3DSIO_TEXDP3TEX    83
+CONSTANT: D3DSIO_TEXM3x2DEPTH 84
+CONSTANT: D3DSIO_TEXDP3       85
+CONSTANT: D3DSIO_TEXM3x3      86
+CONSTANT: D3DSIO_TEXDEPTH     87
+CONSTANT: D3DSIO_CMP          88
+CONSTANT: D3DSIO_BEM          89
+CONSTANT: D3DSIO_DP2ADD       90
+CONSTANT: D3DSIO_DSX          91
+CONSTANT: D3DSIO_DSY          92
+CONSTANT: D3DSIO_TEXLDD       93
+CONSTANT: D3DSIO_SETP         94
+CONSTANT: D3DSIO_TEXLDL       95
+CONSTANT: D3DSIO_BREAKP       96
+CONSTANT: D3DSIO_PHASE        HEX: FFFD
+CONSTANT: D3DSIO_COMMENT      HEX: FFFE
+CONSTANT: D3DSIO_END          HEX: FFFF
+CONSTANT: D3DSIO_FORCE_DWORD  HEX: 7fffffff
+
+CONSTANT: D3DSI_COISSUE           HEX: 40000000
+
+CONSTANT: D3DSP_OPCODESPECIFICCONTROL_MASK  HEX: 00ff0000
+CONSTANT: D3DSP_OPCODESPECIFICCONTROL_SHIFT 16
+
+: D3DSI_TEXLD_PROJECT ( -- n ) 1 D3DSP_OPCODESPECIFICCONTROL_SHIFT shift ; inline
+: D3DSI_TEXLD_BIAS    ( -- n ) 2 D3DSP_OPCODESPECIFICCONTROL_SHIFT shift ; inline
+
+TYPEDEF: int D3DSHADER_COMPARISON
+CONSTANT: D3DSPC_RESERVED0 0
+CONSTANT: D3DSPC_GT        1
+CONSTANT: D3DSPC_EQ        2
+CONSTANT: D3DSPC_GE        3
+CONSTANT: D3DSPC_LT        4
+CONSTANT: D3DSPC_NE        5
+CONSTANT: D3DSPC_LE        6
+CONSTANT: D3DSPC_RESERVED1 7  
+
+CONSTANT: D3DSHADER_COMPARISON_SHIFT D3DSP_OPCODESPECIFICCONTROL_SHIFT
+: D3DSHADER_COMPARISON_MASK ( -- n ) 7 D3DSHADER_COMPARISON_SHIFT shift ; inline
+
+CONSTANT: D3DSHADER_INSTRUCTION_PREDICATED    HEX: 10000000
+
+CONSTANT: D3DSP_DCL_USAGE_SHIFT 0
+CONSTANT: D3DSP_DCL_USAGE_MASK  HEX: 0000000f
+
+CONSTANT: D3DSP_DCL_USAGEINDEX_SHIFT 16
+CONSTANT: D3DSP_DCL_USAGEINDEX_MASK  HEX: 000f0000
+
+CONSTANT: D3DSP_TEXTURETYPE_SHIFT 27
+CONSTANT: D3DSP_TEXTURETYPE_MASK  HEX: 78000000
+
+TYPEDEF: int D3DSAMPLER_TEXTURE_TYPE
+: D3DSTT_UNKNOWN ( -- n ) 0 D3DSP_TEXTURETYPE_SHIFT shift ; inline
+: D3DSTT_2D      ( -- n ) 2 D3DSP_TEXTURETYPE_SHIFT shift ; inline
+: D3DSTT_CUBE    ( -- n ) 3 D3DSP_TEXTURETYPE_SHIFT shift ; inline
+: D3DSTT_VOLUME  ( -- n ) 4 D3DSP_TEXTURETYPE_SHIFT shift ; inline
+CONSTANT: D3DSTT_FORCE_DWORD HEX: 7fffffff
+
+CONSTANT: D3DSP_REGNUM_MASK       HEX: 000007FF
+
+CONSTANT: D3DSP_WRITEMASK_0       HEX: 00010000
+CONSTANT: D3DSP_WRITEMASK_1       HEX: 00020000
+CONSTANT: D3DSP_WRITEMASK_2       HEX: 00040000
+CONSTANT: D3DSP_WRITEMASK_3       HEX: 00080000
+CONSTANT: D3DSP_WRITEMASK_ALL     HEX: 000F0000
+
+CONSTANT: D3DSP_DSTMOD_SHIFT      20
+CONSTANT: D3DSP_DSTMOD_MASK       HEX: 00F00000
+
+: D3DSPDM_NONE             ( -- n ) 0 D3DSP_DSTMOD_SHIFT shift ; inline
+: D3DSPDM_SATURATE         ( -- n ) 1 D3DSP_DSTMOD_SHIFT shift ; inline
+: D3DSPDM_PARTIALPRECISION ( -- n ) 2 D3DSP_DSTMOD_SHIFT shift ; inline
+: D3DSPDM_MSAMPCENTROID    ( -- n ) 4 D3DSP_DSTMOD_SHIFT shift ; inline
+
+CONSTANT: D3DSP_DSTSHIFT_SHIFT    24
+CONSTANT: D3DSP_DSTSHIFT_MASK     HEX: 0F000000
+
+CONSTANT: D3DSP_REGTYPE_SHIFT     28
+CONSTANT: D3DSP_REGTYPE_SHIFT2    8
+CONSTANT: D3DSP_REGTYPE_MASK      HEX: 70000000
+CONSTANT: D3DSP_REGTYPE_MASK2     HEX: 00001800
+
+TYPEDEF: int D3DSHADER_PARAM_REGISTER_TYPE
+CONSTANT: D3DSPR_TEMP           0
+CONSTANT: D3DSPR_INPUT          1
+CONSTANT: D3DSPR_CONST          2
+CONSTANT: D3DSPR_ADDR           3
+CONSTANT: D3DSPR_TEXTURE        3
+CONSTANT: D3DSPR_RASTOUT        4
+CONSTANT: D3DSPR_ATTROUT        5
+CONSTANT: D3DSPR_TEXCRDOUT      6
+CONSTANT: D3DSPR_OUTPUT         6
+CONSTANT: D3DSPR_CONSTINT       7
+CONSTANT: D3DSPR_COLOROUT       8
+CONSTANT: D3DSPR_DEPTHOUT       9
+CONSTANT: D3DSPR_SAMPLER        10
+CONSTANT: D3DSPR_CONST2         11
+CONSTANT: D3DSPR_CONST3         12
+CONSTANT: D3DSPR_CONST4         13
+CONSTANT: D3DSPR_CONSTBOOL      14
+CONSTANT: D3DSPR_LOOP           15
+CONSTANT: D3DSPR_TEMPFLOAT16    16
+CONSTANT: D3DSPR_MISCTYPE       17
+CONSTANT: D3DSPR_LABEL          18
+CONSTANT: D3DSPR_PREDICATE      19
+CONSTANT: D3DSPR_FORCE_DWORD  HEX: 7fffffff
+
+TYPEDEF: int D3DSHADER_MISCTYPE_OFFSETS
+CONSTANT: D3DSMO_POSITION   0
+CONSTANT: D3DSMO_FACE       1
+
+TYPEDEF: int D3DVS_RASTOUT_OFFSETS
+CONSTANT: D3DSRO_POSITION   0
+CONSTANT: D3DSRO_FOG        1
+CONSTANT: D3DSRO_POINT_SIZE 2
+CONSTANT: D3DSRO_FORCE_DWORD HEX: 7fffffff
+
+CONSTANT: D3DVS_ADDRESSMODE_SHIFT 13
+: D3DVS_ADDRESSMODE_MASK ( -- n ) 1 D3DVS_ADDRESSMODE_SHIFT shift ; inline
+
+TYPEDEF: int D3DVS_ADDRESSMODE_TYPE
+: D3DVS_ADDRMODE_ABSOLUTE ( -- n ) 0 D3DVS_ADDRESSMODE_SHIFT shift ; inline
+: D3DVS_ADDRMODE_RELATIVE ( -- n ) 1 D3DVS_ADDRESSMODE_SHIFT shift ; inline
+CONSTANT: D3DVS_ADDRMODE_FORCE_DWORD HEX: 7fffffff
+
+CONSTANT: D3DSHADER_ADDRESSMODE_SHIFT 13
+: D3DSHADER_ADDRESSMODE_MASK ( -- n ) 1 D3DSHADER_ADDRESSMODE_SHIFT shift ; inline
+
+TYPEDEF: int D3DSHADER_ADDRESSMODE_TYPE
+: D3DSHADER_ADDRMODE_ABSOLUTE ( -- n ) 0 D3DSHADER_ADDRESSMODE_SHIFT shift ; inline
+: D3DSHADER_ADDRMODE_RELATIVE ( -- n ) 1 D3DSHADER_ADDRESSMODE_SHIFT shift ; inline
+CONSTANT: D3DSHADER_ADDRMODE_FORCE_DWORD HEX: 7fffffff
+
+CONSTANT: D3DVS_SWIZZLE_SHIFT     16
+CONSTANT: D3DVS_SWIZZLE_MASK      HEX: 00FF0000
+
+: D3DVS_X_X ( -- n ) 0 D3DVS_SWIZZLE_SHIFT shift ; inline
+: D3DVS_X_Y ( -- n ) 1 D3DVS_SWIZZLE_SHIFT shift ; inline
+: D3DVS_X_Z ( -- n ) 2 D3DVS_SWIZZLE_SHIFT shift ; inline
+: D3DVS_X_W ( -- n ) 3 D3DVS_SWIZZLE_SHIFT shift ; inline
+
+: D3DVS_Y_X ( -- n ) 0 D3DVS_SWIZZLE_SHIFT 2 + shift ; inline
+: D3DVS_Y_Y ( -- n ) 1 D3DVS_SWIZZLE_SHIFT 2 + shift ; inline
+: D3DVS_Y_Z ( -- n ) 2 D3DVS_SWIZZLE_SHIFT 2 + shift ; inline
+: D3DVS_Y_W ( -- n ) 3 D3DVS_SWIZZLE_SHIFT 2 + shift ; inline
+
+: D3DVS_Z_X ( -- n ) 0 D3DVS_SWIZZLE_SHIFT 4 + shift ; inline
+: D3DVS_Z_Y ( -- n ) 1 D3DVS_SWIZZLE_SHIFT 4 + shift ; inline
+: D3DVS_Z_Z ( -- n ) 2 D3DVS_SWIZZLE_SHIFT 4 + shift ; inline
+: D3DVS_Z_W ( -- n ) 3 D3DVS_SWIZZLE_SHIFT 4 + shift ; inline
+
+: D3DVS_W_X ( -- n ) 0 D3DVS_SWIZZLE_SHIFT 6 + shift ; inline
+: D3DVS_W_Y ( -- n ) 1 D3DVS_SWIZZLE_SHIFT 6 + shift ; inline
+: D3DVS_W_Z ( -- n ) 2 D3DVS_SWIZZLE_SHIFT 6 + shift ; inline
+: D3DVS_W_W ( -- n ) 3 D3DVS_SWIZZLE_SHIFT 6 + shift ; inline
+
+: D3DVS_NOSWIZZLE ( -- n )
+    { D3DVS_X_X D3DVS_Y_Y D3DVS_Z_Z D3DVS_W_W } flags ; inline
+
+CONSTANT: D3DSP_SWIZZLE_SHIFT     16
+CONSTANT: D3DSP_SWIZZLE_MASK      HEX: 00FF0000
+CONSTANT: D3DSP_SRCMOD_SHIFT      24
+CONSTANT: D3DSP_SRCMOD_MASK       HEX: 0F000000
+
+TYPEDEF: int D3DSHADER_PARAM_SRCMOD_TYPE
+: D3DSPSM_NONE    ( -- n ) 0 D3DSP_SRCMOD_SHIFT shift ; inline
+: D3DSPSM_NEG     ( -- n ) 1 D3DSP_SRCMOD_SHIFT shift ; inline
+: D3DSPSM_BIAS    ( -- n ) 2 D3DSP_SRCMOD_SHIFT shift ; inline
+: D3DSPSM_BIASNEG ( -- n ) 3 D3DSP_SRCMOD_SHIFT shift ; inline
+: D3DSPSM_SIGN    ( -- n ) 4 D3DSP_SRCMOD_SHIFT shift ; inline
+: D3DSPSM_SIGNNEG ( -- n ) 5 D3DSP_SRCMOD_SHIFT shift ; inline
+: D3DSPSM_COMP    ( -- n ) 6 D3DSP_SRCMOD_SHIFT shift ; inline
+: D3DSPSM_X2      ( -- n ) 7 D3DSP_SRCMOD_SHIFT shift ; inline
+: D3DSPSM_X2NEG   ( -- n ) 8 D3DSP_SRCMOD_SHIFT shift ; inline
+: D3DSPSM_DZ      ( -- n ) 9 D3DSP_SRCMOD_SHIFT shift ; inline
+: D3DSPSM_DW      ( -- n ) 10 D3DSP_SRCMOD_SHIFT shift ; inline
+: D3DSPSM_ABS     ( -- n ) 11 D3DSP_SRCMOD_SHIFT shift ; inline
+: D3DSPSM_ABSNEG  ( -- n ) 12 D3DSP_SRCMOD_SHIFT shift ; inline
+: D3DSPSM_NOT     ( -- n ) 13 D3DSP_SRCMOD_SHIFT shift ; inline
+CONSTANT: D3DSPSM_FORCE_DWORD HEX: 7fffffff
+
+: D3DPS_VERSION ( major minor -- n )
+    swap 8 shift bitor HEX: FFFF0000 bitor ; inline
+: D3DVS_VERSION ( major minor -- n )
+    swap 8 shift bitor HEX: FFFF0000 bitor ; inline
+
+: D3DSHADER_VERSION_MAJOR ( version -- n )
+    -8 shift HEX: FF bitand ; inline
+: D3DSHADER_VERSION_MINOR ( version -- n )
+    HEX: FF bitand ; inline
+
+CONSTANT: D3DSI_COMMENTSIZE_SHIFT 16
+CONSTANT: D3DSI_COMMENTSIZE_MASK  HEX: 7FFF0000
+
+CONSTANT: D3DPS_END()  HEX: 0000FFFF
+CONSTANT: D3DVS_END()  HEX: 0000FFFF
+
+TYPEDEF: int D3DBASISTYPE
+CONSTANT: D3DBASIS_BEZIER      0
+CONSTANT: D3DBASIS_BSPLINE     1
+CONSTANT: D3DBASIS_CATMULL_ROM 2
+CONSTANT: D3DBASIS_FORCE_DWORD HEX: 7fffffff
+
+TYPEDEF: int D3DDEGREETYPE
+CONSTANT: D3DDEGREE_LINEAR      1
+CONSTANT: D3DDEGREE_QUADRATIC   2
+CONSTANT: D3DDEGREE_CUBIC       3
+CONSTANT: D3DDEGREE_QUINTIC     5
+CONSTANT: D3DDEGREE_FORCE_DWORD HEX: 7fffffff
+
+TYPEDEF: int D3DPATCHEDGESTYLE
+CONSTANT: D3DPATCHEDGE_DISCRETE    0
+CONSTANT: D3DPATCHEDGE_CONTINUOUS  1
+CONSTANT: D3DPATCHEDGE_FORCE_DWORD HEX: 7fffffff
+
+TYPEDEF: int D3DSTATEBLOCKTYPE
+CONSTANT: D3DSBT_ALL           1
+CONSTANT: D3DSBT_PIXELSTATE    2
+CONSTANT: D3DSBT_VERTEXSTATE   3
+CONSTANT: D3DSBT_FORCE_DWORD   HEX: 7fffffff
+
+TYPEDEF: int D3DVERTEXBLENDFLAGS
+CONSTANT: D3DVBF_DISABLE  0
+CONSTANT: D3DVBF_1WEIGHTS 1
+CONSTANT: D3DVBF_2WEIGHTS 2
+CONSTANT: D3DVBF_3WEIGHTS 3
+CONSTANT: D3DVBF_TWEENING 255
+CONSTANT: D3DVBF_0WEIGHTS 256
+CONSTANT: D3DVBF_FORCE_DWORD HEX: 7fffffff
+
+TYPEDEF: int D3DTEXTURETRANSFORMFLAGS
+CONSTANT: D3DTTFF_DISABLE         0
+CONSTANT: D3DTTFF_COUNT1          1
+CONSTANT: D3DTTFF_COUNT2          2
+CONSTANT: D3DTTFF_COUNT3          3
+CONSTANT: D3DTTFF_COUNT4          4
+CONSTANT: D3DTTFF_PROJECTED       256
+CONSTANT: D3DTTFF_FORCE_DWORD     HEX: 7fffffff
+
+CONSTANT: D3DFVF_TEXTUREFORMAT2 0
+CONSTANT: D3DFVF_TEXTUREFORMAT1 3
+CONSTANT: D3DFVF_TEXTUREFORMAT3 1
+CONSTANT: D3DFVF_TEXTUREFORMAT4 2
+
+: D3DFVF_TEXCOORDSIZE3 ( CoordIndex -- n )
+    2 * 16 + D3DFVF_TEXTUREFORMAT3 swap shift ; inline
+: D3DFVF_TEXCOORDSIZE2 ( CoordIndex -- n )
+    drop D3DFVF_TEXTUREFORMAT2 ; inline
+: D3DFVF_TEXCOORDSIZE4 ( CoordIndex -- n )
+    2 * 16 + D3DFVF_TEXTUREFORMAT4 swap shift ; inline
+: D3DFVF_TEXCOORDSIZE1 ( CoordIndex -- n )
+    2 * 16 + D3DFVF_TEXTUREFORMAT1 swap shift ; inline
+
+TYPEDEF: int D3DDEVTYPE
+CONSTANT: D3DDEVTYPE_HAL         1
+CONSTANT: D3DDEVTYPE_REF         2
+CONSTANT: D3DDEVTYPE_SW          3
+CONSTANT: D3DDEVTYPE_NULLREF     4
+CONSTANT: D3DDEVTYPE_FORCE_DWORD  HEX: 7fffffff
+
+TYPEDEF: int D3DMULTISAMPLE_TYPE
+CONSTANT: D3DMULTISAMPLE_NONE            0
+CONSTANT: D3DMULTISAMPLE_NONMASKABLE     1
+CONSTANT: D3DMULTISAMPLE_2_SAMPLES       2
+CONSTANT: D3DMULTISAMPLE_3_SAMPLES       3
+CONSTANT: D3DMULTISAMPLE_4_SAMPLES       4
+CONSTANT: D3DMULTISAMPLE_5_SAMPLES       5
+CONSTANT: D3DMULTISAMPLE_6_SAMPLES       6
+CONSTANT: D3DMULTISAMPLE_7_SAMPLES       7
+CONSTANT: D3DMULTISAMPLE_8_SAMPLES       8
+CONSTANT: D3DMULTISAMPLE_9_SAMPLES       9
+CONSTANT: D3DMULTISAMPLE_10_SAMPLES      10
+CONSTANT: D3DMULTISAMPLE_11_SAMPLES      11
+CONSTANT: D3DMULTISAMPLE_12_SAMPLES      12
+CONSTANT: D3DMULTISAMPLE_13_SAMPLES      13
+CONSTANT: D3DMULTISAMPLE_14_SAMPLES      14
+CONSTANT: D3DMULTISAMPLE_15_SAMPLES      15
+CONSTANT: D3DMULTISAMPLE_16_SAMPLES      16
+CONSTANT: D3DMULTISAMPLE_FORCE_DWORD     HEX: 7fffffff
+
+:: MAKEFOURCC ( ch0 ch1 ch2 ch3 -- n )
+    ch3 HEX: ff bitand 24 shift
+    ch2 HEX: ff bitand 16 shift
+    ch1 HEX: ff bitand  8 shift
+    ch0 HEX: ff bitand bitor bitor bitor ; inline
+                                                                  
+TYPEDEF: int D3DFORMAT
+CONSTANT: D3DFMT_UNKNOWN              0
+CONSTANT: D3DFMT_R8G8B8               20
+CONSTANT: D3DFMT_A8R8G8B8             21
+CONSTANT: D3DFMT_X8R8G8B8             22
+CONSTANT: D3DFMT_R5G6B5               23
+CONSTANT: D3DFMT_X1R5G5B5             24
+CONSTANT: D3DFMT_A1R5G5B5             25
+CONSTANT: D3DFMT_A4R4G4B4             26
+CONSTANT: D3DFMT_R3G3B2               27
+CONSTANT: D3DFMT_A8                   28
+CONSTANT: D3DFMT_A8R3G3B2             29
+CONSTANT: D3DFMT_X4R4G4B4             30
+CONSTANT: D3DFMT_A2B10G10R10          31
+CONSTANT: D3DFMT_A8B8G8R8             32
+CONSTANT: D3DFMT_X8B8G8R8             33
+CONSTANT: D3DFMT_G16R16               34
+CONSTANT: D3DFMT_A2R10G10B10          35
+CONSTANT: D3DFMT_A16B16G16R16         36
+CONSTANT: D3DFMT_A8P8                 40
+CONSTANT: D3DFMT_P8                   41
+CONSTANT: D3DFMT_L8                   50
+CONSTANT: D3DFMT_A8L8                 51
+CONSTANT: D3DFMT_A4L4                 52
+CONSTANT: D3DFMT_V8U8                 60
+CONSTANT: D3DFMT_L6V5U5               61
+CONSTANT: D3DFMT_X8L8V8U8             62
+CONSTANT: D3DFMT_Q8W8V8U8             63
+CONSTANT: D3DFMT_V16U16               64
+CONSTANT: D3DFMT_A2W10V10U10          67
+#! : D3DFMT_UYVY                 ( -- n ) 'U' 'Y' 'V' 'Y' MAKEFOURCC
+#! D3DFMT_R8G8_B8G8            = MAKEFOURCC('R', 'G', 'B', 'G'),
+#! D3DFMT_YUY2                 = MAKEFOURCC('Y', 'U', 'Y', '2'),
+#! D3DFMT_G8R8_G8B8            = MAKEFOURCC('G', 'R', 'G', 'B'),
+#! D3DFMT_DXT1                 = MAKEFOURCC('D', 'X', 'T', '1'),
+#! D3DFMT_DXT2                 = MAKEFOURCC('D', 'X', 'T', '2'),
+#! D3DFMT_DXT3                 = MAKEFOURCC('D', 'X', 'T', '3'),
+#! D3DFMT_DXT4                 = MAKEFOURCC('D', 'X', 'T', '4'),
+#! D3DFMT_DXT5                 = MAKEFOURCC('D', 'X', 'T', '5'),
+CONSTANT: D3DFMT_D16_LOCKABLE         70
+CONSTANT: D3DFMT_D32                  71
+CONSTANT: D3DFMT_D15S1                73
+CONSTANT: D3DFMT_D24S8                75
+CONSTANT: D3DFMT_D24X8                77
+CONSTANT: D3DFMT_D24X4S4              79
+CONSTANT: D3DFMT_D16                  80
+CONSTANT: D3DFMT_D32F_LOCKABLE        82
+CONSTANT: D3DFMT_D24FS8               83
+CONSTANT: D3DFMT_D32_LOCKABLE         84
+CONSTANT: D3DFMT_S8_LOCKABLE          85
+CONSTANT: D3DFMT_L16                  81
+CONSTANT: D3DFMT_VERTEXDATA           100
+CONSTANT: D3DFMT_INDEX16              101
+CONSTANT: D3DFMT_INDEX32              102
+CONSTANT: D3DFMT_Q16W16V16U16         110
+#! D3DFMT_MULTI2_ARGB8         = MAKEFOURCC('M', 'E', 'T', '1'),
+CONSTANT: D3DFMT_R16F                 111
+CONSTANT: D3DFMT_G16R16F              112
+CONSTANT: D3DFMT_A16B16G16R16F        113
+CONSTANT: D3DFMT_R32F                 114
+CONSTANT: D3DFMT_G32R32F              115
+CONSTANT: D3DFMT_A32B32G32R32F        116
+CONSTANT: D3DFMT_CxV8U8               117
+CONSTANT: D3DFMT_A1                   118
+CONSTANT: D3DFMT_A2B10G10R10_XR_BIAS  119
+CONSTANT: D3DFMT_BINARYBUFFER         199
+CONSTANT: D3DFMT_FORCE_DWORD          HEX: 7fffffff
+
+STRUCT: D3DDISPLAYMODE
+    { Width                  UINT      }
+    { Height                 UINT      }
+    { RefreshRate            UINT      }
+    { Format                 D3DFORMAT } ;
+
+STRUCT: D3DDEVICE_CREATION_PARAMETERS
+    { AdapterOrdinal            UINT       }
+    { DeviceType                D3DDEVTYPE }
+    { hFocusWindow              HWND       }
+    { BehaviorFlags             DWORD      } ;
+
+TYPEDEF: int D3DSWAPEFFECT
+CONSTANT: D3DSWAPEFFECT_DISCARD           1
+CONSTANT: D3DSWAPEFFECT_FLIP              2
+CONSTANT: D3DSWAPEFFECT_COPY              3
+CONSTANT: D3DSWAPEFFECT_OVERLAY           4
+CONSTANT: D3DSWAPEFFECT_FLIPEX            5
+CONSTANT: D3DSWAPEFFECT_FORCE_DWORD       HEX: 7fffffff
+
+TYPEDEF: int D3DPOOL
+CONSTANT: D3DPOOL_DEFAULT                 0
+CONSTANT: D3DPOOL_MANAGED                 1
+CONSTANT: D3DPOOL_SYSTEMMEM               2
+CONSTANT: D3DPOOL_SCRATCH                 3
+CONSTANT: D3DPOOL_FORCE_DWORD             HEX: 7fffffff
+
+CONSTANT: D3DPRESENT_RATE_DEFAULT         HEX: 00000000
+
+STRUCT: D3DPRESENT_PARAMETERS
+    { BackBufferWidth             UINT                }
+    { BackBufferHeight            UINT                }
+    { BackBufferFormat            D3DFORMAT           }
+    { BackBufferCount             UINT                }
+    { MultiSampleType             D3DMULTISAMPLE_TYPE }
+    { MultiSampleQuality          DWORD               }
+    { SwapEffect                  D3DSWAPEFFECT       }
+    { hDeviceWindow               HWND                }
+    { Windowed                    BOOL                }
+    { EnableAutoDepthStencil      BOOL                }
+    { AutoDepthStencilFormat      D3DFORMAT           }
+    { Flags                       DWORD               }
+    { FullScreen_RefreshRateInHz  UINT                }
+    { PresentationInterval        UINT                } ;
+
+CONSTANT: D3DPRESENTFLAG_LOCKABLE_BACKBUFFER      HEX: 00000001
+CONSTANT: D3DPRESENTFLAG_DISCARD_DEPTHSTENCIL     HEX: 00000002
+CONSTANT: D3DPRESENTFLAG_DEVICECLIP               HEX: 00000004
+CONSTANT: D3DPRESENTFLAG_VIDEO                    HEX: 00000010
+
+CONSTANT: D3DPRESENTFLAG_NOAUTOROTATE                    HEX: 00000020
+CONSTANT: D3DPRESENTFLAG_UNPRUNEDMODE                    HEX: 00000040
+CONSTANT: D3DPRESENTFLAG_OVERLAY_LIMITEDRGB              HEX: 00000080
+CONSTANT: D3DPRESENTFLAG_OVERLAY_YCbCr_BT709             HEX: 00000100
+CONSTANT: D3DPRESENTFLAG_OVERLAY_YCbCr_xvYCC             HEX: 00000200
+CONSTANT: D3DPRESENTFLAG_RESTRICTED_CONTENT              HEX: 00000400
+CONSTANT: D3DPRESENTFLAG_RESTRICT_SHARED_RESOURCE_DRIVER HEX: 00000800
+
+STRUCT: D3DGAMMARAMP
+    { red   WORD[256] }
+    { green WORD[256] }
+    { blue  WORD[256] } ;
+
+TYPEDEF: int D3DBACKBUFFER_TYPE
+CONSTANT: D3DBACKBUFFER_TYPE_MONO         0
+CONSTANT: D3DBACKBUFFER_TYPE_LEFT         1
+CONSTANT: D3DBACKBUFFER_TYPE_RIGHT        2
+CONSTANT: D3DBACKBUFFER_TYPE_FORCE_DWORD  HEX: 7fffffff
+
+TYPEDEF: int D3DRESOURCETYPE
+CONSTANT: D3DRTYPE_SURFACE                1
+CONSTANT: D3DRTYPE_VOLUME                 2
+CONSTANT: D3DRTYPE_TEXTURE                3
+CONSTANT: D3DRTYPE_VOLUMETEXTURE          4
+CONSTANT: D3DRTYPE_CUBETEXTURE            5
+CONSTANT: D3DRTYPE_VERTEXBUFFER           6
+CONSTANT: D3DRTYPE_INDEXBUFFER            7
+CONSTANT: D3DRTYPE_FORCE_DWORD            HEX: 7fffffff
+
+CONSTANT: D3DUSAGE_RENDERTARGET       HEX: 00000001
+CONSTANT: D3DUSAGE_DEPTHSTENCIL       HEX: 00000002
+CONSTANT: D3DUSAGE_DYNAMIC            HEX: 00000200
+
+CONSTANT: D3DUSAGE_NONSECURE          HEX: 00800000
+
+CONSTANT: D3DUSAGE_AUTOGENMIPMAP      HEX: 00000400
+CONSTANT: D3DUSAGE_DMAP               HEX: 00004000
+
+CONSTANT: D3DUSAGE_QUERY_LEGACYBUMPMAP            HEX: 00008000
+CONSTANT: D3DUSAGE_QUERY_SRGBREAD                 HEX: 00010000
+CONSTANT: D3DUSAGE_QUERY_FILTER                   HEX: 00020000
+CONSTANT: D3DUSAGE_QUERY_SRGBWRITE                HEX: 00040000
+CONSTANT: D3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING HEX: 00080000
+CONSTANT: D3DUSAGE_QUERY_VERTEXTEXTURE            HEX: 00100000
+CONSTANT: D3DUSAGE_QUERY_WRAPANDMIP             HEX: 00200000
+
+CONSTANT: D3DUSAGE_WRITEONLY          HEX: 00000008
+CONSTANT: D3DUSAGE_SOFTWAREPROCESSING HEX: 00000010
+CONSTANT: D3DUSAGE_DONOTCLIP          HEX: 00000020
+CONSTANT: D3DUSAGE_POINTS             HEX: 00000040
+CONSTANT: D3DUSAGE_RTPATCHES          HEX: 00000080
+CONSTANT: D3DUSAGE_NPATCHES           HEX: 00000100
+
+CONSTANT: D3DUSAGE_TEXTAPI                         HEX: 10000000
+CONSTANT: D3DUSAGE_RESTRICTED_CONTENT              HEX: 00000800
+CONSTANT: D3DUSAGE_RESTRICT_SHARED_RESOURCE        HEX: 00002000
+CONSTANT: D3DUSAGE_RESTRICT_SHARED_RESOURCE_DRIVER HEX: 00001000
+
+TYPEDEF: int D3DCUBEMAP_FACES
+CONSTANT: D3DCUBEMAP_FACE_POSITIVE_X     0
+CONSTANT: D3DCUBEMAP_FACE_NEGATIVE_X     1
+CONSTANT: D3DCUBEMAP_FACE_POSITIVE_Y     2
+CONSTANT: D3DCUBEMAP_FACE_NEGATIVE_Y     3
+CONSTANT: D3DCUBEMAP_FACE_POSITIVE_Z     4
+CONSTANT: D3DCUBEMAP_FACE_NEGATIVE_Z     5
+CONSTANT: D3DCUBEMAP_FACE_FORCE_DWORD    HEX: 7fffffff
+
+CONSTANT: D3DLOCK_READONLY           HEX: 00000010
+CONSTANT: D3DLOCK_DISCARD            HEX: 00002000
+CONSTANT: D3DLOCK_NOOVERWRITE        HEX: 00001000
+CONSTANT: D3DLOCK_NOSYSLOCK          HEX: 00000800
+CONSTANT: D3DLOCK_DONOTWAIT          HEX: 00004000
+
+CONSTANT: D3DLOCK_NO_DIRTY_UPDATE     HEX: 00008000
+
+STRUCT: D3DVERTEXBUFFER_DESC
+    { Format              D3DFORMAT       }
+    { Type                D3DRESOURCETYPE }
+    { Usage               DWORD           }
+    { Pool                D3DPOOL         }
+    { Size                UINT            }
+    { FVF                 DWORD           } ;
+
+STRUCT: D3DINDEXBUFFER_DESC
+    { Format              D3DFORMAT       }
+    { Type                D3DRESOURCETYPE }
+    { Usage               DWORD           }
+    { Pool                D3DPOOL         }
+    { Size                UINT            } ;
+
+STRUCT: D3DSURFACE_DESC
+    { Format              D3DFORMAT           }
+    { Type                D3DRESOURCETYPE     }
+    { Usage               DWORD               }
+    { Pool                D3DPOOL             }
+    { MultiSampleType     D3DMULTISAMPLE_TYPE }
+    { MultiSampleQuality  DWORD               }
+    { Width               UINT                }
+    { Height              UINT                } ;
+
+STRUCT: D3DVOLUME_DESC
+
+    { Format              D3DFORMAT       }
+    { Type                D3DRESOURCETYPE }
+    { Usage               DWORD           }
+    { Pool                D3DPOOL         }
+    { Width               UINT            }
+    { Height              UINT            }
+    { Depth               UINT            } ;
+
+STRUCT: D3DLOCKED_RECT
+    { Pitch               INT   }
+    { pBits               void* } ;
+
+STRUCT: D3DBOX
+    { Left                  UINT }
+    { Top                   UINT }
+    { Right                 UINT }
+    { Bottom                UINT }
+    { Front                 UINT }
+    { Back                  UINT } ;
+
+STRUCT: D3DLOCKED_BOX
+    { RowPitch             INT   }
+    { SlicePitch           INT   }
+    { pBits                void* } ;
+
+STRUCT: D3DRANGE
+    { Offset                UINT }
+    { Size                  UINT } ;
+
+STRUCT: D3DRECTPATCH_INFO
+    { StartVertexOffsetWidth  UINT          }
+    { StartVertexOffsetHeight UINT          }
+    { Width                   UINT          }
+    { Height                  UINT          }
+    { Stride                  UINT          }
+    { Basis                   D3DBASISTYPE  }
+    { Degree                  D3DDEGREETYPE } ;
+
+STRUCT: D3DTRIPATCH_INFO
+    { StartVertexOffset       UINT          }
+    { NumVertices             UINT          }
+    { Basis                   D3DBASISTYPE  }
+    { Degree                  D3DDEGREETYPE } ;
+
+CONSTANT: MAX_DEVICE_IDENTIFIER_STRING        512
+
+STRUCT: D3DADAPTER_IDENTIFIER9
+    { Driver                      char[512]     }
+    { Description                 char[512]     }
+    { DeviceName                  char[32]      }
+    { DriverVersion               LARGE_INTEGER }
+    { VendorId                    DWORD         }
+    { DeviceId                    DWORD         }
+    { SubSysId                    DWORD         }
+    { Revision                    DWORD         }
+    { DeviceIdentifier            GUID          }
+    { WHQLLevel                   DWORD         } ;
+
+STRUCT: D3DRASTER_STATUS
+    { InVBlank            BOOL }
+    { ScanLine            UINT } ;
+
+TYPEDEF: int D3DDEBUGMONITORTOKENS
+CONSTANT: D3DDMT_ENABLE            0
+CONSTANT: D3DDMT_DISABLE           1
+CONSTANT: D3DDMT_FORCE_DWORD     HEX: 7fffffff
+
+TYPEDEF: int D3DQUERYTYPE
+CONSTANT: D3DQUERYTYPE_VCACHE                 4
+CONSTANT: D3DQUERYTYPE_RESOURCEMANAGER        5
+CONSTANT: D3DQUERYTYPE_VERTEXSTATS            6
+CONSTANT: D3DQUERYTYPE_EVENT                  8
+CONSTANT: D3DQUERYTYPE_OCCLUSION              9
+CONSTANT: D3DQUERYTYPE_TIMESTAMP              10
+CONSTANT: D3DQUERYTYPE_TIMESTAMPDISJOINT      11
+CONSTANT: D3DQUERYTYPE_TIMESTAMPFREQ          12
+CONSTANT: D3DQUERYTYPE_PIPELINETIMINGS        13
+CONSTANT: D3DQUERYTYPE_INTERFACETIMINGS       14
+CONSTANT: D3DQUERYTYPE_VERTEXTIMINGS          15
+CONSTANT: D3DQUERYTYPE_PIXELTIMINGS           16
+CONSTANT: D3DQUERYTYPE_BANDWIDTHTIMINGS       17
+CONSTANT: D3DQUERYTYPE_CACHEUTILIZATION       18
+CONSTANT: D3DQUERYTYPE_MEMORYPRESSURE         19
+
+CONSTANT: D3DISSUE_END   1
+CONSTANT: D3DISSUE_BEGIN 2
+
+CONSTANT: D3DGETDATA_FLUSH 1
+
+STRUCT: D3DRESOURCESTATS
+    { bThrashing              BOOL  }
+    { ApproxBytesDownloaded   DWORD }
+    { NumEvicts               DWORD }
+    { NumVidCreates           DWORD }
+    { LastPri                 DWORD }
+    { NumUsed                 DWORD }
+    { NumUsedInVidMem         DWORD }
+    { WorkingSet              DWORD }
+    { WorkingSetBytes         DWORD }
+    { TotalManaged            DWORD }
+    { TotalBytes              DWORD } ;
+
+CONSTANT: D3DRTYPECOUNT 8
+
+STRUCT: D3DDEVINFO_RESOURCEMANAGER
+    { stats D3DRESOURCESTATS[8] } ;
+TYPEDEF: D3DDEVINFO_RESOURCEMANAGER* LPD3DDEVINFO_RESOURCEMANAGER
+
+STRUCT: D3DDEVINFO_D3DVERTEXSTATS
+    { NumRenderedTriangles        DWORD }
+    { NumExtraClippingTriangles   DWORD } ;
+TYPEDEF: D3DDEVINFO_D3DVERTEXSTATS* LPD3DDEVINFO_D3DVERTEXSTATS
+
+STRUCT: D3DDEVINFO_VCACHE
+    { Pattern       DWORD }
+    { OptMethod     DWORD }
+    { CacheSize     DWORD }
+    { MagicNumber   DWORD } ;
+TYPEDEF: D3DDEVINFO_VCACHE* LPD3DDEVINFO_VCACHE
+
+STRUCT: D3DDEVINFO_D3D9PIPELINETIMINGS
+    { VertexProcessingTimePercent   FLOAT }
+    { PixelProcessingTimePercent    FLOAT }
+    { OtherGPUProcessingTimePercent FLOAT }
+    { GPUIdleTimePercent            FLOAT } ;
+
+STRUCT: D3DDEVINFO_D3D9INTERFACETIMINGS
+    { WaitingForGPUToUseApplicationResourceTimePercent FLOAT }
+    { WaitingForGPUToAcceptMoreCommandsTimePercent     FLOAT }
+    { WaitingForGPUToStayWithinLatencyTimePercent      FLOAT }
+    { WaitingForGPUExclusiveResourceTimePercent        FLOAT }
+    { WaitingForGPUOtherTimePercent                    FLOAT } ;
+
+STRUCT: D3DDEVINFO_D3D9STAGETIMINGS
+    { MemoryProcessingPercent      FLOAT }
+    { ComputationProcessingPercent FLOAT } ;
+
+STRUCT: D3DDEVINFO_D3D9BANDWIDTHTIMINGS
+    { MaxBandwidthUtilized                FLOAT }
+    { FrontEndUploadMemoryUtilizedPercent FLOAT }
+    { VertexRateUtilizedPercent           FLOAT }
+    { TriangleSetupRateUtilizedPercent    FLOAT }
+    { FillRateUtilizedPercent             FLOAT } ;
+
+STRUCT: D3DDEVINFO_D3D9CACHEUTILIZATION
+    { TextureCacheHitRate             FLOAT }
+    { PostTransformVertexCacheHitRate FLOAT } ;
+
+STRUCT: D3DMEMORYPRESSURE
+    { BytesEvictedFromProcess      UINT64 }
+    { SizeOfInefficientAllocation  UINT64 }
+    { LevelOfEfficiency            DWORD  } ;
+
+TYPEDEF: int D3DCOMPOSERECTSOP
+CONSTANT: D3DCOMPOSERECTS_COPY     1
+CONSTANT: D3DCOMPOSERECTS_OR       2
+CONSTANT: D3DCOMPOSERECTS_AND      3
+CONSTANT: D3DCOMPOSERECTS_NEG      4
+CONSTANT: D3DCOMPOSERECTS_FORCE_DWORD    HEX: 7fffffff
+
+STRUCT: D3DCOMPOSERECTDESC
+    { X       USHORT }
+    { Y       USHORT }
+    { Width   USHORT }
+    { Height  USHORT } ;
+
+STRUCT: D3DCOMPOSERECTDESTINATION
+    { SrcRectIndex USHORT }
+    { Reserved     USHORT }
+    { X            SHORT  }
+    { Y            SHORT  } ;
+
+CONSTANT: D3DCOMPOSERECTS_MAXNUMRECTS HEX: FFFF
+CONSTANT: D3DCONVOLUTIONMONO_MAXWIDTH  7
+: D3DCONVOLUTIONMONO_MAXHEIGHT ( -- n ) D3DCONVOLUTIONMONO_MAXWIDTH ; inline
+CONSTANT: D3DFMT_A1_SURFACE_MAXWIDTH  8192
+CONSTANT: D3DFMT_A1_SURFACE_MAXHEIGHT 2048
+
+STRUCT: D3DPRESENTSTATS
+    { PresentCount        UINT          }
+    { PresentRefreshCount UINT          }
+    { SyncRefreshCount    UINT          }
+    { SyncQPCTime         LARGE_INTEGER }
+    { SyncGPUTime         LARGE_INTEGER } ;
+
+TYPEDEF: int D3DSCANLINEORDERING
+CONSTANT: D3DSCANLINEORDERING_UNKNOWN                    0
+CONSTANT: D3DSCANLINEORDERING_PROGRESSIVE                1
+CONSTANT: D3DSCANLINEORDERING_INTERLACED                 2
+
+STRUCT: D3DDISPLAYMODEEX
+    { Size                UINT                }
+    { Width               UINT                }
+    { Height              UINT                }
+    { RefreshRate         UINT                }
+    { Format              D3DFORMAT           }
+    { ScanLineOrdering    D3DSCANLINEORDERING } ;
+
+STRUCT: D3DDISPLAYMODEFILTER
+    { Size                 UINT                }
+    { Format               D3DFORMAT           }
+    { ScanLineOrdering     D3DSCANLINEORDERING } ;
+
+TYPEDEF: int D3DDISPLAYROTATION
+CONSTANT: D3DDISPLAYROTATION_IDENTITY 1
+CONSTANT: D3DDISPLAYROTATION_90       2
+CONSTANT: D3DDISPLAYROTATION_180      3
+CONSTANT: D3DDISPLAYROTATION_270      4  
+
+CONSTANT: D3D9_RESOURCE_PRIORITY_MINIMUM       HEX: 28000000
+CONSTANT: D3D9_RESOURCE_PRIORITY_LOW           HEX: 50000000
+CONSTANT: D3D9_RESOURCE_PRIORITY_NORMAL        HEX: 78000000
+CONSTANT: D3D9_RESOURCE_PRIORITY_HIGH          HEX: a0000000
+CONSTANT: D3D9_RESOURCE_PRIORITY_MAXIMUM       HEX: c8000000
+
+CONSTANT: D3D_OMAC_SIZE    16
+
+STRUCT: D3D_OMAC
+    { Omac BYTE[D3D_OMAC_SIZE] } ;
+
+TYPEDEF: int D3DAUTHENTICATEDCHANNELTYPE
+CONSTANT: D3DAUTHENTICATEDCHANNEL_D3D9            1
+CONSTANT: D3DAUTHENTICATEDCHANNEL_DRIVER_SOFTWARE 2
+CONSTANT: D3DAUTHENTICATEDCHANNEL_DRIVER_HARDWARE 3
+
+STRUCT: D3DAUTHENTICATEDCHANNEL_QUERY_INPUT
+    { QueryType        GUID   }
+    { hChannel         HANDLE }
+    { SequenceNumber   UINT   } ;
+
+STRUCT: D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT
+    { omac                D3D_OMAC }
+    { QueryType           GUID     }
+    { hChannel            HANDLE   }
+    { SequenceNumber      UINT     }
+    { ReturnCode          HRESULT  } ;
+
+STRUCT: D3DAUTHENTICATEDCHANNEL_PROTECTION_FLAGS
+    { Value  UINT } ;
+
+STRUCT: D3DAUTHENTICATEDCHANNEL_QUERYPROTECTION_OUTPUT
+    { Output          D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT     }
+    { ProtectionFlags D3DAUTHENTICATEDCHANNEL_PROTECTION_FLAGS } ;
+
+STRUCT: D3DAUTHENTICATEDCHANNEL_QUERYCHANNELTYPE_OUTPUT
+    { Output      D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT }
+    { ChannelType D3DAUTHENTICATEDCHANNELTYPE          } ;
+
+STRUCT: D3DAUTHENTICATEDCHANNEL_QUERYDEVICEHANDLE_OUTPUT
+    { Output         D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT }
+    { DeviceHandle   HANDLE                               } ;
+
+STRUCT: D3DAUTHENTICATEDCHANNEL_QUERYCRYPTOSESSION_INPUT
+    { Input               D3DAUTHENTICATEDCHANNEL_QUERY_INPUT }
+    { DXVA2DecodeHandle   HANDLE                              } ;
+
+STRUCT: D3DAUTHENTICATEDCHANNEL_QUERYCRYPTOSESSION_OUTPUT
+    { Output                D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT }
+    { DXVA2DecodeHandle     HANDLE                               }
+    { CryptoSessionHandle   HANDLE                               }
+    { DeviceHandle          HANDLE                               } ;
+
+STRUCT: D3DAUTHENTICATEDCHANNEL_QUERYRESTRICTEDSHAREDRESOURCEPROCESSCOUNT_OUTPUT
+    { Output                                 D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT }
+    { NumRestrictedSharedResourceProcesses   UINT                                 } ;
+
+STRUCT: D3DAUTHENTICATEDCHANNEL_QUERYRESTRICTEDSHAREDRESOURCEPROCESS_INPUT
+    { Input            D3DAUTHENTICATEDCHANNEL_QUERY_INPUT }
+    { ProcessIndex     UINT                                } ;
+
+TYPEDEF: int D3DAUTHENTICATEDCHANNEL_PROCESSIDENTIFIERTYPE
+CONSTANT: PROCESSIDTYPE_UNKNOWN  0
+CONSTANT: PROCESSIDTYPE_DWM      1
+CONSTANT: PROCESSIDTYPE_HANDLE   2
+
+STRUCT: D3DAUTHENTICATEDCHANNEL_QUERYRESTRICTEDSHAREDRESOURCEPROCESS_OUTPUT
+    { Output           D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT          }
+    { ProcessIndex     UINT                                          }
+    { ProcessIdentifer D3DAUTHENTICATEDCHANNEL_PROCESSIDENTIFIERTYPE }
+    { ProcessHandle    HANDLE                                        } ;
+
+STRUCT: D3DAUTHENTICATEDCHANNEL_QUERYUNRESTRICTEDPROTECTEDSHAREDRESOURCECOUNT_OUTPUT
+    { Output                                    D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT }
+    { NumUnrestrictedProtectedSharedResources   UINT                                 } ;
+
+STRUCT: D3DAUTHENTICATEDCHANNEL_QUERYOUTPUTIDCOUNT_INPUT
+    { Input                D3DAUTHENTICATEDCHANNEL_QUERY_INPUT }
+    { DeviceHandle         HANDLE                              }
+    { CryptoSessionHandle  HANDLE                              } ;
+
+STRUCT: D3DAUTHENTICATEDCHANNEL_QUERYOUTPUTIDCOUNT_OUTPUT
+    { Output               D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT }
+    { DeviceHandle         HANDLE                               }
+    { CryptoSessionHandle  HANDLE                               }
+    { NumOutputIDs         UINT                                 } ;
+
+STRUCT: D3DAUTHENTICATEDCHANNEL_QUERYOUTPUTID_INPUT
+    { Input                D3DAUTHENTICATEDCHANNEL_QUERY_INPUT }
+    { DeviceHandle         HANDLE                              }
+    { CryptoSessionHandle  HANDLE                              }
+    { OutputIDIndex        UINT                                } ;
+
+STRUCT: D3DAUTHENTICATEDCHANNEL_QUERYOUTPUTID_OUTPUT
+    { Output               D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT }
+    { DeviceHandle         HANDLE                               }
+    { CryptoSessionHandle  HANDLE                               }
+    { OutputIDIndex        UINT                                 }
+    { OutputID             UINT64                               } ;
+
+TYPEDEF: int D3DBUSTYPE
+CONSTANT: D3DBUSTYPE_OTHER                                     HEX: 00000000
+CONSTANT: D3DBUSTYPE_PCI                                       HEX: 00000001
+CONSTANT: D3DBUSTYPE_PCIX                                      HEX: 00000002
+CONSTANT: D3DBUSTYPE_PCIEXPRESS                                HEX: 00000003
+CONSTANT: D3DBUSTYPE_AGP                                       HEX: 00000004
+CONSTANT: D3DBUSIMPL_MODIFIER_INSIDE_OF_CHIPSET                HEX: 00010000
+CONSTANT: D3DBUSIMPL_MODIFIER_TRACKS_ON_MOTHER_BOARD_TO_CHIP   HEX: 00020000
+CONSTANT: D3DBUSIMPL_MODIFIER_TRACKS_ON_MOTHER_BOARD_TO_SOCKET HEX: 00030000
+CONSTANT: D3DBUSIMPL_MODIFIER_DAUGHTER_BOARD_CONNECTOR         HEX: 00040000
+CONSTANT: D3DBUSIMPL_MODIFIER_DAUGHTER_BOARD_CONNECTOR_INSIDE_OF_NUAE HEX: 00050000
+CONSTANT: D3DBUSIMPL_MODIFIER_NON_STANDARD                     HEX: 80000000
+
+STRUCT: D3DAUTHENTICATEDCHANNEL_QUERYINFOBUSTYPE_OUTPUT
+    { Output                           D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT }
+    { BusType                          D3DBUSTYPE                           }
+    { bAccessibleInContiguousBlocks    BOOL                                 }
+    { bAccessibleInNonContiguousBlocks BOOL                                 } ;
+
+STRUCT: D3DAUTHENTICATEDCHANNEL_QUERYEVICTIONENCRYPTIONGUIDCOUNT_OUTPUT
+    { Output               D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT }
+    { NumEncryptionGuids   UINT                                 } ;
+
+STRUCT: D3DAUTHENTICATEDCHANNEL_QUERYEVICTIONENCRYPTIONGUID_INPUT
+    { Input               D3DAUTHENTICATEDCHANNEL_QUERY_INPUT }
+    { EncryptionGuidIndex UINT                                } ;
+
+STRUCT: D3DAUTHENTICATEDCHANNEL_QUERYEVICTIONENCRYPTIONGUID_OUTPUT
+    { Output                    D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT }
+    { EncryptionGuidIndex       UINT                                 }
+    { EncryptionGuid            GUID                                 } ;
+
+STRUCT: D3DAUTHENTICATEDCHANNEL_QUERYUNCOMPRESSEDENCRYPTIONLEVEL_OUTPUT
+    { Output               D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT }
+    { EncryptionGuid       GUID                                 } ;
+
+STRUCT: D3DAUTHENTICATEDCHANNEL_CONFIGURE_INPUT
+    { omac                          D3D_OMAC }
+    { ConfigureType                 GUID     }
+    { hChannel                      HANDLE   }
+    { SequenceNumber                UINT     } ;
+
+STRUCT: D3DAUTHENTICATEDCHANNEL_CONFIGURE_OUTPUT
+    { omac                          D3D_OMAC }
+    { ConfigureType                 GUID     }
+    { hChannel                      HANDLE   }
+    { SequenceNumber                UINT     }
+    { ReturnCode                    HRESULT  } ;
+
+STRUCT: D3DAUTHENTICATEDCHANNEL_CONFIGUREINITIALIZE
+    { Parameters               D3DAUTHENTICATEDCHANNEL_CONFIGURE_INPUT }
+    { StartSequenceQuery       UINT                                    }
+    { StartSequenceConfigure   UINT                                    } ;
+
+STRUCT: D3DAUTHENTICATEDCHANNEL_CONFIGUREPROTECTION
+    { Parameters   D3DAUTHENTICATEDCHANNEL_CONFIGURE_INPUT  }
+    { Protections  D3DAUTHENTICATEDCHANNEL_PROTECTION_FLAGS } ;
+
+STRUCT: D3DAUTHENTICATEDCHANNEL_CONFIGURECRYPTOSESSION
+    { Parameters               D3DAUTHENTICATEDCHANNEL_CONFIGURE_INPUT }
+    { DXVA2DecodeHandle        HANDLE                                  }
+    { CryptoSessionHandle      HANDLE                                  }
+    { DeviceHandle             HANDLE                                  } ;
+
+STRUCT: D3DAUTHENTICATEDCHANNEL_CONFIGURESHAREDRESOURCE
+    { Parameters           D3DAUTHENTICATEDCHANNEL_CONFIGURE_INPUT       }
+    { ProcessIdentiferType D3DAUTHENTICATEDCHANNEL_PROCESSIDENTIFIERTYPE }
+    { ProcessHandle        HANDLE                                        }
+    { AllowAccess          BOOL                                          } ;
+
+STRUCT: D3DAUTHENTICATEDCHANNEL_CONFIGUREUNCOMPRESSEDENCRYPTION
+    { Parameters      D3DAUTHENTICATEDCHANNEL_CONFIGURE_INPUT }
+    { EncryptionGuid  GUID                                    } ;
+
+STRUCT: D3DENCRYPTED_BLOCK_INFO
+    { NumEncryptedBytesAtBeginning UINT }
+    { NumBytesInSkipPattern        UINT }
+    { NumBytesInEncryptPattern     UINT } ;
+
+STRUCT: D3DAES_CTR_IV
+    { IV      UINT64 }
+    { Count   UINT64 } ;
diff --git a/basis/windows/directx/d3d9types/summary.txt b/basis/windows/directx/d3d9types/summary.txt
new file mode 100644 (file)
index 0000000..a5b7a8a
--- /dev/null
@@ -0,0 +1 @@
+DirectX 9 bindings. Corresponds to d3d9types.h.
diff --git a/basis/windows/directx/d3d9types/tags.txt b/basis/windows/directx/d3d9types/tags.txt
new file mode 100644 (file)
index 0000000..2320bdd
--- /dev/null
@@ -0,0 +1,2 @@
+unportable
+bindings
diff --git a/basis/windows/directx/d3dcommon/authors.txt b/basis/windows/directx/d3dcommon/authors.txt
new file mode 100644 (file)
index 0000000..6f03a12
--- /dev/null
@@ -0,0 +1 @@
+Erik Charlebois
diff --git a/basis/windows/directx/d3dcommon/d3dcommon.factor b/basis/windows/directx/d3dcommon/d3dcommon.factor
new file mode 100644 (file)
index 0000000..2e8b1ef
--- /dev/null
@@ -0,0 +1,18 @@
+USING: alien.c-types alien.syntax ;
+IN: windows.directx.d3dcommon
+
+CONSTANT: D3D_DRIVER_TYPE_UNKNOWN     0
+CONSTANT: D3D_DRIVER_TYPE_HARDWARE    1
+CONSTANT: D3D_DRIVER_TYPE_REFERENCE   2
+CONSTANT: D3D_DRIVER_TYPE_NULL        3
+CONSTANT: D3D_DRIVER_TYPE_SOFTWARE    4
+CONSTANT: D3D_DRIVER_TYPE_WARP        5
+TYPEDEF: int D3D_DRIVER_TYPE
+
+CONSTANT: D3D_FEATURE_LEVEL_9_1   HEX: 9100
+CONSTANT: D3D_FEATURE_LEVEL_9_2   HEX: 9200
+CONSTANT: D3D_FEATURE_LEVEL_9_3   HEX: 9300
+CONSTANT: D3D_FEATURE_LEVEL_10_0  HEX: a000
+CONSTANT: D3D_FEATURE_LEVEL_10_1  HEX: a100
+CONSTANT: D3D_FEATURE_LEVEL_11_0  HEX: b000
+TYPEDEF: int D3D_FEATURE_LEVEL
diff --git a/basis/windows/directx/d3dcommon/summary.txt b/basis/windows/directx/d3dcommon/summary.txt
new file mode 100644 (file)
index 0000000..0ab8cff
--- /dev/null
@@ -0,0 +1 @@
+Common constants. Corresponds to d3dcommon.h.
diff --git a/basis/windows/directx/d3dcommon/tags.txt b/basis/windows/directx/d3dcommon/tags.txt
new file mode 100644 (file)
index 0000000..2320bdd
--- /dev/null
@@ -0,0 +1,2 @@
+unportable
+bindings
diff --git a/basis/windows/directx/d3dcompiler/authors.txt b/basis/windows/directx/d3dcompiler/authors.txt
new file mode 100644 (file)
index 0000000..6f03a12
--- /dev/null
@@ -0,0 +1 @@
+Erik Charlebois
diff --git a/basis/windows/directx/d3dcompiler/d3dcompiler.factor b/basis/windows/directx/d3dcompiler/d3dcompiler.factor
new file mode 100644 (file)
index 0000000..90babe6
--- /dev/null
@@ -0,0 +1,89 @@
+USING: alien.c-types alien.syntax windows.ole32 windows.types ;
+IN: windows.directx.d3dcompiler
+
+LIBRARY: d3dcompiler
+
+C-TYPE: D3D_SHADER_MACRO
+C-TYPE: ID3DBlob
+TYPEDEF: ID3DBlob* LPD3DBLOB
+C-TYPE: ID3DInclude
+TYPEDEF: ID3DInclude* LPD3DINCLUDE
+C-TYPE: ID3D10Effect
+
+FUNCTION: HRESULT D3DCompile (
+    LPCVOID           pSrcData,
+    SIZE_T            SrcDataSize,
+    LPCSTR            pSourceName,
+    D3D_SHADER_MACRO* pDefines,
+    LPD3DINCLUDE      pInclude,
+    LPCSTR            pEntrypoint,
+    LPCSTR            pTarget,
+    UINT              Flags1,
+    UINT              Flags2,
+    LPD3DBLOB*        ppCode,
+    LPD3DBLOB*        ppErrorMsgs ) ;
+
+FUNCTION: HRESULT D3DPreprocess (
+    LPCVOID           pSrcData,
+    SIZE_T            SrcDataSize,
+    LPCSTR            pSourceName,
+    D3D_SHADER_MACRO* pDefines,
+    LPD3DINCLUDE      pInclude,
+    LPD3DBLOB*        ppCodeText,
+    LPD3DBLOB*        ppErrorMsgs ) ;
+
+FUNCTION: HRESULT D3DGetDebugInfo (
+    LPCVOID    pSrcData,
+    SIZE_T     SrcDataSize,
+    LPD3DBLOB* ppDebugInfo ) ;
+
+FUNCTION: HRESULT D3DReflect (
+    LPCVOID    pSrcData,
+    SIZE_T     SrcDataSize,
+    REFIID     pInterface,
+    void**     ppReflector ) ;
+
+CONSTANT: D3D_DISASM_ENABLE_COLOR_CODE            1
+CONSTANT: D3D_DISASM_ENABLE_DEFAULT_VALUE_PRINTS  2
+CONSTANT: D3D_DISASM_ENABLE_INSTRUCTION_NUMBERING 4
+CONSTANT: D3D_DISASM_ENABLE_INSTRUCTION_CYCLE     8
+
+FUNCTION: HRESULT D3DDisassemble (
+    LPCVOID    pSrcData,
+    SIZE_T     SrcDataSize,
+    UINT       Flags,
+    LPCSTR     szComments,
+    LPD3DBLOB* ppDisassembly ) ;
+
+FUNCTION: HRESULT D3DDisassemble10Effect (
+    ID3D10Effect* pEffect,      
+    UINT          Flags,
+    LPD3DBLOB*    ppDisassembly ) ;
+
+FUNCTION: HRESULT D3DGetInputSignatureBlob (
+    LPCVOID    pSrcData,
+    SIZE_T     SrcDataSize,
+    LPD3DBLOB* ppSignatureBlob ) ;
+
+FUNCTION: HRESULT D3DGetOutputSignatureBlob (
+    LPCVOID    pSrcData,
+    SIZE_T     SrcDataSize,
+    LPD3DBLOB* ppSignatureBlob ) ;
+
+FUNCTION: HRESULT D3DGetInputAndOutputSignatureBlob (
+    LPCVOID    pSrcData,
+    SIZE_T     SrcDataSize,
+    LPD3DBLOB* ppSignatureBlob ) ;
+
+CONSTANT: D3DCOMPILER_STRIP_REFLECTION_DATA 1
+CONSTANT: D3DCOMPILER_STRIP_DEBUG_INFO      2
+CONSTANT: D3DCOMPILER_STRIP_TEST_BLOBS      4
+CONSTANT: D3DCOMPILER_STRIP_FORCE_DWORD     HEX: 7fffffff
+TYPEDEF: int D3DCOMPILER_STRIP_FLAGS
+
+FUNCTION: HRESULT D3DStripShader (
+    LPCVOID    pShaderBytecode,
+    SIZE_T     BytecodeLength,
+    UINT       uStripFlags,
+    LPD3DBLOB* ppStrippedBlob ) ;
+
diff --git a/basis/windows/directx/d3dcompiler/summary.txt b/basis/windows/directx/d3dcompiler/summary.txt
new file mode 100644 (file)
index 0000000..4f61677
--- /dev/null
@@ -0,0 +1 @@
+Shader compiler bindings. Corresponds to d3dcompiler.h.
diff --git a/basis/windows/directx/d3dcompiler/tags.txt b/basis/windows/directx/d3dcompiler/tags.txt
new file mode 100644 (file)
index 0000000..2320bdd
--- /dev/null
@@ -0,0 +1,2 @@
+unportable
+bindings
diff --git a/basis/windows/directx/d3dcsx/authors.txt b/basis/windows/directx/d3dcsx/authors.txt
new file mode 100644 (file)
index 0000000..6f03a12
--- /dev/null
@@ -0,0 +1 @@
+Erik Charlebois
diff --git a/basis/windows/directx/d3dcsx/d3dcsx.factor b/basis/windows/directx/d3dcsx/d3dcsx.factor
new file mode 100644 (file)
index 0000000..c2d3af8
--- /dev/null
@@ -0,0 +1,82 @@
+USING: alien.c-types alien.syntax classes.struct windows.com windows.com.syntax
+windows.directx.d3d11 windows.types ;
+IN: windows.directx.d3dcsx
+
+LIBRARY: d3dcsx
+
+CONSTANT: D3DX11_SCAN_DATA_TYPE_FLOAT 1
+CONSTANT: D3DX11_SCAN_DATA_TYPE_INT   2
+CONSTANT: D3DX11_SCAN_DATA_TYPE_UINT  3
+TYPEDEF: int D3DX11_SCAN_DATA_TYPE
+
+CONSTANT: D3DX11_SCAN_OPCODE_ADD 1
+CONSTANT: D3DX11_SCAN_OPCODE_MIN 2
+CONSTANT: D3DX11_SCAN_OPCODE_MAX 3
+CONSTANT: D3DX11_SCAN_OPCODE_MUL 4
+CONSTANT: D3DX11_SCAN_OPCODE_AND 5
+CONSTANT: D3DX11_SCAN_OPCODE_OR  6
+CONSTANT: D3DX11_SCAN_OPCODE_XOR 7
+TYPEDEF: int D3DX11_SCAN_OPCODE
+
+CONSTANT: D3DX11_SCAN_DIRECTION_FORWARD  1
+CONSTANT: D3DX11_SCAN_DIRECTION_BACKWARD 2
+TYPEDEF: int D3DX11_SCAN_DIRECTION
+
+COM-INTERFACE: ID3DX11Scan IUnknown {5089b68f-e71d-4d38-be8e-f363b95a9405}
+    HRESULT SetScanDirection ( D3DX11_SCAN_DIRECTION Direction )
+    HRESULT Scan ( D3DX11_SCAN_DATA_TYPE ElementType, D3DX11_SCAN_OPCODE OpCode, UINT ElementScanSize, ID3D11UnorderedAccessView* pSrc, ID3D11UnorderedAccessView* pDst )
+    HRESULT Multiscan ( D3DX11_SCAN_DATA_TYPE ElementType, D3DX11_SCAN_OPCODE OpCode, UINT ElementScanSize, UINT ElementScanPitch, UINT ScanCount, ID3D11UnorderedAccessView* pSrc, ID3D11UnorderedAccessView* pDst ) ;
+
+FUNCTION: HRESULT D3DX11CreateScan ( ID3D11DeviceContext* pDeviceContext, UINT MaxElementScanSize, UINT MaxScanCount, ID3DX11Scan** ppScan ) ;
+
+COM-INTERFACE: ID3DX11SegmentedScan IUnknown {a915128c-d954-4c79-bfe1-64db923194d6}
+    HRESULT SetScanDirection ( D3DX11_SCAN_DIRECTION Direction )
+    HRESULT SegScan ( D3DX11_SCAN_DATA_TYPE ElementType, D3DX11_SCAN_OPCODE OpCode, UINT ElementScanSize, ID3D11UnorderedAccessView* pSrc, ID3D11UnorderedAccessView* pSrcElementFlags, ID3D11UnorderedAccessView* pDst ) ;
+
+FUNCTION: HRESULT D3DX11CreateSegmentedScan ( ID3D11DeviceContext* pDeviceContext, UINT MaxElementScanSize, ID3DX11SegmentedScan** ppScan ) ;
+
+CONSTANT: D3DX11_FFT_MAX_PRECOMPUTE_BUFFERS 4
+CONSTANT: D3DX11_FFT_MAX_TEMP_BUFFERS       4
+CONSTANT: D3DX11_FFT_MAX_DIMENSIONS         32
+
+COM-INTERFACE: ID3DX11FFT IUnknown {b3f7a938-4c93-4310-a675-b30d6de50553}
+    HRESULT SetForwardScale ( FLOAT ForwardScale )
+    FLOAT GetForwardScale ( )
+    HRESULT SetInverseScale ( FLOAT InverseScale )
+    FLOAT GetInverseScale ( )
+    HRESULT AttachBuffersAndPrecompute ( UINT NumTempBuffers, ID3D11UnorderedAccessView** ppTempBuffers, UINT NumPrecomputeBuffers, ID3D11UnorderedAccessView** ppPrecomputeBufferSizes )
+    HRESULT ForwardTransform ( ID3D11UnorderedAccessView* pInputBuffer, ID3D11UnorderedAccessView** ppOutputBuffer )
+    HRESULT InverseTransform ( ID3D11UnorderedAccessView* pInputBuffer, ID3D11UnorderedAccessView** ppOutputBuffer ) ;
+
+C-ENUM:
+    D3DX11_FFT_DATA_TYPE_REAL
+    D3DX11_FFT_DATA_TYPE_COMPLEX ;
+TYPEDEF: int D3DX11_FFT_DATA_TYPE
+
+CONSTANT: D3DX11_FFT_DIM_MASK_1D 1
+CONSTANT: D3DX11_FFT_DIM_MASK_2D 3
+CONSTANT: D3DX11_FFT_DIM_MASK_3D 7
+TYPEDEF: int D3DX11_FFT_DIM_MASK
+
+STRUCT: D3DX11_FFT_DESC
+    { NumDimensions  UINT                            }
+    { ElementLengths UINT[D3DX11_FFT_MAX_DIMENSIONS] }
+    { DimensionMask  UINT                            }
+    { Type           D3DX11_FFT_DATA_TYPE            } ;
+
+STRUCT: D3DX11_FFT_BUFFER_INFO
+    { NumTempBufferSize          UINT                                    }
+    { TempBufferFloatSizes       UINT[D3DX11_FFT_MAX_TEMP_BUFFERS]       }
+    { NumPrecomputeBufferSizes   UINT                                    }
+    { PrecomputeBufferFloatSizes UINT[D3DX11_FFT_MAX_PRECOMPUTE_BUFFERS] } ;
+
+CONSTANT: D3DX11_FFT_CREATE_FLAG_NO_PRECOMPUTE_BUFFERS 1
+TYPEDEF: int D3DX11_FFT_CREATE_FLAG
+
+FUNCTION: HRESULT D3DX11CreateFFT ( ID3D11DeviceContext* pDeviceContext, D3DX11_FFT_DESC* pDesc, UINT Flags, D3DX11_FFT_BUFFER_INFO* pBufferInfo, ID3DX11FFT** ppFFT ) ;
+FUNCTION: HRESULT D3DX11CreateFFT1DReal ( ID3D11DeviceContext* pDeviceContext, UINT X, UINT Flags, D3DX11_FFT_BUFFER_INFO* pBufferInfo, ID3DX11FFT** ppFFT ) ;
+FUNCTION: HRESULT D3DX11CreateFFT1DComplex ( ID3D11DeviceContext* pDeviceContext, UINT X, UINT Flags, D3DX11_FFT_BUFFER_INFO* pBufferInfo, ID3DX11FFT** ppFFT ) ;
+FUNCTION: HRESULT D3DX11CreateFFT2DReal ( ID3D11DeviceContext* pDeviceContext, UINT X, UINT Y, UINT Flags, D3DX11_FFT_BUFFER_INFO* pBufferInfo, ID3DX11FFT** ppFFT ) ;
+FUNCTION: HRESULT D3DX11CreateFFT2DComplex ( ID3D11DeviceContext* pDeviceContext, UINT X, UINT Y, UINT Flags, D3DX11_FFT_BUFFER_INFO* pBufferInfo, ID3DX11FFT** ppFFT ) ;
+FUNCTION: HRESULT D3DX11CreateFFT3DReal ( ID3D11DeviceContext* pDeviceContext, UINT X, UINT Y, UINT Z, UINT Flags, D3DX11_FFT_BUFFER_INFO* pBufferInfo, ID3DX11FFT** ppFFT ) ;
+FUNCTION: HRESULT D3DX11CreateFFT3DComplex ( ID3D11DeviceContext* pDeviceContext, UINT X, UINT Y, UINT Z, UINT Flags, D3DX11_FFT_BUFFER_INFO* pBufferInfo, ID3DX11FFT** ppFFT ) ;
diff --git a/basis/windows/directx/d3dcsx/summary.txt b/basis/windows/directx/d3dcsx/summary.txt
new file mode 100644 (file)
index 0000000..80da14c
--- /dev/null
@@ -0,0 +1 @@
+DirectCompute bindings. Corresponds to d3dcsx.h.
diff --git a/basis/windows/directx/d3dcsx/tags.txt b/basis/windows/directx/d3dcsx/tags.txt
new file mode 100644 (file)
index 0000000..2320bdd
--- /dev/null
@@ -0,0 +1,2 @@
+unportable
+bindings
diff --git a/basis/windows/directx/d3dx10/authors.txt b/basis/windows/directx/d3dx10/authors.txt
new file mode 100644 (file)
index 0000000..6f03a12
--- /dev/null
@@ -0,0 +1 @@
+Erik Charlebois
diff --git a/basis/windows/directx/d3dx10/d3dx10.factor b/basis/windows/directx/d3dx10/d3dx10.factor
new file mode 100644 (file)
index 0000000..3eda6f0
--- /dev/null
@@ -0,0 +1,12 @@
+USING: ;
+IN: windows.directx.d3dx10
+
+CONSTANT: D3DX10_ERR_CANNOT_MODIFY_INDEX_BUFFER HEX: 88760B54
+CONSTANT: D3DX10_ERR_INVALID_MESH               HEX: 88760B55
+CONSTANT: D3DX10_ERR_CANNOT_ATTR_SORT           HEX: 88760B56
+CONSTANT: D3DX10_ERR_SKINNING_NOT_SUPPORTED     HEX: 88760B57
+CONSTANT: D3DX10_ERR_TOO_MANY_INFLUENCES        HEX: 88760B58
+CONSTANT: D3DX10_ERR_INVALID_DATA               HEX: 88760B59
+CONSTANT: D3DX10_ERR_LOADED_MESH_HAS_NO_DATA    HEX: 88760B5A
+CONSTANT: D3DX10_ERR_DUPLICATE_NAMED_FRAGMENT   HEX: 88760B5B
+CONSTANT: D3DX10_ERR_CANNOT_REMOVE_LAST_ITEM    HEX: 88760B5C
diff --git a/basis/windows/directx/d3dx10/summary.txt b/basis/windows/directx/d3dx10/summary.txt
new file mode 100644 (file)
index 0000000..b80eea3
--- /dev/null
@@ -0,0 +1 @@
+Direct3D 10 bindings. Corresponds to d3dx10.h.
diff --git a/basis/windows/directx/d3dx10/tags.txt b/basis/windows/directx/d3dx10/tags.txt
new file mode 100644 (file)
index 0000000..2320bdd
--- /dev/null
@@ -0,0 +1,2 @@
+unportable
+bindings
diff --git a/basis/windows/directx/d3dx10async/authors.txt b/basis/windows/directx/d3dx10async/authors.txt
new file mode 100644 (file)
index 0000000..6f03a12
--- /dev/null
@@ -0,0 +1 @@
+Erik Charlebois
diff --git a/basis/windows/directx/d3dx10async/d3dx10async.factor b/basis/windows/directx/d3dx10async/d3dx10async.factor
new file mode 100644 (file)
index 0000000..e216530
--- /dev/null
@@ -0,0 +1,121 @@
+USING: alien.syntax windows.directx.d3d10 windows.directx.d3d10shader
+windows.types ;
+IN: windows.directx.d3dx10async
+
+LIBRARY: d3dx10
+
+C-TYPE: ID3DX10ThreadPump
+C-TYPE: ID3D10EffectPool
+C-TYPE: D3DX10_IMAGE_LOAD_INFO
+C-TYPE: D3DX10_IMAGE_INFO
+
+FUNCTION: HRESULT D3DX10CompileFromFileA ( LPCSTR pSrcFile, D3D10_SHADER_MACRO* pDefines, LPD3D10INCLUDE pInclude,
+        LPCSTR pFunctionName, LPCSTR pProfile, UINT Flags1, UINT Flags2, ID3DX10ThreadPump* pPump, ID3D10Blob** ppShader, ID3D10Blob** ppErrorMsgs, HRESULT* pHResult ) ;
+
+FUNCTION: HRESULT D3DX10CompileFromFileW ( LPCWSTR pSrcFile, D3D10_SHADER_MACRO* pDefines, LPD3D10INCLUDE pInclude,
+        LPCSTR pFunctionName, LPCSTR pProfile, UINT Flags1, UINT Flags2, ID3DX10ThreadPump* pPump, ID3D10Blob** ppShader, ID3D10Blob** ppErrorMsgs, HRESULT* pHResult ) ;
+
+ALIAS: D3DX10CompileFromFile D3DX10CompileFromFileW
+
+FUNCTION: HRESULT D3DX10CompileFromResourceA ( HMODULE hSrcModule, LPCSTR pSrcResource, LPCSTR pSrcFileName, D3D10_SHADER_MACRO* pDefines, 
+    LPD3D10INCLUDE pInclude, LPCSTR pFunctionName, LPCSTR pProfile, UINT Flags1, UINT Flags2, ID3DX10ThreadPump* pPump, ID3D10Blob** ppShader, ID3D10Blob** ppErrorMsgs, HRESULT* pHResult ) ;
+
+FUNCTION: HRESULT D3DX10CompileFromResourceW ( HMODULE hSrcModule, LPCWSTR pSrcResource, LPCWSTR pSrcFileName, D3D10_SHADER_MACRO* pDefines, 
+    LPD3D10INCLUDE pInclude, LPCSTR pFunctionName, LPCSTR pProfile, UINT Flags1, UINT Flags2, ID3DX10ThreadPump* pPump, ID3D10Blob** ppShader, ID3D10Blob** ppErrorMsgs, HRESULT* pHResult ) ;
+
+ALIAS: D3DX10CompileFromResource D3DX10CompileFromResourceW
+
+FUNCTION: HRESULT D3DX10CompileFromMemory ( LPCSTR pSrcData, SIZE_T SrcDataLen, LPCSTR pFileName, D3D10_SHADER_MACRO* pDefines, LPD3D10INCLUDE pInclude, 
+    LPCSTR pFunctionName, LPCSTR pProfile, UINT Flags1, UINT Flags2, ID3DX10ThreadPump* pPump, ID3D10Blob** ppShader, ID3D10Blob** ppErrorMsgs, HRESULT* pHResult ) ;
+
+FUNCTION: HRESULT D3DX10CreateEffectFromFileA ( LPCSTR pFileName, D3D10_SHADER_MACRO* pDefines, 
+    ID3D10Include* pInclude, LPCSTR pProfile, UINT HLSLFlags, UINT FXFlags, ID3D10Device* pDevice, 
+    ID3D10EffectPool* pEffectPool, ID3DX10ThreadPump* pPump, ID3D10Effect** ppEffect, ID3D10Blob** ppErrors, HRESULT* pHResult ) ;
+
+FUNCTION: HRESULT D3DX10CreateEffectFromFileW ( LPCWSTR pFileName, D3D10_SHADER_MACRO* pDefines, 
+    ID3D10Include* pInclude, LPCSTR pProfile, UINT HLSLFlags, UINT FXFlags, ID3D10Device* pDevice, 
+    ID3D10EffectPool* pEffectPool, ID3DX10ThreadPump* pPump, ID3D10Effect** ppEffect, ID3D10Blob** ppErrors, HRESULT* pHResult ) ;
+
+FUNCTION: HRESULT D3DX10CreateEffectFromMemory ( LPCVOID pData, SIZE_T DataLength, LPCSTR pSrcFileName, D3D10_SHADER_MACRO* pDefines, 
+    ID3D10Include* pInclude, LPCSTR pProfile, UINT HLSLFlags, UINT FXFlags, ID3D10Device* pDevice, 
+    ID3D10EffectPool* pEffectPool, ID3DX10ThreadPump* pPump, ID3D10Effect** ppEffect, ID3D10Blob** ppErrors, HRESULT* pHResult ) ;
+
+FUNCTION: HRESULT D3DX10CreateEffectFromResourceA ( HMODULE hModule, LPCSTR pResourceName, LPCSTR pSrcFileName, D3D10_SHADER_MACRO* pDefines, 
+    ID3D10Include* pInclude, LPCSTR pProfile, UINT HLSLFlags, UINT FXFlags, ID3D10Device* pDevice, 
+    ID3D10EffectPool* pEffectPool, ID3DX10ThreadPump* pPump, ID3D10Effect** ppEffect, ID3D10Blob** ppErrors, HRESULT* pHResult ) ;
+
+FUNCTION: HRESULT D3DX10CreateEffectFromResourceW ( HMODULE hModule, LPCWSTR pResourceName, LPCWSTR pSrcFileName, D3D10_SHADER_MACRO* pDefines, 
+    ID3D10Include* pInclude, LPCSTR pProfile, UINT HLSLFlags, UINT FXFlags, ID3D10Device* pDevice, 
+    ID3D10EffectPool* pEffectPool, ID3DX10ThreadPump* pPump, ID3D10Effect** ppEffect, ID3D10Blob** ppErrors, HRESULT* pHResult ) ;
+
+ALIAS: D3DX10CreateEffectFromFile          D3DX10CreateEffectFromFileW
+ALIAS: D3DX10CreateEffectFromResource      D3DX10CreateEffectFromResourceW
+
+FUNCTION: HRESULT D3DX10CreateEffectPoolFromFileA ( LPCSTR pFileName, D3D10_SHADER_MACRO* pDefines, 
+    ID3D10Include* pInclude, LPCSTR pProfile, UINT HLSLFlags, UINT FXFlags, ID3D10Device* pDevice, ID3DX10ThreadPump* pPump, 
+    ID3D10EffectPool** ppEffectPool, ID3D10Blob** ppErrors, HRESULT* pHResult ) ;
+
+FUNCTION: HRESULT D3DX10CreateEffectPoolFromFileW ( LPCWSTR pFileName, D3D10_SHADER_MACRO* pDefines, 
+    ID3D10Include* pInclude, LPCSTR pProfile, UINT HLSLFlags, UINT FXFlags, ID3D10Device* pDevice, ID3DX10ThreadPump* pPump, 
+    ID3D10EffectPool** ppEffectPool, ID3D10Blob** ppErrors, HRESULT* pHResult ) ;
+
+FUNCTION: HRESULT D3DX10CreateEffectPoolFromMemory ( LPCVOID pData, SIZE_T DataLength, LPCSTR pSrcFileName, D3D10_SHADER_MACRO* pDefines, 
+    ID3D10Include* pInclude, LPCSTR pProfile, UINT HLSLFlags, UINT FXFlags, ID3D10Device* pDevice,
+    ID3DX10ThreadPump* pPump, ID3D10EffectPool** ppEffectPool, ID3D10Blob** ppErrors, HRESULT* pHResult ) ;
+
+FUNCTION: HRESULT D3DX10CreateEffectPoolFromResourceA ( HMODULE hModule, LPCSTR pResourceName, LPCSTR pSrcFileName, D3D10_SHADER_MACRO* pDefines, 
+    ID3D10Include* pInclude, LPCSTR pProfile, UINT HLSLFlags, UINT FXFlags, ID3D10Device* pDevice,
+    ID3DX10ThreadPump* pPump, ID3D10EffectPool** ppEffectPool, ID3D10Blob** ppErrors, HRESULT* pHResult ) ;
+                                         
+FUNCTION: HRESULT D3DX10CreateEffectPoolFromResourceW ( HMODULE hModule, LPCWSTR pResourceName, LPCWSTR pSrcFileName, D3D10_SHADER_MACRO* pDefines, 
+    ID3D10Include* pInclude, LPCSTR pProfile, UINT HLSLFlags, UINT FXFlags, ID3D10Device* pDevice,
+    ID3DX10ThreadPump* pPump, ID3D10EffectPool** ppEffectPool, ID3D10Blob** ppErrors, HRESULT* pHResult ) ;
+
+ALIAS: D3DX10CreateEffectPoolFromFile      D3DX10CreateEffectPoolFromFileW
+ALIAS: D3DX10CreateEffectPoolFromResource  D3DX10CreateEffectPoolFromResourceW
+
+FUNCTION: HRESULT D3DX10PreprocessShaderFromFileA ( LPCSTR pFileName, D3D10_SHADER_MACRO* pDefines, 
+    LPD3D10INCLUDE pInclude, ID3DX10ThreadPump* pPump, ID3D10Blob** ppShaderText, ID3D10Blob** ppErrorMsgs, HRESULT* pHResult ) ;
+
+FUNCTION: HRESULT D3DX10PreprocessShaderFromFileW ( LPCWSTR pFileName, D3D10_SHADER_MACRO* pDefines, 
+    LPD3D10INCLUDE pInclude, ID3DX10ThreadPump* pPump, ID3D10Blob** ppShaderText, ID3D10Blob** ppErrorMsgs, HRESULT* pHResult ) ;
+
+FUNCTION: HRESULT D3DX10PreprocessShaderFromMemory ( LPCSTR pSrcData, SIZE_T SrcDataSize, LPCSTR pFileName, D3D10_SHADER_MACRO* pDefines, 
+    LPD3D10INCLUDE pInclude, ID3DX10ThreadPump* pPump, ID3D10Blob** ppShaderText, ID3D10Blob** ppErrorMsgs, HRESULT* pHResult ) ;
+
+FUNCTION: HRESULT D3DX10PreprocessShaderFromResourceA ( HMODULE hModule, LPCSTR pResourceName, LPCSTR pSrcFileName, D3D10_SHADER_MACRO* pDefines, 
+    LPD3D10INCLUDE pInclude, ID3DX10ThreadPump* pPump, ID3D10Blob** ppShaderText, ID3D10Blob** ppErrorMsgs, HRESULT* pHResult ) ;
+
+FUNCTION: HRESULT D3DX10PreprocessShaderFromResourceW ( HMODULE hModule, LPCWSTR pResourceName, LPCWSTR pSrcFileName, D3D10_SHADER_MACRO* pDefines, 
+    LPD3D10INCLUDE pInclude, ID3DX10ThreadPump* pPump, ID3D10Blob** ppShaderText, ID3D10Blob** ppErrorMsgs, HRESULT* pHResult ) ;
+
+ALIAS: D3DX10PreprocessShaderFromFile      D3DX10PreprocessShaderFromFileW
+ALIAS: D3DX10PreprocessShaderFromResource  D3DX10PreprocessShaderFromResourceW
+
+FUNCTION: HRESULT D3DX10CreateAsyncCompilerProcessor ( LPCSTR pFileName, D3D10_SHADER_MACRO* pDefines, LPD3D10INCLUDE pInclude, 
+        LPCSTR pFunctionName, LPCSTR pProfile, UINT Flags1, UINT Flags2,
+        ID3D10Blob** ppCompiledShader, ID3D10Blob** ppErrorBuffer, ID3DX10DataProcessor** ppProcessor ) ;
+
+FUNCTION: HRESULT D3DX10CreateAsyncEffectCreateProcessor ( LPCSTR pFileName, D3D10_SHADER_MACRO* pDefines, LPD3D10INCLUDE pInclude, 
+        LPCSTR pProfile, UINT Flags, UINT FXFlags, ID3D10Device* pDevice,
+        ID3D10EffectPool* pPool, ID3D10Blob** ppErrorBuffer, ID3DX10DataProcessor** ppProcessor ) ;
+
+FUNCTION: HRESULT D3DX10CreateAsyncEffectPoolCreateProcessor ( LPCSTR pFileName, D3D10_SHADER_MACRO* pDefines, LPD3D10INCLUDE pInclude, 
+        LPCSTR pProfile, UINT Flags, UINT FXFlags, ID3D10Device* pDevice,
+        ID3D10Blob** ppErrorBuffer, ID3DX10DataProcessor** ppProcessor ) ;
+
+FUNCTION: HRESULT D3DX10CreateAsyncShaderPreprocessProcessor ( LPCSTR pFileName, D3D10_SHADER_MACRO* pDefines, LPD3D10INCLUDE pInclude, 
+        ID3D10Blob** ppShaderText, ID3D10Blob** ppErrorBuffer, ID3DX10DataProcessor** ppProcessor ) ;
+
+FUNCTION: HRESULT D3DX10CreateAsyncFileLoaderW ( LPCWSTR pFileName, ID3DX10DataLoader** ppDataLoader ) ;
+FUNCTION: HRESULT D3DX10CreateAsyncFileLoaderA ( LPCSTR pFileName, ID3DX10DataLoader** ppDataLoader ) ;
+FUNCTION: HRESULT D3DX10CreateAsyncMemoryLoader ( LPCVOID pData, SIZE_T cbData, ID3DX10DataLoader** ppDataLoader ) ;
+FUNCTION: HRESULT D3DX10CreateAsyncResourceLoaderW ( HMODULE hSrcModule, LPCWSTR pSrcResource, ID3DX10DataLoader** ppDataLoader ) ;
+FUNCTION: HRESULT D3DX10CreateAsyncResourceLoaderA ( HMODULE hSrcModule, LPCSTR pSrcResource, ID3DX10DataLoader** ppDataLoader ) ;
+
+ALIAS: D3DX10CreateAsyncFileLoader D3DX10CreateAsyncFileLoaderW
+ALIAS: D3DX10CreateAsyncResourceLoader D3DX10CreateAsyncResourceLoaderW
+
+FUNCTION: HRESULT D3DX10CreateAsyncTextureProcessor ( ID3D10Device* pDevice, D3DX10_IMAGE_LOAD_INFO* pLoadInfo, ID3DX10DataProcessor** ppDataProcessor ) ;
+FUNCTION: HRESULT D3DX10CreateAsyncTextureInfoProcessor ( D3DX10_IMAGE_INFO* pImageInfo, ID3DX10DataProcessor** ppDataProcessor ) ;
+FUNCTION: HRESULT D3DX10CreateAsyncShaderResourceViewProcessor ( ID3D10Device* pDevice, D3DX10_IMAGE_LOAD_INFO* pLoadInfo, ID3DX10DataProcessor** ppDataProcessor ) ;
diff --git a/basis/windows/directx/d3dx10async/summary.txt b/basis/windows/directx/d3dx10async/summary.txt
new file mode 100644 (file)
index 0000000..5fc96bc
--- /dev/null
@@ -0,0 +1 @@
+Direct3D 10 bindings. Corresponds to d3dx10async.h.
diff --git a/basis/windows/directx/d3dx10async/tags.txt b/basis/windows/directx/d3dx10async/tags.txt
new file mode 100644 (file)
index 0000000..2320bdd
--- /dev/null
@@ -0,0 +1,2 @@
+unportable
+bindings
diff --git a/basis/windows/directx/d3dx10core/authors.txt b/basis/windows/directx/d3dx10core/authors.txt
new file mode 100644 (file)
index 0000000..6f03a12
--- /dev/null
@@ -0,0 +1 @@
+Erik Charlebois
diff --git a/basis/windows/directx/d3dx10core/d3dx10core.factor b/basis/windows/directx/d3dx10core/d3dx10core.factor
new file mode 100644 (file)
index 0000000..38271b5
--- /dev/null
@@ -0,0 +1,186 @@
+USING: alien.c-types alien.syntax classes.struct windows.com
+windows.com.syntax windows.directx.d3d10
+windows.directx.d3d10misc windows.directx.d3dx10math
+windows.directx.dxgi windows.gdi32 windows.types ;
+IN: windows.directx.d3dx10core
+
+LIBRARY: d3dx10
+
+CONSTANT: D3DX10_SDK_VERSION 42
+
+FUNCTION: HRESULT D3DX10CreateDevice (
+    IDXGIAdapter*     pAdapter,
+    D3D10_DRIVER_TYPE DriverType,
+    HMODULE           Software,
+    UINT              Flags,
+    ID3D10Device**    ppDevice ) ;
+
+FUNCTION: HRESULT D3DX10CreateDeviceAndSwapChain (
+    IDXGIAdapter*         pAdapter,
+    D3D10_DRIVER_TYPE     DriverType,
+    HMODULE               Software,
+    UINT                  Flags,
+    DXGI_SWAP_CHAIN_DESC* pSwapChainDesc,
+    IDXGISwapChain**      ppSwapChain,
+    ID3D10Device**        ppDevice ) ;
+
+C-TYPE: ID3D10Device1
+
+FUNCTION: HRESULT D3DX10GetFeatureLevel1 ( ID3D10Device* pDevice, ID3D10Device1** ppDevice1 ) ;
+
+FUNCTION: HRESULT D3DX10CheckVersion ( UINT D3DSdkVersion, UINT D3DX10SdkVersion ) ;
+
+CONSTANT: D3DX10_SPRITE_SORT_TEXTURE              HEX: 01
+CONSTANT: D3DX10_SPRITE_SORT_DEPTH_BACK_TO_FRONT  HEX: 02
+CONSTANT: D3DX10_SPRITE_SORT_DEPTH_FRONT_TO_BACK  HEX: 04
+CONSTANT: D3DX10_SPRITE_SAVE_STATE                HEX: 08
+CONSTANT: D3DX10_SPRITE_ADDREF_TEXTURES           HEX: 10
+TYPEDEF: int D3DX10_SPRITE_FLAG
+
+STRUCT: D3DX10_SPRITE
+    { matWorld            D3DXMATRIX                }
+    { TexCoord            D3DXVECTOR2               }
+    { TexSize             D3DXVECTOR2               }
+    { ColorModulate       D3DXCOLOR                 }
+    { pTexture            ID3D10ShaderResourceView* }
+    { TextureIndex        UINT                      } ;
+
+C-TYPE: ID3DX10Sprite
+TYPEDEF: ID3DX10Sprite* LPD3DX10SPRITE
+
+COM-INTERFACE: ID3DX10Sprite IUnknown {BA0B762D-8D28-43ec-B9DC-2F84443B0614}
+    HRESULT Begin ( UINT flags )
+    HRESULT DrawSpritesBuffered ( D3DX10_SPRITE* pSprites, UINT cSprites )
+    HRESULT Flush ( )
+    HRESULT DrawSpritesImmediate ( D3DX10_SPRITE* pSprites, UINT cSprites, UINT cbSprite, UINT flags )
+    HRESULT End ( )
+    HRESULT GetViewTransform ( D3DXMATRIX* pViewTransform )
+    HRESULT SetViewTransform ( D3DXMATRIX* pViewTransform )
+    HRESULT GetProjectionTransform ( D3DXMATRIX* pProjectionTransform )
+    HRESULT SetProjectionTransform ( D3DXMATRIX* pProjectionTransform )
+    HRESULT GetDevice ( ID3D10Device** ppDevice ) ;
+
+FUNCTION: HRESULT
+    D3DX10CreateSprite (
+        ID3D10Device*         pDevice,
+        UINT                  cDeviceBufferSize,
+        LPD3DX10SPRITE*       ppSprite ) ;
+
+COM-INTERFACE: ID3DX10DataLoader f {00000000-0000-0000-0000-000000000000}
+    HRESULT Load ( )
+    HRESULT Decompress ( void** ppData, SIZE_T* pcBytes )
+    HRESULT Destroy ( ) ;
+
+COM-INTERFACE: ID3DX10DataProcessor f {00000000-0000-0000-0000-000000000000}
+    HRESULT Process ( void* pData, SIZE_T cBytes )
+    HRESULT CreateDeviceObject ( void** ppDataObject )
+    HRESULT Destroy ( ) ;
+
+COM-INTERFACE: ID3DX10ThreadPump IUnknown {C93FECFA-6967-478a-ABBC-402D90621FCB}
+    HRESULT AddWorkItem ( ID3DX10DataLoader* pDataLoader, ID3DX10DataProcessor* pDataProcessor, HRESULT* pHResult, void** ppDeviceObject )
+    UINT GetWorkItemCount ( )
+    HRESULT WaitForAllItems ( )
+    HRESULT ProcessDeviceWorkItems ( UINT iWorkItemCount )
+    HRESULT PurgeAllItems ( )
+    HRESULT GetQueueStatus ( UINT* pIoQueue, UINT* pProcessQueue, UINT* pDeviceQueue ) ;
+
+FUNCTION: HRESULT D3DX10CreateThreadPump ( UINT cIoThreads, UINT cProcThreads, ID3DX10ThreadPump** ppThreadPump ) ;
+
+STRUCT: D3DX10_FONT_DESCA
+    { Height          INT               }
+    { Width           UINT              }
+    { Weight          UINT              }
+    { MipLevels       UINT              }
+    { Italic          BOOL              }
+    { CharSet         BYTE              }
+    { OutputPrecision BYTE              }
+    { Quality         BYTE              }
+    { PitchAndFamily  BYTE              }
+    { FaceName        CHAR[LF_FACESIZE] } ;
+TYPEDEF: D3DX10_FONT_DESCA* LPD3DX10_FONT_DESCA
+
+STRUCT: D3DX10_FONT_DESCW
+    { Height INT }
+    { Width UINT }
+    { Weight UINT }
+    { MipLevels UINT }
+    { Italic BOOL }
+    { CharSet BYTE }
+    { OutputPrecision BYTE }
+    { Quality BYTE }
+    { PitchAndFamily BYTE }
+    { FaceName WCHAR[LF_FACESIZE] } ;
+TYPEDEF: D3DX10_FONT_DESCW* LPD3DX10_FONT_DESCW
+
+TYPEDEF: D3DX10_FONT_DESCW D3DX10_FONT_DESC
+TYPEDEF: LPD3DX10_FONT_DESCW LPD3DX10_FONT_DESC
+
+C-TYPE: TEXTMETRICA
+C-TYPE: TEXTMETRICW
+
+COM-INTERFACE: ID3DX10Font IUnknown {D79DBB70-5F21-4d36-BBC2-FF525C213CDC}
+    HRESULT GetDevice ( ID3D10Device** ppDevice )
+    HRESULT GetDescA ( D3DX10_FONT_DESCA* pDesc )
+    HRESULT GetDescW ( D3DX10_FONT_DESCW* pDesc )
+    BOOL GetTextMetricsA ( TEXTMETRICA* pTextMetrics )
+    BOOL GetTextMetricsW ( TEXTMETRICW* pTextMetrics )
+    HDC GetDC ( )
+    HRESULT GetGlyphData ( UINT Glyph, ID3D10ShaderResourceView** ppTexture, RECT* pBlackBox, POINT* pCellInc )
+    HRESULT PreloadCharacters ( UINT First, UINT Last )
+    HRESULT PreloadGlyphs ( UINT First, UINT Last )
+    HRESULT PreloadTextA ( LPCSTR pString, INT Count )
+    HRESULT PreloadTextW ( LPCWSTR pString, INT Count )
+    INT DrawTextA ( LPD3DX10SPRITE pSprite, LPCSTR pString, INT Count, LPRECT pRect, UINT Format, D3DXCOLOR Color )
+    INT DrawTextW ( LPD3DX10SPRITE pSprite, LPCWSTR pString, INT Count, LPRECT pRect, UINT Format, D3DXCOLOR Color ) ;
+TYPEDEF: ID3DX10Font* LPD3DX10FONT
+
+FUNCTION: HRESULT
+    D3DX10CreateFontA (
+        ID3D10Device*           pDevice,
+        INT                     Height,
+        UINT                    Width,
+        UINT                    Weight,
+        UINT                    MipLevels,
+        BOOL                    Italic,
+        UINT                    CharSet,
+        UINT                    OutputPrecision,
+        UINT                    Quality,
+        UINT                    PitchAndFamily,
+        LPCSTR                  pFaceName,
+        LPD3DX10FONT*           ppFont ) ;
+
+FUNCTION: HRESULT
+    D3DX10CreateFontW (
+        ID3D10Device*           pDevice,
+        INT                     Height,
+        UINT                    Width,
+        UINT                    Weight,
+        UINT                    MipLevels,
+        BOOL                    Italic,
+        UINT                    CharSet,
+        UINT                    OutputPrecision,
+        UINT                    Quality,
+        UINT                    PitchAndFamily,
+        LPCWSTR                 pFaceName,
+        LPD3DX10FONT*           ppFont ) ;
+
+ALIAS: D3DX10CreateFont D3DX10CreateFontW
+
+FUNCTION: HRESULT
+    D3DX10CreateFontIndirectA (
+        ID3D10Device*             pDevice,
+        D3DX10_FONT_DESCA*        pDesc,
+        LPD3DX10FONT*             ppFont ) ;
+
+FUNCTION: HRESULT
+    D3DX10CreateFontIndirectW (
+        ID3D10Device*             pDevice,
+        D3DX10_FONT_DESCW*        pDesc,
+        LPD3DX10FONT*             ppFont ) ;
+
+ALIAS: D3DX10CreateFontIndirect D3DX10CreateFontIndirectW
+
+FUNCTION: HRESULT D3DX10UnsetAllDeviceObjects ( ID3D10Device* pDevice ) ;
+
+CONSTANT: D3DERR_INVALIDCALL     HEX: 8876086C
+CONSTANT: D3DERR_WASSTILLDRAWING HEX: 8876021C
diff --git a/basis/windows/directx/d3dx10core/summary.txt b/basis/windows/directx/d3dx10core/summary.txt
new file mode 100644 (file)
index 0000000..848433b
--- /dev/null
@@ -0,0 +1 @@
+Direct3D 10 bindings. Corresponds to d3dx10core.h.
diff --git a/basis/windows/directx/d3dx10core/tags.txt b/basis/windows/directx/d3dx10core/tags.txt
new file mode 100644 (file)
index 0000000..2320bdd
--- /dev/null
@@ -0,0 +1,2 @@
+unportable
+bindings
diff --git a/basis/windows/directx/d3dx10math/authors.txt b/basis/windows/directx/d3dx10math/authors.txt
new file mode 100644 (file)
index 0000000..6f03a12
--- /dev/null
@@ -0,0 +1 @@
+Erik Charlebois
diff --git a/basis/windows/directx/d3dx10math/d3dx10math.factor b/basis/windows/directx/d3dx10math/d3dx10math.factor
new file mode 100644 (file)
index 0000000..9a244d9
--- /dev/null
@@ -0,0 +1,60 @@
+USING: alien.syntax classes.struct windows.types ;
+IN: windows.directx.d3dx10math
+
+STRUCT: D3DVECTOR
+    { x FLOAT }
+    { y FLOAT }
+    { z FLOAT } ;
+
+STRUCT: D3DMATRIX
+    { m FLOAT[4][4] } ;
+
+STRUCT: D3DXFLOAT16
+    { value WORD } ;
+
+TYPEDEF: D3DMATRIX D3DXMATRIX
+
+STRUCT: D3DXVECTOR2
+    { x FLOAT }
+    { y FLOAT } ;
+
+STRUCT: D3DXVECTOR2_16F
+    { x D3DXFLOAT16 }
+    { y D3DXFLOAT16 } ;
+
+TYPEDEF: D3DVECTOR D3DXVECTOR3
+
+STRUCT: D3DXVECTOR3_16F
+    { x D3DXFLOAT16 }
+    { y D3DXFLOAT16 }
+    { z D3DXFLOAT16 } ;
+
+STRUCT: D3DXVECTOR4
+    { x FLOAT }
+    { y FLOAT }
+    { z FLOAT }
+    { w FLOAT } ;
+
+STRUCT: D3DXVECTOR4_16F
+    { x D3DXFLOAT16 }
+    { y D3DXFLOAT16 }
+    { z D3DXFLOAT16 }
+    { w D3DXFLOAT16 } ;
+
+STRUCT: D3DXQUATERNION
+    { x FLOAT }
+    { y FLOAT }
+    { z FLOAT }
+    { w FLOAT } ;
+
+STRUCT: D3DXPLANE
+    { a FLOAT }
+    { b FLOAT }
+    { c FLOAT }
+    { d FLOAT } ;
+
+STRUCT: D3DXCOLOR
+    { r FLOAT }
+    { g FLOAT }
+    { b FLOAT }
+    { a FLOAT } ;
diff --git a/basis/windows/directx/d3dx10math/summary.txt b/basis/windows/directx/d3dx10math/summary.txt
new file mode 100644 (file)
index 0000000..e19a4c0
--- /dev/null
@@ -0,0 +1 @@
+Direct3D 10 bindings. Corresponds to d3dx10math.h.
diff --git a/basis/windows/directx/d3dx10math/tags.txt b/basis/windows/directx/d3dx10math/tags.txt
new file mode 100644 (file)
index 0000000..2320bdd
--- /dev/null
@@ -0,0 +1,2 @@
+unportable
+bindings
diff --git a/basis/windows/directx/d3dx10mesh/authors.txt b/basis/windows/directx/d3dx10mesh/authors.txt
new file mode 100644 (file)
index 0000000..6f03a12
--- /dev/null
@@ -0,0 +1 @@
+Erik Charlebois
diff --git a/basis/windows/directx/d3dx10mesh/d3dx10mesh.factor b/basis/windows/directx/d3dx10mesh/d3dx10mesh.factor
new file mode 100644 (file)
index 0000000..13066dc
--- /dev/null
@@ -0,0 +1,149 @@
+USING: alien.c-types alien.syntax classes.struct windows.com
+windows.com.syntax windows.directx.d3d10
+windows.directx.d3d10misc windows.types ;
+IN: windows.directx.d3dx10mesh
+
+LIBRARY: d3dx10
+
+CONSTANT: D3DX10_MESH_32_BIT       1
+CONSTANT: D3DX10_MESH_GS_ADJACENCY 4
+
+TYPEDEF: int D3DX10_MESH
+
+STRUCT: D3DX10_ATTRIBUTE_RANGE
+    { AttribId     UINT }
+    { FaceStart    UINT }
+    { FaceCount    UINT }
+    { VertexStart  UINT }
+    { VertexCount  UINT } ;
+
+TYPEDEF: D3DX10_ATTRIBUTE_RANGE* LPD3DX10_ATTRIBUTE_RANGE
+
+CONSTANT: D3DX10_MESH_DISCARD_ATTRIBUTE_BUFFER HEX: 01
+CONSTANT: D3DX10_MESH_DISCARD_ATTRIBUTE_TABLE  HEX: 02
+CONSTANT: D3DX10_MESH_DISCARD_POINTREPS        HEX: 04
+CONSTANT: D3DX10_MESH_DISCARD_ADJACENCY        HEX: 08
+CONSTANT: D3DX10_MESH_DISCARD_DEVICE_BUFFERS   HEX: 10
+TYPEDEF: int D3DX10_MESH_DISCARD_FLAGS
+
+STRUCT: D3DX10_WELD_EPSILONS
+    { Position     FLOAT    }
+    { BlendWeights FLOAT    }
+    { Normal       FLOAT    }
+    { PSize        FLOAT    }
+    { Specular     FLOAT    }
+    { Diffuse      FLOAT    }
+    { Texcoord     FLOAT[8] }
+    { Tangent      FLOAT    }
+    { Binormal     FLOAT    }
+    { TessFactor   FLOAT    } ;
+
+TYPEDEF: D3DX10_WELD_EPSILONS* LPD3DX10_WELD_EPSILONS
+
+STRUCT: D3DX10_INTERSECT_INFO
+    { FaceIndex  UINT  }
+    { U          FLOAT }
+    { V          FLOAT }
+    { Dist       FLOAT } ;
+TYPEDEF: D3DX10_INTERSECT_INFO* LPD3DX10_INTERSECT_INFO
+
+COM-INTERFACE: ID3DX10MeshBuffer IUnknown {04B0D117-1041-46b1-AA8A-3952848BA22E}
+    HRESULT Map ( void** ppData, SIZE_T* pSize )
+    HRESULT Unmap ( )
+    SIZE_T GetSize ( ) ;
+
+COM-INTERFACE: ID3DX10Mesh IUnknown {4020E5C2-1403-4929-883F-E2E849FAC195}
+    UINT GetFaceCount ( )
+    UINT GetVertexCount ( )
+    UINT GetVertexBufferCount ( )
+    UINT GetFlags ( )
+    HRESULT GetVertexDescription ( D3D10_INPUT_ELEMENT_DESC** ppDesc, UINT* pDeclCount )
+    HRESULT SetVertexData ( UINT iBuffer, void* pData )
+    HRESULT GetVertexBuffer ( UINT iBuffer, ID3DX10MeshBuffer** ppVertexBuffer )
+    HRESULT SetIndexData ( void* pData, UINT cIndices )
+    HRESULT GetIndexBuffer ( ID3DX10MeshBuffer** ppIndexBuffer )
+    HRESULT SetAttributeData ( UINT* pData )
+    HRESULT GetAttributeBuffer ( ID3DX10MeshBuffer** ppAttributeBuffer )
+    HRESULT SetAttributeTable ( D3DX10_ATTRIBUTE_RANGE* pAttribTable, UINT cAttribTableSize )
+    HRESULT GetAttributeTable ( D3DX10_ATTRIBUTE_RANGE* pAttribTable, UINT* pAttribTableSize )
+    HRESULT GenerateAdjacencyAndPointReps ( FLOAT Epsilon )
+    HRESULT GenerateGSAdjacency ( )
+    HRESULT SetAdjacencyData ( UINT* pAdjacency )
+    HRESULT GetAdjacencyBuffer ( ID3DX10MeshBuffer** ppAdjacency )
+    HRESULT SetPointRepData ( UINT* pPointReps )
+    HRESULT GetPointRepBuffer ( ID3DX10MeshBuffer** ppPointReps )
+    HRESULT Discard ( D3DX10_MESH_DISCARD_FLAGS dwDiscard )
+    HRESULT CloneMesh ( UINT Flags, LPCSTR pPosSemantic, D3D10_INPUT_ELEMENT_DESC* pDesc, UINT DeclCount, ID3DX10Mesh** ppCloneMesh )
+    HRESULT Optimize ( UINT Flags, UINT* pFaceRemap, LPD3D10BLOB* ppVertexRemap )
+    HRESULT GenerateAttributeBufferFromTable ( )
+    HRESULT Intersect ( D3DXVECTOR3* pRayPos, D3DXVECTOR3* pRayDir,
+                                        UINT* pHitCount, UINT* pFaceIndex, float* pU, float* pV, float* pDist, ID3D10Blob** ppAllHits )
+    HRESULT IntersectSubset ( UINT AttribId, D3DXVECTOR3* pRayPos, D3DXVECTOR3* pRayDir,
+                                        UINT* pHitCount, UINT* pFaceIndex, float* pU, float* pV, float* pDist, ID3D10Blob** ppAllHits )
+    HRESULT CommitToDevice ( )
+    HRESULT DrawSubset ( UINT AttribId )
+    HRESULT DrawSubsetInstanced ( UINT AttribId, UINT InstanceCount, UINT StartInstanceLocation )
+    HRESULT GetDeviceVertexBuffer ( UINT iBuffer, ID3D10Buffer** ppVertexBuffer )
+    HRESULT GetDeviceIndexBuffer ( ID3D10Buffer** ppIndexBuffer ) ;
+
+FUNCTION: HRESULT
+    D3DX10CreateMesh (
+        ID3D10Device*             pDevice,
+        D3D10_INPUT_ELEMENT_DESC* pDeclaration,
+        UINT                      DeclCount,
+        LPCSTR                    pPositionSemantic,
+        UINT                      VertexCount,
+        UINT                      FaceCount,
+        UINT                      Options,
+        ID3DX10Mesh**             ppMesh        ) ;
+
+CONSTANT: D3DX10_MESHOPT_COMPACT            HEX: 01000000
+CONSTANT: D3DX10_MESHOPT_ATTR_SORT          HEX: 02000000
+CONSTANT: D3DX10_MESHOPT_VERTEX_CACHE       HEX: 04000000
+CONSTANT: D3DX10_MESHOPT_STRIP_REORDER      HEX: 08000000
+CONSTANT: D3DX10_MESHOPT_IGNORE_VERTS       HEX: 10000000
+CONSTANT: D3DX10_MESHOPT_DO_NOT_SPLIT       HEX: 20000000
+CONSTANT: D3DX10_MESHOPT_DEVICE_INDEPENDENT HEX: 00400000
+
+CONSTANT: D3DX10_SKININFO_NO_SCALING     0
+CONSTANT: D3DX10_SKININFO_SCALE_TO_1     1
+CONSTANT: D3DX10_SKININFO_SCALE_TO_TOTAL 2
+
+STRUCT: D3DX10_SKINNING_CHANNEL
+    { SrcOffset             UINT }
+    { DestOffset            UINT }
+    { IsNormal              BOOL } ;
+
+COM-INTERFACE: ID3DX10SkinInfo IUnknown {420BD604-1C76-4a34-A466-E45D0658A32C}
+    UINT GetNumVertices ( )
+    UINT GetNumBones ( )
+    UINT GetMaxBoneInfluences ( )
+    HRESULT AddVertices ( UINT  Count )
+    HRESULT RemapVertices ( UINT NewVertexCount, UINT* pVertexRemap )
+    HRESULT AddBones ( UINT Count )
+    HRESULT RemoveBone ( UINT Index )
+    HRESULT RemapBones ( UINT NewBoneCount, UINT* pBoneRemap )
+    HRESULT AddBoneInfluences ( UINT BoneIndex, UINT InfluenceCount, UINT* pIndices, float* pWeights )
+    HRESULT ClearBoneInfluences ( UINT BoneIndex )
+    UINT GetBoneInfluenceCount ( UINT BoneIndex )
+    HRESULT GetBoneInfluences ( UINT BoneIndex, UINT Offset, UINT Count, UINT* pDestIndices, float* pDestWeights )
+    HRESULT FindBoneInfluenceIndex ( UINT BoneIndex, UINT VertexIndex, UINT* pInfluenceIndex )
+    HRESULT SetBoneInfluence ( UINT BoneIndex, UINT InfluenceIndex, float Weight )
+    HRESULT GetBoneInfluence ( UINT BoneIndex, UINT InfluenceIndex, float* pWeight )
+    HRESULT Compact ( UINT MaxPerVertexInfluences, UINT ScaleMode, float MinWeight )
+    HRESULT DoSoftwareSkinning ( UINT StartVertex, UINT VertexCount, void* pSrcVertices, UINT SrcStride, void* pDestVertices, UINT DestStride, D3DXMATRIX* pBoneMatrices, D3DXMATRIX* pInverseTransposeBoneMatrices, D3DX10_SKINNING_CHANNEL* pChannelDescs, UINT NumChannels ) ;
+
+TYPEDEF: ID3DX10SkinInfo* LPD3DX10SKININFO
+
+FUNCTION: HRESULT
+    D3DX10CreateSkinInfo ( LPD3DX10SKININFO* ppSkinInfo ) ;
+
+STRUCT: D3DX10_ATTRIBUTE_WEIGHTS
+    { Position FLOAT    }
+    { Boundary FLOAT    }
+    { Normal   FLOAT    }
+    { Diffuse  FLOAT    }
+    { Specular FLOAT    }
+    { Texcoord FLOAT[8] }
+    { Tangent  FLOAT    }
+    { Binormal FLOAT    } ;
diff --git a/basis/windows/directx/d3dx10mesh/summary.txt b/basis/windows/directx/d3dx10mesh/summary.txt
new file mode 100644 (file)
index 0000000..b294d39
--- /dev/null
@@ -0,0 +1 @@
+Direct3D 10 bindings. Corresponds to d3dx10mesh.h.
diff --git a/basis/windows/directx/d3dx10mesh/tags.txt b/basis/windows/directx/d3dx10mesh/tags.txt
new file mode 100644 (file)
index 0000000..2320bdd
--- /dev/null
@@ -0,0 +1,2 @@
+unportable
+bindings
diff --git a/basis/windows/directx/d3dx10tex/authors.txt b/basis/windows/directx/d3dx10tex/authors.txt
new file mode 100644 (file)
index 0000000..6f03a12
--- /dev/null
@@ -0,0 +1 @@
+Erik Charlebois
diff --git a/basis/windows/directx/d3dx10tex/d3dx10tex.factor b/basis/windows/directx/d3dx10tex/d3dx10tex.factor
new file mode 100644 (file)
index 0000000..c4e3712
--- /dev/null
@@ -0,0 +1,286 @@
+USING: alien.c-types alien.syntax classes.struct
+windows.directx.d3d10 windows.directx.d3d10misc
+windows.directx.d3dx10async windows.directx.dxgiformat
+windows.types ;
+IN: windows.directx.d3dx10tex
+
+LIBRARY: d3dx10
+
+CONSTANT: D3DX10_FILTER_NONE             HEX: 00000001
+CONSTANT: D3DX10_FILTER_POINT            HEX: 00000002
+CONSTANT: D3DX10_FILTER_LINEAR           HEX: 00000003
+CONSTANT: D3DX10_FILTER_TRIANGLE         HEX: 00000004
+CONSTANT: D3DX10_FILTER_BOX              HEX: 00000005
+
+CONSTANT: D3DX10_FILTER_MIRROR_U         HEX: 00010000
+CONSTANT: D3DX10_FILTER_MIRROR_V         HEX: 00020000
+CONSTANT: D3DX10_FILTER_MIRROR_W         HEX: 00040000
+CONSTANT: D3DX10_FILTER_MIRROR           HEX: 00070000
+
+CONSTANT: D3DX10_FILTER_DITHER           HEX: 00080000
+CONSTANT: D3DX10_FILTER_DITHER_DIFFUSION HEX: 00100000
+
+CONSTANT: D3DX10_FILTER_SRGB_IN          HEX: 00200000
+CONSTANT: D3DX10_FILTER_SRGB_OUT         HEX: 00400000
+CONSTANT: D3DX10_FILTER_SRGB             HEX: 00600000
+TYPEDEF: int D3DX10_FILTER_FLAG
+
+CONSTANT: D3DX10_NORMALMAP_MIRROR_U          HEX: 00010000
+CONSTANT: D3DX10_NORMALMAP_MIRROR_V          HEX: 00020000
+CONSTANT: D3DX10_NORMALMAP_MIRROR            HEX: 00030000
+CONSTANT: D3DX10_NORMALMAP_INVERTSIGN        HEX: 00080000
+CONSTANT: D3DX10_NORMALMAP_COMPUTE_OCCLUSION HEX: 00100000
+TYPEDEF: int D3DX10_NORMALMAP_FLAG
+
+CONSTANT: D3DX10_CHANNEL_RED        1
+CONSTANT: D3DX10_CHANNEL_BLUE       2
+CONSTANT: D3DX10_CHANNEL_GREEN      4
+CONSTANT: D3DX10_CHANNEL_ALPHA      8
+CONSTANT: D3DX10_CHANNEL_LUMINANCE  16
+TYPEDEF: int D3DX10_CHANNEL_FLAG
+
+CONSTANT: D3DX10_IFF_BMP          0
+CONSTANT: D3DX10_IFF_JPG          1
+CONSTANT: D3DX10_IFF_PNG          3
+CONSTANT: D3DX10_IFF_DDS          4
+CONSTANT: D3DX10_IFF_TIFF         10
+CONSTANT: D3DX10_IFF_GIF          11
+CONSTANT: D3DX10_IFF_WMP          12
+CONSTANT: D3DX10_IFF_FORCE_DWORD  HEX: 7fffffff
+TYPEDEF: int D3DX10_IMAGE_FILE_FORMAT
+
+CONSTANT: D3DX10_STF_USEINPUTBLOB 1
+TYPEDEF: int D3DX10_SAVE_TEXTURE_FLAG
+
+STRUCT: D3DX10_IMAGE_INFO
+    { Width             UINT                     }
+    { Height            UINT                     }
+    { Depth             UINT                     }
+    { ArraySize         UINT                     }
+    { MipLevels         UINT                     }
+    { MiscFlags         UINT                     }
+    { Format            DXGI_FORMAT              }
+    { ResourceDimension D3D10_RESOURCE_DIMENSION }
+    { ImageFileFormat   D3DX10_IMAGE_FILE_FORMAT } ;
+
+STRUCT: D3DX10_IMAGE_LOAD_INFO
+    { Width          UINT               }
+    { Height         UINT               }
+    { Depth          UINT               }
+    { FirstMipLevel  UINT               }
+    { MipLevels      UINT               }
+    { Usage          D3D10_USAGE        }
+    { BindFlags      UINT               }
+    { CpuAccessFlags UINT               }
+    { MiscFlags      UINT               }
+    { Format         DXGI_FORMAT        }
+    { Filter         UINT               }
+    { MipFilter      UINT               }
+    { pSrcInfo       D3DX10_IMAGE_INFO* } ;
+
+FUNCTION: HRESULT
+    D3DX10GetImageInfoFromFileA (
+        LPCSTR                    pSrcFile,
+        ID3DX10ThreadPump*        pPump,
+        D3DX10_IMAGE_INFO*        pSrcInfo,
+        HRESULT*                  pHResult ) ;
+
+FUNCTION: HRESULT
+    D3DX10GetImageInfoFromFileW (
+        LPCWSTR                   pSrcFile,
+        ID3DX10ThreadPump*        pPump,
+        D3DX10_IMAGE_INFO*        pSrcInfo,
+        HRESULT*                  pHResult ) ;
+
+ALIAS: D3DX10GetImageInfoFromFile D3DX10GetImageInfoFromFileW
+
+FUNCTION: HRESULT
+    D3DX10GetImageInfoFromResourceA (
+        HMODULE                   hSrcModule,
+        LPCSTR                    pSrcResource,
+        ID3DX10ThreadPump*        pPump,
+        D3DX10_IMAGE_INFO*        pSrcInfo,
+        HRESULT*                  pHResult ) ;
+
+FUNCTION: HRESULT
+    D3DX10GetImageInfoFromResourceW (
+        HMODULE                   hSrcModule,
+        LPCWSTR                   pSrcResource,
+        ID3DX10ThreadPump*        pPump,
+        D3DX10_IMAGE_INFO*        pSrcInfo,
+        HRESULT*                  pHResult ) ;
+
+ALIAS: D3DX10GetImageInfoFromResource D3DX10GetImageInfoFromResourceW
+
+FUNCTION: HRESULT
+    D3DX10GetImageInfoFromMemory (
+        LPCVOID                   pSrcData,
+        SIZE_T                    SrcDataSize,
+        ID3DX10ThreadPump*        pPump,
+        D3DX10_IMAGE_INFO*        pSrcInfo,
+        HRESULT*                  pHResult ) ;
+
+FUNCTION: HRESULT
+    D3DX10CreateShaderResourceViewFromFileA (
+        ID3D10Device*               pDevice,
+        LPCSTR                      pSrcFile,
+        D3DX10_IMAGE_LOAD_INFO*     pLoadInfo,
+        ID3DX10ThreadPump*          pPump,
+        ID3D10ShaderResourceView**  ppShaderResourceView,
+        HRESULT*                    pHResult ) ;
+
+FUNCTION: HRESULT
+    D3DX10CreateShaderResourceViewFromFileW (
+        ID3D10Device*               pDevice,
+        LPCWSTR                     pSrcFile,
+        D3DX10_IMAGE_LOAD_INFO*     pLoadInfo,
+        ID3DX10ThreadPump*          pPump,
+        ID3D10ShaderResourceView**  ppShaderResourceView,
+        HRESULT*                    pHResult ) ;
+
+ALIAS: D3DX10CreateShaderResourceViewFromFile D3DX10CreateShaderResourceViewFromFileW
+
+FUNCTION: HRESULT
+    D3DX10CreateTextureFromFileA (
+        ID3D10Device*               pDevice,
+        LPCSTR                      pSrcFile,
+        D3DX10_IMAGE_LOAD_INFO*     pLoadInfo,
+        ID3DX10ThreadPump*          pPump,
+        ID3D10Resource**            ppTexture,
+        HRESULT*                    pHResult ) ;
+
+FUNCTION: HRESULT
+    D3DX10CreateTextureFromFileW (
+        ID3D10Device*               pDevice,
+        LPCWSTR                     pSrcFile,
+        D3DX10_IMAGE_LOAD_INFO*     pLoadInfo,
+        ID3DX10ThreadPump*          pPump,
+        ID3D10Resource**            ppTexture,
+        HRESULT*                    pHResult ) ;
+
+ALIAS: D3DX10CreateTextureFromFile D3DX10CreateTextureFromFileW
+
+FUNCTION: HRESULT
+    D3DX10CreateShaderResourceViewFromResourceA (
+        ID3D10Device*              pDevice,
+        HMODULE                    hSrcModule,
+        LPCSTR                     pSrcResource,
+        D3DX10_IMAGE_LOAD_INFO*    pLoadInfo,
+        ID3DX10ThreadPump*         pPump,
+        ID3D10ShaderResourceView** ppShaderResourceView,
+        HRESULT*                   pHResult ) ;
+
+FUNCTION: HRESULT
+    D3DX10CreateShaderResourceViewFromResourceW (
+        ID3D10Device*              pDevice,
+        HMODULE                    hSrcModule,
+        LPCWSTR                    pSrcResource,
+        D3DX10_IMAGE_LOAD_INFO*    pLoadInfo,
+        ID3DX10ThreadPump*         pPump,
+        ID3D10ShaderResourceView** ppShaderResourceView,
+        HRESULT*                   pHResult ) ;
+
+ALIAS: D3DX10CreateShaderResourceViewFromResource D3DX10CreateShaderResourceViewFromResourceW
+
+FUNCTION: HRESULT
+    D3DX10CreateTextureFromResourceA (
+        ID3D10Device*            pDevice,
+        HMODULE                  hSrcModule,
+        LPCSTR                   pSrcResource,
+        D3DX10_IMAGE_LOAD_INFO*  pLoadInfo,
+        ID3DX10ThreadPump*       pPump,
+        ID3D10Resource**         ppTexture,
+        HRESULT*                 pHResult ) ;
+
+FUNCTION: HRESULT
+    D3DX10CreateTextureFromResourceW (
+        ID3D10Device*           pDevice,
+        HMODULE                 hSrcModule,
+        LPCWSTR                 pSrcResource,
+        D3DX10_IMAGE_LOAD_INFO* pLoadInfo,
+        ID3DX10ThreadPump*      pPump,
+        ID3D10Resource**        ppTexture,
+        HRESULT*                pHResult ) ;
+
+ALIAS: D3DX10CreateTextureFromResource D3DX10CreateTextureFromResourceW
+
+FUNCTION: HRESULT
+    D3DX10CreateShaderResourceViewFromMemory (
+        ID3D10Device*              pDevice,
+        LPCVOID                    pSrcData,
+        SIZE_T                     SrcDataSize,
+        D3DX10_IMAGE_LOAD_INFO*    pLoadInfo,
+        ID3DX10ThreadPump*         pPump,
+        ID3D10ShaderResourceView** ppShaderResourceView,
+        HRESULT*                   pHResult ) ;
+
+FUNCTION: HRESULT
+    D3DX10CreateTextureFromMemory (
+        ID3D10Device*             pDevice,
+        LPCVOID                   pSrcData,
+        SIZE_T                    SrcDataSize,
+        D3DX10_IMAGE_LOAD_INFO*   pLoadInfo,
+        ID3DX10ThreadPump*        pPump,
+        ID3D10Resource**          ppTexture,
+        HRESULT*                  pHResult ) ;
+
+STRUCT: D3DX10_TEXTURE_LOAD_INFO
+    { pSrcBox                    D3D10_BOX* }
+    { pDstBox                    D3D10_BOX* }
+    { SrcFirstMip                UINT       }
+    { DstFirstMip                UINT       }
+    { NumMips                    UINT       }
+    { SrcFirstElement            UINT       }
+    { DstFirstElement            UINT       }
+    { NumElements                UINT       }
+    { Filter                     UINT       }
+    { MipFilter                  UINT       } ;
+
+FUNCTION: HRESULT
+    D3DX10LoadTextureFromTexture (
+        ID3D10Resource*            pSrcTexture,
+        D3DX10_TEXTURE_LOAD_INFO*  pLoadInfo,
+        ID3D10Resource*            pDstTexture ) ;
+
+FUNCTION: HRESULT
+    D3DX10FilterTexture (
+        ID3D10Resource*           pTexture,
+        UINT                      SrcLevel,
+        UINT                      MipFilter ) ;
+
+FUNCTION: HRESULT
+    D3DX10SaveTextureToFileA (
+        ID3D10Resource*           pSrcTexture,
+        D3DX10_IMAGE_FILE_FORMAT  DestFormat,
+        LPCSTR                    pDestFile ) ;
+
+FUNCTION: HRESULT
+    D3DX10SaveTextureToFileW (
+        ID3D10Resource*           pSrcTexture,
+        D3DX10_IMAGE_FILE_FORMAT  DestFormat,
+        LPCWSTR                   pDestFile ) ;
+
+ALIAS: D3DX10SaveTextureToFile D3DX10SaveTextureToFileW
+
+FUNCTION: HRESULT
+    D3DX10SaveTextureToMemory (
+        ID3D10Resource*            pSrcTexture,
+        D3DX10_IMAGE_FILE_FORMAT   DestFormat,
+        LPD3D10BLOB*               ppDestBuf,
+        UINT                       Flags ) ;
+
+FUNCTION: HRESULT
+    D3DX10ComputeNormalMap (
+        ID3D10Texture2D* pSrcTexture,
+        UINT             Flags,
+        UINT             Channel,
+        FLOAT            Amplitude,
+        ID3D10Texture2D* pDestTexture ) ;
+
+FUNCTION: HRESULT
+    D3DX10SHProjectCubeMap (
+        UINT             Order,
+        ID3D10Texture2D* pCubeMap,
+        FLOAT*           pROut,
+        FLOAT*           pGOut,
+        FLOAT*           pBOut ) ;
diff --git a/basis/windows/directx/d3dx10tex/summary.txt b/basis/windows/directx/d3dx10tex/summary.txt
new file mode 100644 (file)
index 0000000..25ff94b
--- /dev/null
@@ -0,0 +1 @@
+Direct3D 10 bindings. Corresponds to d3dx10tex.h.
diff --git a/basis/windows/directx/d3dx10tex/tags.txt b/basis/windows/directx/d3dx10tex/tags.txt
new file mode 100644 (file)
index 0000000..2320bdd
--- /dev/null
@@ -0,0 +1,2 @@
+unportable
+bindings
diff --git a/basis/windows/directx/d3dx11/authors.txt b/basis/windows/directx/d3dx11/authors.txt
new file mode 100644 (file)
index 0000000..6f03a12
--- /dev/null
@@ -0,0 +1 @@
+Erik Charlebois
diff --git a/basis/windows/directx/d3dx11/d3dx11.factor b/basis/windows/directx/d3dx11/d3dx11.factor
new file mode 100644 (file)
index 0000000..63b1733
--- /dev/null
@@ -0,0 +1,12 @@
+USING: ;
+IN: windows.directx.d3dx11
+
+CONSTANT: D3DX11_ERR_CANNOT_MODIFY_INDEX_BUFFER HEX: 88760B54
+CONSTANT: D3DX11_ERR_INVALID_MESH               HEX: 88760B55
+CONSTANT: D3DX11_ERR_CANNOT_ATTR_SORT           HEX: 88760B56
+CONSTANT: D3DX11_ERR_SKINNING_NOT_SUPPORTED     HEX: 88760B57
+CONSTANT: D3DX11_ERR_TOO_MANY_INFLUENCES        HEX: 88760B58
+CONSTANT: D3DX11_ERR_INVALID_DATA               HEX: 88760B59
+CONSTANT: D3DX11_ERR_LOADED_MESH_HAS_NO_DATA    HEX: 88760B5A
+CONSTANT: D3DX11_ERR_DUPLICATE_NAMED_FRAGMENT   HEX: 88760B5B
+CONSTANT: D3DX11_ERR_CANNOT_REMOVE_LAST_ITEM    HEX: 88760B5C
diff --git a/basis/windows/directx/d3dx11/summary.txt b/basis/windows/directx/d3dx11/summary.txt
new file mode 100644 (file)
index 0000000..58dfe46
--- /dev/null
@@ -0,0 +1 @@
+Direct3D 11 bindings. Corresponds to d3dx11.h.
diff --git a/basis/windows/directx/d3dx11/tags.txt b/basis/windows/directx/d3dx11/tags.txt
new file mode 100644 (file)
index 0000000..2320bdd
--- /dev/null
@@ -0,0 +1,2 @@
+unportable
+bindings
diff --git a/basis/windows/directx/d3dx11async/authors.txt b/basis/windows/directx/d3dx11async/authors.txt
new file mode 100644 (file)
index 0000000..6f03a12
--- /dev/null
@@ -0,0 +1 @@
+Erik Charlebois
diff --git a/basis/windows/directx/d3dx11async/d3dx11async.factor b/basis/windows/directx/d3dx11async/d3dx11async.factor
new file mode 100644 (file)
index 0000000..369ffd6
--- /dev/null
@@ -0,0 +1,59 @@
+USING: alien.syntax alien.c-types classes.struct windows.types
+windows.directx.d3d10shader windows.directx.d3dx11core
+windows.directx.d3d11 windows.directx.d3dx11tex ;
+IN: windows.directx.d3dx11async
+
+LIBRARY: d3dx11
+
+FUNCTION: HRESULT D3DX11CompileFromFileA ( LPCSTR pSrcFile, D3D10_SHADER_MACRO* pDefines, LPD3D10INCLUDE pInclude,
+        LPCSTR pFunctionName, LPCSTR pProfile, UINT Flags1, UINT Flags2, ID3DX11ThreadPump* pPump, ID3D10Blob** ppShader, ID3D10Blob** ppErrorMsgs, HRESULT* pHResult ) ;
+FUNCTION: HRESULT D3DX11CompileFromFileW ( LPCWSTR pSrcFile, D3D10_SHADER_MACRO* pDefines, LPD3D10INCLUDE pInclude,
+        LPCSTR pFunctionName, LPCSTR pProfile, UINT Flags1, UINT Flags2, ID3DX11ThreadPump* pPump, ID3D10Blob** ppShader, ID3D10Blob** ppErrorMsgs, HRESULT* pHResult ) ;
+ALIAS: D3DX11CompileFromFile D3DX11CompileFromFileW
+
+FUNCTION: HRESULT D3DX11CompileFromResourceA ( HMODULE hSrcModule, LPCSTR pSrcResource, LPCSTR pSrcFileName, D3D10_SHADER_MACRO* pDefines, 
+    LPD3D10INCLUDE pInclude, LPCSTR pFunctionName, LPCSTR pProfile, UINT Flags1, UINT Flags2, ID3DX11ThreadPump* pPump, ID3D10Blob** ppShader, ID3D10Blob** ppErrorMsgs, HRESULT* pHResult ) ;
+FUNCTION: HRESULT D3DX11CompileFromResourceW ( HMODULE hSrcModule, LPCWSTR pSrcResource, LPCWSTR pSrcFileName, D3D10_SHADER_MACRO* pDefines, 
+    LPD3D10INCLUDE pInclude, LPCSTR pFunctionName, LPCSTR pProfile, UINT Flags1, UINT Flags2, ID3DX11ThreadPump* pPump, ID3D10Blob** ppShader, ID3D10Blob** ppErrorMsgs, HRESULT* pHResult ) ;
+ALIAS: D3DX11CompileFromResource D3DX11CompileFromResourceW
+
+FUNCTION: HRESULT D3DX11CompileFromMemory ( LPCSTR pSrcData, SIZE_T SrcDataLen, LPCSTR pFileName, D3D10_SHADER_MACRO* pDefines, LPD3D10INCLUDE pInclude, 
+    LPCSTR pFunctionName, LPCSTR pProfile, UINT Flags1, UINT Flags2, ID3DX11ThreadPump* pPump, ID3D10Blob** ppShader, ID3D10Blob** ppErrorMsgs, HRESULT* pHResult ) ;
+
+FUNCTION: HRESULT D3DX11PreprocessShaderFromFileA ( LPCSTR pFileName, D3D10_SHADER_MACRO* pDefines, 
+    LPD3D10INCLUDE pInclude, ID3DX11ThreadPump* pPump, ID3D10Blob** ppShaderText, ID3D10Blob** ppErrorMsgs, HRESULT* pHResult ) ;
+
+FUNCTION: HRESULT D3DX11PreprocessShaderFromFileW ( LPCWSTR pFileName, D3D10_SHADER_MACRO* pDefines, 
+    LPD3D10INCLUDE pInclude, ID3DX11ThreadPump* pPump, ID3D10Blob** ppShaderText, ID3D10Blob** ppErrorMsgs, HRESULT* pHResult ) ;
+
+FUNCTION: HRESULT D3DX11PreprocessShaderFromMemory ( LPCSTR pSrcData, SIZE_T SrcDataSize, LPCSTR pFileName, D3D10_SHADER_MACRO* pDefines, 
+    LPD3D10INCLUDE pInclude, ID3DX11ThreadPump* pPump, ID3D10Blob** ppShaderText, ID3D10Blob** ppErrorMsgs, HRESULT* pHResult ) ;
+
+FUNCTION: HRESULT D3DX11PreprocessShaderFromResourceA ( HMODULE hModule, LPCSTR pResourceName, LPCSTR pSrcFileName, D3D10_SHADER_MACRO* pDefines, 
+    LPD3D10INCLUDE pInclude, ID3DX11ThreadPump* pPump, ID3D10Blob** ppShaderText, ID3D10Blob** ppErrorMsgs, HRESULT* pHResult ) ;
+
+FUNCTION: HRESULT D3DX11PreprocessShaderFromResourceW ( HMODULE hModule, LPCWSTR pResourceName, LPCWSTR pSrcFileName, D3D10_SHADER_MACRO* pDefines, 
+    LPD3D10INCLUDE pInclude, ID3DX11ThreadPump* pPump, ID3D10Blob** ppShaderText, ID3D10Blob** ppErrorMsgs, HRESULT* pHResult ) ;
+
+ALIAS: D3DX11PreprocessShaderFromFile      D3DX11PreprocessShaderFromFileW
+ALIAS: D3DX11PreprocessShaderFromResource  D3DX11PreprocessShaderFromResourceW
+
+FUNCTION: HRESULT D3DX11CreateAsyncCompilerProcessor ( LPCSTR pFileName, D3D10_SHADER_MACRO* pDefines, LPD3D10INCLUDE pInclude, 
+        LPCSTR pFunctionName, LPCSTR pProfile, UINT Flags1, UINT Flags2,
+        ID3D10Blob** ppCompiledShader, ID3D10Blob** ppErrorBuffer, ID3DX11DataProcessor** ppProcessor ) ;
+
+FUNCTION: HRESULT D3DX11CreateAsyncShaderPreprocessProcessor ( LPCSTR pFileName, D3D10_SHADER_MACRO* pDefines, LPD3D10INCLUDE pInclude, 
+        ID3D10Blob** ppShaderText, ID3D10Blob** ppErrorBuffer, ID3DX11DataProcessor** ppProcessor ) ;
+
+FUNCTION: HRESULT D3DX11CreateAsyncFileLoaderW ( LPCWSTR pFileName, ID3DX11DataLoader** ppDataLoader ) ;
+FUNCTION: HRESULT D3DX11CreateAsyncFileLoaderA ( LPCSTR pFileName, ID3DX11DataLoader** ppDataLoader ) ;
+FUNCTION: HRESULT D3DX11CreateAsyncMemoryLoader ( LPCVOID pData, SIZE_T cbData, ID3DX11DataLoader** ppDataLoader ) ;
+FUNCTION: HRESULT D3DX11CreateAsyncResourceLoaderW ( HMODULE hSrcModule, LPCWSTR pSrcResource, ID3DX11DataLoader** ppDataLoader ) ;
+FUNCTION: HRESULT D3DX11CreateAsyncResourceLoaderA ( HMODULE hSrcModule, LPCSTR pSrcResource, ID3DX11DataLoader** ppDataLoader ) ;
+
+ALIAS: D3DX11CreateAsyncFileLoader D3DX11CreateAsyncFileLoaderW
+ALIAS: D3DX11CreateAsyncResourceLoader D3DX11CreateAsyncResourceLoaderW
+
+FUNCTION: HRESULT D3DX11CreateAsyncTextureProcessor ( ID3D11Device* pDevice, D3DX11_IMAGE_LOAD_INFO* pLoadInfo, ID3DX11DataProcessor** ppDataProcessor ) ;
+FUNCTION: HRESULT D3DX11CreateAsyncTextureInfoProcessor ( D3DX11_IMAGE_INFO* pImageInfo, ID3DX11DataProcessor** ppDataProcessor ) ;
+FUNCTION: HRESULT D3DX11CreateAsyncShaderResourceViewProcessor ( ID3D11Device* pDevice, D3DX11_IMAGE_LOAD_INFO* pLoadInfo, ID3DX11DataProcessor** ppDataProcessor ) ;
diff --git a/basis/windows/directx/d3dx11async/summary.txt b/basis/windows/directx/d3dx11async/summary.txt
new file mode 100644 (file)
index 0000000..e80d034
--- /dev/null
@@ -0,0 +1 @@
+Direct3D 11 bindings. Corresponds to d3dx11async.h.
diff --git a/basis/windows/directx/d3dx11async/tags.txt b/basis/windows/directx/d3dx11async/tags.txt
new file mode 100644 (file)
index 0000000..2320bdd
--- /dev/null
@@ -0,0 +1,2 @@
+unportable
+bindings
diff --git a/basis/windows/directx/d3dx11core/authors.txt b/basis/windows/directx/d3dx11core/authors.txt
new file mode 100644 (file)
index 0000000..6f03a12
--- /dev/null
@@ -0,0 +1 @@
+Erik Charlebois
diff --git a/basis/windows/directx/d3dx11core/d3dx11core.factor b/basis/windows/directx/d3dx11core/d3dx11core.factor
new file mode 100644 (file)
index 0000000..fc8ce1a
--- /dev/null
@@ -0,0 +1,31 @@
+USING: alien.syntax windows.types windows.com.syntax alien.c-types windows.com
+windows.directx.d3d11 ;
+IN: windows.directx.d3dx11core
+
+LIBRARY: d3dx11
+
+FUNCTION: HRESULT D3DX11CheckVersion ( UINT D3DSdkVersion, UINT D3DX11SdkVersion ) ;
+
+COM-INTERFACE: ID3DX11DataLoader f {00000000-0000-0000-0000-000000000000}
+    HRESULT Load ( )
+    HRESULT Decompress ( void** ppData, SIZE_T* pcBytes )
+    HRESULT Destroy ( ) ;
+
+COM-INTERFACE: ID3DX11DataProcessor f {00000000-0000-0000-0000-000000000000}
+    HRESULT Process ( void* pData, SIZE_T cBytes )
+    HRESULT CreateDeviceObject ( void** ppDataObject )
+    HRESULT Destroy ( ) ;
+
+COM-INTERFACE: ID3DX11ThreadPump IUnknown {C93FECFA-6967-478a-ABBC-402D90621FCB}
+    HRESULT AddWorkItem ( ID3DX11DataLoader* pDataLoader, ID3DX11DataProcessor* pDataProcessor, HRESULT* pHResult, void** ppDeviceObject )
+    UINT GetWorkItemCount ( )
+    HRESULT WaitForAllItems ( )
+    HRESULT ProcessDeviceWorkItems ( UINT iWorkItemCount )
+    HRESULT PurgeAllItems ( )
+    HRESULT GetQueueStatus ( UINT* pIoQueue, UINT* pProcessQueue, UINT* pDeviceQueue ) ;
+
+FUNCTION: HRESULT D3DX11CreateThreadPump ( UINT cIoThreads, UINT cProcThreads, ID3DX11ThreadPump** ppThreadPump ) ;
+FUNCTION: HRESULT D3DX11UnsetAllDeviceObjects ( ID3D11DeviceContext* pContext ) ;
+
+CONSTANT: D3DERR_INVALIDCALL     HEX: 8876086C
+CONSTANT: D3DERR_WASSTILLDRAWING HEX: 8876021C
diff --git a/basis/windows/directx/d3dx11core/summary.txt b/basis/windows/directx/d3dx11core/summary.txt
new file mode 100644 (file)
index 0000000..83ab3f1
--- /dev/null
@@ -0,0 +1 @@
+Direct3D 11 bindings. Corresponds to d3dx11core.h.
diff --git a/basis/windows/directx/d3dx11core/tags.txt b/basis/windows/directx/d3dx11core/tags.txt
new file mode 100644 (file)
index 0000000..2320bdd
--- /dev/null
@@ -0,0 +1,2 @@
+unportable
+bindings
diff --git a/basis/windows/directx/d3dx11tex/authors.txt b/basis/windows/directx/d3dx11tex/authors.txt
new file mode 100644 (file)
index 0000000..6f03a12
--- /dev/null
@@ -0,0 +1 @@
+Erik Charlebois
diff --git a/basis/windows/directx/d3dx11tex/d3dx11tex.factor b/basis/windows/directx/d3dx11tex/d3dx11tex.factor
new file mode 100644 (file)
index 0000000..d21fa0c
--- /dev/null
@@ -0,0 +1,293 @@
+USING: alien.syntax alien.c-types classes.struct windows.types
+windows.directx.dxgiformat windows.directx.d3d11
+windows.directx.d3dx11core ;
+IN: windows.directx.d3dx11tex
+
+LIBRARY: d3dx11
+
+CONSTANT: D3DX11_FILTER_NONE             HEX: 00000001
+CONSTANT: D3DX11_FILTER_POINT            HEX: 00000002
+CONSTANT: D3DX11_FILTER_LINEAR           HEX: 00000003
+CONSTANT: D3DX11_FILTER_TRIANGLE         HEX: 00000004
+CONSTANT: D3DX11_FILTER_BOX              HEX: 00000005
+
+CONSTANT: D3DX11_FILTER_MIRROR_U         HEX: 00010000
+CONSTANT: D3DX11_FILTER_MIRROR_V         HEX: 00020000
+CONSTANT: D3DX11_FILTER_MIRROR_W         HEX: 00040000
+CONSTANT: D3DX11_FILTER_MIRROR           HEX: 00070000
+
+CONSTANT: D3DX11_FILTER_DITHER           HEX: 00080000
+CONSTANT: D3DX11_FILTER_DITHER_DIFFUSION HEX: 00100000
+
+CONSTANT: D3DX11_FILTER_SRGB_IN          HEX: 00200000
+CONSTANT: D3DX11_FILTER_SRGB_OUT         HEX: 00400000
+CONSTANT: D3DX11_FILTER_SRGB             HEX: 00600000
+TYPEDEF: int D3DX11_FILTER_FLAG
+
+CONSTANT: D3DX11_NORMALMAP_MIRROR_U          HEX: 00010000
+CONSTANT: D3DX11_NORMALMAP_MIRROR_V          HEX: 00020000
+CONSTANT: D3DX11_NORMALMAP_MIRROR            HEX: 00030000
+CONSTANT: D3DX11_NORMALMAP_INVERTSIGN        HEX: 00080000
+CONSTANT: D3DX11_NORMALMAP_COMPUTE_OCCLUSION HEX: 00100000
+TYPEDEF: int D3DX11_NORMALMAP_FLAG
+
+CONSTANT: D3DX11_CHANNEL_RED        1
+CONSTANT: D3DX11_CHANNEL_BLUE       2
+CONSTANT: D3DX11_CHANNEL_GREEN      4
+CONSTANT: D3DX11_CHANNEL_ALPHA      8
+CONSTANT: D3DX11_CHANNEL_LUMINANCE  16
+TYPEDEF: int D3DX11_CHANNEL_FLAG
+
+CONSTANT: D3DX11_IFF_BMP          0
+CONSTANT: D3DX11_IFF_JPG          1
+CONSTANT: D3DX11_IFF_PNG          3
+CONSTANT: D3DX11_IFF_DDS          4
+CONSTANT: D3DX11_IFF_TIFF         10
+CONSTANT: D3DX11_IFF_GIF          11
+CONSTANT: D3DX11_IFF_WMP          12
+CONSTANT: D3DX11_IFF_FORCE_DWORD  HEX: 7fffffff
+TYPEDEF: int D3DX11_IMAGE_FILE_FORMAT
+
+CONSTANT: D3DX11_STF_USEINPUTBLOB 1
+TYPEDEF: int D3DX11_SAVE_TEXTURE_FLAG
+
+STRUCT: D3DX11_IMAGE_INFO
+    { Width             UINT                     }
+    { Height            UINT                     }
+    { Depth             UINT                     }
+    { ArraySize         UINT                     }
+    { MipLevels         UINT                     }
+    { MiscFlags         UINT                     }
+    { Format            DXGI_FORMAT              }
+    { ResourceDimension D3D11_RESOURCE_DIMENSION }
+    { ImageFileFormat   D3DX11_IMAGE_FILE_FORMAT } ;
+
+STRUCT: D3DX11_IMAGE_LOAD_INFO
+    { Width          UINT               }
+    { Height         UINT               }
+    { Depth          UINT               }
+    { FirstMipLevel  UINT               }
+    { MipLevels      UINT               }
+    { Usage          D3D11_USAGE        }
+    { BindFlags      UINT               }
+    { CpuAccessFlags UINT               }
+    { MiscFlags      UINT               }
+    { Format         DXGI_FORMAT        }
+    { Filter         UINT               }
+    { MipFilter      UINT               }
+    { pSrcInfo       D3DX11_IMAGE_INFO* } ;
+
+FUNCTION: HRESULT
+    D3DX11GetImageInfoFromFileA (
+        LPCSTR                    pSrcFile,
+        ID3DX11ThreadPump*        pPump,
+        D3DX11_IMAGE_INFO*        pSrcInfo,
+        HRESULT*                  pHResult ) ;
+
+FUNCTION: HRESULT
+    D3DX11GetImageInfoFromFileW (
+        LPCWSTR                   pSrcFile,
+        ID3DX11ThreadPump*        pPump,
+        D3DX11_IMAGE_INFO*        pSrcInfo,
+        HRESULT*                  pHResult ) ;
+
+ALIAS: D3DX11GetImageInfoFromFile D3DX11GetImageInfoFromFileW
+
+FUNCTION: HRESULT
+    D3DX11GetImageInfoFromResourceA (
+        HMODULE                   hSrcModule,
+        LPCSTR                    pSrcResource,
+        ID3DX11ThreadPump*        pPump,
+        D3DX11_IMAGE_INFO*        pSrcInfo,
+        HRESULT*                  pHResult ) ;
+
+FUNCTION: HRESULT
+    D3DX11GetImageInfoFromResourceW (
+        HMODULE                   hSrcModule,
+        LPCWSTR                   pSrcResource,
+        ID3DX11ThreadPump*        pPump,
+        D3DX11_IMAGE_INFO*        pSrcInfo,
+        HRESULT*                  pHResult ) ;
+
+ALIAS: D3DX11GetImageInfoFromResource D3DX11GetImageInfoFromResourceW
+
+FUNCTION: HRESULT
+    D3DX11GetImageInfoFromMemory (
+        LPCVOID                   pSrcData,
+        SIZE_T                    SrcDataSize,
+        ID3DX11ThreadPump*        pPump,
+        D3DX11_IMAGE_INFO*        pSrcInfo,
+        HRESULT*                  pHResult ) ;
+
+FUNCTION: HRESULT
+    D3DX11CreateShaderResourceViewFromFileA (
+        ID3D11Device*               pDevice,
+        LPCSTR                      pSrcFile,
+        D3DX11_IMAGE_LOAD_INFO*     pLoadInfo,
+        ID3DX11ThreadPump*          pPump,
+        ID3D11ShaderResourceView**  ppShaderResourceView,
+        HRESULT*                    pHResult ) ;
+
+FUNCTION: HRESULT
+    D3DX11CreateShaderResourceViewFromFileW (
+        ID3D11Device*               pDevice,
+        LPCWSTR                     pSrcFile,
+        D3DX11_IMAGE_LOAD_INFO*     pLoadInfo,
+        ID3DX11ThreadPump*          pPump,
+        ID3D11ShaderResourceView**  ppShaderResourceView,
+        HRESULT*                    pHResult ) ;
+
+ALIAS: D3DX11CreateShaderResourceViewFromFile D3DX11CreateShaderResourceViewFromFileW
+
+FUNCTION: HRESULT
+    D3DX11CreateTextureFromFileA (
+        ID3D11Device*               pDevice,
+        LPCSTR                      pSrcFile,
+        D3DX11_IMAGE_LOAD_INFO*     pLoadInfo,
+        ID3DX11ThreadPump*          pPump,
+        ID3D11Resource**            ppTexture,
+        HRESULT*                    pHResult ) ;
+
+FUNCTION: HRESULT
+    D3DX11CreateTextureFromFileW (
+        ID3D11Device*               pDevice,
+        LPCWSTR                     pSrcFile,
+        D3DX11_IMAGE_LOAD_INFO*     pLoadInfo,
+        ID3DX11ThreadPump*          pPump,
+        ID3D11Resource**            ppTexture,
+        HRESULT*                    pHResult ) ;
+
+ALIAS: D3DX11CreateTextureFromFile D3DX11CreateTextureFromFileW
+
+FUNCTION: HRESULT
+    D3DX11CreateShaderResourceViewFromResourceA (
+        ID3D11Device*              pDevice,
+        HMODULE                    hSrcModule,
+        LPCSTR                     pSrcResource,
+        D3DX11_IMAGE_LOAD_INFO*    pLoadInfo,
+        ID3DX11ThreadPump*         pPump,
+        ID3D11ShaderResourceView** ppShaderResourceView,
+        HRESULT*                   pHResult ) ;
+
+FUNCTION: HRESULT
+    D3DX11CreateShaderResourceViewFromResourceW (
+        ID3D11Device*              pDevice,
+        HMODULE                    hSrcModule,
+        LPCWSTR                    pSrcResource,
+        D3DX11_IMAGE_LOAD_INFO*    pLoadInfo,
+        ID3DX11ThreadPump*         pPump,
+        ID3D11ShaderResourceView** ppShaderResourceView,
+        HRESULT*                   pHResult ) ;
+
+ALIAS: D3DX11CreateShaderResourceViewFromResource D3DX11CreateShaderResourceViewFromResourceW
+
+FUNCTION: HRESULT
+    D3DX11CreateTextureFromResourceA (
+        ID3D11Device*            pDevice,
+        HMODULE                  hSrcModule,
+        LPCSTR                   pSrcResource,
+        D3DX11_IMAGE_LOAD_INFO*  pLoadInfo,
+        ID3DX11ThreadPump*       pPump,
+        ID3D11Resource**         ppTexture,
+        HRESULT*                 pHResult ) ;
+
+FUNCTION: HRESULT
+    D3DX11CreateTextureFromResourceW (
+        ID3D11Device*           pDevice,
+        HMODULE                 hSrcModule,
+        LPCWSTR                 pSrcResource,
+        D3DX11_IMAGE_LOAD_INFO* pLoadInfo,
+        ID3DX11ThreadPump*      pPump,
+        ID3D11Resource**        ppTexture,
+        HRESULT*                pHResult ) ;
+
+ALIAS: D3DX11CreateTextureFromResource D3DX11CreateTextureFromResourceW
+
+FUNCTION: HRESULT
+    D3DX11CreateShaderResourceViewFromMemory (
+        ID3D11Device*              pDevice,
+        LPCVOID                    pSrcData,
+        SIZE_T                     SrcDataSize,
+        D3DX11_IMAGE_LOAD_INFO*    pLoadInfo,
+        ID3DX11ThreadPump*         pPump,
+        ID3D11ShaderResourceView** ppShaderResourceView,
+        HRESULT*                   pHResult ) ;
+
+FUNCTION: HRESULT
+    D3DX11CreateTextureFromMemory (
+        ID3D11Device*             pDevice,
+        LPCVOID                   pSrcData,
+        SIZE_T                    SrcDataSize,
+        D3DX11_IMAGE_LOAD_INFO*   pLoadInfo,
+        ID3DX11ThreadPump*        pPump,
+        ID3D11Resource**          ppTexture,
+        HRESULT*                  pHResult ) ;
+
+STRUCT: D3DX11_TEXTURE_LOAD_INFO
+    { pSrcBox         D3D11_BOX* }
+    { pDstBox         D3D11_BOX* }
+    { SrcFirstMip     UINT       }
+    { DstFirstMip     UINT       }
+    { NumMips         UINT       }
+    { SrcFirstElement UINT       }
+    { DstFirstElement UINT       }
+    { NumElements     UINT       }
+    { Filter          UINT       }
+    { MipFilter       UINT       } ;
+
+FUNCTION: HRESULT
+    D3DX11LoadTextureFromTexture (
+        ID3D11DeviceContext*       pContext,
+        ID3D11Resource*            pSrcTexture,
+        D3DX11_TEXTURE_LOAD_INFO*  pLoadInfo,
+        ID3D11Resource*            pDstTexture ) ;
+
+FUNCTION: HRESULT
+    D3DX11FilterTexture (
+        ID3D11DeviceContext*      pContext,
+        ID3D11Resource*           pTexture,
+        UINT                      SrcLevel,
+        UINT                      MipFilter ) ;
+
+FUNCTION: HRESULT
+    D3DX11SaveTextureToFileA (
+        ID3D11DeviceContext*      pContext,
+        ID3D11Resource*           pSrcTexture,
+        D3DX11_IMAGE_FILE_FORMAT  DestFormat,
+        LPCSTR                    pDestFile ) ;
+
+FUNCTION: HRESULT
+    D3DX11SaveTextureToFileW (
+        ID3D11DeviceContext*      pContext,
+        ID3D11Resource*           pSrcTexture,
+        D3DX11_IMAGE_FILE_FORMAT  DestFormat,
+        LPCWSTR                   pDestFile ) ;
+
+ALIAS: D3DX11SaveTextureToFile D3DX11SaveTextureToFileW
+
+FUNCTION: HRESULT
+    D3DX11SaveTextureToMemory (
+        ID3D11DeviceContext*       pContext,
+        ID3D11Resource*            pSrcTexture,
+        D3DX11_IMAGE_FILE_FORMAT   DestFormat,
+        ID3D10Blob**               ppDestBuf,
+        UINT                       Flags ) ;
+
+FUNCTION: HRESULT
+    D3DX11ComputeNormalMap (
+        ID3D11DeviceContext*      pContext,
+        ID3D11Texture2D*          pSrcTexture,
+        UINT                      Flags,
+        UINT                      Channel,
+        FLOAT                     Amplitude,
+        ID3D11Texture2D*          pDestTexture ) ;
+
+FUNCTION: HRESULT
+    D3DX11SHProjectCubeMap (
+        ID3D11DeviceContext* pContext,
+        UINT                 Order,
+        ID3D11Texture2D*     pCubeMap,
+        FLOAT*               pROut,
+        FLOAT*               pGOut,
+        FLOAT*               pBOut ) ;
+
diff --git a/basis/windows/directx/d3dx11tex/summary.txt b/basis/windows/directx/d3dx11tex/summary.txt
new file mode 100644 (file)
index 0000000..94bbcd0
--- /dev/null
@@ -0,0 +1 @@
+Direct3D 11 bindings. Corresponds to d3dx11tex.h.
diff --git a/basis/windows/directx/d3dx11tex/tags.txt b/basis/windows/directx/d3dx11tex/tags.txt
new file mode 100644 (file)
index 0000000..2320bdd
--- /dev/null
@@ -0,0 +1,2 @@
+unportable
+bindings
diff --git a/basis/windows/directx/d3dx9/authors.txt b/basis/windows/directx/d3dx9/authors.txt
new file mode 100644 (file)
index 0000000..6f03a12
--- /dev/null
@@ -0,0 +1 @@
+Erik Charlebois
diff --git a/basis/windows/directx/d3dx9/d3dx9.factor b/basis/windows/directx/d3dx9/d3dx9.factor
new file mode 100644 (file)
index 0000000..c2bccb2
--- /dev/null
@@ -0,0 +1,12 @@
+USING: ;
+IN: windows.directx.d3dx9
+
+CONSTANT: D3DXERR_CANNOTMODIFYINDEXBUFFER     HEX: 88760B55
+CONSTANT: D3DXERR_INVALIDMESH                 HEX: 88760B56
+CONSTANT: D3DXERR_CANNOTATTRSORT              HEX: 88760B57
+CONSTANT: D3DXERR_SKINNINGNOTSUPPORTED        HEX: 88760B58
+CONSTANT: D3DXERR_TOOMANYINFLUENCES           HEX: 88760B59
+CONSTANT: D3DXERR_INVALIDDATA                 HEX: 88760B5A
+CONSTANT: D3DXERR_LOADEDMESHASNODATA          HEX: 88760B5B
+CONSTANT: D3DXERR_DUPLICATENAMEDFRAGMENT      HEX: 88760B5C
+CONSTANT: D3DXERR_CANNOTREMOVELASTITEM        HEX: 88760B5D
diff --git a/basis/windows/directx/d3dx9/summary.txt b/basis/windows/directx/d3dx9/summary.txt
new file mode 100644 (file)
index 0000000..3132a55
--- /dev/null
@@ -0,0 +1 @@
+DirectX 9 bindings. Corresponds to d3dx9.h.
diff --git a/basis/windows/directx/d3dx9/tags.txt b/basis/windows/directx/d3dx9/tags.txt
new file mode 100644 (file)
index 0000000..2320bdd
--- /dev/null
@@ -0,0 +1,2 @@
+unportable
+bindings
diff --git a/basis/windows/directx/d3dx9anim/authors.txt b/basis/windows/directx/d3dx9anim/authors.txt
new file mode 100644 (file)
index 0000000..6f03a12
--- /dev/null
@@ -0,0 +1 @@
+Erik Charlebois
diff --git a/basis/windows/directx/d3dx9anim/d3dx9anim.factor b/basis/windows/directx/d3dx9anim/d3dx9anim.factor
new file mode 100644 (file)
index 0000000..9864d64
--- /dev/null
@@ -0,0 +1,426 @@
+USING: alien.c-types alien.syntax classes.struct windows.com
+windows.com.syntax windows.directx.d3d9
+windows.directx.d3dx9core windows.directx.d3dx9math
+windows.directx.d3dx9mesh windows.directx.d3dx9xof
+windows.types ;
+IN: windows.directx.d3dx9anim
+
+LIBRARY: d3dx9
+
+TYPEDEF: int D3DXMESHDATATYPE
+CONSTANT: D3DXMESHTYPE_MESH      1
+CONSTANT: D3DXMESHTYPE_PMESH     2
+CONSTANT: D3DXMESHTYPE_PATCHMESH 3
+CONSTANT: D3DXMESHTYPE_FORCE_DWORD HEX: 7fffffff
+
+STRUCT: D3DXMESHDATA
+    { Type D3DXMESHDATATYPE }
+    { Mesh void*            } ;
+TYPEDEF: D3DXMESHDATA* LPD3DXMESHDATA
+
+STRUCT: D3DXMESHCONTAINER
+    { Name                LPSTR                }
+    { MeshData            D3DXMESHDATA         }
+    { pMaterials          LPD3DXMATERIAL       }
+    { pEffects            LPD3DXEFFECTINSTANCE }
+    { NumMaterials        DWORD                }
+    { pAdjacency          DWORD*               }
+    { pSkinInfo           LPD3DXSKININFO       }
+    { pNextMeshContainer  D3DXMESHCONTAINER*   } ;
+TYPEDEF: D3DXMESHCONTAINER* LPD3DXMESHCONTAINER
+
+STRUCT: D3DXFRAME
+    { Name                  LPSTR               }
+    { TransformationMatrix  D3DXMATRIX          }
+    { pMeshContainer        LPD3DXMESHCONTAINER }
+    { pFrameSibling         D3DXFRAME*          }
+    { pFrameFirstChild      D3DXFRAME*          } ;
+TYPEDEF: D3DXFRAME* LPD3DXFRAME
+
+C-TYPE: ID3DXAllocateHierarchy
+TYPEDEF: ID3DXAllocateHierarchy* LPD3DXALLOCATEHIERARCHY
+
+COM-INTERFACE: ID3DXAllocateHierarchy f {00000000-0000-0000-0000-000000000000}
+    HRESULT CreateFrame ( LPCSTR Name, LPD3DXFRAME* ppNewFrame )
+    HRESULT CreateMeshContainer (
+        LPCSTR               Name,
+        D3DXMESHDATA*        pMeshData,
+        D3DXMATERIAL*        pMaterials,
+        D3DXEFFECTINSTANCE*  pEffectInstances,
+        DWORD                NumMaterials,
+        DWORD*               pAdjacency,
+        LPD3DXSKININFO       pSkinInfo,
+        LPD3DXMESHCONTAINER* ppNewMeshContainer )
+    HRESULT DestroyFrame ( LPD3DXFRAME pFrameToFree )
+    HRESULT DestroyMeshContainer ( LPD3DXMESHCONTAINER pMeshContainerToFree )  ;
+
+C-TYPE: ID3DXLoadUserData
+TYPEDEF: ID3DXLoadUserData* LPD3DXLOADUSERDATA
+
+COM-INTERFACE: ID3DXLoadUserData f {00000000-0000-0000-0000-000000000000}
+    HRESULT LoadTopLevelData ( LPD3DXFILEDATA pXofChildData )
+    HRESULT LoadFrameChildData ( LPD3DXFRAME pFrame,
+                                 LPD3DXFILEDATA pXofChildData )
+    HRESULT LoadMeshChildData ( LPD3DXMESHCONTAINER pMeshContainer,
+                                LPD3DXFILEDATA pXofChildData ) ;
+
+C-TYPE: ID3DXSaveUserData
+TYPEDEF: ID3DXSaveUserData* LPD3DXSAVEUSERDATA
+
+COM-INTERFACE: ID3DXSaveUserData f {00000000-0000-0000-0000-000000000000}
+    HRESULT AddFrameChildData (
+        D3DXFRAME*           pFrame,
+        LPD3DXFILESAVEOBJECT pXofSave,
+        LPD3DXFILESAVEDATA   pXofFrameData )
+
+    HRESULT AddMeshChildData (
+        D3DXMESHCONTAINER*   pMeshContainer,
+        LPD3DXFILESAVEOBJECT pXofSave,
+        LPD3DXFILESAVEDATA   pXofMeshData )
+    HRESULT AddTopLevelDataObjectsPre ( LPD3DXFILESAVEOBJECT pXofSave )
+    HRESULT AddTopLevelDataObjectsPost ( LPD3DXFILESAVEOBJECT pXofSave )
+    HRESULT RegisterTemplates ( LPD3DXFILE pXFileApi )
+    HRESULT SaveTemplates ( LPD3DXFILESAVEOBJECT pXofSave ) ;
+
+TYPEDEF: int D3DXCALLBACK_SEARCH_FLAGS
+CONSTANT: D3DXCALLBACK_SEARCH_EXCLUDING_INITIAL_POSITION 1
+CONSTANT: D3DXCALLBACK_SEARCH_BEHIND_INITIAL_POSITION    2
+CONSTANT: D3DXCALLBACK_SEARCH_FORCE_DWORD                HEX: 7fffffff
+
+C-TYPE: ID3DXAnimationSet
+TYPEDEF: ID3DXAnimationSet* LPD3DXANIMATIONSET
+
+COM-INTERFACE: ID3DXAnimationSet IUnknown {698CFB3F-9289-4d95-9A57-33A94B5A65F9}
+    LPCSTR GetName ( )
+    double GetPeriod ( )
+    double GetPeriodicPosition ( double Position )
+    UINT GetNumAnimations ( )
+    HRESULT GetAnimationNameByIndex ( UINT Index, LPCSTR* ppName )
+    HRESULT GetAnimationIndexByName ( LPCSTR pName, UINT* pIndex )
+    HRESULT GetSRT (
+        double          PeriodicPosition,
+        UINT            Animation,
+        D3DXVECTOR3*    pScale,
+        D3DXQUATERNION* pRotation,
+        D3DXVECTOR3*    pTranslation )
+    HRESULT GetCallback (
+        double  Position,
+        DWORD   Flags,
+        double* pCallbackPosition,
+        LPVOID* ppCallbackData ) ;
+
+TYPEDEF: int D3DXPLAYBACK_TYPE
+CONSTANT: D3DXPLAY_LOOP          0
+CONSTANT: D3DXPLAY_ONCE          1
+CONSTANT: D3DXPLAY_PINGPONG      2
+CONSTANT: D3DXPLAY_FORCE_DWORD   HEX: 7fffffff
+
+STRUCT: D3DXKEY_VECTOR3
+    { Time  FLOAT       }
+    { Value D3DXVECTOR3 } ;
+TYPEDEF: D3DXKEY_VECTOR3* LPD3DXKEY_VECTOR3
+
+STRUCT: D3DXKEY_QUATERNION
+    { Time  FLOAT          }
+    { Value D3DXQUATERNION } ;
+TYPEDEF: D3DXKEY_QUATERNION* LPD3DXKEY_QUATERNION
+
+STRUCT: D3DXKEY_CALLBACK
+    { Time          FLOAT  }
+    { pCallbackData LPVOID } ;
+TYPEDEF: D3DXKEY_CALLBACK* LPD3DXKEY_CALLBACK
+
+TYPEDEF: int D3DXCOMPRESSION_FLAGS
+CONSTANT: D3DXCOMPRESS_DEFAULT 0
+CONSTANT: D3DXCOMPRESS_FORCE_DWORD HEX: 7fffffff
+
+C-TYPE: ID3DXKeyframedAnimationSet
+TYPEDEF: ID3DXKeyframedAnimationSet* LPD3DXKEYFRAMEDANIMATIONSET
+
+COM-INTERFACE: ID3DXKeyframedAnimationSet ID3DXAnimationSet {FA4E8E3A-9786-407d-8B4C-5995893764AF}
+    D3DXPLAYBACK_TYPE GetPlaybackType ( )
+    double GetSourceTicksPerSecond ( )
+    UINT GetNumScaleKeys ( UINT Animation )
+    HRESULT GetScaleKeys ( UINT Animation, LPD3DXKEY_VECTOR3 pScaleKeys )
+    HRESULT GetScaleKey ( UINT Animation, UINT Key, LPD3DXKEY_VECTOR3 pScaleKey )
+    HRESULT SetScaleKey ( UINT Animation, UINT Key, LPD3DXKEY_VECTOR3 pScaleKey )
+    UINT GetNumRotationKeys ( UINT Animation )
+    HRESULT GetRotationKeys ( UINT Animation, LPD3DXKEY_QUATERNION pRotationKeys )
+    HRESULT GetRotationKey ( UINT Animation, UINT Key, LPD3DXKEY_QUATERNION pRotationKey )
+    HRESULT SetRotationKey ( UINT Animation, UINT Key, LPD3DXKEY_QUATERNION pRotationKey )
+    UINT GetNumTranslationKeys ( UINT Animation )
+    HRESULT GetTranslationKeys ( UINT Animation, LPD3DXKEY_VECTOR3 pTranslationKeys )
+    HRESULT GetTranslationKey ( UINT Animation, UINT Key, LPD3DXKEY_VECTOR3 pTranslationKey )
+    HRESULT SetTranslationKey ( UINT Animation, UINT Key, LPD3DXKEY_VECTOR3 pTranslationKey )
+    UINT GetNumCallbackKeys ( )
+    HRESULT GetCallbackKeys ( LPD3DXKEY_CALLBACK pCallbackKeys )
+    HRESULT GetCallbackKey ( UINT Key, LPD3DXKEY_CALLBACK pCallbackKey )
+    HRESULT SetCallbackKey ( UINT Key, LPD3DXKEY_CALLBACK pCallbackKey )
+    HRESULT UnregisterScaleKey ( UINT Animation, UINT Key )
+    HRESULT UnregisterRotationKey ( UINT Animation, UINT Key )
+    HRESULT UnregisterTranslationKey ( UINT Animation, UINT Key )
+    HRESULT RegisterAnimationSRTKeys (
+        LPCSTR              pName,
+        UINT                NumScaleKeys,
+        UINT                NumRotationKeys,
+        UINT                NumTranslationKeys,
+        D3DXKEY_VECTOR3*    pScaleKeys,
+        D3DXKEY_QUATERNION* pRotationKeys,
+        D3DXKEY_VECTOR3*    pTranslationKeys,
+        DWORD*              pAnimationIndex )
+    HRESULT Compress (
+        DWORD         Flags,
+        FLOAT         Lossiness,
+        LPD3DXFRAME   pHierarchy,
+        LPD3DXBUFFER* ppCompressedData )
+    HRESULT UnregisterAnimation ( UINT Index ) ;
+
+C-TYPE: ID3DXCompressedAnimationSet
+TYPEDEF: ID3DXCompressedAnimationSet* LPD3DXCOMPRESSEDANIMATIONSET
+
+COM-INTERFACE: ID3DXCompressedAnimationSet ID3DXAnimationSet {6CC2480D-3808-4739-9F88-DE49FACD8D4C}
+    D3DXPLAYBACK_TYPE GetPlaybackType ( )
+    double GetSourceTicksPerSecond ( )
+    HRESULT GetCompressedData ( LPD3DXBUFFER* ppCompressedData )
+    UINT GetNumCallbackKeys ( )
+    HRESULT GetCallbackKeys ( LPD3DXKEY_CALLBACK pCallbackKeys ) ;
+
+TYPEDEF: int D3DXPRIORITY_TYPE
+CONSTANT: D3DXPRIORITY_LOW         0
+CONSTANT: D3DXPRIORITY_HIGH        1
+CONSTANT: D3DXPRIORITY_FORCE_DWORD HEX: 7fffffff
+
+STRUCT: D3DXTRACK_DESC
+    { Priority              D3DXPRIORITY_TYPE }
+    { Weight                FLOAT             }
+    { Speed                 FLOAT             }
+    { Position              double            }
+    { Enable                BOOL              } ;
+TYPEDEF: D3DXTRACK_DESC* LPD3DXTRACK_DESC
+
+TYPEDEF: int D3DXEVENT_TYPE
+CONSTANT: D3DXEVENT_TRACKSPEED    0
+CONSTANT: D3DXEVENT_TRACKWEIGHT   1
+CONSTANT: D3DXEVENT_TRACKPOSITION 2
+CONSTANT: D3DXEVENT_TRACKENABLE   3
+CONSTANT: D3DXEVENT_PRIORITYBLEND 4
+CONSTANT: D3DXEVENT_FORCE_DWORD   HEX: 7fffffff
+
+TYPEDEF: int D3DXTRANSITION_TYPE
+CONSTANT: D3DXTRANSITION_LINEAR        0
+CONSTANT: D3DXTRANSITION_EASEINEASEOUT 1
+CONSTANT: D3DXTRANSITION_FORCE_DWORD   HEX: 7fffffff
+
+UNION-STRUCT: D3DXEVENT_DESC_UNION
+    { Weight            FLOAT  }
+    { Speed             FLOAT  }
+    { Position          double }
+    { Enable            BOOL   } ;
+STRUCT: D3DXEVENT_DESC
+    { Type                   D3DXEVENT_TYPE       }
+    { Track                  UINT                 }
+    { StartTime              double               }
+    { Duration               double               }
+    { Transition             D3DXTRANSITION_TYPE  }
+    { Union                  D3DXEVENT_DESC_UNION } ;
+TYPEDEF: D3DXEVENT_DESC* LPD3DXEVENT_DESC
+
+TYPEDEF: DWORD D3DXEVENTHANDLE
+TYPEDEF: D3DXEVENTHANDLE* LPD3DXEVENTHANDLE
+
+C-TYPE: ID3DXAnimationCallbackHandler
+TYPEDEF: ID3DXAnimationCallbackHandler* LPD3DXANIMATIONCALLBACKHANDLER
+
+COM-INTERFACE: ID3DXAnimationCallbackHandler f {00000000-0000-0000-0000-000000000000}
+    HRESULT HandleCallback ( UINT Track, LPVOID pCallbackData ) ;
+
+C-TYPE: ID3DXAnimationController
+TYPEDEF: ID3DXAnimationController* LPD3DXANIMATIONCONTROLLER
+
+COM-INTERFACE: ID3DXAnimationController IUnknown {AC8948EC-F86D-43e2-96DE-31FC35F96D9E}
+    UINT GetMaxNumAnimationOutputs ( )
+    UINT GetMaxNumAnimationSets ( )
+    UINT GetMaxNumTracks ( )
+    UINT GetMaxNumEvents ( )
+    HRESULT RegisterAnimationOutput (
+        LPCSTR          pName,
+        D3DXMATRIX*     pMatrix,
+        D3DXVECTOR3*    pScale,
+        D3DXQUATERNION* pRotation,
+        D3DXVECTOR3*    pTranslation )
+    HRESULT RegisterAnimationSet ( LPD3DXANIMATIONSET pAnimSet )
+    HRESULT UnregisterAnimationSet ( LPD3DXANIMATIONSET pAnimSet )
+    UINT GetNumAnimationSets ( )
+    HRESULT GetAnimationSet ( UINT Index, LPD3DXANIMATIONSET* ppAnimationSet )
+    HRESULT GetAnimationSetByName ( LPCSTR szName, LPD3DXANIMATIONSET* ppAnimationSet )
+    HRESULT AdvanceTime ( double TimeDelta, LPD3DXANIMATIONCALLBACKHANDLER pCallbackHandler )
+    HRESULT ResetTime ( )
+    double GetTime ( )
+    HRESULT SetTrackAnimationSet ( UINT Track, LPD3DXANIMATIONSET pAnimSet )
+    HRESULT GetTrackAnimationSet ( UINT Track, LPD3DXANIMATIONSET* ppAnimSet )
+    HRESULT SetTrackPriority ( UINT Track, D3DXPRIORITY_TYPE Priority )
+    HRESULT SetTrackSpeed ( UINT Track, FLOAT Speed )
+    HRESULT SetTrackWeight ( UINT Track, FLOAT Weight )
+    HRESULT SetTrackPosition ( UINT Track, double Position )
+    HRESULT SetTrackEnable ( UINT Track, BOOL Enable )
+    HRESULT SetTrackDesc ( UINT Track, LPD3DXTRACK_DESC pDesc )
+    HRESULT GetTrackDesc ( UINT Track, LPD3DXTRACK_DESC pDesc )
+    HRESULT SetPriorityBlend ( FLOAT BlendWeight )
+    FLOAT GetPriorityBlend ( )
+    D3DXEVENTHANDLE KeyTrackSpeed ( UINT Track, FLOAT NewSpeed, double StartTime, double Duration, D3DXTRANSITION_TYPE Transition )
+    D3DXEVENTHANDLE KeyTrackWeight ( UINT Track, FLOAT NewWeight, double StartTime, double Duration, D3DXTRANSITION_TYPE Transition )
+    D3DXEVENTHANDLE KeyTrackPosition ( UINT Track, double NewPosition, double StartTime )
+    D3DXEVENTHANDLE KeyTrackEnable ( UINT Track, BOOL NewEnable, double StartTime )
+    D3DXEVENTHANDLE KeyPriorityBlend ( FLOAT NewBlendWeight, double StartTime, double Duration, D3DXTRANSITION_TYPE Transition )
+    HRESULT UnkeyEvent ( D3DXEVENTHANDLE hEvent )
+    HRESULT UnkeyAllTrackEvents ( UINT Track )
+    HRESULT UnkeyAllPriorityBlends ( )
+    D3DXEVENTHANDLE GetCurrentTrackEvent ( UINT Track, D3DXEVENT_TYPE EventType )
+    D3DXEVENTHANDLE GetCurrentPriorityBlend ( )
+    D3DXEVENTHANDLE GetUpcomingTrackEvent ( UINT Track, D3DXEVENTHANDLE hEvent )
+    D3DXEVENTHANDLE GetUpcomingPriorityBlend ( D3DXEVENTHANDLE hEvent )
+    HRESULT ValidateEvent ( D3DXEVENTHANDLE hEvent )
+    HRESULT GetEventDesc ( D3DXEVENTHANDLE hEvent, LPD3DXEVENT_DESC pDesc )
+    HRESULT CloneAnimationController (
+        UINT                       MaxNumAnimationOutputs,
+        UINT                       MaxNumAnimationSets,
+        UINT                       MaxNumTracks,
+        UINT                       MaxNumEvents,
+        LPD3DXANIMATIONCONTROLLER* ppAnimController ) ;
+
+FUNCTION: HRESULT
+D3DXLoadMeshHierarchyFromXA
+    (
+    LPCSTR                     Filename,
+    DWORD                      MeshOptions,
+    LPDIRECT3DDEVICE9          pD3DDevice,
+    LPD3DXALLOCATEHIERARCHY    pAlloc,
+    LPD3DXLOADUSERDATA         pUserDataLoader,
+    LPD3DXFRAME*               ppFrameHierarchy,
+    LPD3DXANIMATIONCONTROLLER* ppAnimController
+    ) ;
+
+FUNCTION: HRESULT
+D3DXLoadMeshHierarchyFromXW
+    (
+    LPCWSTR                    Filename,
+    DWORD                      MeshOptions,
+    LPDIRECT3DDEVICE9          pD3DDevice,
+    LPD3DXALLOCATEHIERARCHY    pAlloc,
+    LPD3DXLOADUSERDATA         pUserDataLoader,
+    LPD3DXFRAME*               ppFrameHierarchy,
+    LPD3DXANIMATIONCONTROLLER* ppAnimController
+    ) ;
+
+ALIAS: D3DXLoadMeshHierarchyFromX D3DXLoadMeshHierarchyFromXW
+
+FUNCTION: HRESULT
+D3DXLoadMeshHierarchyFromXInMemory
+    (
+    LPCVOID                    Memory,
+    DWORD                      SizeOfMemory,
+    DWORD                      MeshOptions,
+    LPDIRECT3DDEVICE9          pD3DDevice,
+    LPD3DXALLOCATEHIERARCHY    pAlloc,
+    LPD3DXLOADUSERDATA         pUserDataLoader,
+    LPD3DXFRAME*               ppFrameHierarchy,
+    LPD3DXANIMATIONCONTROLLER* ppAnimController
+    ) ;
+
+FUNCTION: HRESULT
+D3DXSaveMeshHierarchyToFileA
+    (
+    LPCSTR                    Filename,
+    DWORD                     XFormat,
+    D3DXFRAME*                pFrameRoot,
+    LPD3DXANIMATIONCONTROLLER pAnimcontroller,
+    LPD3DXSAVEUSERDATA        pUserDataSaver
+    ) ;
+
+FUNCTION: HRESULT
+D3DXSaveMeshHierarchyToFileW
+    (
+    LPCWSTR                   Filename,
+    DWORD                     XFormat,
+    D3DXFRAME*                pFrameRoot,
+    LPD3DXANIMATIONCONTROLLER pAnimController,
+    LPD3DXSAVEUSERDATA        pUserDataSaver
+    ) ;
+
+ALIAS: D3DXSaveMeshHierarchyToFile D3DXSaveMeshHierarchyToFileW
+
+FUNCTION: HRESULT
+D3DXFrameDestroy
+    (
+    LPD3DXFRAME             pFrameRoot,
+    LPD3DXALLOCATEHIERARCHY pAlloc
+    ) ;
+
+FUNCTION: HRESULT
+D3DXFrameAppendChild
+    (
+    LPD3DXFRAME pFrameParent,
+    D3DXFRAME*  pFrameChild
+    ) ;
+
+FUNCTION: LPD3DXFRAME
+D3DXFrameFind
+    (
+    D3DXFRAME* pFrameRoot,
+    LPCSTR     Name
+    ) ;
+
+FUNCTION: HRESULT
+D3DXFrameRegisterNamedMatrices
+    (
+    LPD3DXFRAME               pFrameRoot,
+    LPD3DXANIMATIONCONTROLLER pAnimController
+    ) ;
+        
+FUNCTION: UINT
+D3DXFrameNumNamedMatrices
+    (
+    D3DXFRAME* pFrameRoot
+    ) ;
+        
+FUNCTION: HRESULT
+D3DXFrameCalculateBoundingSphere
+    (
+    D3DXFRAME*    pFrameRoot,
+    LPD3DXVECTOR3 pObjectCenter,
+    FLOAT*        pObjectRadius
+    ) ;
+
+FUNCTION: HRESULT
+D3DXCreateKeyframedAnimationSet
+    (
+    LPCSTR                       pName,
+    double                       TicksPerSecond,
+    D3DXPLAYBACK_TYPE            Playback,
+    UINT                         NumAnimations,
+    UINT                         NumCallbackKeys,
+    D3DXKEY_CALLBACK*            pCallbackKeys,
+    LPD3DXKEYFRAMEDANIMATIONSET* ppAnimationSet
+    ) ;
+
+FUNCTION: HRESULT
+D3DXCreateCompressedAnimationSet
+    (
+    LPCSTR                        pName,
+    double                        TicksPerSecond,
+    D3DXPLAYBACK_TYPE             Playback,
+    LPD3DXBUFFER                  pCompressedData,
+    UINT                          NumCallbackKeys,
+    D3DXKEY_CALLBACK*             pCallbackKeys,
+    LPD3DXCOMPRESSEDANIMATIONSET* ppAnimationSet
+    ) ;
+
+FUNCTION: HRESULT
+D3DXCreateAnimationController
+    (
+    UINT                       MaxNumMatrices,
+    UINT                       MaxNumAnimationSets,
+    UINT                       MaxNumTracks,
+    UINT                       MaxNumEvents,
+    LPD3DXANIMATIONCONTROLLER* ppAnimController
+    ) ;
diff --git a/basis/windows/directx/d3dx9anim/summary.txt b/basis/windows/directx/d3dx9anim/summary.txt
new file mode 100644 (file)
index 0000000..ef56df2
--- /dev/null
@@ -0,0 +1 @@
+DirectX 9 bindings. Corresponds to d3dx9anim.h.
diff --git a/basis/windows/directx/d3dx9anim/tags.txt b/basis/windows/directx/d3dx9anim/tags.txt
new file mode 100644 (file)
index 0000000..2320bdd
--- /dev/null
@@ -0,0 +1,2 @@
+unportable
+bindings
diff --git a/basis/windows/directx/d3dx9core/authors.txt b/basis/windows/directx/d3dx9core/authors.txt
new file mode 100644 (file)
index 0000000..6f03a12
--- /dev/null
@@ -0,0 +1 @@
+Erik Charlebois
diff --git a/basis/windows/directx/d3dx9core/d3dx9core.factor b/basis/windows/directx/d3dx9core/d3dx9core.factor
new file mode 100644 (file)
index 0000000..f963b03
--- /dev/null
@@ -0,0 +1,238 @@
+USING: alien.syntax windows.types windows.directx.d3d9 windows.com.syntax
+windows.com windows.directx.d3dx9math windows.directx.d3d9types classes.struct
+windows.gdi32 ;
+IN: windows.directx.d3dx9core
+
+LIBRARY: d3dx9
+
+CONSTANT: D3DX_VERSION HEX: 0902
+CONSTANT: D3DX_SDK_VERSION 42
+
+FUNCTION: BOOL D3DXCheckVersion ( UINT D3DSdkVersion, UINT D3DXSdkVersion ) ;
+FUNCTION: BOOL D3DXDebugMute ( BOOL Mute ) ;  
+FUNCTION: UINT D3DXGetDriverLevel ( LPDIRECT3DDEVICE9 pDevice ) ;
+
+C-TYPE: ID3DXBuffer
+TYPEDEF: ID3DXBuffer* LPD3DXBUFFER
+
+COM-INTERFACE: ID3DXBuffer IUnknown {8BA5FB08-5195-40e2-AC58-0D989C3A0102}
+    LPVOID GetBufferPointer ( )
+    DWORD GetBufferSize ( ) ;
+
+CONSTANT: D3DXSPRITE_DONOTSAVESTATE               1
+CONSTANT: D3DXSPRITE_DONOTMODIFY_RENDERSTATE      2
+CONSTANT: D3DXSPRITE_OBJECTSPACE                  4
+CONSTANT: D3DXSPRITE_BILLBOARD                    8
+CONSTANT: D3DXSPRITE_ALPHABLEND                   16
+CONSTANT: D3DXSPRITE_SORT_TEXTURE                 32
+CONSTANT: D3DXSPRITE_SORT_DEPTH_FRONTTOBACK       64
+CONSTANT: D3DXSPRITE_SORT_DEPTH_BACKTOFRONT       128
+CONSTANT: D3DXSPRITE_DO_NOT_ADDREF_TEXTURE        256
+
+C-TYPE: ID3DXSprite
+TYPEDEF: ID3DXSprite* LPD3DXSPRITE
+
+COM-INTERFACE: ID3DXSprite IUnknown {BA0B762D-7D28-43ec-B9DC-2F84443B0614}
+    HRESULT GetDevice ( LPDIRECT3DDEVICE9* ppDevice )
+    HRESULT GetTransform ( D3DXMATRIX* pTransform )
+    HRESULT SetTransform ( D3DXMATRIX* pTransform )
+    HRESULT SetWorldViewRH ( D3DXMATRIX* pWorld, D3DXMATRIX* pView )
+    HRESULT SetWorldViewLH ( D3DXMATRIX* pWorld, D3DXMATRIX* pView )
+    HRESULT Begin ( DWORD Flags )
+    HRESULT Draw ( LPDIRECT3DTEXTURE9 pTexture, RECT* pSrcRect, D3DXVECTOR3* pCenter, D3DXVECTOR3* pPosition, D3DCOLOR Color )
+    HRESULT Flush ( )
+    HRESULT End ( )
+    HRESULT OnLostDevice ( )
+    HRESULT OnResetDevice ( ) ;
+
+FUNCTION: HRESULT
+    D3DXCreateSprite ( 
+        LPDIRECT3DDEVICE9   pDevice, 
+        LPD3DXSPRITE*       ppSprite ) ;
+
+STRUCT: D3DXFONT_DESCA
+    { Height          INT               }
+    { Width           UINT              }
+    { Weight          UINT              }
+    { MipLevels       UINT              }
+    { Italic          BOOL              }
+    { CharSet         BYTE              }
+    { OutputPrecision BYTE              }
+    { Quality         BYTE              }
+    { PitchAndFamily  BYTE              }
+    { FaceName        CHAR[LF_FACESIZE] } ;
+TYPEDEF: D3DXFONT_DESCA* LPD3DXFONT_DESCA
+
+STRUCT: D3DXFONT_DESCW
+    { Height          INT                }
+    { Width           UINT               }
+    { Weight          UINT               }
+    { MipLevels       UINT               }
+    { Italic          BOOL               }
+    { CharSet         BYTE               }
+    { OutputPrecision BYTE               }
+    { Quality         BYTE               }
+    { PitchAndFamily  BYTE               }
+    { FaceName        WCHAR[LF_FACESIZE] } ;
+TYPEDEF: D3DXFONT_DESCW* LPD3DXFONT_DESCW
+
+TYPEDEF: D3DXFONT_DESCW D3DXFONT_DESC
+TYPEDEF: LPD3DXFONT_DESCW LPD3DXFONT_DESC
+
+C-TYPE: ID3DXFont
+TYPEDEF: ID3DXFont* LPD3DXFONT
+C-TYPE: TEXTMETRICA
+C-TYPE: TEXTMETRICW
+
+COM-INTERFACE: ID3DXFont IUnknown {D79DBB70-5F21-4d36-BBC2-FF525C213CDC}
+    HRESULT GetDevice ( LPDIRECT3DDEVICE9* ppDevice )
+    HRESULT GetDescA ( D3DXFONT_DESCA* pDesc )
+    HRESULT GetDescW ( D3DXFONT_DESCW* pDesc )
+    BOOL GetTextMetricsA ( TEXTMETRICA* pTextMetrics )
+    BOOL GetTextMetricsW ( TEXTMETRICW* pTextMetrics )
+    HDC GetDC ( )
+    HRESULT GetGlyphData ( UINT Glyph, LPDIRECT3DTEXTURE9* ppTexture, RECT* pBlackBox, POINT* pCellInc )
+    HRESULT PreloadCharacters ( UINT First, UINT Last )
+    HRESULT PreloadGlyphs ( UINT First, UINT Last )
+    HRESULT PreloadTextA ( LPCSTR pString, INT Count )
+    HRESULT PreloadTextW ( LPCWSTR pString, INT Count )
+    INT DrawTextA ( LPD3DXSPRITE pSprite, LPCSTR pString, INT Count, LPRECT pRect, DWORD Format, D3DCOLOR Color )
+    INT DrawTextW ( LPD3DXSPRITE pSprite, LPCWSTR pString, INT Count, LPRECT pRect, DWORD Format, D3DCOLOR Color )
+    HRESULT OnLostDevice ( )
+    HRESULT OnResetDevice ( ) ;
+
+FUNCTION: HRESULT
+    D3DXCreateFontA (
+        LPDIRECT3DDEVICE9       pDevice,  
+        INT                     Height,
+        UINT                    Width,
+        UINT                    Weight,
+        UINT                    MipLevels,
+        BOOL                    Italic,
+        DWORD                   CharSet,
+        DWORD                   OutputPrecision,
+        DWORD                   Quality,
+        DWORD                   PitchAndFamily,
+        LPCSTR                  pFaceName,
+        LPD3DXFONT*             ppFont ) ;
+
+FUNCTION: HRESULT
+    D3DXCreateFontW (
+        LPDIRECT3DDEVICE9       pDevice,  
+        INT                     Height,
+        UINT                    Width,
+        UINT                    Weight,
+        UINT                    MipLevels,
+        BOOL                    Italic,
+        DWORD                   CharSet,
+        DWORD                   OutputPrecision,
+        DWORD                   Quality,
+        DWORD                   PitchAndFamily,
+        LPCWSTR                 pFaceName,
+        LPD3DXFONT*             ppFont ) ;
+
+ALIAS: D3DXCreateFont D3DXCreateFontW
+
+FUNCTION: HRESULT
+    D3DXCreateFontIndirectA ( 
+        LPDIRECT3DDEVICE9       pDevice, 
+        D3DXFONT_DESCA*         pDesc,   
+        LPD3DXFONT*             ppFont ) ;
+
+FUNCTION: HRESULT
+    D3DXCreateFontIndirectW ( 
+        LPDIRECT3DDEVICE9       pDevice, 
+        D3DXFONT_DESCW*         pDesc,   
+        LPD3DXFONT*             ppFont ) ;
+
+ALIAS: D3DXCreateFontIndirect D3DXCreateFontIndirectW
+
+STRUCT: D3DXRTS_DESC
+    { Width                        UINT      }
+    { Height                       UINT      }
+    { Format                       D3DFORMAT }
+    { DepthStencil                 BOOL      }
+    { DepthStencilFormat           D3DFORMAT } ;
+TYPEDEF: D3DXRTS_DESC* LPD3DXRTS_DESC
+
+C-TYPE: ID3DXRenderToSurface
+TYPEDEF: ID3DXRenderToSurface* LPD3DXRENDERTOSURFACE
+
+COM-INTERFACE: ID3DXRenderToSurface IUnknown {6985F346-2C3D-43b3-BE8B-DAAE8A03D894}
+    HRESULT GetDevice ( LPDIRECT3DDEVICE9* ppDevice )
+    HRESULT GetDesc ( D3DXRTS_DESC* pDesc )
+    HRESULT BeginScene ( LPDIRECT3DSURFACE9 pSurface, D3DVIEWPORT9* pViewport )
+    HRESULT EndScene ( DWORD MipFilter )
+    HRESULT OnLostDevice ( )
+    HRESULT OnResetDevice ( ) ;
+
+FUNCTION: HRESULT
+    D3DXCreateRenderToSurface (
+        LPDIRECT3DDEVICE9       pDevice,
+        UINT                    Width,
+        UINT                    Height,
+        D3DFORMAT               Format,
+        BOOL                    DepthStencil,
+        D3DFORMAT               DepthStencilFormat,
+        LPD3DXRENDERTOSURFACE*  ppRenderToSurface ) ;
+
+STRUCT: D3DXRTE_DESC
+    { Size                 UINT      }
+    { MipLevels            UINT      }
+    { Format               D3DFORMAT }
+    { DepthStencil         BOOL      }
+    { DepthStencilFormat   D3DFORMAT } ;
+TYPEDEF: D3DXRTE_DESC* LPD3DXRTE_DESC
+
+C-TYPE: ID3DXRenderToEnvMap
+TYPEDEF: ID3DXRenderToEnvMap* LPD3DXRenderToEnvMap
+
+COM-INTERFACE: ID3DXRenderToEnvMap IUnknown {313F1B4B-C7B0-4fa2-9D9D-8D380B64385E}
+    HRESULT GetDevice ( LPDIRECT3DDEVICE9* ppDevice )
+    HRESULT GetDesc ( D3DXRTE_DESC* pDesc )
+    HRESULT BeginCube ( LPDIRECT3DCUBETEXTURE9 pCubeTex )
+    HRESULT BeginSphere ( LPDIRECT3DTEXTURE9 pTex )
+    HRESULT BeginHemisphere ( LPDIRECT3DTEXTURE9 pTexZPos, LPDIRECT3DTEXTURE9 pTexZNeg )
+    HRESULT BeginParabolic ( LPDIRECT3DTEXTURE9 pTexZPos, LPDIRECT3DTEXTURE9 pTexZNeg )
+    HRESULT Face ( D3DCUBEMAP_FACES Face, DWORD MipFilter )
+    HRESULT End ( DWORD MipFilter )
+    HRESULT OnLostDevice ( )
+    HRESULT OnResetDevice ( ) ;
+
+FUNCTION: HRESULT
+    D3DXCreateRenderToEnvMap (
+        LPDIRECT3DDEVICE9       pDevice,
+        UINT                    Size,
+        UINT                    MipLevels,
+        D3DFORMAT               Format,
+        BOOL                    DepthStencil,
+        D3DFORMAT               DepthStencilFormat,
+        LPD3DXRenderToEnvMap*   ppRenderToEnvMap ) ;
+
+C-TYPE: ID3DXLine
+TYPEDEF: ID3DXLine* LPD3DXLINE
+COM-INTERFACE: ID3DXLine IUnknown {D379BA7F-9042-4ac4-9F5E-58192A4C6BD8}
+    HRESULT GetDevice ( LPDIRECT3DDEVICE9* ppDevice )
+    HRESULT Begin ( )
+    HRESULT Draw ( D3DXVECTOR2* pVertexList, DWORD dwVertexListCount, D3DCOLOR Color )
+    HRESULT DrawTransform ( D3DXVECTOR3* pVertexList,
+        DWORD dwVertexListCount, D3DXMATRIX* pTransform, 
+        D3DCOLOR Color )
+    HRESULT SetPattern ( DWORD dwPattern )
+    DWORD GetPattern ( )
+    HRESULT SetPatternScale ( FLOAT fPatternScale )
+    FLOAT GetPatternScale ( )
+    HRESULT SetWidth ( FLOAT fWidth )
+    FLOAT GetWidth ( )
+    HRESULT SetAntialias ( BOOL bAntialias )
+    BOOL GetAntialias ( )
+    HRESULT SetGLLines ( BOOL bGLLines )
+    BOOL GetGLLines ( )
+    HRESULT End ( )
+    HRESULT OnLostDevice ( )
+    HRESULT OnResetDevice ( ) ;
+
+FUNCTION: HRESULT
+    D3DXCreateLine (
+        LPDIRECT3DDEVICE9   pDevice,
+        LPD3DXLINE*         ppLine ) ;
diff --git a/basis/windows/directx/d3dx9core/summary.txt b/basis/windows/directx/d3dx9core/summary.txt
new file mode 100644 (file)
index 0000000..c2c4bae
--- /dev/null
@@ -0,0 +1 @@
+DirectX 9 bindings. Corresponds to d3dx9core.h.
diff --git a/basis/windows/directx/d3dx9core/tags.txt b/basis/windows/directx/d3dx9core/tags.txt
new file mode 100644 (file)
index 0000000..2320bdd
--- /dev/null
@@ -0,0 +1,2 @@
+unportable
+bindings
diff --git a/basis/windows/directx/d3dx9effect/authors.txt b/basis/windows/directx/d3dx9effect/authors.txt
new file mode 100644 (file)
index 0000000..6f03a12
--- /dev/null
@@ -0,0 +1 @@
+Erik Charlebois
diff --git a/basis/windows/directx/d3dx9effect/d3dx9effect.factor b/basis/windows/directx/d3dx9effect/d3dx9effect.factor
new file mode 100644 (file)
index 0000000..e383336
--- /dev/null
@@ -0,0 +1,369 @@
+USING: alien.syntax classes.struct math windows.com
+windows.com.syntax windows.directx.d3d9
+windows.directx.d3d9types windows.directx.d3dx9core
+windows.directx.d3dx9math windows.directx.d3dx9shader
+windows.types ;
+IN: windows.directx.d3dx9effect
+
+LIBRARY: d3dx9
+
+CONSTANT: D3DXFX_DONOTSAVESTATE         1
+CONSTANT: D3DXFX_DONOTSAVESHADERSTATE   2
+CONSTANT: D3DXFX_DONOTSAVESAMPLERSTATE  4
+
+: D3DXFX_NOT_CLONEABLE     ( -- n ) 1 11 shift ; inline
+: D3DXFX_LARGEADDRESSAWARE ( -- n ) 1 17 shift ; inline
+
+CONSTANT: D3DX_PARAMETER_SHARED       1
+CONSTANT: D3DX_PARAMETER_LITERAL      2
+CONSTANT: D3DX_PARAMETER_ANNOTATION   4
+
+STRUCT: D3DXEFFECT_DESC
+    { Creator    LPCSTR }
+    { Parameters UINT   }
+    { Techniques UINT   }
+    { Functions  UINT   } ;
+
+STRUCT: D3DXPARAMETER_DESC
+    { Name          LPCSTR              }
+    { Semantic      LPCSTR              }
+    { Class         D3DXPARAMETER_CLASS }
+    { Type          D3DXPARAMETER_TYPE  }
+    { Rows          UINT                }
+    { Columns       UINT                }
+    { Elements      UINT                }
+    { Annotations   UINT                }
+    { StructMembers UINT                }
+    { Flags         DWORD               }
+    { Bytes         UINT                } ;
+
+STRUCT: D3DXTECHNIQUE_DESC
+    { Name        LPCSTR }
+    { Passes      UINT   }
+    { Annotations UINT   }  ;
+
+STRUCT: D3DXPASS_DESC
+    { Name                  LPCSTR }
+    { Annotations           UINT   }
+    { pVertexShaderFunction DWORD* }
+    { pPixelShaderFunction  DWORD* } ;
+
+STRUCT: D3DXFUNCTION_DESC
+    { Name        LPCSTR }
+    { Annotations UINT   } ;
+
+C-TYPE: ID3DXEffectPool
+TYPEDEF: ID3DXEffectPool* LPD3DXEFFECTPOOL
+
+COM-INTERFACE: ID3DXEffectPool IUnknown {9537AB04-3250-412e-8213-FCD2F8677933} ;
+
+C-TYPE: ID3DXBaseEffect
+TYPEDEF: ID3DXBaseEffect* LPD3DXBASEEFFECT
+
+COM-INTERFACE: ID3DXBaseEffect IUnknown {017C18AC-103F-4417-8C51-6BF6EF1E56BE}
+    HRESULT GetDesc ( D3DXEFFECT_DESC* pDesc )
+    HRESULT GetParameterDesc ( D3DXHANDLE hParameter, D3DXPARAMETER_DESC* pDesc )
+    HRESULT GetTechniqueDesc ( D3DXHANDLE hTechnique, D3DXTECHNIQUE_DESC* pDesc )
+    HRESULT GetPassDesc ( D3DXHANDLE hPass, D3DXPASS_DESC* pDesc )
+    HRESULT GetFunctionDesc ( D3DXHANDLE hShader, D3DXFUNCTION_DESC* pDesc )
+    D3DXHANDLE GetParameter ( D3DXHANDLE hParameter, UINT Index )
+    D3DXHANDLE GetParameterByName ( D3DXHANDLE hParameter, LPCSTR pName )
+    D3DXHANDLE GetParameterBySemantic ( D3DXHANDLE hParameter, LPCSTR pSemantic )
+    D3DXHANDLE GetParameterElement ( D3DXHANDLE hParameter, UINT Index )
+    D3DXHANDLE GetTechnique ( UINT Index )
+    D3DXHANDLE GetTechniqueByName ( LPCSTR pName )
+    D3DXHANDLE GetPass ( D3DXHANDLE hTechnique, UINT Index )
+    D3DXHANDLE GetPassByName ( D3DXHANDLE hTechnique, LPCSTR pName )
+    D3DXHANDLE GetFunction ( UINT Index )
+    D3DXHANDLE GetFunctionByName ( LPCSTR pName )
+    D3DXHANDLE GetAnnotation ( D3DXHANDLE hObject, UINT Index )
+    D3DXHANDLE GetAnnotationByName ( D3DXHANDLE hObject, LPCSTR pName )
+    HRESULT SetValue ( D3DXHANDLE hParameter, LPCVOID pData, UINT Bytes )
+    HRESULT GetValue ( D3DXHANDLE hParameter, LPVOID pData, UINT Bytes )
+    HRESULT SetBool ( D3DXHANDLE hParameter, BOOL b )
+    HRESULT GetBool ( D3DXHANDLE hParameter, BOOL* pb )
+    HRESULT SetBoolArray ( D3DXHANDLE hParameter, BOOL* pb, UINT Count )
+    HRESULT GetBoolArray ( D3DXHANDLE hParameter, BOOL* pb, UINT Count )
+    HRESULT SetInt ( D3DXHANDLE hParameter, INT n )
+    HRESULT GetInt ( D3DXHANDLE hParameter, INT* pn )
+    HRESULT SetIntArray ( D3DXHANDLE hParameter, INT* pn, UINT Count )
+    HRESULT GetIntArray ( D3DXHANDLE hParameter, INT* pn, UINT Count )
+    HRESULT SetFloat ( D3DXHANDLE hParameter, FLOAT f )
+    HRESULT GetFloat ( D3DXHANDLE hParameter, FLOAT* pf )
+    HRESULT SetFloatArray ( D3DXHANDLE hParameter, FLOAT* pf, UINT Count )
+    HRESULT GetFloatArray ( D3DXHANDLE hParameter, FLOAT* pf, UINT Count )
+    HRESULT SetVector ( D3DXHANDLE hParameter, D3DXVECTOR4* pVector )
+    HRESULT GetVector ( D3DXHANDLE hParameter, D3DXVECTOR4* pVector )
+    HRESULT SetVectorArray ( D3DXHANDLE hParameter, D3DXVECTOR4* pVector, UINT Count )
+    HRESULT GetVectorArray ( D3DXHANDLE hParameter, D3DXVECTOR4* pVector, UINT Count )
+    HRESULT SetMatrix ( D3DXHANDLE hParameter, D3DXMATRIX* pMatrix )
+    HRESULT GetMatrix ( D3DXHANDLE hParameter, D3DXMATRIX* pMatrix )
+    HRESULT SetMatrixArray ( D3DXHANDLE hParameter, D3DXMATRIX* pMatrix, UINT Count )
+    HRESULT GetMatrixArray ( D3DXHANDLE hParameter, D3DXMATRIX* pMatrix, UINT Count )
+    HRESULT SetMatrixPointerArray ( D3DXHANDLE hParameter, D3DXMATRIX** ppMatrix, UINT Count )
+    HRESULT GetMatrixPointerArray ( D3DXHANDLE hParameter, D3DXMATRIX** ppMatrix, UINT Count )
+    HRESULT SetMatrixTranspose ( D3DXHANDLE hParameter, D3DXMATRIX* pMatrix )
+    HRESULT GetMatrixTranspose ( D3DXHANDLE hParameter, D3DXMATRIX* pMatrix )
+    HRESULT SetMatrixTransposeArray ( D3DXHANDLE hParameter, D3DXMATRIX* pMatrix, UINT Count )
+    HRESULT GetMatrixTransposeArray ( D3DXHANDLE hParameter, D3DXMATRIX* pMatrix, UINT Count )
+    HRESULT SetMatrixTransposePointerArray ( D3DXHANDLE hParameter, D3DXMATRIX** ppMatrix, UINT Count )
+    HRESULT GetMatrixTransposePointerArray ( D3DXHANDLE hParameter, D3DXMATRIX** ppMatrix, UINT Count )
+    HRESULT SetString ( D3DXHANDLE hParameter, LPCSTR pString )
+    HRESULT GetString ( D3DXHANDLE hParameter, LPCSTR* ppString )
+    HRESULT SetTexture ( D3DXHANDLE hParameter, LPDIRECT3DBASETEXTURE9 pTexture )
+    HRESULT GetTexture ( D3DXHANDLE hParameter, LPDIRECT3DBASETEXTURE9* ppTexture )
+    HRESULT GetPixelShader ( D3DXHANDLE hParameter, LPDIRECT3DPIXELSHADER9* ppPShader )
+    HRESULT GetVertexShader ( D3DXHANDLE hParameter, LPDIRECT3DVERTEXSHADER9* ppVShader )
+    HRESULT SetArrayRange ( D3DXHANDLE hParameter, UINT uStart, UINT uEnd ) ;
+
+C-TYPE: ID3DXEffectStateManager
+TYPEDEF: ID3DXEffectStateManager* LPD3DXEFFECTSTATEMANAGER
+
+COM-INTERFACE: ID3DXEffectStateManager IUnknown {79AAB587-6DBC-4fa7-82DE-37FA1781C5CE}
+    HRESULT SetTransform ( D3DTRANSFORMSTATETYPE State, D3DMATRIX* pMatrix )
+    HRESULT SetMaterial ( D3DMATERIAL9* pMaterial )
+    HRESULT SetLight ( DWORD Index, D3DLIGHT9* pLight )
+    HRESULT LightEnable ( DWORD Index, BOOL Enable )
+    HRESULT SetRenderState ( D3DRENDERSTATETYPE State, DWORD Value )
+    HRESULT SetTexture ( DWORD Stage, LPDIRECT3DBASETEXTURE9 pTexture )
+    HRESULT SetTextureStageState ( DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value )
+    HRESULT SetSamplerState ( DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD Value )
+    HRESULT SetNPatchMode ( FLOAT NumSegments )
+    HRESULT SetFVF ( DWORD FVF )
+    HRESULT SetVertexShader ( LPDIRECT3DVERTEXSHADER9 pShader )
+    HRESULT SetVertexShaderConstantF ( UINT RegisterIndex, FLOAT* pConstantData, UINT RegisterCount )
+    HRESULT SetVertexShaderConstantI ( UINT RegisterIndex, INT* pConstantData, UINT RegisterCount )
+    HRESULT SetVertexShaderConstantB ( UINT RegisterIndex, BOOL* pConstantData, UINT RegisterCount )
+    HRESULT SetPixelShader ( LPDIRECT3DPIXELSHADER9 pShader )
+    HRESULT SetPixelShaderConstantF ( UINT RegisterIndex, FLOAT* pConstantData, UINT RegisterCount )
+    HRESULT SetPixelShaderConstantI ( UINT RegisterIndex, INT* pConstantData, UINT RegisterCount )
+    HRESULT SetPixelShaderConstantB ( UINT RegisterIndex, BOOL* pConstantData, UINT RegisterCount ) ;
+
+C-TYPE: ID3DXEffect
+TYPEDEF: ID3DXEffect* LPD3DXEFFECT
+
+COM-INTERFACE: ID3DXEffect ID3DXBaseEffect {F6CEB4B3-4E4C-40dd-B883-8D8DE5EA0CD5}
+    HRESULT GetPool ( LPD3DXEFFECTPOOL* ppPool )
+    HRESULT SetTechnique ( D3DXHANDLE hTechnique )
+    D3DXHANDLE GetCurrentTechnique ( )
+    HRESULT ValidateTechnique ( D3DXHANDLE hTechnique )
+    HRESULT FindNextValidTechnique ( D3DXHANDLE hTechnique, D3DXHANDLE* pTechnique )
+    BOOL IsParameterUsed ( D3DXHANDLE hParameter, D3DXHANDLE hTechnique )
+    HRESULT Begin ( UINT* pPasses, DWORD Flags )
+    HRESULT BeginPass ( UINT Pass )
+    HRESULT CommitChanges ( )
+    HRESULT EndPass ( )
+    HRESULT End ( )
+    HRESULT GetDevice ( LPDIRECT3DDEVICE9* ppDevice )
+    HRESULT OnLostDevice ( )
+    HRESULT OnResetDevice ( )
+    HRESULT SetStateManager ( LPD3DXEFFECTSTATEMANAGER pManager )
+    HRESULT GetStateManager ( LPD3DXEFFECTSTATEMANAGER* ppManager )
+    HRESULT BeginParameterBlock ( )
+    D3DXHANDLE EndParameterBlock ( )
+    HRESULT ApplyParameterBlock ( D3DXHANDLE hParameterBlock )
+    HRESULT DeleteParameterBlock ( D3DXHANDLE hParameterBlock )
+    HRESULT CloneEffect ( LPDIRECT3DDEVICE9 pDevice, LPD3DXEFFECT* ppEffect )
+    HRESULT SetRawValue ( D3DXHANDLE hParameter, LPCVOID pData, UINT ByteOffset, UINT Bytes ) ;
+
+C-TYPE: ID3DXEffectCompiler
+TYPEDEF: ID3DXEffectCompiler* LPD3DXEFFECTCOMPILER
+
+COM-INTERFACE: ID3DXEffectCompiler ID3DXBaseEffect {51B8A949-1A31-47e6-BEA0-4B30DB53F1E0}
+    HRESULT SetLiteral ( D3DXHANDLE hParameter, BOOL Literal )
+    HRESULT GetLiteral ( D3DXHANDLE hParameter, BOOL* pLiteral )
+    HRESULT CompileEffect ( DWORD Flags, LPD3DXBUFFER* ppEffect, LPD3DXBUFFER* ppErrorMsgs )
+    HRESULT CompileShader ( D3DXHANDLE hFunction, LPCSTR pTarget, DWORD Flags,
+                            LPD3DXBUFFER* ppShader, LPD3DXBUFFER* ppErrorMsgs,
+                            LPD3DXCONSTANTTABLE* ppConstantTable ) ;
+
+FUNCTION: HRESULT
+    D3DXCreateEffectPool ( LPD3DXEFFECTPOOL* ppPool ) ;
+
+FUNCTION: HRESULT
+    D3DXCreateEffectFromFileA (
+        LPDIRECT3DDEVICE9               pDevice,
+        LPCSTR                          pSrcFile,
+        D3DXMACRO*                      pDefines,
+        LPD3DXINCLUDE                   pInclude,
+        DWORD                           Flags,
+        LPD3DXEFFECTPOOL                pPool,
+        LPD3DXEFFECT*                   ppEffect,
+        LPD3DXBUFFER*                   ppCompilationErrors ) ;
+
+FUNCTION: HRESULT
+    D3DXCreateEffectFromFileW (
+        LPDIRECT3DDEVICE9               pDevice,
+        LPCWSTR                         pSrcFile,
+        D3DXMACRO*                      pDefines,
+        LPD3DXINCLUDE                   pInclude,
+        DWORD                           Flags,
+        LPD3DXEFFECTPOOL                pPool,
+        LPD3DXEFFECT*                   ppEffect,
+        LPD3DXBUFFER*                   ppCompilationErrors ) ;
+
+ALIAS: D3DXCreateEffectFromFile D3DXCreateEffectFromFileW
+
+FUNCTION: HRESULT
+    D3DXCreateEffectFromResourceA (
+        LPDIRECT3DDEVICE9               pDevice,
+        HMODULE                         hSrcModule,
+        LPCSTR                          pSrcResource,
+        D3DXMACRO*                      pDefines,
+        LPD3DXINCLUDE                   pInclude,
+        DWORD                           Flags,
+        LPD3DXEFFECTPOOL                pPool,
+        LPD3DXEFFECT*                   ppEffect,
+        LPD3DXBUFFER*                   ppCompilationErrors ) ;
+
+FUNCTION: HRESULT
+    D3DXCreateEffectFromResourceW (
+        LPDIRECT3DDEVICE9               pDevice,
+        HMODULE                         hSrcModule,
+        LPCWSTR                         pSrcResource,
+        D3DXMACRO*                      pDefines,
+        LPD3DXINCLUDE                   pInclude,
+        DWORD                           Flags,
+        LPD3DXEFFECTPOOL                pPool,
+        LPD3DXEFFECT*                   ppEffect,
+        LPD3DXBUFFER*                   ppCompilationErrors ) ;
+
+ALIAS: D3DXCreateEffectFromResource D3DXCreateEffectFromResourceW
+
+FUNCTION: HRESULT
+    D3DXCreateEffect (
+        LPDIRECT3DDEVICE9               pDevice,
+        LPCVOID                         pSrcData,
+        UINT                            SrcDataLen,
+        D3DXMACRO*                      pDefines,
+        LPD3DXINCLUDE                   pInclude,
+        DWORD                           Flags,
+        LPD3DXEFFECTPOOL                pPool,
+        LPD3DXEFFECT*                   ppEffect,
+        LPD3DXBUFFER*                   ppCompilationErrors ) ;
+
+FUNCTION: HRESULT
+    D3DXCreateEffectFromFileExA (
+        LPDIRECT3DDEVICE9               pDevice,
+        LPCSTR                          pSrcFile,
+        D3DXMACRO*                      pDefines,
+        LPD3DXINCLUDE                   pInclude,
+        LPCSTR                          pSkipConstants, 
+        DWORD                           Flags,
+        LPD3DXEFFECTPOOL                pPool,
+        LPD3DXEFFECT*                   ppEffect,
+        LPD3DXBUFFER*                   ppCompilationErrors ) ;
+
+FUNCTION: HRESULT
+    D3DXCreateEffectFromFileExW (
+        LPDIRECT3DDEVICE9               pDevice,
+        LPCWSTR                         pSrcFile,
+        D3DXMACRO*                      pDefines,
+        LPD3DXINCLUDE                   pInclude,
+        LPCSTR                          pSkipConstants, 
+        DWORD                           Flags,
+        LPD3DXEFFECTPOOL                pPool,
+        LPD3DXEFFECT*                   ppEffect,
+        LPD3DXBUFFER*                   ppCompilationErrors ) ;
+
+ALIAS: D3DXCreateEffectFromFileEx D3DXCreateEffectFromFileExW
+
+FUNCTION: HRESULT
+    D3DXCreateEffectFromResourceExA (
+        LPDIRECT3DDEVICE9               pDevice,
+        HMODULE                         hSrcModule,
+        LPCSTR                          pSrcResource,
+        D3DXMACRO*                      pDefines,
+        LPD3DXINCLUDE                   pInclude,
+        LPCSTR                          pSkipConstants, 
+        DWORD                           Flags,
+        LPD3DXEFFECTPOOL                pPool,
+        LPD3DXEFFECT*                   ppEffect,
+        LPD3DXBUFFER*                   ppCompilationErrors ) ;
+
+FUNCTION: HRESULT
+    D3DXCreateEffectFromResourceExW (
+        LPDIRECT3DDEVICE9               pDevice,
+        HMODULE                         hSrcModule,
+        LPCWSTR                         pSrcResource,
+        D3DXMACRO*                      pDefines,
+        LPD3DXINCLUDE                   pInclude,
+        LPCSTR                          pSkipConstants, 
+        DWORD                           Flags,
+        LPD3DXEFFECTPOOL                pPool,
+        LPD3DXEFFECT*                   ppEffect,
+        LPD3DXBUFFER*                   ppCompilationErrors ) ;
+
+ALIAS: D3DXCreateEffectFromResourceEx D3DXCreateEffectFromResourceExW
+
+FUNCTION: HRESULT
+    D3DXCreateEffectEx (
+        LPDIRECT3DDEVICE9               pDevice,
+        LPCVOID                         pSrcData,
+        UINT                            SrcDataLen,
+        D3DXMACRO*                      pDefines,
+        LPD3DXINCLUDE                   pInclude,
+        LPCSTR                          pSkipConstants, 
+        DWORD                           Flags,
+        LPD3DXEFFECTPOOL                pPool,
+        LPD3DXEFFECT*                   ppEffect,
+        LPD3DXBUFFER*                   ppCompilationErrors ) ;
+
+FUNCTION: HRESULT
+    D3DXCreateEffectCompilerFromFileA (
+        LPCSTR                          pSrcFile,
+        D3DXMACRO*                      pDefines,
+        LPD3DXINCLUDE                   pInclude,
+        DWORD                           Flags,
+        LPD3DXEFFECTCOMPILER*           ppCompiler,
+        LPD3DXBUFFER*                   ppParseErrors ) ;
+
+FUNCTION: HRESULT
+    D3DXCreateEffectCompilerFromFileW (
+        LPCWSTR                         pSrcFile,
+        D3DXMACRO*                      pDefines,
+        LPD3DXINCLUDE                   pInclude,
+        DWORD                           Flags,
+        LPD3DXEFFECTCOMPILER*           ppCompiler,
+        LPD3DXBUFFER*                   ppParseErrors ) ;
+
+ALIAS: D3DXCreateEffectCompilerFromFile D3DXCreateEffectCompilerFromFileW
+
+FUNCTION: HRESULT
+    D3DXCreateEffectCompilerFromResourceA (
+        HMODULE                         hSrcModule,
+        LPCSTR                          pSrcResource,
+        D3DXMACRO*                      pDefines,
+        LPD3DXINCLUDE                   pInclude,
+        DWORD                           Flags,
+        LPD3DXEFFECTCOMPILER*           ppCompiler,
+        LPD3DXBUFFER*                   ppParseErrors ) ;
+
+FUNCTION: HRESULT
+    D3DXCreateEffectCompilerFromResourceW (
+        HMODULE                         hSrcModule,
+        LPCWSTR                         pSrcResource,
+        D3DXMACRO*                      pDefines,
+        LPD3DXINCLUDE                   pInclude,
+        DWORD                           Flags,
+        LPD3DXEFFECTCOMPILER*           ppCompiler,
+        LPD3DXBUFFER*                   ppParseErrors ) ;
+
+ALIAS: D3DXCreateEffectCompilerFromResource D3DXCreateEffectCompilerFromResourceW
+
+FUNCTION: HRESULT
+    D3DXCreateEffectCompiler (
+        LPCSTR                          pSrcData,
+        UINT                            SrcDataLen,
+        D3DXMACRO*                      pDefines,
+        LPD3DXINCLUDE                   pInclude,
+        DWORD                           Flags,
+        LPD3DXEFFECTCOMPILER*           ppCompiler,
+        LPD3DXBUFFER*                   ppParseErrors ) ;
+
+FUNCTION: HRESULT 
+    D3DXDisassembleEffect (
+        LPD3DXEFFECT pEffect, 
+        BOOL EnableColorCode, 
+        LPD3DXBUFFER* ppDisassembly ) ;
+        
diff --git a/basis/windows/directx/d3dx9effect/summary.txt b/basis/windows/directx/d3dx9effect/summary.txt
new file mode 100644 (file)
index 0000000..dc32407
--- /dev/null
@@ -0,0 +1 @@
+DirectX 9 bindings. Corresponds to d3dx9effect.h.
diff --git a/basis/windows/directx/d3dx9effect/tags.txt b/basis/windows/directx/d3dx9effect/tags.txt
new file mode 100644 (file)
index 0000000..2320bdd
--- /dev/null
@@ -0,0 +1,2 @@
+unportable
+bindings
diff --git a/basis/windows/directx/d3dx9math/authors.txt b/basis/windows/directx/d3dx9math/authors.txt
new file mode 100644 (file)
index 0000000..6f03a12
--- /dev/null
@@ -0,0 +1 @@
+Erik Charlebois
diff --git a/basis/windows/directx/d3dx9math/d3dx9math.factor b/basis/windows/directx/d3dx9math/d3dx9math.factor
new file mode 100644 (file)
index 0000000..6d37af5
--- /dev/null
@@ -0,0 +1,160 @@
+USING: math classes.struct windows.types alien.syntax windows.directx.d3d9types
+windows.com.syntax windows.com windows.directx.d3d9 ;
+IN: windows.directx.d3dx9math
+
+LIBRARY: d3dx9
+
+CONSTANT: D3DX_PI    3.141592654
+CONSTANT: D3DX_1BYPI 0.318309886
+
+: D3DXToRadian ( degree -- radian ) D3DX_PI 180.0 / * ; inline
+: D3DXToDegree ( radian -- degree ) 180.0 D3DX_PI / * ; inline
+
+CONSTANT: D3DX_16F_DIG          3
+CONSTANT: D3DX_16F_EPSILON      4.8875809e-4
+CONSTANT: D3DX_16F_MANT_DIG     11
+CONSTANT: D3DX_16F_MAX          6.550400e+004
+CONSTANT: D3DX_16F_MAX_10_EXP   4
+CONSTANT: D3DX_16F_MAX_EXP      15
+CONSTANT: D3DX_16F_MIN          6.1035156e-5
+CONSTANT: D3DX_16F_MIN_10_EXP   -4
+CONSTANT: D3DX_16F_MIN_EXP      -14
+CONSTANT: D3DX_16F_RADIX        2
+CONSTANT: D3DX_16F_ROUNDS       1
+
+STRUCT: D3DXFLOAT16
+    { value WORD } ;
+TYPEDEF: D3DXFLOAT16* LPD3DXFLOAT16
+
+STRUCT: D3DXVECTOR2
+    { x FLOAT }
+    { y FLOAT } ;
+TYPEDEF: D3DXVECTOR2* LPD3DXVECTOR2
+
+STRUCT: D3DXVECTOR2_16F
+    { x D3DXFLOAT16 }
+    { y D3DXFLOAT16 } ;
+TYPEDEF: D3DXVECTOR2_16F* LPD3DXVECTOR2_16F
+
+TYPEDEF: D3DVECTOR D3DXVECTOR3
+TYPEDEF: D3DXVECTOR3* LPD3DXVECTOR3
+
+STRUCT: D3DXVECTOR3_16F
+    { x D3DXFLOAT16 }
+    { y D3DXFLOAT16 }
+    { z D3DXFLOAT16 } ;
+TYPEDEF: D3DXVECTOR3_16F* LPD3DXVECTOR3_16F
+
+STRUCT: D3DXVECTOR4
+    { x FLOAT }
+    { y FLOAT }
+    { z FLOAT }
+    { w FLOAT } ;
+TYPEDEF: D3DXVECTOR4* LPD3DXVECTOR4
+
+STRUCT: D3DXVECTOR4_16F
+    { x D3DXFLOAT16 }
+    { y D3DXFLOAT16 }
+    { z D3DXFLOAT16 }
+    { w D3DXFLOAT16 } ;
+TYPEDEF: D3DXVECTOR4_16F* LPD3DXVECTOR4_16F
+
+TYPEDEF: D3DMATRIX D3DXMATRIX
+TYPEDEF: D3DXMATRIX* LPD3DXMATRIX
+TYPEDEF: D3DXMATRIX D3DXMATRIXA16
+TYPEDEF: D3DXMATRIXA16* LPD3DXMATRIXA16
+
+STRUCT: D3DXQUATERNION
+    { x FLOAT }
+    { y FLOAT }
+    { z FLOAT }
+    { w FLOAT } ;
+TYPEDEF: D3DXQUATERNION* LPD3DXQUATERNION
+
+STRUCT: D3DXPLANE
+    { a FLOAT }
+    { b FLOAT }
+    { c FLOAT }
+    { d FLOAT } ;
+TYPEDEF: D3DXPLANE* LPD3DXPLANE
+
+STRUCT: D3DXCOLOR
+    { r FLOAT }
+    { g FLOAT }
+    { b FLOAT }
+    { a FLOAT } ;
+TYPEDEF: D3DXCOLOR* LPD3DXCOLOR
+
+C-TYPE: ID3DXMatrixStack
+TYPEDEF: ID3DXMatrixStack* LPD3DXMATRIXSTACK
+
+COM-INTERFACE: ID3DXMatrixStack IUnknown {C7885BA7-F990-4fe7-922D-8515E477DD85}
+    HRESULT Pop ( )
+    HRESULT Push ( )
+    HRESULT LoadIdentity ( )
+    HRESULT LoadMatrix ( D3DXMATRIX* pM  )
+    HRESULT MultMatrix ( D3DXMATRIX* pM  )
+    HRESULT MultMatrixLocal ( D3DXMATRIX* pM  )
+    HRESULT RotateAxis ( D3DXVECTOR3* pV, FLOAT Angle )
+    HRESULT RotateAxisLocal ( D3DXVECTOR3* pV, FLOAT Angle )
+    HRESULT RotateYawPitchRoll ( FLOAT Yaw, FLOAT Pitch, FLOAT Roll )
+    HRESULT RotateYawPitchRollLocal ( FLOAT Yaw, FLOAT Pitch, FLOAT Roll )
+    HRESULT Scale ( FLOAT x, FLOAT y, FLOAT z )
+    HRESULT ScaleLocal ( FLOAT x, FLOAT y, FLOAT z )
+    HRESULT Translate ( FLOAT x, FLOAT y, FLOAT z  )
+    HRESULT TranslateLocal ( FLOAT x, FLOAT y, FLOAT z )
+    D3DXMATRIX* GetTop ( ) ;
+
+FUNCTION: HRESULT D3DXCreateMatrixStack (
+        DWORD               Flags,
+        LPD3DXMATRIXSTACK*  ppStack ) ;
+
+CONSTANT: D3DXSH_MINORDER 2
+CONSTANT: D3DXSH_MAXORDER 6
+
+FUNCTION: FLOAT* D3DXSHEvalDirection
+    ( FLOAT* Out, UINT Order, D3DXVECTOR3 *pDir ) ;
+
+FUNCTION: FLOAT* D3DXSHRotate
+    ( FLOAT* Out, UINT Order, D3DXMATRIX *pMatrix, FLOAT* In ) ;
+
+FUNCTION: FLOAT* D3DXSHRotateZ
+    ( FLOAT* Out, UINT Order, FLOAT Angle, FLOAT* In ) ;
+
+FUNCTION: FLOAT* D3DXSHAdd
+    ( FLOAT* Out, UINT Order, FLOAT* A, FLOAT* B ) ;
+
+FUNCTION: FLOAT* D3DXSHScale
+    ( FLOAT* Out, UINT Order, FLOAT* In, FLOAT Scale ) ;
+
+FUNCTION: FLOAT WINAPI ( UINT Order, FLOAT* A, FLOAT* B ) ;
+
+FUNCTION: FLOAT* D3DXSHMultiply2 ( FLOAT* Out, FLOAT* F, FLOAT* G ) ;
+FUNCTION: FLOAT* D3DXSHMultiply3 ( FLOAT* Out, FLOAT* F, FLOAT* G ) ;
+FUNCTION: FLOAT* D3DXSHMultiply4 ( FLOAT* Out, FLOAT* F, FLOAT* G ) ;
+FUNCTION: FLOAT* D3DXSHMultiply5 ( FLOAT* Out, FLOAT* F, FLOAT* G ) ;
+FUNCTION: FLOAT* D3DXSHMultiply6 ( FLOAT* Out, FLOAT* F, FLOAT* G ) ;
+
+FUNCTION: HRESULT D3DXSHEvalDirectionalLight
+    ( UINT Order, D3DXVECTOR3* pDir,
+      FLOAT RIntensity, FLOAT GIntensity, FLOAT BIntensity,
+      FLOAT* ROut, FLOAT* GOut, FLOAT* BOut ) ;
+
+FUNCTION: HRESULT D3DXSHEvalSphericalLight
+    ( UINT Order, D3DXVECTOR3* pPos, FLOAT Radius,
+      FLOAT RIntensity, FLOAT GIntensity, FLOAT BIntensity,
+      FLOAT* ROut, FLOAT* GOut, FLOAT* BOut ) ;
+
+FUNCTION: HRESULT D3DXSHEvalConeLight
+    ( UINT Order, D3DXVECTOR3* pDir, FLOAT Radius,
+      FLOAT RIntensity, FLOAT GIntensity, FLOAT BIntensity,
+      FLOAT* ROut, FLOAT* GOut, FLOAT* BOut ) ;
+
+FUNCTION: HRESULT D3DXSHEvalHemisphereLight
+    ( UINT Order, D3DXVECTOR3* pDir, D3DXCOLOR Top, D3DXCOLOR Bottom,
+      FLOAT* ROut, FLOAT* GOut, FLOAT* BOut ) ;
+
+FUNCTION: HRESULT D3DXSHProjectCubeMap
+    ( UINT uOrder, LPDIRECT3DCUBETEXTURE9 pCubeMap,
+      FLOAT* ROut, FLOAT* GOut, FLOAT* BOut ) ;
+
diff --git a/basis/windows/directx/d3dx9math/summary.txt b/basis/windows/directx/d3dx9math/summary.txt
new file mode 100644 (file)
index 0000000..06c58ba
--- /dev/null
@@ -0,0 +1 @@
+DirectX 9 bindings. Corresponds to d3dx9math.h.
diff --git a/basis/windows/directx/d3dx9math/tags.txt b/basis/windows/directx/d3dx9math/tags.txt
new file mode 100644 (file)
index 0000000..2320bdd
--- /dev/null
@@ -0,0 +1,2 @@
+unportable
+bindings
diff --git a/basis/windows/directx/d3dx9mesh/authors.txt b/basis/windows/directx/d3dx9mesh/authors.txt
new file mode 100644 (file)
index 0000000..6f03a12
--- /dev/null
@@ -0,0 +1 @@
+Erik Charlebois
diff --git a/basis/windows/directx/d3dx9mesh/d3dx9mesh.factor b/basis/windows/directx/d3dx9mesh/d3dx9mesh.factor
new file mode 100644 (file)
index 0000000..e4cb3dd
--- /dev/null
@@ -0,0 +1,1220 @@
+USING: alien.syntax alien.c-types windows.directx.d3d9types math
+classes.struct windows.types windows.com.syntax windows.com
+windows.directx.d3d9 windows.directx.d3dx9core windows.directx.d3dx9math
+windows.directx.d3dx9xof ;
+IN: windows.directx.d3dx9mesh
+
+LIBRARY: d3dx9
+
+TYPEDEF: int D3DXPATCHMESHTYPE
+CONSTANT: D3DXPATCHMESH_RECT   1
+CONSTANT: D3DXPATCHMESH_TRI    2
+CONSTANT: D3DXPATCHMESH_NPATCH 3
+CONSTANT: D3DXPATCHMESH_FORCE_DWORD HEX: 7fffffff
+
+TYPEDEF: int D3DXMESH
+CONSTANT: D3DXMESH_32BIT                  HEX: 001
+CONSTANT: D3DXMESH_DONOTCLIP              HEX: 002
+CONSTANT: D3DXMESH_POINTS                 HEX: 004
+CONSTANT: D3DXMESH_RTPATCHES              HEX: 008
+CONSTANT: D3DXMESH_NPATCHES               HEX: 4000
+CONSTANT: D3DXMESH_VB_SYSTEMMEM           HEX: 010
+CONSTANT: D3DXMESH_VB_MANAGED             HEX: 020
+CONSTANT: D3DXMESH_VB_WRITEONLY           HEX: 040
+CONSTANT: D3DXMESH_VB_DYNAMIC             HEX: 080
+CONSTANT: D3DXMESH_VB_SOFTWAREPROCESSING  HEX: 8000
+CONSTANT: D3DXMESH_IB_SYSTEMMEM           HEX: 100
+CONSTANT: D3DXMESH_IB_MANAGED             HEX: 200
+CONSTANT: D3DXMESH_IB_WRITEONLY           HEX: 400
+CONSTANT: D3DXMESH_IB_DYNAMIC             HEX: 800
+CONSTANT: D3DXMESH_IB_SOFTWAREPROCESSING  HEX: 10000
+CONSTANT: D3DXMESH_VB_SHARE               HEX: 1000
+CONSTANT: D3DXMESH_USEHWONLY              HEX: 2000
+CONSTANT: D3DXMESH_SYSTEMMEM              HEX: 110
+CONSTANT: D3DXMESH_MANAGED                HEX: 220
+CONSTANT: D3DXMESH_WRITEONLY              HEX: 440
+CONSTANT: D3DXMESH_DYNAMIC                HEX: 880
+CONSTANT: D3DXMESH_SOFTWAREPROCESSING     HEX: 18000
+
+TYPEDEF: int D3DXPATCHMESH
+CONSTANT: D3DXPATCHMESH_DEFAULT 0
+
+TYPEDEF: int D3DXMESHSIMP
+CONSTANT: D3DXMESHSIMP_VERTEX   1
+CONSTANT: D3DXMESHSIMP_FACE     2
+
+TYPEDEF: int D3DXCLEANTYPE
+CONSTANT: D3DXCLEAN_BACKFACING     1
+CONSTANT: D3DXCLEAN_BOWTIES        2
+CONSTANT: D3DXCLEAN_SKINNING       1
+CONSTANT: D3DXCLEAN_OPTIMIZATION   1
+CONSTANT: D3DXCLEAN_SIMPLIFICATION 3
+
+: MAX_FVF_DECL_SIZE ( -- n ) MAXD3DDECLLENGTH 1 + ; inline
+
+TYPEDEF: int D3DXTANGENT
+CONSTANT: D3DXTANGENT_WRAP_U                  HEX: 01
+CONSTANT: D3DXTANGENT_WRAP_V                  HEX: 02
+CONSTANT: D3DXTANGENT_WRAP_UV                 HEX: 03
+CONSTANT: D3DXTANGENT_DONT_NORMALIZE_PARTIALS HEX: 04
+CONSTANT: D3DXTANGENT_DONT_ORTHOGONALIZE      HEX: 08
+CONSTANT: D3DXTANGENT_ORTHOGONALIZE_FROM_V    HEX: 010
+CONSTANT: D3DXTANGENT_ORTHOGONALIZE_FROM_U    HEX: 020
+CONSTANT: D3DXTANGENT_WEIGHT_BY_AREA          HEX: 040
+CONSTANT: D3DXTANGENT_WEIGHT_EQUAL            HEX: 080
+CONSTANT: D3DXTANGENT_WIND_CW                 HEX: 0100
+CONSTANT: D3DXTANGENT_CALCULATE_NORMALS       HEX: 0200
+CONSTANT: D3DXTANGENT_GENERATE_IN_PLACE       HEX: 0400
+
+TYPEDEF: int D3DXIMT
+CONSTANT: D3DXIMT_WRAP_U  HEX: 01
+CONSTANT: D3DXIMT_WRAP_V  HEX: 02
+CONSTANT: D3DXIMT_WRAP_UV HEX: 03
+
+TYPEDEF: int D3DXUVATLAS
+CONSTANT: D3DXUVATLAS_DEFAULT               HEX: 00
+CONSTANT: D3DXUVATLAS_GEODESIC_FAST         HEX: 01
+CONSTANT: D3DXUVATLAS_GEODESIC_QUALITY      HEX: 02
+
+C-TYPE: ID3DXBaseMesh
+TYPEDEF: ID3DXBaseMesh* LPD3DXBASEMESH
+C-TYPE: ID3DXMesh
+TYPEDEF: ID3DXMesh* LPD3DXMESH
+C-TYPE: ID3DXPMesh
+TYPEDEF: ID3DXPMesh* LPD3DXPMESH
+C-TYPE: ID3DXSPMesh
+TYPEDEF: ID3DXSPMesh* LPD3DXSPMESH
+C-TYPE: ID3DXSkinInfo
+TYPEDEF: ID3DXSkinInfo* LPD3DXSKININFO
+C-TYPE: ID3DXPatchMesh
+TYPEDEF: ID3DXPatchMesh* LPD3DXPATCHMESH
+C-TYPE: ID3DXTextureGutterHelper
+TYPEDEF: ID3DXTextureGutterHelper* LPD3DXTEXTUREGUTTERHELPER
+C-TYPE: ID3DXPRTBuffer
+TYPEDEF: ID3DXPRTBuffer* LPD3DXPRTBUFFER
+
+STRUCT: D3DXATTRIBUTERANGE
+    { AttribId    DWORD }
+    { FaceStart   DWORD }
+    { FaceCount   DWORD }
+    { VertexStart DWORD }
+    { VertexCount DWORD } ;
+TYPEDEF: D3DXATTRIBUTERANGE* LPD3DXATTRIBUTERANGE
+
+STRUCT: D3DXMATERIAL
+    { MatD3D           D3DMATERIAL9 }
+    { pTextureFilename LPSTR        } ;
+TYPEDEF: D3DXMATERIAL* LPD3DXMATERIAL
+
+TYPEDEF: int D3DXEFFECTDEFAULTTYPE
+CONSTANT: D3DXEDT_STRING     HEX: 1
+CONSTANT: D3DXEDT_FLOATS     HEX: 2
+CONSTANT: D3DXEDT_DWORD      HEX: 3
+CONSTANT: D3DXEDT_FORCEDWORD HEX: 7fffffff
+
+STRUCT: D3DXEFFECTDEFAULT
+    { pParamName    LPSTR                 }
+    { Type          D3DXEFFECTDEFAULTTYPE }
+    { NumBytes      DWORD                 }
+    { pValue        LPVOID                } ;
+TYPEDEF: D3DXEFFECTDEFAULT* LPD3DXEFFECTDEFAULT
+
+STRUCT: D3DXEFFECTINSTANCE
+    { pEffectFilename               LPSTR               }
+    { NumDefaults                   DWORD               }
+    { pDefaults                     LPD3DXEFFECTDEFAULT } ;
+TYPEDEF: D3DXEFFECTINSTANCE* LPD3DXEFFECTINSTANCE
+
+STRUCT: D3DXATTRIBUTEWEIGHTS
+    { Position FLOAT    }
+    { Boundary FLOAT    }
+    { Normal   FLOAT    }
+    { Diffuse  FLOAT    }
+    { Specular FLOAT    }
+    { Texcoord FLOAT[8] }
+    { Tangent  FLOAT    }
+    { Binormal FLOAT    } ;
+TYPEDEF: D3DXATTRIBUTEWEIGHTS* LPD3DXATTRIBUTEWEIGHTS
+
+CONSTANT: D3DXWELDEPSILONS_WELDALL             HEX: 1
+CONSTANT: D3DXWELDEPSILONS_WELDPARTIALMATCHES  HEX: 2
+CONSTANT: D3DXWELDEPSILONS_DONOTREMOVEVERTICES HEX: 4
+CONSTANT: D3DXWELDEPSILONS_DONOTSPLIT          HEX: 8
+
+STRUCT: D3DXWELDEPSILONS
+    { Position     FLOAT    }
+    { BlendWeights FLOAT    }
+    { Normal       FLOAT    }
+    { PSize        FLOAT    }
+    { Specular     FLOAT    }
+    { Diffuse      FLOAT    }
+    { Texcoord     FLOAT[8] }
+    { Tangent      FLOAT    }
+    { Binormal     FLOAT    }
+    { TessFactor   FLOAT    } ;
+TYPEDEF: D3DXWELDEPSILONS* LPD3DXWELDEPSILONS
+
+COM-INTERFACE: ID3DXBaseMesh IUnknown {7ED943DD-52E8-40b5-A8D8-76685C406330}
+    HRESULT DrawSubset ( DWORD AttribId )
+    DWORD GetNumFaces ( )
+    DWORD GetNumVertices ( )
+    DWORD GetFVF ( )
+    HRESULT GetDeclaration ( D3DVERTEXELEMENT9* Declaration )
+    DWORD GetNumBytesPerVertex ( )
+    DWORD GetOptions ( )
+    HRESULT GetDevice ( LPDIRECT3DDEVICE9* ppDevice )
+    HRESULT CloneMeshFVF ( DWORD Options, DWORD FVF, LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXMESH* ppCloneMesh )
+    HRESULT CloneMesh ( DWORD Options, D3DVERTEXELEMENT9* pDeclaration, LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXMESH* ppCloneMesh )
+    HRESULT GetVertexBuffer ( LPDIRECT3DVERTEXBUFFER9* ppVB )
+    HRESULT GetIndexBuffer ( LPDIRECT3DINDEXBUFFER9* ppIB )
+    HRESULT LockVertexBuffer ( DWORD Flags, LPVOID* ppData )
+    HRESULT UnlockVertexBuffer ( )
+    HRESULT LockIndexBuffer ( DWORD Flags, LPVOID* ppData )
+    HRESULT UnlockIndexBuffer ( )
+    HRESULT GetAttributeTable ( D3DXATTRIBUTERANGE* pAttribTable, DWORD* pAttribTableSize )
+    HRESULT ConvertPointRepsToAdjacency ( DWORD* pPRep, DWORD* pAdjacency )
+    HRESULT ConvertAdjacencyToPointReps ( DWORD* pAdjacency, DWORD* pPRep )
+    HRESULT GenerateAdjacency ( FLOAT Epsilon, DWORD* pAdjacency )
+    HRESULT UpdateSemantics ( D3DVERTEXELEMENT9* Declaration ) ;
+
+C-TYPE: IStream
+
+COM-INTERFACE: ID3DXMesh ID3DXBaseMesh {4020E5C2-1403-4929-883F-E2E849FAC195}
+    HRESULT LockAttributeBuffer ( DWORD Flags, DWORD** ppData )
+    HRESULT UnlockAttributeBuffer ( )
+    HRESULT Optimize ( DWORD Flags, DWORD* pAdjacencyIn, DWORD* pAdjacencyOut,
+                       DWORD* pFaceRemap, LPD3DXBUFFER* ppVertexRemap,
+                       LPD3DXMESH* ppOptMesh )
+    HRESULT OptimizeInplace ( DWORD Flags, DWORD* pAdjacencyIn, DWORD* pAdjacencyOut,
+                              DWORD* pFaceRemap, LPD3DXBUFFER* ppVertexRemap )
+    HRESULT SetAttributeTable ( D3DXATTRIBUTERANGE* pAttribTable, DWORD cAttribTableSize ) ;
+
+COM-INTERFACE: ID3DXPMesh ID3DXBaseMesh {8875769A-D579-4088-AAEB-534D1AD84E96}
+    HRESULT ClonePMeshFVF ( DWORD Options,
+                            DWORD FVF, LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXPMESH* ppCloneMesh )
+    HRESULT ClonePMesh ( DWORD Options,
+                         D3DVERTEXELEMENT9* pDeclaration, LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXPMESH* ppCloneMesh )
+    HRESULT SetNumFaces ( DWORD Faces )
+    HRESULT SetNumVertices ( DWORD Vertices )
+    DWORD GetMaxFaces ( )
+    DWORD GetMinFaces ( )
+    DWORD GetMaxVertices ( )
+    DWORD GetMinVertices ( )
+    HRESULT Save ( IStream* pStream, D3DXMATERIAL* pMaterials, D3DXEFFECTINSTANCE* pEffectInstances, DWORD NumMaterials )
+    HRESULT Optimize ( DWORD Flags, DWORD* pAdjacencyOut,
+                       DWORD* pFaceRemap, LPD3DXBUFFER* ppVertexRemap,
+                       LPD3DXMESH* ppOptMesh )
+    HRESULT OptimizeBaseLOD ( DWORD Flags, DWORD* pFaceRemap )
+    HRESULT TrimByFaces ( DWORD NewFacesMin, DWORD NewFacesMax, DWORD* rgiFaceRemap, DWORD* rgiVertRemap )
+    HRESULT TrimByVertices ( DWORD NewVerticesMin, DWORD NewVerticesMax, DWORD* rgiFaceRemap, DWORD* rgiVertRemap )
+    HRESULT GetAdjacency ( DWORD* pAdjacency )
+    HRESULT GenerateVertexHistory ( DWORD* pVertexHistory ) ;
+
+COM-INTERFACE: ID3DXSPMesh IUnknown {667EA4C7-F1CD-4386-B523-7C0290B83CC5}
+    DWORD GetNumFaces ( )
+    DWORD GetNumVertices ( )
+    DWORD GetFVF ( )
+    HRESULT GetDeclaration ( D3DVERTEXELEMENT9* Declaration )
+    DWORD GetOptions ( )
+    HRESULT GetDevice ( LPDIRECT3DDEVICE9* ppDevice )
+    HRESULT CloneMeshFVF ( DWORD Options,
+                           DWORD FVF, LPDIRECT3DDEVICE9 pD3DDevice, DWORD* pAdjacencyOut, DWORD* pVertexRemapOut, LPD3DXMESH* ppCloneMesh )
+    HRESULT CloneMesh ( DWORD Options,
+                        D3DVERTEXELEMENT9* pDeclaration, LPDIRECT3DDEVICE9 pD3DDevice, DWORD* pAdjacencyOut, DWORD* pVertexRemapOut, LPD3DXMESH* ppCloneMesh )
+    HRESULT ClonePMeshFVF ( DWORD Options,
+                            DWORD FVF, LPDIRECT3DDEVICE9 pD3DDevice, DWORD* pVertexRemapOut, FLOAT* pErrorsByFace, LPD3DXPMESH* ppCloneMesh )
+    HRESULT ClonePMesh ( DWORD Options,
+                         D3DVERTEXELEMENT9* pDeclaration, LPDIRECT3DDEVICE9 pD3DDevice, DWORD* pVertexRemapOut, FLOAT* pErrorsbyFace, LPD3DXPMESH* ppCloneMesh )
+    HRESULT ReduceFaces ( DWORD Faces )
+    HRESULT ReduceVertices ( DWORD Vertices )
+    DWORD GetMaxFaces ( )
+    DWORD GetMaxVertices ( )
+    HRESULT GetVertexAttributeWeights ( LPD3DXATTRIBUTEWEIGHTS pVertexAttributeWeights )
+    HRESULT GetVertexWeights ( FLOAT* pVertexWeights ) ;
+
+CONSTANT: D3DXMESHOPT_COMPACT           HEX: 01000000
+CONSTANT: D3DXMESHOPT_ATTRSORT          HEX: 02000000
+CONSTANT: D3DXMESHOPT_VERTEXCACHE       HEX: 04000000
+CONSTANT: D3DXMESHOPT_STRIPREORDER      HEX: 08000000
+CONSTANT: D3DXMESHOPT_IGNOREVERTS       HEX: 10000000
+CONSTANT: D3DXMESHOPT_DONOTSPLIT        HEX: 20000000
+CONSTANT: D3DXMESHOPT_DEVICEINDEPENDENT HEX: 00400000
+
+STRUCT: D3DXBONECOMBINATION
+    { AttribId    DWORD  }
+    { FaceStart   DWORD  }
+    { FaceCount   DWORD  }
+    { VertexStart DWORD  }
+    { VertexCount DWORD  }
+    { BoneId      DWORD* } ;
+TYPEDEF: D3DXBONECOMBINATION* LPD3DXBONECOMBINATION
+
+STRUCT: D3DXPATCHINFO
+    { PatchType D3DXPATCHMESHTYPE }
+    { Degree    D3DDEGREETYPE     }
+    { Basis     D3DBASISTYPE      } ;
+TYPEDEF: D3DXPATCHINFO* LPD3DXPATCHINFO
+
+COM-INTERFACE: ID3DXPatchMesh IUnknown {3CE6CC22-DBF2-44f4-894D-F9C34A337139}
+    DWORD GetNumPatches ( )
+    DWORD GetNumVertices ( )
+    HRESULT GetDeclaration ( D3DVERTEXELEMENT9* Declaration )
+    DWORD GetControlVerticesPerPatch ( )
+    DWORD GetOptions ( )
+    HRESULT GetDevice ( LPDIRECT3DDEVICE9* ppDevice )
+    HRESULT GetPatchInfo ( LPD3DXPATCHINFO PatchInfo )
+    HRESULT GetVertexBuffer ( LPDIRECT3DVERTEXBUFFER9* ppVB )
+    HRESULT GetIndexBuffer ( LPDIRECT3DINDEXBUFFER9* ppIB )
+    HRESULT LockVertexBuffer ( DWORD flags, LPVOID* ppData )
+    HRESULT UnlockVertexBuffer ( )
+    HRESULT LockIndexBuffer ( DWORD flags, LPVOID* ppData )
+    HRESULT UnlockIndexBuffer ( )
+    HRESULT LockAttributeBuffer ( DWORD flags, DWORD** ppData )
+    HRESULT UnlockAttributeBuffer ( )
+    HRESULT GetTessSize ( FLOAT fTessLevel, DWORD Adaptive, DWORD* NumTriangles, DWORD* NumVertices )
+    HRESULT GenerateAdjacency ( FLOAT Tolerance )
+    HRESULT CloneMesh ( DWORD Options, D3DVERTEXELEMENT9* pDecl, LPD3DXPATCHMESH* pMesh )
+    HRESULT Optimize ( DWORD flags )
+    HRESULT SetDisplaceParam (
+        LPDIRECT3DBASETEXTURE9 Texture,
+        D3DTEXTUREFILTERTYPE   MinFilter,
+        D3DTEXTUREFILTERTYPE   MagFilter,
+        D3DTEXTUREFILTERTYPE   MipFilter,
+        D3DTEXTUREADDRESS      Wrap,
+        DWORD                  dwLODBias )
+    HRESULT GetDisplaceParam (
+        LPDIRECT3DBASETEXTURE9* Texture,
+        D3DTEXTUREFILTERTYPE*   MinFilter,
+        D3DTEXTUREFILTERTYPE*   MagFilter,
+        D3DTEXTUREFILTERTYPE*   MipFilter,
+        D3DTEXTUREADDRESS*      Wrap,
+        DWORD*                  dwLODBias )
+    HRESULT Tessellate ( FLOAT fTessLevel, LPD3DXMESH pMesh )
+    HRESULT TessellateAdaptive (
+        D3DXVECTOR4* pTrans,
+        DWORD        dwMaxTessLevel,
+        DWORD        dwMinTessLevel,
+        LPD3DXMESH   pMesh ) ;
+
+COM-INTERFACE: ID3DXSkinInfo IUnknown {11EAA540-F9A6-4d49-AE6A-E19221F70CC4}
+    HRESULT SetBoneInfluence ( DWORD bone, DWORD numInfluences, DWORD* vertices, FLOAT* weights )
+    HRESULT SetBoneVertexInfluence ( DWORD boneNum, DWORD influenceNum, FLOAT weight )
+    DWORD GetNumBoneInfluences ( DWORD bone )
+    HRESULT GetBoneInfluence ( DWORD bone, DWORD* vertices, FLOAT* weights )
+    HRESULT GetBoneVertexInfluence ( DWORD boneNum, DWORD influenceNum, FLOAT* pWeight, DWORD* pVertexNum )
+    HRESULT GetMaxVertexInfluences ( DWORD* maxVertexInfluences )
+    DWORD GetNumBones ( )
+    HRESULT FindBoneVertexInfluenceIndex ( DWORD boneNum, DWORD vertexNum, DWORD* pInfluenceIndex )
+    HRESULT GetMaxFaceInfluences ( LPDIRECT3DINDEXBUFFER9 pIB, DWORD NumFaces, DWORD* maxFaceInfluences )
+    HRESULT SetMinBoneInfluence ( FLOAT MinInfl )
+    FLOAT GetMinBoneInfluence ( )
+    HRESULT SetBoneName ( DWORD Bone, LPCSTR pName )
+    LPCSTR GetBoneName ( DWORD Bone )
+    HRESULT SetBoneOffsetMatrix ( DWORD Bone, D3DXMATRIX* pBoneTransform )
+    LPD3DXMATRIX GetBoneOffsetMatrix ( DWORD Bone )
+    HRESULT Clone ( LPD3DXSKININFO* ppSkinInfo )
+    HRESULT Remap ( DWORD NumVertices, DWORD* pVertexRemap )
+    HRESULT SetFVF ( DWORD FVF )
+    HRESULT SetDeclaration ( D3DVERTEXELEMENT9* pDeclaration )
+    DWORD GetFVF ( )
+    HRESULT GetDeclaration ( D3DVERTEXELEMENT9* Declaration )
+    HRESULT UpdateSkinnedMesh (
+        D3DXMATRIX* pBoneTransforms,
+        D3DXMATRIX* pBoneInvTransposeTransforms,
+        LPCVOID     pVerticesSrc,
+        PVOID       pVerticesDst )
+    HRESULT ConvertToBlendedMesh (
+        LPD3DXMESH    pMesh,
+        DWORD         Options,
+        DWORD*        pAdjacencyIn,
+        LPDWORD       pAdjacencyOut,
+        DWORD*        pFaceRemap,
+        LPD3DXBUFFER* ppVertexRemap,
+        DWORD*        pMaxFaceInfl,
+        DWORD*        pNumBoneCombinations,
+        LPD3DXBUFFER* ppBoneCombinationTable,
+        LPD3DXMESH*   ppMesh )
+    HRESULT ConvertToIndexedBlendedMesh (
+        LPD3DXMESH    pMesh,
+        DWORD         Options,
+        DWORD         paletteSize,
+        DWORD*        pAdjacencyIn,
+        LPDWORD       pAdjacencyOut,
+        DWORD*        pFaceRemap,
+        LPD3DXBUFFER* ppVertexRemap,
+        DWORD*        pMaxVertexInfl,
+        DWORD*        pNumBoneCombinations,
+        LPD3DXBUFFER* ppBoneCombinationTable,
+        LPD3DXMESH*   ppMesh ) ;
+
+FUNCTION: HRESULT
+    D3DXCreateMesh (
+        DWORD              NumFaces,
+        DWORD              NumVertices,
+        DWORD              Options,
+        D3DVERTEXELEMENT9* pDeclaration,
+        LPDIRECT3DDEVICE9  pD3DDevice,
+        LPD3DXMESH*        ppMesh ) ;
+
+FUNCTION: HRESULT
+    D3DXCreateMeshFVF (
+        DWORD             NumFaces,
+        DWORD             NumVertices,
+        DWORD             Options,
+        DWORD             FVF,
+        LPDIRECT3DDEVICE9 pD3DDevice,
+        LPD3DXMESH*       ppMesh ) ;
+
+FUNCTION: HRESULT
+    D3DXCreateSPMesh (
+        LPD3DXMESH            pMesh,
+        DWORD*                pAdjacency,
+        D3DXATTRIBUTEWEIGHTS* pVertexAttributeWeights,
+        FLOAT*                pVertexWeights,
+        LPD3DXSPMESH*         ppSMesh ) ;
+
+FUNCTION: HRESULT
+    D3DXCleanMesh (
+    D3DXCLEANTYPE CleanType,
+    LPD3DXMESH    pMeshIn,
+    DWORD*        pAdjacencyIn,
+    LPD3DXMESH*   ppMeshOut,
+    DWORD*        pAdjacencyOut,
+    LPD3DXBUFFER* ppErrorsAndWarnings ) ;
+
+FUNCTION: HRESULT
+    D3DXValidMesh (
+    LPD3DXMESH    pMeshIn,
+    DWORD*        pAdjacency,
+    LPD3DXBUFFER* ppErrorsAndWarnings ) ;
+
+FUNCTION: HRESULT
+    D3DXGeneratePMesh (
+        LPD3DXMESH            pMesh,
+        DWORD*                pAdjacency,
+        D3DXATTRIBUTEWEIGHTS* pVertexAttributeWeights,
+        FLOAT*                pVertexWeights,
+        DWORD                 MinValue,
+        DWORD                 Options,
+        LPD3DXPMESH*          ppPMesh ) ;
+
+FUNCTION: HRESULT
+    D3DXSimplifyMesh (
+        LPD3DXMESH            pMesh,
+        DWORD*                pAdjacency,
+        D3DXATTRIBUTEWEIGHTS* pVertexAttributeWeights,
+        FLOAT*                pVertexWeights,
+        DWORD                 MinValue,
+        DWORD                 Options,
+        LPD3DXMESH*           ppMesh ) ;
+
+FUNCTION: HRESULT
+    D3DXComputeBoundingSphere (
+        D3DXVECTOR3* pFirstPosition,
+        DWORD        NumVertices,
+        DWORD        dwStride,
+        D3DXVECTOR3* pCenter,
+        FLOAT*       pRadius ) ;
+
+FUNCTION: HRESULT
+    D3DXComputeBoundingBox (
+        D3DXVECTOR3* pFirstPosition,
+        DWORD        NumVertices,
+        DWORD        dwStride,
+        D3DXVECTOR3* pMin,
+        D3DXVECTOR3* pMax ) ;
+
+FUNCTION: HRESULT
+    D3DXComputeNormals (
+        LPD3DXBASEMESH pMesh,
+        DWORD*         pAdjacency ) ;
+
+FUNCTION: HRESULT
+    D3DXCreateBuffer (
+        DWORD         NumBytes,
+        LPD3DXBUFFER* ppBuffer ) ;
+
+FUNCTION: HRESULT
+    D3DXLoadMeshFromXA (
+        LPCSTR            pFilename,
+        DWORD             Options,
+        LPDIRECT3DDEVICE9 pD3DDevice,
+        LPD3DXBUFFER*     ppAdjacency,
+        LPD3DXBUFFER*     ppMaterials,
+        LPD3DXBUFFER*     ppEffectInstances,
+        DWORD*            pNumMaterials,
+        LPD3DXMESH*       ppMesh ) ;
+
+FUNCTION: HRESULT
+    D3DXLoadMeshFromXW (
+        LPCWSTR           pFilename,
+        DWORD             Options,
+        LPDIRECT3DDEVICE9 pD3DDevice,
+        LPD3DXBUFFER*     ppAdjacency,
+        LPD3DXBUFFER*     ppMaterials,
+        LPD3DXBUFFER*     ppEffectInstances,
+        DWORD*            pNumMaterials,
+        LPD3DXMESH*       ppMesh ) ;
+
+ALIAS: D3DXLoadMeshFromX D3DXLoadMeshFromXW
+
+FUNCTION: HRESULT
+    D3DXLoadMeshFromXInMemory (
+        LPCVOID           Memory,
+        DWORD             SizeOfMemory,
+        DWORD             Options,
+        LPDIRECT3DDEVICE9 pD3DDevice,
+        LPD3DXBUFFER*     ppAdjacency,
+        LPD3DXBUFFER*     ppMaterials,
+        LPD3DXBUFFER*     ppEffectInstances,
+        DWORD*            pNumMaterials,
+        LPD3DXMESH*       ppMesh ) ;
+
+FUNCTION: HRESULT
+    D3DXLoadMeshFromXResource (
+        HMODULE           Module,
+        LPCSTR            Name,
+        LPCSTR            Type,
+        DWORD             Options,
+        LPDIRECT3DDEVICE9 pD3DDevice,
+        LPD3DXBUFFER*     ppAdjacency,
+        LPD3DXBUFFER*     ppMaterials,
+        LPD3DXBUFFER*     ppEffectInstances,
+        DWORD*            pNumMaterials,
+        LPD3DXMESH*       ppMesh ) ;
+
+FUNCTION: HRESULT
+    D3DXSaveMeshToXA (
+        LPCSTR              pFilename,
+        LPD3DXMESH          pMesh,
+        DWORD*              pAdjacency,
+        D3DXMATERIAL*       pMaterials,
+        D3DXEFFECTINSTANCE* pEffectInstances,
+        DWORD               NumMaterials,
+        DWORD               Format ) ;
+
+FUNCTION: HRESULT
+    D3DXSaveMeshToXW (
+        LPCWSTR             pFilename,
+        LPD3DXMESH          pMesh,
+        DWORD*              pAdjacency,
+        D3DXMATERIAL*       pMaterials,
+        D3DXEFFECTINSTANCE* pEffectInstances,
+        DWORD               NumMaterials,
+        DWORD               Format ) ;
+
+ALIAS: D3DXSaveMeshToX D3DXSaveMeshToXW
+
+FUNCTION: HRESULT
+    D3DXCreatePMeshFromStream (
+        IStream*          pStream,
+        DWORD             Options,
+        LPDIRECT3DDEVICE9 pD3DDevice,
+        LPD3DXBUFFER*     ppMaterials,
+        LPD3DXBUFFER*     ppEffectInstances,
+        DWORD*            pNumMaterials,
+        LPD3DXPMESH*      ppPMesh ) ;
+
+FUNCTION: HRESULT
+    D3DXCreateSkinInfo (
+        DWORD              NumVertices,
+        D3DVERTEXELEMENT9* pDeclaration,
+        DWORD              NumBones,
+        LPD3DXSKININFO*    ppSkinInfo ) ;
+
+FUNCTION: HRESULT
+    D3DXCreateSkinInfoFVF (
+        DWORD           NumVertices,
+        DWORD           FVF,
+        DWORD           NumBones,
+        LPD3DXSKININFO* ppSkinInfo ) ;
+
+FUNCTION: HRESULT
+    D3DXLoadMeshFromXof (
+        LPD3DXFILEDATA    pxofMesh,
+        DWORD             Options,
+        LPDIRECT3DDEVICE9 pD3DDevice,
+        LPD3DXBUFFER*     ppAdjacency,
+        LPD3DXBUFFER*     ppMaterials,
+        LPD3DXBUFFER*     ppEffectInstances,
+        DWORD*            pNumMaterials,
+        LPD3DXMESH*       ppMesh ) ;
+
+FUNCTION: HRESULT
+    D3DXLoadSkinMeshFromXof (
+        LPD3DXFILEDATA    pxofMesh,
+        DWORD             Options,
+        LPDIRECT3DDEVICE9 pD3DDevice,
+        LPD3DXBUFFER*     ppAdjacency,
+        LPD3DXBUFFER*     ppMaterials,
+        LPD3DXBUFFER*     ppEffectInstances,
+        DWORD*            pMatOut,
+        LPD3DXSKININFO*   ppSkinInfo,
+        LPD3DXMESH*       ppMesh ) ;
+
+FUNCTION: HRESULT
+    D3DXCreateSkinInfoFromBlendedMesh (
+        LPD3DXBASEMESH       pMesh,
+        DWORD                NumBones,
+        D3DXBONECOMBINATION* pBoneCombinationTable,
+        LPD3DXSKININFO*      ppSkinInfo ) ;
+        
+FUNCTION: HRESULT
+    D3DXTessellateNPatches (
+        LPD3DXMESH    pMeshIn,
+        DWORD*        pAdjacencyIn,
+        FLOAT         NumSegs,
+        BOOL          QuadraticInterpNormals,
+        LPD3DXMESH*   ppMeshOut,
+        LPD3DXBUFFER* ppAdjacencyOut ) ;
+
+FUNCTION: HRESULT
+    D3DXGenerateOutputDecl (
+        D3DVERTEXELEMENT9* pOutput,
+        D3DVERTEXELEMENT9* pInput ) ;
+
+FUNCTION: HRESULT
+    D3DXLoadPatchMeshFromXof (
+        LPD3DXFILEDATA    pXofObjMesh,
+        DWORD             Options,
+        LPDIRECT3DDEVICE9 pD3DDevice,
+        LPD3DXBUFFER*     ppMaterials,
+        LPD3DXBUFFER*     ppEffectInstances,
+        PDWORD            pNumMaterials,
+        LPD3DXPATCHMESH*  ppMesh ) ;
+
+FUNCTION: HRESULT
+    D3DXRectPatchSize (
+        FLOAT* pfNumSegs,
+        DWORD* pdwTriangles,
+        DWORD* pdwVertices ) ;
+
+FUNCTION: HRESULT
+    D3DXTriPatchSize (
+        FLOAT* pfNumSegs,
+        DWORD* pdwTriangles,
+        DWORD* pdwVertices ) ;
+
+FUNCTION: HRESULT
+    D3DXTessellateRectPatch (
+        LPDIRECT3DVERTEXBUFFER9 pVB,
+        FLOAT*                  pNumSegs,
+        D3DVERTEXELEMENT9*      pdwInDecl,
+        D3DRECTPATCH_INFO*      pRectPatchInfo,
+        LPD3DXMESH              pMesh ) ;
+
+FUNCTION: HRESULT
+    D3DXTessellateTriPatch (
+      LPDIRECT3DVERTEXBUFFER9 pVB,
+      FLOAT*                  pNumSegs,
+      D3DVERTEXELEMENT9*      pInDecl,
+      D3DTRIPATCH_INFO*       pTriPatchInfo,
+      LPD3DXMESH              pMesh ) ;
+
+FUNCTION: HRESULT
+    D3DXCreateNPatchMesh (
+        LPD3DXMESH       pMeshSysMem,
+        LPD3DXPATCHMESH* pPatchMesh ) ;
+
+FUNCTION: HRESULT
+    D3DXCreatePatchMesh (
+        D3DXPATCHINFO*     pInfo,
+        DWORD              dwNumPatches,
+        DWORD              dwNumVertices,
+        DWORD              dwOptions,
+        D3DVERTEXELEMENT9* pDecl,
+        LPDIRECT3DDEVICE9  pD3DDevice,
+        LPD3DXPATCHMESH*   pPatchMesh ) ;
+
+FUNCTION: HRESULT
+    D3DXValidPatchMesh (
+        LPD3DXPATCHMESH pMesh,
+        DWORD*          dwcDegenerateVertices,
+        DWORD*          dwcDegeneratePatches,
+        LPD3DXBUFFER*   ppErrorsAndWarnings ) ;
+
+FUNCTION: UINT
+    D3DXGetFVFVertexSize ( DWORD FVF ) ;
+
+FUNCTION: UINT
+    D3DXGetDeclVertexSize ( D3DVERTEXELEMENT9* pDecl, DWORD Stream ) ;
+
+FUNCTION: UINT
+    D3DXGetDeclLength ( D3DVERTEXELEMENT9* pDecl ) ;
+
+FUNCTION: HRESULT
+    D3DXDeclaratorFromFVF (
+        DWORD              FVF,
+        D3DVERTEXELEMENT9* pDeclarator ) ;
+
+FUNCTION: HRESULT
+    D3DXFVFFromDeclarator (
+        D3DVERTEXELEMENT9* pDeclarator,
+        DWORD*             pFVF ) ;
+
+FUNCTION: HRESULT
+    D3DXWeldVertices (
+        LPD3DXMESH        pMesh,
+        DWORD             Flags,
+        D3DXWELDEPSILONS* pEpsilons,
+        DWORD*            pAdjacencyIn,
+        DWORD*            pAdjacencyOut,
+        DWORD*            pFaceRemap,
+        LPD3DXBUFFER*     ppVertexRemap ) ;
+
+STRUCT: D3DXINTERSECTINFO
+    { FaceIndex DWORD }
+    { U         FLOAT }
+    { V         FLOAT }
+    { Dist      FLOAT } ;
+TYPEDEF: D3DXINTERSECTINFO* LPD3DXINTERSECTINFO
+
+FUNCTION: HRESULT
+    D3DXIntersect (
+        LPD3DXBASEMESH pMesh,
+        D3DXVECTOR3*   pRayPos,
+        D3DXVECTOR3*   pRayDir,
+        BOOL*          pHit,
+        DWORD*         pFaceIndex,
+        FLOAT*         pU,
+        FLOAT*         pV,
+        FLOAT*         pDist,
+        LPD3DXBUFFER*  ppAllHits,
+        DWORD*         pCountOfHits ) ;
+
+FUNCTION: HRESULT
+    D3DXIntersectSubset (
+        LPD3DXBASEMESH pMesh,
+        DWORD          AttribId,
+        D3DXVECTOR3*   pRayPos,
+        D3DXVECTOR3*   pRayDir,
+        BOOL*          pHit,
+        DWORD*         pFaceIndex,
+        FLOAT*         pU,
+        FLOAT*         pV,
+        FLOAT*         pDist,
+        LPD3DXBUFFER*  ppAllHits,
+        DWORD*         pCountOfHits ) ;
+
+FUNCTION: HRESULT D3DXSplitMesh (
+    LPD3DXMESH    pMeshIn,
+    DWORD*        pAdjacencyIn,
+    DWORD         MaxSize,
+    DWORD         Options,
+    DWORD*        pMeshesOut,
+    LPD3DXBUFFER* ppMeshArrayOut,
+    LPD3DXBUFFER* ppAdjacencyArrayOut,
+    LPD3DXBUFFER* ppFaceRemapArrayOut,
+    LPD3DXBUFFER* ppVertRemapArrayOut ) ;
+
+FUNCTION: BOOL D3DXIntersectTri (
+    D3DXVECTOR3* p0,
+    D3DXVECTOR3* p1,
+    D3DXVECTOR3* p2,
+    D3DXVECTOR3* pRayPos,
+    D3DXVECTOR3* pRayDir,
+    FLOAT*       pU,
+    FLOAT*       pV,
+    FLOAT*       pDist ) ;
+
+FUNCTION: BOOL
+    D3DXSphereBoundProbe (
+        D3DXVECTOR3* pCenter,
+        FLOAT        Radius,
+        D3DXVECTOR3* pRayPosition,
+        D3DXVECTOR3* pRayDirection ) ;
+
+FUNCTION: BOOL
+    D3DXBoxBoundProbe (
+        D3DXVECTOR3* pMin,
+        D3DXVECTOR3* pMax,
+        D3DXVECTOR3* pRayPosition,
+        D3DXVECTOR3* pRayDirection ) ;
+
+FUNCTION: HRESULT D3DXComputeTangentFrame (
+    ID3DXMesh* pMesh,
+    DWORD      dwOptions ) ;
+
+FUNCTION: HRESULT D3DXComputeTangentFrameEx (
+    ID3DXMesh*    pMesh,
+    DWORD         dwTextureInSemantic,
+    DWORD         dwTextureInIndex,
+    DWORD         dwUPartialOutSemantic,
+    DWORD         dwUPartialOutIndex,
+    DWORD         dwVPartialOutSemantic,
+    DWORD         dwVPartialOutIndex,
+    DWORD         dwNormalOutSemantic,
+    DWORD         dwNormalOutIndex,
+    DWORD         dwOptions,
+    DWORD*        pdwAdjacency,
+    FLOAT         fPartialEdgeThreshold,
+    FLOAT         fSingularPointThreshold,
+    FLOAT         fNormalEdgeThreshold,
+    ID3DXMesh**   ppMeshOut,
+    ID3DXBuffer** ppVertexMapping ) ;
+
+FUNCTION: HRESULT D3DXComputeTangent (
+    LPD3DXMESH Mesh,
+    DWORD      TexStage,
+    DWORD      TangentIndex,
+    DWORD      BinormIndex,
+    DWORD      Wrap,
+    DWORD*     pAdjacency ) ;
+
+C-TYPE: D3DXUVATLASCB 
+TYPEDEF: D3DXUVATLASCB* LPD3DXUVATLASCB 
+
+FUNCTION: HRESULT D3DXUVAtlasCreate (
+    LPD3DXMESH      pMesh,
+    UINT            uMaxChartNumber,
+    FLOAT           fMaxStretch,
+    UINT            uWidth,
+    UINT            uHeight,
+    FLOAT           fGutter,
+    DWORD           dwTextureIndex,
+    DWORD*          pdwAdjacency,
+    DWORD*          pdwFalseEdgeAdjacency,
+    FLOAT*          pfIMTArray,
+    LPD3DXUVATLASCB pStatusCallback,
+    FLOAT           fCallbackFrequency,
+    LPVOID          pUserContext,
+    DWORD           dwOptions,
+    LPD3DXMESH*     ppMeshOut,
+    LPD3DXBUFFER*   ppFacePartitioning,
+    LPD3DXBUFFER*   ppVertexRemapArray,
+    FLOAT*          pfMaxStretchOut,
+    UINT*           puNumChartsOut ) ;
+
+FUNCTION: HRESULT D3DXUVAtlasPartition (
+    LPD3DXMESH      pMesh,
+    UINT            uMaxChartNumber,
+    FLOAT           fMaxStretch,
+    DWORD           dwTextureIndex,
+    DWORD*          pdwAdjacency,
+    DWORD*          pdwFalseEdgeAdjacency,
+    FLOAT*          pfIMTArray,
+    LPD3DXUVATLASCB pStatusCallback,
+    FLOAT           fCallbackFrequency,
+    LPVOID          pUserContext,
+    DWORD           dwOptions,
+    LPD3DXMESH*     ppMeshOut,
+    LPD3DXBUFFER*   ppFacePartitioning,
+    LPD3DXBUFFER*   ppVertexRemapArray,
+    LPD3DXBUFFER*   ppPartitionResultAdjacency,
+    FLOAT*          pfMaxStretchOut,
+    UINT*           puNumChartsOut ) ;
+
+FUNCTION: HRESULT D3DXUVAtlasPack (
+    ID3DXMesh*      pMesh,
+    UINT            uWidth,
+    UINT            uHeight,
+    FLOAT           fGutter,
+    DWORD           dwTextureIndex,
+    DWORD*          pdwPartitionResultAdjacency,
+    LPD3DXUVATLASCB pStatusCallback,
+    FLOAT           fCallbackFrequency,
+    LPVOID          pUserContext,
+    DWORD           dwOptions,
+    LPD3DXBUFFER    pFacePartitioning ) ;
+    
+TYPEDEF: void* LPD3DXIMTSIGNALCALLBACK
+
+FUNCTION: HRESULT D3DXComputeIMTFromPerVertexSignal (
+    LPD3DXMESH      pMesh,
+    FLOAT*          pfVertexSignal,
+    UINT            uSignalDimension,
+    UINT            uSignalStride,
+    DWORD           dwOptions,
+    LPD3DXUVATLASCB pStatusCallback,
+    LPVOID          pUserContext,
+    LPD3DXBUFFER*   ppIMTData ) ;
+
+FUNCTION: HRESULT D3DXComputeIMTFromSignal (
+    LPD3DXMESH              pMesh,
+    DWORD                   dwTextureIndex,
+    UINT                    uSignalDimension,
+    FLOAT                   fMaxUVDistance,
+    DWORD                   dwOptions,
+    LPD3DXIMTSIGNALCALLBACK pSignalCallback,
+    VOID*                   pUserData,
+    LPD3DXUVATLASCB         pStatusCallback,
+    LPVOID                  pUserContext,
+    LPD3DXBUFFER*           ppIMTData ) ;
+
+FUNCTION: HRESULT D3DXComputeIMTFromTexture (
+    LPD3DXMESH         pMesh,
+    LPDIRECT3DTEXTURE9 pTexture,
+    DWORD              dwTextureIndex,
+    DWORD              dwOptions,
+    LPD3DXUVATLASCB    pStatusCallback,
+    LPVOID             pUserContext,
+    LPD3DXBUFFER*      ppIMTData ) ;
+
+FUNCTION: HRESULT D3DXComputeIMTFromPerTexelSignal (
+    LPD3DXMESH      pMesh,
+    DWORD           dwTextureIndex,
+    FLOAT*          pfTexelSignal,
+    UINT            uWidth,
+    UINT            uHeight,
+    UINT            uSignalDimension,
+    UINT            uComponents,
+    DWORD           dwOptions,
+    LPD3DXUVATLASCB pStatusCallback,
+    LPVOID          pUserContext,
+    LPD3DXBUFFER*   ppIMTData ) ;
+
+FUNCTION: HRESULT
+    D3DXConvertMeshSubsetToSingleStrip (
+        LPD3DXBASEMESH          MeshIn,
+        DWORD                   AttribId,
+        DWORD                   IBOptions,
+        LPDIRECT3DINDEXBUFFER9* ppIndexBuffer,
+        DWORD*                  pNumIndices ) ;
+
+FUNCTION: HRESULT
+    D3DXConvertMeshSubsetToStrips (
+        LPD3DXBASEMESH          MeshIn,
+        DWORD                   AttribId,
+        DWORD                   IBOptions,
+        LPDIRECT3DINDEXBUFFER9* ppIndexBuffer,
+        DWORD*                  pNumIndices,
+        LPD3DXBUFFER*           ppStripLengths,
+        DWORD*                  pNumStrips ) ;
+
+FUNCTION: HRESULT
+    D3DXOptimizeFaces (
+        LPCVOID pbIndices,
+        UINT    cFaces,
+        UINT    cVertices,
+        BOOL    b32BitIndices,
+        DWORD*  pFaceRemap ) ;
+
+FUNCTION: HRESULT
+    D3DXOptimizeVertices (
+        LPCVOID pbIndices,
+        UINT    cFaces,
+        UINT    cVertices,
+        BOOL    b32BitIndices,
+        DWORD*  pVertexRemap ) ;
+
+TYPEDEF: int D3DXSHCOMPRESSQUALITYTYPE
+CONSTANT: D3DXSHCQUAL_FASTLOWQUALITY  1
+CONSTANT: D3DXSHCQUAL_SLOWHIGHQUALITY 2
+CONSTANT: D3DXSHCQUAL_FORCE_DWORD     HEX: 7fffffff
+
+TYPEDEF: int D3DXSHGPUSIMOPT
+CONSTANT: D3DXSHGPUSIMOPT_SHADOWRES256  1
+CONSTANT: D3DXSHGPUSIMOPT_SHADOWRES512  0
+CONSTANT: D3DXSHGPUSIMOPT_SHADOWRES1024 2
+CONSTANT: D3DXSHGPUSIMOPT_SHADOWRES2048 3
+CONSTANT: D3DXSHGPUSIMOPT_HIGHQUALITY   4
+CONSTANT: D3DXSHGPUSIMOPT_FORCE_DWORD   HEX: 7fffffff
+
+STRUCT: D3DXSHMATERIAL
+    { Diffuse                           D3DCOLORVALUE }
+    { bMirror                           BOOL          }
+    { bSubSurf                          BOOL          }
+    { RelativeIndexOfRefraction         FLOAT         }
+    { Absorption                        D3DCOLORVALUE }
+    { ReducedScattering                 D3DCOLORVALUE } ;
+
+STRUCT: D3DXSHPRTSPLITMESHVERTDATA
+    { uVertRemap   UINT  }
+    { uSubCluster  UINT  }
+    { ucVertStatus UCHAR } ;
+
+STRUCT: D3DXSHPRTSPLITMESHCLUSTERDATA
+    { uVertStart     UINT }
+    { uVertLength    UINT }
+    { uFaceStart     UINT }
+    { uFaceLength    UINT }
+    { uClusterStart  UINT }
+    { uClusterLength UINT } ;
+
+TYPEDEF: void* LPD3DXSHPRTSIMCB
+
+C-TYPE: ID3DXTextureGutterHelper
+C-TYPE: ID3DXPRTBuffer
+
+COM-INTERFACE: ID3DXPRTBuffer IUnknown {F1827E47-00A8-49cd-908C-9D11955F8728}
+    UINT GetNumSamples ( )
+    UINT GetNumCoeffs ( )
+    UINT GetNumChannels ( )
+    BOOL IsTexture ( )
+    UINT GetWidth ( )
+    UINT GetHeight ( )
+    HRESULT Resize ( UINT NewSize )
+    HRESULT LockBuffer ( UINT Start, UINT NumSamples, FLOAT** ppData )
+    HRESULT UnlockBuffer ( )
+    HRESULT ScaleBuffer ( FLOAT Scale )
+    HRESULT AddBuffer ( LPD3DXPRTBUFFER pBuffer )
+    HRESULT AttachGH ( LPD3DXTEXTUREGUTTERHELPER f )
+    HRESULT ReleaseGH ( )
+    HRESULT EvalGH ( )
+    HRESULT ExtractTexture ( UINT Channel, UINT StartCoefficient,
+                             UINT NumCoefficients, LPDIRECT3DTEXTURE9 pTexture )
+    HRESULT ExtractToMesh ( UINT NumCoefficients, D3DDECLUSAGE Usage, UINT UsageIndexStart,
+                            LPD3DXMESH pScene ) ;
+
+C-TYPE: ID3DXPRTCompBuffer
+TYPEDEF: ID3DXPRTCompBuffer* LPD3DXPRTCOMPBUFFER;
+
+COM-INTERFACE: ID3DXPRTCompBuffer IUnknown {A758D465-FE8D-45ad-9CF0-D01E56266A07}
+    UINT GetNumSamples ( )
+    UINT GetNumCoeffs ( )
+    UINT GetNumChannels ( )
+    BOOL IsTexture ( )
+    UINT GetWidth ( )
+    UINT GetHeight ( )
+    UINT GetNumClusters ( )
+    UINT GetNumPCA ( )
+    HRESULT NormalizeData ( )
+    HRESULT ExtractBasis ( UINT Cluster, FLOAT* pClusterBasis )
+    HRESULT ExtractClusterIDs ( UINT* pClusterIDs )
+    HRESULT ExtractPCA ( UINT StartPCA, UINT NumExtract, FLOAT* pPCACoefficients )
+    HRESULT ExtractTexture ( UINT StartPCA, UINT NumpPCA,
+                             LPDIRECT3DTEXTURE9 pTexture )
+    HRESULT ExtractToMesh ( UINT NumPCA, D3DDECLUSAGE Usage, UINT UsageIndexStart,
+                            LPD3DXMESH pScene ) ;
+
+COM-INTERFACE: ID3DXTextureGutterHelper IUnknown {838F01EC-9729-4527-AADB-DF70ADE7FEA9}
+    UINT GetWidth ( )
+    UINT GetHeight ( )
+    HRESULT ApplyGuttersFLOAT ( FLOAT* pDataIn, UINT NumCoeffs, UINT Width, UINT Height )
+    HRESULT ApplyGuttersTex ( LPDIRECT3DTEXTURE9 pTexture )
+    HRESULT ApplyGuttersPRT ( LPD3DXPRTBUFFER pBuffer )
+    HRESULT ResampleTex (
+        LPDIRECT3DTEXTURE9 pTextureIn,
+        LPD3DXMESH         pMeshIn,
+        D3DDECLUSAGE       Usage,
+        UINT               UsageIndex,
+        LPDIRECT3DTEXTURE9 pTextureOut )
+    HRESULT GetFaceMap ( UINT* pFaceData )
+    HRESULT GetBaryMap ( D3DXVECTOR2* pBaryData )
+    HRESULT GetTexelMap ( D3DXVECTOR2* pTexelData )
+    HRESULT GetGutterMap ( BYTE* pGutterData )
+    HRESULT SetFaceMap ( UINT* pFaceData )
+    HRESULT SetBaryMap ( D3DXVECTOR2* pBaryData )
+    HRESULT SetTexelMap ( D3DXVECTOR2* pTexelData )
+    HRESULT SetGutterMap ( BYTE* pGutterData ) ;
+
+C-TYPE: ID3DXPRTEngine
+TYPEDEF: ID3DXPRTEngine* LPD3DXPRTENGINE
+
+COM-INTERFACE: ID3DXPRTEngine IUnknown {683A4278-CD5F-4d24-90AD-C4E1B6855D53}
+    HRESULT SetMeshMaterials ( D3DXSHMATERIAL** ppMaterials, UINT NumMeshes,
+                               UINT NumChannels, BOOL bSetAlbedo, FLOAT fLengthScale )
+    HRESULT SetPerVertexAlbedo ( VOID* pDataIn, UINT NumChannels, UINT Stride )
+    HRESULT SetPerTexelAlbedo ( LPDIRECT3DTEXTURE9 pAlbedoTexture,
+                                UINT NumChannels,
+                                LPD3DXTEXTUREGUTTERHELPER pGH )
+    HRESULT GetVertexAlbedo ( D3DXCOLOR* pVertColors, UINT NumVerts )
+    HRESULT SetPerTexelNormal ( LPDIRECT3DTEXTURE9 pNormalTexture )
+    HRESULT ExtractPerVertexAlbedo ( LPD3DXMESH pMesh,
+                                     D3DDECLUSAGE Usage,
+                                     UINT NumChannels )
+    HRESULT ResampleBuffer ( LPD3DXPRTBUFFER pBufferIn, LPD3DXPRTBUFFER pBufferOut )
+    HRESULT GetAdaptedMesh ( LPDIRECT3DDEVICE9 pD3DDevice, UINT* pFaceRemap, UINT* pVertRemap, FLOAT* pfVertWeights, LPD3DXMESH* ppMesh )
+    UINT GetNumVerts ( )
+    UINT GetNumFaces ( )
+    HRESULT SetMinMaxIntersection ( FLOAT fMin, FLOAT fMax )
+    HRESULT RobustMeshRefine ( FLOAT MinEdgeLength, UINT MaxSubdiv )
+    HRESULT SetSamplingInfo ( UINT NumRays,
+                              BOOL UseSphere,
+                              BOOL UseCosine,
+                              BOOL Adaptive,
+                              FLOAT AdaptiveThresh )
+    HRESULT ComputeDirectLightingSH ( UINT SHOrder,
+                                      LPD3DXPRTBUFFER pDataOut )
+    HRESULT ComputeDirectLightingSHAdaptive ( UINT SHOrder,
+                                              FLOAT AdaptiveThresh,
+                                              FLOAT MinEdgeLength,
+                                              UINT MaxSubdiv,
+                                              LPD3DXPRTBUFFER pDataOut )
+    HRESULT ComputeDirectLightingSHGPU ( LPDIRECT3DDEVICE9 pD3DDevice,
+                                         UINT Flags,
+                                         UINT SHOrder,
+                                         FLOAT ZBias,
+                                         FLOAT ZAngleBias,
+                                         LPD3DXPRTBUFFER pDataOut )
+    HRESULT ComputeSS ( LPD3DXPRTBUFFER pDataIn,
+                        LPD3DXPRTBUFFER pDataOut, LPD3DXPRTBUFFER pDataTotal )
+    HRESULT ComputeSSAdaptive ( LPD3DXPRTBUFFER pDataIn,
+                                FLOAT AdaptiveThresh,
+                                FLOAT MinEdgeLength,
+                                UINT MaxSubdiv,
+                                LPD3DXPRTBUFFER pDataOut, LPD3DXPRTBUFFER pDataTotal )
+    HRESULT ComputeBounce ( LPD3DXPRTBUFFER pDataIn,
+                            LPD3DXPRTBUFFER pDataOut,
+                            LPD3DXPRTBUFFER pDataTotal )
+    HRESULT ComputeBounceAdaptive ( LPD3DXPRTBUFFER pDataIn,
+                                    FLOAT AdaptiveThresh,
+                                    FLOAT MinEdgeLength,
+                                    UINT MaxSubdiv,
+                                    LPD3DXPRTBUFFER pDataOut,
+                                    LPD3DXPRTBUFFER pDataTotal )
+    HRESULT ComputeVolumeSamplesDirectSH ( UINT SHOrderIn,
+                                           UINT SHOrderOut,
+                                           UINT NumVolSamples,
+                                           D3DXVECTOR3* pSampleLocs,
+                                           LPD3DXPRTBUFFER pDataOut )
+    HRESULT ComputeVolumeSamples ( LPD3DXPRTBUFFER pSurfDataIn,
+                                   UINT SHOrder,
+                                    UINT NumVolSamples,
+                                   D3DXVECTOR3* pSampleLocs,
+                                   LPD3DXPRTBUFFER pDataOut )
+    HRESULT ComputeSurfSamplesDirectSH ( UINT SHOrder,
+                                         UINT NumSamples,
+                                         D3DXVECTOR3* pSampleLocs,
+                                         D3DXVECTOR3* pSampleNorms,
+                                         LPD3DXPRTBUFFER pDataOut )
+    HRESULT ComputeSurfSamplesBounce ( LPD3DXPRTBUFFER pSurfDataIn,
+                                       UINT NumSamples,
+                                       D3DXVECTOR3* pSampleLocs,
+                                       D3DXVECTOR3* pSampleNorms,
+                                       LPD3DXPRTBUFFER pDataOut,
+                                       LPD3DXPRTBUFFER pDataTotal )
+    HRESULT FreeSSData ( )
+    HRESULT FreeBounceData ( )
+    HRESULT ComputeLDPRTCoeffs ( LPD3DXPRTBUFFER pDataIn,
+                                 UINT SHOrder,
+                                 D3DXVECTOR3* pNormOut,
+                                 LPD3DXPRTBUFFER pDataOut )
+    HRESULT ScaleMeshChunk ( UINT uMeshChunk, FLOAT fScale, LPD3DXPRTBUFFER pDataOut )
+    HRESULT MultiplyAlbedo ( LPD3DXPRTBUFFER pDataOut )
+    HRESULT SetCallBack ( LPD3DXSHPRTSIMCB pCB, FLOAT Frequency,  LPVOID lpUserContext )
+    BOOL ShadowRayIntersects ( D3DXVECTOR3* pRayPos, D3DXVECTOR3* pRayDir )
+    BOOL ClosestRayIntersects ( D3DXVECTOR3* pRayPos, D3DXVECTOR3* pRayDir,
+                                DWORD* pFaceIndex, FLOAT* pU, FLOAT* pV, FLOAT* pDist ) ;
+
+FUNCTION: HRESULT
+    D3DXCreatePRTBuffer (
+        UINT             NumSamples,
+        UINT             NumCoeffs,
+        UINT             NumChannels,
+        LPD3DXPRTBUFFER* ppBuffer ) ;
+
+FUNCTION: HRESULT
+    D3DXCreatePRTBufferTex (
+        UINT             Width,
+        UINT             Height,
+        UINT             NumCoeffs,
+        UINT             NumChannels,
+        LPD3DXPRTBUFFER* ppBuffer ) ;
+
+FUNCTION: HRESULT
+    D3DXLoadPRTBufferFromFileA (
+        LPCSTR                 pFilename,
+        LPD3DXPRTBUFFER*       ppBuffer ) ;
+
+FUNCTION: HRESULT
+    D3DXLoadPRTBufferFromFileW (
+        LPCWSTR                pFilename,
+        LPD3DXPRTBUFFER*       ppBuffer ) ;
+
+ALIAS: D3DXLoadPRTBufferFromFile D3DXLoadPRTBufferFromFileW
+
+FUNCTION: HRESULT
+    D3DXSavePRTBufferToFileA (
+        LPCSTR          pFileName,
+        LPD3DXPRTBUFFER pBuffer ) ;
+
+FUNCTION: HRESULT
+    D3DXSavePRTBufferToFileW (
+        LPCWSTR         pFileName,
+        LPD3DXPRTBUFFER pBuffer ) ;
+
+ALIAS: D3DXSavePRTBufferToFile D3DXSavePRTBufferToFileW
+
+C-TYPE: D3DXPRTCOMPBUFFER
+TYPEDEF: D3DXPRTCOMPBUFFER* LPD3DXPRTCOMPBUFFER
+    
+FUNCTION: HRESULT
+    D3DXLoadPRTCompBufferFromFileA (
+        LPCSTR                     pFilename,
+        LPD3DXPRTCOMPBUFFER*       ppBuffer ) ;
+
+FUNCTION: HRESULT
+    D3DXLoadPRTCompBufferFromFileW (
+        LPCWSTR                    pFilename,
+        LPD3DXPRTCOMPBUFFER*       ppBuffer ) ;
+
+ALIAS: D3DXLoadPRTCompBufferFromFile D3DXLoadPRTCompBufferFromFileW
+
+FUNCTION: HRESULT
+    D3DXSavePRTCompBufferToFileA (
+        LPCSTR              pFileName,
+        LPD3DXPRTCOMPBUFFER pBuffer ) ;
+
+FUNCTION: HRESULT
+    D3DXSavePRTCompBufferToFileW (
+        LPCWSTR             pFileName,
+        LPD3DXPRTCOMPBUFFER pBuffer ) ;
+
+ALIAS: D3DXSavePRTCompBufferToFile D3DXSavePRTCompBufferToFileW
+
+FUNCTION: HRESULT
+    D3DXCreatePRTCompBuffer (
+        D3DXSHCOMPRESSQUALITYTYPE Quality,
+        UINT                      NumClusters,
+        UINT                      NumPCA,
+        LPD3DXSHPRTSIMCB          pCB,
+        LPVOID                    lpUserContext,
+        LPD3DXPRTBUFFER           pBufferIn,
+        LPD3DXPRTCOMPBUFFER*      ppBufferOut ) ;
+
+FUNCTION: HRESULT
+    D3DXCreateTextureGutterHelper (
+        UINT                       Width,
+        UINT                       Height,
+        LPD3DXMESH                 pMesh,
+        FLOAT                      GutterSize,
+        LPD3DXTEXTUREGUTTERHELPER* ppBuffer ) ;
+
+FUNCTION: HRESULT
+    D3DXCreatePRTEngine (
+        LPD3DXMESH       pMesh,
+        DWORD*           pAdjacency,
+        BOOL             ExtractUVs,
+        LPD3DXMESH       pBlockerMesh,
+        LPD3DXPRTENGINE* ppEngine ) ;
+
+FUNCTION: HRESULT
+    D3DXConcatenateMeshes (
+        LPD3DXMESH*        ppMeshes,
+        UINT               NumMeshes,
+        DWORD              Options,
+        D3DXMATRIX*        pGeomXForms,
+        D3DXMATRIX*        pTextureXForms,
+        D3DVERTEXELEMENT9* pDecl,
+        LPDIRECT3DDEVICE9  pD3DDevice,
+        LPD3DXMESH*        ppMeshOut ) ;
+
+FUNCTION: HRESULT
+    D3DXSHPRTCompSuperCluster (
+        UINT*      pClusterIDs,
+        LPD3DXMESH pScene,
+        UINT       MaxNumClusters,
+        UINT       NumClusters,
+        UINT*      pSuperClusterIDs,
+        UINT*      pNumSuperClusters ) ;
+
+FUNCTION: HRESULT
+    D3DXSHPRTCompSplitMeshSC (
+        UINT*                          pClusterIDs,
+        UINT                           NumVertices,
+        UINT                           NumClusters,
+        UINT*                          pSuperClusterIDs,
+        UINT                           NumSuperClusters,
+        LPVOID                         pInputIB,
+        BOOL                           InputIBIs32Bit,
+        UINT                           NumFaces,
+        LPD3DXBUFFER*                  ppIBData,
+        UINT*                          pIBDataLength,
+        BOOL                           OutputIBIs32Bit,
+        LPD3DXBUFFER*                  ppFaceRemap,
+        LPD3DXBUFFER*                  ppVertData,
+        UINT*                          pVertDataLength,
+        UINT*                          pSCClusterList,
+        D3DXSHPRTSPLITMESHCLUSTERDATA* pSCData ) ;
+
diff --git a/basis/windows/directx/d3dx9mesh/summary.txt b/basis/windows/directx/d3dx9mesh/summary.txt
new file mode 100644 (file)
index 0000000..faa4133
--- /dev/null
@@ -0,0 +1 @@
+DirectX 9 bindings. Corresponds to d3dx9mesh.h.
diff --git a/basis/windows/directx/d3dx9mesh/tags.txt b/basis/windows/directx/d3dx9mesh/tags.txt
new file mode 100644 (file)
index 0000000..2320bdd
--- /dev/null
@@ -0,0 +1,2 @@
+unportable
+bindings
diff --git a/basis/windows/directx/d3dx9shader/authors.txt b/basis/windows/directx/d3dx9shader/authors.txt
new file mode 100644 (file)
index 0000000..6f03a12
--- /dev/null
@@ -0,0 +1 @@
+Erik Charlebois
diff --git a/basis/windows/directx/d3dx9shader/d3dx9shader.factor b/basis/windows/directx/d3dx9shader/d3dx9shader.factor
new file mode 100644 (file)
index 0000000..12ba902
--- /dev/null
@@ -0,0 +1,441 @@
+USING: alien.c-types alien.syntax classes.struct math
+windows.com windows.com.syntax windows.directx.d3d9
+windows.directx.d3dx9core windows.directx.d3dx9math
+windows.types ;
+IN: windows.directx.d3dx9shader
+
+LIBRARY: d3dx9
+
+: D3DXSHADER_DEBUG                          ( -- n ) 1 0 shift ; inline
+: D3DXSHADER_SKIPVALIDATION                 ( -- n ) 1 1 shift ; inline
+: D3DXSHADER_SKIPOPTIMIZATION               ( -- n ) 1 2 shift ; inline
+: D3DXSHADER_PACKMATRIX_ROWMAJOR            ( -- n ) 1 3 shift ; inline
+: D3DXSHADER_PACKMATRIX_COLUMNMAJOR         ( -- n ) 1 4 shift ; inline
+: D3DXSHADER_PARTIALPRECISION               ( -- n ) 1 5 shift ; inline
+: D3DXSHADER_FORCE_VS_SOFTWARE_NOOPT        ( -- n ) 1 6 shift ; inline
+: D3DXSHADER_FORCE_PS_SOFTWARE_NOOPT        ( -- n ) 1 7 shift ; inline
+: D3DXSHADER_NO_PRESHADER                   ( -- n ) 1 8 shift ; inline
+: D3DXSHADER_AVOID_FLOW_CONTROL             ( -- n ) 1 9 shift ; inline
+: D3DXSHADER_PREFER_FLOW_CONTROL            ( -- n ) 1 10 shift ; inline
+: D3DXSHADER_ENABLE_BACKWARDS_COMPATIBILITY ( -- n ) 1 12 shift ; inline
+: D3DXSHADER_IEEE_STRICTNESS                ( -- n ) 1 13 shift ; inline
+: D3DXSHADER_USE_LEGACY_D3DX9_31_DLL        ( -- n ) 1 16 shift ; inline
+
+: D3DXSHADER_OPTIMIZATION_LEVEL0            ( -- n ) 1 14 shift ; inline
+: D3DXSHADER_OPTIMIZATION_LEVEL1            ( -- n ) 0 ; inline
+: D3DXSHADER_OPTIMIZATION_LEVEL2            ( -- n ) 1 14 shift 1 15 shift bitor ; inline
+: D3DXSHADER_OPTIMIZATION_LEVEL3            ( -- n ) 1 15 shift ; inline
+
+: D3DXCONSTTABLE_LARGEADDRESSAWARE          ( -- n ) 1 17 shift ; inline
+
+TYPEDEF: LPCSTR D3DXHANDLE
+TYPEDEF: D3DXHANDLE* LPD3DXHANDLE
+
+STRUCT: D3DXMACRO
+    { Name       LPCSTR }
+    { Definition LPCSTR } ;
+TYPEDEF: D3DXMACRO* LPD3DXMACRO
+
+STRUCT: D3DXSEMANTIC
+    { Usage      UINT }
+    { UsageIndex UINT } ;
+TYPEDEF: D3DXSEMANTIC* LPD3DXSEMANTIC
+
+C-ENUM:
+    D3DXRS_BOOL
+    D3DXRS_INT4
+    D3DXRS_FLOAT4
+    D3DXRS_SAMPLER ;
+TYPEDEF: int D3DXREGISTER_SET
+TYPEDEF: D3DXREGISTER_SET* LPD3DXREGISTER_SET
+
+C-ENUM:
+    D3DXPC_SCALAR
+    D3DXPC_VECTOR
+    D3DXPC_MATRIX_ROWS
+    D3DXPC_MATRIX_COLUMNS
+    D3DXPC_OBJECT
+    D3DXPC_STRUCT ;
+TYPEDEF: int D3DXPARAMETER_CLASS
+TYPEDEF: D3DXPARAMETER_CLASS* LPD3DXPARAMETER_CLASS
+
+C-ENUM:
+    D3DXPT_VOID
+    D3DXPT_BOOL
+    D3DXPT_INT
+    D3DXPT_FLOAT
+    D3DXPT_STRING
+    D3DXPT_TEXTURE
+    D3DXPT_TEXTURE1D
+    D3DXPT_TEXTURE2D
+    D3DXPT_TEXTURE3D
+    D3DXPT_TEXTURECUBE
+    D3DXPT_SAMPLER
+    D3DXPT_SAMPLER1D
+    D3DXPT_SAMPLER2D
+    D3DXPT_SAMPLER3D
+    D3DXPT_SAMPLERCUBE
+    D3DXPT_PIXELSHADER
+    D3DXPT_VERTEXSHADER
+    D3DXPT_PIXELFRAGMENT
+    D3DXPT_VERTEXFRAGMENT
+    D3DXPT_UNSUPPORTED ;
+TYPEDEF: int D3DXPARAMETER_TYPE
+TYPEDEF: D3DXPARAMETER_TYPE* LPD3DXPARAMETER_TYPE
+
+STRUCT: D3DXCONSTANTTABLE_DESC
+    { Creator   LPCSTR }
+    { Version   DWORD  }
+    { Constants UINT   } ;
+TYPEDEF: D3DXCONSTANTTABLE_DESC* LPD3DXCONSTANTTABLE_DESC
+
+STRUCT: D3DXCONSTANT_DESC
+    { Name          LPCSTR              }
+    { RegisterSet   D3DXREGISTER_SET    }
+    { RegisterIndex UINT                }
+    { RegisterCount UINT                }
+    { Class         D3DXPARAMETER_CLASS }
+    { Type          D3DXPARAMETER_TYPE  }
+    { Rows          UINT                }
+    { Columns       UINT                }
+    { Elements      UINT                }
+    { StructMembers UINT                }
+    { Bytes         UINT                }
+    { DefaultValue  LPCVOID             } ;
+TYPEDEF: D3DXCONSTANT_DESC* LPD3DXCONSTANT_DESC
+
+C-TYPE: ID3DXConstantTable
+TYPEDEF: ID3DXConstantTable* LPD3DXCONSTANTTABLE
+
+COM-INTERFACE: ID3DXConstantTable IUnknown {AB3C758F-093E-4356-B762-4DB18F1B3A01}
+    LPVOID GetBufferPointer ( )
+    DWORD GetBufferSize ( )
+    HRESULT GetDesc ( D3DXCONSTANTTABLE_DESC* pDesc )
+    HRESULT GetConstantDesc ( D3DXHANDLE hConstant, D3DXCONSTANT_DESC* pConstantDesc, UINT* pCount )
+    UINT GetSamplerIndex ( D3DXHANDLE hConstant )
+    D3DXHANDLE GetConstant ( D3DXHANDLE hConstant, UINT Index )
+    D3DXHANDLE GetConstantByName ( D3DXHANDLE hConstant, LPCSTR pName )
+    D3DXHANDLE GetConstantElement ( D3DXHANDLE hConstant, UINT Index )
+    HRESULT SetDefaults ( LPDIRECT3DDEVICE9 pDevice )
+    HRESULT SetValue ( LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, LPCVOID pData, UINT Bytes )
+    HRESULT SetBool ( LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, BOOL b )
+    HRESULT SetBoolArray ( LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, BOOL* pb, UINT Count )
+    HRESULT SetInt ( LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, INT n )
+    HRESULT SetIntArray ( LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, INT* pn, UINT Count )
+    HRESULT SetFloat ( LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, FLOAT f )
+    HRESULT SetFloatArray ( LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, FLOAT* pf, UINT Count )
+    HRESULT SetVector ( LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, D3DXVECTOR4* pVector )
+    HRESULT SetVectorArray ( LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, D3DXVECTOR4* pVector, UINT Count )
+    HRESULT SetMatrix ( LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, D3DXMATRIX* pMatrix )
+    HRESULT SetMatrixArray ( LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, D3DXMATRIX* pMatrix, UINT Count )
+    HRESULT SetMatrixPointerArray ( LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, D3DXMATRIX** ppMatrix, UINT Count )
+    HRESULT SetMatrixTranspose ( LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, D3DXMATRIX* pMatrix )
+    HRESULT SetMatrixTransposeArray ( LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, D3DXMATRIX* pMatrix, UINT Count )
+    HRESULT SetMatrixTransposePointerArray ( LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, D3DXMATRIX** ppMatrix, UINT Count ) ;
+
+C-TYPE: ID3DXTextureShader
+TYPEDEF: ID3DXTextureShader* LPD3DXTEXTURESHADER
+
+COM-INTERFACE: ID3DXTextureShader IUnknown {3E3D67F8-AA7A-405d-A857-BA01D4758426}
+    HRESULT GetFunction ( LPD3DXBUFFER* ppFunction )
+    HRESULT GetConstantBuffer ( LPD3DXBUFFER* ppConstantBuffer )
+    HRESULT GetDesc ( D3DXCONSTANTTABLE_DESC* pDesc )
+    HRESULT GetConstantDesc ( D3DXHANDLE hConstant, D3DXCONSTANT_DESC* pConstantDesc, UINT* pCount )
+    D3DXHANDLE GetConstant ( D3DXHANDLE hConstant, UINT Index )
+    D3DXHANDLE GetConstantByName ( D3DXHANDLE hConstant, LPCSTR pName )
+    D3DXHANDLE GetConstantElement ( D3DXHANDLE hConstant, UINT Index )
+    HRESULT SetDefaults ( )
+    HRESULT SetValue ( D3DXHANDLE hConstant, LPCVOID pData, UINT Bytes )
+    HRESULT SetBool ( D3DXHANDLE hConstant, BOOL b )
+    HRESULT SetBoolArray ( D3DXHANDLE hConstant, BOOL* pb, UINT Count )
+    HRESULT SetInt ( D3DXHANDLE hConstant, INT n )
+    HRESULT SetIntArray ( D3DXHANDLE hConstant, INT* pn, UINT Count )
+    HRESULT SetFloat ( D3DXHANDLE hConstant, FLOAT f )
+    HRESULT SetFloatArray ( D3DXHANDLE hConstant, FLOAT* pf, UINT Count )
+    HRESULT SetVector ( D3DXHANDLE hConstant, D3DXVECTOR4* pVector )
+    HRESULT SetVectorArray ( D3DXHANDLE hConstant, D3DXVECTOR4* pVector, UINT Count )
+    HRESULT SetMatrix ( D3DXHANDLE hConstant, D3DXMATRIX* pMatrix )
+    HRESULT SetMatrixArray ( D3DXHANDLE hConstant, D3DXMATRIX* pMatrix, UINT Count )
+    HRESULT SetMatrixPointerArray ( D3DXHANDLE hConstant, D3DXMATRIX** ppMatrix, UINT Count )
+    HRESULT SetMatrixTranspose ( D3DXHANDLE hConstant, D3DXMATRIX* pMatrix )
+    HRESULT SetMatrixTransposeArray ( D3DXHANDLE hConstant, D3DXMATRIX* pMatrix, UINT Count )
+    HRESULT SetMatrixTransposePointerArray ( D3DXHANDLE hConstant, D3DXMATRIX** ppMatrix, UINT Count ) ;
+
+C-ENUM:
+    D3DXINC_LOCAL
+    D3DXINC_SYSTEM ;
+TYPEDEF: int D3DXINCLUDE_TYPE
+TYPEDEF: D3DXINCLUDE_TYPE* LPD3DXINCLUDE_TYPE
+
+C-TYPE: ID3DXInclude
+TYPEDEF: ID3DXInclude* LPD3DXINCLUDE
+
+COM-INTERFACE: ID3DXInclude f {00000000-0000-0000-0000-000000000000}
+    HRESULT Open ( D3DXINCLUDE_TYPE IncludeType, LPCSTR pFileName, LPCVOID pParentData, LPCVOID* ppData, UINT* pBytes )
+    HRESULT Close ( LPCVOID pData ) ;
+
+FUNCTION: HRESULT
+    D3DXAssembleShaderFromFileA (
+        LPCSTR                          pSrcFile,
+        D3DXMACRO*                      pDefines,
+        LPD3DXINCLUDE                   pInclude,
+        DWORD                           Flags,
+        LPD3DXBUFFER*                   ppShader,
+        LPD3DXBUFFER*                   ppErrorMsgs ) ;
+
+FUNCTION: HRESULT
+    D3DXAssembleShaderFromFileW (
+        LPCWSTR                         pSrcFile,
+        D3DXMACRO*                      pDefines,
+        LPD3DXINCLUDE                   pInclude,
+        DWORD                           Flags,
+        LPD3DXBUFFER*                   ppShader,
+        LPD3DXBUFFER*                   ppErrorMsgs ) ;
+
+ALIAS: D3DXAssembleShaderFromFile D3DXAssembleShaderFromFileW
+
+FUNCTION: HRESULT
+    D3DXAssembleShaderFromResourceA (
+        HMODULE                         hSrcModule,
+        LPCSTR                          pSrcResource,
+        D3DXMACRO*                      pDefines,
+        LPD3DXINCLUDE                   pInclude,
+        DWORD                           Flags,
+        LPD3DXBUFFER*                   ppShader,
+        LPD3DXBUFFER*                   ppErrorMsgs ) ;
+
+FUNCTION: HRESULT
+    D3DXAssembleShaderFromResourceW (
+        HMODULE                         hSrcModule,
+        LPCWSTR                         pSrcResource,
+        D3DXMACRO*                      pDefines,
+        LPD3DXINCLUDE                   pInclude,
+        DWORD                           Flags,
+        LPD3DXBUFFER*                   ppShader,
+        LPD3DXBUFFER*                   ppErrorMsgs ) ;
+
+ALIAS: D3DXAssembleShaderFromResource D3DXAssembleShaderFromResourceW
+
+FUNCTION: HRESULT
+    D3DXAssembleShader (
+        LPCSTR                          pSrcData,
+        UINT                            SrcDataLen,
+        D3DXMACRO*                      pDefines,
+        LPD3DXINCLUDE                   pInclude,
+        DWORD                           Flags,
+        LPD3DXBUFFER*                   ppShader,
+        LPD3DXBUFFER*                   ppErrorMsgs ) ;
+
+FUNCTION: HRESULT
+    D3DXCompileShaderFromFileA (
+        LPCSTR                          pSrcFile,
+        D3DXMACRO*                      pDefines,
+        LPD3DXINCLUDE                   pInclude,
+        LPCSTR                          pFunctionName,
+        LPCSTR                          pProfile,
+        DWORD                           Flags,
+        LPD3DXBUFFER*                   ppShader,
+        LPD3DXBUFFER*                   ppErrorMsgs,
+        LPD3DXCONSTANTTABLE*            ppConstantTable ) ;
+
+FUNCTION: HRESULT
+    D3DXCompileShaderFromFileW (
+        LPCWSTR                         pSrcFile,
+        D3DXMACRO*                      pDefines,
+        LPD3DXINCLUDE                   pInclude,
+        LPCSTR                          pFunctionName,
+        LPCSTR                          pProfile,
+        DWORD                           Flags,
+        LPD3DXBUFFER*                   ppShader,
+        LPD3DXBUFFER*                   ppErrorMsgs,
+        LPD3DXCONSTANTTABLE*            ppConstantTable ) ;
+
+ALIAS: D3DXCompileShaderFromFile D3DXCompileShaderFromFileW
+
+FUNCTION: HRESULT
+    D3DXCompileShaderFromResourceA (
+        HMODULE                         hSrcModule,
+        LPCSTR                          pSrcResource,
+        D3DXMACRO*                      pDefines,
+        LPD3DXINCLUDE                   pInclude,
+        LPCSTR                          pFunctionName,
+        LPCSTR                          pProfile,
+        DWORD                           Flags,
+        LPD3DXBUFFER*                   ppShader,
+        LPD3DXBUFFER*                   ppErrorMsgs,
+        LPD3DXCONSTANTTABLE*            ppConstantTable ) ;
+
+FUNCTION: HRESULT
+    D3DXCompileShaderFromResourceW (
+        HMODULE                         hSrcModule,
+        LPCWSTR                         pSrcResource,
+        D3DXMACRO*                      pDefines,
+        LPD3DXINCLUDE                   pInclude,
+        LPCSTR                          pFunctionName,
+        LPCSTR                          pProfile,
+        DWORD                           Flags,
+        LPD3DXBUFFER*                   ppShader,
+        LPD3DXBUFFER*                   ppErrorMsgs,
+        LPD3DXCONSTANTTABLE*            ppConstantTable ) ;
+
+ALIAS: D3DXCompileShaderFromResource D3DXCompileShaderFromResourceW
+
+FUNCTION: HRESULT
+    D3DXCompileShader (
+        LPCSTR                          pSrcData,
+        UINT                            SrcDataLen,
+        D3DXMACRO*                      pDefines,
+        LPD3DXINCLUDE                   pInclude,
+        LPCSTR                          pFunctionName,
+        LPCSTR                          pProfile,
+        DWORD                           Flags,
+        LPD3DXBUFFER*                   ppShader,
+        LPD3DXBUFFER*                   ppErrorMsgs,
+        LPD3DXCONSTANTTABLE*            ppConstantTable ) ;
+
+FUNCTION: HRESULT
+    D3DXDisassembleShader (
+        DWORD*                          pShader,         
+        BOOL                            EnableColorCode, 
+        LPCSTR                          pComments,       
+        LPD3DXBUFFER*                   ppDisassembly ) ;
+
+FUNCTION: LPCSTR
+    D3DXGetPixelShaderProfile (
+        LPDIRECT3DDEVICE9               pDevice ) ;
+
+FUNCTION: LPCSTR
+    D3DXGetVertexShaderProfile (
+        LPDIRECT3DDEVICE9               pDevice ) ;
+
+FUNCTION: HRESULT
+    D3DXFindShaderComment (
+        DWORD*                          pFunction,
+        DWORD                           FourCC,
+        LPCVOID*                        ppData,
+        UINT*                           pSizeInBytes ) ;
+        
+FUNCTION: UINT
+    D3DXGetShaderSize (
+        DWORD*                    pFunction ) ;
+
+FUNCTION: DWORD
+    D3DXGetShaderVersion (
+        DWORD*                    pFunction ) ;
+
+FUNCTION: HRESULT
+    D3DXGetShaderInputSemantics (
+        DWORD*                          pFunction,
+        D3DXSEMANTIC*                   pSemantics,
+        UINT*                           pCount ) ;
+
+FUNCTION: HRESULT
+    D3DXGetShaderOutputSemantics (
+        DWORD*                          pFunction,
+        D3DXSEMANTIC*                   pSemantics,
+        UINT*                           pCount ) ;
+
+FUNCTION: HRESULT
+    D3DXGetShaderSamplers (
+        DWORD*                          pFunction,
+        LPCSTR*                         pSamplers,
+        UINT*                           pCount ) ;
+
+FUNCTION: HRESULT
+    D3DXGetShaderConstantTable (
+        DWORD*                          pFunction,
+        LPD3DXCONSTANTTABLE*            ppConstantTable ) ;
+
+FUNCTION: HRESULT
+    D3DXGetShaderConstantTableEx (
+        DWORD*                          pFunction,
+        DWORD                           Flags,
+        LPD3DXCONSTANTTABLE*            ppConstantTable ) ;
+
+FUNCTION: HRESULT
+    D3DXCreateTextureShader (
+        DWORD*                          pFunction,      
+        LPD3DXTEXTURESHADER*            ppTextureShader ) ;
+    
+FUNCTION: HRESULT 
+    D3DXPreprocessShaderFromFileA (
+        LPCSTR                       pSrcFile,
+        D3DXMACRO*                   pDefines,
+        LPD3DXINCLUDE                pInclude,
+        LPD3DXBUFFER*                ppShaderText,
+        LPD3DXBUFFER*                ppErrorMsgs ) ;
+                                             
+FUNCTION: HRESULT 
+    D3DXPreprocessShaderFromFileW (
+        LPCWSTR                      pSrcFile,
+        D3DXMACRO*                   pDefines,
+        LPD3DXINCLUDE                pInclude,
+        LPD3DXBUFFER*                ppShaderText,
+        LPD3DXBUFFER*                ppErrorMsgs ) ;
+
+ALIAS: D3DXPreprocessShaderFromFile D3DXPreprocessShaderFromFileW
+
+FUNCTION: HRESULT 
+    D3DXPreprocessShaderFromResourceA (
+        HMODULE                      hSrcModule,
+        LPCSTR                       pSrcResource,
+        D3DXMACRO*                   pDefines,
+        LPD3DXINCLUDE                pInclude,
+        LPD3DXBUFFER*                ppShaderText,
+        LPD3DXBUFFER*                ppErrorMsgs ) ;
+
+FUNCTION: HRESULT 
+    D3DXPreprocessShaderFromResourceW (
+        HMODULE                      hSrcModule,
+        LPCWSTR                      pSrcResource,
+        D3DXMACRO*                   pDefines,
+        LPD3DXINCLUDE                pInclude,
+        LPD3DXBUFFER*                ppShaderText,
+        LPD3DXBUFFER*                ppErrorMsgs ) ;
+
+ALIAS: D3DXPreprocessShaderFromResource D3DXPreprocessShaderFromResourceW
+
+FUNCTION: HRESULT 
+    D3DXPreprocessShader (
+        LPCSTR                       pSrcData,
+        UINT                         SrcDataSize,
+        D3DXMACRO*                   pDefines,
+        LPD3DXINCLUDE                pInclude,
+        LPD3DXBUFFER*                ppShaderText,
+        LPD3DXBUFFER*                ppErrorMsgs ) ;
+
+STRUCT: D3DXSHADER_CONSTANTTABLE
+    { Size         DWORD }
+    { Creator      DWORD }
+    { Version      DWORD }
+    { Constants    DWORD }
+    { ConstantInfo DWORD }
+    { Flags        DWORD }
+    { Target       DWORD } ;
+TYPEDEF: D3DXSHADER_CONSTANTTABLE* LPD3DXSHADER_CONSTANTTABLE
+
+STRUCT: D3DXSHADER_CONSTANTINFO
+    { Name           DWORD }
+    { RegisterSet    WORD  }
+    { RegisterIndex  WORD  }
+    { RegisterCount  WORD  }
+    { Reserved       WORD  }
+    { TypeInfo       DWORD }
+    { DefaultValue   DWORD } ;
+TYPEDEF: D3DXSHADER_CONSTANTINFO* LPD3DXSHADER_CONSTANTINFO
+
+STRUCT: D3DXSHADER_TYPEINFO
+    { Class            WORD  }
+    { Type             WORD  }
+    { Rows             WORD  }
+    { Columns          WORD  }
+    { Elements         WORD  }
+    { StructMembers    WORD  }
+    { StructMemberInfo DWORD } ;
+TYPEDEF: D3DXSHADER_TYPEINFO* LPD3DXSHADER_TYPEINFO
+
+STRUCT: D3DXSHADER_STRUCTMEMBERINFO
+    { Name     DWORD }
+    { TypeInfo DWORD } ;
+TYPEDEF: D3DXSHADER_STRUCTMEMBERINFO* LPD3DXSHADER_STRUCTMEMBERINFO
+
diff --git a/basis/windows/directx/d3dx9shader/summary.txt b/basis/windows/directx/d3dx9shader/summary.txt
new file mode 100644 (file)
index 0000000..a56300a
--- /dev/null
@@ -0,0 +1 @@
+DirectX 9 bindings. Corresponds to d3dx9shader.h.
diff --git a/basis/windows/directx/d3dx9shader/tags.txt b/basis/windows/directx/d3dx9shader/tags.txt
new file mode 100644 (file)
index 0000000..2320bdd
--- /dev/null
@@ -0,0 +1,2 @@
+unportable
+bindings
diff --git a/basis/windows/directx/d3dx9shape/authors.txt b/basis/windows/directx/d3dx9shape/authors.txt
new file mode 100644 (file)
index 0000000..6f03a12
--- /dev/null
@@ -0,0 +1 @@
+Erik Charlebois
diff --git a/basis/windows/directx/d3dx9shape/d3dx9shape.factor b/basis/windows/directx/d3dx9shape/d3dx9shape.factor
new file mode 100644 (file)
index 0000000..33b3308
--- /dev/null
@@ -0,0 +1,85 @@
+USING: alien.c-types alien.syntax windows.directx.d3d9
+windows.directx.d3dx9core windows.directx.d3dx9mesh
+windows.types ;
+IN: windows.directx.d3dx9shape
+
+LIBRARY: d3dx9
+
+TYPEDEF: void* LPGLYPHMETRICSFLOAT 
+
+FUNCTION: HRESULT 
+    D3DXCreatePolygon (
+        LPDIRECT3DDEVICE9   pDevice,
+        FLOAT               Length, 
+        UINT                Sides, 
+        LPD3DXMESH*         ppMesh,
+        LPD3DXBUFFER*       ppAdjacency ) ;
+
+FUNCTION: HRESULT 
+    D3DXCreateBox (
+        LPDIRECT3DDEVICE9   pDevice, 
+        FLOAT               Width,
+        FLOAT               Height,
+        FLOAT               Depth,
+        LPD3DXMESH*         ppMesh,
+        LPD3DXBUFFER*       ppAdjacency ) ;
+
+FUNCTION: HRESULT 
+    D3DXCreateCylinder (
+        LPDIRECT3DDEVICE9   pDevice,
+        FLOAT               Radius1, 
+        FLOAT               Radius2, 
+        FLOAT               Length, 
+        UINT                Slices, 
+        UINT                Stacks,   
+        LPD3DXMESH*         ppMesh,
+        LPD3DXBUFFER*       ppAdjacency ) ;
+
+FUNCTION: HRESULT
+    D3DXCreateSphere (
+        LPDIRECT3DDEVICE9  pDevice, 
+        FLOAT              Radius, 
+        UINT               Slices, 
+        UINT               Stacks,
+        LPD3DXMESH*        ppMesh,
+        LPD3DXBUFFER*      ppAdjacency ) ;
+
+FUNCTION: HRESULT
+    D3DXCreateTorus (
+        LPDIRECT3DDEVICE9   pDevice,
+        FLOAT               InnerRadius,
+        FLOAT               OuterRadius, 
+        UINT                Sides,
+        UINT                Rings, 
+        LPD3DXMESH*         ppMesh,
+        LPD3DXBUFFER*       ppAdjacency ) ;
+
+FUNCTION: HRESULT
+    D3DXCreateTeapot (
+        LPDIRECT3DDEVICE9   pDevice,
+        LPD3DXMESH*         ppMesh,
+        LPD3DXBUFFER*       ppAdjacency ) ;
+
+FUNCTION: HRESULT
+    D3DXCreateTextA (
+        LPDIRECT3DDEVICE9   pDevice,
+        HDC                 hDC,
+        LPCSTR              pText,
+        FLOAT               Deviation,
+        FLOAT               Extrusion,
+        LPD3DXMESH*         ppMesh,
+        LPD3DXBUFFER*       ppAdjacency,
+        LPGLYPHMETRICSFLOAT pGlyphMetrics ) ;
+
+FUNCTION: HRESULT
+    D3DXCreateTextW (
+        LPDIRECT3DDEVICE9   pDevice,
+        HDC                 hDC,
+        LPCWSTR             pText,
+        FLOAT               Deviation,
+        FLOAT               Extrusion,
+        LPD3DXMESH*         ppMesh,
+        LPD3DXBUFFER*       ppAdjacency,
+        LPGLYPHMETRICSFLOAT pGlyphMetrics ) ;
+
+ALIAS: D3DXCreateText D3DXCreateTextW
diff --git a/basis/windows/directx/d3dx9shape/summary.txt b/basis/windows/directx/d3dx9shape/summary.txt
new file mode 100644 (file)
index 0000000..0675145
--- /dev/null
@@ -0,0 +1 @@
+DirectX 9 bindings. Corresponds to d3dx9shape.h.
diff --git a/basis/windows/directx/d3dx9shape/tags.txt b/basis/windows/directx/d3dx9shape/tags.txt
new file mode 100644 (file)
index 0000000..2320bdd
--- /dev/null
@@ -0,0 +1,2 @@
+unportable
+bindings
diff --git a/basis/windows/directx/d3dx9tex/authors.txt b/basis/windows/directx/d3dx9tex/authors.txt
new file mode 100644 (file)
index 0000000..6f03a12
--- /dev/null
@@ -0,0 +1 @@
+Erik Charlebois
diff --git a/basis/windows/directx/d3dx9tex/d3dx9tex.factor b/basis/windows/directx/d3dx9tex/d3dx9tex.factor
new file mode 100644 (file)
index 0000000..c1de9d0
--- /dev/null
@@ -0,0 +1,847 @@
+USING: alien.c-types alien.syntax classes.struct math
+windows.directx.d3d9 windows.directx.d3d9types
+windows.directx.d3dx9core windows.directx.d3dx9shader
+windows.types ;
+IN: windows.directx.d3dx9tex
+
+LIBRARY: d3dx9
+
+: D3DX_FILTER_NONE             ( -- n ) 1 0 shift ; inline
+: D3DX_FILTER_POINT            ( -- n ) 2 0 shift ; inline
+: D3DX_FILTER_LINEAR           ( -- n ) 3 0 shift ; inline
+: D3DX_FILTER_TRIANGLE         ( -- n ) 4 0 shift ; inline
+: D3DX_FILTER_BOX              ( -- n ) 5 0 shift ; inline
+
+: D3DX_FILTER_MIRROR_U         ( -- n ) 1 16 shift ; inline
+: D3DX_FILTER_MIRROR_V         ( -- n ) 2 16 shift ; inline
+: D3DX_FILTER_MIRROR_W         ( -- n ) 4 16 shift ; inline
+: D3DX_FILTER_MIRROR           ( -- n ) 7 16 shift ; inline
+
+: D3DX_FILTER_DITHER           ( -- n ) 1 19 shift ; inline
+: D3DX_FILTER_DITHER_DIFFUSION ( -- n ) 2 19 shift ; inline
+
+: D3DX_FILTER_SRGB_IN          ( -- n ) 1 21 shift ; inline
+: D3DX_FILTER_SRGB_OUT         ( -- n ) 2 21 shift ; inline
+: D3DX_FILTER_SRGB             ( -- n ) 3 21 shift ; inline
+
+CONSTANT: D3DX_SKIP_DDS_MIP_LEVELS_MASK   HEX: 1F
+CONSTANT: D3DX_SKIP_DDS_MIP_LEVELS_SHIFT  26
+
+: D3DX_NORMALMAP_MIRROR_U     ( -- n ) 1 16 shift ; inline
+: D3DX_NORMALMAP_MIRROR_V     ( -- n ) 2 16 shift ; inline
+: D3DX_NORMALMAP_MIRROR       ( -- n ) 3 16 shift ; inline
+: D3DX_NORMALMAP_INVERTSIGN   ( -- n ) 8 16 shift ; inline
+: D3DX_NORMALMAP_COMPUTE_OCCLUSION ( -- n ) 16 16 shift ; inline
+
+: D3DX_CHANNEL_RED            ( -- n ) 1 0 shift ; inline
+: D3DX_CHANNEL_BLUE           ( -- n ) 1 1 shift ; inline
+: D3DX_CHANNEL_GREEN          ( -- n ) 1 2 shift ; inline
+: D3DX_CHANNEL_ALPHA          ( -- n ) 1 3 shift ; inline
+: D3DX_CHANNEL_LUMINANCE      ( -- n ) 1 4 shift ; inline
+
+CONSTANT: D3DXIFF_BMP         0
+CONSTANT: D3DXIFF_JPG         1
+CONSTANT: D3DXIFF_TGA         2
+CONSTANT: D3DXIFF_PNG         3
+CONSTANT: D3DXIFF_DDS         4
+CONSTANT: D3DXIFF_PPM         5
+CONSTANT: D3DXIFF_DIB         6
+CONSTANT: D3DXIFF_HDR         7
+CONSTANT: D3DXIFF_PFM         8
+CONSTANT: D3DXIFF_FORCE_DWORD HEX: 7fffffff
+TYPEDEF: int D3DXIMAGE_FILEFORMAT
+
+TYPEDEF: void* LPD3DXFILL2D
+TYPEDEF: void* LPD3DXFILL3D
+
+STRUCT: D3DXIMAGE_INFO
+    { Width                        UINT                 }
+    { Height                       UINT                 }
+    { Depth                        UINT                 }
+    { MipLevels                    UINT                 }
+    { Format                       D3DFORMAT            }
+    { ResourceType                 D3DRESOURCETYPE      }
+    { ImageFileFormat              D3DXIMAGE_FILEFORMAT } ;
+
+FUNCTION: HRESULT
+    D3DXGetImageInfoFromFileA (
+        LPCSTR                    pSrcFile,
+        D3DXIMAGE_INFO*           pSrcInfo ) ;
+
+FUNCTION: HRESULT
+    D3DXGetImageInfoFromFileW (
+        LPCWSTR                   pSrcFile,
+        D3DXIMAGE_INFO*           pSrcInfo ) ;
+
+ALIAS: D3DXGetImageInfoFromFile D3DXGetImageInfoFromFileW
+
+FUNCTION: HRESULT
+    D3DXGetImageInfoFromResourceA (
+        HMODULE                   hSrcModule,
+        LPCSTR                    pSrcResource,
+        D3DXIMAGE_INFO*           pSrcInfo ) ;
+
+FUNCTION: HRESULT
+    D3DXGetImageInfoFromResourceW (
+        HMODULE                   hSrcModule,
+        LPCWSTR                   pSrcResource,
+        D3DXIMAGE_INFO*           pSrcInfo ) ;
+
+ALIAS: D3DXGetImageInfoFromResource D3DXGetImageInfoFromResourceW
+
+FUNCTION: HRESULT
+    D3DXGetImageInfoFromFileInMemory (
+        LPCVOID                   pSrcData,
+        UINT                      SrcDataSize,
+        D3DXIMAGE_INFO*           pSrcInfo ) ;
+
+FUNCTION: HRESULT
+    D3DXLoadSurfaceFromFileA (
+        LPDIRECT3DSURFACE9        pDestSurface,
+        PALETTEENTRY*             pDestPalette,
+        RECT*                     pDestRect,
+        LPCSTR                    pSrcFile,
+        RECT*                     pSrcRect,
+        DWORD                     Filter,
+        D3DCOLOR                  ColorKey,
+        D3DXIMAGE_INFO*           pSrcInfo ) ;
+
+FUNCTION: HRESULT
+    D3DXLoadSurfaceFromFileW (
+        LPDIRECT3DSURFACE9        pDestSurface,
+        PALETTEENTRY*             pDestPalette,
+        RECT*                     pDestRect,
+        LPCWSTR                   pSrcFile,
+        RECT*                     pSrcRect,
+        DWORD                     Filter,
+        D3DCOLOR                  ColorKey,
+        D3DXIMAGE_INFO*           pSrcInfo ) ;
+        
+ALIAS: D3DXLoadSurfaceFromFile D3DXLoadSurfaceFromFileW
+
+FUNCTION: HRESULT
+    D3DXLoadSurfaceFromResourceA (
+        LPDIRECT3DSURFACE9        pDestSurface,
+        PALETTEENTRY*             pDestPalette,
+        RECT*                     pDestRect,
+        HMODULE                   hSrcModule,
+        LPCSTR                    pSrcResource,
+        RECT*                     pSrcRect,
+        DWORD                     Filter,
+        D3DCOLOR                  ColorKey,
+        D3DXIMAGE_INFO*           pSrcInfo ) ;
+
+FUNCTION: HRESULT
+    D3DXLoadSurfaceFromResourceW (
+        LPDIRECT3DSURFACE9        pDestSurface,
+        PALETTEENTRY*             pDestPalette,
+        RECT*                     pDestRect,
+        HMODULE                   hSrcModule,
+        LPCWSTR                   pSrcResource,
+        RECT*                     pSrcRect,
+        DWORD                     Filter,
+        D3DCOLOR                  ColorKey,
+        D3DXIMAGE_INFO*           pSrcInfo ) ;
+
+ALIAS: D3DXLoadSurfaceFromResource D3DXLoadSurfaceFromResourceW
+
+FUNCTION: HRESULT
+    D3DXLoadSurfaceFromFileInMemory (
+        LPDIRECT3DSURFACE9        pDestSurface,
+        PALETTEENTRY*             pDestPalette,
+        RECT*                     pDestRect,
+        LPCVOID                   pSrcData,
+        UINT                      SrcDataSize,
+        RECT*                     pSrcRect,
+        DWORD                     Filter,
+        D3DCOLOR                  ColorKey,
+        D3DXIMAGE_INFO*           pSrcInfo ) ;
+
+FUNCTION: HRESULT
+    D3DXLoadSurfaceFromSurface (
+        LPDIRECT3DSURFACE9        pDestSurface,
+        PALETTEENTRY*             pDestPalette,
+        RECT*                     pDestRect,
+        LPDIRECT3DSURFACE9        pSrcSurface,
+        PALETTEENTRY*             pSrcPalette,
+        RECT*                     pSrcRect,
+        DWORD                     Filter,
+        D3DCOLOR                  ColorKey ) ;
+        
+FUNCTION: HRESULT
+    D3DXLoadSurfaceFromMemory (
+        LPDIRECT3DSURFACE9        pDestSurface,
+        PALETTEENTRY*             pDestPalette,
+        RECT*                     pDestRect,
+        LPCVOID                   pSrcMemory,
+        D3DFORMAT                 SrcFormat,
+        UINT                      SrcPitch,
+        PALETTEENTRY*             pSrcPalette,
+        RECT*                     pSrcRect,
+        DWORD                     Filter,
+        D3DCOLOR                  ColorKey ) ;
+
+FUNCTION: HRESULT
+    D3DXSaveSurfaceToFileA (
+        LPCSTR                    pDestFile,
+        D3DXIMAGE_FILEFORMAT      DestFormat,
+        LPDIRECT3DSURFACE9        pSrcSurface,
+        PALETTEENTRY*             pSrcPalette,
+        RECT*                     pSrcRect ) ;
+
+FUNCTION: HRESULT
+    D3DXSaveSurfaceToFileW (
+        LPCWSTR                   pDestFile,
+        D3DXIMAGE_FILEFORMAT      DestFormat,
+        LPDIRECT3DSURFACE9        pSrcSurface,
+        PALETTEENTRY*             pSrcPalette,
+        RECT*                     pSrcRect ) ;
+
+ALIAS: D3DXSaveSurfaceToFile D3DXSaveSurfaceToFileW
+
+FUNCTION: HRESULT
+    D3DXSaveSurfaceToFileInMemory (
+        LPD3DXBUFFER*             ppDestBuf,
+        D3DXIMAGE_FILEFORMAT      DestFormat,
+        LPDIRECT3DSURFACE9        pSrcSurface,
+        PALETTEENTRY*             pSrcPalette,
+        RECT*                     pSrcRect ) ;
+
+FUNCTION: HRESULT
+    D3DXLoadVolumeFromFileA (
+        LPDIRECT3DVOLUME9         pDestVolume,
+        PALETTEENTRY*             pDestPalette,
+        D3DBOX*                   pDestBox,
+        LPCSTR                    pSrcFile,
+        D3DBOX*                   pSrcBox,
+        DWORD                     Filter,
+        D3DCOLOR                  ColorKey,
+        D3DXIMAGE_INFO*           pSrcInfo ) ;
+        
+FUNCTION: HRESULT
+    D3DXLoadVolumeFromFileW (
+        LPDIRECT3DVOLUME9         pDestVolume,
+        PALETTEENTRY*             pDestPalette,
+        D3DBOX*                   pDestBox,
+        LPCWSTR                   pSrcFile,
+        D3DBOX*                   pSrcBox,
+        DWORD                     Filter,
+        D3DCOLOR                  ColorKey,
+        D3DXIMAGE_INFO*           pSrcInfo ) ;
+
+ALIAS: D3DXLoadVolumeFromFile D3DXLoadVolumeFromFileW
+
+FUNCTION: HRESULT
+    D3DXLoadVolumeFromResourceA (
+        LPDIRECT3DVOLUME9         pDestVolume,
+        PALETTEENTRY*             pDestPalette,
+        D3DBOX*                   pDestBox,
+        HMODULE                   hSrcModule,
+        LPCSTR                    pSrcResource,
+        D3DBOX*                   pSrcBox,
+        DWORD                     Filter,
+        D3DCOLOR                  ColorKey,
+        D3DXIMAGE_INFO*           pSrcInfo ) ;
+
+FUNCTION: HRESULT
+    D3DXLoadVolumeFromResourceW (
+        LPDIRECT3DVOLUME9         pDestVolume,
+        PALETTEENTRY*             pDestPalette,
+        D3DBOX*                   pDestBox,
+        HMODULE                   hSrcModule,
+        LPCWSTR                   pSrcResource,
+        D3DBOX*                   pSrcBox,
+        DWORD                     Filter,
+        D3DCOLOR                  ColorKey,
+        D3DXIMAGE_INFO*           pSrcInfo ) ;
+
+ALIAS: D3DXLoadVolumeFromResource D3DXLoadVolumeFromResourceW
+
+FUNCTION: HRESULT
+    D3DXLoadVolumeFromFileInMemory (
+        LPDIRECT3DVOLUME9         pDestVolume,
+        PALETTEENTRY*             pDestPalette,
+        D3DBOX*                   pDestBox,
+        LPCVOID                   pSrcData,
+        UINT                      SrcDataSize,
+        D3DBOX*                   pSrcBox,
+        DWORD                     Filter,
+        D3DCOLOR                  ColorKey,
+        D3DXIMAGE_INFO*           pSrcInfo ) ;
+
+FUNCTION: HRESULT
+    D3DXLoadVolumeFromVolume (
+        LPDIRECT3DVOLUME9         pDestVolume,
+        PALETTEENTRY*             pDestPalette,
+        D3DBOX*                   pDestBox,
+        LPDIRECT3DVOLUME9         pSrcVolume,
+        PALETTEENTRY*             pSrcPalette,
+        D3DBOX*                   pSrcBox,
+        DWORD                     Filter,
+        D3DCOLOR                  ColorKey ) ;
+        
+FUNCTION: HRESULT
+    D3DXLoadVolumeFromMemory (
+        LPDIRECT3DVOLUME9         pDestVolume,
+        PALETTEENTRY*             pDestPalette,
+        D3DBOX*                   pDestBox,
+        LPCVOID                   pSrcMemory,
+        D3DFORMAT                 SrcFormat,
+        UINT                      SrcRowPitch,
+        UINT                      SrcSlicePitch,
+        PALETTEENTRY*             pSrcPalette,
+        D3DBOX*                   pSrcBox,
+        DWORD                     Filter,
+        D3DCOLOR                  ColorKey ) ;
+
+FUNCTION: HRESULT
+    D3DXSaveVolumeToFileA (
+        LPCSTR                    pDestFile,
+        D3DXIMAGE_FILEFORMAT      DestFormat,
+        LPDIRECT3DVOLUME9         pSrcVolume,
+        PALETTEENTRY*             pSrcPalette,
+        D3DBOX*                   pSrcBox ) ;
+
+FUNCTION: HRESULT
+    D3DXSaveVolumeToFileW (
+        LPCWSTR                   pDestFile,
+        D3DXIMAGE_FILEFORMAT      DestFormat,
+        LPDIRECT3DVOLUME9         pSrcVolume,
+        PALETTEENTRY*             pSrcPalette,
+        D3DBOX*                   pSrcBox ) ;
+
+ALIAS: D3DXSaveVolumeToFile D3DXSaveVolumeToFileW
+
+FUNCTION: HRESULT
+    D3DXSaveVolumeToFileInMemory (
+        LPD3DXBUFFER*             ppDestBuf,
+        D3DXIMAGE_FILEFORMAT      DestFormat,
+        LPDIRECT3DVOLUME9         pSrcVolume,
+        PALETTEENTRY*             pSrcPalette,
+        D3DBOX*                   pSrcBox ) ;
+
+FUNCTION: HRESULT
+    D3DXCheckTextureRequirements (
+        LPDIRECT3DDEVICE9         pDevice,
+        UINT*                     pWidth,
+        UINT*                     pHeight,
+        UINT*                     pNumMipLevels,
+        DWORD                     Usage,
+        D3DFORMAT*                pFormat,
+        D3DPOOL                   Pool ) ;
+
+FUNCTION: HRESULT
+    D3DXCheckCubeTextureRequirements (
+        LPDIRECT3DDEVICE9         pDevice,
+        UINT*                     pSize,
+        UINT*                     pNumMipLevels,
+        DWORD                     Usage,
+        D3DFORMAT*                pFormat,
+        D3DPOOL                   Pool ) ;
+
+FUNCTION: HRESULT
+    D3DXCheckVolumeTextureRequirements (
+        LPDIRECT3DDEVICE9         pDevice,
+        UINT*                     pWidth,
+        UINT*                     pHeight,
+        UINT*                     pDepth,
+        UINT*                     pNumMipLevels,
+        DWORD                     Usage,
+        D3DFORMAT*                pFormat,
+        D3DPOOL                   Pool ) ;
+
+FUNCTION: HRESULT
+    D3DXCreateTexture (
+        LPDIRECT3DDEVICE9         pDevice,
+        UINT                      Width,
+        UINT                      Height,
+        UINT                      MipLevels,
+        DWORD                     Usage,
+        D3DFORMAT                 Format,
+        D3DPOOL                   Pool,
+        LPDIRECT3DTEXTURE9*       ppTexture ) ;
+
+FUNCTION: HRESULT
+    D3DXCreateCubeTexture (
+        LPDIRECT3DDEVICE9         pDevice,
+        UINT                      Size,
+        UINT                      MipLevels,
+        DWORD                     Usage,
+        D3DFORMAT                 Format,
+        D3DPOOL                   Pool,
+        LPDIRECT3DCUBETEXTURE9*   ppCubeTexture ) ;
+
+FUNCTION: HRESULT
+    D3DXCreateVolumeTexture (
+        LPDIRECT3DDEVICE9         pDevice,
+        UINT                      Width,
+        UINT                      Height,
+        UINT                      Depth,
+        UINT                      MipLevels,
+        DWORD                     Usage,
+        D3DFORMAT                 Format,
+        D3DPOOL                   Pool,
+        LPDIRECT3DVOLUMETEXTURE9* ppVolumeTexture ) ;
+
+FUNCTION: HRESULT
+    D3DXCreateTextureFromFileA (
+        LPDIRECT3DDEVICE9         pDevice,
+        LPCSTR                    pSrcFile,
+        LPDIRECT3DTEXTURE9*       ppTexture ) ;
+
+FUNCTION: HRESULT
+    D3DXCreateTextureFromFileW (
+        LPDIRECT3DDEVICE9         pDevice,
+        LPCWSTR                   pSrcFile,
+        LPDIRECT3DTEXTURE9*       ppTexture ) ;
+
+ALIAS: D3DXCreateTextureFromFile D3DXCreateTextureFromFileW
+
+FUNCTION: HRESULT
+    D3DXCreateCubeTextureFromFileA (
+        LPDIRECT3DDEVICE9         pDevice,
+        LPCSTR                    pSrcFile,
+        LPDIRECT3DCUBETEXTURE9*   ppCubeTexture ) ;
+
+FUNCTION: HRESULT
+    D3DXCreateCubeTextureFromFileW (
+        LPDIRECT3DDEVICE9         pDevice,
+        LPCWSTR                   pSrcFile,
+        LPDIRECT3DCUBETEXTURE9*   ppCubeTexture ) ;
+
+ALIAS: D3DXCreateCubeTextureFromFile D3DXCreateCubeTextureFromFileW
+
+FUNCTION: HRESULT
+    D3DXCreateVolumeTextureFromFileA (
+        LPDIRECT3DDEVICE9         pDevice,
+        LPCSTR                    pSrcFile,
+        LPDIRECT3DVOLUMETEXTURE9* ppVolumeTexture ) ;
+
+FUNCTION: HRESULT
+    D3DXCreateVolumeTextureFromFileW (
+        LPDIRECT3DDEVICE9         pDevice,
+        LPCWSTR                   pSrcFile,
+        LPDIRECT3DVOLUMETEXTURE9* ppVolumeTexture ) ;
+
+ALIAS: D3DXCreateVolumeTextureFromFile D3DXCreateVolumeTextureFromFileW
+
+FUNCTION: HRESULT
+    D3DXCreateTextureFromResourceA (
+        LPDIRECT3DDEVICE9         pDevice,
+        HMODULE                   hSrcModule,
+        LPCSTR                    pSrcResource,
+        LPDIRECT3DTEXTURE9*       ppTexture ) ;
+
+FUNCTION: HRESULT
+    D3DXCreateTextureFromResourceW (
+        LPDIRECT3DDEVICE9         pDevice,
+        HMODULE                   hSrcModule,
+        LPCWSTR                   pSrcResource,
+        LPDIRECT3DTEXTURE9*       ppTexture ) ;
+
+ALIAS: D3DXCreateTextureFromResource D3DXCreateTextureFromResourceW
+
+FUNCTION: HRESULT
+    D3DXCreateCubeTextureFromResourceA (
+        LPDIRECT3DDEVICE9         pDevice,
+        HMODULE                   hSrcModule,
+        LPCSTR                    pSrcResource,
+        LPDIRECT3DCUBETEXTURE9*   ppCubeTexture ) ;
+
+FUNCTION: HRESULT
+    D3DXCreateCubeTextureFromResourceW (
+        LPDIRECT3DDEVICE9         pDevice,
+        HMODULE                   hSrcModule,
+        LPCWSTR                   pSrcResource,
+        LPDIRECT3DCUBETEXTURE9*   ppCubeTexture ) ;
+
+ALIAS: D3DXCreateCubeTextureFromResource D3DXCreateCubeTextureFromResourceW
+
+FUNCTION: HRESULT
+    D3DXCreateVolumeTextureFromResourceA (
+        LPDIRECT3DDEVICE9         pDevice,
+        HMODULE                   hSrcModule,
+        LPCSTR                    pSrcResource,
+        LPDIRECT3DVOLUMETEXTURE9* ppVolumeTexture ) ;
+
+FUNCTION: HRESULT
+    D3DXCreateVolumeTextureFromResourceW (
+        LPDIRECT3DDEVICE9         pDevice,
+        HMODULE                   hSrcModule,
+        LPCWSTR                   pSrcResource,
+        LPDIRECT3DVOLUMETEXTURE9* ppVolumeTexture ) ;
+
+ALIAS: D3DXCreateVolumeTextureFromResource D3DXCreateVolumeTextureFromResourceW
+
+FUNCTION: HRESULT
+    D3DXCreateTextureFromFileExA (
+        LPDIRECT3DDEVICE9         pDevice,
+        LPCSTR                    pSrcFile,
+        UINT                      Width,
+        UINT                      Height,
+        UINT                      MipLevels,
+        DWORD                     Usage,
+        D3DFORMAT                 Format,
+        D3DPOOL                   Pool,
+        DWORD                     Filter,
+        DWORD                     MipFilter,
+        D3DCOLOR                  ColorKey,
+        D3DXIMAGE_INFO*           pSrcInfo,
+        PALETTEENTRY*             pPalette,
+        LPDIRECT3DTEXTURE9*       ppTexture ) ;
+
+FUNCTION: HRESULT
+    D3DXCreateTextureFromFileExW (
+        LPDIRECT3DDEVICE9         pDevice,
+        LPCWSTR                   pSrcFile,
+        UINT                      Width,
+        UINT                      Height,
+        UINT                      MipLevels,
+        DWORD                     Usage,
+        D3DFORMAT                 Format,
+        D3DPOOL                   Pool,
+        DWORD                     Filter,
+        DWORD                     MipFilter,
+        D3DCOLOR                  ColorKey,
+        D3DXIMAGE_INFO*           pSrcInfo,
+        PALETTEENTRY*             pPalette,
+        LPDIRECT3DTEXTURE9*       ppTexture ) ;
+
+ALIAS: D3DXCreateTextureFromFileEx D3DXCreateTextureFromFileExW
+
+FUNCTION: HRESULT
+    D3DXCreateCubeTextureFromFileExA (
+        LPDIRECT3DDEVICE9         pDevice,
+        LPCSTR                    pSrcFile,
+        UINT                      Size,
+        UINT                      MipLevels,
+        DWORD                     Usage,
+        D3DFORMAT                 Format,
+        D3DPOOL                   Pool,
+        DWORD                     Filter,
+        DWORD                     MipFilter,
+        D3DCOLOR                  ColorKey,
+        D3DXIMAGE_INFO*           pSrcInfo,
+        PALETTEENTRY*             pPalette,
+        LPDIRECT3DCUBETEXTURE9*   ppCubeTexture ) ;
+
+FUNCTION: HRESULT
+    D3DXCreateCubeTextureFromFileExW (
+        LPDIRECT3DDEVICE9         pDevice,
+        LPCWSTR                   pSrcFile,
+        UINT                      Size,
+        UINT                      MipLevels,
+        DWORD                     Usage,
+        D3DFORMAT                 Format,
+        D3DPOOL                   Pool,
+        DWORD                     Filter,
+        DWORD                     MipFilter,
+        D3DCOLOR                  ColorKey,
+        D3DXIMAGE_INFO*           pSrcInfo,
+        PALETTEENTRY*             pPalette,
+        LPDIRECT3DCUBETEXTURE9*   ppCubeTexture ) ;
+
+ALIAS: D3DXCreateCubeTextureFromFileEx D3DXCreateCubeTextureFromFileExW
+
+FUNCTION: HRESULT
+    D3DXCreateVolumeTextureFromFileExA (
+        LPDIRECT3DDEVICE9         pDevice,
+        LPCSTR                    pSrcFile,
+        UINT                      Width,
+        UINT                      Height,
+        UINT                      Depth,
+        UINT                      MipLevels,
+        DWORD                     Usage,
+        D3DFORMAT                 Format,
+        D3DPOOL                   Pool,
+        DWORD                     Filter,
+        DWORD                     MipFilter,
+        D3DCOLOR                  ColorKey,
+        D3DXIMAGE_INFO*           pSrcInfo,
+        PALETTEENTRY*             pPalette,
+        LPDIRECT3DVOLUMETEXTURE9* ppVolumeTexture ) ;
+
+FUNCTION: HRESULT
+    D3DXCreateVolumeTextureFromFileExW (
+        LPDIRECT3DDEVICE9         pDevice,
+        LPCWSTR                   pSrcFile,
+        UINT                      Width,
+        UINT                      Height,
+        UINT                      Depth,
+        UINT                      MipLevels,
+        DWORD                     Usage,
+        D3DFORMAT                 Format,
+        D3DPOOL                   Pool,
+        DWORD                     Filter,
+        DWORD                     MipFilter,
+        D3DCOLOR                  ColorKey,
+        D3DXIMAGE_INFO*           pSrcInfo,
+        PALETTEENTRY*             pPalette,
+        LPDIRECT3DVOLUMETEXTURE9* ppVolumeTexture ) ;
+
+ALIAS: D3DXCreateVolumeTextureFromFileEx D3DXCreateVolumeTextureFromFileExW
+
+FUNCTION: HRESULT
+    D3DXCreateTextureFromResourceExA (
+        LPDIRECT3DDEVICE9         pDevice,
+        HMODULE                   hSrcModule,
+        LPCSTR                    pSrcResource,
+        UINT                      Width,
+        UINT                      Height,
+        UINT                      MipLevels,
+        DWORD                     Usage,
+        D3DFORMAT                 Format,
+        D3DPOOL                   Pool,
+        DWORD                     Filter,
+        DWORD                     MipFilter,
+        D3DCOLOR                  ColorKey,
+        D3DXIMAGE_INFO*           pSrcInfo,
+        PALETTEENTRY*             pPalette,
+        LPDIRECT3DTEXTURE9*       ppTexture ) ;
+
+FUNCTION: HRESULT
+    D3DXCreateTextureFromResourceExW (
+        LPDIRECT3DDEVICE9         pDevice,
+        HMODULE                   hSrcModule,
+        LPCWSTR                   pSrcResource,
+        UINT                      Width,
+        UINT                      Height,
+        UINT                      MipLevels,
+        DWORD                     Usage,
+        D3DFORMAT                 Format,
+        D3DPOOL                   Pool,
+        DWORD                     Filter,
+        DWORD                     MipFilter,
+        D3DCOLOR                  ColorKey,
+        D3DXIMAGE_INFO*           pSrcInfo,
+        PALETTEENTRY*             pPalette,
+        LPDIRECT3DTEXTURE9*       ppTexture ) ;
+
+ALIAS: D3DXCreateTextureFromResourceEx D3DXCreateTextureFromResourceExW
+
+FUNCTION: HRESULT
+    D3DXCreateCubeTextureFromResourceExA (
+        LPDIRECT3DDEVICE9         pDevice,
+        HMODULE                   hSrcModule,
+        LPCSTR                    pSrcResource,
+        UINT                      Size,
+        UINT                      MipLevels,
+        DWORD                     Usage,
+        D3DFORMAT                 Format,
+        D3DPOOL                   Pool,
+        DWORD                     Filter,
+        DWORD                     MipFilter,
+        D3DCOLOR                  ColorKey,
+        D3DXIMAGE_INFO*           pSrcInfo,
+        PALETTEENTRY*             pPalette,
+        LPDIRECT3DCUBETEXTURE9*   ppCubeTexture ) ;
+
+FUNCTION: HRESULT
+    D3DXCreateCubeTextureFromResourceExW (
+        LPDIRECT3DDEVICE9         pDevice,
+        HMODULE                   hSrcModule,
+        LPCWSTR                   pSrcResource,
+        UINT                      Size,
+        UINT                      MipLevels,
+        DWORD                     Usage,
+        D3DFORMAT                 Format,
+        D3DPOOL                   Pool,
+        DWORD                     Filter,
+        DWORD                     MipFilter,
+        D3DCOLOR                  ColorKey,
+        D3DXIMAGE_INFO*           pSrcInfo,
+        PALETTEENTRY*             pPalette,
+        LPDIRECT3DCUBETEXTURE9*   ppCubeTexture ) ;
+
+ALIAS: D3DXCreateCubeTextureFromResourceEx D3DXCreateCubeTextureFromResourceExW
+
+FUNCTION: HRESULT
+    D3DXCreateVolumeTextureFromResourceExA (
+        LPDIRECT3DDEVICE9         pDevice,
+        HMODULE                   hSrcModule,
+        LPCSTR                    pSrcResource,
+        UINT                      Width,
+        UINT                      Height,
+        UINT                      Depth,
+        UINT                      MipLevels,
+        DWORD                     Usage,
+        D3DFORMAT                 Format,
+        D3DPOOL                   Pool,
+        DWORD                     Filter,
+        DWORD                     MipFilter,
+        D3DCOLOR                  ColorKey,
+        D3DXIMAGE_INFO*           pSrcInfo,
+        PALETTEENTRY*             pPalette,
+        LPDIRECT3DVOLUMETEXTURE9* ppVolumeTexture ) ;
+
+FUNCTION: HRESULT
+    D3DXCreateVolumeTextureFromResourceExW (
+        LPDIRECT3DDEVICE9         pDevice,
+        HMODULE                   hSrcModule,
+        LPCWSTR                   pSrcResource,
+        UINT                      Width,
+        UINT                      Height,
+        UINT                      Depth,
+        UINT                      MipLevels,
+        DWORD                     Usage,
+        D3DFORMAT                 Format,
+        D3DPOOL                   Pool,
+        DWORD                     Filter,
+        DWORD                     MipFilter,
+        D3DCOLOR                  ColorKey,
+        D3DXIMAGE_INFO*           pSrcInfo,
+        PALETTEENTRY*             pPalette,
+        LPDIRECT3DVOLUMETEXTURE9* ppVolumeTexture ) ;
+
+ALIAS: D3DXCreateVolumeTextureFromResourceEx D3DXCreateVolumeTextureFromResourceExW
+
+FUNCTION: HRESULT
+    D3DXCreateTextureFromFileInMemory (
+        LPDIRECT3DDEVICE9         pDevice,
+        LPCVOID                   pSrcData,
+        UINT                      SrcDataSize,
+        LPDIRECT3DTEXTURE9*       ppTexture ) ;
+
+FUNCTION: HRESULT
+    D3DXCreateCubeTextureFromFileInMemory (
+        LPDIRECT3DDEVICE9         pDevice,
+        LPCVOID                   pSrcData,
+        UINT                      SrcDataSize,
+        LPDIRECT3DCUBETEXTURE9*   ppCubeTexture ) ;
+
+FUNCTION: HRESULT
+    D3DXCreateVolumeTextureFromFileInMemory (
+        LPDIRECT3DDEVICE9         pDevice,
+        LPCVOID                   pSrcData,
+        UINT                      SrcDataSize,
+        LPDIRECT3DVOLUMETEXTURE9* ppVolumeTexture ) ;
+
+FUNCTION: HRESULT
+    D3DXCreateTextureFromFileInMemoryEx (
+        LPDIRECT3DDEVICE9         pDevice,
+        LPCVOID                   pSrcData,
+        UINT                      SrcDataSize,
+        UINT                      Width,
+        UINT                      Height,
+        UINT                      MipLevels,
+        DWORD                     Usage,
+        D3DFORMAT                 Format,
+        D3DPOOL                   Pool,
+        DWORD                     Filter,
+        DWORD                     MipFilter,
+        D3DCOLOR                  ColorKey,
+        D3DXIMAGE_INFO*           pSrcInfo,
+        PALETTEENTRY*             pPalette,
+        LPDIRECT3DTEXTURE9*       ppTexture ) ;
+
+FUNCTION: HRESULT
+    D3DXCreateCubeTextureFromFileInMemoryEx (
+        LPDIRECT3DDEVICE9         pDevice,
+        LPCVOID                   pSrcData,
+        UINT                      SrcDataSize,
+        UINT                      Size,
+        UINT                      MipLevels,
+        DWORD                     Usage,
+        D3DFORMAT                 Format,
+        D3DPOOL                   Pool,
+        DWORD                     Filter,
+        DWORD                     MipFilter,
+        D3DCOLOR                  ColorKey,
+        D3DXIMAGE_INFO*           pSrcInfo,
+        PALETTEENTRY*             pPalette,
+        LPDIRECT3DCUBETEXTURE9*   ppCubeTexture ) ;
+
+FUNCTION: HRESULT
+    D3DXCreateVolumeTextureFromFileInMemoryEx (
+        LPDIRECT3DDEVICE9         pDevice,
+        LPCVOID                   pSrcData,
+        UINT                      SrcDataSize,
+        UINT                      Width,
+        UINT                      Height,
+        UINT                      Depth,
+        UINT                      MipLevels,
+        DWORD                     Usage,
+        D3DFORMAT                 Format,
+        D3DPOOL                   Pool,
+        DWORD                     Filter,
+        DWORD                     MipFilter,
+        D3DCOLOR                  ColorKey,
+        D3DXIMAGE_INFO*           pSrcInfo,
+        PALETTEENTRY*             pPalette,
+        LPDIRECT3DVOLUMETEXTURE9* ppVolumeTexture ) ;
+
+FUNCTION: HRESULT
+    D3DXSaveTextureToFileA (
+        LPCSTR                    pDestFile,
+        D3DXIMAGE_FILEFORMAT      DestFormat,
+        LPDIRECT3DBASETEXTURE9    pSrcTexture,
+        PALETTEENTRY*             pSrcPalette ) ;
+
+FUNCTION: HRESULT
+    D3DXSaveTextureToFileW (
+        LPCWSTR                   pDestFile,
+        D3DXIMAGE_FILEFORMAT      DestFormat,
+        LPDIRECT3DBASETEXTURE9    pSrcTexture,
+        PALETTEENTRY*             pSrcPalette ) ;
+
+ALIAS: D3DXSaveTextureToFile D3DXSaveTextureToFileW
+
+FUNCTION: HRESULT
+    D3DXSaveTextureToFileInMemory (
+        LPD3DXBUFFER*             ppDestBuf,
+        D3DXIMAGE_FILEFORMAT      DestFormat,
+        LPDIRECT3DBASETEXTURE9    pSrcTexture,
+        PALETTEENTRY*             pSrcPalette ) ;
+
+FUNCTION: HRESULT
+    D3DXFilterTexture (
+        LPDIRECT3DBASETEXTURE9    pBaseTexture,
+        PALETTEENTRY*             pPalette,
+        UINT                      SrcLevel,
+        DWORD                     Filter ) ;
+
+ALIAS: D3DXFilterCubeTexture D3DXFilterTexture
+ALIAS: D3DXFilterVolumeTexture D3DXFilterTexture
+
+FUNCTION: HRESULT
+    D3DXFillTexture (
+        LPDIRECT3DTEXTURE9        pTexture,
+        LPD3DXFILL2D              pFunction,
+        LPVOID                    pData ) ;
+
+FUNCTION: HRESULT
+    D3DXFillCubeTexture (
+        LPDIRECT3DCUBETEXTURE9    pCubeTexture,
+        LPD3DXFILL3D              pFunction,
+        LPVOID                    pData ) ;
+
+FUNCTION: HRESULT
+    D3DXFillVolumeTexture (
+        LPDIRECT3DVOLUMETEXTURE9  pVolumeTexture,
+        LPD3DXFILL3D              pFunction,
+        LPVOID                    pData ) ;
+
+FUNCTION: HRESULT
+    D3DXFillTextureTX (
+        LPDIRECT3DTEXTURE9        pTexture,
+        LPD3DXTEXTURESHADER       pTextureShader ) ;
+
+FUNCTION: HRESULT
+    D3DXFillCubeTextureTX (
+        LPDIRECT3DCUBETEXTURE9    pCubeTexture,
+        LPD3DXTEXTURESHADER       pTextureShader ) ;
+
+
+FUNCTION: HRESULT
+    D3DXFillVolumeTextureTX (
+        LPDIRECT3DVOLUMETEXTURE9  pVolumeTexture,
+        LPD3DXTEXTURESHADER       pTextureShader ) ;
+
+FUNCTION: HRESULT
+    D3DXComputeNormalMap (
+        LPDIRECT3DTEXTURE9        pTexture,
+        LPDIRECT3DTEXTURE9        pSrcTexture,
+        PALETTEENTRY*       pSrcPalette,
+        DWORD                     Flags,
+        DWORD                     Channel,
+        FLOAT                     Amplitude ) ;
diff --git a/basis/windows/directx/d3dx9tex/summary.txt b/basis/windows/directx/d3dx9tex/summary.txt
new file mode 100644 (file)
index 0000000..b714b21
--- /dev/null
@@ -0,0 +1 @@
+DirectX 9 texture library bindings. Corresponds to d3dx9tex.h.
diff --git a/basis/windows/directx/d3dx9tex/tags.txt b/basis/windows/directx/d3dx9tex/tags.txt
new file mode 100644 (file)
index 0000000..2320bdd
--- /dev/null
@@ -0,0 +1,2 @@
+unportable
+bindings
diff --git a/basis/windows/directx/d3dx9xof/authors.txt b/basis/windows/directx/d3dx9xof/authors.txt
new file mode 100644 (file)
index 0000000..6f03a12
--- /dev/null
@@ -0,0 +1 @@
+Erik Charlebois
diff --git a/basis/windows/directx/d3dx9xof/d3dx9xof.factor b/basis/windows/directx/d3dx9xof/d3dx9xof.factor
new file mode 100644 (file)
index 0000000..bd55854
--- /dev/null
@@ -0,0 +1,111 @@
+USING: alien.syntax classes.struct windows.com
+windows.com.syntax windows.kernel32 windows.ole32 windows.types ;
+IN: windows.directx.d3dx9xof
+
+LIBRARY: d3dx9
+
+TYPEDEF: DWORD D3DXF_FILEFORMAT
+
+CONSTANT: D3DXF_FILEFORMAT_BINARY          0
+CONSTANT: D3DXF_FILEFORMAT_TEXT            1
+CONSTANT: D3DXF_FILEFORMAT_COMPRESSED      2
+
+TYPEDEF: DWORD D3DXF_FILESAVEOPTIONS
+
+CONSTANT: D3DXF_FILESAVE_TOFILE     0
+CONSTANT: D3DXF_FILESAVE_TOWFILE    1
+
+TYPEDEF: DWORD D3DXF_FILELOADOPTIONS
+
+CONSTANT: D3DXF_FILELOAD_FROMFILE     0
+CONSTANT: D3DXF_FILELOAD_FROMWFILE    1
+CONSTANT: D3DXF_FILELOAD_FROMRESOURCE 2
+CONSTANT: D3DXF_FILELOAD_FROMMEMORY   3
+
+STRUCT: D3DXF_FILELOADRESOURCE
+    { hModule HMODULE }
+    { lpName  LPCSTR  }
+    { lpType  LPCSTR  } ;
+
+STRUCT: D3DXF_FILELOADMEMORY
+    { lpMemory LPCVOID }
+    { dSize    SIZE_T  } ;
+
+C-TYPE: ID3DXFile
+C-TYPE: ID3DXFileSaveObject
+C-TYPE: ID3DXFileSaveData
+C-TYPE: ID3DXFileEnumObject
+C-TYPE: ID3DXFileData
+
+TYPEDEF: ID3DXFile* LPD3DXFILE
+TYPEDEF: ID3DXFile** LPLPD3DXFILE
+TYPEDEF: ID3DXFileEnumObject* LPD3DXFILEENUMOBJECT
+TYPEDEF: ID3DXFileEnumObject** LPLPD3DXFILEENUMOBJECT
+TYPEDEF: ID3DXFileSaveObject* LPD3DXFILESAVEOBJECT
+TYPEDEF: ID3DXFileSaveObject** LPLPD3DXFILESAVEOBJECT
+TYPEDEF: ID3DXFileData* LPD3DXFILEDATA
+TYPEDEF: ID3DXFileData** LPLPD3DXFILEDATA
+TYPEDEF: ID3DXFileSaveData* LPD3DXFILESAVEDATA
+TYPEDEF: ID3DXFileSaveData** LPLPD3DXFILESAVEDATA
+
+COM-INTERFACE: ID3DXFile IUnknown {cef08cf9-7b4f-4429-9624-2a690a933201}
+    HRESULT CreateEnumObject ( LPCVOID x, D3DXF_FILELOADOPTIONS y,
+        ID3DXFileEnumObject** z )
+    HRESULT CreateSaveObject ( LPCVOID x, D3DXF_FILESAVEOPTIONS y,
+        D3DXF_FILEFORMAT z, ID3DXFileSaveObject** w )
+    HRESULT RegisterTemplates ( LPCVOID x, SIZE_T y )
+    HRESULT RegisterEnumTemplates ( ID3DXFileEnumObject* x ) ;
+
+COM-INTERFACE: ID3DXFileSaveObject IUnknown {cef08cfa-7b4f-4429-9624-2a690a933201}
+    HRESULT GetFile ( ID3DXFile** x )
+    HRESULT AddDataObject ( REFGUID x, LPCSTR y, GUID* z,
+        SIZE_T w, LPCVOID a, ID3DXFileSaveData** b )
+    HRESULT Save ( ) ;
+
+COM-INTERFACE: ID3DXFileSaveData IUnknown {cef08cfb-7b4f-4429-9624-2a690a933201}
+    HRESULT GetSave ( ID3DXFileSaveObject** x )
+    HRESULT GetName ( LPSTR x, SIZE_T* y )
+    HRESULT GetId ( LPGUID x )
+    HRESULT GetType ( GUID* x )
+    HRESULT AddDataObject ( REFGUID x, LPCSTR y, GUID* z,
+        SIZE_T w, LPCVOID a, ID3DXFileSaveData** b )
+    HRESULT AddDataReference ( LPCSTR x, GUID* y ) ;
+
+COM-INTERFACE: ID3DXFileEnumObject IUnknown {cef08cfc-7b4f-4429-9624-2a690a933201}
+    HRESULT GetFile ( ID3DXFile** x )
+    HRESULT GetChildren ( SIZE_T* x )
+    HRESULT GetChild ( SIZE_T x, ID3DXFileData** y )
+    HRESULT GetDataObjectById ( REFGUID x, ID3DXFileData** y )
+    HRESULT GetDataObjectByName ( LPCSTR x, ID3DXFileData** y ) ;
+
+COM-INTERFACE: ID3DXFileData IUnknown {cef08cfd-7b4f-4429-9624-2a690a933201}
+    HRESULT GetEnum ( ID3DXFileEnumObject** x )
+    HRESULT GetName ( LPSTR x, SIZE_T* y )
+    HRESULT GetId ( LPGUID x )
+    HRESULT Lock ( SIZE_T* x, LPCVOID* y )
+    HRESULT Unlock ( )
+    HRESULT GetType ( GUID* x )
+    BOOL IsReference ( )
+    HRESULT GetChildren ( SIZE_T* x )
+    HRESULT GetChild ( SIZE_T x, ID3DXFileData** y ) ;
+
+FUNCTION: HRESULT D3DXFileCreate ( ID3DXFile** lplpDirectXFile ) ;
+
+CONSTANT: D3DXFERR_BADOBJECT              HEX: 88760384
+CONSTANT: D3DXFERR_BADVALUE               HEX: 88760385
+CONSTANT: D3DXFERR_BADTYPE                HEX: 88760386
+CONSTANT: D3DXFERR_NOTFOUND               HEX: 88760387
+CONSTANT: D3DXFERR_NOTDONEYET             HEX: 88760388
+CONSTANT: D3DXFERR_FILENOTFOUND           HEX: 88760389
+CONSTANT: D3DXFERR_RESOURCENOTFOUND       HEX: 8876038A
+CONSTANT: D3DXFERR_BADRESOURCE            HEX: 8876038B
+CONSTANT: D3DXFERR_BADFILETYPE            HEX: 8876038C
+CONSTANT: D3DXFERR_BADFILEVERSION         HEX: 8876038D
+CONSTANT: D3DXFERR_BADFILEFLOATSIZE       HEX: 8876038E
+CONSTANT: D3DXFERR_BADFILE                HEX: 8876038F
+CONSTANT: D3DXFERR_PARSEERROR             HEX: 88760390
+CONSTANT: D3DXFERR_BADARRAYSIZE           HEX: 88760391
+CONSTANT: D3DXFERR_BADDATAREFERENCE       HEX: 88760392
+CONSTANT: D3DXFERR_NOMOREOBJECTS          HEX: 88760393
+CONSTANT: D3DXFERR_NOMOREDATA             HEX: 88760394
+CONSTANT: D3DXFERR_BADCACHEFILE           HEX: 88760395
diff --git a/basis/windows/directx/d3dx9xof/summary.txt b/basis/windows/directx/d3dx9xof/summary.txt
new file mode 100644 (file)
index 0000000..7f88f93
--- /dev/null
@@ -0,0 +1 @@
+File library bindings for DirectX. Corresponds to d3dx9xof.h.
diff --git a/basis/windows/directx/d3dx9xof/tags.txt b/basis/windows/directx/d3dx9xof/tags.txt
new file mode 100644 (file)
index 0000000..2320bdd
--- /dev/null
@@ -0,0 +1,2 @@
+unportable
+bindings
diff --git a/basis/windows/directx/dcommon/authors.txt b/basis/windows/directx/dcommon/authors.txt
new file mode 100644 (file)
index 0000000..6f03a12
--- /dev/null
@@ -0,0 +1 @@
+Erik Charlebois
diff --git a/basis/windows/directx/dcommon/dcommon.factor b/basis/windows/directx/dcommon/dcommon.factor
new file mode 100644 (file)
index 0000000..3b80bd4
--- /dev/null
@@ -0,0 +1,7 @@
+USING: alien.c-types alien.syntax ;
+IN: windows.directx.dcommon
+
+C-ENUM: DWRITE_MEASURING_MODE_NATURAL
+        DWRITE_MEASURING_MODE_GDI_CLASSIC
+        DWRITE_MEASURING_MODE_GDI_NATURAL ;
+TYPEDEF: int DWRITE_MEASURING_MODE
diff --git a/basis/windows/directx/dcommon/summary.txt b/basis/windows/directx/dcommon/summary.txt
new file mode 100644 (file)
index 0000000..902e5fa
--- /dev/null
@@ -0,0 +1 @@
+Common DirectX constants. Corresponds to dcommon.h.
diff --git a/basis/windows/directx/dcommon/tags.txt b/basis/windows/directx/dcommon/tags.txt
new file mode 100644 (file)
index 0000000..2320bdd
--- /dev/null
@@ -0,0 +1,2 @@
+unportable
+bindings
diff --git a/basis/windows/directx/dinput/authors.txt b/basis/windows/directx/dinput/authors.txt
new file mode 100644 (file)
index 0000000..f13c9c1
--- /dev/null
@@ -0,0 +1 @@
+Joe Groff
diff --git a/basis/windows/directx/dinput/constants/constants-tests.factor b/basis/windows/directx/dinput/constants/constants-tests.factor
new file mode 100644 (file)
index 0000000..eceafeb
--- /dev/null
@@ -0,0 +1,5 @@
+IN: windows.directx.dinput.constants.tests
+USING: tools.test windows.directx.dinput.constants.private ;
+
+[ ] [ define-constants ] unit-test
+[ ] [ free-dinput-constants ] unit-test
diff --git a/basis/windows/directx/dinput/constants/constants.factor b/basis/windows/directx/dinput/constants/constants.factor
new file mode 100644 (file)
index 0000000..26f9da0
--- /dev/null
@@ -0,0 +1,853 @@
+USING: windows.directx.dinput windows.kernel32 windows.ole32 windows.com
+windows.com.syntax alien alien.c-types alien.data alien.syntax
+kernel system namespaces combinators sequences fry math accessors
+macros words quotations libc continuations generalizations
+splitting locals assocs init specialized-arrays memoize
+classes.struct strings arrays ;
+SPECIALIZED-ARRAY: DIOBJECTDATAFORMAT
+IN: windows.directx.dinput.constants
+
+! Some global variables aren't provided by the DirectInput DLL (they're in the
+! dinput8.lib import library), so we lovingly hand-craft equivalent values here
+
+SYMBOLS:
+    GUID_XAxis_malloced GUID_YAxis_malloced GUID_ZAxis_malloced
+    GUID_RxAxis_malloced GUID_RyAxis_malloced GUID_RzAxis_malloced
+    GUID_Slider_malloced GUID_Button_malloced GUID_Key_malloced GUID_POV_malloced GUID_Unknown_malloced
+    GUID_SysMouse_malloced GUID_SysKeyboard_malloced GUID_Joystick_malloced GUID_SysMouseEm_malloced
+    GUID_SysMouseEm2_malloced GUID_SysKeyboardEm_malloced GUID_SysKeyboardEm2_malloced
+    c_dfDIKeyboard c_dfDIKeyboard_HID c_dfDIMouse2 c_dfDIJoystick2 ;
+
+<PRIVATE
+
+MEMO: c-type* ( name -- c-type ) c-type ;
+MEMO: heap-size* ( c-type -- n ) heap-size ;
+
+GENERIC: array-base-type ( c-type -- c-type' )
+M: object array-base-type ;
+M: string array-base-type "[" split1 drop ;
+M: array array-base-type first ;
+
+: (field-spec-of) ( field struct -- field-spec )
+    c-type* fields>> [ name>> = ] with find nip ;
+: (offsetof) ( field struct -- offset )
+    [ (field-spec-of) offset>> ] [ drop 0 ] if* ;
+: (sizeof) ( field struct -- size )
+    [ (field-spec-of) type>> array-base-type heap-size* ] [ drop 1 ] if* ;
+
+: (flag) ( thing -- integer )
+    {
+        { [ dup word? ] [ execute( -- value ) ] }
+        { [ dup callable? ] [ call( -- value ) ] }
+        [ ]
+    } cond ;
+
+: (flags) ( array -- n )
+    0 [ (flag) bitor ] reduce ;
+
+: <DIOBJECTDATAFORMAT> ( struct {pguid-var,field,index,dwType-flags,dwFlags} -- alien )
+    {
+        [ first dup word? [ get ] when ]
+        [ second rot [ (offsetof) ] [ (sizeof) ] 2bi ]
+        [ third * + ]
+        [ fourth (flags) ]
+        [ 4 swap nth (flag) ]
+    } cleave
+    DIOBJECTDATAFORMAT <struct-boa> ;
+
+:: make-DIOBJECTDATAFORMAT-array ( struct array -- alien )
+    array length malloc-DIOBJECTDATAFORMAT-array :> alien
+    array [| args i |
+        struct args <DIOBJECTDATAFORMAT>
+        i alien set-nth
+    ] each-index
+    alien ;
+
+: <DIDATAFORMAT> ( dwFlags dwDataSize struct rgodf-array -- alien )
+    [ DIDATAFORMAT heap-size DIOBJECTDATAFORMAT heap-size ] 4 ndip
+    [ nip length ] [ make-DIOBJECTDATAFORMAT-array ] 2bi
+    DIDATAFORMAT <struct-boa> ;
+
+: initialize ( symbol quot -- )
+    call swap set-global ; inline
+
+: (malloc-guid-symbol) ( symbol guid -- )
+    '[
+        _ execute( -- value )
+        [ byte-length malloc ] [ over byte-array>memory ] bi
+    ] initialize ;
+
+: define-guid-constants ( -- )
+    {
+        { GUID_XAxis_malloced          GUID_XAxis }
+        { GUID_YAxis_malloced          GUID_YAxis }
+        { GUID_ZAxis_malloced          GUID_ZAxis }
+        { GUID_RxAxis_malloced         GUID_RxAxis }
+        { GUID_RyAxis_malloced         GUID_RyAxis }
+        { GUID_RzAxis_malloced         GUID_RzAxis }
+        { GUID_Slider_malloced         GUID_Slider }
+        { GUID_Button_malloced         GUID_Button }
+        { GUID_Key_malloced            GUID_Key }
+        { GUID_POV_malloced            GUID_POV }
+        { GUID_Unknown_malloced        GUID_Unknown }
+        { GUID_SysMouse_malloced       GUID_SysMouse }
+        { GUID_SysKeyboard_malloced    GUID_SysKeyboard }
+        { GUID_Joystick_malloced       GUID_Joystick }
+        { GUID_SysMouseEm_malloced     GUID_SysMouseEm }
+        { GUID_SysMouseEm2_malloced    GUID_SysMouseEm2 }
+        { GUID_SysKeyboardEm_malloced  GUID_SysKeyboardEm }
+        { GUID_SysKeyboardEm2_malloced GUID_SysKeyboardEm2 }
+    } [ first2 (malloc-guid-symbol) ] each ;
+
+: define-joystick-format-constant ( -- )
+    c_dfDIJoystick2 [
+        DIDF_ABSAXIS
+        DIJOYSTATE2 heap-size
+        DIJOYSTATE2 {
+            { GUID_XAxis_malloced  "lX"           0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
+            { GUID_YAxis_malloced  "lY"           0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
+            { GUID_ZAxis_malloced  "lZ"           0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
+            { GUID_RxAxis_malloced "lRx"          0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
+            { GUID_RyAxis_malloced "lRy"          0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
+            { GUID_RzAxis_malloced "lRz"          0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
+            { GUID_Slider_malloced "rglSlider"    0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
+            { GUID_Slider_malloced "rglSlider"    1 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } 0 }
+            { GUID_POV_malloced    "rgdwPOV"      0 { DIDFT_OPTIONAL DIDFT_POV    DIDFT_ANYINSTANCE } 0 }
+            { GUID_POV_malloced    "rgdwPOV"      1 { DIDFT_OPTIONAL DIDFT_POV    DIDFT_ANYINSTANCE } 0 }
+            { GUID_POV_malloced    "rgdwPOV"      2 { DIDFT_OPTIONAL DIDFT_POV    DIDFT_ANYINSTANCE } 0 }
+            { GUID_POV_malloced    "rgdwPOV"      3 { DIDFT_OPTIONAL DIDFT_POV    DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"   0 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"   1 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"   2 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"   3 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"   4 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"   5 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"   6 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"   7 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"   8 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"   9 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  10 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  11 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  12 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  13 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  14 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  15 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  16 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  17 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  18 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  19 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  20 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  21 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  22 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  23 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  24 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  25 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  26 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  27 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  28 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  29 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  30 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  31 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  32 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  33 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  34 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  35 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  36 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  37 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  38 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  39 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  40 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  41 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  42 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  43 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  44 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  45 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  46 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  47 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  48 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  49 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  50 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  51 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  52 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  53 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  54 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  55 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  56 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  57 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  58 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  59 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  60 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  61 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  62 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  63 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  64 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  65 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  66 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  67 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  68 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  69 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  70 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  71 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  72 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  73 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  74 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  75 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  76 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  77 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  78 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  79 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  80 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  81 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  82 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  83 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  84 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  85 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  86 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  87 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  88 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  89 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  90 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  91 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  92 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  93 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  94 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  95 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  96 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  97 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  98 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons"  99 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons" 100 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons" 101 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons" 102 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons" 103 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons" 104 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons" 105 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons" 106 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons" 107 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons" 108 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons" 109 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons" 110 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons" 111 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons" 112 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons" 113 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons" 114 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons" 115 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons" 116 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons" 117 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons" 118 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons" 119 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons" 120 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons" 121 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons" 122 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons" 123 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons" 124 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons" 125 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons" 126 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { f           "rgbButtons" 127 { DIDFT_OPTIONAL DIDFT_BUTTON DIDFT_ANYINSTANCE } 0 }
+            { GUID_XAxis_malloced  "lVX"          0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } DIDOI_ASPECTVELOCITY }
+            { GUID_YAxis_malloced  "lVY"          0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } DIDOI_ASPECTVELOCITY }
+            { GUID_ZAxis_malloced  "lVZ"          0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } DIDOI_ASPECTVELOCITY }
+            { GUID_RxAxis_malloced "lVRx"         0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } DIDOI_ASPECTVELOCITY }
+            { GUID_RyAxis_malloced "lVRy"         0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } DIDOI_ASPECTVELOCITY }
+            { GUID_RzAxis_malloced "lVRz"         0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } DIDOI_ASPECTVELOCITY }
+            { GUID_Slider_malloced "rglVSlider"   0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } DIDOI_ASPECTVELOCITY }
+            { GUID_Slider_malloced "rglVSlider"   1 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } DIDOI_ASPECTVELOCITY }
+            { GUID_XAxis_malloced  "lAX"          0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } DIDOI_ASPECTACCEL }
+            { GUID_YAxis_malloced  "lAY"          0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } DIDOI_ASPECTACCEL }
+            { GUID_ZAxis_malloced  "lAZ"          0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } DIDOI_ASPECTACCEL }
+            { GUID_RxAxis_malloced "lARx"         0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } DIDOI_ASPECTACCEL }
+            { GUID_RyAxis_malloced "lARy"         0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } DIDOI_ASPECTACCEL }
+            { GUID_RzAxis_malloced "lARz"         0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } DIDOI_ASPECTACCEL }
+            { GUID_Slider_malloced "rglASlider"   0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } DIDOI_ASPECTACCEL }
+            { GUID_Slider_malloced "rglASlider"   1 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } DIDOI_ASPECTACCEL }
+            { GUID_XAxis_malloced  "lFX"          0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } DIDOI_ASPECTFORCE }
+            { GUID_YAxis_malloced  "lFY"          0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } DIDOI_ASPECTFORCE }
+            { GUID_ZAxis_malloced  "lFZ"          0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } DIDOI_ASPECTFORCE }
+            { GUID_RxAxis_malloced "lFRx"         0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } DIDOI_ASPECTFORCE }
+            { GUID_RyAxis_malloced "lFRy"         0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } DIDOI_ASPECTFORCE }
+            { GUID_RzAxis_malloced "lFRz"         0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } DIDOI_ASPECTFORCE }
+            { GUID_Slider_malloced "rglFSlider"   0 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } DIDOI_ASPECTFORCE }
+            { GUID_Slider_malloced "rglFSlider"   1 { DIDFT_OPTIONAL DIDFT_AXIS   DIDFT_ANYINSTANCE } DIDOI_ASPECTFORCE }
+        } <DIDATAFORMAT>
+    ] initialize ;
+
+: define-mouse-format-constant ( -- )
+    c_dfDIMouse2 [
+        DIDF_RELAXIS
+        DIMOUSESTATE2 heap-size
+        DIMOUSESTATE2 {
+            { GUID_XAxis_malloced  "lX"         0 {                DIDFT_ANYINSTANCE DIDFT_AXIS   } 0 }
+            { GUID_YAxis_malloced  "lY"         0 {                DIDFT_ANYINSTANCE DIDFT_AXIS   } 0 }
+            { GUID_ZAxis_malloced  "lZ"         0 { DIDFT_OPTIONAL DIDFT_ANYINSTANCE DIDFT_AXIS   } 0 }
+            { GUID_Button_malloced "rgbButtons" 0 {                DIDFT_ANYINSTANCE DIDFT_BUTTON } 0 }
+            { GUID_Button_malloced "rgbButtons" 1 {                DIDFT_ANYINSTANCE DIDFT_BUTTON } 0 }
+            { GUID_Button_malloced "rgbButtons" 2 { DIDFT_OPTIONAL DIDFT_ANYINSTANCE DIDFT_BUTTON } 0 }
+            { GUID_Button_malloced "rgbButtons" 3 { DIDFT_OPTIONAL DIDFT_ANYINSTANCE DIDFT_BUTTON } 0 }
+            { GUID_Button_malloced "rgbButtons" 4 { DIDFT_OPTIONAL DIDFT_ANYINSTANCE DIDFT_BUTTON } 0 }
+            { GUID_Button_malloced "rgbButtons" 5 { DIDFT_OPTIONAL DIDFT_ANYINSTANCE DIDFT_BUTTON } 0 }
+            { GUID_Button_malloced "rgbButtons" 6 { DIDFT_OPTIONAL DIDFT_ANYINSTANCE DIDFT_BUTTON } 0 }
+            { GUID_Button_malloced "rgbButtons" 7 { DIDFT_OPTIONAL DIDFT_ANYINSTANCE DIDFT_BUTTON } 0 }
+        } <DIDATAFORMAT>
+    ] initialize ;
+
+! Not a standard DirectInput format. Included for cross-platform niceness.
+! This format returns the keyboard keys in USB HID order rather than Windows
+! order
+: define-hid-keyboard-format-constant ( -- )
+    c_dfDIKeyboard_HID [
+        DIDF_RELAXIS
+        256
+        f {
+            { GUID_Key_malloced f   0 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f   1 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f   2 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f   3 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f   4 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_A DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f   5 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_B DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f   6 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_C DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f   7 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_D DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f   8 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_E DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f   9 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_F DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  10 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_G DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  11 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_H DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  12 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_I DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  13 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_J DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  14 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_K DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  15 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_L DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  16 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_M DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  17 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_N DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  18 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_O DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  19 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_P DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  20 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_Q DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  21 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_R DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  22 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_S DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  23 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_T DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  24 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_U DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  25 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_V DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  26 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_W DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  27 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_X DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  28 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_Y DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  29 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_Z DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  30 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_1 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  31 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_2 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  32 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_3 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  33 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_4 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  34 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_5 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  35 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_6 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  36 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_7 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  37 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_8 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  38 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_9 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  39 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  40 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_RETURN DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  41 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_ESCAPE DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  42 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_BACK DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  43 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_TAB DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  44 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_SPACE DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  45 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_MINUS DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  46 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_EQUALS DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  47 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_LBRACKET DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  48 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_RBRACKET DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  49 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_BACKSLASH DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  50 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  51 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_SEMICOLON DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  52 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_APOSTROPHE DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  53 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_GRAVE DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  54 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_COMMA  DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  55 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_PERIOD DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  56 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_SLASH  DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  57 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_CAPITAL DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  58 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_F1 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  59 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_F2 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  60 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_F3 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  61 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_F4 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  62 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_F5 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  63 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_F6 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  64 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_F7 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  65 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_F8 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  66 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_F9 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  67 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_F10 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  68 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_F11 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  69 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_F12 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  70 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_SYSRQ DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  71 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_SCROLL DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  72 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_PAUSE DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  73 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_INSERT DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  74 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_HOME DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  75 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_PRIOR DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  76 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_DELETE DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  77 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_END DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  78 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_NEXT DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  79 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_RIGHT DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  80 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_LEFT DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  81 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_DOWN DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  82 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_UP DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  83 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_NUMLOCK DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  84 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_DIVIDE DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  85 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_MULTIPLY DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  86 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_SUBTRACT DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  87 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_ADD DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  88 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_NUMPADENTER DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  89 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_NUMPAD1 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  90 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_NUMPAD2 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  91 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_NUMPAD3 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  92 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_NUMPAD4 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  93 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_NUMPAD5 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  94 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_NUMPAD6 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  95 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_NUMPAD7 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  96 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_NUMPAD8 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  97 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_NUMPAD9 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  98 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_NUMPAD0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  99 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_DECIMAL DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 100 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_OEM_102 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 101 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_APPS DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 102 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_POWER DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 103 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_NUMPADEQUALS DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 104 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_F13 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 105 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_F14 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 106 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_F15 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 107 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 108 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 109 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 110 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 111 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 112 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 113 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 114 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 115 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 116 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 117 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 118 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 119 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 120 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 121 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 122 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 123 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 124 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 125 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 126 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 127 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_MUTE DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 128 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_VOLUMEUP DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 129 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_VOLUMEDOWN DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 130 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 131 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 132 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 133 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_ABNT_C2 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 134 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 135 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_ABNT_C1 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 136 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_KANA DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 137 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_YEN DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 138 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_CONVERT DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 139 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_NOCONVERT DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 140 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 141 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 142 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 143 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 144 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 145 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 146 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 147 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 148 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 149 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 150 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 151 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 152 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 153 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 154 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 155 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 156 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 157 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 158 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 159 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 160 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 161 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 162 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 163 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 164 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 165 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 166 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 167 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 168 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 169 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 170 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 171 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 172 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 173 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 174 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 175 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 176 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 177 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 178 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 179 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 180 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 181 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 182 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 183 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 184 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 185 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 186 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 187 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 188 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 189 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 190 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 191 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 192 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 193 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 194 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 195 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 196 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 197 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 198 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 199 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 200 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 201 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 202 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 203 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 204 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 205 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 206 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 207 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 208 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 209 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 210 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 211 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 212 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 213 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 214 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 215 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 216 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 217 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 218 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 219 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 220 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 221 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 222 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 223 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 224 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_LCONTROL DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 225 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_LSHIFT DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 226 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_LMENU DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 227 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_LWIN DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 228 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_RCONTROL DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 229 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_RSHIFT DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 230 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_RMENU DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 231 { DIDFT_OPTIONAL DIDFT_BUTTON [ DIK_RWIN DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 232 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 233 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 234 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 235 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 236 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 237 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 238 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 239 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 240 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 241 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 242 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 243 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 244 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 245 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 246 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 247 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 248 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 249 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 250 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 251 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 252 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 253 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 254 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 255 { DIDFT_OPTIONAL DIDFT_BUTTON [ 0 DIDFT_MAKEINSTANCE ] } 0 }
+        } <DIDATAFORMAT>
+    ] initialize ;
+
+: define-keyboard-format-constant ( -- )
+    c_dfDIKeyboard [
+        DIDF_RELAXIS
+        256
+        f {
+            { GUID_Key_malloced f   0 { DIDFT_OPTIONAL DIDFT_BUTTON [   0 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f   1 { DIDFT_OPTIONAL DIDFT_BUTTON [   1 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f   2 { DIDFT_OPTIONAL DIDFT_BUTTON [   2 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f   3 { DIDFT_OPTIONAL DIDFT_BUTTON [   3 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f   4 { DIDFT_OPTIONAL DIDFT_BUTTON [   4 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f   5 { DIDFT_OPTIONAL DIDFT_BUTTON [   5 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f   6 { DIDFT_OPTIONAL DIDFT_BUTTON [   6 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f   7 { DIDFT_OPTIONAL DIDFT_BUTTON [   7 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f   8 { DIDFT_OPTIONAL DIDFT_BUTTON [   8 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f   9 { DIDFT_OPTIONAL DIDFT_BUTTON [   9 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  10 { DIDFT_OPTIONAL DIDFT_BUTTON [  10 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  11 { DIDFT_OPTIONAL DIDFT_BUTTON [  11 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  12 { DIDFT_OPTIONAL DIDFT_BUTTON [  12 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  13 { DIDFT_OPTIONAL DIDFT_BUTTON [  13 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  14 { DIDFT_OPTIONAL DIDFT_BUTTON [  14 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  15 { DIDFT_OPTIONAL DIDFT_BUTTON [  15 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  16 { DIDFT_OPTIONAL DIDFT_BUTTON [  16 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  17 { DIDFT_OPTIONAL DIDFT_BUTTON [  17 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  18 { DIDFT_OPTIONAL DIDFT_BUTTON [  18 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  19 { DIDFT_OPTIONAL DIDFT_BUTTON [  19 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  20 { DIDFT_OPTIONAL DIDFT_BUTTON [  20 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  21 { DIDFT_OPTIONAL DIDFT_BUTTON [  21 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  22 { DIDFT_OPTIONAL DIDFT_BUTTON [  22 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  23 { DIDFT_OPTIONAL DIDFT_BUTTON [  23 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  24 { DIDFT_OPTIONAL DIDFT_BUTTON [  24 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  25 { DIDFT_OPTIONAL DIDFT_BUTTON [  25 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  26 { DIDFT_OPTIONAL DIDFT_BUTTON [  26 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  27 { DIDFT_OPTIONAL DIDFT_BUTTON [  27 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  28 { DIDFT_OPTIONAL DIDFT_BUTTON [  28 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  29 { DIDFT_OPTIONAL DIDFT_BUTTON [  29 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  30 { DIDFT_OPTIONAL DIDFT_BUTTON [  30 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  31 { DIDFT_OPTIONAL DIDFT_BUTTON [  31 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  32 { DIDFT_OPTIONAL DIDFT_BUTTON [  32 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  33 { DIDFT_OPTIONAL DIDFT_BUTTON [  33 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  34 { DIDFT_OPTIONAL DIDFT_BUTTON [  34 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  35 { DIDFT_OPTIONAL DIDFT_BUTTON [  35 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  36 { DIDFT_OPTIONAL DIDFT_BUTTON [  36 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  37 { DIDFT_OPTIONAL DIDFT_BUTTON [  37 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  38 { DIDFT_OPTIONAL DIDFT_BUTTON [  38 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  39 { DIDFT_OPTIONAL DIDFT_BUTTON [  39 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  40 { DIDFT_OPTIONAL DIDFT_BUTTON [  40 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  41 { DIDFT_OPTIONAL DIDFT_BUTTON [  41 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  42 { DIDFT_OPTIONAL DIDFT_BUTTON [  42 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  43 { DIDFT_OPTIONAL DIDFT_BUTTON [  43 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  44 { DIDFT_OPTIONAL DIDFT_BUTTON [  44 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  45 { DIDFT_OPTIONAL DIDFT_BUTTON [  45 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  46 { DIDFT_OPTIONAL DIDFT_BUTTON [  46 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  47 { DIDFT_OPTIONAL DIDFT_BUTTON [  47 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  48 { DIDFT_OPTIONAL DIDFT_BUTTON [  48 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  49 { DIDFT_OPTIONAL DIDFT_BUTTON [  49 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  50 { DIDFT_OPTIONAL DIDFT_BUTTON [  50 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  51 { DIDFT_OPTIONAL DIDFT_BUTTON [  51 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  52 { DIDFT_OPTIONAL DIDFT_BUTTON [  52 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  53 { DIDFT_OPTIONAL DIDFT_BUTTON [  53 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  54 { DIDFT_OPTIONAL DIDFT_BUTTON [  54 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  55 { DIDFT_OPTIONAL DIDFT_BUTTON [  55 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  56 { DIDFT_OPTIONAL DIDFT_BUTTON [  56 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  57 { DIDFT_OPTIONAL DIDFT_BUTTON [  57 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  58 { DIDFT_OPTIONAL DIDFT_BUTTON [  58 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  59 { DIDFT_OPTIONAL DIDFT_BUTTON [  59 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  60 { DIDFT_OPTIONAL DIDFT_BUTTON [  60 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  61 { DIDFT_OPTIONAL DIDFT_BUTTON [  61 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  62 { DIDFT_OPTIONAL DIDFT_BUTTON [  62 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  63 { DIDFT_OPTIONAL DIDFT_BUTTON [  63 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  64 { DIDFT_OPTIONAL DIDFT_BUTTON [  64 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  65 { DIDFT_OPTIONAL DIDFT_BUTTON [  65 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  66 { DIDFT_OPTIONAL DIDFT_BUTTON [  66 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  67 { DIDFT_OPTIONAL DIDFT_BUTTON [  67 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  68 { DIDFT_OPTIONAL DIDFT_BUTTON [  68 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  69 { DIDFT_OPTIONAL DIDFT_BUTTON [  69 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  70 { DIDFT_OPTIONAL DIDFT_BUTTON [  70 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  71 { DIDFT_OPTIONAL DIDFT_BUTTON [  71 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  72 { DIDFT_OPTIONAL DIDFT_BUTTON [  72 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  73 { DIDFT_OPTIONAL DIDFT_BUTTON [  73 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  74 { DIDFT_OPTIONAL DIDFT_BUTTON [  74 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  75 { DIDFT_OPTIONAL DIDFT_BUTTON [  75 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  76 { DIDFT_OPTIONAL DIDFT_BUTTON [  76 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  77 { DIDFT_OPTIONAL DIDFT_BUTTON [  77 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  78 { DIDFT_OPTIONAL DIDFT_BUTTON [  78 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  79 { DIDFT_OPTIONAL DIDFT_BUTTON [  79 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  80 { DIDFT_OPTIONAL DIDFT_BUTTON [  80 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  81 { DIDFT_OPTIONAL DIDFT_BUTTON [  81 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  82 { DIDFT_OPTIONAL DIDFT_BUTTON [  82 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  83 { DIDFT_OPTIONAL DIDFT_BUTTON [  83 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  84 { DIDFT_OPTIONAL DIDFT_BUTTON [  84 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  85 { DIDFT_OPTIONAL DIDFT_BUTTON [  85 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  86 { DIDFT_OPTIONAL DIDFT_BUTTON [  86 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  87 { DIDFT_OPTIONAL DIDFT_BUTTON [  87 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  88 { DIDFT_OPTIONAL DIDFT_BUTTON [  88 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  89 { DIDFT_OPTIONAL DIDFT_BUTTON [  89 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  90 { DIDFT_OPTIONAL DIDFT_BUTTON [  90 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  91 { DIDFT_OPTIONAL DIDFT_BUTTON [  91 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  92 { DIDFT_OPTIONAL DIDFT_BUTTON [  92 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  93 { DIDFT_OPTIONAL DIDFT_BUTTON [  93 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  94 { DIDFT_OPTIONAL DIDFT_BUTTON [  94 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  95 { DIDFT_OPTIONAL DIDFT_BUTTON [  95 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  96 { DIDFT_OPTIONAL DIDFT_BUTTON [  96 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  97 { DIDFT_OPTIONAL DIDFT_BUTTON [  97 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  98 { DIDFT_OPTIONAL DIDFT_BUTTON [  98 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f  99 { DIDFT_OPTIONAL DIDFT_BUTTON [  99 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 100 { DIDFT_OPTIONAL DIDFT_BUTTON [ 100 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 101 { DIDFT_OPTIONAL DIDFT_BUTTON [ 101 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 102 { DIDFT_OPTIONAL DIDFT_BUTTON [ 102 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 103 { DIDFT_OPTIONAL DIDFT_BUTTON [ 103 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 104 { DIDFT_OPTIONAL DIDFT_BUTTON [ 104 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 105 { DIDFT_OPTIONAL DIDFT_BUTTON [ 105 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 106 { DIDFT_OPTIONAL DIDFT_BUTTON [ 106 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 107 { DIDFT_OPTIONAL DIDFT_BUTTON [ 107 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 108 { DIDFT_OPTIONAL DIDFT_BUTTON [ 108 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 109 { DIDFT_OPTIONAL DIDFT_BUTTON [ 109 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 110 { DIDFT_OPTIONAL DIDFT_BUTTON [ 110 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 111 { DIDFT_OPTIONAL DIDFT_BUTTON [ 111 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 112 { DIDFT_OPTIONAL DIDFT_BUTTON [ 112 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 113 { DIDFT_OPTIONAL DIDFT_BUTTON [ 113 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 114 { DIDFT_OPTIONAL DIDFT_BUTTON [ 114 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 115 { DIDFT_OPTIONAL DIDFT_BUTTON [ 115 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 116 { DIDFT_OPTIONAL DIDFT_BUTTON [ 116 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 117 { DIDFT_OPTIONAL DIDFT_BUTTON [ 117 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 118 { DIDFT_OPTIONAL DIDFT_BUTTON [ 118 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 119 { DIDFT_OPTIONAL DIDFT_BUTTON [ 119 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 120 { DIDFT_OPTIONAL DIDFT_BUTTON [ 120 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 121 { DIDFT_OPTIONAL DIDFT_BUTTON [ 121 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 122 { DIDFT_OPTIONAL DIDFT_BUTTON [ 122 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 123 { DIDFT_OPTIONAL DIDFT_BUTTON [ 123 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 124 { DIDFT_OPTIONAL DIDFT_BUTTON [ 124 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 125 { DIDFT_OPTIONAL DIDFT_BUTTON [ 125 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 126 { DIDFT_OPTIONAL DIDFT_BUTTON [ 126 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 127 { DIDFT_OPTIONAL DIDFT_BUTTON [ 127 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 128 { DIDFT_OPTIONAL DIDFT_BUTTON [ 128 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 129 { DIDFT_OPTIONAL DIDFT_BUTTON [ 129 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 130 { DIDFT_OPTIONAL DIDFT_BUTTON [ 130 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 131 { DIDFT_OPTIONAL DIDFT_BUTTON [ 131 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 132 { DIDFT_OPTIONAL DIDFT_BUTTON [ 132 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 133 { DIDFT_OPTIONAL DIDFT_BUTTON [ 133 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 134 { DIDFT_OPTIONAL DIDFT_BUTTON [ 134 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 135 { DIDFT_OPTIONAL DIDFT_BUTTON [ 135 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 136 { DIDFT_OPTIONAL DIDFT_BUTTON [ 136 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 137 { DIDFT_OPTIONAL DIDFT_BUTTON [ 137 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 138 { DIDFT_OPTIONAL DIDFT_BUTTON [ 138 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 139 { DIDFT_OPTIONAL DIDFT_BUTTON [ 139 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 140 { DIDFT_OPTIONAL DIDFT_BUTTON [ 140 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 141 { DIDFT_OPTIONAL DIDFT_BUTTON [ 141 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 142 { DIDFT_OPTIONAL DIDFT_BUTTON [ 142 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 143 { DIDFT_OPTIONAL DIDFT_BUTTON [ 143 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 144 { DIDFT_OPTIONAL DIDFT_BUTTON [ 144 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 145 { DIDFT_OPTIONAL DIDFT_BUTTON [ 145 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 146 { DIDFT_OPTIONAL DIDFT_BUTTON [ 146 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 147 { DIDFT_OPTIONAL DIDFT_BUTTON [ 147 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 148 { DIDFT_OPTIONAL DIDFT_BUTTON [ 148 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 149 { DIDFT_OPTIONAL DIDFT_BUTTON [ 149 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 150 { DIDFT_OPTIONAL DIDFT_BUTTON [ 150 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 151 { DIDFT_OPTIONAL DIDFT_BUTTON [ 151 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 152 { DIDFT_OPTIONAL DIDFT_BUTTON [ 152 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 153 { DIDFT_OPTIONAL DIDFT_BUTTON [ 153 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 154 { DIDFT_OPTIONAL DIDFT_BUTTON [ 154 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 155 { DIDFT_OPTIONAL DIDFT_BUTTON [ 155 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 156 { DIDFT_OPTIONAL DIDFT_BUTTON [ 156 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 157 { DIDFT_OPTIONAL DIDFT_BUTTON [ 157 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 158 { DIDFT_OPTIONAL DIDFT_BUTTON [ 158 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 159 { DIDFT_OPTIONAL DIDFT_BUTTON [ 159 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 160 { DIDFT_OPTIONAL DIDFT_BUTTON [ 160 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 161 { DIDFT_OPTIONAL DIDFT_BUTTON [ 161 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 162 { DIDFT_OPTIONAL DIDFT_BUTTON [ 162 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 163 { DIDFT_OPTIONAL DIDFT_BUTTON [ 163 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 164 { DIDFT_OPTIONAL DIDFT_BUTTON [ 164 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 165 { DIDFT_OPTIONAL DIDFT_BUTTON [ 165 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 166 { DIDFT_OPTIONAL DIDFT_BUTTON [ 166 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 167 { DIDFT_OPTIONAL DIDFT_BUTTON [ 167 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 168 { DIDFT_OPTIONAL DIDFT_BUTTON [ 168 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 169 { DIDFT_OPTIONAL DIDFT_BUTTON [ 169 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 170 { DIDFT_OPTIONAL DIDFT_BUTTON [ 170 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 171 { DIDFT_OPTIONAL DIDFT_BUTTON [ 171 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 172 { DIDFT_OPTIONAL DIDFT_BUTTON [ 172 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 173 { DIDFT_OPTIONAL DIDFT_BUTTON [ 173 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 174 { DIDFT_OPTIONAL DIDFT_BUTTON [ 174 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 175 { DIDFT_OPTIONAL DIDFT_BUTTON [ 175 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 176 { DIDFT_OPTIONAL DIDFT_BUTTON [ 176 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 177 { DIDFT_OPTIONAL DIDFT_BUTTON [ 177 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 178 { DIDFT_OPTIONAL DIDFT_BUTTON [ 178 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 179 { DIDFT_OPTIONAL DIDFT_BUTTON [ 179 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 180 { DIDFT_OPTIONAL DIDFT_BUTTON [ 180 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 181 { DIDFT_OPTIONAL DIDFT_BUTTON [ 181 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 182 { DIDFT_OPTIONAL DIDFT_BUTTON [ 182 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 183 { DIDFT_OPTIONAL DIDFT_BUTTON [ 183 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 184 { DIDFT_OPTIONAL DIDFT_BUTTON [ 184 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 185 { DIDFT_OPTIONAL DIDFT_BUTTON [ 185 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 186 { DIDFT_OPTIONAL DIDFT_BUTTON [ 186 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 187 { DIDFT_OPTIONAL DIDFT_BUTTON [ 187 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 188 { DIDFT_OPTIONAL DIDFT_BUTTON [ 188 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 189 { DIDFT_OPTIONAL DIDFT_BUTTON [ 189 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 190 { DIDFT_OPTIONAL DIDFT_BUTTON [ 190 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 191 { DIDFT_OPTIONAL DIDFT_BUTTON [ 191 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 192 { DIDFT_OPTIONAL DIDFT_BUTTON [ 192 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 193 { DIDFT_OPTIONAL DIDFT_BUTTON [ 193 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 194 { DIDFT_OPTIONAL DIDFT_BUTTON [ 194 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 195 { DIDFT_OPTIONAL DIDFT_BUTTON [ 195 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 196 { DIDFT_OPTIONAL DIDFT_BUTTON [ 196 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 197 { DIDFT_OPTIONAL DIDFT_BUTTON [ 197 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 198 { DIDFT_OPTIONAL DIDFT_BUTTON [ 198 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 199 { DIDFT_OPTIONAL DIDFT_BUTTON [ 199 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 200 { DIDFT_OPTIONAL DIDFT_BUTTON [ 200 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 201 { DIDFT_OPTIONAL DIDFT_BUTTON [ 201 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 202 { DIDFT_OPTIONAL DIDFT_BUTTON [ 202 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 203 { DIDFT_OPTIONAL DIDFT_BUTTON [ 203 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 204 { DIDFT_OPTIONAL DIDFT_BUTTON [ 204 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 205 { DIDFT_OPTIONAL DIDFT_BUTTON [ 205 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 206 { DIDFT_OPTIONAL DIDFT_BUTTON [ 206 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 207 { DIDFT_OPTIONAL DIDFT_BUTTON [ 207 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 208 { DIDFT_OPTIONAL DIDFT_BUTTON [ 208 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 209 { DIDFT_OPTIONAL DIDFT_BUTTON [ 209 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 210 { DIDFT_OPTIONAL DIDFT_BUTTON [ 210 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 211 { DIDFT_OPTIONAL DIDFT_BUTTON [ 211 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 212 { DIDFT_OPTIONAL DIDFT_BUTTON [ 212 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 213 { DIDFT_OPTIONAL DIDFT_BUTTON [ 213 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 214 { DIDFT_OPTIONAL DIDFT_BUTTON [ 214 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 215 { DIDFT_OPTIONAL DIDFT_BUTTON [ 215 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 216 { DIDFT_OPTIONAL DIDFT_BUTTON [ 216 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 217 { DIDFT_OPTIONAL DIDFT_BUTTON [ 217 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 218 { DIDFT_OPTIONAL DIDFT_BUTTON [ 218 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 219 { DIDFT_OPTIONAL DIDFT_BUTTON [ 219 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 220 { DIDFT_OPTIONAL DIDFT_BUTTON [ 220 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 221 { DIDFT_OPTIONAL DIDFT_BUTTON [ 221 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 222 { DIDFT_OPTIONAL DIDFT_BUTTON [ 222 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 223 { DIDFT_OPTIONAL DIDFT_BUTTON [ 223 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 224 { DIDFT_OPTIONAL DIDFT_BUTTON [ 224 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 225 { DIDFT_OPTIONAL DIDFT_BUTTON [ 225 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 226 { DIDFT_OPTIONAL DIDFT_BUTTON [ 226 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 227 { DIDFT_OPTIONAL DIDFT_BUTTON [ 227 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 228 { DIDFT_OPTIONAL DIDFT_BUTTON [ 228 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 229 { DIDFT_OPTIONAL DIDFT_BUTTON [ 229 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 230 { DIDFT_OPTIONAL DIDFT_BUTTON [ 230 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 231 { DIDFT_OPTIONAL DIDFT_BUTTON [ 231 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 232 { DIDFT_OPTIONAL DIDFT_BUTTON [ 232 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 233 { DIDFT_OPTIONAL DIDFT_BUTTON [ 233 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 234 { DIDFT_OPTIONAL DIDFT_BUTTON [ 234 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 235 { DIDFT_OPTIONAL DIDFT_BUTTON [ 235 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 236 { DIDFT_OPTIONAL DIDFT_BUTTON [ 236 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 237 { DIDFT_OPTIONAL DIDFT_BUTTON [ 237 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 238 { DIDFT_OPTIONAL DIDFT_BUTTON [ 238 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 239 { DIDFT_OPTIONAL DIDFT_BUTTON [ 239 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 240 { DIDFT_OPTIONAL DIDFT_BUTTON [ 240 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 241 { DIDFT_OPTIONAL DIDFT_BUTTON [ 241 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 242 { DIDFT_OPTIONAL DIDFT_BUTTON [ 242 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 243 { DIDFT_OPTIONAL DIDFT_BUTTON [ 243 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 244 { DIDFT_OPTIONAL DIDFT_BUTTON [ 244 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 245 { DIDFT_OPTIONAL DIDFT_BUTTON [ 245 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 246 { DIDFT_OPTIONAL DIDFT_BUTTON [ 246 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 247 { DIDFT_OPTIONAL DIDFT_BUTTON [ 247 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 248 { DIDFT_OPTIONAL DIDFT_BUTTON [ 248 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 249 { DIDFT_OPTIONAL DIDFT_BUTTON [ 249 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 250 { DIDFT_OPTIONAL DIDFT_BUTTON [ 250 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 251 { DIDFT_OPTIONAL DIDFT_BUTTON [ 251 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 252 { DIDFT_OPTIONAL DIDFT_BUTTON [ 252 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 253 { DIDFT_OPTIONAL DIDFT_BUTTON [ 253 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 254 { DIDFT_OPTIONAL DIDFT_BUTTON [ 254 DIDFT_MAKEINSTANCE ] } 0 }
+            { GUID_Key_malloced f 255 { DIDFT_OPTIONAL DIDFT_BUTTON [ 255 DIDFT_MAKEINSTANCE ] } 0 }
+        } <DIDATAFORMAT>
+    ] initialize ;
+
+: define-format-constants ( -- )
+    define-joystick-format-constant
+    define-mouse-format-constant
+    define-keyboard-format-constant
+    define-hid-keyboard-format-constant ;
+
+: define-constants ( -- )
+    define-guid-constants
+    define-format-constants ;
+
+[ define-constants ] "windows.directx.dinput.constants" add-startup-hook
+
+: uninitialize ( variable quot -- )
+    '[ _ when* f ] change-global ; inline
+
+: free-dinput-constants ( -- )
+    {
+        GUID_XAxis_malloced GUID_YAxis_malloced GUID_ZAxis_malloced
+        GUID_RxAxis_malloced GUID_RyAxis_malloced GUID_RzAxis_malloced
+        GUID_Slider_malloced GUID_Button_malloced GUID_Key_malloced GUID_POV_malloced GUID_Unknown_malloced
+        GUID_SysMouse_malloced GUID_SysKeyboard_malloced GUID_Joystick_malloced GUID_SysMouseEm_malloced
+        GUID_SysMouseEm2_malloced GUID_SysKeyboardEm_malloced GUID_SysKeyboardEm2_malloced
+    } [ [ free ] uninitialize ] each
+
+    {
+        c_dfDIKeyboard c_dfDIKeyboard_HID c_dfDIMouse2 c_dfDIJoystick2
+    } [ [ rgodf>> free ] uninitialize ] each ;
+
+PRIVATE>
+
diff --git a/basis/windows/directx/dinput/constants/tags.txt b/basis/windows/directx/dinput/constants/tags.txt
new file mode 100644 (file)
index 0000000..6bf6830
--- /dev/null
@@ -0,0 +1 @@
+unportable
diff --git a/basis/windows/directx/dinput/dinput.factor b/basis/windows/directx/dinput/dinput.factor
new file mode 100644 (file)
index 0000000..2a7ae19
--- /dev/null
@@ -0,0 +1,711 @@
+USING: windows.kernel32 windows.ole32 windows.com windows.com.syntax
+alien alien.c-types alien.syntax kernel system namespaces math
+classes.struct windows.types ;
+IN: windows.directx.dinput
+
+LIBRARY: dinput
+
+TYPEDEF: DWORD D3DCOLOR
+
+STRUCT: DIDEVICEINSTANCEW
+    { dwSize          DWORD      }
+    { guidInstance    GUID       }
+    { guidProduct     GUID       }
+    { dwDevType       DWORD      }
+    { tszInstanceName WCHAR[260] }
+    { tszProductName  WCHAR[260] }
+    { guidFFDriver    GUID       }
+    { wUsagePage      WORD       }
+    { wUsage          WORD       } ;
+TYPEDEF: DIDEVICEINSTANCEW* LPDIDEVICEINSTANCEW
+TYPEDEF: DIDEVICEINSTANCEW* LPCDIDEVICEINSTANCEW
+UNION-STRUCT: DIACTION-union
+    { lptszActionName LPCWSTR }
+    { uResIdString    UINT    } ;
+STRUCT: DIACTIONW
+    { uAppData     UINT_PTR       }
+    { dwSemantic   DWORD          }
+    { dwFlags      DWORD          }
+    { union        DIACTION-union }
+    { guidInstance GUID           }
+    { dwObjID      DWORD          }
+    { dwHow        DWORD          } ;
+TYPEDEF: DIACTIONW* LPDIACTIONW
+TYPEDEF: DIACTIONW* LPCDIACTIONW
+STRUCT: DIACTIONFORMATW
+    { dwSize        DWORD       }
+    { dwActionSize  DWORD       }
+    { dwDataSize    DWORD       }
+    { dwNumActions  DWORD       }
+    { rgoAction     LPDIACTIONW }
+    { guidActionMap GUID        }
+    { dwGenre       DWORD       }
+    { dwBufferSize  DWORD       }
+    { lAxisMin      LONG        }
+    { lAxisMax      LONG        }
+    { hInstString   HINSTANCE   }
+    { ftTimeStamp   FILETIME    }
+    { dwCRC         DWORD       }
+    { tszActionMap  WCHAR[260]  } ;
+TYPEDEF: DIACTIONFORMATW* LPDIACTIONFORMATW
+TYPEDEF: DIACTIONFORMATW* LPCDIACTIONFORMATW
+STRUCT: DICOLORSET
+    { dwSize            DWORD    }
+    { cTextFore         D3DCOLOR }
+    { cTextHighlight    D3DCOLOR }
+    { cCalloutLine      D3DCOLOR }
+    { cCalloutHighlight D3DCOLOR }
+    { cBorder           D3DCOLOR }
+    { cControlFill      D3DCOLOR }
+    { cHighlightFill    D3DCOLOR }
+    { cAreaFill         D3DCOLOR } ;
+TYPEDEF: DICOLORSET* LPDICOLORSET
+TYPEDEF: DICOLORSET* LPCDICOLORSET
+
+STRUCT: DICONFIGUREDEVICESPARAMSW
+    { dwSize         DWORD             }
+    { dwcUsers       DWORD             }
+    { lptszUserNames LPWSTR            }
+    { dwcFormats     DWORD             }
+    { lprgFormats    LPDIACTIONFORMATW }
+    { hwnd           HWND              }
+    { dics           DICOLORSET        }
+    { lpUnkDDSTarget IUnknown*         } ;
+TYPEDEF: DICONFIGUREDEVICESPARAMSW* LPDICONFIGUREDEVICESPARAMSW
+TYPEDEF: DICONFIGUREDEVICESPARAMSW* LPDICONFIGUREDEVICESPARAMSW
+
+STRUCT: DIDEVCAPS
+    { dwSize DWORD }
+    { dwFlags DWORD }
+    { dwDevType DWORD }
+    { dwAxes DWORD }
+    { dwButtons DWORD }
+    { dwPOVs DWORD }
+    { dwFFSamplePeriod DWORD }
+    { dwFFMinTimeResolution DWORD }
+    { dwFirmwareRevision DWORD }
+    { dwHardwareRevision DWORD }
+    { dwFFDriverVersion DWORD } ;
+TYPEDEF: DIDEVCAPS* LPDIDEVCAPS
+TYPEDEF: DIDEVCAPS* LPCDIDEVCAPS
+STRUCT: DIDEVICEOBJECTINSTANCEW
+    { dwSize DWORD }
+    { guidType GUID }
+    { dwOfs DWORD }
+    { dwType DWORD }
+    { dwFlags DWORD }
+    { tszName WCHAR[260] }
+    { dwFFMaxForce DWORD }
+    { dwFFForceResolution DWORD }
+    { wCollectionNumber WORD }
+    { wDesignatorIndex WORD }
+    { wUsagePage WORD }
+    { wUsage WORD }
+    { dwDimension DWORD }
+    { wExponent WORD }
+    { wReportId WORD } ;
+TYPEDEF: DIDEVICEOBJECTINSTANCEW* LPDIDEVICEOBJECTINSTANCEW
+TYPEDEF: DIDEVICEOBJECTINSTANCEW* LPCDIDEVICEOBJECTINSTANCEW
+STRUCT: DIDEVICEOBJECTDATA
+    { dwOfs DWORD    }
+    { dwData DWORD    }
+    { dwTimeStamp DWORD    }
+    { dwSequence DWORD    }
+    { uAppData UINT_PTR } ;
+TYPEDEF: DIDEVICEOBJECTDATA* LPDIDEVICEOBJECTDATA
+TYPEDEF: DIDEVICEOBJECTDATA* LPCDIDEVICEOBJECTDATA
+STRUCT: DIOBJECTDATAFORMAT
+    { pguid GUID* }
+    { dwOfs DWORD }
+    { dwType DWORD }
+    { dwFlags DWORD } ;
+TYPEDEF: DIOBJECTDATAFORMAT* LPDIOBJECTDATAFORMAT
+TYPEDEF: DIOBJECTDATAFORMAT* LPCDIOBJECTDATAFORMAT
+STRUCT: DIDATAFORMAT
+    { dwSize DWORD }
+    { dwObjSize DWORD }
+    { dwFlags DWORD }
+    { dwDataSize DWORD }
+    { dwNumObjs DWORD }
+    { rgodf LPDIOBJECTDATAFORMAT } ;
+TYPEDEF: DIDATAFORMAT* LPDIDATAFORMAT
+TYPEDEF: DIDATAFORMAT* LPCDIDATAFORMAT
+STRUCT: DIPROPHEADER
+    { dwSize DWORD }
+    { dwHeaderSize DWORD }
+    { dwObj DWORD }
+    { dwHow DWORD } ;
+TYPEDEF: DIPROPHEADER* LPDIPROPHEADER
+TYPEDEF: DIPROPHEADER* LPCDIPROPHEADER
+STRUCT: DIPROPDWORD
+    { diph DIPROPHEADER }
+    { dwData DWORD        } ;
+TYPEDEF: DIPROPDWORD* LPDIPROPDWORD
+TYPEDEF: DIPROPDWORD* LPCDIPROPDWORD
+STRUCT: DIPROPPOINTER
+    { diph DIPROPHEADER }
+    { uData UINT_PTR } ;
+TYPEDEF: DIPROPPOINTER* LPDIPROPPOINTER
+TYPEDEF: DIPROPPOINTER* LPCDIPROPPOINTER
+STRUCT: DIPROPRANGE
+    { diph DIPROPHEADER }
+    { lMin LONG }
+    { lMax LONG } ;
+TYPEDEF: DIPROPRANGE* LPDIPROPRANGE
+TYPEDEF: DIPROPRANGE* LPCDIPROPRANGE
+STRUCT: DIPROPCAL
+    { diph DIPROPHEADER }
+    { lMin LONG }
+    { lCenter LONG }
+    { lMax LONG } ;
+TYPEDEF: DIPROPCAL* LPDIPROPCAL
+TYPEDEF: DIPROPCAL* LPCDIPROPCAL
+STRUCT: DIPROPGUIDANDPATH
+    { diph DIPROPHEADER }
+    { guidClass GUID }
+    { wszPath WCHAR[260]   } ;
+TYPEDEF: DIPROPGUIDANDPATH* LPDIPROPGUIDANDPATH
+TYPEDEF: DIPROPGUIDANDPATH* LPCDIPROPGUIDANDPATH
+STRUCT: DIPROPSTRING
+    { diph DIPROPHEADER }
+    { wsz WCHAR[260]   } ;
+TYPEDEF: DIPROPSTRING* LPDIPROPSTRING
+TYPEDEF: DIPROPSTRING* LPCDIPROPSTRING
+STRUCT: CPOINT
+    { lP LONG }
+    { dwLog DWORD } ;
+STRUCT: DIPROPCPOINTS
+    { diph DIPROPHEADER }
+    { dwCPointsNum DWORD }
+    { cp CPOINT[8] } ;
+TYPEDEF: DIPROPCPOINTS* LPDIPROPCPOINTS
+TYPEDEF: DIPROPCPOINTS* LPCDIPROPCPOINTS
+STRUCT: DIENVELOPE
+    { dwSize DWORD }
+    { dwAttackLevel DWORD }
+    { dwAttackTime DWORD }
+    { dwFadeLevel DWORD }
+    { dwFadeTime DWORD } ;
+TYPEDEF: DIENVELOPE* LPDIENVELOPE
+TYPEDEF: DIENVELOPE* LPCDIENVELOPE
+STRUCT: DIEFFECT
+    { dwSize DWORD }
+    { dwFlags DWORD }
+    { dwDuration DWORD }
+    { dwSamplePeriod DWORD }
+    { dwGain DWORD }
+    { dwTriggerButton DWORD }
+    { dwTriggerRepeatInterval DWORD }
+    { cAxes DWORD }
+    { rgdwAxes LPDWORD }
+    { rglDirection LPLONG }
+    { lpEnvelope LPDIENVELOPE }
+    { cbTypeSpecificParams DWORD }
+    { lpvTypeSpecificParams LPVOID }
+    { dwStartDelay DWORD } ;
+TYPEDEF: DIEFFECT* LPDIEFFECT
+TYPEDEF: DIEFFECT* LPCDIEFFECT
+STRUCT: DIEFFECTINFOW
+    { dwSize          DWORD      }
+    { guid            GUID       }
+    { dwEffType       DWORD      }
+    { dwStaticParams  DWORD      }
+    { dwDynamicParams DWORD      }
+    { tszName         WCHAR[260] } ;
+TYPEDEF: DIEFFECTINFOW* LPDIEFFECTINFOW
+TYPEDEF: DIEFFECTINFOW* LPCDIEFFECTINFOW
+STRUCT: DIEFFESCAPE
+    { dwSize       DWORD  }
+    { dwCommand    DWORD  }
+    { lpvInBuffer  LPVOID }
+    { cbInBuffer   DWORD  }
+    { lpvOutBuffer LPVOID }
+    { cbOutBuffer  DWORD  } ;
+TYPEDEF: DIEFFESCAPE* LPDIEFFESCAPE
+TYPEDEF: DIEFFESCAPE* LPCDIEFFESCAPE
+STRUCT: DIFILEEFFECT
+    { dwSize         DWORD       }
+    { GuidEffect     GUID        }
+    { lpDiEffect     LPCDIEFFECT }
+    { szFriendlyName CHAR[260]   } ;
+TYPEDEF: DIFILEEFFECT* LPDIFILEEFFECT
+TYPEDEF: DIFILEEFFECT* LPCDIFILEEFFECT
+STRUCT: DIDEVICEIMAGEINFOW
+    { tszImagePath    WCHAR[260] }
+    { dwFlags         DWORD      }
+    { dwViewID        DWORD      }
+    { rcOverlay       RECT       }
+    { dwObjID         DWORD      }
+    { dwcValidPts     DWORD      }
+    { rgptCalloutLine POINT[5]   }
+    { rcCalloutRect   RECT       }
+    { dwTextAlign     DWORD      } ;
+TYPEDEF: DIDEVICEIMAGEINFOW* LPDIDEVICEIMAGEINFOW
+TYPEDEF: DIDEVICEIMAGEINFOW* LPCDIDEVICEIMAGEINFOW
+STRUCT: DIDEVICEIMAGEINFOHEADERW
+    { dwSize          DWORD }
+    { dwSizeImageInfo DWORD }
+    { dwcViews        DWORD }
+    { dwcButtons      DWORD }
+    { dwcAxes         DWORD }
+    { dwcPOVs         DWORD }
+    { dwBufferSize    DWORD }
+    { dwBufferUsed    DWORD }
+    { lprgImageInfoArray DIDEVICEIMAGEINFOW* } ;
+TYPEDEF: DIDEVICEIMAGEINFOHEADERW* LPDIDEVICEIMAGEINFOHEADERW
+TYPEDEF: DIDEVICEIMAGEINFOHEADERW* LPCDIDEVICEIMAGEINFOHEADERW
+
+STRUCT: DIMOUSESTATE2
+    { lX         LONG    }
+    { lY         LONG    }
+    { lZ         LONG    }
+    { rgbButtons BYTE[8] } ;
+TYPEDEF: DIMOUSESTATE2* LPDIMOUSESTATE2
+TYPEDEF: DIMOUSESTATE2* LPCDIMOUSESTATE2
+
+STRUCT: DIJOYSTATE2
+    { lX         LONG      }
+    { lY         LONG      }
+    { lZ         LONG      }
+    { lRx        LONG      }
+    { lRy        LONG      }
+    { lRz        LONG      }
+    { rglSlider  LONG[2]   }
+    { rgdwPOV    DWORD[4]  }
+    { rgbButtons BYTE[128] }
+    { lVX        LONG      }
+    { lVY        LONG      }
+    { lVZ        LONG      }
+    { lVRx       LONG      }
+    { lVRy       LONG      }
+    { lVRz       LONG      }
+    { rglVSlider LONG[2]   }
+    { lAX        LONG      }
+    { lAY        LONG      }
+    { lAZ        LONG      }
+    { lARx       LONG      }
+    { lARy       LONG      }
+    { lARz       LONG      }
+    { rglASlider LONG[2]   }
+    { lFX        LONG      }
+    { lFY        LONG      }
+    { lFZ        LONG      }
+    { lFRx       LONG      }
+    { lFRy       LONG      }
+    { lFRz       LONG      }
+    { rglFSlider LONG[2]   } ;
+TYPEDEF: DIJOYSTATE2* LPDIJOYSTATE2
+TYPEDEF: DIJOYSTATE2* LPCDIJOYSTATE2
+
+CALLBACK: BOOL LPDIENUMDEVICESCALLBACKW (
+    LPCDIDEVICEINSTANCEW lpddi,
+    LPVOID pvRef
+) ;
+CALLBACK: BOOL LPDICONFIGUREDEVICESCALLBACK (
+    IUnknown* lpDDSTarget,
+    LPVOID pvRef
+) ;
+CALLBACK: BOOL LPDIENUMEFFECTSCALLBACKW (
+    LPCDIEFFECTINFOW pdei,
+    LPVOID pvRef
+) ;
+CALLBACK: BOOL LPDIENUMEFFECTSINFILECALLBACK (
+    LPCDIFILEEFFECT lpDiFileEf,
+    LPVOID pvRef
+) ;
+CALLBACK: BOOL LPDIENUMDEVICEOBJECTSCALLBACKW (
+    LPCDIDEVICEOBJECTINSTANCEW lpddoi,
+    LPVOID pvRef
+) ;
+
+COM-INTERFACE: IDirectInputEffect IUnknown {E7E1F7C0-88D2-11D0-9AD0-00A0C9A06E35}
+    HRESULT Initialize ( HINSTANCE hinst, DWORD dwVersion, REFGUID rguid )
+    HRESULT GetEffectGuid ( LPGUID pguid )
+    HRESULT GetParameters ( LPDIEFFECT peff, DWORD dwFlags )
+    HRESULT SetParameters ( LPCDIEFFECT peff, DWORD dwFlags )
+    HRESULT Start ( DWORD dwIterations, DWORD dwFlags )
+    HRESULT Stop ( )
+    HRESULT GetEffectStatus ( LPDWORD pdwFlags )
+    HRESULT Download ( )
+    HRESULT Unload ( )
+    HRESULT Escape ( LPDIEFFESCAPE pesc ) ;
+
+CALLBACK: BOOL LPDIENUMCREATEDEFFECTOBJECTSCALLBACK (
+    IDirectInputEffect* peff,
+    LPVOID pvRef
+) ;
+
+COM-INTERFACE: IDirectInputDevice8W IUnknown {54D41081-DC15-4833-A41B-748F73A38179}
+    HRESULT GetCapabilities ( LPDIDEVCAPS lpDIDeviceCaps )
+    HRESULT EnumObjects ( LPDIENUMDEVICEOBJECTSCALLBACKW lpCallback, LPVOID pvRef, DWORD dwFlags )
+    HRESULT GetProperty ( REFGUID rguidProp, LPDIPROPHEADER pdiph )
+    HRESULT SetProperty ( REFGUID rguidProp, LPCDIPROPHEADER pdiph )
+    HRESULT Acquire ( )
+    HRESULT Unacquire ( )
+    HRESULT GetDeviceState ( DWORD cbData, LPVOID lpvData )
+    HRESULT GetDeviceData ( DWORD cbObjectData, LPDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD dwFlags )
+    HRESULT SetDataFormat ( LPCDIDATAFORMAT lpdf )
+    HRESULT SetEventNotification ( HANDLE hEvent )
+    HRESULT SetCooperativeLevel ( HWND hwnd, DWORD dwFlags )
+    HRESULT GetObjectInfo ( LPDIDEVICEOBJECTINSTANCEW rdidoi, DWORD dwObj, DWORD dwHow )
+    HRESULT GetDeviceInfo ( LPDIDEVICEINSTANCEW pdidi )
+    HRESULT RunControlPanel ( HWND hwndOwner, DWORD dwFlags )
+    HRESULT Initialize ( HINSTANCE hinst, DWORD dwVersion, REFGUID rguid )
+    HRESULT CreateEffect ( REFGUID rguid, LPCDIEFFECT lpeff, IDirectInputEffect** ppdeff, LPUNKNOWN punkOuter )
+    HRESULT EnumEffects ( LPDIENUMEFFECTSCALLBACKW lpCallback, LPVOID pvRef, DWORD dwEffType )
+    HRESULT GetEffectInfo ( LPDIEFFECTINFOW pdei, REFGUID rguid )
+    HRESULT GetForceFeedbackState ( LPDWORD pdwOut )
+    HRESULT SendForceFeedbackCommand ( DWORD dwFlags )
+    HRESULT EnumCreatedEffectObjects ( LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback, LPVOID pvRef, DWORD fl )
+    HRESULT Escape ( LPDIEFFESCAPE pesc )
+    HRESULT Poll ( )
+    HRESULT SendDeviceData ( DWORD cbObjectData, LPCDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD fl )
+    HRESULT EnumEffectsInFile ( LPCWSTR lpszFileName, LPDIENUMEFFECTSINFILECALLBACK lpCallback, LPVOID pvRef, DWORD dwFlags )
+    HRESULT WriteEffectToFile ( LPCWSTR lpszFileName, DWORD dwEntries, LPDIFILEEFFECT rgDiFileEffect, DWORD dwFlags )
+    HRESULT BuildActionMap ( LPDIACTIONFORMATW lpdiaf, LPCWSTR lpszUserName, DWORD dwFlags )
+    HRESULT SetActionMap ( LPDIACTIONFORMATW lpdiActionFormat, LPCWSTR lpwszUserName, DWORD dwFlags )
+    HRESULT GetImageInfo ( LPDIDEVICEIMAGEINFOHEADERW lpdiDeviceImageInfoHeader ) ;
+
+CALLBACK: BOOL LPDIENUMDEVICESBYSEMANTICSCBW (
+    LPCDIDEVICEINSTANCEW lpddi, 
+    IDirectInputDevice8W* lpdid,
+    DWORD dwFlags,
+    DWORD dwRemaining,
+    LPVOID pvRef
+) ;
+
+COM-INTERFACE: IDirectInput8W IUnknown {BF798031-483A-4DA2-AA99-5D64ED369700}
+    HRESULT CreateDevice ( REFGUID rguid, IDirectInputDevice8W** lplpDevice, LPUNKNOWN pUnkOuter )
+    HRESULT EnumDevices ( DWORD dwDevType, LPDIENUMDEVICESCALLBACKW lpCallback, LPVOID pvRef, DWORD dwFlags )
+    HRESULT GetDeviceStatus ( REFGUID rguidInstance )
+    HRESULT RunControlPanel ( HWND hwndOwner, DWORD dwFlags )
+    HRESULT Initialize ( HINSTANCE hinst, DWORD dwVersion )
+    HRESULT FindDevice ( REFGUID rguidClass, LPCWSTR pwszName, LPGUID pguidInstance )
+    HRESULT EnumDevicesBySemantics ( LPCWSTR pwszUserName, LPDIACTIONFORMATW lpdiActionFormat, LPDIENUMDEVICESBYSEMANTICSCBW lpCallback, LPVOID pvRef, DWORD dwFlags )
+    HRESULT ConfigureDevices ( LPDICONFIGUREDEVICESCALLBACK lpdiCallback, LPDICONFIGUREDEVICESPARAMSW lpdiCDParams, DWORD dwFlags, LPVOID pvRefData ) ;
+
+FUNCTION: HRESULT DirectInput8Create ( HINSTANCE hinst, DWORD dwVersion, REFIID riidtlf, LPVOID* ppvOut, LPUNKNOWN punkOuter ) ;
+
+CONSTANT: DIRECTINPUT_VERSION HEX: 0800
+                               
+CONSTANT: DI8DEVCLASS_ALL             0
+CONSTANT: DI8DEVCLASS_DEVICE          1
+CONSTANT: DI8DEVCLASS_POINTER         2
+CONSTANT: DI8DEVCLASS_KEYBOARD        3
+CONSTANT: DI8DEVCLASS_GAMECTRL        4
+
+CONSTANT: DIEDFL_ALLDEVICES       HEX: 00000000
+CONSTANT: DIEDFL_ATTACHEDONLY     HEX: 00000001
+CONSTANT: DIEDFL_FORCEFEEDBACK    HEX: 00000100
+CONSTANT: DIEDFL_INCLUDEALIASES   HEX: 00010000
+CONSTANT: DIEDFL_INCLUDEPHANTOMS  HEX: 00020000
+CONSTANT: DIEDFL_INCLUDEHIDDEN    HEX: 00040000
+                                               
+CONSTANT: DIENUM_STOP             0
+CONSTANT: DIENUM_CONTINUE         1
+
+CONSTANT: DIDF_ABSAXIS            1
+CONSTANT: DIDF_RELAXIS            2
+
+CONSTANT: DIDFT_ALL           HEX: 00000000
+         
+CONSTANT: DIDFT_RELAXIS       HEX: 00000001
+CONSTANT: DIDFT_ABSAXIS       HEX: 00000002
+CONSTANT: DIDFT_AXIS          HEX: 00000003
+         
+CONSTANT: DIDFT_PSHBUTTON     HEX: 00000004
+CONSTANT: DIDFT_TGLBUTTON     HEX: 00000008
+CONSTANT: DIDFT_BUTTON        HEX: 0000000C
+         
+CONSTANT: DIDFT_POV           HEX: 00000010
+CONSTANT: DIDFT_COLLECTION    HEX: 00000040
+CONSTANT: DIDFT_NODATA        HEX: 00000080
+         
+CONSTANT: DIDFT_ANYINSTANCE   HEX: 00FFFF00
+ALIAS: DIDFT_INSTANCEMASK  DIDFT_ANYINSTANCE
+: DIDFT_MAKEINSTANCE ( n -- instance ) 8 shift                   ; inline
+: DIDFT_GETTYPE      ( n -- type     ) HEX: FF bitand            ; inline
+: DIDFT_GETINSTANCE  ( n -- instance ) -8 shift HEX: FFFF bitand ; inline
+CONSTANT: DIDFT_FFACTUATOR        HEX: 01000000
+CONSTANT: DIDFT_FFEFFECTTRIGGER   HEX: 02000000
+CONSTANT: DIDFT_OUTPUT            HEX: 10000000
+CONSTANT: DIDFT_VENDORDEFINED     HEX: 04000000
+CONSTANT: DIDFT_ALIAS             HEX: 08000000
+CONSTANT: DIDFT_OPTIONAL          HEX: 80000000
+
+: DIDFT_ENUMCOLLECTION ( n -- instance ) 8 shift HEX: FFFF bitand ; inline
+CONSTANT: DIDFT_NOCOLLECTION      HEX: 00FFFF00
+
+CONSTANT: DIDOI_FFACTUATOR        HEX: 00000001
+CONSTANT: DIDOI_FFEFFECTTRIGGER   HEX: 00000002
+CONSTANT: DIDOI_POLLED            HEX: 00008000
+CONSTANT: DIDOI_ASPECTPOSITION    HEX: 00000100
+CONSTANT: DIDOI_ASPECTVELOCITY    HEX: 00000200
+CONSTANT: DIDOI_ASPECTACCEL       HEX: 00000300
+CONSTANT: DIDOI_ASPECTFORCE       HEX: 00000400
+CONSTANT: DIDOI_ASPECTMASK        HEX: 00000F00
+CONSTANT: DIDOI_GUIDISUSAGE       HEX: 00010000
+
+CONSTANT: DISCL_EXCLUSIVE     HEX: 00000001
+CONSTANT: DISCL_NONEXCLUSIVE  HEX: 00000002
+CONSTANT: DISCL_FOREGROUND    HEX: 00000004
+CONSTANT: DISCL_BACKGROUND    HEX: 00000008
+CONSTANT: DISCL_NOWINKEY      HEX: 00000010
+
+CONSTANT: DIMOFS_X        0
+CONSTANT: DIMOFS_Y        4
+CONSTANT: DIMOFS_Z        8
+CONSTANT: DIMOFS_BUTTON0 12
+CONSTANT: DIMOFS_BUTTON1 13
+CONSTANT: DIMOFS_BUTTON2 14
+CONSTANT: DIMOFS_BUTTON3 15
+CONSTANT: DIMOFS_BUTTON4 16
+CONSTANT: DIMOFS_BUTTON5 17
+CONSTANT: DIMOFS_BUTTON6 18
+CONSTANT: DIMOFS_BUTTON7 19
+
+CONSTANT: DIK_ESCAPE          HEX: 01
+CONSTANT: DIK_1               HEX: 02
+CONSTANT: DIK_2               HEX: 03
+CONSTANT: DIK_3               HEX: 04
+CONSTANT: DIK_4               HEX: 05
+CONSTANT: DIK_5               HEX: 06
+CONSTANT: DIK_6               HEX: 07
+CONSTANT: DIK_7               HEX: 08
+CONSTANT: DIK_8               HEX: 09
+CONSTANT: DIK_9               HEX: 0A
+CONSTANT: DIK_0               HEX: 0B
+CONSTANT: DIK_MINUS           HEX: 0C
+CONSTANT: DIK_EQUALS          HEX: 0D
+CONSTANT: DIK_BACK            HEX: 0E
+CONSTANT: DIK_TAB             HEX: 0F
+CONSTANT: DIK_Q               HEX: 10
+CONSTANT: DIK_W               HEX: 11
+CONSTANT: DIK_E               HEX: 12
+CONSTANT: DIK_R               HEX: 13
+CONSTANT: DIK_T               HEX: 14
+CONSTANT: DIK_Y               HEX: 15
+CONSTANT: DIK_U               HEX: 16
+CONSTANT: DIK_I               HEX: 17
+CONSTANT: DIK_O               HEX: 18
+CONSTANT: DIK_P               HEX: 19
+CONSTANT: DIK_LBRACKET        HEX: 1A
+CONSTANT: DIK_RBRACKET        HEX: 1B
+CONSTANT: DIK_RETURN          HEX: 1C
+CONSTANT: DIK_LCONTROL        HEX: 1D
+CONSTANT: DIK_A               HEX: 1E
+CONSTANT: DIK_S               HEX: 1F
+CONSTANT: DIK_D               HEX: 20
+CONSTANT: DIK_F               HEX: 21
+CONSTANT: DIK_G               HEX: 22
+CONSTANT: DIK_H               HEX: 23
+CONSTANT: DIK_J               HEX: 24
+CONSTANT: DIK_K               HEX: 25
+CONSTANT: DIK_L               HEX: 26
+CONSTANT: DIK_SEMICOLON       HEX: 27
+CONSTANT: DIK_APOSTROPHE      HEX: 28
+CONSTANT: DIK_GRAVE           HEX: 29
+CONSTANT: DIK_LSHIFT          HEX: 2A
+CONSTANT: DIK_BACKSLASH       HEX: 2B
+CONSTANT: DIK_Z               HEX: 2C
+CONSTANT: DIK_X               HEX: 2D
+CONSTANT: DIK_C               HEX: 2E
+CONSTANT: DIK_V               HEX: 2F
+CONSTANT: DIK_B               HEX: 30
+CONSTANT: DIK_N               HEX: 31
+CONSTANT: DIK_M               HEX: 32
+CONSTANT: DIK_COMMA           HEX: 33
+CONSTANT: DIK_PERIOD          HEX: 34
+CONSTANT: DIK_SLASH           HEX: 35
+CONSTANT: DIK_RSHIFT          HEX: 36
+CONSTANT: DIK_MULTIPLY        HEX: 37
+CONSTANT: DIK_LMENU           HEX: 38
+CONSTANT: DIK_SPACE           HEX: 39
+CONSTANT: DIK_CAPITAL         HEX: 3A
+CONSTANT: DIK_F1              HEX: 3B
+CONSTANT: DIK_F2              HEX: 3C
+CONSTANT: DIK_F3              HEX: 3D
+CONSTANT: DIK_F4              HEX: 3E
+CONSTANT: DIK_F5              HEX: 3F
+CONSTANT: DIK_F6              HEX: 40
+CONSTANT: DIK_F7              HEX: 41
+CONSTANT: DIK_F8              HEX: 42
+CONSTANT: DIK_F9              HEX: 43
+CONSTANT: DIK_F10             HEX: 44
+CONSTANT: DIK_NUMLOCK         HEX: 45
+CONSTANT: DIK_SCROLL          HEX: 46
+CONSTANT: DIK_NUMPAD7         HEX: 47
+CONSTANT: DIK_NUMPAD8         HEX: 48
+CONSTANT: DIK_NUMPAD9         HEX: 49
+CONSTANT: DIK_SUBTRACT        HEX: 4A
+CONSTANT: DIK_NUMPAD4         HEX: 4B
+CONSTANT: DIK_NUMPAD5         HEX: 4C
+CONSTANT: DIK_NUMPAD6         HEX: 4D
+CONSTANT: DIK_ADD             HEX: 4E
+CONSTANT: DIK_NUMPAD1         HEX: 4F
+CONSTANT: DIK_NUMPAD2         HEX: 50
+CONSTANT: DIK_NUMPAD3         HEX: 51
+CONSTANT: DIK_NUMPAD0         HEX: 52
+CONSTANT: DIK_DECIMAL         HEX: 53
+CONSTANT: DIK_OEM_102         HEX: 56
+CONSTANT: DIK_F11             HEX: 57
+CONSTANT: DIK_F12             HEX: 58
+CONSTANT: DIK_F13             HEX: 64
+CONSTANT: DIK_F14             HEX: 65
+CONSTANT: DIK_F15             HEX: 66
+CONSTANT: DIK_KANA            HEX: 70
+CONSTANT: DIK_ABNT_C1         HEX: 73
+CONSTANT: DIK_CONVERT         HEX: 79
+CONSTANT: DIK_NOCONVERT       HEX: 7B
+CONSTANT: DIK_YEN             HEX: 7D
+CONSTANT: DIK_ABNT_C2         HEX: 7E
+CONSTANT: DIK_NUMPADEQUALS    HEX: 8D
+CONSTANT: DIK_PREVTRACK       HEX: 90
+CONSTANT: DIK_AT              HEX: 91
+CONSTANT: DIK_COLON           HEX: 92
+CONSTANT: DIK_UNDERLINE       HEX: 93
+CONSTANT: DIK_KANJI           HEX: 94
+CONSTANT: DIK_STOP            HEX: 95
+CONSTANT: DIK_AX              HEX: 96
+CONSTANT: DIK_UNLABELED       HEX: 97
+CONSTANT: DIK_NEXTTRACK       HEX: 99
+CONSTANT: DIK_NUMPADENTER     HEX: 9C
+CONSTANT: DIK_RCONTROL        HEX: 9D
+CONSTANT: DIK_MUTE            HEX: A0
+CONSTANT: DIK_CALCULATOR      HEX: A1
+CONSTANT: DIK_PLAYPAUSE       HEX: A2
+CONSTANT: DIK_MEDIASTOP       HEX: A4
+CONSTANT: DIK_VOLUMEDOWN      HEX: AE
+CONSTANT: DIK_VOLUMEUP        HEX: B0
+CONSTANT: DIK_WEBHOME         HEX: B2
+CONSTANT: DIK_NUMPADCOMMA     HEX: B3
+CONSTANT: DIK_DIVIDE          HEX: B5
+CONSTANT: DIK_SYSRQ           HEX: B7
+CONSTANT: DIK_RMENU           HEX: B8
+CONSTANT: DIK_PAUSE           HEX: C5
+CONSTANT: DIK_HOME            HEX: C7
+CONSTANT: DIK_UP              HEX: C8
+CONSTANT: DIK_PRIOR           HEX: C9
+CONSTANT: DIK_LEFT            HEX: CB
+CONSTANT: DIK_RIGHT           HEX: CD
+CONSTANT: DIK_END             HEX: CF
+CONSTANT: DIK_DOWN            HEX: D0
+CONSTANT: DIK_NEXT            HEX: D1
+CONSTANT: DIK_INSERT          HEX: D2
+CONSTANT: DIK_DELETE          HEX: D3
+CONSTANT: DIK_LWIN            HEX: DB
+CONSTANT: DIK_RWIN            HEX: DC
+CONSTANT: DIK_APPS            HEX: DD
+CONSTANT: DIK_POWER           HEX: DE
+CONSTANT: DIK_SLEEP           HEX: DF
+CONSTANT: DIK_WAKE            HEX: E3
+CONSTANT: DIK_WEBSEARCH       HEX: E5
+CONSTANT: DIK_WEBFAVORITES    HEX: E6
+CONSTANT: DIK_WEBREFRESH      HEX: E7
+CONSTANT: DIK_WEBSTOP         HEX: E8
+CONSTANT: DIK_WEBFORWARD      HEX: E9
+CONSTANT: DIK_WEBBACK         HEX: EA
+CONSTANT: DIK_MYCOMPUTER      HEX: EB
+CONSTANT: DIK_MAIL            HEX: EC
+CONSTANT: DIK_MEDIASELECT     HEX: ED
+
+ALIAS: DIK_BACKSPACE       DIK_BACK
+ALIAS: DIK_NUMPADSTAR      DIK_MULTIPLY
+ALIAS: DIK_LALT            DIK_LMENU
+ALIAS: DIK_CAPSLOCK        DIK_CAPITAL
+ALIAS: DIK_NUMPADMINUS     DIK_SUBTRACT
+ALIAS: DIK_NUMPADPLUS      DIK_ADD
+ALIAS: DIK_NUMPADPERIOD    DIK_DECIMAL
+ALIAS: DIK_NUMPADSLASH     DIK_DIVIDE
+ALIAS: DIK_RALT            DIK_RMENU
+ALIAS: DIK_UPARROW         DIK_UP
+ALIAS: DIK_PGUP            DIK_PRIOR
+ALIAS: DIK_LEFTARROW       DIK_LEFT
+ALIAS: DIK_RIGHTARROW      DIK_RIGHT
+ALIAS: DIK_DOWNARROW       DIK_DOWN
+ALIAS: DIK_PGDN            DIK_NEXT
+
+ALIAS: DIK_CIRCUMFLEX      DIK_PREVTRACK
+
+CONSTANT: DI8DEVTYPE_DEVICE           HEX: 11
+CONSTANT: DI8DEVTYPE_MOUSE            HEX: 12
+CONSTANT: DI8DEVTYPE_KEYBOARD         HEX: 13
+CONSTANT: DI8DEVTYPE_JOYSTICK         HEX: 14
+CONSTANT: DI8DEVTYPE_GAMEPAD          HEX: 15
+CONSTANT: DI8DEVTYPE_DRIVING          HEX: 16
+CONSTANT: DI8DEVTYPE_FLIGHT           HEX: 17
+CONSTANT: DI8DEVTYPE_1STPERSON        HEX: 18
+CONSTANT: DI8DEVTYPE_DEVICECTRL       HEX: 19
+CONSTANT: DI8DEVTYPE_SCREENPOINTER    HEX: 1A
+CONSTANT: DI8DEVTYPE_REMOTE           HEX: 1B
+CONSTANT: DI8DEVTYPE_SUPPLEMENTAL     HEX: 1C
+
+: GET_DIDEVICE_TYPE ( dwType -- type ) HEX: FF bitand ; inline
+
+CONSTANT: DIPROPRANGE_NOMIN       HEX: 80000000
+CONSTANT: DIPROPRANGE_NOMAX       HEX: 7FFFFFFF
+CONSTANT: MAXCPOINTSNUM           8
+
+CONSTANT: DIPH_DEVICE             0
+CONSTANT: DIPH_BYOFFSET           1
+CONSTANT: DIPH_BYID               2
+CONSTANT: DIPH_BYUSAGE            3
+                                   
+: DIMAKEUSAGEDWORD ( UsagePage Usage -- DWORD ) 16 shift bitor ; inline
+
+: DIPROP_BUFFERSIZE ( -- alien ) 1 <alien> ; inline
+: DIPROP_AXISMODE   ( -- alien ) 2 <alien> ; inline
+
+CONSTANT: DIPROPAXISMODE_ABS      0
+CONSTANT: DIPROPAXISMODE_REL      1
+                                   
+: DIPROP_GRANULARITY ( -- alien ) 3 <alien> ; inline
+: DIPROP_RANGE       ( -- alien ) 4 <alien> ; inline
+: DIPROP_DEADZONE    ( -- alien ) 5 <alien> ; inline
+: DIPROP_SATURATION  ( -- alien ) 6 <alien> ; inline
+: DIPROP_FFGAIN      ( -- alien ) 7 <alien> ; inline
+: DIPROP_FFLOAD      ( -- alien ) 8 <alien> ; inline
+: DIPROP_AUTOCENTER  ( -- alien ) 9 <alien> ; inline
+
+CONSTANT: DIPROPAUTOCENTER_OFF    0
+CONSTANT: DIPROPAUTOCENTER_ON     1
+
+: DIPROP_CALIBRATIONMODE ( -- alien ) 10 <alien> ; inline
+
+CONSTANT: DIPROPCALIBRATIONMODE_COOKED    0
+CONSTANT: DIPROPCALIBRATIONMODE_RAW       1
+
+: DIPROP_CALIBRATION ( -- alien )        11 <alien> ; inline
+: DIPROP_GUIDANDPATH ( -- alien )        12 <alien> ; inline
+: DIPROP_INSTANCENAME ( -- alien )       13 <alien> ; inline
+: DIPROP_PRODUCTNAME ( -- alien )        14 <alien> ; inline
+: DIPROP_JOYSTICKID ( -- alien )         15 <alien> ; inline
+: DIPROP_GETPORTDISPLAYNAME ( -- alien ) 16 <alien> ; inline
+: DIPROP_PHYSICALRANGE ( -- alien )      18 <alien> ; inline
+: DIPROP_LOGICALRANGE ( -- alien )       19 <alien> ; inline
+: DIPROP_KEYNAME ( -- alien )            20 <alien> ; inline
+: DIPROP_CPOINTS ( -- alien )            21 <alien> ; inline
+: DIPROP_APPDATA ( -- alien )            22 <alien> ; inline
+: DIPROP_SCANCODE ( -- alien )           23 <alien> ; inline
+: DIPROP_VIDPID ( -- alien )             24 <alien> ; inline
+: DIPROP_USERNAME ( -- alien )           25 <alien> ; inline
+: DIPROP_TYPENAME ( -- alien )           26 <alien> ; inline
+
+CONSTANT: GUID_XAxis          GUID: {A36D02E0-C9F3-11CF-BFC7-444553540000}
+CONSTANT: GUID_YAxis          GUID: {A36D02E1-C9F3-11CF-BFC7-444553540000}
+CONSTANT: GUID_ZAxis          GUID: {A36D02E2-C9F3-11CF-BFC7-444553540000}
+CONSTANT: GUID_RxAxis         GUID: {A36D02F4-C9F3-11CF-BFC7-444553540000}
+CONSTANT: GUID_RyAxis         GUID: {A36D02F5-C9F3-11CF-BFC7-444553540000}
+CONSTANT: GUID_RzAxis         GUID: {A36D02E3-C9F3-11CF-BFC7-444553540000}
+CONSTANT: GUID_Slider         GUID: {A36D02E4-C9F3-11CF-BFC7-444553540000}
+CONSTANT: GUID_Button         GUID: {A36D02F0-C9F3-11CF-BFC7-444553540000}
+CONSTANT: GUID_Key            GUID: {55728220-D33C-11CF-BFC7-444553540000}
+CONSTANT: GUID_POV            GUID: {A36D02F2-C9F3-11CF-BFC7-444553540000}
+CONSTANT: GUID_Unknown        GUID: {A36D02F3-C9F3-11CF-BFC7-444553540000}
+CONSTANT: GUID_SysMouse       GUID: {6F1D2B60-D5A0-11CF-BFC7-444553540000}
+CONSTANT: GUID_SysKeyboard    GUID: {6F1D2B61-D5A0-11CF-BFC7-444553540000}
+CONSTANT: GUID_Joystick       GUID: {6F1D2B70-D5A0-11CF-BFC7-444553540000}
+CONSTANT: GUID_SysMouseEm     GUID: {6F1D2B80-D5A0-11CF-BFC7-444553540000}
+CONSTANT: GUID_SysMouseEm2    GUID: {6F1D2B81-D5A0-11CF-BFC7-444553540000}
+CONSTANT: GUID_SysKeyboardEm  GUID: {6F1D2B82-D5A0-11CF-BFC7-444553540000}
+CONSTANT: GUID_SysKeyboardEm2 GUID: {6F1D2B83-D5A0-11CF-BFC7-444553540000}
diff --git a/basis/windows/directx/dinput/summary.txt b/basis/windows/directx/dinput/summary.txt
new file mode 100644 (file)
index 0000000..7747560
--- /dev/null
@@ -0,0 +1 @@
+DirectInput bindings
diff --git a/basis/windows/directx/dinput/tags.txt b/basis/windows/directx/dinput/tags.txt
new file mode 100644 (file)
index 0000000..2320bdd
--- /dev/null
@@ -0,0 +1,2 @@
+unportable
+bindings
diff --git a/basis/windows/directx/dwrite/authors.txt b/basis/windows/directx/dwrite/authors.txt
new file mode 100644 (file)
index 0000000..6f03a12
--- /dev/null
@@ -0,0 +1 @@
+Erik Charlebois
diff --git a/basis/windows/directx/dwrite/dwrite.factor b/basis/windows/directx/dwrite/dwrite.factor
new file mode 100644 (file)
index 0000000..3e4167e
--- /dev/null
@@ -0,0 +1,676 @@
+USING: alien.c-types alien.syntax classes.struct windows.com
+windows.com.syntax windows.directx.dcommon windows.kernel32
+windows.ole32 windows.types ;
+IN: windows.directx.dwrite
+
+LIBRARY: dwrite
+
+C-ENUM:
+    DWRITE_FONT_FILE_TYPE_UNKNOWN
+    DWRITE_FONT_FILE_TYPE_CFF
+    DWRITE_FONT_FILE_TYPE_TRUETYPE
+    DWRITE_FONT_FILE_TYPE_TRUETYPE_COLLECTION
+    DWRITE_FONT_FILE_TYPE_TYPE1_PFM
+    DWRITE_FONT_FILE_TYPE_TYPE1_PFB
+    DWRITE_FONT_FILE_TYPE_VECTOR
+    DWRITE_FONT_FILE_TYPE_BITMAP ;
+TYPEDEF: int DWRITE_FONT_FILE_TYPE
+
+C-ENUM:
+    DWRITE_FONT_FACE_TYPE_CFF
+    DWRITE_FONT_FACE_TYPE_TRUETYPE
+    DWRITE_FONT_FACE_TYPE_TRUETYPE_COLLECTION
+    DWRITE_FONT_FACE_TYPE_TYPE1
+    DWRITE_FONT_FACE_TYPE_VECTOR
+    DWRITE_FONT_FACE_TYPE_BITMAP
+    DWRITE_FONT_FACE_TYPE_UNKNOWN ;
+TYPEDEF: int DWRITE_FONT_FACE_TYPE
+
+CONSTANT: DWRITE_FONT_SIMULATIONS_NONE    0
+CONSTANT: DWRITE_FONT_SIMULATIONS_BOLD    1
+CONSTANT: DWRITE_FONT_SIMULATIONS_OBLIQUE 2
+TYPEDEF: int DWRITE_FONT_SIMULATIONS
+
+CONSTANT: DWRITE_FONT_WEIGHT_THIN        100
+CONSTANT: DWRITE_FONT_WEIGHT_EXTRA_LIGHT 200
+CONSTANT: DWRITE_FONT_WEIGHT_ULTRA_LIGHT 200
+CONSTANT: DWRITE_FONT_WEIGHT_LIGHT       300
+CONSTANT: DWRITE_FONT_WEIGHT_NORMAL      400
+CONSTANT: DWRITE_FONT_WEIGHT_REGULAR     400
+CONSTANT: DWRITE_FONT_WEIGHT_MEDIUM      500
+CONSTANT: DWRITE_FONT_WEIGHT_DEMI_BOLD   600
+CONSTANT: DWRITE_FONT_WEIGHT_SEMI_BOLD   600
+CONSTANT: DWRITE_FONT_WEIGHT_BOLD        700
+CONSTANT: DWRITE_FONT_WEIGHT_EXTRA_BOLD  800
+CONSTANT: DWRITE_FONT_WEIGHT_ULTRA_BOLD  800
+CONSTANT: DWRITE_FONT_WEIGHT_BLACK       900
+CONSTANT: DWRITE_FONT_WEIGHT_HEAVY       900
+CONSTANT: DWRITE_FONT_WEIGHT_EXTRA_BLACK 950
+CONSTANT: DWRITE_FONT_WEIGHT_ULTRA_BLACK 950
+TYPEDEF: int DWRITE_FONT_WEIGHT
+
+CONSTANT: DWRITE_FONT_STRETCH_UNDEFINED       0
+CONSTANT: DWRITE_FONT_STRETCH_ULTRA_CONDENSED 1
+CONSTANT: DWRITE_FONT_STRETCH_EXTRA_CONDENSED 2
+CONSTANT: DWRITE_FONT_STRETCH_CONDENSED       3
+CONSTANT: DWRITE_FONT_STRETCH_SEMI_CONDENSED  4
+CONSTANT: DWRITE_FONT_STRETCH_NORMAL          5
+CONSTANT: DWRITE_FONT_STRETCH_MEDIUM          5
+CONSTANT: DWRITE_FONT_STRETCH_SEMI_EXPANDED   6
+CONSTANT: DWRITE_FONT_STRETCH_EXPANDED        7
+CONSTANT: DWRITE_FONT_STRETCH_EXTRA_EXPANDED  8
+CONSTANT: DWRITE_FONT_STRETCH_ULTRA_EXPANDED  9
+TYPEDEF: int DWRITE_FONT_STRETCH
+
+C-ENUM:
+    DWRITE_FONT_STYLE_NORMAL
+    DWRITE_FONT_STYLE_OBLIQUE
+    DWRITE_FONT_STYLE_ITALIC ;
+TYPEDEF: int DWRITE_FONT_STYLE
+
+C-ENUM:
+    DWRITE_INFORMATIONAL_STRING_NONE
+    DWRITE_INFORMATIONAL_STRING_COPYRIGHT_NOTICE
+    DWRITE_INFORMATIONAL_STRING_VERSION_STRINGS
+    DWRITE_INFORMATIONAL_STRING_TRADEMARK
+    DWRITE_INFORMATIONAL_STRING_MANUFACTURER
+    DWRITE_INFORMATIONAL_STRING_DESIGNER
+    DWRITE_INFORMATIONAL_STRING_DESIGNER_URL
+    DWRITE_INFORMATIONAL_STRING_DESCRIPTION
+    DWRITE_INFORMATIONAL_STRING_FONT_VENDOR_URL
+    DWRITE_INFORMATIONAL_STRING_LICENSE_DESCRIPTION
+    DWRITE_INFORMATIONAL_STRING_LICENSE_INFO_URL
+    DWRITE_INFORMATIONAL_STRING_WIN32_FAMILY_NAMES
+    DWRITE_INFORMATIONAL_STRING_WIN32_SUBFAMILY_NAMES
+    DWRITE_INFORMATIONAL_STRING_PREFERRED_FAMILY_NAMES
+    DWRITE_INFORMATIONAL_STRING_PREFERRED_SUBFAMILY_NAMES
+    DWRITE_INFORMATIONAL_STRING_SAMPLE_TEXT ;
+TYPEDEF: int DWRITE_INFORMATIONAL_STRING_ID
+
+STRUCT: DWRITE_FONT_METRICS
+    { designUnitsPerEm       USHORT }
+    { ascent                 USHORT }
+    { descent                USHORT }
+    { lineGap                SHORT  }
+    { capHeight              USHORT }
+    { xHeight                USHORT }
+    { underlinePosition      SHORT  }
+    { underlineThickness     USHORT }
+    { strikethroughPosition  SHORT  }
+    { strikethroughThickness USHORT } ;
+
+STRUCT: DWRITE_GLYPH_METRICS
+    { leftSideBearing   INT32  }
+    { advanceWidth      UINT32 }
+    { rightSideBearing  INT32  }
+    { topSideBearing    INT32  }
+    { advanceHeight     UINT32 }
+    { bottomSideBearing INT32  }
+    { verticalOriginY   INT32  } ;
+
+STRUCT: DWRITE_GLYPH_OFFSET
+    { advanceOffset  FLOAT }
+    { ascenderOffset FLOAT } ;
+
+C-ENUM:
+    DWRITE_FACTORY_TYPE_SHARED
+    DWRITE_FACTORY_TYPE_ISOLATED ;
+TYPEDEF: int DWRITE_FACTORY_TYPE
+
+C-TYPE: IDWriteFontFileStream
+
+COM-INTERFACE: IDWriteFontFileLoader IUnknown {727cad4e-d6af-4c9e-8a08-d695b11caa49}
+    HRESULT CreateStreamFromKey ( void* fontFileReferenceKey, UINT32 fontFileReferenceKeySize, IDWriteFontFileStream** fontFileStream ) ;
+
+COM-INTERFACE: IDWriteLocalFontFileLoader IDWriteFontFileLoader {b2d9f3ec-c9fe-4a11-a2ec-d86208f7c0a2}
+    HRESULT GetFilePathLengthFromKey ( void* fontFileReferenceKey, UINT32 fontFileReferenceKeySize, UINT32* filePathLength )
+    HRESULT GetFilePathFromKey ( void* fontFileReferenceKey, UINT32 fontFileReferenceKeySize, WCHAR* filePath, UINT32 filePathSize )
+    HRESULT GetLastWriteTimeFromKey ( void* fontFileReferenceKey, UINT32 fontFileReferenceKeySize, FILETIME* lastWriteTime ) ;
+
+COM-INTERFACE: IDWriteFontFileStream IUnknown {6d4865fe-0ab8-4d91-8f62-5dd6be34a3e0}
+    HRESULT ReadFileFragment ( void** fragmentStart, UINT64 fileOffset, UINT64 fragmentSize, void** fragmentContext )
+    void ReleaseFileFragment ( void* fragmentContext )
+    HRESULT GetFileSize ( UINT64* fileSize )
+    HRESULT GetLastWriteTime ( UINT64* lastWriteTime ) ;
+
+COM-INTERFACE: IDWriteFontFile IUnknown {739d886a-cef5-47dc-8769-1a8b41bebbb0}
+    HRESULT GetReferenceKey ( void** fontFileReferenceKey, UINT32* fontFileReferenceKeySize )
+    HRESULT GetLoader ( IDWriteFontFileLoader** fontFileLoader )
+    HRESULT Analyze ( BOOL* isSupportedFontType, DWRITE_FONT_FILE_TYPE* fontFileType, DWRITE_FONT_FACE_TYPE* fontFaceType, UINT32* numberOfFaces ) ;
+
+TYPEDEF: int DWRITE_PIXEL_GEOMETRY
+C-ENUM:
+    DWRITE_PIXEL_GEOMETRY_FLAT
+    DWRITE_PIXEL_GEOMETRY_RGB
+    DWRITE_PIXEL_GEOMETRY_BGR ;
+
+TYPEDEF: int DWRITE_RENDERING_MODE
+C-ENUM:
+    DWRITE_RENDERING_MODE_DEFAULT
+    DWRITE_RENDERING_MODE_ALIASED
+    DWRITE_RENDERING_MODE_CLEARTYPE_GDI_CLASSIC
+    DWRITE_RENDERING_MODE_CLEARTYPE_GDI_NATURAL
+    DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL
+    DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL_SYMMETRIC
+    DWRITE_RENDERING_MODE_OUTLINE ;
+
+STRUCT: DWRITE_MATRIX
+    { m11 FLOAT }
+    { m12 FLOAT }
+    { m21 FLOAT }
+    { m22 FLOAT }
+    { dx  FLOAT }
+    { dy  FLOAT } ;
+
+COM-INTERFACE: IDWriteRenderingParams IUnknown {2f0da53a-2add-47cd-82ee-d9ec34688e75}
+    FLOAT GetGamma ( )
+    FLOAT GetEnhancedContrast ( )
+    FLOAT GetClearTypeLevel ( )
+    DWRITE_PIXEL_GEOMETRY GetPixelGeometry ( )
+    DWRITE_RENDERING_MODE GetRenderingMode ( ) ;
+
+C-TYPE: ID2D1SimplifiedGeometrySink
+
+TYPEDEF: ID2D1SimplifiedGeometrySink IDWriteGeometrySink
+
+COM-INTERFACE: IDWriteFontFace IUnknown {5f49804d-7024-4d43-bfa9-d25984f53849}
+    DWRITE_FONT_FACE_TYPE GetType ( )
+    HRESULT GetFiles ( UINT32* numberOfFiles, IDWriteFontFile** fontFiles )
+    UINT32 GetIndex ( )
+    DWRITE_FONT_SIMULATIONS GetSimulations ( )
+    BOOL IsSymbolFont ( )
+    void GetMetrics ( DWRITE_FONT_METRICS* fontFaceMetrics )
+    USHORT GetGlyphCount ( )
+    HRESULT GetDesignGlyphMetrics ( USHORT* glyphIndices, UINT32 glyphCount, DWRITE_GLYPH_METRICS* glyphMetrics, BOOL isSideways )
+    HRESULT GetGlyphIndices ( UINT32* codePoints, UINT32 codePointCount, USHORT* glyphIndices )
+    HRESULT TryGetFontTable ( UINT32 openTypeTableTag, void** tableData, UINT32* tableSize, void** tableContext, BOOL* exists )
+    void ReleaseFontTable ( void* tableContext )
+    HRESULT GetGlyphRunOutline ( FLOAT emSize, USHORT* glyphIndices, FLOAT* glyphAdvances, DWRITE_GLYPH_OFFSET* glyphOffsets, UINT32 glyphCount, BOOL isSideways, BOOL isRightToLeft, IDWriteGeometrySink* geometrySink )
+    HRESULT GetRecommendedRenderingMode ( FLOAT emSize, FLOAT pixelsPerDip, DWRITE_MEASURING_MODE measuringMode, IDWriteRenderingParams* renderingParams, DWRITE_RENDERING_MODE* renderingMode )
+    HRESULT GetGdiCompatibleMetrics ( FLOAT emSize, FLOAT pixelsPerDip, DWRITE_MATRIX* transform, DWRITE_FONT_METRICS* fontFaceMetrics )
+    HRESULT GetGdiCompatibleGlyphMetrics ( FLOAT emSize, FLOAT pixelsPerDip, DWRITE_MATRIX* transform, BOOL useGdiNatural, USHORT* glyphIndices, UINT32 glyphCount, DWRITE_GLYPH_METRICS* glyphMetrics, BOOL isSideways ) ;
+
+C-TYPE: IDWriteFactory
+C-TYPE: IDWriteFontFileEnumerator
+
+COM-INTERFACE: IDWriteFontCollectionLoader IUnknown {cca920e4-52f0-492b-bfa8-29c72ee0a468}
+    HRESULT CreateEnumeratorFromKey ( IDWriteFactory* factory, void* collectionKey, UINT32 collectionKeySize, IDWriteFontFileEnumerator** fontFileEnumerator ) ;
+
+COM-INTERFACE: IDWriteFontFileEnumerator IUnknown {72755049-5ff7-435d-8348-4be97cfa6c7c}
+    HRESULT MoveNext ( BOOL* hasCurrentFile )
+    HRESULT GetCurrentFontFile ( IDWriteFontFile** fontFile ) ;
+
+COM-INTERFACE: IDWriteLocalizedStrings IUnknown {08256209-099a-4b34-b86d-c22b110e7771}
+    UINT32 GetCount ( )
+    HRESULT FindLocaleName ( WCHAR* localeName, UINT32* index, BOOL* exists )
+    HRESULT GetLocaleNameLength ( UINT32 index, UINT32* length )
+    HRESULT GetLocaleName ( UINT32 index, WCHAR* localeName, UINT32 size )
+    HRESULT GetStringLength ( UINT32 index, UINT32* length )
+    HRESULT GetString ( UINT32 index, WCHAR* stringBuffer, UINT32 size ) ;
+
+C-TYPE: IDWriteFontFamily
+C-TYPE: IDWriteFont
+
+COM-INTERFACE: IDWriteFontCollection IUnknown {a84cee02-3eea-4eee-a827-87c1a02a0fcc}
+    UINT32 GetFontFamilyCount ( )
+    HRESULT GetFontFamily ( UINT32 index, IDWriteFontFamily** fontFamily )
+    HRESULT FindFamilyName ( WCHAR* familyName, UINT32* index, BOOL* exists )
+    HRESULT GetFontFromFontFace ( IDWriteFontFace* fontFace, IDWriteFont** font ) ;
+
+COM-INTERFACE: IDWriteFontList IUnknown {1a0d8438-1d97-4ec1-aef9-a2fb86ed6acb}
+    HRESULT GetFontCollection ( IDWriteFontCollection** fontCollection )
+    UINT32 GetFontCount ( )
+    HRESULT GetFont ( UINT32 index, IDWriteFont** font ) ;
+
+COM-INTERFACE: IDWriteFontFamily IDWriteFontList {da20d8ef-812a-4c43-9802-62ec4abd7add}
+    HRESULT GetFamilyNames ( IDWriteLocalizedStrings** names )
+    HRESULT GetFirstMatchingFont ( DWRITE_FONT_WEIGHT  weight, DWRITE_FONT_STRETCH stretch, DWRITE_FONT_STYLE style, IDWriteFont** matchingFont )
+    HRESULT GetMatchingFonts ( DWRITE_FONT_WEIGHT weight, DWRITE_FONT_STRETCH stretch, DWRITE_FONT_STYLE style, IDWriteFontList** matchingFonts ) ;
+
+COM-INTERFACE: IDWriteFont IUnknown {acd16696-8c14-4f5d-877e-fe3fc1d32737}
+    HRESULT GetFontFamily ( IDWriteFontFamily** fontFamily )
+    DWRITE_FONT_WEIGHT GetWeight ( )
+    DWRITE_FONT_STRETCH GetStretch ( )
+    DWRITE_FONT_STYLE GetStyle ( )
+    BOOL IsSymbolFont ( )
+    HRESULT GetFaceNames ( IDWriteLocalizedStrings** names )
+    HRESULT GetInformationalStrings ( DWRITE_INFORMATIONAL_STRING_ID informationalStringID, IDWriteLocalizedStrings** informationalStrings, BOOL* exists )
+    DWRITE_FONT_SIMULATIONS GetSimulations ( )
+    void GetMetrics ( DWRITE_FONT_METRICS* fontMetrics )
+    HRESULT HasCharacter ( UINT32 unicodeValue, BOOL* exists )
+    HRESULT CreateFontFace ( IDWriteFontFace** fontFace ) ;
+
+TYPEDEF: int DWRITE_READING_DIRECTION
+C-ENUM:
+    DWRITE_READING_DIRECTION_LEFT_TO_RIGHT
+    DWRITE_READING_DIRECTION_RIGHT_TO_LEFT ;
+
+TYPEDEF: int DWRITE_FLOW_DIRECTION
+C-ENUM:
+    DWRITE_FLOW_DIRECTION_TOP_TO_BOTTOM ;
+
+TYPEDEF: int DWRITE_TEXT_ALIGNMENT
+C-ENUM:
+    DWRITE_TEXT_ALIGNMENT_LEADING
+    DWRITE_TEXT_ALIGNMENT_TRAILING
+    DWRITE_TEXT_ALIGNMENT_CENTER ;
+
+TYPEDEF: int DWRITE_PARAGRAPH_ALIGNMENT
+C-ENUM:
+    DWRITE_PARAGRAPH_ALIGNMENT_NEAR
+    DWRITE_PARAGRAPH_ALIGNMENT_FAR
+    DWRITE_PARAGRAPH_ALIGNMENT_CENTER ;
+
+TYPEDEF: int DWRITE_WORD_WRAPPING
+C-ENUM:
+    DWRITE_WORD_WRAPPING_WRAP
+    DWRITE_WORD_WRAPPING_NO_WRAP ;
+
+TYPEDEF: int DWRITE_LINE_SPACING_METHOD
+C-ENUM:
+    DWRITE_LINE_SPACING_METHOD_DEFAULT
+    DWRITE_LINE_SPACING_METHOD_UNIFORM ;
+
+TYPEDEF: int DWRITE_TRIMMING_GRANULARITY
+C-ENUM:
+    DWRITE_TRIMMING_GRANULARITY_NONE
+    DWRITE_TRIMMING_GRANULARITY_CHARACTER
+    DWRITE_TRIMMING_GRANULARITY_WORD ;
+
+TYPEDEF: int DWRITE_FONT_FEATURE_TAG
+CONSTANT: DWRITE_FONT_FEATURE_TAG_ALTERNATIVE_FRACTIONS               HEX: 63726661
+CONSTANT: DWRITE_FONT_FEATURE_TAG_PETITE_CAPITALS_FROM_CAPITALS       HEX: 63703263
+CONSTANT: DWRITE_FONT_FEATURE_TAG_SMALL_CAPITALS_FROM_CAPITALS        HEX: 63733263
+CONSTANT: DWRITE_FONT_FEATURE_TAG_CONTEXTUAL_ALTERNATES               HEX: 746c6163
+CONSTANT: DWRITE_FONT_FEATURE_TAG_CASE_SENSITIVE_FORMS                HEX: 65736163
+CONSTANT: DWRITE_FONT_FEATURE_TAG_GLYPH_COMPOSITION_DECOMPOSITION     HEX: 706d6363
+CONSTANT: DWRITE_FONT_FEATURE_TAG_CONTEXTUAL_LIGATURES                HEX: 67696c63
+CONSTANT: DWRITE_FONT_FEATURE_TAG_CAPITAL_SPACING                     HEX: 70737063
+CONSTANT: DWRITE_FONT_FEATURE_TAG_CONTEXTUAL_SWASH                    HEX: 68777363
+CONSTANT: DWRITE_FONT_FEATURE_TAG_CURSIVE_POSITIONING                 HEX: 73727563
+CONSTANT: DWRITE_FONT_FEATURE_TAG_DEFAULT                             HEX: 746c6664
+CONSTANT: DWRITE_FONT_FEATURE_TAG_DISCRETIONARY_LIGATURES             HEX: 67696c64
+CONSTANT: DWRITE_FONT_FEATURE_TAG_EXPERT_FORMS                        HEX: 74707865
+CONSTANT: DWRITE_FONT_FEATURE_TAG_FRACTIONS                           HEX: 63617266
+CONSTANT: DWRITE_FONT_FEATURE_TAG_FULL_WIDTH                          HEX: 64697766
+CONSTANT: DWRITE_FONT_FEATURE_TAG_HALF_FORMS                          HEX: 666c6168
+CONSTANT: DWRITE_FONT_FEATURE_TAG_HALANT_FORMS                        HEX: 6e6c6168
+CONSTANT: DWRITE_FONT_FEATURE_TAG_ALTERNATE_HALF_WIDTH                HEX: 746c6168
+CONSTANT: DWRITE_FONT_FEATURE_TAG_HISTORICAL_FORMS                    HEX: 74736968
+CONSTANT: DWRITE_FONT_FEATURE_TAG_HORIZONTAL_KANA_ALTERNATES          HEX: 616e6b68
+CONSTANT: DWRITE_FONT_FEATURE_TAG_HISTORICAL_LIGATURES                HEX: 67696c68
+CONSTANT: DWRITE_FONT_FEATURE_TAG_HALF_WIDTH                          HEX: 64697768
+CONSTANT: DWRITE_FONT_FEATURE_TAG_HOJO_KANJI_FORMS                    HEX: 6f6a6f68
+CONSTANT: DWRITE_FONT_FEATURE_TAG_JIS04_FORMS                         HEX: 3430706a
+CONSTANT: DWRITE_FONT_FEATURE_TAG_JIS78_FORMS                         HEX: 3837706a
+CONSTANT: DWRITE_FONT_FEATURE_TAG_JIS83_FORMS                         HEX: 3338706a
+CONSTANT: DWRITE_FONT_FEATURE_TAG_JIS90_FORMS                         HEX: 3039706a
+CONSTANT: DWRITE_FONT_FEATURE_TAG_KERNING                             HEX: 6e72656b
+CONSTANT: DWRITE_FONT_FEATURE_TAG_STANDARD_LIGATURES                  HEX: 6167696c
+CONSTANT: DWRITE_FONT_FEATURE_TAG_LINING_FIGURES                      HEX: 6d756e6c
+CONSTANT: DWRITE_FONT_FEATURE_TAG_LOCALIZED_FORMS                     HEX: 6c636f6c
+CONSTANT: DWRITE_FONT_FEATURE_TAG_MARK_POSITIONING                    HEX: 6b72616d
+CONSTANT: DWRITE_FONT_FEATURE_TAG_MATHEMATICAL_GREEK                  HEX: 6b72676d
+CONSTANT: DWRITE_FONT_FEATURE_TAG_MARK_TO_MARK_POSITIONING            HEX: 6b6d6b6d
+CONSTANT: DWRITE_FONT_FEATURE_TAG_ALTERNATE_ANNOTATION_FORMS          HEX: 746c616e
+CONSTANT: DWRITE_FONT_FEATURE_TAG_NLC_KANJI_FORMS                     HEX: 6b636c6e
+CONSTANT: DWRITE_FONT_FEATURE_TAG_OLD_STYLE_FIGURES                   HEX: 6d756e6f
+CONSTANT: DWRITE_FONT_FEATURE_TAG_ORDINALS                            HEX: 6e64726f
+CONSTANT: DWRITE_FONT_FEATURE_TAG_PROPORTIONAL_ALTERNATE_WIDTH        HEX: 746c6170
+CONSTANT: DWRITE_FONT_FEATURE_TAG_PETITE_CAPITALS                     HEX: 70616370
+CONSTANT: DWRITE_FONT_FEATURE_TAG_PROPORTIONAL_FIGURES                HEX: 6d756e70
+CONSTANT: DWRITE_FONT_FEATURE_TAG_PROPORTIONAL_WIDTHS                 HEX: 64697770
+CONSTANT: DWRITE_FONT_FEATURE_TAG_QUARTER_WIDTHS                      HEX: 64697771
+CONSTANT: DWRITE_FONT_FEATURE_TAG_REQUIRED_LIGATURES                  HEX: 67696c72
+CONSTANT: DWRITE_FONT_FEATURE_TAG_RUBY_NOTATION_FORMS                 HEX: 79627572
+CONSTANT: DWRITE_FONT_FEATURE_TAG_STYLISTIC_ALTERNATES                HEX: 746c6173
+CONSTANT: DWRITE_FONT_FEATURE_TAG_SCIENTIFIC_INFERIORS                HEX: 666e6973
+CONSTANT: DWRITE_FONT_FEATURE_TAG_SMALL_CAPITALS                      HEX: 70636d73
+CONSTANT: DWRITE_FONT_FEATURE_TAG_SIMPLIFIED_FORMS                    HEX: 6c706d73
+CONSTANT: DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_1                     HEX: 31307373
+CONSTANT: DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_2                     HEX: 32307373
+CONSTANT: DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_3                     HEX: 33307373
+CONSTANT: DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_4                     HEX: 34307373
+CONSTANT: DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_5                     HEX: 35307373
+CONSTANT: DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_6                     HEX: 36307373
+CONSTANT: DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_7                     HEX: 37307373
+CONSTANT: DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_8                     HEX: 38307373
+CONSTANT: DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_9                     HEX: 39307373
+CONSTANT: DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_10                    HEX: 30317373
+CONSTANT: DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_11                    HEX: 31317373
+CONSTANT: DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_12                    HEX: 32317373
+CONSTANT: DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_13                    HEX: 33317373
+CONSTANT: DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_14                    HEX: 34317373
+CONSTANT: DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_15                    HEX: 35317373
+CONSTANT: DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_16                    HEX: 36317373
+CONSTANT: DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_17                    HEX: 37317373
+CONSTANT: DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_18                    HEX: 38317373
+CONSTANT: DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_19                    HEX: 39317373
+CONSTANT: DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_20                    HEX: 30327373
+CONSTANT: DWRITE_FONT_FEATURE_TAG_SUBSCRIPT                           HEX: 73627573
+CONSTANT: DWRITE_FONT_FEATURE_TAG_SUPERSCRIPT                         HEX: 73707573
+CONSTANT: DWRITE_FONT_FEATURE_TAG_SWASH                               HEX: 68737773
+CONSTANT: DWRITE_FONT_FEATURE_TAG_TITLING                             HEX: 6c746974
+CONSTANT: DWRITE_FONT_FEATURE_TAG_TRADITIONAL_NAME_FORMS              HEX: 6d616e74
+CONSTANT: DWRITE_FONT_FEATURE_TAG_TABULAR_FIGURES                     HEX: 6d756e74
+CONSTANT: DWRITE_FONT_FEATURE_TAG_TRADITIONAL_FORMS                   HEX: 64617274
+CONSTANT: DWRITE_FONT_FEATURE_TAG_THIRD_WIDTHS                        HEX: 64697774
+CONSTANT: DWRITE_FONT_FEATURE_TAG_UNICASE                             HEX: 63696e75
+CONSTANT: DWRITE_FONT_FEATURE_TAG_SLASHED_ZERO                        HEX: 6f72657a
+
+STRUCT: DWRITE_TEXT_RANGE
+    { startPosition UINT32 }
+    { length        UINT32 } ;
+
+STRUCT: DWRITE_FONT_FEATURE
+    { nameTag   DWRITE_FONT_FEATURE_TAG }
+    { parameter UINT32                  } ;
+
+STRUCT: DWRITE_TYPOGRAPHIC_FEATURES
+    { features     DWRITE_FONT_FEATURE* }
+    { featureCount UINT32               } ;
+
+STRUCT: DWRITE_TRIMMING
+    { granularity    DWRITE_TRIMMING_GRANULARITY }
+    { delimiter      UINT32                      }
+    { delimiterCount UINT32                      } ;
+
+C-TYPE: IDWriteTypography
+C-TYPE: IDWriteInlineObject
+
+COM-INTERFACE: IDWriteTextFormat IUnknown {9c906818-31d7-4fd3-a151-7c5e225db55a}
+    HRESULT SetTextAlignment ( DWRITE_TEXT_ALIGNMENT textAlignment )
+    HRESULT SetParagraphAlignment ( DWRITE_PARAGRAPH_ALIGNMENT paragraphAlignment )
+    HRESULT SetWordWrapping ( DWRITE_WORD_WRAPPING wordWrapping )
+    HRESULT SetReadingDirection ( DWRITE_READING_DIRECTION readingDirection )
+    HRESULT SetFlowDirection ( DWRITE_FLOW_DIRECTION flowDirection )
+    HRESULT SetIncrementalTabStop ( FLOAT incrementalTabStop )
+    HRESULT SetTrimming ( DWRITE_TRIMMING* trimmingOptions, IDWriteInlineObject* trimmingSign )
+    HRESULT SetLineSpacing ( DWRITE_LINE_SPACING_METHOD lineSpacingMethod, FLOAT lineSpacing, FLOAT baseline )
+    DWRITE_TEXT_ALIGNMENT GetTextAlignment ( )
+    DWRITE_PARAGRAPH_ALIGNMENT GetParagraphAlignment ( )
+    DWRITE_WORD_WRAPPING GetWordWrapping ( )
+    DWRITE_READING_DIRECTION GetReadingDirection ( )
+    DWRITE_FLOW_DIRECTION GetFlowDirection ( )
+    FLOAT GetIncrementalTabStop ( )
+    HRESULT GetTrimming ( DWRITE_TRIMMING* trimmingOptions, IDWriteInlineObject** trimmingSign )
+    HRESULT GetLineSpacing ( DWRITE_LINE_SPACING_METHOD* lineSpacingMethod, FLOAT* lineSpacing, FLOAT* baseline )
+    HRESULT GetFontCollection ( IDWriteFontCollection** fontCollection )
+    UINT32 GetFontFamilyNameLength ( )
+    HRESULT GetFontFamilyName ( WCHAR* fontFamilyName, UINT32 nameSize )
+    DWRITE_FONT_WEIGHT GetFontWeight ( )
+    DWRITE_FONT_STYLE GetFontStyle ( )
+    DWRITE_FONT_STRETCH GetFontStretch ( )
+    FLOAT GetFontSize ( )
+    UINT32 GetLocaleNameLength ( )
+    HRESULT GetLocaleName ( WCHAR* localeName, UINT32 nameSize ) ;
+
+COM-INTERFACE: IDWriteTypography IUnknown {55f1112b-1dc2-4b3c-9541-f46894ed85b6}
+    HRESULT AddFontFeature ( DWRITE_FONT_FEATURE fontFeature )
+    UINT32 GetFontFeatureCount ( )
+    HRESULT GetFontFeature ( UINT32 fontFeatureIndex, DWRITE_FONT_FEATURE* fontFeature ) ;
+
+CONSTANT: DWRITE_SCRIPT_SHAPES_DEFAULT   0
+CONSTANT: DWRITE_SCRIPT_SHAPES_NO_VISUAL 1
+TYPEDEF: int DWRITE_SCRIPT_SHAPES
+
+STRUCT: DWRITE_SCRIPT_ANALYSIS
+    { script USHORT               }
+    { shapes DWRITE_SCRIPT_SHAPES } ;
+
+C-ENUM:
+    DWRITE_BREAK_CONDITION_NEUTRAL
+    DWRITE_BREAK_CONDITION_CAN_BREAK
+    DWRITE_BREAK_CONDITION_MAY_NOT_BREAK
+    DWRITE_BREAK_CONDITION_MUST_BREAK ;
+TYPEDEF: int DWRITE_BREAK_CONDITION
+
+STRUCT: DWRITE_LINE_BREAKPOINT
+    { data BYTE } ;
+
+C-ENUM:
+    DWRITE_NUMBER_SUBSTITUTION_METHOD_FROM_CULTURE
+    DWRITE_NUMBER_SUBSTITUTION_METHOD_CONTEXTUAL
+    DWRITE_NUMBER_SUBSTITUTION_METHOD_NONE
+    DWRITE_NUMBER_SUBSTITUTION_METHOD_NATIONAL
+    DWRITE_NUMBER_SUBSTITUTION_METHOD_TRADITIONAL ;
+TYPEDEF: int DWRITE_NUMBER_SUBSTITUTION_METHOD
+
+COM-INTERFACE: IDWriteNumberSubstitution IUnknown {14885CC9-BAB0-4f90-B6ED-5C366A2CD03D} ;
+
+STRUCT: DWRITE_SHAPING_TEXT_PROPERTIES
+    { data USHORT } ;
+
+STRUCT: DWRITE_SHAPING_GLYPH_PROPERTIES
+    { data USHORT } ;
+
+COM-INTERFACE: IDWriteTextAnalysisSource IUnknown {688e1a58-5094-47c8-adc8-fbcea60ae92b}
+    HRESULT GetTextAtPosition ( UINT32 textPosition, WCHAR** textString, UINT32* textLength )
+    HRESULT GetTextBeforePosition ( UINT32 textPosition, WCHAR** textString, UINT32* textLength )
+    DWRITE_READING_DIRECTION GetParagraphReadingDirection ( )
+    HRESULT GetLocaleName ( UINT32 textPosition, UINT32* textLength, WCHAR** localeName )
+    HRESULT GetNumberSubstitution ( UINT32 textPosition, UINT32* textLength, IDWriteNumberSubstitution** numberSubstitution ) ;
+
+COM-INTERFACE: IDWriteTextAnalysisSink IUnknown {5810cd44-0ca0-4701-b3fa-bec5182ae4f6}
+    HRESULT SetScriptAnalysis ( UINT32 textPosition, UINT32 textLength, DWRITE_SCRIPT_ANALYSIS* scriptAnalysis )
+    HRESULT SetLineBreakpoints ( UINT32 textPosition, UINT32 textLength, DWRITE_LINE_BREAKPOINT* lineBreakpoints )
+    HRESULT SetBidiLevel ( UINT32 textPosition, UINT32 textLength, BYTE explicitLevel, BYTE resolvedLevel )
+    HRESULT SetNumberSubstitution ( UINT32 textPosition, UINT32 textLength, IDWriteNumberSubstitution* numberSubstitution ) ;
+
+COM-INTERFACE: IDWriteTextAnalyzer IUnknown {b7e6163e-7f46-43b4-84b3-e4e6249c365d}
+    HRESULT AnalyzeScript ( IDWriteTextAnalysisSource* analysisSource, UINT32 textPosition, UINT32 textLength, IDWriteTextAnalysisSink* analysisSink )
+    HRESULT AnalyzeBidi ( IDWriteTextAnalysisSource* analysisSource, UINT32 textPosition, UINT32 textLength, IDWriteTextAnalysisSink* analysisSink )
+    HRESULT AnalyzeNumberSubstitution ( IDWriteTextAnalysisSource* analysisSource, UINT32 textPosition, UINT32 textLength, IDWriteTextAnalysisSink* analysisSink )
+    HRESULT AnalyzeLineBreakpoints ( IDWriteTextAnalysisSource* analysisSource, UINT32 textPosition, UINT32 textLength, IDWriteTextAnalysisSink* analysisSink )
+    HRESULT GetGlyphs ( WCHAR* textString, UINT32 textLength, IDWriteFontFace* fontFace, BOOL isSideways, BOOL isRightToLeft, DWRITE_SCRIPT_ANALYSIS* scriptAnalysis, WCHAR* localeName, IDWriteNumberSubstitution* numberSubstitution, DWRITE_TYPOGRAPHIC_FEATURES** features, UINT32* featureRangeLengths, UINT32 featureRanges, UINT32 maxGlyphCount, USHORT* clusterMap, DWRITE_SHAPING_TEXT_PROPERTIES* textProps, USHORT* glyphIndices, DWRITE_SHAPING_GLYPH_PROPERTIES* glyphProps, UINT32* actualGlyphCount )
+    HRESULT GetGlyphPlacements ( WCHAR* textString, USHORT* clusterMap, DWRITE_SHAPING_TEXT_PROPERTIES* textProps, UINT32 textLength, USHORT* glyphIndices, DWRITE_SHAPING_GLYPH_PROPERTIES* glyphProps, UINT32 glyphCount, IDWriteFontFace* fontFace, FLOAT fontEmSize, BOOL isSideways, BOOL isRightToLeft, DWRITE_SCRIPT_ANALYSIS* scriptAnalysis, WCHAR* localeName, DWRITE_TYPOGRAPHIC_FEATURES** features, UINT32* featureRangeLengths, UINT32 featureRanges, FLOAT* glyphAdvances, DWRITE_GLYPH_OFFSET* glyphOffsets )
+    HRESULT GetGdiCompatibleGlyphPlacements ( WCHAR* textString, USHORT* clusterMap, DWRITE_SHAPING_TEXT_PROPERTIES* textProps, UINT32 textLength, USHORT* glyphIndices, DWRITE_SHAPING_GLYPH_PROPERTIES* glyphProps, UINT32 glyphCount, IDWriteFontFace* fontFace, FLOAT fontEmSize, FLOAT pixelsPerDip, DWRITE_MATRIX* transform, BOOL useGdiNatural, BOOL isSideways, BOOL isRightToLeft, DWRITE_SCRIPT_ANALYSIS* scriptAnalysis, WCHAR* localeName, DWRITE_TYPOGRAPHIC_FEATURES** features, UINT32* featureRangeLengths, UINT32 featureRanges, FLOAT* glyphAdvances, DWRITE_GLYPH_OFFSET* glyphOffsets ) ;
+
+STRUCT: DWRITE_GLYPH_RUN
+    { fontFace      IDWriteFontFace*     }
+    { fontEmSize    FLOAT                }
+    { glyphCount    UINT32               }
+    { glyphIndices  USHORT*              }
+    { glyphAdvances FLOAT*               }
+    { glyphOffsets  DWRITE_GLYPH_OFFSET* }
+    { isSideways    BOOL                 }
+    { bidiLevel     UINT32               } ;
+
+STRUCT: DWRITE_GLYPH_RUN_DESCRIPTION
+    { localeName   WCHAR*  }
+    { string       WCHAR*  }
+    { stringLength UINT32  }
+    { clusterMap   USHORT* }
+    { textPosition UINT32  } ;
+
+STRUCT: DWRITE_UNDERLINE
+    { width            FLOAT                    }
+    { thickness        FLOAT                    }
+    { offset           FLOAT                    }
+    { runHeight        FLOAT                    }
+    { readingDirection DWRITE_READING_DIRECTION }
+    { flowDirection    DWRITE_FLOW_DIRECTION    }
+    { localeName       WCHAR*                   }
+    { measuringMode    DWRITE_MEASURING_MODE    } ;
+
+STRUCT: DWRITE_STRIKETHROUGH
+    { width            FLOAT                    }
+    { thickness        FLOAT                    }
+    { offset           FLOAT                    }
+    { readingDirection DWRITE_READING_DIRECTION }
+    { flowDirection    DWRITE_FLOW_DIRECTION    }
+    { localeName       WCHAR*                   }
+    { measuringMode    DWRITE_MEASURING_MODE    } ;
+
+STRUCT: DWRITE_LINE_METRICS
+    { length                   UINT32 }
+    { trailingWhitespaceLength UINT32 }
+    { newlineLength            UINT32 }
+    { height                   FLOAT  }
+    { baseline                 FLOAT  }
+    { isTrimmed                BOOL   } ;
+
+STRUCT: DWRITE_CLUSTER_METRICS
+    { width  FLOAT  } 
+    { length USHORT }
+    { data   USHORT } ;
+
+STRUCT: DWRITE_TEXT_METRICS
+    { left                             FLOAT  }
+    { top                              FLOAT  }
+    { width                            FLOAT  }
+    { widthIncludingTrailingWhitespace FLOAT  }
+    { height                           FLOAT  }
+    { layoutWidth                      FLOAT  }
+    { layoutHeight                     FLOAT  }
+    { maxBidiReorderingDepth           UINT32 }
+    { lineCount                        UINT32 } ;
+
+STRUCT: DWRITE_INLINE_OBJECT_METRICS
+    { width             FLOAT }
+    { height            FLOAT }
+    { baseline          FLOAT }
+    { supportsSideways  BOOL  } ;
+
+STRUCT: DWRITE_OVERHANG_METRICS
+    { left   FLOAT }
+    { top    FLOAT }
+    { right  FLOAT }
+    { bottom FLOAT } ;
+
+STRUCT: DWRITE_HIT_TEST_METRICS
+    { textPosition UINT32 }
+    { length       UINT32 }
+    { left         FLOAT  }
+    { top          FLOAT  }
+    { width        FLOAT  }
+    { height       FLOAT  }
+    { bidiLevel    UINT32 }
+    { isText       BOOL   }
+    { isTrimmed    BOOL   } ;
+
+C-TYPE: IDWriteTextRenderer
+
+COM-INTERFACE: IDWriteInlineObject IUnknown {8339FDE3-106F-47ab-8373-1C6295EB10B3}
+    HRESULT Draw ( void* clientDrawingContext, IDWriteTextRenderer* renderer, FLOAT originX, FLOAT originY, BOOL isSideways, BOOL isRightToLeft, IUnknown* clientDrawingEffect )
+    HRESULT GetMetrics ( DWRITE_INLINE_OBJECT_METRICS* metrics )
+    HRESULT GetOverhangMetrics ( DWRITE_OVERHANG_METRICS* overhangs )
+    HRESULT GetBreakConditions ( DWRITE_BREAK_CONDITION* breakConditionBefore, DWRITE_BREAK_CONDITION* breakConditionAfter ) ;
+
+COM-INTERFACE: IDWritePixelSnapping IUnknown {eaf3a2da-ecf4-4d24-b644-b34f6842024b}
+    HRESULT IsPixelSnappingDisabled ( void* clientDrawingContext, BOOL* isDisabled )
+    HRESULT GetCurrentTransform ( void* clientDrawingContext, DWRITE_MATRIX* transform )
+    HRESULT GetPixelsPerDip ( void* clientDrawingContext, FLOAT* pixelsPerDip ) ;
+
+COM-INTERFACE: IDWriteTextRenderer IDWritePixelSnapping {ef8a8135-5cc6-45fe-8825-c5a0724eb819}
+    HRESULT DrawGlyphRun ( void* clientDrawingContext, FLOAT baselineOriginX, FLOAT baselineOriginY, DWRITE_MEASURING_MODE measuringMode, DWRITE_GLYPH_RUN* glyphRun, DWRITE_GLYPH_RUN_DESCRIPTION* glyphRunDescription, IUnknown* clientDrawingEffect )
+    HRESULT DrawUnderline ( void* clientDrawingContext, FLOAT baselineOriginX, FLOAT baselineOriginY, DWRITE_UNDERLINE* underline, IUnknown* clientDrawingEffect )
+    HRESULT DrawStrikethrough ( void* clientDrawingContext, FLOAT baselineOriginX, FLOAT baselineOriginY, DWRITE_STRIKETHROUGH* strikethrough, IUnknown* clientDrawingEffect )
+    HRESULT DrawInlineObject ( void* clientDrawingContext, FLOAT originX, FLOAT originY, IDWriteInlineObject* inlineObject, BOOL isSideways, BOOL isRightToLeft, IUnknown* clientDrawingEffect ) ;
+
+COM-INTERFACE: IDWriteTextLayout IDWriteTextFormat {53737037-6d14-410b-9bfe-0b182bb70961}
+    HRESULT SetMaxWidth ( FLOAT maxWidth )
+    HRESULT SetMaxHeight ( FLOAT maxHeight )
+    HRESULT SetFontCollection ( IDWriteFontCollection* fontCollection, DWRITE_TEXT_RANGE textRange )
+    HRESULT SetFontFamilyName ( WCHAR* fontFamilyName, DWRITE_TEXT_RANGE textRange )
+    HRESULT SetFontWeight ( DWRITE_FONT_WEIGHT fontWeight, DWRITE_TEXT_RANGE textRange )
+    HRESULT SetFontStyle ( DWRITE_FONT_STYLE fontStyle, DWRITE_TEXT_RANGE textRange )
+    HRESULT SetFontStretch ( DWRITE_FONT_STRETCH fontStretch, DWRITE_TEXT_RANGE textRange )
+    HRESULT SetFontSize ( FLOAT fontSize, DWRITE_TEXT_RANGE textRange )
+    HRESULT SetUnderline ( BOOL hasUnderline, DWRITE_TEXT_RANGE textRange )
+    HRESULT SetStrikethrough ( BOOL hasStrikethrough, DWRITE_TEXT_RANGE textRange )
+    HRESULT SetDrawingEffect ( IUnknown* drawingEffect, DWRITE_TEXT_RANGE textRange )
+    HRESULT SetInlineObject ( IDWriteInlineObject* inlineObject, DWRITE_TEXT_RANGE textRange )
+    HRESULT SetTypography ( IDWriteTypography* typography, DWRITE_TEXT_RANGE textRange )
+    HRESULT SetLocaleName ( WCHAR* localeName, DWRITE_TEXT_RANGE textRange )
+    FLOAT GetMaxWidth ( )
+    FLOAT GetMaxHeight ( )
+    HRESULT GetFontCollection2 ( UINT32 currentPosition, IDWriteFontCollection** fontCollection, DWRITE_TEXT_RANGE* textRange )
+    HRESULT GetFontFamilyNameLength2 ( UINT32 currentPosition, UINT32* nameLength, DWRITE_TEXT_RANGE* textRange )
+    HRESULT GetFontFamilyName2 ( UINT32 currentPosition, WCHAR* fontFamilyName, UINT32 nameSize, DWRITE_TEXT_RANGE* textRange )
+    HRESULT GetFontWeight2 ( UINT32 currentPosition, DWRITE_FONT_WEIGHT* fontWeight, DWRITE_TEXT_RANGE* textRange )
+    HRESULT GetFontStyle2 ( UINT32 currentPosition, DWRITE_FONT_STYLE* fontStyle, DWRITE_TEXT_RANGE* textRange )
+    HRESULT GetFontStretch2 ( UINT32 currentPosition, DWRITE_FONT_STRETCH* fontStretch, DWRITE_TEXT_RANGE* textRange )
+    HRESULT GetFontSize2 ( UINT32 currentPosition, FLOAT* fontSize, DWRITE_TEXT_RANGE* textRange )
+    HRESULT GetUnderline ( UINT32 currentPosition, BOOL* hasUnderline, DWRITE_TEXT_RANGE* textRange )
+    HRESULT GetStrikethrough ( UINT32 currentPosition, BOOL* hasStrikethrough, DWRITE_TEXT_RANGE* textRange )
+    HRESULT GetDrawingEffect ( UINT32 currentPosition, IUnknown** drawingEffect, DWRITE_TEXT_RANGE* textRange )
+    HRESULT GetInlineObject ( UINT32 currentPosition, IDWriteInlineObject** inlineObject, DWRITE_TEXT_RANGE* textRange )
+    HRESULT GetTypography ( UINT32 currentPosition, IDWriteTypography** typography, DWRITE_TEXT_RANGE* textRange )
+    HRESULT GetLocaleNameLength2 ( UINT32 currentPosition, UINT32* nameLength, DWRITE_TEXT_RANGE* textRange )
+    HRESULT GetLocaleName2 ( UINT32 currentPosition, WCHAR* localeName, UINT32 nameSize, DWRITE_TEXT_RANGE* textRange )
+    HRESULT Draw ( void* clientDrawingContext, IDWriteTextRenderer* renderer, FLOAT originX, FLOAT originY )
+    HRESULT GetLineMetrics ( DWRITE_LINE_METRICS* lineMetrics, UINT32 maxLineCount, UINT32* actualLineCount )
+    HRESULT GetMetrics ( DWRITE_TEXT_METRICS* textMetrics )
+    HRESULT GetOverhangMetrics ( DWRITE_OVERHANG_METRICS* overhangs )
+    HRESULT GetClusterMetrics ( DWRITE_CLUSTER_METRICS* clusterMetrics, UINT32 maxClusterCount, UINT32* actualClusterCount )
+    HRESULT DetermineMinWidth ( FLOAT* minWidth )
+    HRESULT HitTestPoint ( FLOAT pointX, FLOAT pointY, BOOL* isTrailingHit, BOOL* isInside, DWRITE_HIT_TEST_METRICS* hitTestMetrics )
+    HRESULT HitTestTextPosition ( UINT32 textPosition, BOOL isTrailingHit, FLOAT* pointX, FLOAT* pointY, DWRITE_HIT_TEST_METRICS* hitTestMetrics )
+    HRESULT HitTestTextRange ( UINT32 textPosition, UINT32 textLength, FLOAT originX, FLOAT originY, DWRITE_HIT_TEST_METRICS* hitTestMetrics, UINT32 maxHitTestMetricsCount, UINT32* actualHitTestMetricsCount ) ;
+
+COM-INTERFACE: IDWriteBitmapRenderTarget IUnknown {5e5a32a3-8dff-4773-9ff6-0696eab77267}
+    HRESULT DrawGlyphRun ( FLOAT baselineOriginX, FLOAT baselineOriginY, DWRITE_MEASURING_MODE measuringMode, DWRITE_GLYPH_RUN* glyphRun, IDWriteRenderingParams* renderingParams, COLORREF textColor, RECT* blackBoxRect )
+    HDC GetMemoryDC ( )
+    FLOAT GetPixelsPerDip ( )
+    HRESULT SetPixelsPerDip ( FLOAT pixelsPerDip )
+    HRESULT GetCurrentTransform ( DWRITE_MATRIX* transform )
+    HRESULT SetCurrentTransform ( DWRITE_MATRIX* transform )
+    HRESULT GetSize ( SIZE* size )
+    HRESULT Resize ( UINT32 width, UINT32 height ) ;
+
+C-TYPE: LOGFONTW
+
+COM-INTERFACE: IDWriteGdiInterop IUnknown {1edd9491-9853-4299-898f-6432983b6f3a}
+    HRESULT CreateFontFromLOGFONT ( LOGFONTW* logFont, IDWriteFont** font )
+    HRESULT ConvertFontToLOGFONT ( IDWriteFont* font, LOGFONTW* logFont, BOOL* isSystemFont )
+    HRESULT ConvertFontFaceToLOGFONT ( IDWriteFontFace* font, LOGFONTW* logFont )
+    HRESULT CreateFontFaceFromHdc ( HDC hdc, IDWriteFontFace** fontFace )
+    HRESULT CreateBitmapRenderTarget ( HDC hdc, UINT32 width, UINT32 height, IDWriteBitmapRenderTarget** renderTarget ) ;
+
+C-ENUM: DWRITE_TEXTURE_ALIASED_1x1
+        DWRITE_TEXTURE_CLEARTYPE_3x1 ;
+TYPEDEF: int DWRITE_TEXTURE_TYPE
+
+CONSTANT: DWRITE_ALPHA_MAX 255
+
+COM-INTERFACE: IDWriteGlyphRunAnalysis IUnknown {7d97dbf7-e085-42d4-81e3-6a883bded118}
+    HRESULT GetAlphaTextureBounds ( DWRITE_TEXTURE_TYPE textureType, RECT* textureBounds )
+    HRESULT CreateAlphaTexture ( DWRITE_TEXTURE_TYPE textureType, RECT* textureBounds, BYTE* alphaValues, UINT32 bufferSize )
+    HRESULT GetAlphaBlendParams ( IDWriteRenderingParams* renderingParams, FLOAT* blendGamma, FLOAT* blendEnhancedContrast, FLOAT* blendClearTypeLevel ) ;
+
+COM-INTERFACE: IDWriteFactory IUnknown {b859ee5a-d838-4b5b-a2e8-1adc7d93db48}
+    HRESULT GetSystemFontCollection ( IDWriteFontCollection** fontCollection, BOOL checkForUpdates )
+    HRESULT CreateCustomFontCollection ( IDWriteFontCollectionLoader* collectionLoader, void* collectionKey, UINT32 collectionKeySize, IDWriteFontCollection** fontCollection )
+    HRESULT RegisterFontCollectionLoader ( IDWriteFontCollectionLoader* fontCollectionLoader )
+    HRESULT UnregisterFontCollectionLoader ( IDWriteFontCollectionLoader* fontCollectionLoader )
+    HRESULT CreateFontFileReference ( WCHAR* filePath, FILETIME* lastWriteTime, IDWriteFontFile** fontFile )
+    HRESULT CreateCustomFontFileReference ( void* fontFileReferenceKey, UINT32 fontFileReferenceKeySize, IDWriteFontFileLoader* fontFileLoader, IDWriteFontFile** fontFile )
+    HRESULT CreateFontFace ( DWRITE_FONT_FACE_TYPE fontFaceType, UINT32 numberOfFiles, IDWriteFontFile** fontFiles, UINT32 faceIndex, DWRITE_FONT_SIMULATIONS fontFaceSimulationFlags, IDWriteFontFace** fontFace )
+    HRESULT CreateRenderingParams ( IDWriteRenderingParams** renderingParams )
+    HRESULT CreateMonitorRenderingParams ( HMONITOR monitor, IDWriteRenderingParams** renderingParams )
+    HRESULT CreateCustomRenderingParams ( FLOAT gamma, FLOAT enhancedContrast, FLOAT clearTypeLevel, DWRITE_PIXEL_GEOMETRY pixelGeometry, DWRITE_RENDERING_MODE renderingMode, IDWriteRenderingParams** renderingParams )
+    HRESULT RegisterFontFileLoader ( IDWriteFontFileLoader* fontFileLoader )
+    HRESULT UnregisterFontFileLoader ( IDWriteFontFileLoader* fontFileLoader )
+    HRESULT CreateTextFormat ( WCHAR* fontFamilyName, IDWriteFontCollection* fontCollection, DWRITE_FONT_WEIGHT fontWeight, DWRITE_FONT_STYLE fontStyle, DWRITE_FONT_STRETCH fontStretch, FLOAT fontSize, WCHAR* localeName, IDWriteTextFormat** textFormat )
+    HRESULT CreateTypography ( IDWriteTypography** typography )
+    HRESULT GetGdiInterop ( IDWriteGdiInterop** gdiInterop )
+    HRESULT CreateTextLayout ( WCHAR* string, UINT32 stringLength, IDWriteTextFormat* textFormat, FLOAT maxWidth, FLOAT maxHeight, IDWriteTextLayout** textLayout )
+    HRESULT CreateGdiCompatibleTextLayout ( WCHAR* string, UINT32 stringLength, IDWriteTextFormat* textFormat, FLOAT layoutWidth, FLOAT layoutHeight, FLOAT pixelsPerDip, DWRITE_MATRIX* transform, BOOL useGdiNatural, IDWriteTextLayout** textLayout )
+    HRESULT CreateEllipsisTrimmingSign ( IDWriteTextFormat* textFormat, IDWriteInlineObject** trimmingSign )
+    HRESULT CreateTextAnalyzer ( IDWriteTextAnalyzer** textAnalyzer )
+    HRESULT CreateNumberSubstitution ( DWRITE_NUMBER_SUBSTITUTION_METHOD substitutionMethod, WCHAR* localeName, BOOL ignoreUserOverride, IDWriteNumberSubstitution** numberSubstitution )
+    HRESULT CreateGlyphRunAnalysis ( DWRITE_GLYPH_RUN* glyphRun, FLOAT pixelsPerDip, DWRITE_MATRIX* transform, DWRITE_RENDERING_MODE renderingMode, DWRITE_MEASURING_MODE measuringMode, FLOAT baselineOriginX, FLOAT baselineOriginY, IDWriteGlyphRunAnalysis** glyphRunAnalysis ) ;
+
+FUNCTION: HRESULT DWriteCreateFactory (
+    DWRITE_FACTORY_TYPE factoryType,
+    REFIID              iid,
+    IUnknown**          factory ) ;
+
+CONSTANT: DWRITE_E_FILEFORMAT             HEX: 88985000
+CONSTANT: DWRITE_E_UNEXPECTED             HEX: 88985001
+CONSTANT: DWRITE_E_NOFONT                 HEX: 88985002
+CONSTANT: DWRITE_E_FILENOTFOUND           HEX: 88985003
+CONSTANT: DWRITE_E_FILEACCESS             HEX: 88985004
+CONSTANT: DWRITE_E_FONTCOLLECTIONOBSOLETE HEX: 88985005
+CONSTANT: DWRITE_E_ALREADYREGISTERED      HEX: 88985006
diff --git a/basis/windows/directx/dwrite/summary.txt b/basis/windows/directx/dwrite/summary.txt
new file mode 100644 (file)
index 0000000..06c2e21
--- /dev/null
@@ -0,0 +1 @@
+Bindings to DirectWrite text rendering. Corresponds to dwrite.h.
diff --git a/basis/windows/directx/dwrite/tags.txt b/basis/windows/directx/dwrite/tags.txt
new file mode 100644 (file)
index 0000000..2320bdd
--- /dev/null
@@ -0,0 +1,2 @@
+unportable
+bindings
diff --git a/basis/windows/directx/dxfile/authors.txt b/basis/windows/directx/dxfile/authors.txt
new file mode 100644 (file)
index 0000000..6f03a12
--- /dev/null
@@ -0,0 +1 @@
+Erik Charlebois
diff --git a/basis/windows/directx/dxfile/dxfile.factor b/basis/windows/directx/dxfile/dxfile.factor
new file mode 100644 (file)
index 0000000..60d0722
--- /dev/null
@@ -0,0 +1,122 @@
+USING: alien.syntax classes.struct windows.com
+windows.com.syntax windows.kernel32 windows.ole32 windows.types ;
+IN: windows.directx.dxfile
+
+LIBRARY: d3dxof
+
+TYPEDEF: DWORD DXFILEFORMAT
+
+CONSTANT: DXFILEFORMAT_BINARY     0
+CONSTANT: DXFILEFORMAT_TEXT       1
+CONSTANT: DXFILEFORMAT_COMPRESSED 2
+
+TYPEDEF: DWORD DXFILELOADOPTIONS
+
+CONSTANT: DXFILELOAD_FROMFILE     0
+CONSTANT: DXFILELOAD_FROMRESOURCE 1
+CONSTANT: DXFILELOAD_FROMMEMORY   2
+CONSTANT: DXFILELOAD_FROMSTREAM   4
+CONSTANT: DXFILELOAD_FROMURL      8
+
+STRUCT: DXFILELOADRESOURCE
+    { hModule HMODULE }
+    { lpName  LPCTSTR }
+    { lpType  LPCTSTR } ;
+TYPEDEF: DXFILELOADRESOURCE* LPDXFILELOADRESOURCE
+
+STRUCT: DXFILELOADMEMORY
+    { lpMemory LPVOID }
+    { dSize    DWORD  } ;
+TYPEDEF: DXFILELOADMEMORY* LPDXFILELOADMEMORY
+
+C-TYPE: IDirectXFile
+TYPEDEF: IDirectXFile* LPDIRECTXFILE
+TYPEDEF: IDirectXFile** LPLPDIRECTXFILE
+C-TYPE: IDirectXFileEnumObject
+TYPEDEF: IDirectXFileEnumObject* LPDIRECTXFILEENUMOBJECT
+TYPEDEF: IDirectXFileEnumObject** LPLPDIRECTXFILEENUMOBJECT
+C-TYPE: IDirectXFileSaveObject
+TYPEDEF: IDirectXFileSaveObject* LPDIRECTXFILESAVEOBJECT
+TYPEDEF: IDirectXFileSaveObject** LPLPDIRECTXFILESAVEOBJECT
+C-TYPE: IDirectXFileObject
+TYPEDEF: IDirectXFileObject* LPDIRECTXFILEOBJECT
+TYPEDEF: IDirectXFileObject** LPLPDIRECTXFILEOBJECT
+C-TYPE: IDirectXFileData
+TYPEDEF: IDirectXFileData* LPDIRECTXFILEDATA
+TYPEDEF: IDirectXFileData** LPLPDIRECTXFILEDATA
+C-TYPE: IDirectXFileDataReference
+TYPEDEF: IDirectXFileDataReference* LPDIRECTXFILEDATAREFERENCE
+TYPEDEF: IDirectXFileDataReference** LPLPDIRECTXFILEDATAREFERENCE
+C-TYPE: IDirectXFileBinary
+TYPEDEF: IDirectXFileBinary* LPDIRECTXFILEBINARY
+TYPEDEF: IDirectXFileBinary** LPLPDIRECTXFILEBINARY
+
+FUNCTION: HRESULT DirectXFileCreate ( LPDIRECTXFILE* lplpDirectXFile ) ;
+
+COM-INTERFACE: IDirectXFile IUnknown {3d82ab40-62da-11cf-ab39-0020af71e433}
+    HRESULT CreateEnumObject ( LPVOID v, DXFILELOADOPTIONS y,
+                               LPDIRECTXFILEENUMOBJECT* z )
+    HRESULT CreateSaveObject ( LPCSTR v, DXFILEFORMAT y,
+                                 LPDIRECTXFILESAVEOBJECT* z )
+    HRESULT RegisterTemplates ( LPVOID x, DWORD y ) ;
+
+COM-INTERFACE: IDirectXFileEnumObject IUnknown {3d82ab41-62da-11cf-ab39-0020af71e433}
+    HRESULT GetNextDataObject ( LPDIRECTXFILEDATA* x )
+    HRESULT GetDataObjectById ( REFGUID x, LPDIRECTXFILEDATA* y )
+    HRESULT GetDataObjectByName ( LPCSTR x, LPDIRECTXFILEDATA* y ) ;
+
+COM-INTERFACE: IDirectXFileSaveObject IUnknown {3d82ab42-62da-11cf-ab39-0020af71e433}
+    HRESULT SaveTemplates ( DWORD x, GUID** y )
+    HRESULT CreateDataObject ( REFGUID x, LPCSTR y, GUID* z,
+                               DWORD a, LPVOID b, LPDIRECTXFILEDATA* c )
+    HRESULT SaveData ( LPDIRECTXFILEDATA x ) ;
+
+COM-INTERFACE: IDirectXFileObject IUnknown {3d82ab43-62da-11cf-ab39-0020af71e433}
+    HRESULT GetName ( LPSTR x, LPDWORD y )
+    HRESULT GetId ( LPGUID y ) ;
+
+COM-INTERFACE: IDirectXFileData IDirectXFileObject {3d82ab44-62da-11cf-ab39-0020af71e433}
+    HRESULT GetData          ( LPCSTR x, DWORD* y, void** z )
+    HRESULT GetType          ( GUID** x )
+    HRESULT GetNextObject    ( LPDIRECTXFILEOBJECT* x )
+    HRESULT AddDataObject    ( LPDIRECTXFILEDATA y )
+    HRESULT AddDataReference ( LPCSTR x, GUID* y )
+    HRESULT AddBinaryObject  ( LPCSTR x, GUID* y, LPCSTR z, LPVOID a, DWORD b ) ;
+
+COM-INTERFACE: IDirectXFileDataReference IDirectXFileObject {3d82ab45-62da-11cf-ab39-0020af71e433}
+    HRESULT Resolve ( LPDIRECTXFILEDATA* x ) ;
+
+COM-INTERFACE: IDirectXFileBinary IDirectXFileObject {3d82ab46-62da-11cf-ab39-0020af71e433}
+    HRESULT GetSize      ( DWORD* x )
+    HRESULT GetMimeType  ( LPCSTR* x )
+    HRESULT Read         ( LPVOID x, DWORD y, LPDWORD z ) ;
+
+CONSTANT: DXFILE_OK   0
+                               
+CONSTANT: DXFILEERR_BADOBJECT                 HEX: 88760352
+CONSTANT: DXFILEERR_BADVALUE                  HEX: 88760353
+CONSTANT: DXFILEERR_BADTYPE                   HEX: 88760354
+CONSTANT: DXFILEERR_BADSTREAMHANDLE           HEX: 88760355
+CONSTANT: DXFILEERR_BADALLOC                  HEX: 88760356
+CONSTANT: DXFILEERR_NOTFOUND                  HEX: 88760357
+CONSTANT: DXFILEERR_NOTDONEYET                HEX: 88760358
+CONSTANT: DXFILEERR_FILENOTFOUND              HEX: 88760359
+CONSTANT: DXFILEERR_RESOURCENOTFOUND          HEX: 8876035A
+CONSTANT: DXFILEERR_URLNOTFOUND               HEX: 8876035B
+CONSTANT: DXFILEERR_BADRESOURCE               HEX: 8876035C
+CONSTANT: DXFILEERR_BADFILETYPE               HEX: 8876035D
+CONSTANT: DXFILEERR_BADFILEVERSION            HEX: 8876035E
+CONSTANT: DXFILEERR_BADFILEFLOATSIZE          HEX: 8876035F
+CONSTANT: DXFILEERR_BADFILECOMPRESSIONTYPE    HEX: 88760360
+CONSTANT: DXFILEERR_BADFILE                   HEX: 88760361
+CONSTANT: DXFILEERR_PARSEERROR                HEX: 88760362
+CONSTANT: DXFILEERR_NOTEMPLATE                HEX: 88760363
+CONSTANT: DXFILEERR_BADARRAYSIZE              HEX: 88760364
+CONSTANT: DXFILEERR_BADDATAREFERENCE          HEX: 88760365
+CONSTANT: DXFILEERR_INTERNALERROR             HEX: 88760366
+CONSTANT: DXFILEERR_NOMOREOBJECTS             HEX: 88760367
+CONSTANT: DXFILEERR_BADINTRINSICS             HEX: 88760368
+CONSTANT: DXFILEERR_NOMORESTREAMHANDLES       HEX: 88760369
+CONSTANT: DXFILEERR_NOMOREDATA                HEX: 8876036A
+CONSTANT: DXFILEERR_BADCACHEFILE              HEX: 8876036B
+CONSTANT: DXFILEERR_NOINTERNET                HEX: 8876036C
diff --git a/basis/windows/directx/dxfile/summary.txt b/basis/windows/directx/dxfile/summary.txt
new file mode 100644 (file)
index 0000000..34ad8e6
--- /dev/null
@@ -0,0 +1 @@
+Bindings to DirectX file abstraction. Corresponds to dxfile.h.
diff --git a/basis/windows/directx/dxfile/tags.txt b/basis/windows/directx/dxfile/tags.txt
new file mode 100644 (file)
index 0000000..2320bdd
--- /dev/null
@@ -0,0 +1,2 @@
+unportable
+bindings
diff --git a/basis/windows/directx/dxgi/authors.txt b/basis/windows/directx/dxgi/authors.txt
new file mode 100644 (file)
index 0000000..6f03a12
--- /dev/null
@@ -0,0 +1 @@
+Erik Charlebois
diff --git a/basis/windows/directx/dxgi/dxgi.factor b/basis/windows/directx/dxgi/dxgi.factor
new file mode 100644 (file)
index 0000000..6537de8
--- /dev/null
@@ -0,0 +1,213 @@
+USING: alien.c-types alien.syntax classes.struct windows.com windows.com.syntax
+windows.directx.dxgiformat windows.directx.dxgitype windows.kernel32
+windows.ole32 windows.types ;
+IN: windows.directx.dxgi
+
+LIBRARY: dxgi
+
+CONSTANT: DXGI_CPU_ACCESS_NONE 0
+CONSTANT: DXGI_CPU_ACCESS_DYNAMIC 1
+CONSTANT: DXGI_CPU_ACCESS_READ_WRITE 2
+CONSTANT: DXGI_CPU_ACCESS_SCRATCH 3
+CONSTANT: DXGI_CPU_ACCESS_FIELD 15
+CONSTANT: DXGI_USAGE_SHADER_INPUT 16
+CONSTANT: DXGI_USAGE_RENDER_TARGET_OUTPUT 32
+CONSTANT: DXGI_USAGE_BACK_BUFFER 64
+CONSTANT: DXGI_USAGE_SHARED 128
+CONSTANT: DXGI_USAGE_READ_ONLY 256
+CONSTANT: DXGI_USAGE_DISCARD_ON_PRESENT 512
+CONSTANT: DXGI_USAGE_UNORDERED_ACCESS 1024
+TYPEDEF: UINT DXGI_USAGE
+
+STRUCT: DXGI_FRAME_STATISTICS
+{ PresentCount UINT }
+{ PresentRefreshCount UINT }
+{ SyncRefreshCount UINT }
+{ SyncQPCTime LARGE_INTEGER }
+{ SyncGPUTime LARGE_INTEGER } ;
+
+STRUCT: DXGI_MAPPED_RECT
+{ Pitch INT }
+{ pBits BYTE* } ;
+
+STRUCT: DXGI_ADAPTER_DESC
+{ Description WCHAR[128] }
+{ VendorId UINT }
+{ DeviceId UINT }
+{ SubSysId UINT }
+{ Revision UINT }
+{ DedicatedVideoMemory SIZE_T }
+{ DedicatedSystemMemory SIZE_T }
+{ SharedSystemMemory SIZE_T }
+{ AdapterLuid LUID } ;
+
+STRUCT: DXGI_OUTPUT_DESC
+{ DeviceName WCHAR[32] }
+{ DesktopCoordinates RECT }
+{ AttachedToDesktop BOOL }
+{ Rotation DXGI_MODE_ROTATION }
+{ Monitor HMONITOR } ;
+
+STRUCT: DXGI_SHARED_RESOURCE
+{ Handle HANDLE } ;
+
+CONSTANT: DXGI_RESOURCE_PRIORITY_MINIMUM HEX: 28000000
+CONSTANT: DXGI_RESOURCE_PRIORITY_LOW HEX: 50000000
+CONSTANT: DXGI_RESOURCE_PRIORITY_NORMAL HEX: 78000000
+CONSTANT: DXGI_RESOURCE_PRIORITY_HIGH HEX: a0000000
+CONSTANT: DXGI_RESOURCE_PRIORITY_MAXIMUM HEX: c8000000
+
+CONSTANT: DXGI_RESIDENCY_FULLY_RESIDENT 1
+CONSTANT: DXGI_RESIDENCY_RESIDENT_IN_SHARED_MEMORY 2
+CONSTANT: DXGI_RESIDENCY_EVICTED_TO_DISK 3
+TYPEDEF: int DXGI_RESIDENCY
+
+STRUCT: DXGI_SURFACE_DESC
+{ Width UINT }
+{ Height UINT }
+{ Format DXGI_FORMAT }
+{ SampleDesc DXGI_SAMPLE_DESC } ;
+
+CONSTANT: DXGI_SWAP_EFFECT_DISCARD 0
+CONSTANT: DXGI_SWAP_EFFECT_SEQUENTIAL 1
+TYPEDEF: int DXGI_SWAP_EFFECT
+
+CONSTANT: DXGI_SWAP_CHAIN_FLAG_NONPREROTATED 1
+CONSTANT: DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH 2
+CONSTANT: DXGI_SWAP_CHAIN_FLAG_GDI_COMPATIBLE 4
+TYPEDEF: int DXGI_SWAP_CHAIN_FLAG
+
+STRUCT: DXGI_SWAP_CHAIN_DESC
+{ BufferDesc DXGI_MODE_DESC }
+{ SampleDesc DXGI_SAMPLE_DESC }
+{ BufferUsage DXGI_USAGE }
+{ BufferCount UINT }
+{ OutputWindow HWND }
+{ Windowed BOOL }
+{ SwapEffect DXGI_SWAP_EFFECT }
+{ Flags UINT } ;
+
+COM-INTERFACE: IDXGIObject IUnknown {aec22fb8-76f3-4639-9be0-28eb43a67a2e}
+HRESULT SetPrivateData ( REFGUID Name, UINT DataSize, void* pData )
+HRESULT SetPrivateDataInterface ( REFGUID Name, IUnknown* pUnknown )
+HRESULT GetPrivateData ( REFGUID Name, UINT* pDataSize, void* pData )
+HRESULT GetParent ( REFIID riid, void** ppParent ) ;
+
+COM-INTERFACE: IDXGIDeviceSubObject IDXGIObject {3d3e0379-f9de-4d58-bb6c-18d62992f1a6}
+HRESULT GetDevice ( REFIID riid, void** ppDevice ) ;
+
+COM-INTERFACE: IDXGIResource IDXGIDeviceSubObject {035f3ab4-482e-4e50-b41f-8a7f8bd8960b}
+HRESULT GetSharedHandle ( HANDLE* pSharedHandle )
+HRESULT GetUsage ( DXGI_USAGE* pUsage )
+HRESULT SetEvictionPriority ( UINT EvictionPriority )
+HRESULT GetEvictionPriority ( UINT* pEvictionPriority ) ;
+
+COM-INTERFACE: IDXGIKeyedMutex IDXGIDeviceSubObject {9d8e1289-d7b3-465f-8126-250e349af85d}
+HRESULT AcquireSync ( UINT64 Key, DWORD dwMilliseconds )
+HRESULT ReleaseSync ( UINT64 Key ) ;
+
+CONSTANT: DXGI_MAP_READ 1
+CONSTANT: DXGI_MAP_WRITE 2
+CONSTANT: DXGI_MAP_DISCARD 4
+
+COM-INTERFACE: IDXGISurface IDXGIDeviceSubObject {cafcb56c-6ac3-4889-bf47-9e23bbd260ec}
+HRESULT GetDesc ( DXGI_SURFACE_DESC* pDesc )
+HRESULT Map ( DXGI_MAPPED_RECT* pLockedRect, UINT MapFlags )
+HRESULT Unmap ( ) ;
+
+COM-INTERFACE: IDXGISurface1 IDXGISurface {4AE63092-6327-4c1b-80AE-BFE12EA32B86}
+HRESULT GetDC ( BOOL Discard, HDC* phdc )
+HRESULT ReleaseDC ( RECT* pDirtyRect ) ;
+
+COM-INTERFACE: IDXGIAdapter IDXGIObject {2411e7e1-12ac-4ccf-bd14-9798e8534dc0}
+HRESULT EnumOutputs ( UINT Output, IDXGIOutput** ppOutput )
+HRESULT GetDesc ( DXGI_ADAPTER_DESC* pDesc )
+HRESULT CheckInterfaceSupport ( REFGUID InterfaceName, LARGE_INTEGER* pUMDVersion ) ;
+
+CONSTANT: DXGI_ENUM_MODES_INTERLACED 1
+CONSTANT: DXGI_ENUM_MODES_SCALING 2
+
+COM-INTERFACE: IDXGIOutput IDXGIObject {ae02eedb-c735-4690-8d52-5a8dc20213aa}
+HRESULT GetDesc ( DXGI_OUTPUT_DESC* pDesc )
+HRESULT GetDisplayModeList ( DXGI_FORMAT EnumFormat, UINT Flags, UINT* pNumModes, DXGI_MODE_DESC* pDesc )
+HRESULT FindClosestMatchingMode ( DXGI_MODE_DESC* pModeToMatch, DXGI_MODE_DESC* pClosestMatch, IUnknown* pConcernedDevice )
+HRESULT WaitForVBlank ( )
+HRESULT TakeOwnership ( IUnknown* pDevice, BOOL Exclusive )
+void ReleaseOwnership ( )
+HRESULT GetGammaControlCapabilities ( DXGI_GAMMA_CONTROL_CAPABILITIES* pGammaCaps )
+HRESULT SetGammaControl ( DXGI_GAMMA_CONTROL* pArray )
+HRESULT GetGammaControl ( DXGI_GAMMA_CONTROL* pArray )
+HRESULT SetDisplaySurface ( IDXGISurface* pScanoutSurface )
+HRESULT GetDisplaySurfaceData ( IDXGISurface* pDestination )
+HRESULT GetFrameStatistics ( DXGI_FRAME_STATISTICS* pStats ) ;
+
+CONSTANT: DXGI_MAX_SWAP_CHAIN_BUFFERS 16
+CONSTANT: DXGI_PRESENT_TEST 1
+CONSTANT: DXGI_PRESENT_DO_NOT_SEQUENCE 2
+CONSTANT: DXGI_PRESENT_RESTART 4
+
+COM-INTERFACE: IDXGISwapChain IDXGIDeviceSubObject {310d36a0-d2e7-4c0a-aa04-6a9d23b8886a}
+HRESULT Present ( UINT SyncInterval, UINT Flags )
+HRESULT GetBuffer ( UINT Buffer, REFIID riid, void** ppSurface )
+HRESULT SetFullscreenState ( BOOL Fullscreen, IDXGIOutput* pTarget )
+HRESULT GetFullscreenState ( BOOL* pFullscreen, IDXGIOutput** ppTarget )
+HRESULT GetDesc ( DXGI_SWAP_CHAIN_DESC* pDesc )
+HRESULT ResizeBuffers ( UINT BufferCount, UINT Width, UINT Height, DXGI_FORMAT NewFormat, UINT SwapChainFlags )
+HRESULT ResizeTarget ( DXGI_MODE_DESC* pNewTargetParameters )
+HRESULT GetContainingOutput ( IDXGIOutput** ppOutput )
+HRESULT GetFrameStatistics ( DXGI_FRAME_STATISTICS* pStats )
+HRESULT GetLastPresentCount ( UINT* pLastPresentCount ) ;
+
+CONSTANT: DXGI_MWA_NO_WINDOW_CHANGES 1
+CONSTANT: DXGI_MWA_NO_ALT_ENTER 2
+CONSTANT: DXGI_MWA_NO_PRINT_SCREEN 4
+CONSTANT: DXGI_MWA_VALID 7
+
+COM-INTERFACE: IDXGIFactory IDXGIObject {7b7166ec-21c7-44ae-b21a-c9ae321ae369}
+HRESULT EnumAdapters ( UINT Adapter, IDXGIAdapter** ppAdapter )
+HRESULT MakeWindowAssociation ( HWND WindowHandle, UINT Flags )
+HRESULT GetWindowAssociation ( HWND* pWindowHandle )
+HRESULT CreateSwapChain ( IUnknown* pDevice, DXGI_SWAP_CHAIN_DESC* pDesc, IDXGISwapChain** ppSwapChain )
+HRESULT CreateSoftwareAdapter ( HMODULE Module, IDXGIAdapter** ppAdapter ) ;
+
+FUNCTION: HRESULT CreateDXGIFactory ( REFIID riid, void** ppFactory ) ;
+FUNCTION: HRESULT CreateDXGIFactory1 ( REFIID riid, void** ppFactory ) ;
+
+COM-INTERFACE: IDXGIDevice IDXGIObject {54ec77fa-1377-44e6-8c32-88fd5f44c84c}
+HRESULT GetAdapter ( IDXGIAdapter** pAdapter )
+HRESULT CreateSurface ( DXGI_SURFACE_DESC* pDesc, UINT NumSurfaces, DXGI_USAGE Usage, DXGI_SHARED_RESOURCE* pSharedResource, IDXGISurface** ppSurface )
+HRESULT QueryResourceResidency ( IUnknown** ppResources, DXGI_RESIDENCY* pResidencyStatus, UINT NumResources )
+HRESULT SetGPUThreadPriority ( INT Priority )
+HRESULT GetGPUThreadPriority ( INT* pPriority ) ;
+
+CONSTANT: DXGI_ADAPTER_FLAG_NONE 0
+CONSTANT: DXGI_ADAPTER_FLAG_REMOTE 1
+CONSTANT: DXGI_ADAPTER_FLAG_FORCE_DWORD HEX: ffffffff
+TYPEDEF: int DXGI_ADAPTER_FLAG
+
+STRUCT: DXGI_ADAPTER_DESC1
+{ Description WCHAR[128] }
+{ VendorId UINT }
+{ DeviceId UINT }
+{ SubSysId UINT }
+{ Revision UINT }
+{ DedicatedVideoMemory SIZE_T }
+{ DedicatedSystemMemory SIZE_T }
+{ SharedSystemMemory SIZE_T }
+{ AdapterLuid LUID }
+{ Flags UINT } ;
+
+STRUCT: DXGI_DISPLAY_COLOR_SPACE
+{ PrimaryCoordinates FLOAT[8][2] }
+{ WhitePoints FLOAT[16][2] } ;
+
+COM-INTERFACE: IDXGIFactory1 IDXGIFactory {770aae78-f26f-4dba-a829-253c83d1b387}
+HRESULT EnumAdapters1 ( UINT Adapter, IDXGIAdapter1** ppAdapter )
+BOOL IsCurrent ( ) ;
+
+COM-INTERFACE: IDXGIAdapter1 IDXGIAdapter {29038f61-3839-4626-91fd-086879011a05}
+HRESULT GetDesc1 ( DXGI_ADAPTER_DESC1* pDesc ) ;
+
+COM-INTERFACE: IDXGIDevice1 IDXGIDevice {77db970f-6276-48ba-ba28-070143b4392c}
+HRESULT SetMaximumFrameLatency ( UINT MaxLatency )
+HRESULT GetMaximumFrameLatency ( UINT* pMaxLatency ) ;
diff --git a/basis/windows/directx/dxgi/summary.txt b/basis/windows/directx/dxgi/summary.txt
new file mode 100644 (file)
index 0000000..1bcb6b4
--- /dev/null
@@ -0,0 +1 @@
+Bindings to the DirectX Graphics Infrastructure. Corresponds to DXGI.h.
diff --git a/basis/windows/directx/dxgi/tags.txt b/basis/windows/directx/dxgi/tags.txt
new file mode 100644 (file)
index 0000000..2320bdd
--- /dev/null
@@ -0,0 +1,2 @@
+unportable
+bindings
diff --git a/basis/windows/directx/dxgiformat/authors.txt b/basis/windows/directx/dxgiformat/authors.txt
new file mode 100644 (file)
index 0000000..6f03a12
--- /dev/null
@@ -0,0 +1 @@
+Erik Charlebois
diff --git a/basis/windows/directx/dxgiformat/dxgiformat.factor b/basis/windows/directx/dxgiformat/dxgiformat.factor
new file mode 100644 (file)
index 0000000..ab2c082
--- /dev/null
@@ -0,0 +1,105 @@
+USING: alien.c-types alien.syntax ;
+IN: windows.directx.dxgiformat
+
+CONSTANT: DXGI_FORMAT_UNKNOWN 0
+CONSTANT: DXGI_FORMAT_R32G32B32A32_TYPELESS 1
+CONSTANT: DXGI_FORMAT_R32G32B32A32_FLOAT 2
+CONSTANT: DXGI_FORMAT_R32G32B32A32_UINT 3
+CONSTANT: DXGI_FORMAT_R32G32B32A32_SINT 4
+CONSTANT: DXGI_FORMAT_R32G32B32_TYPELESS 5
+CONSTANT: DXGI_FORMAT_R32G32B32_FLOAT 6
+CONSTANT: DXGI_FORMAT_R32G32B32_UINT 7
+CONSTANT: DXGI_FORMAT_R32G32B32_SINT 8
+CONSTANT: DXGI_FORMAT_R16G16B16A16_TYPELESS 9
+CONSTANT: DXGI_FORMAT_R16G16B16A16_FLOAT 10
+CONSTANT: DXGI_FORMAT_R16G16B16A16_UNORM 11
+CONSTANT: DXGI_FORMAT_R16G16B16A16_UINT 12
+CONSTANT: DXGI_FORMAT_R16G16B16A16_SNORM 13
+CONSTANT: DXGI_FORMAT_R16G16B16A16_SINT 14
+CONSTANT: DXGI_FORMAT_R32G32_TYPELESS 15
+CONSTANT: DXGI_FORMAT_R32G32_FLOAT 16
+CONSTANT: DXGI_FORMAT_R32G32_UINT 17
+CONSTANT: DXGI_FORMAT_R32G32_SINT 18
+CONSTANT: DXGI_FORMAT_R32G8X24_TYPELESS 19
+CONSTANT: DXGI_FORMAT_D32_FLOAT_S8X24_UINT 20
+CONSTANT: DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS 21
+CONSTANT: DXGI_FORMAT_X32_TYPELESS_G8X24_UINT 22
+CONSTANT: DXGI_FORMAT_R10G10B10A2_TYPELESS 23
+CONSTANT: DXGI_FORMAT_R10G10B10A2_UNORM 24
+CONSTANT: DXGI_FORMAT_R10G10B10A2_UINT 25
+CONSTANT: DXGI_FORMAT_R11G11B10_FLOAT 26
+CONSTANT: DXGI_FORMAT_R8G8B8A8_TYPELESS 27
+CONSTANT: DXGI_FORMAT_R8G8B8A8_UNORM 28
+CONSTANT: DXGI_FORMAT_R8G8B8A8_UNORM_SRGB 29
+CONSTANT: DXGI_FORMAT_R8G8B8A8_UINT 30
+CONSTANT: DXGI_FORMAT_R8G8B8A8_SNORM 31
+CONSTANT: DXGI_FORMAT_R8G8B8A8_SINT 32
+CONSTANT: DXGI_FORMAT_R16G16_TYPELESS 33
+CONSTANT: DXGI_FORMAT_R16G16_FLOAT 34
+CONSTANT: DXGI_FORMAT_R16G16_UNORM 35
+CONSTANT: DXGI_FORMAT_R16G16_UINT 36
+CONSTANT: DXGI_FORMAT_R16G16_SNORM 37
+CONSTANT: DXGI_FORMAT_R16G16_SINT 38
+CONSTANT: DXGI_FORMAT_R32_TYPELESS 39
+CONSTANT: DXGI_FORMAT_D32_FLOAT 40
+CONSTANT: DXGI_FORMAT_R32_FLOAT 41
+CONSTANT: DXGI_FORMAT_R32_UINT 42
+CONSTANT: DXGI_FORMAT_R32_SINT 43
+CONSTANT: DXGI_FORMAT_R24G8_TYPELESS 44
+CONSTANT: DXGI_FORMAT_D24_UNORM_S8_UINT 45
+CONSTANT: DXGI_FORMAT_R24_UNORM_X8_TYPELESS 46
+CONSTANT: DXGI_FORMAT_X24_TYPELESS_G8_UINT 47
+CONSTANT: DXGI_FORMAT_R8G8_TYPELESS 48
+CONSTANT: DXGI_FORMAT_R8G8_UNORM 49
+CONSTANT: DXGI_FORMAT_R8G8_UINT 50
+CONSTANT: DXGI_FORMAT_R8G8_SNORM 51
+CONSTANT: DXGI_FORMAT_R8G8_SINT 52
+CONSTANT: DXGI_FORMAT_R16_TYPELESS 53
+CONSTANT: DXGI_FORMAT_R16_FLOAT 54
+CONSTANT: DXGI_FORMAT_D16_UNORM 55
+CONSTANT: DXGI_FORMAT_R16_UNORM 56
+CONSTANT: DXGI_FORMAT_R16_UINT 57
+CONSTANT: DXGI_FORMAT_R16_SNORM 58
+CONSTANT: DXGI_FORMAT_R16_SINT 59
+CONSTANT: DXGI_FORMAT_R8_TYPELESS 60
+CONSTANT: DXGI_FORMAT_R8_UNORM 61
+CONSTANT: DXGI_FORMAT_R8_UINT 62
+CONSTANT: DXGI_FORMAT_R8_SNORM 63
+CONSTANT: DXGI_FORMAT_R8_SINT 64
+CONSTANT: DXGI_FORMAT_A8_UNORM 65
+CONSTANT: DXGI_FORMAT_R1_UNORM 66
+CONSTANT: DXGI_FORMAT_R9G9B9E5_SHAREDEXP 67
+CONSTANT: DXGI_FORMAT_R8G8_B8G8_UNORM 68
+CONSTANT: DXGI_FORMAT_G8R8_G8B8_UNORM 69
+CONSTANT: DXGI_FORMAT_BC1_TYPELESS 70
+CONSTANT: DXGI_FORMAT_BC1_UNORM 71
+CONSTANT: DXGI_FORMAT_BC1_UNORM_SRGB 72
+CONSTANT: DXGI_FORMAT_BC2_TYPELESS 73
+CONSTANT: DXGI_FORMAT_BC2_UNORM 74
+CONSTANT: DXGI_FORMAT_BC2_UNORM_SRGB 75
+CONSTANT: DXGI_FORMAT_BC3_TYPELESS 76
+CONSTANT: DXGI_FORMAT_BC3_UNORM 77
+CONSTANT: DXGI_FORMAT_BC3_UNORM_SRGB 78
+CONSTANT: DXGI_FORMAT_BC4_TYPELESS 79
+CONSTANT: DXGI_FORMAT_BC4_UNORM 80
+CONSTANT: DXGI_FORMAT_BC4_SNORM 81
+CONSTANT: DXGI_FORMAT_BC5_TYPELESS 82
+CONSTANT: DXGI_FORMAT_BC5_UNORM 83
+CONSTANT: DXGI_FORMAT_BC5_SNORM 84
+CONSTANT: DXGI_FORMAT_B5G6R5_UNORM 85
+CONSTANT: DXGI_FORMAT_B5G5R5A1_UNORM 86
+CONSTANT: DXGI_FORMAT_B8G8R8A8_UNORM 87
+CONSTANT: DXGI_FORMAT_B8G8R8X8_UNORM 88
+CONSTANT: DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM 89
+CONSTANT: DXGI_FORMAT_B8G8R8A8_TYPELESS 90
+CONSTANT: DXGI_FORMAT_B8G8R8A8_UNORM_SRGB 91
+CONSTANT: DXGI_FORMAT_B8G8R8X8_TYPELESS 92
+CONSTANT: DXGI_FORMAT_B8G8R8X8_UNORM_SRGB 93
+CONSTANT: DXGI_FORMAT_BC6H_TYPELESS 94
+CONSTANT: DXGI_FORMAT_BC6H_UF16 95
+CONSTANT: DXGI_FORMAT_BC6H_SF16 96
+CONSTANT: DXGI_FORMAT_BC7_TYPELESS 97
+CONSTANT: DXGI_FORMAT_BC7_UNORM 98
+CONSTANT: DXGI_FORMAT_BC7_UNORM_SRGB 99
+CONSTANT: DXGI_FORMAT_FORCE_UINT HEX: ffffffff
+TYPEDEF: int DXGI_FORMAT
diff --git a/basis/windows/directx/dxgiformat/summary.txt b/basis/windows/directx/dxgiformat/summary.txt
new file mode 100644 (file)
index 0000000..9aa9982
--- /dev/null
@@ -0,0 +1 @@
+Bindings to the DirectX Graphics Infrastructure. Corresponds to DXGIFormat.h.
diff --git a/basis/windows/directx/dxgiformat/tags.txt b/basis/windows/directx/dxgiformat/tags.txt
new file mode 100644 (file)
index 0000000..2320bdd
--- /dev/null
@@ -0,0 +1,2 @@
+unportable
+bindings
diff --git a/basis/windows/directx/dxgitype/authors.txt b/basis/windows/directx/dxgitype/authors.txt
new file mode 100644 (file)
index 0000000..6f03a12
--- /dev/null
@@ -0,0 +1 @@
+Erik Charlebois
diff --git a/basis/windows/directx/dxgitype/dxgitype.factor b/basis/windows/directx/dxgitype/dxgitype.factor
new file mode 100644 (file)
index 0000000..0b318f7
--- /dev/null
@@ -0,0 +1,78 @@
+USING: alien.c-types alien.syntax classes.struct
+windows.directx.dxgiformat windows.types ;
+IN: windows.directx.dxgitype
+
+CONSTANT: DXGI_STATUS_OCCLUDED HEX: 087a0001
+CONSTANT: DXGI_STATUS_CLIPPED HEX: 087a0002
+CONSTANT: DXGI_STATUS_NO_REDIRECTION HEX: 087a0004
+CONSTANT: DXGI_STATUS_NO_DESKTOP_ACCESS HEX: 087a0005
+CONSTANT: DXGI_STATUS_GRAPHICS_VIDPN_SOURCE_IN_USE HEX: 087a0006
+CONSTANT: DXGI_STATUS_MODE_CHANGED HEX: 087a0007
+CONSTANT: DXGI_STATUS_MODE_CHANGE_IN_PROGRESS HEX: 087a0008
+
+CONSTANT: DXGI_ERROR_INVALID_CALL HEX: 887a0001
+CONSTANT: DXGI_ERROR_NOT_FOUND HEX: 887a0002
+CONSTANT: DXGI_ERROR_MORE_DATA HEX: 887a0003
+CONSTANT: DXGI_ERROR_UNSUPPORTED HEX: 887a0004
+CONSTANT: DXGI_ERROR_DEVICE_REMOVED HEX: 887a0005
+CONSTANT: DXGI_ERROR_DEVICE_HUNG HEX: 887a0006
+CONSTANT: DXGI_ERROR_DEVICE_RESET HEX: 887a0007
+CONSTANT: DXGI_ERROR_WAS_STILL_DRAWING HEX: 887a000a
+CONSTANT: DXGI_ERROR_FRAME_STATISTICS_DISJOINT HEX: 887a000b
+CONSTANT: DXGI_ERROR_GRAPHICS_VIDPN_SOURCE_IN_USE HEX: 887a000c
+CONSTANT: DXGI_ERROR_DRIVER_INTERNAL_ERROR HEX: 887a0020
+CONSTANT: DXGI_ERROR_NONEXCLUSIVE HEX: 887a0021
+CONSTANT: DXGI_ERROR_NOT_CURRENTLY_AVAILABLE HEX: 887a0022
+CONSTANT: DXGI_ERROR_REMOTE_CLIENT_DISCONNECTED HEX: 887a0023
+CONSTANT: DXGI_ERROR_REMOTE_OUTOFMEMORY HEX: 887a0024
+
+STRUCT: DXGI_RGB
+{ Red FLOAT }
+{ Green FLOAT }
+{ Blue FLOAT } ;
+
+STRUCT: DXGI_GAMMA_CONTROL
+{ Scale DXGI_RGB }
+{ Offset DXGI_RGB }
+{ GammaCurve DXGI_RGB[1025] } ;
+
+STRUCT: DXGI_GAMMA_CONTROL_CAPABILITIES
+{ ScaleAndOffsetSupported BOOL }
+{ MaxConvertedValue FLOAT }
+{ MinConvertedValue FLOAT }
+{ NumGammaControlPoints UINT }
+{ ControlPointPositions FLOAT[1025] } ;
+
+STRUCT: DXGI_RATIONAL
+{ Numerator UINT }
+{ Denominator UINT } ;
+
+C-ENUM: DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED
+        DXGI_MODE_SCANLINE_ORDER_PROGRESSIVE
+        DXGI_MODE_SCANLINE_ORDER_UPPER_FIELD_FIRST
+        DXGI_MODE_SCANLINE_ORDER_LOWER_FIELD_FIRST ;
+TYPEDEF: int DXGI_MODE_SCANLINE_ORDER
+
+C-ENUM: DXGI_MODE_SCALING_UNSPECIFIED
+        DXGI_MODE_SCALING_CENTERED
+        DXGI_MODE_SCALING_STRETCHED ;
+TYPEDEF: int DXGI_MODE_SCALING
+
+C-ENUM: DXGI_MODE_ROTATION_UNSPECIFIED
+        DXGI_MODE_ROTATION_IDENTITY
+        DXGI_MODE_ROTATION_ROTATE90
+        DXGI_MODE_ROTATION_ROTATE180
+        DXGI_MODE_ROTATION_ROTATE270 ;
+TYPEDEF: int DXGI_MODE_ROTATION
+
+STRUCT: DXGI_MODE_DESC
+{ Width UINT }
+{ Height UINT }
+{ RefreshRate DXGI_RATIONAL }
+{ Format DXGI_FORMAT }
+{ ScanlineOrdering DXGI_MODE_SCANLINE_ORDER }
+{ Scaling DXGI_MODE_SCALING } ;
+
+STRUCT: DXGI_SAMPLE_DESC
+{ Count UINT }
+{ Quality UINT } ;
diff --git a/basis/windows/directx/dxgitype/summary.txt b/basis/windows/directx/dxgitype/summary.txt
new file mode 100644 (file)
index 0000000..f7ea233
--- /dev/null
@@ -0,0 +1 @@
+Bindings to the DirectX Graphics Infrastructure. Corresponds to DXGIType.h.
diff --git a/basis/windows/directx/dxgitype/tags.txt b/basis/windows/directx/dxgitype/tags.txt
new file mode 100644 (file)
index 0000000..2320bdd
--- /dev/null
@@ -0,0 +1,2 @@
+unportable
+bindings
diff --git a/basis/windows/directx/x3daudio/authors.txt b/basis/windows/directx/x3daudio/authors.txt
new file mode 100644 (file)
index 0000000..6f03a12
--- /dev/null
@@ -0,0 +1 @@
+Erik Charlebois
diff --git a/basis/windows/directx/x3daudio/summary.txt b/basis/windows/directx/x3daudio/summary.txt
new file mode 100644 (file)
index 0000000..9fa60a3
--- /dev/null
@@ -0,0 +1 @@
+X3DAudio bindings. Corresponds to x3daudio.h.
diff --git a/basis/windows/directx/x3daudio/tags.txt b/basis/windows/directx/x3daudio/tags.txt
new file mode 100644 (file)
index 0000000..2320bdd
--- /dev/null
@@ -0,0 +1,2 @@
+unportable
+bindings
diff --git a/basis/windows/directx/x3daudio/x3daudio.factor b/basis/windows/directx/x3daudio/x3daudio.factor
new file mode 100644 (file)
index 0000000..f6b1e63
--- /dev/null
@@ -0,0 +1,96 @@
+USING: alien.c-types alien.syntax classes.struct
+windows.directx.d3dx10math windows.types ;
+IN: windows.directx.x3daudio
+
+LIBRARY: x3daudio
+
+CONSTANT: X3DAUDIO_HANDLE_BYTESIZE 20
+
+CONSTANT: X3DAUDIO_PI  3.141592654
+CONSTANT: X3DAUDIO_2PI 6.283185307
+
+CONSTANT: X3DAUDIO_SPEED_OF_SOUND 343.5
+
+CONSTANT: X3DAUDIO_CALCULATE_MATRIX          HEX: 00000001
+CONSTANT: X3DAUDIO_CALCULATE_DELAY           HEX: 00000002
+CONSTANT: X3DAUDIO_CALCULATE_LPF_DIRECT      HEX: 00000004
+CONSTANT: X3DAUDIO_CALCULATE_LPF_REVERB      HEX: 00000008
+CONSTANT: X3DAUDIO_CALCULATE_REVERB          HEX: 00000010
+CONSTANT: X3DAUDIO_CALCULATE_DOPPLER         HEX: 00000020
+CONSTANT: X3DAUDIO_CALCULATE_EMITTER_ANGLE   HEX: 00000040
+CONSTANT: X3DAUDIO_CALCULATE_ZEROCENTER      HEX: 00010000
+CONSTANT: X3DAUDIO_CALCULATE_REDIRECT_TO_LFE HEX: 00020000
+
+TYPEDEF: float FLOAT32
+TYPEDEF: D3DVECTOR X3DAUDIO_VECTOR
+
+TYPEDEF: BYTE[20] X3DAUDIO_HANDLE
+
+STRUCT: X3DAUDIO_DISTANCE_CURVE_POINT
+    { Distance   FLOAT32 }
+    { DSPSetting FLOAT32 } ;
+TYPEDEF: X3DAUDIO_DISTANCE_CURVE_POINT* LPX3DAUDIO_DISTANCE_CURVE_POINT
+
+STRUCT: X3DAUDIO_DISTANCE_CURVE
+    { pPoints                            X3DAUDIO_DISTANCE_CURVE_POINT* }
+    { PointCount                         UINT32                         } ;
+TYPEDEF: X3DAUDIO_DISTANCE_CURVE* LPX3DAUDIO_DISTANCE_CURVE
+
+STRUCT: X3DAUDIO_CONE
+    { InnerAngle  FLOAT32 }
+    { OuterAngle  FLOAT32 }
+    { InnerVolume FLOAT32 }
+    { OuterVolume FLOAT32 }
+    { InnerLPF    FLOAT32 }
+    { OuterLPF    FLOAT32 }
+    { InnerReverb FLOAT32 }
+    { OuterReverb FLOAT32 } ;
+TYPEDEF: X3DAUDIO_CONE* LPX3DAUDIO_CONE
+
+STRUCT: X3DAUDIO_LISTENER
+    { OrientFront X3DAUDIO_VECTOR }
+    { OrientTop   X3DAUDIO_VECTOR }
+    { Position    X3DAUDIO_VECTOR }
+    { Velocity    X3DAUDIO_VECTOR }
+    { pCone       X3DAUDIO_CONE*  } ;
+TYPEDEF: X3DAUDIO_LISTENER* LPX3DAUDIO_LISTENER
+
+STRUCT: X3DAUDIO_EMITTER
+    { pCone               X3DAUDIO_CONE*           }
+    { OrientFront         X3DAUDIO_VECTOR          }
+    { OrientTop           X3DAUDIO_VECTOR          }
+    { Position            X3DAUDIO_VECTOR          }
+    { Velocity            X3DAUDIO_VECTOR          }
+    { InnerRadius         FLOAT32                  }
+    { InnerRadiusAngle    FLOAT32                  }
+    { ChannelCount        UINT32                   }
+    { ChannelRadius       FLOAT32                  }
+    { pChannelAzimuths    FLOAT32*                 }
+    { pVolumeCurve        X3DAUDIO_DISTANCE_CURVE* }
+    { pLFECurve           X3DAUDIO_DISTANCE_CURVE* }
+    { pLPFDirectCurve     X3DAUDIO_DISTANCE_CURVE* }
+    { pLPFReverbCurve     X3DAUDIO_DISTANCE_CURVE* }
+    { pReverbCurve        X3DAUDIO_DISTANCE_CURVE* }
+    { CurveDistanceScaler FLOAT32                  }
+    { DopplerScaler       FLOAT32                  } ;
+TYPEDEF: X3DAUDIO_EMITTER* LPX3DAUDIO_EMITTER
+
+STRUCT: X3DAUDIO_DSP_SETTINGS
+    { pMatrixCoefficients       FLOAT32* }
+    { pDelayTimes               FLOAT32* }
+    { SrcChannelCount           UINT32   }
+    { DstChannelCount           UINT32   }
+    { LPFDirectCoefficient      FLOAT32  }
+    { LPFReverbCoefficient      FLOAT32  }
+    { ReverbLevel               FLOAT32  }
+    { DopplerFactor             FLOAT32  }
+    { EmitterToListenerAngle    FLOAT32  }
+    { EmitterToListenerDistance FLOAT32  }
+    { EmitterVelocityComponent  FLOAT32  }
+    { ListenerVelocityComponent FLOAT32  } ;
+TYPEDEF: X3DAUDIO_DSP_SETTINGS* LPX3DAUDIO_DSP_SETTINGS
+
+
+FUNCTION: void X3DAudioInitialize ( UINT32 SpeakerChannelMask, FLOAT32 SpeedOfSound, X3DAUDIO_HANDLE Instance ) ;
+
+FUNCTION: void X3DAudioCalculate ( X3DAUDIO_HANDLE Instance, X3DAUDIO_LISTENER* pListener, X3DAUDIO_EMITTER* pEmitter, UINT32 Flags, X3DAUDIO_DSP_SETTINGS* pDSPSettings ) ;
diff --git a/basis/windows/directx/xact3/authors.txt b/basis/windows/directx/xact3/authors.txt
new file mode 100644 (file)
index 0000000..6f03a12
--- /dev/null
@@ -0,0 +1 @@
+Erik Charlebois
diff --git a/basis/windows/directx/xact3/summary.txt b/basis/windows/directx/xact3/summary.txt
new file mode 100644 (file)
index 0000000..99a2c4a
--- /dev/null
@@ -0,0 +1 @@
+XACT3 bindings. Corresponds to xact3.h.
diff --git a/basis/windows/directx/xact3/tags.txt b/basis/windows/directx/xact3/tags.txt
new file mode 100644 (file)
index 0000000..2320bdd
--- /dev/null
@@ -0,0 +1,2 @@
+unportable
+bindings
diff --git a/basis/windows/directx/xact3/xact3.factor b/basis/windows/directx/xact3/xact3.factor
new file mode 100644 (file)
index 0000000..f9ebf24
--- /dev/null
@@ -0,0 +1,474 @@
+USING: alien.c-types alien.syntax classes.struct windows.com
+windows.com.syntax windows.directx.xaudio2 windows.kernel32
+windows.types ;
+IN: windows.directx.xact3
+
+LIBRARY: xactengine
+
+C-TYPE: IXACT3SoundBank
+C-TYPE: IXACT3WaveBank
+C-TYPE: IXACT3Cue
+C-TYPE: IXACT3Wave
+C-TYPE: IXACT3Engine
+C-TYPE: XACT_NOTIFICATION
+
+TYPEDEF: WORD  XACTINDEX
+TYPEDEF: BYTE  XACTNOTIFICATIONTYPE
+TYPEDEF: FLOAT XACTVARIABLEVALUE
+TYPEDEF: WORD  XACTVARIABLEINDEX
+TYPEDEF: WORD  XACTCATEGORY
+TYPEDEF: BYTE  XACTCHANNEL
+TYPEDEF: FLOAT XACTVOLUME
+TYPEDEF: LONG  XACTTIME
+TYPEDEF: SHORT XACTPITCH
+TYPEDEF: BYTE  XACTLOOPCOUNT
+TYPEDEF: BYTE  XACTVARIATIONWEIGHT
+TYPEDEF: BYTE  XACTPRIORITY
+TYPEDEF: BYTE  XACTINSTANCELIMIT
+
+CONSTANT: WAVE_FORMAT_IEEE_FLOAT HEX: 0003
+CONSTANT: WAVE_FORMAT_EXTENSIBLE HEX: FFFE
+
+STRUCT: WAVEFORMATEX
+    { wFormatTag        WORD  }
+    { nChannels         WORD  }
+    { nSamplesPerSec    DWORD }
+    { nAvgBytesPerSec   DWORD }
+    { nBlockAlign       WORD  }
+    { wBitsPerSample    WORD  }
+    { cbSize            WORD  } ;
+TYPEDEF: WAVEFORMATEX* PWAVEFORMATEX
+TYPEDEF: WAVEFORMATEX* NPWAVEFORMATEX
+TYPEDEF: WAVEFORMATEX* LPWAVEFORMATEX
+
+UNION-STRUCT: WAVEFORMATEXTENSIBLE_UNION
+    { wValidBitsPerSample        WORD }
+    { wSamplesPerBlock           WORD }
+    { wReserved                  WORD } ;
+STRUCT: WAVEFORMATEXTENSIBLE
+    { Format                  WAVEFORMATEX               }
+    { Union                   WAVEFORMATEXTENSIBLE_UNION }
+    { dwChannelMask           DWORD                      }
+    { SubFormat               GUID                       } ;
+TYPEDEF: WAVEFORMATEXTENSIBLE* PWAVEFORMATEXTENSIBLE
+
+CONSTANT: XACTTIME_MIN                    HEX: 80000001
+CONSTANT: XACTTIME_MAX                    HEX: 7fffffff
+CONSTANT: XACTTIME_INFINITE               HEX: 7fffffff
+CONSTANT: XACTINSTANCELIMIT_INFINITE      HEX: ff
+CONSTANT: XACTINSTANCELIMIT_MIN           HEX: 00
+CONSTANT: XACTINSTANCELIMIT_MAX           HEX: fe
+CONSTANT: XACTINDEX_MIN                   HEX: 0
+CONSTANT: XACTINDEX_MAX                   HEX: fffe
+CONSTANT: XACTINDEX_INVALID               HEX: ffff
+CONSTANT: XACTNOTIFICATIONTYPE_MIN        HEX: 00
+CONSTANT: XACTNOTIFICATIONTYPE_MAX        HEX: ff
+CONSTANT: XACTVARIABLEINDEX_MIN           HEX: 0000
+CONSTANT: XACTVARIABLEINDEX_MAX           HEX: fffe
+CONSTANT: XACTVARIABLEINDEX_INVALID       HEX: ffff
+CONSTANT: XACTCATEGORY_MIN                HEX: 0
+CONSTANT: XACTCATEGORY_MAX                HEX: fffe
+CONSTANT: XACTCATEGORY_INVALID            HEX: ffff
+CONSTANT: XACTCHANNEL_MIN                 0
+CONSTANT: XACTCHANNEL_MAX                 HEX: FF
+CONSTANT: XACTPITCH_MIN                   -1200
+CONSTANT: XACTPITCH_MAX                   1200
+CONSTANT: XACTPITCH_MIN_TOTAL             -2400
+CONSTANT: XACTPITCH_MAX_TOTAL             2400
+CONSTANT: XACTVOLUME_MIN                  0.0
+CONSTANT: XACTVOLUME_MAX                  16777216.0
+CONSTANT: XACTLOOPCOUNT_MIN               HEX: 0
+CONSTANT: XACTLOOPCOUNT_MAX               HEX: fe
+CONSTANT: XACTLOOPCOUNT_INFINITE          HEX: ff
+CONSTANT: XACTWAVEALIGNMENT_MIN           2048
+
+CONSTANT: XACT_CUE_NAME_LENGTH        HEX: FF
+CONSTANT: XACT_CONTENT_VERSION        46
+
+CONSTANT: XACT_FLAG_STOP_RELEASE       HEX: 00000000
+CONSTANT: XACT_FLAG_STOP_IMMEDIATE     HEX: 00000001
+
+CONSTANT: XACT_FLAG_MANAGEDATA         HEX: 00000001
+
+CONSTANT: XACT_FLAG_BACKGROUND_MUSIC   HEX: 00000002
+CONSTANT: XACT_FLAG_UNITS_MS           HEX: 00000004
+CONSTANT: XACT_FLAG_UNITS_SAMPLES      HEX: 00000008
+
+CONSTANT: XACT_STATE_CREATED           HEX: 00000001
+CONSTANT: XACT_STATE_PREPARING         HEX: 00000002
+CONSTANT: XACT_STATE_PREPARED          HEX: 00000004
+CONSTANT: XACT_STATE_PLAYING           HEX: 00000008
+CONSTANT: XACT_STATE_STOPPING          HEX: 00000010
+CONSTANT: XACT_STATE_STOPPED           HEX: 00000020
+CONSTANT: XACT_STATE_PAUSED            HEX: 00000040
+CONSTANT: XACT_STATE_INUSE             HEX: 00000080
+CONSTANT: XACT_STATE_PREPAREFAILED     HEX: 80000000
+
+C-TYPE: XACT_READFILE_CB
+C-TYPE: XACT_GETOVERLAPPEDRESULT_CB
+
+: XACT_FLAG_GLOBAL_SETTINGS_MANAGEDATA ( -- z ) XACT_FLAG_MANAGEDATA ; inline
+
+
+STRUCT: XACT_FILEIO_CALLBACKS
+    { readFileCallback              XACT_READFILE_CB* }
+    { getOverlappedResultCallback   XACT_GETOVERLAPPEDRESULT_CB* } ;
+TYPEDEF: XACT_FILEIO_CALLBACKS* PXACT_FILEIO_CALLBACKS
+
+C-TYPE: XACT_NOTIFICATION_CALLBACK
+
+CONSTANT: XACT_RENDERER_ID_LENGTH                 HEX: ff
+CONSTANT: XACT_RENDERER_NAME_LENGTH               HEX: ff
+
+STRUCT: XACT_RENDERER_DETAILS
+    { rendererID     WCHAR[255] }
+    { displayName    WCHAR[255] }
+    { defaultDevice  BOOL       } ;
+TYPEDEF: XACT_RENDERER_DETAILS* LPXACT_RENDERER_DETAILS
+
+CONSTANT: XACT_ENGINE_LOOKAHEAD_DEFAULT 250
+
+STRUCT: XACT_RUNTIME_PARAMETERS
+    { lookAheadTime                  DWORD                       }
+    { pGlobalSettingsBuffer          void*                       }
+    { globalSettingsBufferSize       DWORD                       }
+    { globalSettingsFlags            DWORD                       }
+    { globalSettingsAllocAttributes  DWORD                       }
+    { fileIOCallbacks                XACT_FILEIO_CALLBACKS       }
+    { fnNotificationCallback         XACT_NOTIFICATION_CALLBACK* }
+    { pRendererID                    PWSTR                       }
+    { pXAudio2                       IXAudio2*                   }
+    { pMasteringVoice                IXAudio2MasteringVoice*     } ;
+TYPEDEF: XACT_RUNTIME_PARAMETERS* LPXACT_RUNTIME_PARAMETERS
+
+STRUCT: XACT_STREAMING_PARAMETERS
+    { file          HANDLE }
+    { offset        DWORD  }
+    { flags         DWORD  }
+    { packetSize    WORD   } ;
+TYPEDEF: XACT_STREAMING_PARAMETERS XACT_WAVEBANK_STREAMING_PARAMETERS
+TYPEDEF: XACT_WAVEBANK_STREAMING_PARAMETERS* LPXACT_WAVEBANK_STREAMING_PARAMETERS
+TYPEDEF: XACT_STREAMING_PARAMETERS* LPXACT_STREAMING_PARAMETERS
+
+STRUCT: XACT_CUE_PROPERTIES
+    { friendlyName     CHAR[255] }
+    { interactive      BOOL }
+    { iaVariableIndex  XACTINDEX }
+    { numVariations    XACTINDEX }
+    { maxInstances     XACTINSTANCELIMIT }
+    { currentInstances XACTINSTANCELIMIT } ;
+TYPEDEF: XACT_CUE_PROPERTIES* LPXACT_CUE_PROPERTIES
+
+STRUCT: XACT_TRACK_PROPERTIES
+    { duration            XACTTIME      }
+    { numVariations       XACTINDEX     }
+    { numChannels         XACTCHANNEL   }
+    { waveVariation       XACTINDEX     }
+    { loopCount           XACTLOOPCOUNT } ;
+TYPEDEF: XACT_TRACK_PROPERTIES* LPXACT_TRACK_PROPERTIES
+
+STRUCT: XACT_VARIATION_PROPERTIES
+    { index                     XACTINDEX           }
+    { weight                    XACTVARIATIONWEIGHT }
+    { iaVariableMin             XACTVARIABLEVALUE   }
+    { iaVariableMax             XACTVARIABLEVALUE   }
+    { linger                    BOOL                } ;
+TYPEDEF: XACT_VARIATION_PROPERTIES* LPXACT_VARIATION_PROPERTIES
+
+STRUCT: XACT_SOUND_PROPERTIES
+    { category            XACTCATEGORY          }
+    { priority            BYTE                  }
+    { pitch               XACTPITCH             }
+    { volume              XACTVOLUME            }
+    { numTracks           XACTINDEX             }
+    { arrTrackProperties  XACT_TRACK_PROPERTIES } ;
+TYPEDEF: XACT_SOUND_PROPERTIES* LPXACT_SOUND_PROPERTIES
+
+STRUCT: XACT_SOUND_VARIATION_PROPERTIES
+    { variationProperties   XACT_VARIATION_PROPERTIES }
+    { soundProperties       XACT_SOUND_PROPERTIES     } ;
+TYPEDEF: XACT_SOUND_VARIATION_PROPERTIES* LPXACT_SOUND_VARIATION_PROPERTIES
+
+STRUCT: XACT_CUE_INSTANCE_PROPERTIES
+    { allocAttributes           DWORD                           }
+    { cueProperties             XACT_CUE_PROPERTIES             }
+    { activeVariationProperties XACT_SOUND_VARIATION_PROPERTIES } ;
+TYPEDEF: XACT_CUE_INSTANCE_PROPERTIES* LPXACT_CUE_INSTANCE_PROPERTIES
+
+STRUCT: WAVEBANKMINIWAVEFORMAT
+    { dwValue DWORD } ;
+
+STRUCT: WAVEBANKSAMPLEREGION
+    { dwStartSample  DWORD }
+    { dwTotalSamples DWORD } ;
+
+STRUCT: XACT_WAVE_PROPERTIES
+    { friendlyName      char[64]               }
+    { format            WAVEBANKMINIWAVEFORMAT }
+    { durationInSamples DWORD                  }
+    { loopRegion        WAVEBANKSAMPLEREGION   }
+    { streaming         BOOL                   } ;
+TYPEDEF: XACT_WAVE_PROPERTIES* LPXACT_WAVE_PROPERTIES
+
+STRUCT: XACT_WAVE_INSTANCE_PROPERTIES
+    { properties      XACT_WAVE_PROPERTIES }
+    { backgroundMusic BOOL                 } ;
+TYPEDEF: XACT_WAVE_INSTANCE_PROPERTIES* LPXACT_WAVE_INSTANCE_PROPERTIES
+
+STRUCT: XACTCHANNELMAPENTRY
+    { InputChannel    XACTCHANNEL }
+    { OutputChannel   XACTCHANNEL }
+    { Volume          XACTVOLUME  } ;
+TYPEDEF: XACTCHANNELMAPENTRY* LPXACTCHANNELMAPENTRY
+
+STRUCT: XACTCHANNELMAP
+    { EntryCount             XACTCHANNEL          }
+    { paEntries              XACTCHANNELMAPENTRY* } ;
+TYPEDEF: XACTCHANNELMAP* LPXACTCHANNELMAP
+
+STRUCT: XACTCHANNELVOLUMEENTRY
+    { EntryIndex   XACTCHANNEL }
+    { Volume       XACTVOLUME  } ;
+TYPEDEF: XACTCHANNELVOLUMEENTRY* LPXACTCHANNELVOLUMEENTRY
+
+STRUCT: XACTCHANNELVOLUME
+    { EntryCount             XACTCHANNEL             }
+    { paEntries              XACTCHANNELVOLUMEENTRY* } ;
+TYPEDEF: XACTCHANNELVOLUME* LPXACTCHANNELVOLUME
+
+CONSTANT: XACTNOTIFICATIONTYPE_CUEPREPARED                      1
+CONSTANT: XACTNOTIFICATIONTYPE_CUEPLAY                          2
+CONSTANT: XACTNOTIFICATIONTYPE_CUESTOP                          3
+CONSTANT: XACTNOTIFICATIONTYPE_CUEDESTROYED                     4
+CONSTANT: XACTNOTIFICATIONTYPE_MARKER                           5
+CONSTANT: XACTNOTIFICATIONTYPE_SOUNDBANKDESTROYED               6
+CONSTANT: XACTNOTIFICATIONTYPE_WAVEBANKDESTROYED                7
+CONSTANT: XACTNOTIFICATIONTYPE_LOCALVARIABLECHANGED             8
+CONSTANT: XACTNOTIFICATIONTYPE_GLOBALVARIABLECHANGED            9
+CONSTANT: XACTNOTIFICATIONTYPE_GUICONNECTED                     10
+CONSTANT: XACTNOTIFICATIONTYPE_GUIDISCONNECTED                  11
+CONSTANT: XACTNOTIFICATIONTYPE_WAVEPREPARED                     12
+CONSTANT: XACTNOTIFICATIONTYPE_WAVEPLAY                         13
+CONSTANT: XACTNOTIFICATIONTYPE_WAVESTOP                         14
+CONSTANT: XACTNOTIFICATIONTYPE_WAVELOOPED                       15
+CONSTANT: XACTNOTIFICATIONTYPE_WAVEDESTROYED                    16
+CONSTANT: XACTNOTIFICATIONTYPE_WAVEBANKPREPARED                 17
+CONSTANT: XACTNOTIFICATIONTYPE_WAVEBANKSTREAMING_INVALIDCONTENT 18
+
+CONSTANT: XACT_FLAG_NOTIFICATION_PERSIST HEX: 01
+
+STRUCT: XACT_NOTIFICATION_DESCRIPTION
+    { type                     XACTNOTIFICATIONTYPE }
+    { flags                    BYTE                 }
+    { pSoundBank               IXACT3SoundBank*     }
+    { pWaveBank                IXACT3WaveBank*      }
+    { pCue                     IXACT3Cue*           }
+    { pWave                    IXACT3Wave*          }
+    { cueIndex                 XACTINDEX            }
+    { waveIndex                XACTINDEX            }
+    { pvContext                PVOID                } ;
+TYPEDEF: XACT_NOTIFICATION_DESCRIPTION* LPXACT_NOTIFICATION_DESCRIPTION
+
+STRUCT: XACT_NOTIFICATION_CUE
+    { cueIndex       XACTINDEX        }
+    { pSoundBank     IXACT3SoundBank* }
+    { pCue           IXACT3Cue*       } ;
+TYPEDEF: XACT_NOTIFICATION_CUE* LPXACT_NOTIFICATION_CUE
+
+STRUCT: XACT_NOTIFICATION_MARKER
+    { cueIndex         XACTINDEX        }
+    { pSoundBank       IXACT3SoundBank* }
+    { pCue             IXACT3Cue*       }
+    { marker           DWORD            } ;
+TYPEDEF: XACT_NOTIFICATION_MARKER* LPXACT_NOTIFICATION_MARKER
+
+STRUCT: XACT_NOTIFICATION_SOUNDBANK
+    { pSoundBank IXACT3SoundBank* } ;
+TYPEDEF: XACT_NOTIFICATION_SOUNDBANK* LPXACT_NOTIFICATION_SOUNDBANK
+
+STRUCT: XACT_NOTIFICATION_WAVEBANK
+    { pWaveBank  IXACT3WaveBank* } ;
+TYPEDEF: XACT_NOTIFICATION_WAVEBANK* LPXACT_NOTIFICATION_WAVEBANK
+
+STRUCT: XACT_NOTIFICATION_VARIABLE
+    { cueIndex             XACTINDEX         }
+    { pSoundBank           IXACT3SoundBank*  }
+    { pCue                 IXACT3Cue*        }
+    { variableIndex        XACTVARIABLEINDEX }
+    { variableValue        XACTVARIABLEVALUE }
+    { local                BOOL              } ;
+TYPEDEF: XACT_NOTIFICATION_VARIABLE* LPXACT_NOTIFICATION_VARIABLE
+
+STRUCT: XACT_NOTIFICATION_GUI
+    { reserved   DWORD } ;
+TYPEDEF: XACT_NOTIFICATION_GUI* LPXACT_NOTIFICATION_GUI
+
+STRUCT: XACT_NOTIFICATION_WAVE
+    { pWaveBank       IXACT3WaveBank*  }
+    { waveIndex       XACTINDEX        }
+    { cueIndex        XACTINDEX        }
+    { pSoundBank      IXACT3SoundBank* }
+    { pCue            IXACT3Cue*       }
+    { pWave           IXACT3Wave*      } ;
+TYPEDEF: XACT_NOTIFICATION_WAVE* LPXACT_NOTIFICATION_WAVE
+
+UNION-STRUCT: XACT_NOTIFICATION_UNION
+    { cue       XACT_NOTIFICATION_CUE }
+    { marker    XACT_NOTIFICATION_MARKER }
+    { soundBank XACT_NOTIFICATION_SOUNDBANK }
+    { waveBank  XACT_NOTIFICATION_WAVEBANK }
+    { variable  XACT_NOTIFICATION_VARIABLE }
+    { gui       XACT_NOTIFICATION_GUI }
+    { wave      XACT_NOTIFICATION_WAVE } ;
+STRUCT: XACT_NOTIFICATION
+    { type                         XACTNOTIFICATIONTYPE    }
+    { timeStamp                    LONG                    }
+    { pvContext                    PVOID                   }
+    { union                        XACT_NOTIFICATION_UNION } ;
+TYPEDEF: XACT_NOTIFICATION* LPXACT_NOTIFICATION
+
+CONSTANT: XACT_FLAG_SOUNDBANK_STOP_IMMEDIATE  HEX: 00000001
+CONSTANT: XACT_SOUNDBANKSTATE_INUSE           HEX: 00000080
+
+COM-INTERFACE: IXACT3SoundBank f {00000000-0000-0000-0000-000000000000}
+    XACTINDEX GetCueIndex ( PCSTR szFriendlyName )
+    HRESULT GetNumCues ( XACTINDEX* pnNumCues )
+    HRESULT GetCueProperties ( XACTINDEX nCueIndex, LPXACT_CUE_PROPERTIES pProperties )
+    HRESULT Prepare ( XACTINDEX nCueIndex, DWORD dwFlags, XACTTIME timeOffset, IXACT3Cue** ppCue )
+    HRESULT Play ( XACTINDEX nCueIndex, DWORD dwFlags, XACTTIME timeOffset, IXACT3Cue** ppCue )
+    HRESULT Stop ( XACTINDEX nCueIndex, DWORD dwFlags )
+    HRESULT Destroy ( )
+    HRESULT GetState ( DWORD* pdwState ) ;
+
+CONSTANT: XACT_WAVEBANKSTATE_INUSE            HEX: 00000080
+CONSTANT: XACT_WAVEBANKSTATE_PREPARED         HEX: 00000004
+CONSTANT: XACT_WAVEBANKSTATE_PREPAREFAILED    HEX: 80000000
+
+COM-INTERFACE: IXACT3WaveBank f {00000000-0000-0000-0000-000000000000}
+    HRESULT Destroy ( )
+    HRESULT GetNumWaves ( XACTINDEX* pnNumWaves )
+    XACTINDEX GetWaveIndex ( PCSTR szFriendlyName )
+    HRESULT GetWaveProperties ( XACTINDEX nWaveIndex, LPXACT_WAVE_PROPERTIES pWaveProperties )
+    HRESULT Prepare ( XACTINDEX nWaveIndex, DWORD dwFlags, DWORD dwPlayOffset, XACTLOOPCOUNT nLoopCount, IXACT3Wave** ppWave )
+    HRESULT Play ( XACTINDEX nWaveIndex, DWORD dwFlags, DWORD dwPlayOffset, XACTLOOPCOUNT nLoopCount, IXACT3Wave** ppWave )
+    HRESULT Stop ( XACTINDEX nWaveIndex, DWORD dwFlags )
+    HRESULT GetState ( DWORD* pdwState ) ;
+
+COM-INTERFACE: IXACT3Wave f {00000000-0000-0000-0000-000000000000}
+    HRESULT Destroy ( )
+    HRESULT Play ( )
+    HRESULT Stop ( DWORD dwFlags )
+    HRESULT Pause ( BOOL fPause )
+    HRESULT GetState ( DWORD* pdwState )
+    HRESULT SetPitch ( XACTPITCH pitch )
+    HRESULT SetVolume ( XACTVOLUME volume )
+    HRESULT SetMatrixCoefficients ( UINT32 uSrcChannelCount, UINT32 uDstChannelCount,  float* pMatrixCoefficients )
+    HRESULT GetProperties ( LPXACT_WAVE_INSTANCE_PROPERTIES pProperties ) ;
+
+: XACT_FLAG_CUE_STOP_RELEASE      ( -- z ) XACT_FLAG_STOP_RELEASE ; inline 
+: XACT_FLAG_CUE_STOP_IMMEDIATE    ( -- z ) XACT_FLAG_STOP_IMMEDIATE ; inline 
+
+: XACT_CUESTATE_CREATED           ( -- z ) XACT_STATE_CREATED ; inline 
+: XACT_CUESTATE_PREPARING         ( -- z ) XACT_STATE_PREPARING ; inline 
+: XACT_CUESTATE_PREPARED          ( -- z ) XACT_STATE_PREPARED ; inline 
+: XACT_CUESTATE_PLAYING           ( -- z ) XACT_STATE_PLAYING ; inline 
+: XACT_CUESTATE_STOPPING          ( -- z ) XACT_STATE_STOPPING ; inline 
+: XACT_CUESTATE_STOPPED           ( -- z ) XACT_STATE_STOPPED ; inline 
+: XACT_CUESTATE_PAUSED            ( -- z ) XACT_STATE_PAUSED ; inline 
+
+COM-INTERFACE: IXACT3Cue f {00000000-0000-0000-0000-000000000000}
+    HRESULT Play (  )
+    HRESULT Stop ( DWORD dwFlags )
+    HRESULT GetState ( DWORD* pdwState )
+    HRESULT Destroy (  )
+    HRESULT SetMatrixCoefficients ( UINT32 uSrcChannelCount, UINT32 uDstChannelCount,  float* pMatrixCoefficients )
+    XACTVARIABLEINDEX GetVariableIndex ( PCSTR szFriendlyName )
+    HRESULT SetVariable ( XACTVARIABLEINDEX nIndex, XACTVARIABLEVALUE nValue )
+    HRESULT GetVariable ( XACTVARIABLEINDEX nIndex, XACTVARIABLEVALUE* nValue )
+    HRESULT Pause ( BOOL fPause )
+    HRESULT GetProperties ( LPXACT_CUE_INSTANCE_PROPERTIES* ppProperties )
+    HRESULT SetOutputVoices ( XAUDIO2_VOICE_SENDS* pSendList )
+    HRESULT SetOutputVoiceMatrix ( IXAudio2Voice* pDestinationVoice, UINT32 SourceChannels, UINT32 DestinationChannels, float* pLevelMatrix ) ;
+
+: XACT_FLAG_ENGINE_CREATE_MANAGEDATA    ( -- z ) XACT_FLAG_MANAGEDATA ; inline 
+: XACT_FLAG_ENGINE_STOP_IMMEDIATE       ( -- z ) XACT_FLAG_STOP_IMMEDIATE ; inline 
+
+STRUCT: WAVEBANKREGION
+    { dwOffset       DWORD }
+    { dwLength       DWORD } ;
+
+STRUCT: WAVEBANKENTRY
+    { dwFlagsAndDuration  DWORD                  }
+    { Format              WAVEBANKMINIWAVEFORMAT }
+    { PlayRegion          WAVEBANKREGION         }
+    { LoopRegion          WAVEBANKSAMPLEREGION   } ;
+
+COM-INTERFACE: IXACT3Engine IUnknown {b1ee676a-d9cd-4d2a-89a8-fa53eb9e480b}
+    HRESULT GetRendererCount ( XACTINDEX* pnRendererCount )
+    HRESULT GetRendererDetails ( XACTINDEX nRendererIndex, LPXACT_RENDERER_DETAILS pRendererDetails )
+    HRESULT GetFinalMixFormat ( WAVEFORMATEXTENSIBLE* pFinalMixFormat )
+    HRESULT Initialize ( XACT_RUNTIME_PARAMETERS* pParams )
+    HRESULT ShutDown (  )
+    HRESULT DoWork (  )
+    HRESULT CreateSoundBank ( void* pvBuffer, DWORD dwSize, DWORD dwFlags, DWORD dwAllocAttributes, IXACT3SoundBank** ppSoundBank )
+    HRESULT CreateInMemoryWaveBank ( void* pvBuffer, DWORD dwSize, DWORD dwFlags, DWORD dwAllocAttributes, IXACT3WaveBank** ppWaveBank )
+    HRESULT CreateStreamingWaveBank ( XACT_WAVEBANK_STREAMING_PARAMETERS* pParms, IXACT3WaveBank** ppWaveBank )
+    HRESULT PrepareWave ( DWORD dwFlags,  PCSTR szWavePath, WORD wStreamingPacketSize, DWORD dwAlignment, DWORD dwPlayOffset, XACTLOOPCOUNT nLoopCount, IXACT3Wave** ppWave )
+    HRESULT PrepareInMemoryWave ( DWORD dwFlags, WAVEBANKENTRY entry, DWORD* pdwSeekTable, BYTE* pbWaveData, DWORD dwPlayOffset, XACTLOOPCOUNT nLoopCount, IXACT3Wave** ppWave )
+    HRESULT PrepareStreamingWave ( DWORD dwFlags, WAVEBANKENTRY entry, XACT_STREAMING_PARAMETERS streamingParams, DWORD dwAlignment, DWORD* pdwSeekTable, DWORD dwPlayOffset, XACTLOOPCOUNT nLoopCount, IXACT3Wave** ppWave )
+    HRESULT RegisterNotification ( XACT_NOTIFICATION_DESCRIPTION* pNotificationDesc )
+    HRESULT UnRegisterNotification ( XACT_NOTIFICATION_DESCRIPTION* pNotificationDesc )
+    XACTCATEGORY GetCategory ( PCSTR szFriendlyName )
+    HRESULT Stop ( XACTCATEGORY nCategory, DWORD dwFlags )
+    HRESULT SetVolume ( XACTCATEGORY nCategory, XACTVOLUME nVolume )
+    HRESULT Pause ( XACTCATEGORY nCategory, BOOL fPause )
+    XACTVARIABLEINDEX GetGlobalVariableIndex ( PCSTR szFriendlyName )
+    HRESULT SetGlobalVariable ( XACTVARIABLEINDEX nIndex, XACTVARIABLEVALUE nValue )
+    HRESULT GetGlobalVariable ( XACTVARIABLEINDEX nIndex,  XACTVARIABLEVALUE* nValue ) ;
+
+CONSTANT: XACT_FLAG_API_AUDITION_MODE 1
+CONSTANT: XACT_FLAG_API_DEBUG_MODE    2
+
+CONSTANT: XACTENGINE_E_OUTOFMEMORY               HEX: 80070000
+CONSTANT: XACTENGINE_E_INVALIDARG                HEX: 80070057
+CONSTANT: XACTENGINE_E_NOTIMPL                   HEX: 80004001
+CONSTANT: XACTENGINE_E_FAIL                      HEX: 80004005
+
+CONSTANT: XACTENGINE_E_ALREADYINITIALIZED        HEX: 8AC70001
+CONSTANT: XACTENGINE_E_NOTINITIALIZED            HEX: 8AC70002
+CONSTANT: XACTENGINE_E_EXPIRED                   HEX: 8AC70003
+CONSTANT: XACTENGINE_E_NONOTIFICATIONCALLBACK    HEX: 8AC70004
+CONSTANT: XACTENGINE_E_NOTIFICATIONREGISTERED    HEX: 8AC70005
+CONSTANT: XACTENGINE_E_INVALIDUSAGE              HEX: 8AC70006
+CONSTANT: XACTENGINE_E_INVALIDDATA               HEX: 8AC70007
+CONSTANT: XACTENGINE_E_INSTANCELIMITFAILTOPLAY   HEX: 8AC70008
+CONSTANT: XACTENGINE_E_NOGLOBALSETTINGS          HEX: 8AC70009
+CONSTANT: XACTENGINE_E_INVALIDVARIABLEINDEX      HEX: 8AC7000a
+CONSTANT: XACTENGINE_E_INVALIDCATEGORY           HEX: 8AC7000b
+CONSTANT: XACTENGINE_E_INVALIDCUEINDEX           HEX: 8AC7000c
+CONSTANT: XACTENGINE_E_INVALIDWAVEINDEX          HEX: 8AC7000d
+CONSTANT: XACTENGINE_E_INVALIDTRACKINDEX         HEX: 8AC7000e
+CONSTANT: XACTENGINE_E_INVALIDSOUNDOFFSETORINDEX HEX: 8AC7000f
+CONSTANT: XACTENGINE_E_READFILE                  HEX: 8AC70010
+CONSTANT: XACTENGINE_E_UNKNOWNEVENT              HEX: 8AC70011
+CONSTANT: XACTENGINE_E_INCALLBACK                HEX: 8AC70012
+CONSTANT: XACTENGINE_E_NOWAVEBANK                HEX: 8AC70013
+CONSTANT: XACTENGINE_E_SELECTVARIATION           HEX: 8AC70014
+CONSTANT: XACTENGINE_E_MULTIPLEAUDITIONENGINES   HEX: 8AC70015
+CONSTANT: XACTENGINE_E_WAVEBANKNOTPREPARED       HEX: 8AC70016
+CONSTANT: XACTENGINE_E_NORENDERER                HEX: 8AC70017
+CONSTANT: XACTENGINE_E_INVALIDENTRYCOUNT         HEX: 8AC70018
+CONSTANT: XACTENGINE_E_SEEKTIMEBEYONDCUEEND      HEX: 8AC70019
+CONSTANT: XACTENGINE_E_SEEKTIMEBEYONDWAVEEND     HEX: 8AC7001a
+CONSTANT: XACTENGINE_E_NOFRIENDLYNAMES           HEX: 8AC7001b
+
+CONSTANT: XACTENGINE_E_AUDITION_WRITEFILE             HEX: 8AC70101
+CONSTANT: XACTENGINE_E_AUDITION_NOSOUNDBANK           HEX: 8AC70102
+CONSTANT: XACTENGINE_E_AUDITION_INVALIDRPCINDEX       HEX: 8AC70103
+CONSTANT: XACTENGINE_E_AUDITION_MISSINGDATA           HEX: 8AC70104
+CONSTANT: XACTENGINE_E_AUDITION_UNKNOWNCOMMAND        HEX: 8AC70105
+CONSTANT: XACTENGINE_E_AUDITION_INVALIDDSPINDEX       HEX: 8AC70106
+CONSTANT: XACTENGINE_E_AUDITION_MISSINGWAVE           HEX: 8AC70107
+CONSTANT: XACTENGINE_E_AUDITION_CREATEDIRECTORYFAILED HEX: 8AC70108
+CONSTANT: XACTENGINE_E_AUDITION_INVALIDSESSION        HEX: 8AC70109
+
diff --git a/basis/windows/directx/xapo/authors.txt b/basis/windows/directx/xapo/authors.txt
new file mode 100644 (file)
index 0000000..6f03a12
--- /dev/null
@@ -0,0 +1 @@
+Erik Charlebois
diff --git a/basis/windows/directx/xapo/summary.txt b/basis/windows/directx/xapo/summary.txt
new file mode 100644 (file)
index 0000000..95e1421
--- /dev/null
@@ -0,0 +1 @@
+XAPO bindings. Corresponds to xapo.h.
diff --git a/basis/windows/directx/xapo/tags.txt b/basis/windows/directx/xapo/tags.txt
new file mode 100644 (file)
index 0000000..2320bdd
--- /dev/null
@@ -0,0 +1,2 @@
+unportable
+bindings
diff --git a/basis/windows/directx/xapo/xapo.factor b/basis/windows/directx/xapo/xapo.factor
new file mode 100644 (file)
index 0000000..5878af8
--- /dev/null
@@ -0,0 +1,68 @@
+USING: alien.c-types alien.syntax classes.struct windows.com
+windows.com.syntax windows.directx.audiodefs windows.kernel32
+windows.types ;
+IN: windows.directx.xapo
+
+CONSTANT: XAPO_MIN_CHANNELS 1
+CONSTANT: XAPO_MAX_CHANNELS 64
+
+CONSTANT: XAPO_MIN_FRAMERATE 1000
+CONSTANT: XAPO_MAX_FRAMERATE 200000
+
+CONSTANT: XAPO_REGISTRATION_STRING_LENGTH 256
+
+CONSTANT: XAPO_FLAG_CHANNELS_MUST_MATCH      HEX: 00000001
+
+CONSTANT: XAPO_FLAG_FRAMERATE_MUST_MATCH     HEX: 00000002
+
+CONSTANT: XAPO_FLAG_BITSPERSAMPLE_MUST_MATCH HEX: 00000004
+
+CONSTANT: XAPO_FLAG_BUFFERCOUNT_MUST_MATCH   HEX: 00000008
+
+CONSTANT: XAPO_FLAG_INPLACE_REQUIRED         HEX: 00000020
+
+CONSTANT: XAPO_FLAG_INPLACE_SUPPORTED        HEX: 00000010
+
+STRUCT: XAPO_REGISTRATION_PROPERTIES 
+    { clsid                GUID       }
+    { FriendlyName         WCHAR[256] }
+    { CopyrightInfo        WCHAR[256] }
+    { MajorVersion         UINT32     }
+    { MinorVersion         UINT32     }
+    { Flags                UINT32     }
+    { MinInputBufferCount  UINT32     }
+    { MaxInputBufferCount  UINT32     }
+    { MinOutputBufferCount UINT32     }
+    { MaxOutputBufferCount UINT32     } ;
+
+STRUCT: XAPO_LOCKFORPROCESS_BUFFER_PARAMETERS
+    { pFormat                    WAVEFORMATEX* }
+    { MaxFrameCount              UINT32        } ;
+
+C-ENUM:
+        XAPO_BUFFER_SILENT
+        XAPO_BUFFER_VALID ;
+TYPEDEF: int XAPO_BUFFER_FLAGS
+
+STRUCT: XAPO_PROCESS_BUFFER_PARAMETERS
+    { pBuffer                    void*             }
+    { BufferFlags                XAPO_BUFFER_FLAGS }
+    { ValidFrameCount            UINT32            } ;
+
+COM-INTERFACE: IXAPO IUnknown {A90BC001-E897-E897-55E4-9E4700000000}
+    HRESULT GetRegistrationProperties ( XAPO_REGISTRATION_PROPERTIES** ppRegistrationProperties )
+    HRESULT IsInputFormatSupported ( WAVEFORMATEX* pOutputFormat, WAVEFORMATEX* pRequestedInputFormat, WAVEFORMATEX** ppSupportedInputFormat )
+    HRESULT IsOutputFormatSupported ( WAVEFORMATEX* pInputFormat, WAVEFORMATEX* pRequestedOutputFormat, WAVEFORMATEX** ppSupportedOutputFormat )
+    HRESULT Initialize ( void* pData, UINT32 DataByteSize )
+    void Reset ( )
+    HRESULT LockForProcess ( UINT32 InputLockedParameterCount, XAPO_LOCKFORPROCESS_BUFFER_PARAMETERS* pInputLockedParameters, UINT32 OutputLockedParameterCount, XAPO_LOCKFORPROCESS_BUFFER_PARAMETERS* pOutputLockedParameters )
+    void UnlockForProcess ( )
+    void Process ( UINT32 InputProcessParameterCount, XAPO_PROCESS_BUFFER_PARAMETERS* pInputProcessParameters, UINT32 OutputProcessParameterCount, XAPO_PROCESS_BUFFER_PARAMETERS* pOutputProcessParameters, BOOL IsEnabled )
+    UINT32 CalcInputFrames ( UINT32 OutputFrameCount )
+    UINT32 CalcOutputFrames ( UINT32 InputFrameCount ) ;
+
+COM-INTERFACE: IXAPOParameters IUnknown {A90BC001-E897-E897-55E4-9E4700000001}
+    void SetParameters ( void* pParameters, UINT32 ParameterByteSize )
+    void GetParameters ( void* pParameters, UINT32 ParameterByteSize ) ;
+
+
diff --git a/basis/windows/directx/xapofx/authors.txt b/basis/windows/directx/xapofx/authors.txt
new file mode 100644 (file)
index 0000000..6f03a12
--- /dev/null
@@ -0,0 +1 @@
+Erik Charlebois
diff --git a/basis/windows/directx/xapofx/summary.txt b/basis/windows/directx/xapofx/summary.txt
new file mode 100644 (file)
index 0000000..8dce424
--- /dev/null
@@ -0,0 +1 @@
+XAPOFX bindings. Corresponds to xapofx.h.
diff --git a/basis/windows/directx/xapofx/tags.txt b/basis/windows/directx/xapofx/tags.txt
new file mode 100644 (file)
index 0000000..2320bdd
--- /dev/null
@@ -0,0 +1,2 @@
+unportable
+bindings
diff --git a/basis/windows/directx/xapofx/xapofx.factor b/basis/windows/directx/xapofx/xapofx.factor
new file mode 100644 (file)
index 0000000..1255880
--- /dev/null
@@ -0,0 +1,80 @@
+USING: alien.c-types alien.syntax classes.struct windows.ole32
+windows.types ;
+IN: windows.directx.xapofx
+
+LIBRARY: xapofx
+
+CONSTANT: FXEQ_MIN_FRAMERATE 22000
+CONSTANT: FXEQ_MAX_FRAMERATE 48000
+
+CONSTANT: FXEQ_MIN_FREQUENCY_CENTER       20.0
+CONSTANT: FXEQ_MAX_FREQUENCY_CENTER       20000.0
+CONSTANT: FXEQ_DEFAULT_FREQUENCY_CENTER_0 100.0
+CONSTANT: FXEQ_DEFAULT_FREQUENCY_CENTER_1 800.0
+CONSTANT: FXEQ_DEFAULT_FREQUENCY_CENTER_2 2000.0
+CONSTANT: FXEQ_DEFAULT_FREQUENCY_CENTER_3 10000.0
+
+CONSTANT: FXEQ_MIN_GAIN     0.126
+CONSTANT: FXEQ_MAX_GAIN     7.94
+CONSTANT: FXEQ_DEFAULT_GAIN 1.0
+
+CONSTANT: FXEQ_MIN_BANDWIDTH     0.1
+CONSTANT: FXEQ_MAX_BANDWIDTH     2.0
+CONSTANT: FXEQ_DEFAULT_BANDWIDTH 1.0
+
+CONSTANT: FXMASTERINGLIMITER_MIN_RELEASE     1
+CONSTANT: FXMASTERINGLIMITER_MAX_RELEASE     20
+CONSTANT: FXMASTERINGLIMITER_DEFAULT_RELEASE 6
+
+CONSTANT: FXMASTERINGLIMITER_MIN_LOUDNESS     1
+CONSTANT: FXMASTERINGLIMITER_MAX_LOUDNESS     1800
+CONSTANT: FXMASTERINGLIMITER_DEFAULT_LOUDNESS 1000
+
+CONSTANT: FXREVERB_MIN_DIFFUSION     0.0
+CONSTANT: FXREVERB_MAX_DIFFUSION     1.0
+CONSTANT: FXREVERB_DEFAULT_DIFFUSION 0.9
+
+CONSTANT: FXREVERB_MIN_ROOMSIZE     0.0001
+CONSTANT: FXREVERB_MAX_ROOMSIZE     1.0
+CONSTANT: FXREVERB_DEFAULT_ROOMSIZE 0.6
+
+CONSTANT: FXECHO_MIN_WETDRYMIX     0.0
+CONSTANT: FXECHO_MAX_WETDRYMIX     1.0
+CONSTANT: FXECHO_DEFAULT_WETDRYMIX 0.5
+
+CONSTANT: FXECHO_MIN_FEEDBACK     0.0
+CONSTANT: FXECHO_MAX_FEEDBACK     1.0
+CONSTANT: FXECHO_DEFAULT_FEEDBACK 0.5
+
+CONSTANT: FXECHO_MIN_DELAY     1.0
+CONSTANT: FXECHO_MAX_DELAY     2000.0
+CONSTANT: FXECHO_DEFAULT_DELAY 500.0
+
+STRUCT: FXEQ_PARAMETERS
+    { FrequencyCenter0 float }
+    { Gain0            float }
+    { Bandwidth0       float }
+    { FrequencyCenter1 float }
+    { Gain1            float }
+    { Bandwidth1       float }
+    { FrequencyCenter2 float }
+    { Gain2            float }
+    { Bandwidth2       float }
+    { FrequencyCenter3 float }
+    { Gain3            float }
+    { Bandwidth3       float } ;
+
+STRUCT: FXMASTERINGLIMITER_PARAMETERS
+    { Release  UINT32 }
+    { Loudness UINT32 } ;
+
+STRUCT: FXREVERB_PARAMETERS
+    { Diffusion float }
+    { RoomSize  float } ;
+
+STRUCT: FXECHO_PARAMETERS
+    { WetDryMix float }
+    { Feedback  float }
+    { Delay     float } ;
+
+FUNCTION: HRESULT CreateFX ( REFCLSID clsid, IUnknown** pEffect ) ;
diff --git a/basis/windows/directx/xaudio2/authors.txt b/basis/windows/directx/xaudio2/authors.txt
new file mode 100644 (file)
index 0000000..6f03a12
--- /dev/null
@@ -0,0 +1 @@
+Erik Charlebois
diff --git a/basis/windows/directx/xaudio2/summary.txt b/basis/windows/directx/xaudio2/summary.txt
new file mode 100644 (file)
index 0000000..4b78fa9
--- /dev/null
@@ -0,0 +1 @@
+XAudio2 bindings. Corresponds to xaudio2.h.
diff --git a/basis/windows/directx/xaudio2/tags.txt b/basis/windows/directx/xaudio2/tags.txt
new file mode 100644 (file)
index 0000000..2320bdd
--- /dev/null
@@ -0,0 +1,2 @@
+unportable
+bindings
diff --git a/basis/windows/directx/xaudio2/xaudio2.factor b/basis/windows/directx/xaudio2/xaudio2.factor
new file mode 100644 (file)
index 0000000..67a9234
--- /dev/null
@@ -0,0 +1,312 @@
+USING: alien.c-types alien.syntax classes.struct math
+windows.com windows.com.syntax windows.directx.audiodefs
+windows.types ;
+IN: windows.directx.xaudio2
+
+LIBRARY: xaudio2
+
+CONSTANT: XAUDIO2_MAX_BUFFER_BYTES        HEX: 80000000
+CONSTANT: XAUDIO2_MAX_QUEUED_BUFFERS      64
+CONSTANT: XAUDIO2_MAX_BUFFERS_SYSTEM      2
+CONSTANT: XAUDIO2_MAX_AUDIO_CHANNELS      64
+CONSTANT: XAUDIO2_MIN_SAMPLE_RATE         1000
+CONSTANT: XAUDIO2_MAX_SAMPLE_RATE         200000
+CONSTANT: XAUDIO2_MAX_VOLUME_LEVEL        16777216.0
+: XAUDIO2_MIN_FREQ_RATIO ( -- z ) 1.0 1024.0 / ; inline
+CONSTANT: XAUDIO2_MAX_FREQ_RATIO          1024.0
+CONSTANT: XAUDIO2_DEFAULT_FREQ_RATIO      2.0
+CONSTANT: XAUDIO2_MAX_FILTER_ONEOVERQ     1.5
+CONSTANT: XAUDIO2_MAX_FILTER_FREQUENCY    1.0
+CONSTANT: XAUDIO2_MAX_LOOP_COUNT          254
+CONSTANT: XAUDIO2_MAX_INSTANCES           8
+
+CONSTANT: XAUDIO2_MAX_RATIO_TIMES_RATE_XMA_MONO         600000
+CONSTANT: XAUDIO2_MAX_RATIO_TIMES_RATE_XMA_MULTICHANNEL 300000
+
+CONSTANT: XAUDIO2_COMMIT_NOW              0
+CONSTANT: XAUDIO2_COMMIT_ALL              0
+CONSTANT: XAUDIO2_INVALID_OPSET           HEX: ffffffff
+CONSTANT: XAUDIO2_NO_LOOP_REGION          0
+CONSTANT: XAUDIO2_LOOP_INFINITE           255
+CONSTANT: XAUDIO2_DEFAULT_CHANNELS        0
+CONSTANT: XAUDIO2_DEFAULT_SAMPLERATE      0
+
+
+CONSTANT: XAUDIO2_DEBUG_ENGINE            HEX: 0001
+CONSTANT: XAUDIO2_VOICE_NOPITCH           HEX: 0002
+CONSTANT: XAUDIO2_VOICE_NOSRC             HEX: 0004
+CONSTANT: XAUDIO2_VOICE_USEFILTER         HEX: 0008
+CONSTANT: XAUDIO2_VOICE_MUSIC             HEX: 0010
+CONSTANT: XAUDIO2_PLAY_TAILS              HEX: 0020
+CONSTANT: XAUDIO2_END_OF_STREAM           HEX: 0040
+CONSTANT: XAUDIO2_SEND_USEFILTER          HEX: 0080
+
+
+CONSTANT: XAUDIO2_DEFAULT_FILTER_TYPE      0
+CONSTANT: XAUDIO2_DEFAULT_FILTER_FREQUENCY 1.0
+CONSTANT: XAUDIO2_DEFAULT_FILTER_ONEOVERQ  1.0
+
+CONSTANT: XAUDIO2_QUANTUM_NUMERATOR   1
+CONSTANT: XAUDIO2_QUANTUM_DENOMINATOR 100
+
+: XAUDIO2_QUANTUM_MS ( -- z )
+    XAUDIO2_QUANTUM_DENOMINATOR 1000.0 XAUDIO2_QUANTUM_NUMERATOR * / ; inline
+
+CONSTANT: XAUDIO2_E_INVALID_CALL          HEX: 88960001
+CONSTANT: XAUDIO2_E_XMA_DECODER_ERROR     HEX: 88960002
+CONSTANT: XAUDIO2_E_XAPO_CREATION_FAILED  HEX: 88960003
+CONSTANT: XAUDIO2_E_DEVICE_INVALIDATED    HEX: 88960004
+
+CONSTANT: Processor1  HEX: 00000001
+CONSTANT: Processor2  HEX: 00000002
+CONSTANT: Processor3  HEX: 00000004
+CONSTANT: Processor4  HEX: 00000008
+CONSTANT: Processor5  HEX: 00000010
+CONSTANT: Processor6  HEX: 00000020
+CONSTANT: Processor7  HEX: 00000040
+CONSTANT: Processor8  HEX: 00000080
+CONSTANT: Processor9  HEX: 00000100
+CONSTANT: Processor10 HEX: 00000200
+CONSTANT: Processor11 HEX: 00000400
+CONSTANT: Processor12 HEX: 00000800
+CONSTANT: Processor13 HEX: 00001000
+CONSTANT: Processor14 HEX: 00002000
+CONSTANT: Processor15 HEX: 00004000
+CONSTANT: Processor16 HEX: 00008000
+CONSTANT: Processor17 HEX: 00010000
+CONSTANT: Processor18 HEX: 00020000
+CONSTANT: Processor19 HEX: 00040000
+CONSTANT: Processor20 HEX: 00080000
+CONSTANT: Processor21 HEX: 00100000
+CONSTANT: Processor22 HEX: 00200000
+CONSTANT: Processor23 HEX: 00400000
+CONSTANT: Processor24 HEX: 00800000
+CONSTANT: Processor25 HEX: 01000000
+CONSTANT: Processor26 HEX: 02000000
+CONSTANT: Processor27 HEX: 04000000
+CONSTANT: Processor28 HEX: 08000000
+CONSTANT: Processor29 HEX: 10000000
+CONSTANT: Processor30 HEX: 20000000
+CONSTANT: Processor31 HEX: 40000000
+CONSTANT: Processor32 HEX: 80000000
+CONSTANT: XAUDIO2_ANY_PROCESSOR HEX: ffffffff
+CONSTANT: XAUDIO2_DEFAULT_PROCESSOR HEX: ffffffff
+TYPEDEF: int XAUDIO2_WINDOWS_PROCESSOR_SPECIFIER
+TYPEDEF: int XAUDIO2_PROCESSOR
+
+CONSTANT: NotDefaultDevice            HEX: 0
+CONSTANT: DefaultConsoleDevice        HEX: 1
+CONSTANT: DefaultMultimediaDevice     HEX: 2
+CONSTANT: DefaultCommunicationsDevice HEX: 4
+CONSTANT: DefaultGameDevice           HEX: 8
+CONSTANT: GlobalDefaultDevice         HEX: f
+CONSTANT: InvalidDeviceRole           HEX: 0
+TYPEDEF: int XAUDIO2_DEVICE_ROLE
+
+STRUCT: XAUDIO2_DEVICE_DETAILS
+    { DeviceID     WCHAR[256]           }
+    { DisplayName  WCHAR[256]           }
+    { Role         XAUDIO2_DEVICE_ROLE  }
+    { OutputFormat WAVEFORMATEXTENSIBLE } ;
+
+STRUCT: XAUDIO2_VOICE_DETAILS
+    { CreationFlags   UINT32 }
+    { InputChannels   UINT32 }
+    { InputSampleRate UINT32 } ;
+
+C-TYPE: IXAudio2Voice
+
+STRUCT: XAUDIO2_SEND_DESCRIPTOR
+    { Flags        UINT32         }
+    { pOutputVoice IXAudio2Voice* } ;
+
+STRUCT: XAUDIO2_VOICE_SENDS
+    { SendCount UINT32                   }
+    { pSends    XAUDIO2_SEND_DESCRIPTOR* } ;
+
+STRUCT: XAUDIO2_EFFECT_DESCRIPTOR
+    { pEffect        IUnknown* }
+    { InitialState   BOOL      }
+    { OutputChannels UINT32    } ;
+
+STRUCT: XAUDIO2_EFFECT_CHAIN
+    { EffectCount        UINT32                     }
+    { pEffectDescriptors XAUDIO2_EFFECT_DESCRIPTOR* } ;
+
+C-ENUM:
+    LowPassFilter
+    BandPassFilter
+    HighPassFilter
+    NotchFilter ;
+TYPEDEF: int XAUDIO2_FILTER_TYPE
+
+STRUCT: XAUDIO2_FILTER_PARAMETERS
+    { Type      XAUDIO2_FILTER_TYPE }
+    { Frequency FLOAT               }
+    { OneOverQ  FLOAT               } ;
+
+STRUCT: XAUDIO2_BUFFER
+    { Flags      UINT32 }
+    { AudioBytes UINT32 }
+    { pAudioData BYTE*  }
+    { PlayBegin  UINT32 }
+    { PlayLength UINT32 }
+    { LoopBegin  UINT32 }
+    { LoopLength UINT32 }
+    { LoopCount  UINT32 }
+    { pContext   void*  } ;
+
+
+STRUCT: XAUDIO2_BUFFER_WMA
+    { pDecodedPacketCumulativeBytes UINT32* }
+    { PacketCount                   UINT32  } ;
+
+STRUCT: XAUDIO2_VOICE_STATE
+    { pCurrentBufferContext void*  }
+    { BuffersQueued         UINT32 }
+    { SamplesPlayed         UINT64 } ;
+
+STRUCT: XAUDIO2_PERFORMANCE_DATA
+    { AudioCyclesSinceLastQuery  UINT64 }
+    { TotalCyclesSinceLastQuery  UINT64 }
+    { MinimumCyclesPerQuantum    UINT32 }
+    { MaximumCyclesPerQuantum    UINT32 }
+    { MemoryUsageInBytes         UINT32 }
+    { CurrentLatencyInSamples    UINT32 }
+    { GlitchesSinceEngineStarted UINT32 }
+    { ActiveSourceVoiceCount     UINT32 }
+    { TotalSourceVoiceCount      UINT32 }
+    { ActiveSubmixVoiceCount     UINT32 }
+    { ActiveResamplerCount       UINT32 }
+    { ActiveMatrixMixCount       UINT32 }
+    { ActiveXmaSourceVoices      UINT32 }
+    { ActiveXmaStreams           UINT32 } ;
+
+STRUCT: XAUDIO2_DEBUG_CONFIGURATION
+    { TraceMask       UINT32 }
+    { BreakMask       UINT32 }
+    { LogThreadID     BOOL   }
+    { LogFileline     BOOL   }
+    { LogFunctionName BOOL   }
+    { LogTiming       BOOL   } ;
+
+CONSTANT: XAUDIO2_LOG_ERRORS     HEX: 0001
+CONSTANT: XAUDIO2_LOG_WARNINGS   HEX: 0002
+CONSTANT: XAUDIO2_LOG_INFO       HEX: 0004
+CONSTANT: XAUDIO2_LOG_DETAIL     HEX: 0008
+CONSTANT: XAUDIO2_LOG_API_CALLS  HEX: 0010
+CONSTANT: XAUDIO2_LOG_FUNC_CALLS HEX: 0020
+CONSTANT: XAUDIO2_LOG_TIMING     HEX: 0040
+CONSTANT: XAUDIO2_LOG_LOCKS      HEX: 0080
+CONSTANT: XAUDIO2_LOG_MEMORY     HEX: 0100
+CONSTANT: XAUDIO2_LOG_STREAMING  HEX: 1000
+
+C-TYPE: IXAudio2EngineCallback
+C-TYPE: IXAudio2VoiceCallback
+
+COM-INTERFACE: IXAudio2 IUnknown {8bcf1f58-9fe7-4583-8ac6-e2adc465c8bb}
+    HRESULT GetDeviceCount ( UINT32* pCount )
+    HRESULT GetDeviceDetails ( UINT32 Index, XAUDIO2_DEVICE_DETAILS* pDeviceDetails )
+    HRESULT Initialize ( UINT32 Flags, XAUDIO2_PROCESSOR XAudio2Processor )
+    HRESULT RegisterForCallbacks ( IXAudio2EngineCallback* pCallback )
+    void UnregisterForCallbacks ( IXAudio2EngineCallback* pCallback )
+    HRESULT CreateSourceVoice (
+        IXAudio2SourceVoice**  ppSourceVoice,
+        WAVEFORMATEX*          pSourceFormat,
+        UINT32                 Flags,
+        FLOAT                  MaxFrequencyRatio,
+        IXAudio2VoiceCallback* pCallback,
+        XAUDIO2_VOICE_SENDS*   pSendList,
+        XAUDIO2_EFFECT_CHAIN*  pEffectChain )
+    HRESULT CreateSubmixVoice (
+        IXAudio2SubmixVoice** ppSubmixVoice,
+        UINT32                InputChannels,
+        UINT32                InputSampleRate,
+        UINT32                Flags,
+        UINT32                ProcessingStage,
+        XAUDIO2_VOICE_SENDS*  pSendList,
+        XAUDIO2_EFFECT_CHAIN* pEffectChain )
+    HRESULT CreateMasteringVoice (
+        IXAudio2MasteringVoice** ppMasteringVoice,
+        UINT32                   InputChannels,
+        UINT32                   InputSampleRate,
+        UINT32                   Flags
+        UINT32                   DeviceIndex,
+        XAUDIO2_EFFECT_CHAIN*    pEffectChain )
+    HRESULT StartEngine (   )
+    void StopEngine (   )
+    HRESULT CommitChanges ( UINT32 OperationSet )
+    void GetPerformanceData ( XAUDIO2_PERFORMANCE_DATA* pPerfData )
+    void SetDebugConfiguration ( XAUDIO2_DEBUG_CONFIGURATION* pDebugConfiguration, void* pReserved ) ;
+
+COM-INTERFACE: IXAudio2Voice f {00000000-0000-0000-0000-000000000000}
+    void GetVoiceDetails ( XAUDIO2_VOICE_DETAILS* pVoiceDetails )
+    HRESULT SetOutputVoices ( XAUDIO2_VOICE_SENDS* pSendList )
+    HRESULT SetEffectChain ( XAUDIO2_EFFECT_CHAIN* pEffectChain )
+    HRESULT EnableEffect ( UINT32 EffectIndex, UINT32 OperationSet )
+    HRESULT DisableEffect ( UINT32 EffectIndex, UINT32 OperationSet )
+    void GetEffectState ( UINT32 EffectIndex, BOOL* pEnabled )
+    HRESULT SetEffectParameters (
+        UINT32 EffectIndex,
+        void*  pParameters,
+        UINT32 ParametersByteSize,
+        UINT32 OperationSet )
+    HRESULT GetEffectParameters (
+        UINT32 EffectIndex,
+        void*  pParameters,
+        UINT32 ParametersByteSize )
+    HRESULT SetFilterParameters ( XAUDIO2_FILTER_PARAMETERS* pParameters, UINT32 OperationSet )
+    void GetFilterParameters ( XAUDIO2_FILTER_PARAMETERS* pParameters )
+    HRESULT SetOutputFilterParameters ( IXAudio2Voice*             pDestinationVoice,
+                                        XAUDIO2_FILTER_PARAMETERS* pParameters,
+                                        UINT32                     OperationSet )
+    void GetOutputFilterParameters ( IXAudio2Voice*             pDestinationVoice,
+                                     XAUDIO2_FILTER_PARAMETERS* pParameters )
+    HRESULT SetVolume ( FLOAT  Volume,
+                        UINT32 OperationSet )
+    void GetVolume ( FLOAT* pVolume )
+    HRESULT SetChannelVolumes ( UINT32 Channels,
+                                FLOAT* pVolumes,
+                                UINT32 OperationSet )
+    void GetChannelVolumes ( UINT32 Channels, FLOAT* pVolumes )
+    HRESULT SetOutputMatrix (
+        IXAudio2Voice* pDestinationVoice,
+        UINT32         SourceChannels,
+        UINT32         DestinationChannels,
+        FLOAT*         pLevelMatrix,
+        UINT32         OperationSet    )
+    void GetOutputMatrix (
+        IXAudio2Voice* pDestinationVoice,
+        UINT32         SourceChannels,
+        UINT32         DestinationChannels,
+        FLOAT*         pLevelMatrix )
+    void DestroyVoice (  ) ;
+
+COM-INTERFACE: IXAudio2SourceVoice IXAudio2Voice {00000000-0000-0000-0000-000000000000}
+    HRESULT Start ( UINT32 Flags, UINT32 OperationSet )
+    HRESULT Stop ( UINT32 Flags, UINT32 OperationSet )
+    HRESULT SubmitSourceBuffer ( XAUDIO2_BUFFER* pBuffer, XAUDIO2_BUFFER_WMA* pBufferWMA )
+    HRESULT FlushSourceBuffers ( )
+    HRESULT Discontinuity ( )
+    HRESULT ExitLoop ( UINT32 OperationSet )
+    void GetState ( XAUDIO2_VOICE_STATE* pVoiceState )
+    HRESULT SetFrequencyRatio ( FLOAT Ratio, UINT32 OperationSet )
+    void GetFrequencyRatio ( FLOAT* pRatio )
+    HRESULT SetSourceSampleRate ( UINT32 NewSourceSampleRate ) ;
+
+COM-INTERFACE: IXAudio2SubmixVoice IXAudio2Voice {00000000-0000-0000-0000-000000000000} ;
+COM-INTERFACE: IXAudio2MasteringVoice IXAudio2Voice {00000000-0000-0000-0000-000000000000} ;
+    
+COM-INTERFACE: IXAudio2EngineCallback f {00000000-0000-0000-0000-000000000000}
+    void OnProcessingPassStart (   )
+    void OnProcessingPassEnd (   )
+    void OnCriticalError ( HRESULT Error ) ;
+
+COM-INTERFACE: IXAudio2VoiceCallback f {00000000-0000-0000-0000-000000000000}
+    void OnVoiceProcessingPassStart ( UINT32 BytesRequired )
+    void OnVoiceProcessingPassEnd (   )
+    void OnStreamEnd (   )
+    void OnBufferStart ( void* pBufferContext )
+    void OnBufferEnd ( void* pBufferContext )
+    void OnLoopEnd ( void* pBufferContext )
+    void OnVoiceError ( void* pBufferContext, HRESULT Error ) ;
diff --git a/basis/windows/directx/xaudio2fx/authors.txt b/basis/windows/directx/xaudio2fx/authors.txt
new file mode 100644 (file)
index 0000000..6f03a12
--- /dev/null
@@ -0,0 +1 @@
+Erik Charlebois
diff --git a/basis/windows/directx/xaudio2fx/summary.txt b/basis/windows/directx/xaudio2fx/summary.txt
new file mode 100644 (file)
index 0000000..92502ae
--- /dev/null
@@ -0,0 +1 @@
+Constants and types for XAudio2. Corresponds to xaudio2fx.h.
diff --git a/basis/windows/directx/xaudio2fx/tags.txt b/basis/windows/directx/xaudio2fx/tags.txt
new file mode 100644 (file)
index 0000000..2320bdd
--- /dev/null
@@ -0,0 +1,2 @@
+unportable
+bindings
diff --git a/basis/windows/directx/xaudio2fx/xaudio2fx.factor b/basis/windows/directx/xaudio2fx/xaudio2fx.factor
new file mode 100644 (file)
index 0000000..9d088f3
--- /dev/null
@@ -0,0 +1,109 @@
+USING: alien.c-types classes.struct windows.types ;
+IN: windows.directx.xaudio2fx
+
+CONSTANT: XAUDIO2FX_DEBUG 1
+
+STRUCT: XAUDIO2FX_VOLUMEMETER_LEVELS
+    { pPeakLevels  float*  }
+    { pRMSLevels   float*  }
+    { ChannelCount UINT32  } ;
+
+CONSTANT: XAUDIO2FX_REVERB_MIN_FRAMERATE 20000
+CONSTANT: XAUDIO2FX_REVERB_MAX_FRAMERATE 48000
+
+STRUCT: XAUDIO2FX_REVERB_PARAMETERS
+    { WetDryMix           float  }
+    { ReflectionsDelay    UINT32 }
+    { ReverbDelay         BYTE   }
+    { RearDelay           BYTE   }
+    { PositionLeft        BYTE   }
+    { PositionRight       BYTE   }
+    { PositionMatrixLeft  BYTE   }
+    { PositionMatrixRight BYTE   }
+    { EarlyDiffusion      BYTE   }
+    { LateDiffusion       BYTE   }
+    { LowEQGain           BYTE   }
+    { LowEQCutoff         BYTE   }
+    { HighEQGain          BYTE   }
+    { HighEQCutoff        BYTE   }
+    { RoomFilterFreq      float  }
+    { RoomFilterMain      float  }
+    { RoomFilterHF        float  }
+    { ReflectionsGain     float  }
+    { ReverbGain          float  }
+    { DecayTime           float  }
+    { Density             float  }
+    { RoomSize            float  } ;
+
+CONSTANT: XAUDIO2FX_REVERB_MIN_WET_DRY_MIX            0.0
+CONSTANT: XAUDIO2FX_REVERB_MIN_REFLECTIONS_DELAY      0
+CONSTANT: XAUDIO2FX_REVERB_MIN_REVERB_DELAY           0
+CONSTANT: XAUDIO2FX_REVERB_MIN_REAR_DELAY             0
+CONSTANT: XAUDIO2FX_REVERB_MIN_POSITION               0
+CONSTANT: XAUDIO2FX_REVERB_MIN_DIFFUSION              0
+CONSTANT: XAUDIO2FX_REVERB_MIN_LOW_EQ_GAIN            0
+CONSTANT: XAUDIO2FX_REVERB_MIN_LOW_EQ_CUTOFF          0
+CONSTANT: XAUDIO2FX_REVERB_MIN_HIGH_EQ_GAIN           0
+CONSTANT: XAUDIO2FX_REVERB_MIN_HIGH_EQ_CUTOFF         0
+CONSTANT: XAUDIO2FX_REVERB_MIN_ROOM_FILTER_FREQ       20.0
+CONSTANT: XAUDIO2FX_REVERB_MIN_ROOM_FILTER_MAIN       -100.0
+CONSTANT: XAUDIO2FX_REVERB_MIN_ROOM_FILTER_HF         -100.0
+CONSTANT: XAUDIO2FX_REVERB_MIN_REFLECTIONS_GAIN       -100.0
+CONSTANT: XAUDIO2FX_REVERB_MIN_REVERB_GAIN            -100.0
+CONSTANT: XAUDIO2FX_REVERB_MIN_DECAY_TIME             0.1
+CONSTANT: XAUDIO2FX_REVERB_MIN_DENSITY                0.0
+CONSTANT: XAUDIO2FX_REVERB_MIN_ROOM_SIZE              0.0
+
+CONSTANT: XAUDIO2FX_REVERB_MAX_WET_DRY_MIX            100.0
+CONSTANT: XAUDIO2FX_REVERB_MAX_REFLECTIONS_DELAY      300
+CONSTANT: XAUDIO2FX_REVERB_MAX_REVERB_DELAY           85
+CONSTANT: XAUDIO2FX_REVERB_MAX_REAR_DELAY             5
+CONSTANT: XAUDIO2FX_REVERB_MAX_POSITION               30
+CONSTANT: XAUDIO2FX_REVERB_MAX_DIFFUSION              15
+CONSTANT: XAUDIO2FX_REVERB_MAX_LOW_EQ_GAIN            12
+CONSTANT: XAUDIO2FX_REVERB_MAX_LOW_EQ_CUTOFF          9
+CONSTANT: XAUDIO2FX_REVERB_MAX_HIGH_EQ_GAIN           8
+CONSTANT: XAUDIO2FX_REVERB_MAX_HIGH_EQ_CUTOFF         14
+CONSTANT: XAUDIO2FX_REVERB_MAX_ROOM_FILTER_FREQ       20000.0
+CONSTANT: XAUDIO2FX_REVERB_MAX_ROOM_FILTER_MAIN       0.0
+CONSTANT: XAUDIO2FX_REVERB_MAX_ROOM_FILTER_HF         0.0
+CONSTANT: XAUDIO2FX_REVERB_MAX_REFLECTIONS_GAIN       20.0
+CONSTANT: XAUDIO2FX_REVERB_MAX_REVERB_GAIN            20.0
+CONSTANT: XAUDIO2FX_REVERB_MAX_DENSITY                100.0
+CONSTANT: XAUDIO2FX_REVERB_MAX_ROOM_SIZE              100.0
+
+CONSTANT: XAUDIO2FX_REVERB_DEFAULT_WET_DRY_MIX        100.0
+CONSTANT: XAUDIO2FX_REVERB_DEFAULT_REFLECTIONS_DELAY  5
+CONSTANT: XAUDIO2FX_REVERB_DEFAULT_REVERB_DELAY       5
+CONSTANT: XAUDIO2FX_REVERB_DEFAULT_REAR_DELAY         5
+CONSTANT: XAUDIO2FX_REVERB_DEFAULT_POSITION           6
+CONSTANT: XAUDIO2FX_REVERB_DEFAULT_POSITION_MATRIX    27
+CONSTANT: XAUDIO2FX_REVERB_DEFAULT_EARLY_DIFFUSION    8
+CONSTANT: XAUDIO2FX_REVERB_DEFAULT_LATE_DIFFUSION     8
+CONSTANT: XAUDIO2FX_REVERB_DEFAULT_LOW_EQ_GAIN        8
+CONSTANT: XAUDIO2FX_REVERB_DEFAULT_LOW_EQ_CUTOFF      4
+CONSTANT: XAUDIO2FX_REVERB_DEFAULT_HIGH_EQ_GAIN       8
+CONSTANT: XAUDIO2FX_REVERB_DEFAULT_HIGH_EQ_CUTOFF     4
+CONSTANT: XAUDIO2FX_REVERB_DEFAULT_ROOM_FILTER_FREQ   5000.0
+CONSTANT: XAUDIO2FX_REVERB_DEFAULT_ROOM_FILTER_MAIN   0.0
+CONSTANT: XAUDIO2FX_REVERB_DEFAULT_ROOM_FILTER_HF     0.0
+CONSTANT: XAUDIO2FX_REVERB_DEFAULT_REFLECTIONS_GAIN   0.0
+CONSTANT: XAUDIO2FX_REVERB_DEFAULT_REVERB_GAIN        0.0
+CONSTANT: XAUDIO2FX_REVERB_DEFAULT_DECAY_TIME         1.0
+CONSTANT: XAUDIO2FX_REVERB_DEFAULT_DENSITY            100.0
+CONSTANT: XAUDIO2FX_REVERB_DEFAULT_ROOM_SIZE          100.0
+
+STRUCT: XAUDIO2FX_REVERB_I3DL2_PARAMETERS
+    { WetDryMix         float }
+    { Room              INT32 }
+    { RoomHF            INT32 }
+    { RoomRolloffFactor float }
+    { DecayTime         float }
+    { DecayHFRatio      float }
+    { Reflections       INT32 }
+    { ReflectionsDelay  float }
+    { Reverb            INT32 }
+    { ReverbDelay       float }
+    { Diffusion         float }
+    { Density           float }
+    { HFReference       float } ;
diff --git a/basis/windows/directx/xinput/authors.txt b/basis/windows/directx/xinput/authors.txt
new file mode 100644 (file)
index 0000000..6f03a12
--- /dev/null
@@ -0,0 +1 @@
+Erik Charlebois
diff --git a/basis/windows/directx/xinput/summary.txt b/basis/windows/directx/xinput/summary.txt
new file mode 100644 (file)
index 0000000..4b67f6f
--- /dev/null
@@ -0,0 +1 @@
+XInput bindings for using the Xbox 360 controller. Corresponds to XInput.h.
diff --git a/basis/windows/directx/xinput/tags.txt b/basis/windows/directx/xinput/tags.txt
new file mode 100644 (file)
index 0000000..2320bdd
--- /dev/null
@@ -0,0 +1,2 @@
+unportable
+bindings
diff --git a/basis/windows/directx/xinput/xinput.factor b/basis/windows/directx/xinput/xinput.factor
new file mode 100644 (file)
index 0000000..d51e37a
--- /dev/null
@@ -0,0 +1,123 @@
+USING: alien.syntax classes.struct windows.kernel32 windows.types ;
+IN: windows.directx.xinput
+
+LIBRARY: xinput
+
+CONSTANT: XINPUT_DEVTYPE_GAMEPAD         1
+CONSTANT: XINPUT_DEVSUBTYPE_GAMEPAD      1
+CONSTANT: XINPUT_DEVSUBTYPE_WHEEL        2
+CONSTANT: XINPUT_DEVSUBTYPE_ARCADE_STICK 3
+CONSTANT: XINPUT_DEVSUBTYPE_FLIGHT_SICK  4
+CONSTANT: XINPUT_DEVSUBTYPE_DANCE_PAD    5
+CONSTANT: XINPUT_DEVSUBTYPE_GUITAR       6
+CONSTANT: XINPUT_DEVSUBTYPE_DRUM_KIT     8
+
+CONSTANT: XINPUT_CAPS_VOICE_SUPPORTED 4
+
+CONSTANT: XINPUT_GAMEPAD_DPAD_UP        HEX: 0001
+CONSTANT: XINPUT_GAMEPAD_DPAD_DOWN      HEX: 0002
+CONSTANT: XINPUT_GAMEPAD_DPAD_LEFT      HEX: 0004
+CONSTANT: XINPUT_GAMEPAD_DPAD_RIGHT     HEX: 0008
+CONSTANT: XINPUT_GAMEPAD_START          HEX: 0010
+CONSTANT: XINPUT_GAMEPAD_BACK           HEX: 0020
+CONSTANT: XINPUT_GAMEPAD_LEFT_THUMB     HEX: 0040
+CONSTANT: XINPUT_GAMEPAD_RIGHT_THUMB    HEX: 0080
+CONSTANT: XINPUT_GAMEPAD_LEFT_SHOULDER  HEX: 0100
+CONSTANT: XINPUT_GAMEPAD_RIGHT_SHOULDER HEX: 0200
+CONSTANT: XINPUT_GAMEPAD_A              HEX: 1000
+CONSTANT: XINPUT_GAMEPAD_B              HEX: 2000
+CONSTANT: XINPUT_GAMEPAD_X              HEX: 4000
+CONSTANT: XINPUT_GAMEPAD_Y              HEX: 8000
+
+CONSTANT: XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE  7849
+CONSTANT: XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE 8689
+CONSTANT: XINPUT_GAMEPAD_TRIGGER_THRESHOLD    30
+
+CONSTANT: XINPUT_FLAG_GAMEPAD 1
+
+CONSTANT: XUSER_MAX_COUNT                 4
+
+CONSTANT: XUSER_INDEX_ANY                 HEX: 000000FF
+
+CONSTANT: VK_PAD_A                        HEX: 5800
+CONSTANT: VK_PAD_B                        HEX: 5801
+CONSTANT: VK_PAD_X                        HEX: 5802
+CONSTANT: VK_PAD_Y                        HEX: 5803
+CONSTANT: VK_PAD_RSHOULDER                HEX: 5804
+CONSTANT: VK_PAD_LSHOULDER                HEX: 5805
+CONSTANT: VK_PAD_LTRIGGER                 HEX: 5806
+CONSTANT: VK_PAD_RTRIGGER                 HEX: 5807
+
+CONSTANT: VK_PAD_DPAD_UP                  HEX: 5810
+CONSTANT: VK_PAD_DPAD_DOWN                HEX: 5811
+CONSTANT: VK_PAD_DPAD_LEFT                HEX: 5812
+CONSTANT: VK_PAD_DPAD_RIGHT               HEX: 5813
+CONSTANT: VK_PAD_START                    HEX: 5814
+CONSTANT: VK_PAD_BACK                     HEX: 5815
+CONSTANT: VK_PAD_LTHUMB_PRESS             HEX: 5816
+CONSTANT: VK_PAD_RTHUMB_PRESS             HEX: 5817
+
+CONSTANT: VK_PAD_LTHUMB_UP                HEX: 5820
+CONSTANT: VK_PAD_LTHUMB_DOWN              HEX: 5821
+CONSTANT: VK_PAD_LTHUMB_RIGHT             HEX: 5822
+CONSTANT: VK_PAD_LTHUMB_LEFT              HEX: 5823
+CONSTANT: VK_PAD_LTHUMB_UPLEFT            HEX: 5824
+CONSTANT: VK_PAD_LTHUMB_UPRIGHT           HEX: 5825
+CONSTANT: VK_PAD_LTHUMB_DOWNRIGHT         HEX: 5826
+CONSTANT: VK_PAD_LTHUMB_DOWNLEFT          HEX: 5827
+
+CONSTANT: VK_PAD_RTHUMB_UP                HEX: 5830
+CONSTANT: VK_PAD_RTHUMB_DOWN              HEX: 5831
+CONSTANT: VK_PAD_RTHUMB_RIGHT             HEX: 5832
+CONSTANT: VK_PAD_RTHUMB_LEFT              HEX: 5833
+CONSTANT: VK_PAD_RTHUMB_UPLEFT            HEX: 5834
+CONSTANT: VK_PAD_RTHUMB_UPRIGHT           HEX: 5835
+CONSTANT: VK_PAD_RTHUMB_DOWNRIGHT         HEX: 5836
+CONSTANT: VK_PAD_RTHUMB_DOWNLEFT          HEX: 5837
+
+CONSTANT: XINPUT_KEYSTROKE_KEYDOWN        HEX: 0001
+CONSTANT: XINPUT_KEYSTROKE_KEYUP          HEX: 0002
+CONSTANT: XINPUT_KEYSTROKE_REPEAT         HEX: 0004
+
+STRUCT: XINPUT_GAMEPAD
+    { wButtons WORD }
+    { bLeftTrigger BYTE }
+    { bRightTrigger BYTE }
+    { sThumbLX SHORT }
+    { sThumbLY SHORT }
+    { sThumbRX SHORT }
+    { sThumbRY SHORT } ;
+TYPEDEF: XINPUT_GAMEPAD* PXINPUT_GAMEPAD
+
+STRUCT: XINPUT_VIBRATION
+    { wLeftMotorSpeed WORD }
+    { wRightMotorSpeed WORD } ;
+TYPEDEF: XINPUT_VIBRATION* PXINPUT_VIBRATION
+
+STRUCT: XINPUT_CAPABILITIES
+    { Type BYTE }
+    { SubType BYTE }
+    { Flags WORD }
+    { Gamepad XINPUT_GAMEPAD }
+    { Vibration XINPUT_VIBRATION } ;
+TYPEDEF: XINPUT_CAPABILITIES* PXINPUT_CAPABILITIES
+
+STRUCT: XINPUT_KEYSTROKE
+    { VirtualKey WORD }
+    { Unicode WCHAR }
+    { Flags WORD }
+    { UserIndex BYTE }
+    { HidCode BYTE } ;
+TYPEDEF: XINPUT_KEYSTROKE* PXINPUT_KEYSTROKE
+
+STRUCT: XINPUT_STATE
+    { dwPacketNumber DWORD }
+    { Gamepad XINPUT_GAMEPAD } ;
+TYPEDEF: XINPUT_STATE* PXINPUT_STATE
+
+FUNCTION: DWORD XInputGetCapabilities ( DWORD dwUserIndex, DWORD dwFlags, XINPUT_CAPABILITIES* pCapabilities ) ;
+FUNCTION: DWORD XInputGetKeystroke ( DWORD dwUserIndex, DWORD dwReserved, PXINPUT_KEYSTROKE pKeystroke ) ;
+FUNCTION: DWORD XInputGetState ( DWORD dwUserIndex, XINPUT_STATE* pState ) ;
+FUNCTION: DWORD XInputSetState ( DWORD dwUserIndex, XINPUT_VIBRATION* pVibration ) ;
+FUNCTION: DWORD XInputGetDSoundAudioDeviceGuids ( DWORD dwUserIndex, GUID* pDSoundRenderGuid, GUID* pDSoundCaptureGuid ) ;
+FUNCTION: void XInputEnable ( BOOL enable ) ;
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 9e113e8..65a08ce
@@ -37,7 +37,7 @@ MEMO:: (cache-font) ( font -- HFONT )
 
 : cache-font ( font -- HFONT ) strip-font-colors (cache-font) ;
 
-[ \ (cache-font) reset-memoized ] "windows.fonts" add-init-hook
+[ \ (cache-font) reset-memoized ] "windows.fonts" add-startup-hook
 
 : TEXTMETRIC>metrics ( TEXTMETRIC -- metrics )
     [ metrics new 0 >>width ] dip {
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 54d3fe6..80f50ef
@@ -1622,8 +1622,8 @@ FUNCTION: HANDLE OpenProcess ( DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD
 ! FUNCTION: QueryDosDeviceW
 ! FUNCTION: QueryInformationJobObject
 ! FUNCTION: QueryMemoryResourceNotification
-! FUNCTION: QueryPerformanceCounter
-! FUNCTION: QueryPerformanceFrequency
+FUNCTION: BOOL QueryPerformanceCounter ( LARGE_INTEGER* lpPerformanceCount ) ;
+FUNCTION: BOOL QueryPerformanceFrequency ( LARGE_INTEGER* lpFrequency ) ;
 ! FUNCTION: QueryWin31IniFilesMappedToRegistry
 ! FUNCTION: QueueUserAPC
 ! FUNCTION: QueueUserWorkItem
old mode 100755 (executable)
new mode 100644 (file)
index 10e6cd4..40b0979
@@ -1024,3 +1024,63 @@ CONSTANT: SC_RESTORE      HEX: f120
 CONSTANT: SC_TASKLIST     HEX: f130
 CONSTANT: SC_SCREENSAVE   HEX: f140
 CONSTANT: SC_HOTKEY       HEX: f150
+
+CONSTANT: APPCOMMAND_BROWSER_BACKWARD       1
+CONSTANT: APPCOMMAND_BROWSER_FORWARD        2
+CONSTANT: APPCOMMAND_BROWSER_REFRESH        3
+CONSTANT: APPCOMMAND_BROWSER_STOP           4
+CONSTANT: APPCOMMAND_BROWSER_SEARCH         5
+CONSTANT: APPCOMMAND_BROWSER_FAVORITES      6
+CONSTANT: APPCOMMAND_BROWSER_HOME           7
+CONSTANT: APPCOMMAND_VOLUME_MUTE            8
+CONSTANT: APPCOMMAND_VOLUME_DOWN            9
+CONSTANT: APPCOMMAND_VOLUME_UP              10
+CONSTANT: APPCOMMAND_MEDIA_NEXTTRACK        11
+CONSTANT: APPCOMMAND_MEDIA_PREVIOUSTRACK    12
+CONSTANT: APPCOMMAND_MEDIA_STOP             13
+CONSTANT: APPCOMMAND_MEDIA_PLAY_PAUSE       14
+CONSTANT: APPCOMMAND_LAUNCH_MAIL            15
+CONSTANT: APPCOMMAND_LAUNCH_MEDIA_SELECT    16
+CONSTANT: APPCOMMAND_LAUNCH_APP1            17
+CONSTANT: APPCOMMAND_LAUNCH_APP2            18
+CONSTANT: APPCOMMAND_BASS_DOWN              19
+CONSTANT: APPCOMMAND_BASS_BOOST             20
+CONSTANT: APPCOMMAND_BASS_UP                21
+CONSTANT: APPCOMMAND_TREBLE_DOWN            22
+CONSTANT: APPCOMMAND_TREBLE_UP              23
+CONSTANT: APPCOMMAND_MICROPHONE_VOLUME_MUTE 24
+CONSTANT: APPCOMMAND_MICROPHONE_VOLUME_DOWN 25
+CONSTANT: APPCOMMAND_MICROPHONE_VOLUME_UP   26
+CONSTANT: APPCOMMAND_HELP                   27
+CONSTANT: APPCOMMAND_FIND                   28
+CONSTANT: APPCOMMAND_NEW                    29
+CONSTANT: APPCOMMAND_OPEN                   30
+CONSTANT: APPCOMMAND_CLOSE                  31
+CONSTANT: APPCOMMAND_SAVE                   32
+CONSTANT: APPCOMMAND_PRINT                  33
+CONSTANT: APPCOMMAND_UNDO                   34
+CONSTANT: APPCOMMAND_REDO                   35
+CONSTANT: APPCOMMAND_COPY                   36
+CONSTANT: APPCOMMAND_CUT                    37
+CONSTANT: APPCOMMAND_PASTE                  38
+CONSTANT: APPCOMMAND_REPLY_TO_MAIL          39
+CONSTANT: APPCOMMAND_FORWARD_MAIL           40
+CONSTANT: APPCOMMAND_SEND_MAIL              41
+CONSTANT: APPCOMMAND_SPELL_CHECK            42
+CONSTANT: APPCOMMAND_DICTATE_OR_COMMAND_CONTROL_TOGGLE    43
+CONSTANT: APPCOMMAND_MIC_ON_OFF_TOGGLE      44
+CONSTANT: APPCOMMAND_CORRECTION_LIST        45
+CONSTANT: APPCOMMAND_MEDIA_PLAY             46
+CONSTANT: APPCOMMAND_MEDIA_PAUSE            47
+CONSTANT: APPCOMMAND_MEDIA_RECORD           48
+CONSTANT: APPCOMMAND_MEDIA_FAST_FORWARD     49
+CONSTANT: APPCOMMAND_MEDIA_REWIND           50
+CONSTANT: APPCOMMAND_MEDIA_CHANNEL_UP       51
+CONSTANT: APPCOMMAND_MEDIA_CHANNEL_DOWN     52
+CONSTANT: APPCOMMAND_DELETE                 53
+CONSTANT: APPCOMMAND_DWM_FLIP3D             54
+
+CONSTANT: FAPPCOMMAND_MOUSE HEX: 8000
+CONSTANT: FAPPCOMMAND_KEY   HEX: 0000
+CONSTANT: FAPPCOMMAND_OEM   HEX: 1000
+CONSTANT: FAPPCOMMAND_MASK  HEX: F000
index abc728ed19cfe456aea82652b042bd887afe88ea..8e831e153e0cf7f9399fb829efc4081e0f2cda39 100644 (file)
@@ -1,18 +1,35 @@
 USING: alien sequences alien.libraries ;
 {
-    { "advapi32" "advapi32.dll" "stdcall" }
-    { "dinput"   "dinput8.dll"  "stdcall" }
-    { "gdi32"    "gdi32.dll"    "stdcall" }
-    { "user32"   "user32.dll"   "stdcall" }
-    { "kernel32" "kernel32.dll" "stdcall" }
-    { "winsock"  "ws2_32.dll"   "stdcall" }
-    { "mswsock"  "mswsock.dll"  "stdcall" }
-    { "shell32"  "shell32.dll"  "stdcall" }
-    { "libc"     "msvcrt.dll"   "cdecl"   }
-    { "libm"     "msvcrt.dll"   "cdecl"   }
-    { "gl"       "opengl32.dll" "stdcall" }
-    { "glu"      "glu32.dll"    "stdcall" }
-    { "ole32"    "ole32.dll"    "stdcall" }
-    { "usp10"    "usp10.dll"    "stdcall" }
-    { "psapi"    "psapi.dll"    "stdcall" }
+    { "advapi32"    "advapi32.dll"       "stdcall" }
+    { "dinput"      "dinput8.dll"        "stdcall" }
+    { "gdi32"       "gdi32.dll"          "stdcall" }
+    { "user32"      "user32.dll"         "stdcall" }
+    { "kernel32"    "kernel32.dll"       "stdcall" }
+    { "winsock"     "ws2_32.dll"         "stdcall" }
+    { "mswsock"     "mswsock.dll"        "stdcall" }
+    { "shell32"     "shell32.dll"        "stdcall" }
+    { "libc"        "msvcrt.dll"         "cdecl"   }
+    { "libm"        "msvcrt.dll"         "cdecl"   }
+    { "gl"          "opengl32.dll"       "stdcall" }
+    { "glu"         "glu32.dll"          "stdcall" }
+    { "ole32"       "ole32.dll"          "stdcall" }
+    { "usp10"       "usp10.dll"          "stdcall" }
+    { "psapi"       "psapi.dll"          "stdcall" }
+    { "xinput"      "xinput1_3.dll"      "stdcall" }
+    { "dxgi"        "dxgi.dll"           "stdcall" }
+    { "d2d1"        "d2d1.dll"           "stdcall" }
+    { "d3d9"        "d3d9.dll"           "stdcall" }
+    { "d3d10"       "d3d10.dll"          "stdcall" }
+    { "d3d10_1"     "d3d10_1.dll"        "stdcall" }
+    { "d3d11"       "d3d11.dll"          "stdcall" }
+    { "d3dcompiler" "d3dcompiler_42.dll" "stdcall" } 
+    { "d3dcsx"      "d3dcsx_42.dll"      "stdcall" }
+    { "d3dx9"       "d3dx9_42.dll"       "stdcall" }
+    { "d3dx10"      "d3dx10_42.dll"      "stdcall" }
+    { "d3dx11"      "d3dx11_42.dll"      "stdcall" }
+    { "dwrite"      "dwrite.dll"         "stdcall" }
+    { "x3daudio"    "x3daudio1_6.dll"    "stdcall" }
+    { "xactengine"  "xactengine3_5.dll"  "stdcall" }
+    { "xapofx"      "xapofx1_3.dll"      "stdcall" }
+    { "xaudio2"     "xaudio2_5.dll"      "stdcall" }
 } [ first3 add-library ] each
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
diff --git a/basis/windows/psapi/tags.txt b/basis/windows/psapi/tags.txt
new file mode 100644 (file)
index 0000000..2320bdd
--- /dev/null
@@ -0,0 +1,2 @@
+unportable
+bindings
old mode 100755 (executable)
new mode 100644 (file)
index 1fe3ad065cb881eefd316f1e16f8d0d5443ba889..904c85200e583509959a70edf683461f5815ed8f 100644 (file)
@@ -1,15 +1,14 @@
 ! Copyright (C) 2007 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: alien alien.c-types kernel math windows.errors
-windows.kernel32 namespaces calendar math.bitwise accessors
-classes.struct ;
+windows.kernel32 windows.types namespaces calendar math.bitwise
+accessors classes.struct ;
 IN: windows.time
 
 : >64bit ( lo hi -- n )
     32 shift bitor ; inline
 
-: windows-1601 ( -- timestamp )
-    1601 1 1 0 0 0 instant <timestamp> ;
+: windows-1601 ( -- timestamp ) 1601 <year-gmt> ;
 
 : FILETIME>windows-time ( FILETIME -- n )
     [ dwLowDateTime>> ] [ dwHighDateTime>> ] bi >64bit ;
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 9555927..87540dc
@@ -113,5 +113,5 @@ SYMBOL: cached-script-strings
 : cached-script-string ( font string -- script-string )
     cached-script-strings get-global [ <script-string> ] 2cache ;
 
-[ <cache-assoc> cached-script-strings set-global ]
-"windows.uniscribe" add-init-hook
+[ <cache-assoc> &dispose cached-script-strings set-global ]
+"windows.uniscribe" add-startup-hook
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 7bd86c8..b8d1f09
@@ -442,4 +442,7 @@ CONSTANT: WSAID_CONNECTEX GUID: {25a207b9-ddf3-4660-8ee9-76e58c74063e}
 : init-winsock ( -- )
     HEX: 0202 <wsadata> WSAStartup winsock-return-check ;
 
-[ init-winsock ] "windows.winsock" add-init-hook
+: shutdown-winsock ( -- ) WSACleanup winsock-return-check ;
+
+[ init-winsock ] "windows.winsock" add-startup-hook
+[ shutdown-winsock ] "windows.winsock" add-shutdown-hook
index 04c0b66063f311d8745b3f0b18823d178817c06d..fd8480307a6626d6610a9e1045d8eb21a9047ffe 100644 (file)
@@ -11,8 +11,8 @@ VALUE: html-entities
 
 : get-html ( -- table )
     { "lat1" "special" "symbol" } [
-        "vocab:xml/entities/html/xhtml-"
-        swap ".ent" 3append read-entities-file
+        "vocab:xml/entities/html/xhtml-" ".ent" surround
+        read-entities-file
     ] map first3 assoc-union assoc-union ;
 
 get-html to: html-entities
index 2f1d73f9ca8087840b2cc3640dc985bbc9c2fabf..6149910a558694dceafe79d33d76227e8bdfb81a 100644 (file)
@@ -1,5 +1,4 @@
-USING: xml xml.data xml.traversal tools.test accessors kernel
-io.encodings.8-bit ;
+USING: xml xml.data xml.traversal tools.test accessors kernel ;
 
 [ "\u000131" ] [ "vocab:xml/tests/latin5.xml" file>xml children>string ] unit-test
 [ "\u0000e9" ] [ "vocab:xml/tests/latin1.xml" file>xml children>string ] unit-test
index 55b5147abba72a48b0bbddc5bb3e719e4a0e0de1..2cbc5890b16da57b5239cb54b7918889532f6da1 100644 (file)
@@ -1,6 +1,7 @@
-USING: accessors assocs combinators continuations fry generalizations
-io.pathnames kernel macros sequences stack-checker tools.test xml
-xml.traversal xml.writer arrays xml.data ; 
+USING: accessors assocs combinators combinators.smart
+continuations fry generalizations io.pathnames kernel macros
+sequences stack-checker tools.test xml xml.traversal xml.writer
+arrays xml.data ;
 IN: xml.tests.suite
 
 TUPLE: xml-test id uri sections description type ;
@@ -19,14 +20,11 @@ TUPLE: xml-test id uri sections description type ;
 
 CONSTANT: base "vocab:xml/tests/xmltest/"
 
-MACRO: drop-output ( quot -- newquot )
-    dup infer out>> '[ @ _ ndrop ] ;
-
-MACRO: drop-input ( quot -- newquot )
-    infer in>> '[ _ ndrop ] ;
+MACRO: drop-inputs ( quot -- newquot )
+    inputs '[ _ ndrop ] ;
 
 : fails? ( quot -- ? )
-    [ drop-output f ] [ nip drop-input t ] bi-curry recover ; inline
+    [ drop-outputs f ] [ nip drop-inputs t ] bi-curry recover ; inline
 
 : well-formed? ( uri -- answer )
     [ file>xml ] fails? "not-wf" "valid" ? ;
index b0dbdf22ac83036076b8271eb0dfc3322a9c2fee..ef8420d66c8012199bf001a55c9069ad63749e87 100644 (file)
@@ -86,7 +86,7 @@ HINTS: next* { spot } ;
     spot get '[ _ char>> blank? not ] skip-until ;
 
 : string-matches? ( string circular spot -- ? )
-    char>> over push-circular sequence= ;
+    char>> over circular-push sequence= ;
 
 : take-string ( match -- string )
     dup length <circular-string>
@@ -95,7 +95,7 @@ HINTS: next* { spot } ;
     get-char [ missing-close ] unless next ;
 
 : expect ( string -- )
-    dup spot get '[ _ [ char>> ] keep next* ] replicate
+    dup length spot get '[ _ [ char>> ] keep next* ] "" replicate-as
     2dup = [ 2drop ] [ expected ] if ;
 
 ! Suddenly XML-specific
@@ -147,7 +147,7 @@ HINTS: next* { spot } ;
 :: parse-text ( -- string )
     3 f <array> <circular> :> circ
     depth get zero? :> no-text [| char |
-        char circ push-circular
+        char circ circular-push
         circ assure-no-]]>
         no-text [ char blank? char CHAR: < = or [
             char 1string t pre/post-content
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 97de95a932d8ded288a696cb4524e8c315b45f37..40b8e2191c1173a329ff4d9cd9e011b5f4e2dc1a 100644 (file)
@@ -110,7 +110,7 @@ ERROR: mutually-recursive-rulesets ruleset ;
     dup [ glob-matches? ] [ 2drop f ] if ;
 
 : suitable-mode? ( file-name first-line mode -- ? )
-    tuck first-line-glob>> ?glob-matches
+    [ nip ] 2keep first-line-glob>> ?glob-matches
     [ 2drop t ] [ file-name-glob>> ?glob-matches ] if ;
 
 : find-mode ( file-name first-line -- mode )
old mode 100755 (executable)
new mode 100644 (file)
index d3a4f1e..6b8db76
@@ -86,7 +86,7 @@ M: regexp text-matches?
     [ >string ] dip first-match dup [ to>> ] when ;
 
 : rule-start-matches? ( rule -- match-count/f )
-    dup start>> tuck swap can-match-here? [
+    [ start>> dup ] keep can-match-here? [
         rest-of-line swap text>> text-matches?
     ] [
         drop f
@@ -96,7 +96,7 @@ M: regexp text-matches?
     dup mark-following-rule? [
         dup start>> swap can-match-here? 0 and
     ] [
-        dup end>> tuck swap can-match-here? [
+        [ end>> dup ] keep can-match-here? [
             rest-of-line
             swap text>> context get end>> or
             text-matches?
@@ -170,7 +170,7 @@ M: seq-rule handle-rule-start
     ?end-rule
     mark-token
     add-remaining-token
-    tuck body-token>> next-token,
+    [ body-token>> next-token, ] keep
     delegate>> [ push-context ] when* ;
 
 UNION: abstract-span-rule span-rule eol-span-rule ;
@@ -179,7 +179,7 @@ M: abstract-span-rule handle-rule-start
     ?end-rule
     mark-token
     add-remaining-token
-    tuck rule-match-token* next-token,
+    [ rule-match-token* next-token, ] keep
     ! ... end subst ...
     dup context get (>>in-rule)
     delegate>> push-context ;
@@ -190,7 +190,7 @@ M: span-rule handle-rule-end
 M: mark-following-rule handle-rule-start
     ?end-rule
     mark-token add-remaining-token
-    tuck rule-match-token* next-token,
+    [ rule-match-token* next-token, ] keep
     f context get (>>end)
     context get (>>in-rule) ;
 
index 2d2aab0bba8f19c44fefea6ff783a70135a25d5d..06cb09a4ddf8b645f7f304ffc0f327e5174d2b07 100644 (file)
@@ -3,6 +3,8 @@ temp
 logs
 .git
 .gitignore
-Makefile
+GNUmakefile
+Nmakefile
 unmaintained
 build-support
+images
index 4943d3e5c0e2bdc36145f5bccda5b1c8a697862b..a02a2fad7e797ebd74626bd187eb4aa6d237ddd0 100755 (executable)
@@ -11,7 +11,7 @@ ECHO=echo
 OS=
 ARCH=
 WORD=
-NO_UI=
+NO_UI=${NO_UI-}
 GIT_PROTOCOL=${GIT_PROTOCOL:="git"}
 GIT_URL=${GIT_URL:=$GIT_PROTOCOL"://factorcode.org/git/factor.git"}
 SCRIPT_ARGS="$*"
@@ -25,9 +25,9 @@ test_program_installed() {
 
 exit_script() {
     if [[ $FIND_MAKE_TARGET -eq true ]] ; then
-               echo $MAKE_TARGET;
-       fi
-       exit $1
+        echo $MAKE_TARGET;
+    fi
+    exit $1
 }
 
 ensure_program_installed() {
@@ -63,20 +63,6 @@ check_ret() {
     fi
 }
 
-check_gcc_version() {
-    $ECHO -n "Checking gcc version..."
-    GCC_VERSION=`$CC --version`
-    check_ret gcc
-    if [[ $GCC_VERSION == *3.3.* ]] ; then
-        $ECHO "You have a known buggy version of gcc (3.3)"
-        $ECHO "Install gcc 3.4 or higher and try again."
-        exit_script 3
-    elif [[ $GCC_VERSION == *4.3.* ]] ; then
-       MAKE_OPTS="$MAKE_OPTS SITE_CFLAGS=-fno-forward-propagate"
-    fi
-    $ECHO "ok."
-}
-
 set_downloader() {
     test_program_installed wget curl
     if [[ $? -ne 0 ]] ; then
@@ -124,7 +110,6 @@ check_installed_programs() {
     ensure_program_installed make gmake
     ensure_program_installed md5sum md5
     ensure_program_installed cut
-    check_gcc_version
 }
 
 check_library_exists() {
@@ -147,9 +132,11 @@ check_library_exists() {
 }
 
 check_X11_libraries() {
-    check_library_exists GL
-    check_library_exists X11
-    check_library_exists pango-1.0
+    if [ -z "$NO_UI" ]; then
+        check_library_exists GL
+        check_library_exists X11
+        check_library_exists pango-1.0
+    fi
 }
 
 check_libraries() {
@@ -360,8 +347,8 @@ update_script_name() {
 
 update_script() {
     update_script=`update_script_name`
-    
-    echo "#!/bin/sh" >"$update_script"
+    bash_path=`which bash`
+    echo "#!$bash_path" >"$update_script"
     echo "git pull \"$GIT_URL\" master" >>"$update_script"
     echo "if [[ \$? -eq 0 ]]; then exec \"$0\" $SCRIPT_ARGS; else echo \"git pull failed\"; exit 2; fi" \
         >>"$update_script"
@@ -419,9 +406,9 @@ backup_factor() {
 }
 
 check_makefile_exists() {
-    if [[ ! -e "Makefile" ]] ; then
+    if [[ ! -e "GNUmakefile" ]] ; then
         echo ""
-        echo "***Makefile not found***"
+        echo "***GNUmakefile not found***"
         echo "You are likely in the wrong directory."
         echo "Run this script from your factor directory:"
         echo "     ./build-support/factor.sh"
@@ -446,7 +433,7 @@ make_factor() {
 update_boot_images() {
     echo "Deleting old images..."
     $DELETE checksums.txt* > /dev/null 2>&1
-       # delete boot images with one or two characters after the dot
+    # delete boot images with one or two characters after the dot
     $DELETE $BOOT_IMAGE.{?,??} > /dev/null 2>&1
     $DELETE temp/staging.*.image > /dev/null 2>&1
     if [[ -f $BOOT_IMAGE ]] ; then
index 6787d3714b4f5f34cfebc62506639e92d697e33d..98292b8728b4b6ee2a190716c5c98b81ee83f340 100644 (file)
@@ -1,7 +1,7 @@
 USING: byte-arrays arrays help.syntax help.markup
 alien.syntax compiler definitions math libc eval
 debugger parser io io.backend system alien.accessors
-alien.libraries ;
+alien.libraries alien.c-types quotations ;
 IN: alien
 
 HELP: alien
@@ -44,17 +44,26 @@ HELP: <alien>
 HELP: c-ptr
 { $class-description "Class of objects consisting of aliens, byte arrays and " { $link f } ". These objects can convert to pointer C types, which are all aliases of " { $snippet "void*" } "." } ;
 
+HELP: alien-invoke-error
+{ $error-description "Thrown if the word calling " { $link alien-invoke } " was not compiled with the optimizing compiler. This may be a result of one of several failure conditions:"
+    { $list
+        { "This can happen when experimenting with " { $link alien-invoke } " in this listener. To fix the problem, place the " { $link alien-invoke } " call in a word; word definitions are automatically compiled with the optimizing compiler." }
+        { "The return type or parameter list references an unknown C type." }
+        { "The symbol or library could not be found." }
+        { "One of the four inputs to " { $link alien-invoke } " is not a literal value. To call functions which are not known at compile-time, use " { $link alien-indirect } "." }
+    }
+} ;
+
 HELP: alien-invoke
 { $values { "..." "zero or more objects passed to the C function" } { "return" "a C return type" } { "library" "a logical library name" } { "function" "a C function name" } { "parameters" "a sequence of C parameter types" } }
-{ $description "Calls a C library function with the given name. Input parameters are taken from the data stack, and the return value is pushed on the data stack after the function returns. A return type of " { $snippet "\"void\"" } " indicates that no value is to be expected." }
+{ $description "Calls a C library function with the given name. Input parameters are taken from the data stack, and the return value is pushed on the data stack after the function returns. A return type of " { $link void } " indicates that no value is to be expected." }
 { $notes "C type names are documented in " { $link "c-types-specs" } "." }
 { $errors "Throws an " { $link alien-invoke-error } " if the word calling " { $link alien-invoke } " was not compiled with the optimizing compiler." } ;
 
 HELP: alien-indirect-error
-{ $error-description "Thrown if the word calling " { $link alien-indirect } " was not compiled with the optimizing compiler. This may be a result of one of several failure conditions:"
+{ $error-description "Thrown if the word calling " { $link alien-indirect } " was not compiled with the optimizing compiler. This may be a result of one of two failure conditions:"
     { $list
         { "This can happen when experimenting with " { $link alien-indirect } " in this listener. To fix the problem, place the " { $link alien-indirect } " call in a word; word definitions are automatically compiled with the optimizing compiler." }
-        { "The return type or parameter list references an unknown C type." }
         { "One of the three inputs to " { $link alien-indirect } " is not a literal value." }
     }
 } ;
@@ -62,22 +71,21 @@ HELP: alien-indirect-error
 HELP: alien-indirect
 { $values { "..." "zero or more objects passed to the C function" } { "funcptr" "a C function pointer" } { "return" "a C return type" } { "parameters" "a sequence of C parameter types" } { "abi" "one of " { $snippet "\"cdecl\"" } " or " { $snippet "\"stdcall\"" } } }
 { $description
-    "Invokes a C function pointer passed on the data stack. Input parameters are taken from the data stack following the function pointer, and the return value is pushed on the data stack after the function returns. A return type of " { $snippet "\"void\"" } " indicates that no value is to be expected."
+    "Invokes a C function pointer passed on the data stack. Input parameters are taken from the data stack following the function pointer, and the return value is pushed on the data stack after the function returns. A return type of " { $link void } " indicates that no value is to be expected."
 }
 { $notes "C type names are documented in " { $link "c-types-specs" } "." }
 { $errors "Throws an " { $link alien-indirect-error } " if the word calling " { $link alien-indirect } " is not compiled." } ;
 
 HELP: alien-callback-error
-{ $error-description "Thrown if the word calling " { $link alien-callback } " was not compiled with the optimizing compiler. This may be a result of one of several failure conditions:"
+{ $error-description "Thrown if the word calling " { $link alien-callback } " was not compiled with the optimizing compiler. This may be a result of one of two failure conditions:"
     { $list
         { "This can happen when experimenting with " { $link alien-callback } " in this listener. To fix the problem, place the " { $link alien-callback } " call in a word; word definitions are automatically compiled with the optimizing compiler." }
-        { "The return type or parameter list references an unknown C type." }
         { "One of the four inputs to " { $link alien-callback } " is not a literal value." }
     }
 } ;
 
 HELP: alien-callback
-{ $values { "return" "a C return type" } { "parameters" "a sequence of C parameter types" } { "abi" "one of " { $snippet "\"cdecl\"" } " or " { $snippet "\"stdcall\"" } } { "quot" "a quotation" } { "alien" alien } }
+{ $values { "return" "a C return type" } { "parameters" "a sequence of C parameter types" } { "abi" "one of " { $snippet "\"cdecl\"" } " or " { $snippet "\"stdcall\"" } } { "quot" quotation } { "alien" alien } }
 { $description
     "Defines a callback from C to Factor which accepts the given set of parameters from the C caller, pushes them on the data stack, calls the quotation, and passes a return value back to the C caller. A return type of " { $snippet "void" } " indicates that no value is to be returned."
     $nl
@@ -95,7 +103,23 @@ HELP: alien-callback
 }
 { $errors "Throws an " { $link alien-callback-error } " if the word calling " { $link alien-callback } " is not compiled." } ;
 
-{ alien-invoke alien-indirect alien-callback } related-words
+HELP: alien-assembly-error
+{ $error-description "Thrown if the word calling " { $link alien-assembly } " was not compiled with the optimizing compiler. This may be a result of one of two failure conditions:"
+    { $list
+        { "This can happen when experimenting with " { $link alien-assembly } " in this listener. To fix the problem, place the " { $link alien-assembly } " call in a word; word definitions are automatically compiled with the optimizing compiler." }
+        { "One of the four inputs to " { $link alien-assembly } " is not a literal value." }
+    }
+} ;
+
+HELP: alien-assembly
+{ $values { "..." "zero or more objects passed to the C function" } { "return" "a C return type" } { "parameters" "a sequence of C parameter types" } { "abi" "one of " { $snippet "\"cdecl\"" } " or " { $snippet "\"stdcall\"" } } { "quot" quotation } }
+{ $description
+    "Invokes arbitrary machine code, generated at compile-time by the quotation. Input parameters are taken from the data stack, and the return value is pushed on the data stack after the function returns. A return type of " { $link void } " indicates that no value is to be expected."
+}
+{ $notes "C type names are documented in " { $link "c-types-specs" } "." }
+{ $errors "Throws an " { $link alien-assembly-error } " if the word calling " { $link alien-assembly } " is not compiled." } ;
+
+{ alien-invoke alien-indirect alien-assembly alien-callback } related-words
 
 ARTICLE: "alien-expiry" "Alien expiry"
 "When an image is loaded, any alien objects which persisted from the previous session are marked as having expired. This is because the C pointers they contain are almost certainly no longer valid."
@@ -165,16 +189,6 @@ ARTICLE: "alien-invoke" "Calling C from Factor"
 { $subsections alien-indirect }
 "There are some details concerning the conversion of Factor objects to C values, and vice versa. See " { $link "c-data" } "." ;
 
-HELP: alien-invoke-error
-{ $error-description "Thrown if the word calling " { $link alien-invoke } " was not compiled with the optimizing compiler. This may be a result of one of several failure conditions:"
-    { $list
-        { "This can happen when experimenting with " { $link alien-invoke } " in this listener. To fix the problem, place the " { $link alien-invoke } " call in a word; word definitions are automatically compiled with the optimizing compiler." }
-        { "The return type or parameter list references an unknown C type." }
-        { "The symbol or library could not be found." }
-        { "One of the four inputs to " { $link alien-invoke } " is not a literal value. To call functions which are not known at compile-time, use " { $link alien-indirect } "." }
-    }
-} ;
-
 ARTICLE: "alien-callback" "Calling Factor from C"
 "Callbacks can be defined and passed to C code as function pointers; the C code can then invoke the callback and run Factor code:"
 { $subsections
@@ -191,6 +205,18 @@ ARTICLE: "alien-globals" "Accessing C global variables"
     POSTPONE: &:
 } ;
 
+ARTICLE: "alien-assembly" "Calling arbitrary assembly code"
+"It is possible to write a word whose body consists of arbitrary assembly code. The assembly receives parameters and returns values as per the platform's ABI; marshalling and unmarshalling Factor values is taken care of by the C library interface, as with " { $link alien-invoke } "."
+$nl
+"Assembler opcodes are defined in CPU-specific vocabularies:"
+{ $list
+    { $vocab-link "cpu.arm.assembler" }
+    { $vocab-link "cpu.ppc.assembler" }
+    { $vocab-link "cpu.x86.assembler" }
+}
+"The combinator for generating arbitrary assembly by calling a quotation at compile time:"
+{ $subsection alien-assembly } ;
+
 ARTICLE: "dll.private" "DLL handles"
 "DLL handles are a built-in class of objects which represent loaded native libraries. DLL handles are instances of the " { $link dll } " class, and have a literal syntax used for debugging prinouts; see " { $link "syntax-aliens" } "."
 $nl
@@ -281,6 +307,7 @@ $nl
     "c-data"
     "classes.struct"
     "alien-globals"
+    "alien-assembly"
     "dll.private"
     "embedding"
 } ;
index f008a4bd599ace290acf22c8b771c2e12b656b94..16c33fc1c33ea773b3e2c4194fd81c52299148ec 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2004, 2009 Slava Pestov.
+! Copyright (C) 2004, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors assocs kernel math namespaces sequences system
 kernel.private byte-arrays arrays init ;
@@ -49,7 +49,7 @@ ERROR: alien-callback-error ;
 
 ERROR: alien-indirect-error ;
 
-: alien-indirect ( ... funcptr return parameters abi -- )
+: alien-indirect ( ... funcptr return parameters abi -- ... )
     alien-indirect-error ;
 
 ERROR: alien-invoke-error library symbol ;
@@ -57,13 +57,18 @@ ERROR: alien-invoke-error library symbol ;
 : alien-invoke ( ... return library function parameters -- ... )
     2over alien-invoke-error ;
 
+ERROR: alien-assembly-error code ;
+
+: alien-assembly ( ... return parameters abi quot -- ... )
+    dup alien-assembly-error ;
+
 ! Callbacks are registered in a global hashtable. Note that they
 ! are also pinned in a special callback area, so clearing this
 ! hashtable will not reclaim callbacks. It should only be
 ! cleared on startup.
 SYMBOL: callbacks
 
-[ H{ } clone callbacks set-global ] "alien" add-init-hook
+[ H{ } clone callbacks set-global ] "alien" add-startup-hook
 
 <PRIVATE
 
index c1b5a9e159f25c67ab3536cce186d6345e69a24e..c6516d3839bf4f80fb962df72d3b4b91520e12c7 100644 (file)
@@ -1,6 +1,6 @@
-USING: alien.strings alien.c-types alien.data tools.test kernel libc
-io.encodings.8-bit io.encodings.utf8 io.encodings.utf16
-io.encodings.utf16n io.encodings.ascii alien io.encodings.string ;
+USING: alien.strings alien.c-types alien.data tools.test
+kernel libc io.encodings.utf8 io.encodings.utf16 io.encodings.utf16n
+io.encodings.ascii alien io.encodings.string io.encodings.8-bit.latin1 ;
 IN: alien.strings.tests
 
 [ "\u0000ff" ]
index 83758cd8666ab53a047bc5f9784203feb0068e7f..15e0370ba081daa8f2ed53b25bf5da83e81920fb 100644 (file)
@@ -67,7 +67,6 @@ M: string string>symbol string>symbol* ;
 M: sequence string>symbol [ string>symbol* ] map ;
 
 [
-    8 getenv utf8 alien>string string>cpu \ cpu set-global
-    9 getenv utf8 alien>string string>os \ os set-global
-] "alien.strings" add-init-hook
-
+    8 special-object utf8 alien>string string>cpu \ cpu set-global
+    9 special-object utf8 alien>string string>os \ os set-global
+] "alien.strings" add-startup-hook
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index e441855..7b50d7c
@@ -1,4 +1,4 @@
-! Copyright (C) 2007, 2009 Daniel Ehrenberg, Slava Pestov
+! Copyright (C) 2007, 2010 Daniel Ehrenberg, Slava Pestov
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel sequences arrays math sequences.private vectors
 accessors ;
@@ -225,7 +225,7 @@ M: enum set-at seq>> set-nth ; inline
 M: enum delete-at seq>> remove-nth! drop ; inline
 
 M: enum >alist ( enum -- alist )
-    seq>> [ length ] keep zip ; inline
+    seq>> [ length iota ] keep zip ; inline
 
 M: enum assoc-size seq>> length ; inline
 
index 8b6547ce5c42251e9acc1d25df9f432569a533fc..61bff382019b98e00253424911683a2cd764e9b1 100644 (file)
@@ -30,3 +30,5 @@ H{
     { word 12 }
     { dll 13 }
 } type-numbers set
+
+2 header-bits set
index 5d4144e3548e0c56257a8361ed4e8021a09cf0eb..dde5463c0f7f1b2ae41955a4bcda32bbd50805cb 100644 (file)
@@ -1,11 +1,11 @@
-! Copyright (C) 2004, 2009 Slava Pestov.
+! Copyright (C) 2004, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: alien arrays byte-arrays generic hashtables
-hashtables.private io kernel math math.private math.order
-namespaces make parser sequences strings vectors words
-quotations assocs layouts classes classes.builtin classes.tuple
-classes.tuple.private kernel.private vocabs vocabs.loader
-source-files definitions slots classes.union
+USING: alien alien.strings arrays byte-arrays generic hashtables
+hashtables.private io io.encodings.ascii kernel math
+math.private math.order namespaces make parser sequences strings
+vectors words quotations assocs layouts classes classes.builtin
+classes.tuple classes.tuple.private kernel.private vocabs
+vocabs.loader source-files definitions slots classes.union
 classes.intersection classes.predicate compiler.units
 bootstrap.image.private io.files accessors combinators ;
 IN: bootstrap.primitives
@@ -16,7 +16,7 @@ H{ } clone sub-primitives set
 
 "vocab:bootstrap/syntax.factor" parse-file
 
-"vocab:cpu/" architecture get {
+architecture get {
     { "x86.32" "x86/32" }
     { "winnt-x86.64" "x86/64/winnt" }
     { "unix-x86.64" "x86/64/unix" }
@@ -24,7 +24,7 @@ H{ } clone sub-primitives set
     { "macosx-ppc" "ppc/macosx" }
     { "arm" "arm" }
 } ?at [ "Bad architecture: " prepend throw ] unless
-"/bootstrap.factor" 3append parse-file
+"vocab:cpu/" "/bootstrap.factor" surround parse-file
 
 "vocab:bootstrap/layouts/layouts.factor" parse-file
 
@@ -55,6 +55,8 @@ num-types get f <array> builtins set
 
 bootstrapping? on
 
+[
+
 ! Create some empty vocabs where the below primitives and
 ! classes will go
 {
@@ -307,27 +309,16 @@ tuple
 
 ! Sub-primitive words
 : make-sub-primitive ( word vocab effect -- )
-    [ create dup 1quotation ] dip define-declared ;
+    [
+        create
+        dup t "primitive" set-word-prop
+        dup 1quotation
+    ] dip define-declared ;
 
 {
-    { "(execute)" "kernel.private" (( word -- )) }
-    { "(call)" "kernel.private" (( quot -- )) }
-    { "both-fixnums?" "math.private" (( x y -- ? )) }
-    { "fixnum+fast" "math.private" (( x y -- z )) }
-    { "fixnum-fast" "math.private" (( x y -- z )) }
-    { "fixnum*fast" "math.private" (( x y -- z )) }
-    { "fixnum-bitand" "math.private" (( x y -- z )) }
-    { "fixnum-bitor" "math.private" (( x y -- z )) }
-    { "fixnum-bitxor" "math.private" (( x y -- z )) }
-    { "fixnum-bitnot" "math.private" (( x -- y )) }
-    { "fixnum-mod" "math.private" (( x y -- z )) }
-    { "fixnum-shift-fast" "math.private" (( x y -- z )) }
-    { "fixnum/i-fast" "math.private" (( x y -- z )) }
-    { "fixnum/mod-fast" "math.private" (( x y -- z w )) }
-    { "fixnum<" "math.private" (( x y -- ? )) }
-    { "fixnum<=" "math.private" (( x y -- z )) }
-    { "fixnum>" "math.private" (( x y -- ? )) }
-    { "fixnum>=" "math.private" (( x y -- ? )) }
+    { "mega-cache-lookup" "generic.single.private" (( methods index cache -- )) }
+    { "inline-cache-miss" "generic.single.private" (( generic methods index cache -- )) }
+    { "inline-cache-miss-tail" "generic.single.private" (( generic methods index cache -- )) }
     { "drop" "kernel" (( x -- )) }
     { "2drop" "kernel" (( x y -- )) }
     { "3drop" "kernel" (( x y z -- )) }
@@ -340,188 +331,211 @@ tuple
     { "swapd" "kernel" (( x y z -- y x z )) }
     { "nip" "kernel" (( x y -- y )) }
     { "2nip" "kernel" (( x y z -- z )) }
-    { "tuck" "kernel" (( x y -- y x y )) }
     { "over" "kernel" (( x y -- x y x )) }
     { "pick" "kernel" (( x y z -- x y z x )) }
     { "swap" "kernel" (( x y -- y x )) }
     { "eq?" "kernel" (( obj1 obj2 -- ? )) }
     { "tag" "kernel.private" (( object -- n )) }
+    { "(execute)" "kernel.private" (( word -- )) }
+    { "(call)" "kernel.private" (( quot -- )) }
+    { "unwind-native-frames" "kernel.private" (( -- )) }
+    { "set-callstack" "kernel.private" (( cs -- * )) }
+    { "lazy-jit-compile" "kernel.private" (( -- )) }
+    { "c-to-factor" "kernel.private" (( -- )) }
     { "slot" "slots.private" (( obj m -- value )) }
     { "get-local" "locals.backend" (( n -- obj )) }
     { "load-local" "locals.backend" (( obj -- )) }
     { "drop-locals" "locals.backend" (( n -- )) }
-    { "mega-cache-lookup" "generic.single.private" (( methods index cache -- )) }
+    { "both-fixnums?" "math.private" (( x y -- ? )) }
+    { "fixnum+fast" "math.private" (( x y -- z )) }
+    { "fixnum-fast" "math.private" (( x y -- z )) }
+    { "fixnum*fast" "math.private" (( x y -- z )) }
+    { "fixnum-bitand" "math.private" (( x y -- z )) }
+    { "fixnum-bitor" "math.private" (( x y -- z )) }
+    { "fixnum-bitxor" "math.private" (( x y -- z )) }
+    { "fixnum-bitnot" "math.private" (( x -- y )) }
+    { "fixnum-mod" "math.private" (( x y -- z )) }
+    { "fixnum-shift-fast" "math.private" (( x y -- z )) }
+    { "fixnum/i-fast" "math.private" (( x y -- z )) }
+    { "fixnum/mod-fast" "math.private" (( x y -- z w )) }
+    { "fixnum+" "math.private" (( x y -- z )) }
+    { "fixnum-" "math.private" (( x y -- z )) }
+    { "fixnum*" "math.private" (( x y -- z )) }
+    { "fixnum<" "math.private" (( x y -- ? )) }
+    { "fixnum<=" "math.private" (( x y -- z )) }
+    { "fixnum>" "math.private" (( x y -- ? )) }
+    { "fixnum>=" "math.private" (( x y -- ? )) }
 } [ first3 make-sub-primitive ] each
 
 ! Primitive words
-: make-primitive ( word vocab n effect -- )
+: make-primitive ( word vocab function effect -- )
     [
-        [ create dup reset-word ] dip
-        [ do-primitive ] curry
+        [
+            create
+            dup reset-word
+            dup t "primitive" set-word-prop
+        ] dip
+        ascii string>alien [ do-primitive ] curry
     ] dip define-declared ;
 
 {
-    { "bignum>fixnum" "math.private" (( x -- y )) }
-    { "float>fixnum" "math.private" (( x -- y )) }
-    { "fixnum>bignum" "math.private" (( x -- y )) }
-    { "float>bignum" "math.private" (( x -- y )) }
-    { "fixnum>float" "math.private" (( x -- y )) }
-    { "bignum>float" "math.private" (( x -- y )) }
-    { "(string>float)" "math.parser.private" (( str -- n/f )) }
-    { "(float>string)" "math.parser.private" (( n -- str )) }
-    { "float>bits" "math" (( x -- n )) }
-    { "double>bits" "math" (( x -- n )) }
-    { "bits>float" "math" (( n -- x )) }
-    { "bits>double" "math" (( n -- x )) }
-    { "fixnum+" "math.private" (( x y -- z )) }
-    { "fixnum-" "math.private" (( x y -- z )) }
-    { "fixnum*" "math.private" (( x y -- z )) }
-    { "fixnum/i" "math.private" (( x y -- z )) }
-    { "fixnum/mod" "math.private" (( x y -- z w )) }
-    { "fixnum-shift" "math.private" (( x y -- z )) }
-    { "bignum=" "math.private" (( x y -- ? )) }
-    { "bignum+" "math.private" (( x y -- z )) }
-    { "bignum-" "math.private" (( x y -- z )) }
-    { "bignum*" "math.private" (( x y -- z )) }
-    { "bignum/i" "math.private" (( x y -- z )) }
-    { "bignum-mod" "math.private" (( x y -- z )) }
-    { "bignum/mod" "math.private" (( x y -- z w )) }
-    { "bignum-bitand" "math.private" (( x y -- z )) }
-    { "bignum-bitor" "math.private" (( x y -- z )) }
-    { "bignum-bitxor" "math.private" (( x y -- z )) }
-    { "bignum-bitnot" "math.private" (( x -- y )) }
-    { "bignum-shift" "math.private" (( x y -- z )) }
-    { "bignum<" "math.private" (( x y -- ? )) }
-    { "bignum<=" "math.private" (( x y -- ? )) }
-    { "bignum>" "math.private" (( x y -- ? )) }
-    { "bignum>=" "math.private" (( x y -- ? )) }
-    { "bignum-bit?" "math.private" (( n x -- ? )) }
-    { "bignum-log2" "math.private" (( x -- n )) }
-    { "byte-array>bignum" "math" (( x -- y ))  }
-    { "float=" "math.private" (( x y -- ? )) }
-    { "float+" "math.private" (( x y -- z )) }
-    { "float-" "math.private" (( x y -- z )) }
-    { "float*" "math.private" (( x y -- z )) }
-    { "float/f" "math.private" (( x y -- z )) }
-    { "float-mod" "math.private" (( x y -- z )) }
-    { "float<" "math.private" (( x y -- ? )) }
-    { "float<=" "math.private" (( x y -- ? )) }
-    { "float>" "math.private" (( x y -- ? )) }
-    { "float>=" "math.private" (( x y -- ? )) }
-    { "float-u<" "math.private" (( x y -- ? )) }
-    { "float-u<=" "math.private" (( x y -- ? )) }
-    { "float-u>" "math.private" (( x y -- ? )) }
-    { "float-u>=" "math.private" (( x y -- ? )) }
-    { "(word)" "words.private" (( name vocab -- word )) }
-    { "word-xt" "words" (( word -- start end )) }
-    { "getenv" "kernel.private" (( n -- obj )) }
-    { "setenv" "kernel.private" (( obj n -- )) }
-    { "(exists?)" "io.files.private" (( path -- ? )) }
-    { "minor-gc" "memory" (( -- )) }
-    { "gc" "memory" (( -- )) }
-    { "compact-gc" "memory" (( -- )) }
-    { "(save-image)" "memory.private" (( path -- )) }
-    { "(save-image-and-exit)" "memory.private" (( path -- )) }
-    { "datastack" "kernel" (( -- ds )) }
-    { "retainstack" "kernel" (( -- rs )) }
-    { "callstack" "kernel" (( -- cs )) }
-    { "set-datastack" "kernel" (( ds -- )) }
-    { "set-retainstack" "kernel" (( rs -- )) }
-    { "set-callstack" "kernel" (( cs -- )) }
-    { "exit" "system" (( n -- )) }
-    { "data-room" "memory" (( -- data-room )) }
-    { "code-room" "memory" (( -- code-room )) }
-    { "micros" "system" (( -- us )) }
-    { "modify-code-heap" "compiler.units" (( alist -- )) }
-    { "(dlopen)" "alien.libraries" (( path -- dll )) }
-    { "(dlsym)" "alien.libraries" (( name dll -- alien )) }
-    { "dlclose" "alien.libraries" (( dll -- )) }
-    { "<byte-array>" "byte-arrays" (( n -- byte-array )) }
-    { "(byte-array)" "byte-arrays" (( n -- byte-array )) }
-    { "<displaced-alien>" "alien" (( displacement c-ptr -- alien )) }
-    { "alien-signed-cell" "alien.accessors" (( c-ptr n -- value )) }
-    { "set-alien-signed-cell" "alien.accessors" (( value c-ptr n -- )) }
-    { "alien-unsigned-cell" "alien.accessors" (( c-ptr n -- value )) }
-    { "set-alien-unsigned-cell" "alien.accessors" (( value c-ptr n -- )) }
-    { "alien-signed-8" "alien.accessors" (( c-ptr n -- value )) }
-    { "set-alien-signed-8" "alien.accessors" (( value c-ptr n -- )) }
-    { "alien-unsigned-8" "alien.accessors" (( c-ptr n -- value )) }
-    { "set-alien-unsigned-8" "alien.accessors" (( value c-ptr n -- )) }
-    { "alien-signed-4" "alien.accessors" (( c-ptr n -- value )) }
-    { "set-alien-signed-4" "alien.accessors" (( value c-ptr n -- )) }
-    { "alien-unsigned-4" "alien.accessors" (( c-ptr n -- value )) }
-    { "set-alien-unsigned-4" "alien.accessors" (( value c-ptr n -- )) }
-    { "alien-signed-2" "alien.accessors" (( c-ptr n -- value )) }
-    { "set-alien-signed-2" "alien.accessors" (( value c-ptr n -- )) }
-    { "alien-unsigned-2" "alien.accessors" (( c-ptr n -- value )) }
-    { "set-alien-unsigned-2" "alien.accessors" (( value c-ptr n -- )) }
-    { "alien-signed-1" "alien.accessors" (( c-ptr n -- value )) }
-    { "set-alien-signed-1" "alien.accessors" (( value c-ptr n -- )) }
-    { "alien-unsigned-1" "alien.accessors" (( c-ptr n -- value )) }
-    { "set-alien-unsigned-1" "alien.accessors" (( value c-ptr n -- )) }
-    { "alien-float" "alien.accessors" (( c-ptr n -- value )) }
-    { "set-alien-float" "alien.accessors" (( value c-ptr n -- )) }
-    { "alien-double" "alien.accessors" (( c-ptr n -- value )) }
-    { "set-alien-double" "alien.accessors" (( value c-ptr n -- )) }
-    { "alien-cell" "alien.accessors" (( c-ptr n -- value )) }
-    { "set-alien-cell" "alien.accessors" (( value c-ptr n -- )) }
-    { "alien-address" "alien" (( c-ptr -- addr )) }
-    { "set-slot" "slots.private" (( value obj n -- )) }
-    { "string-nth" "strings.private" (( n string -- ch )) }
-    { "set-string-nth-fast" "strings.private" (( ch n string -- )) }
-    { "set-string-nth-slow" "strings.private" (( ch n string -- )) }
-    { "resize-array" "arrays" (( n array -- newarray )) }
-    { "resize-string" "strings" (( n str -- newstr )) }
-    { "<array>" "arrays" (( n elt -- array )) }
-    { "begin-scan" "memory" (( -- )) }
-    { "next-object" "memory" (( -- obj )) }
-    { "end-scan" "memory" (( -- )) }
-    { "size" "memory" (( obj -- n )) }
-    { "die" "kernel" (( -- )) }
-    { "(fopen)" "io.streams.c" (( path mode -- alien )) }
-    { "fgetc" "io.streams.c" (( alien -- ch/f )) }
-    { "fread" "io.streams.c" (( n alien -- str/f )) }
-    { "fputc" "io.streams.c" (( ch alien -- )) }
-    { "fwrite" "io.streams.c" (( string alien -- )) }
-    { "fflush" "io.streams.c" (( alien -- )) }
-    { "ftell" "io.streams.c" (( alien -- n )) }
-    { "fseek" "io.streams.c" (( alien offset whence -- )) }
-    { "fclose" "io.streams.c" (( alien -- )) }
-    { "<wrapper>" "kernel" (( obj -- wrapper )) }
-    { "(clone)" "kernel" (( obj -- newobj )) }
-    { "<string>" "strings" (( n ch -- string )) }
-    { "array>quotation" "quotations.private" (( array -- quot )) }
-    { "quotation-xt" "quotations" (( quot -- xt )) }
-    { "<tuple>" "classes.tuple.private" (( layout -- tuple )) }
-    { "profiling" "tools.profiler.private" (( ? -- )) }
-    { "become" "kernel.private" (( old new -- )) }
-    { "(sleep)" "threads.private" (( us -- )) }
-    { "<tuple-boa>" "classes.tuple.private" (( ... layout -- tuple )) }
-    { "callstack>array" "kernel" (( callstack -- array )) }
-    { "innermost-frame-executing" "kernel.private" (( callstack -- obj )) }
-    { "innermost-frame-scan" "kernel.private" (( callstack -- n )) }
-    { "set-innermost-frame-quot" "kernel.private" (( n callstack -- )) }
-    { "call-clear" "kernel" (( quot -- )) }
-    { "resize-byte-array" "byte-arrays" (( n byte-array -- newbyte-array )) }
-    { "dll-valid?" "alien.libraries" (( dll -- ? )) }
-    { "unimplemented" "kernel.private" (( -- * )) }
-    { "jit-compile" "quotations" (( quot -- )) }
-    { "load-locals" "locals.backend" (( ... n -- )) }
-    { "check-datastack" "kernel.private" (( array in# out# -- ? )) }
-    { "inline-cache-miss" "generic.single.private" (( generic methods index cache -- )) }
-    { "inline-cache-miss-tail" "generic.single.private" (( generic methods index cache -- )) }
-    { "mega-cache-miss" "generic.single.private" (( methods index cache -- method )) }
-    { "lookup-method" "generic.single.private" (( object methods -- method )) }
-    { "reset-dispatch-stats" "tools.dispatch.private" (( -- )) }
-    { "dispatch-stats" "tools.dispatch.private" (( -- stats )) }
-    { "optimized?" "words" (( word -- ? )) }
-    { "quot-compiled?" "quotations" (( quot -- ? )) }
-    { "vm-ptr" "vm" (( -- ptr )) }
-    { "strip-stack-traces" "kernel.private" (( -- )) }
-    { "<callback>" "alien" (( word -- alien )) }
-    { "enable-gc-events" "memory" (( -- )) }
-    { "disable-gc-events" "memory" (( -- events )) }
-} [ [ first3 ] dip swap make-primitive ] each-index
+    { "<callback>" "alien" "primitive_callback" (( return-rewind word -- alien )) }
+    { "<displaced-alien>" "alien" "primitive_displaced_alien" (( displacement c-ptr -- alien )) }
+    { "alien-address" "alien" "primitive_alien_address" (( c-ptr -- addr )) }
+    { "alien-cell" "alien.accessors" "primitive_alien_cell" (( c-ptr n -- value )) }
+    { "alien-double" "alien.accessors" "primitive_alien_double" (( c-ptr n -- value )) }
+    { "alien-float" "alien.accessors" "primitive_alien_float" (( c-ptr n -- value )) }
+    { "alien-signed-1" "alien.accessors" "primitive_alien_signed_1" (( c-ptr n -- value )) }
+    { "alien-signed-2" "alien.accessors" "primitive_alien_signed_2" (( c-ptr n -- value )) }
+    { "alien-signed-4" "alien.accessors" "primitive_alien_signed_4" (( c-ptr n -- value )) }
+    { "alien-signed-8" "alien.accessors" "primitive_alien_signed_8" (( c-ptr n -- value )) }
+    { "alien-signed-cell" "alien.accessors" "primitive_alien_signed_cell" (( c-ptr n -- value )) }
+    { "alien-unsigned-1" "alien.accessors" "primitive_alien_unsigned_1" (( c-ptr n -- value )) }
+    { "alien-unsigned-2" "alien.accessors" "primitive_alien_unsigned_2" (( c-ptr n -- value )) }
+    { "alien-unsigned-4" "alien.accessors" "primitive_alien_unsigned_4" (( c-ptr n -- value )) }
+    { "alien-unsigned-8" "alien.accessors" "primitive_alien_unsigned_8" (( c-ptr n -- value )) }
+    { "alien-unsigned-cell" "alien.accessors" "primitive_alien_unsigned_cell" (( c-ptr n -- value )) }
+    { "set-alien-cell" "alien.accessors" "primitive_set_alien_cell" (( value c-ptr n -- )) }
+    { "set-alien-double" "alien.accessors" "primitive_set_alien_double" (( value c-ptr n -- )) }
+    { "set-alien-float" "alien.accessors" "primitive_set_alien_float" (( value c-ptr n -- )) }
+    { "set-alien-signed-1" "alien.accessors" "primitive_set_alien_signed_1" (( value c-ptr n -- )) }
+    { "set-alien-signed-2" "alien.accessors" "primitive_set_alien_signed_2" (( value c-ptr n -- )) }
+    { "set-alien-signed-4" "alien.accessors" "primitive_set_alien_signed_4" (( value c-ptr n -- )) }
+    { "set-alien-signed-8" "alien.accessors" "primitive_set_alien_signed_8" (( value c-ptr n -- )) }
+    { "set-alien-signed-cell" "alien.accessors" "primitive_set_alien_signed_cell" (( value c-ptr n -- )) }
+    { "set-alien-unsigned-1" "alien.accessors" "primitive_set_alien_unsigned_1" (( value c-ptr n -- )) }
+    { "set-alien-unsigned-2" "alien.accessors" "primitive_set_alien_unsigned_2" (( value c-ptr n -- )) }
+    { "set-alien-unsigned-4" "alien.accessors" "primitive_set_alien_unsigned_4" (( value c-ptr n -- )) }
+    { "set-alien-unsigned-8" "alien.accessors" "primitive_set_alien_unsigned_8" (( value c-ptr n -- )) }
+    { "set-alien-unsigned-cell" "alien.accessors" "primitive_set_alien_unsigned_cell" (( value c-ptr n -- )) }
+    { "(dlopen)" "alien.libraries" "primitive_dlopen" (( path -- dll )) }
+    { "(dlsym)" "alien.libraries" "primitive_dlsym" (( name dll -- alien )) }
+    { "dlclose" "alien.libraries" "primitive_dlclose" (( dll -- )) }
+    { "dll-valid?" "alien.libraries" "primitive_dll_validp" (( dll -- ? )) }
+    { "<array>" "arrays" "primitive_array" (( n elt -- array )) }
+    { "resize-array" "arrays" "primitive_resize_array" (( n array -- newarray )) }
+    { "(byte-array)" "byte-arrays" "primitive_uninitialized_byte_array" (( n -- byte-array )) }
+    { "<byte-array>" "byte-arrays" "primitive_byte_array" (( n -- byte-array )) }
+    { "resize-byte-array" "byte-arrays" "primitive_resize_byte_array" (( n byte-array -- newbyte-array )) }
+    { "<tuple-boa>" "classes.tuple.private" "primitive_tuple_boa" (( ... layout -- tuple )) }
+    { "<tuple>" "classes.tuple.private" "primitive_tuple" (( layout -- tuple )) }
+    { "modify-code-heap" "compiler.units" "primitive_modify_code_heap" (( alist -- )) }
+    { "lookup-method" "generic.single.private" "primitive_lookup_method" (( object methods -- method )) }
+    { "mega-cache-miss" "generic.single.private" "primitive_mega_cache_miss" (( methods index cache -- method )) }
+    { "(exists?)" "io.files.private" "primitive_existsp" (( path -- ? )) }
+    { "(fopen)" "io.streams.c" "primitive_fopen" (( path mode -- alien )) }
+    { "fclose" "io.streams.c" "primitive_fclose" (( alien -- )) }
+    { "fflush" "io.streams.c" "primitive_fflush" (( alien -- )) }
+    { "fgetc" "io.streams.c" "primitive_fgetc" (( alien -- ch/f )) }
+    { "fputc" "io.streams.c" "primitive_fputc" (( ch alien -- )) }
+    { "fread" "io.streams.c" "primitive_fread" (( n alien -- str/f )) }
+    { "fseek" "io.streams.c" "primitive_fseek" (( alien offset whence -- )) }
+    { "ftell" "io.streams.c" "primitive_ftell" (( alien -- n )) }
+    { "fwrite" "io.streams.c" "primitive_fwrite" (( string alien -- )) }
+    { "(clone)" "kernel" "primitive_clone" (( obj -- newobj )) }
+    { "<wrapper>" "kernel" "primitive_wrapper" (( obj -- wrapper )) }
+    { "callstack" "kernel" "primitive_callstack" (( -- cs )) }
+    { "callstack>array" "kernel" "primitive_callstack_to_array" (( callstack -- array )) }
+    { "datastack" "kernel" "primitive_datastack" (( -- ds )) }
+    { "die" "kernel" "primitive_die" (( -- )) }
+    { "retainstack" "kernel" "primitive_retainstack" (( -- rs )) }
+    { "(identity-hashcode)" "kernel.private" "primitive_identity_hashcode" (( obj -- code )) }
+    { "become" "kernel.private" "primitive_become" (( old new -- )) }
+    { "call-clear" "kernel.private" "primitive_call_clear" (( quot -- * )) }
+    { "check-datastack" "kernel.private" "primitive_check_datastack" (( array in# out# -- ? )) }
+    { "compute-identity-hashcode" "kernel.private" "primitive_compute_identity_hashcode" (( obj -- )) }
+    { "innermost-frame-executing" "kernel.private" "primitive_innermost_stack_frame_executing" (( callstack -- obj )) }
+    { "innermost-frame-scan" "kernel.private" "primitive_innermost_stack_frame_scan" (( callstack -- n )) }
+    { "set-datastack" "kernel.private" "primitive_set_datastack" (( ds -- )) }
+    { "set-innermost-frame-quot" "kernel.private" "primitive_set_innermost_stack_frame_quot" (( n callstack -- )) }
+    { "set-retainstack" "kernel.private" "primitive_set_retainstack" (( rs -- )) }
+    { "set-special-object" "kernel.private" "primitive_set_special_object" (( obj n -- )) }
+    { "special-object" "kernel.private" "primitive_special_object" (( n -- obj )) }
+    { "strip-stack-traces" "kernel.private" "primitive_strip_stack_traces" (( -- )) }
+    { "unimplemented" "kernel.private" "primitive_unimplemented" (( -- * )) }
+    { "load-locals" "locals.backend" "primitive_load_locals" (( ... n -- )) }
+    { "bits>double" "math" "primitive_bits_double" (( n -- x )) }
+    { "bits>float" "math" "primitive_bits_float" (( n -- x )) }
+    { "byte-array>bignum" "math" "primitive_byte_array_to_bignum" (( x -- y )) }
+    { "double>bits" "math" "primitive_double_bits" (( x -- n )) }
+    { "float>bits" "math" "primitive_float_bits" (( x -- n )) }
+    { "(float>string)" "math.parser.private" "primitive_float_to_str" (( n -- str )) }
+    { "(string>float)" "math.parser.private" "primitive_str_to_float" (( str -- n/f )) }
+    { "bignum*" "math.private" "primitive_bignum_multiply" (( x y -- z )) }
+    { "bignum+" "math.private" "primitive_bignum_add" (( x y -- z )) }
+    { "bignum-" "math.private" "primitive_bignum_subtract" (( x y -- z )) }
+    { "bignum-bit?" "math.private" "primitive_bignum_bitp" (( n x -- ? )) }
+    { "bignum-bitand" "math.private" "primitive_bignum_and" (( x y -- z )) }
+    { "bignum-bitnot" "math.private" "primitive_bignum_not" (( x -- y )) }
+    { "bignum-bitor" "math.private" "primitive_bignum_or" (( x y -- z )) }
+    { "bignum-bitxor" "math.private" "primitive_bignum_xor" (( x y -- z )) }
+    { "bignum-log2" "math.private" "primitive_bignum_log2" (( x -- n )) }
+    { "bignum-mod" "math.private" "primitive_bignum_mod" (( x y -- z )) }
+    { "bignum-shift" "math.private" "primitive_bignum_shift" (( x y -- z )) }
+    { "bignum/i" "math.private" "primitive_bignum_divint" (( x y -- z )) }
+    { "bignum/mod" "math.private" "primitive_bignum_divmod" (( x y -- z w )) }
+    { "bignum<" "math.private" "primitive_bignum_less" (( x y -- ? )) }
+    { "bignum<=" "math.private" "primitive_bignum_lesseq" (( x y -- ? )) }
+    { "bignum=" "math.private" "primitive_bignum_eq" (( x y -- ? )) }
+    { "bignum>" "math.private" "primitive_bignum_greater" (( x y -- ? )) }
+    { "bignum>=" "math.private" "primitive_bignum_greatereq" (( x y -- ? )) }
+    { "bignum>fixnum" "math.private" "primitive_bignum_to_fixnum" (( x -- y )) }
+    { "bignum>float" "math.private" "primitive_bignum_to_float" (( x -- y )) }
+    { "fixnum-shift" "math.private" "primitive_fixnum_shift" (( x y -- z )) }
+    { "fixnum/i" "math.private" "primitive_fixnum_divint" (( x y -- z )) }
+    { "fixnum/mod" "math.private" "primitive_fixnum_divmod" (( x y -- z w )) }
+    { "fixnum>bignum" "math.private" "primitive_fixnum_to_bignum" (( x -- y )) }
+    { "fixnum>float" "math.private" "primitive_fixnum_to_float" (( x -- y )) }
+    { "float*" "math.private" "primitive_float_multiply" (( x y -- z )) }
+    { "float+" "math.private" "primitive_float_add" (( x y -- z )) }
+    { "float-" "math.private" "primitive_float_subtract" (( x y -- z )) }
+    { "float-mod" "math.private" "primitive_float_mod" (( x y -- z )) }
+    { "float-u<" "math.private" "primitive_float_less" (( x y -- ? )) }
+    { "float-u<=" "math.private" "primitive_float_lesseq" (( x y -- ? )) }
+    { "float-u>" "math.private" "primitive_float_greater" (( x y -- ? )) }
+    { "float-u>=" "math.private" "primitive_float_greatereq" (( x y -- ? )) }
+    { "float/f" "math.private" "primitive_float_divfloat" (( x y -- z )) }
+    { "float<" "math.private" "primitive_float_less" (( x y -- ? )) }
+    { "float<=" "math.private" "primitive_float_lesseq" (( x y -- ? )) }
+    { "float=" "math.private" "primitive_float_eq" (( x y -- ? )) }
+    { "float>" "math.private" "primitive_float_greater" (( x y -- ? )) }
+    { "float>=" "math.private" "primitive_float_greatereq" (( x y -- ? )) }
+    { "float>bignum" "math.private" "primitive_float_to_bignum" (( x -- y )) }
+    { "float>fixnum" "math.private" "primitive_float_to_fixnum" (( x -- y )) }
+    { "all-instances" "memory" "primitive_all_instances" (( -- array )) }
+    { "code-room" "memory" "primitive_code_room" (( -- code-room )) }
+    { "compact-gc" "memory" "primitive_compact_gc" (( -- )) }
+    { "data-room" "memory" "primitive_data_room" (( -- data-room )) }
+    { "disable-gc-events" "memory" "primitive_disable_gc_events" (( -- events )) }
+    { "enable-gc-events" "memory" "primitive_enable_gc_events" (( -- )) }
+    { "gc" "memory" "primitive_full_gc" (( -- )) }
+    { "minor-gc" "memory" "primitive_minor_gc" (( -- )) }
+    { "size" "memory" "primitive_size" (( obj -- n )) }
+    { "(save-image)" "memory.private" "primitive_save_image" (( path -- )) }
+    { "(save-image-and-exit)" "memory.private" "primitive_save_image_and_exit" (( path -- )) }
+    { "jit-compile" "quotations" "primitive_jit_compile" (( quot -- )) }
+    { "quot-compiled?" "quotations" "primitive_quot_compiled_p" (( quot -- ? )) }
+    { "quotation-code" "quotations" "primitive_quotation_code" (( quot -- start end )) }
+    { "array>quotation" "quotations.private" "primitive_array_to_quotation" (( array -- quot )) }
+    { "set-slot" "slots.private" "primitive_set_slot" (( value obj n -- )) }
+    { "<string>" "strings" "primitive_string" (( n ch -- string )) }
+    { "resize-string" "strings" "primitive_resize_string" (( n str -- newstr )) }
+    { "set-string-nth-fast" "strings.private" "primitive_set_string_nth_fast" (( ch n string -- )) }
+    { "set-string-nth-slow" "strings.private" "primitive_set_string_nth_slow" (( ch n string -- )) }
+    { "string-nth" "strings.private" "primitive_string_nth" (( n string -- ch )) }
+    { "(exit)" "system" "primitive_exit" (( n -- )) }
+    { "nano-count" "system" "primitive_nano_count" (( -- ns )) }
+    { "system-micros" "system" "primitive_system_micros" (( -- us )) }
+    { "(sleep)" "threads.private" "primitive_sleep" (( nanos -- )) }
+    { "dispatch-stats" "tools.dispatch.private" "primitive_dispatch_stats" (( -- stats )) }
+    { "reset-dispatch-stats" "tools.dispatch.private" "primitive_reset_dispatch_stats" (( -- )) }
+    { "profiling" "tools.profiler.private" "primitive_profiling" (( ? -- )) }
+    { "optimized?" "words" "primitive_optimized_p" (( word -- ? )) }
+    { "word-code" "words" "primitive_word_code" (( word -- start end )) }
+    { "(word)" "words.private" "primitive_word" (( name vocab -- word )) }
+} [ first4 make-primitive ] each
 
 ! Bump build number
 "build" "kernel" create build 1 + [ ] curry (( -- n )) define-declared
+
+] with-compilation-unit
index 9c84904ff736db68c7da487bd773d1e0aa5b1a26..78658206de42af07531195fa573d21ab40a63634 100644 (file)
@@ -3,7 +3,7 @@
 USING: arrays assocs continuations debugger generic hashtables
 init io io.files kernel kernel.private make math memory
 namespaces parser prettyprint sequences splitting system
-vectors vocabs vocabs.loader words ;
+vectors vocabs vocabs.loader words destructors ;
 QUALIFIED: bootstrap.image.private
 IN: bootstrap.stage1
 
@@ -14,28 +14,23 @@ IN: bootstrap.stage1
 load-help? off
 { "resource:core" } vocab-roots set
 
-! Create a boot quotation for the target
+! Create a boot quotation for the target by collecting all top-level
+! forms into a quotation, surrounded by some boilerplate.
 [
     [
-        ! Rehash hashtables, since bootstrap.image creates them
-        ! using the host image's hashing algorithms. We don't
-        ! use each-object here since the catch stack isn't yet
-        ! set up.
-        gc
-        begin-scan
-        [ hashtable? ] pusher [ (each-object) ] dip
-        end-scan
-        [ rehash ] each
+        ! Rehash hashtables first, since bootstrap.image creates
+        ! them using the host image's hashing algorithms.
+        [ hashtable? ] instances [ rehash ] each
         boot
     ] %
 
     "math.integers" require
     "math.floats" require
     "memory" require
-    
+
     "io.streams.c" require
     "vocabs.loader" require
-    
+
     "syntax" require
     "bootstrap.layouts" require
 
@@ -47,8 +42,8 @@ load-help? off
             "Cannot find " write write "." print
             "Please move " write image write " to the same directory as the Factor sources," print
             "and try again." print
-            1 exit
+            1 (exit)
         ] if
     ] %
 ] [ ] make
-bootstrap.image.private:bootstrap-boot-quot set
+bootstrap.image.private:bootstrap-startup-quot set
index 57be2fb90f25b059dc64babaad361fbaddf52a02..bb159f04df985a28c2826e6623cdf5ac2f5ac7f2 100644 (file)
@@ -1,90 +1,93 @@
 ! Copyright (C) 2007, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: words words.symbol sequences vocabs kernel ;
+USING: words words.symbol sequences vocabs kernel
+compiler.units ;
 IN: bootstrap.syntax
 
-"syntax" create-vocab drop
+[
+    "syntax" create-vocab drop
 
-{
-    "!"
-    "\""
-    "#!"
-    "("
-    "(("
-    ":"
-    ";"
-    "<PRIVATE"
-    "BIN:"
-    "B{"
-    "BV{"
-    "C:"
-    "CHAR:"
-    "DEFER:"
-    "ERROR:"
-    "FORGET:"
-    "GENERIC#"
-    "GENERIC:"
-    "HEX:"
-    "HOOK:"
-    "H{"
-    "IN:"
-    "INSTANCE:"
-    "M:"
-    "MAIN:"
-    "MATH:"
-    "MIXIN:"
-    "NAN:"
-    "OCT:"
-    "P\""
-    "POSTPONE:"
-    "PREDICATE:"
-    "PRIMITIVE:"
-    "PRIVATE>"
-    "SBUF\""
-    "SINGLETON:"
-    "SINGLETONS:"
-    "SYMBOL:"
-    "SYMBOLS:"
-    "CONSTANT:"
-    "TUPLE:"
-    "SLOT:"
-    "T{"
-    "UNION:"
-    "INTERSECTION:"
-    "USE:"
-    "UNUSE:"
-    "USING:"
-    "QUALIFIED:"
-    "QUALIFIED-WITH:"
-    "FROM:"
-    "EXCLUDE:"
-    "RENAME:"
-    "ALIAS:"
-    "SYNTAX:"
-    "V{"
-    "W{"
-    "["
-    "\\"
-    "M\\"
-    "]"
-    "delimiter"
-    "deprecated"
-    "f"
-    "flushable"
-    "foldable"
-    "inline"
-    "recursive"
-    "t"
-    "{"
-    "}"
-    "CS{"
-    "<<"
-    ">>"
-    "call-next-method"
-    "initial:"
-    "read-only"
-    "call("
-    "execute("
-} [ "syntax" create drop ] each
+    {
+        "!"
+        "\""
+        "#!"
+        "("
+        "(("
+        ":"
+        ";"
+        "<PRIVATE"
+        "BIN:"
+        "B{"
+        "BV{"
+        "C:"
+        "CHAR:"
+        "DEFER:"
+        "ERROR:"
+        "FORGET:"
+        "GENERIC#"
+        "GENERIC:"
+        "HEX:"
+        "HOOK:"
+        "H{"
+        "IN:"
+        "INSTANCE:"
+        "M:"
+        "MAIN:"
+        "MATH:"
+        "MIXIN:"
+        "NAN:"
+        "OCT:"
+        "P\""
+        "POSTPONE:"
+        "PREDICATE:"
+        "PRIMITIVE:"
+        "PRIVATE>"
+        "SBUF\""
+        "SINGLETON:"
+        "SINGLETONS:"
+        "SYMBOL:"
+        "SYMBOLS:"
+        "CONSTANT:"
+        "TUPLE:"
+        "SLOT:"
+        "T{"
+        "UNION:"
+        "INTERSECTION:"
+        "USE:"
+        "UNUSE:"
+        "USING:"
+        "QUALIFIED:"
+        "QUALIFIED-WITH:"
+        "FROM:"
+        "EXCLUDE:"
+        "RENAME:"
+        "ALIAS:"
+        "SYNTAX:"
+        "V{"
+        "W{"
+        "["
+        "\\"
+        "M\\"
+        "]"
+        "delimiter"
+        "deprecated"
+        "f"
+        "flushable"
+        "foldable"
+        "inline"
+        "recursive"
+        "t"
+        "{"
+        "}"
+        "CS{"
+        "<<"
+        ">>"
+        "call-next-method"
+        "initial:"
+        "read-only"
+        "call("
+        "execute("
+    } [ "syntax" create drop ] each
 
-"t" "syntax" lookup define-symbol
+    "t" "syntax" lookup define-symbol
+] with-compilation-unit
index fdf4ab6aca99c6c4600a20d76ae80abbf36d5b14..286b7c419e101749edc59c51ca2b838c9157aa36 100644 (file)
@@ -1,11 +1,11 @@
 USING: tools.test byte-vectors vectors sequences kernel\r
-prettyprint ;\r
+prettyprint math ;\r
 IN: byte-vectors.tests\r
 \r
 [ 0 ] [ 123 <byte-vector> length ] unit-test\r
 \r
 : do-it ( seq -- seq )\r
-    123 [ over push ] each ;\r
+    123 [ over push ] each-integer ;\r
 \r
 [ t ] [\r
     3 <byte-vector> do-it\r
index 209de83763801b4877271874dc0029c050131697..e937cf591086c008d48baffa4d26b0960802bc0f 100644 (file)
@@ -33,9 +33,9 @@ INSTANCE: crc32 checksum
 M: crc32 checksum-bytes
     init-crc32
     [ (crc32) ] each
-    finish-crc32 ;
+    finish-crc32 ; inline
 
 M: crc32 checksum-lines
     init-crc32
     [ [ (crc32) ] each CHAR: \n (crc32) ] each
-    finish-crc32 ;
+    finish-crc32 ; inline
index 65e6f856786e7ced5e99e775fcf6c3a21b0403ad..7b931c80e8260326e2eb1bfe6f76d579671d16f7 100644 (file)
@@ -11,12 +11,7 @@ ARTICLE: "class-operations" "Class operations"
     class-and\r
     class-or\r
     classes-intersect?\r
-}\r
-"Low-level implementation detail:"\r
-{ $subsections\r
     flatten-class\r
-    flatten-builtin-class\r
-    class-types\r
 } ;\r
 \r
 ARTICLE: "class-linearization" "Class linearization"\r
@@ -45,18 +40,10 @@ $nl
 "Metaclass order:"\r
 { $subsections rank-class } ;\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
index 72c2dd575cd08684300149a6269f70cde8c8cb6b..11cb11d334c4f692e1d9789ee96f4d58969c54dc 100644 (file)
@@ -7,36 +7,42 @@ stack-checker effects kernel.private sbufs math.order
 classes.tuple accessors generic.private ;\r
 IN: classes.algebra.tests\r
 \r
-: class-and* ( cls1 cls2 cls3 -- ? ) [ class-and ] dip class= ;\r
+TUPLE: first-one ;\r
+TUPLE: second-one ;\r
+UNION: both first-one union-class ;\r
 \r
-: class-or* ( cls1 cls2 cls3 -- ? ) [ class-or ] dip class= ;\r
+PREDICATE: no-docs < word "documentation" word-prop not ;\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
+UNION: no-docs-union no-docs integer ;\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 ] [ \ f class-not \ f      null   class-and* ] unit-test\r
-[ t ] [ \ f class-not \ f      object class-or*  ] unit-test\r
+TUPLE: a ;\r
+TUPLE: b ;\r
+UNION: c a b ;\r
 \r
-TUPLE: first-one ;\r
-TUPLE: second-one ;\r
-UNION: both first-one union-class ;\r
+TUPLE: tuple-example ;\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
+TUPLE: a1 ;\r
+TUPLE: b1 ;\r
+TUPLE: c1 ;\r
 \r
-[ t ] [ number vector class-or sequence classes-intersect? ] unit-test\r
+UNION: x1 a1 b1 ;\r
+UNION: y1 a1 c1 ;\r
+UNION: z1 b1 c1 ;\r
 \r
-[ f ] [ number vector class-and sequence classes-intersect? ] unit-test\r
+SINGLETON: sa\r
+SINGLETON: sb\r
+SINGLETON: sc\r
+\r
+INTERSECTION: empty-intersection ;\r
+\r
+INTERSECTION: generic-class generic class ;\r
+\r
+UNION: union-with-one-member a ;\r
+\r
+MIXIN: mixin-with-one-member\r
+INSTANCE: union-with-one-member mixin-with-one-member\r
 \r
+! class<=\r
 [ t ] [ \ fixnum \ integer class<= ] unit-test\r
 [ t ] [ \ fixnum \ fixnum class<= ] unit-test\r
 [ f ] [ \ integer \ fixnum class<= ] unit-test\r
@@ -50,71 +56,41 @@ UNION: both first-one union-class ;
 [ 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: tuple-example ;\r
-\r
 [ t ] [ \ null \ tuple-example class<= ] unit-test\r
 [ f ] [ \ object \ tuple-example class<= ] unit-test\r
 [ f ] [ \ object \ tuple-example class<= ] unit-test\r
 [ t ] [ \ tuple-example \ tuple class<= ] unit-test\r
 [ f ] [ \ tuple \ tuple-example 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
-[ t ] [\r
-    growable tuple sequence class-and class<=\r
-] unit-test\r
+[ t ] [ growable tuple sequence class-and class<= ] unit-test\r
 \r
-[ t ] [\r
-    growable assoc class-and tuple class<=\r
-] unit-test\r
+[ t ] [ growable assoc class-and tuple class<= ] 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
@@ -127,12 +103,99 @@ UNION: z1 b1 c1 ;
 \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
+[ f ] [ fixnum class-not integer class<= ] unit-test\r
+\r
+[ t ] [ object empty-intersection class<= ] unit-test\r
+[ t ] [ empty-intersection object class<= ] unit-test\r
+[ t ] [ \ f class-not empty-intersection class<= ] unit-test\r
+[ f ] [ empty-intersection \ f class-not class<= ] unit-test\r
+[ t ] [ \ number empty-intersection class<= ] unit-test\r
+[ t ] [ empty-intersection class-not null class<= ] unit-test\r
+[ t ] [ null empty-intersection class-not class<= ] unit-test\r
+\r
+[ t ] [ \ f class-not \ f class-or empty-intersection class<= ] unit-test\r
+[ t ] [ empty-intersection \ f class-not \ f class-or class<= ] unit-test\r
+\r
+[ t ] [ object \ f class-not \ f class-or class<= ] unit-test\r
+\r
+[ t ] [\r
+    fixnum class-not\r
+    fixnum fixnum class-not class-or\r
+    class<=\r
+] unit-test\r
+\r
+[ t ] [ generic-class generic class<= ] unit-test\r
+[ t ] [ generic-class \ class class<= ] unit-test\r
+\r
+[ t ] [ a union-with-one-member class<= ] unit-test\r
+[ f ] [ union-with-one-member class-not integer class<= ] unit-test\r
+\r
+! class-and\r
+: class-and* ( cls1 cls2 cls3 -- ? ) [ class-and ] dip 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 ] [ \ f class-not \ f      null   class-and* ] unit-test\r
+\r
+[ t ] [ vector virtual-sequence null class-and* ] unit-test\r
+\r
+[ t ] [ vector array class-not vector class-and* ] unit-test\r
+\r
+! class-or\r
+: class-or* ( cls1 cls2 cls3 -- ? ) [ class-or ] dip class= ;\r
+\r
+[ t ] [ \ f class-not \ f      object class-or*  ] unit-test\r
+\r
+! class-not\r
+[ vector ] [ vector class-not class-not ] unit-test\r
+\r
+! classes-intersect?\r
+[ t ] [ both tuple classes-intersect? ] 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
+[ f ] [ y1 z1 class-and x1 classes-intersect? ] 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 ] [ integer integer class-not classes-intersect? ] 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
+[ t ] [ \ word generic-class classes-intersect? ] unit-test\r
+[ f ] [ number generic-class classes-intersect? ] unit-test\r
+\r
+[ f ] [ sa sb classes-intersect? ] unit-test\r
+\r
+[ t ] [ a union-with-one-member classes-intersect? ] unit-test\r
+[ f ] [ fixnum union-with-one-member classes-intersect? ] unit-test\r
+[ t ] [ object union-with-one-member classes-intersect? ] unit-test\r
+\r
+[ t ] [ union-with-one-member a classes-intersect? ] unit-test\r
+[ f ] [ union-with-one-member fixnum classes-intersect? ] unit-test\r
+[ t ] [ union-with-one-member object classes-intersect? ] unit-test\r
 \r
+[ t ] [ a mixin-with-one-member classes-intersect? ] unit-test\r
+[ f ] [ fixnum mixin-with-one-member classes-intersect? ] unit-test\r
+[ t ] [ object mixin-with-one-member classes-intersect? ] unit-test\r
+\r
+[ t ] [ mixin-with-one-member a classes-intersect? ] unit-test\r
+[ f ] [ mixin-with-one-member fixnum classes-intersect? ] unit-test\r
+[ t ] [ mixin-with-one-member object classes-intersect? ] unit-test\r
+\r
+! class=\r
 [ t ] [ null class-not object class= ] unit-test\r
 \r
 [ t ] [ object class-not null class= ] unit-test\r
@@ -141,13 +204,13 @@ UNION: z1 b1 c1 ;
 \r
 [ f ] [ null class-not null class= ] unit-test\r
 \r
-[ t ] [\r
-    fixnum class-not\r
-    fixnum fixnum class-not class-or\r
-    class<=\r
-] unit-test\r
+! class<=>\r
+\r
+[ +lt+ ] [ sequence object class<=> ] unit-test\r
+[ +gt+ ] [ object sequence class<=> ] unit-test\r
+[ +eq+ ] [ integer integer class<=> ] unit-test\r
 \r
-! Test method inlining\r
+! smallest-class etc\r
 [ real ] [ { real sequence } smallest-class ] unit-test\r
 [ real ] [ { sequence real } smallest-class ] unit-test\r
 \r
@@ -202,7 +265,7 @@ UNION: z1 b1 c1 ;
 10 [\r
     [ ] [\r
         20 [ random-op ] [ ] replicate-as\r
-        [ infer in>> [ random-class ] times ] keep\r
+        [ infer in>> length [ random-class ] times ] keep\r
         call\r
         drop\r
     ] unit-test\r
@@ -236,7 +299,7 @@ UNION: z1 b1 c1 ;
 20 [\r
     [ t ] [\r
         20 [ random-boolean-op ] [ ] replicate-as dup .\r
-        [ infer in>> [ random-boolean ] replicate dup . ] keep\r
+        [ infer in>> length [ random-boolean ] replicate dup . ] keep\r
         \r
         [ [ [ ] each ] dip call ] 2keep\r
         \r
@@ -266,59 +329,10 @@ TUPLE: xh < xb ;
 \r
 [ t ] [ { xa xb xc xd xe xf xg xh } sort-classes dup sort-classes = ] unit-test\r
 \r
-INTERSECTION: generic-class generic class ;\r
-\r
-[ t ] [ generic-class generic class<= ] unit-test\r
-[ t ] [ generic-class \ class class<= ] unit-test\r
-\r
-! Later\r
-[\r
-    [ t ] [ \ class generic class-and generic-class class<= ] unit-test\r
-    [ t ] [ \ class generic class-and generic-class swap class<= ] unit-test\r
-] drop\r
-\r
-[ t ] [ \ word generic-class classes-intersect? ] unit-test\r
-[ f ] [ number generic-class classes-intersect? ] unit-test\r
-\r
 [ H{ { word word } } ] [ \r
     generic-class flatten-class\r
 ] unit-test\r
 \r
-[ \ + flatten-class ] must-fail\r
-\r
-INTERSECTION: empty-intersection ;\r
-\r
-[ t ] [ object empty-intersection class<= ] unit-test\r
-[ t ] [ empty-intersection object class<= ] unit-test\r
-[ t ] [ \ f class-not empty-intersection class<= ] unit-test\r
-[ f ] [ empty-intersection \ f class-not class<= ] unit-test\r
-[ t ] [ \ number empty-intersection class<= ] unit-test\r
-[ t ] [ empty-intersection class-not null class<= ] unit-test\r
-[ t ] [ null empty-intersection class-not class<= ] unit-test\r
-\r
-[ t ] [ \ f class-not \ f class-or empty-intersection class<= ] unit-test\r
-[ t ] [ empty-intersection \ f class-not \ f class-or class<= ] unit-test\r
-\r
-[ t ] [ object \ f class-not \ f class-or class<= ] unit-test\r
-\r
-[ ] [ object flatten-builtin-class drop ] unit-test\r
-\r
-SINGLETON: sa\r
-SINGLETON: sb\r
-SINGLETON: sc\r
-\r
 [ sa ] [ sa { sa sb sc } min-class ] unit-test\r
 \r
-[ f ] [ sa sb classes-intersect? ] unit-test\r
-\r
-[ +lt+ ] [ integer sequence class<=> ] unit-test\r
-[ +lt+ ] [ sequence object class<=> ] unit-test\r
-[ +gt+ ] [ object sequence class<=> ] unit-test\r
-[ +eq+ ] [ integer integer class<=> ] unit-test\r
-\r
-! Limitations:\r
-\r
-! UNION: u1 sa sb ;\r
-! UNION: u2 sc ;\r
-\r
-! [ f ] [ u1 u2 classes-intersect? ] unit-test\r
+[ \ + flatten-class ] must-fail\r
old mode 100755 (executable)
new mode 100644 (file)
index 06857d3..e98470c
@@ -5,18 +5,44 @@ vectors assocs namespaces words sorting layouts math hashtables
 kernel.private sets math.order ;\r
 IN: classes.algebra\r
 \r
-TUPLE: anonymous-union members ;\r
+<PRIVATE\r
 \r
-C: <anonymous-union> anonymous-union\r
+TUPLE: anonymous-union { members read-only } ;\r
 \r
-TUPLE: anonymous-intersection participants ;\r
+: <anonymous-union> ( members -- class )\r
+    [ null eq? not ] filter prune\r
+    dup length 1 = [ first ] [ anonymous-union boa ] if ;\r
 \r
-C: <anonymous-intersection> anonymous-intersection\r
+TUPLE: anonymous-intersection { participants read-only } ;\r
 \r
-TUPLE: anonymous-complement class ;\r
+: <anonymous-intersection> ( participants -- class )\r
+    prune dup length 1 = [ first ] [ anonymous-intersection boa ] if ;\r
+\r
+TUPLE: anonymous-complement { class read-only } ;\r
 \r
 C: <anonymous-complement> anonymous-complement\r
 \r
+DEFER: (class<=)\r
+\r
+DEFER: (class-not)\r
+\r
+GENERIC: (classes-intersect?) ( first second -- ? )\r
+\r
+DEFER: (class-and)\r
+\r
+DEFER: (class-or)\r
+\r
+GENERIC: (flatten-class) ( class -- )\r
+\r
+: normalize-class ( class -- class' )\r
+    {\r
+        { [ dup members ] [ members <anonymous-union> normalize-class ] }\r
+        { [ dup participants ] [ participants <anonymous-intersection> normalize-class ] }\r
+        [ ]\r
+    } cond ;\r
+\r
+PRIVATE>\r
+\r
 GENERIC: valid-class? ( obj -- ? )\r
 \r
 M: class valid-class? drop t ;\r
@@ -25,40 +51,42 @@ M: anonymous-intersection valid-class? participants>> [ valid-class? ] all? ;
 M: anonymous-complement valid-class? class>> valid-class? ;\r
 M: word valid-class? drop f ;\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
-GENERIC: (classes-intersect?) ( first second -- ? )\r
+: class< ( first second -- ? )\r
+    {\r
+        { [ 2dup class<= not ] [ 2drop f ] }\r
+        { [ 2dup swap class<= not ] [ 2drop t ] }\r
+        [ [ rank-class ] bi@ < ]\r
+    } cond ;\r
 \r
-: normalize-class ( class -- class' )\r
+: class<=> ( first second -- ? )\r
     {\r
-        { [ dup members ] [ members <anonymous-union> ] }\r
-        { [ dup participants ] [ participants <anonymous-intersection> ] }\r
-        [ ]\r
+        { [ 2dup class<= not ] [ 2drop +gt+ ] }\r
+        { [ 2dup swap class<= not ] [ 2drop +lt+ ] }\r
+        [ [ rank-class ] bi@ <=> ]\r
     } cond ;\r
 \r
+: class= ( first second -- ? )\r
+    [ class<= ] [ swap class<= ] 2bi and ;\r
+\r
+: class-not ( class -- complement )\r
+    class-not-cache get [ (class-not) ] cache ;\r
+\r
 : classes-intersect? ( first second -- ? )\r
     classes-intersect-cache get [\r
         normalize-class (classes-intersect?)\r
     ] 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
+<PRIVATE\r
+\r
 : superclass<= ( first second -- ? )\r
     swap superclass dup [ swap class<= ] [ 2drop f ] if ;\r
 \r
@@ -89,6 +117,7 @@ DEFER: (class-or)
             [ class-not normalize-class ] map\r
             <anonymous-union>\r
         ] }\r
+        [ <anonymous-complement> ]\r
     } cond ;\r
 \r
 : left-anonymous-complement<= ( first second -- ? )\r
@@ -108,8 +137,10 @@ PREDICATE: empty-intersection < anonymous-intersection participants>> empty? ;
 \r
 : (class<=) ( first second -- ? )\r
     2dup eq? [ 2drop t ] [\r
+        [ normalize-class ] bi@\r
         2dup superclass<= [ 2drop t ] [\r
-            [ normalize-class ] bi@ {\r
+            {\r
+                { [ 2dup eq? ] [ 2drop t ] }\r
                 { [ dup empty-intersection? ] [ 2drop t ] }\r
                 { [ over empty-union? ] [ 2drop t ] }\r
                 { [ 2dup [ anonymous-complement? ] both? ] [ anonymous-complement<= ] }\r
@@ -185,22 +216,10 @@ M: anonymous-complement (classes-intersect?)
         [ <anonymous-complement> ]\r
     } cond ;\r
 \r
-: class< ( first second -- ? )\r
-    {\r
-        { [ 2dup class<= not ] [ 2drop f ] }\r
-        { [ 2dup swap class<= not ] [ 2drop t ] }\r
-        [ [ rank-class ] bi@ < ]\r
-    } cond ;\r
-\r
-: class<=> ( first second -- ? )\r
-    {\r
-        { [ 2dup class<= not ] [ 2drop +gt+ ] }\r
-        { [ 2dup swap class<= not ] [ 2drop +lt+ ] }\r
-        [ [ rank-class ] bi@ <=> ]\r
-    } cond ;\r
+M: anonymous-union (flatten-class)\r
+    members>> [ (flatten-class) ] each ;\r
 \r
-: class= ( first second -- ? )\r
-    [ class<= ] [ swap class<= ] 2bi and ;\r
+PRIVATE>\r
 \r
 ERROR: topological-sort-failed ;\r
 \r
@@ -211,7 +230,7 @@ ERROR: topological-sort-failed ;
 : sort-classes ( seq -- newseq )\r
     [ name>> ] sort-with >vector\r
     [ dup empty? not ]\r
-    [ dup largest-class [ over remove-nth! drop ] dip ]\r
+    [ dup largest-class [ swap remove-nth! ] dip ]\r
     produce nip ;\r
 \r
 : smallest-class ( classes -- class/f )\r
@@ -220,22 +239,5 @@ ERROR: topological-sort-failed ;
         [ ] [ [ class<= ] most ] map-reduce\r
     ] if-empty ;\r
 \r
-GENERIC: (flatten-class) ( class -- )\r
-\r
-M: anonymous-union (flatten-class)\r
-    members>> [ (flatten-class) ] each ;\r
-\r
 : flatten-class ( class -- assoc )\r
     [ (flatten-class) ] H{ } make-assoc ;\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-type ( class -- tag/f )\r
-    class-types dup length 1 = [ first ] [ drop f ] if ;\r
old mode 100755 (executable)
new mode 100644 (file)
index 6185e4f24dabc603b13848c39ab0f6a0fb84b17b..028225ec490aada25e0b56d4de2650fcc1c9c2be 100644 (file)
@@ -1,8 +1,8 @@
 ! Copyright (C) 2004, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors classes classes.algebra words kernel
-kernel.private namespaces sequences math math.private
-combinators assocs quotations ;
+USING: accessors classes classes.algebra classes.algebra.private
+words kernel kernel.private namespaces sequences math
+math.private combinators assocs quotations ;
 IN: classes.builtin
 
 SYMBOL: builtins
@@ -36,6 +36,6 @@ M: builtin-class (classes-intersect?)
         [ swap classes-intersect? ]
     } cond ;
 
-: full-cover ( -- ) builtins get sift [ (flatten-class) ] each ;
+: full-cover ( -- ) builtins get [ (flatten-class) ] each ;
 
 M: anonymous-complement (flatten-class) drop full-cover ;
index a0481a62a730963f14d6ed06d0d9ba64db29ff0d..36514f3cb2e8aef18bb4055142b400ac6b4ae6a8 100644 (file)
@@ -1,7 +1,8 @@
 ! Copyright (C) 2004, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: words accessors sequences kernel assocs combinators classes
-classes.algebra classes.builtin namespaces arrays math quotations ;
+classes.algebra classes.algebra.private classes.builtin
+namespaces arrays math quotations ;
 IN: classes.intersection
 
 PREDICATE: intersection-class < class
index e544c7f8aba361cc10715b5bcf2808e335e01556..eab2746dea985427c49e487e7a1fbbfcae773086 100644 (file)
@@ -1,7 +1,8 @@
 ! Copyright (C) 2004, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: classes classes.algebra kernel namespaces make words
-sequences quotations arrays kernel.private assocs combinators ;
+USING: classes classes.algebra classes.algebra.private kernel
+namespaces make words sequences quotations arrays kernel.private
+assocs combinators ;
 IN: classes.predicate
 
 PREDICATE: predicate-class < class
index 0db49cefa05c8eed35fccc35f6b2954ed7d7137b..e1caf4f46b67270d9e6eb3f3410c3210247312d4 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2008, 2009 Doug Coleman, Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: classes classes.algebra classes.predicate kernel
-sequences words ;
+USING: classes classes.algebra classes.algebra.private
+classes.predicate kernel sequences words ;
 IN: classes.singleton
 
 : singleton-predicate-quot ( class -- quot ) [ eq? ] curry ;
index 355514754295321047b8dfd8655c5e04b8949f61..710a011aa42420394117fbe2b15319bd5c99c449 100644 (file)
@@ -6,7 +6,7 @@ io.streams.string kernel kernel.private math math.constants
 math.order namespaces parser parser.notes prettyprint
 quotations random see sequences sequences.private slots
 slots.private splitting strings summary threads tools.test
-vectors vocabs words words.symbol ;
+vectors vocabs words words.symbol fry literals ;
 IN: classes.tuple.tests
 
 TUPLE: rect x y w h ;
@@ -577,8 +577,31 @@ unit-test
 [ T{ bad-slot-value f "hi" fixnum } = ]
 must-fail-with
 
-[ T{ declared-types f 0 "hi" } ]
-[ 0.0 "hi" declared-types boa ] unit-test
+! Check fixnum coercer
+[ 0 ] [ 0.0 "hi" declared-types boa n>> ] unit-test
+
+[ 0 ] [ declared-types new 0.0 >>n n>> ] unit-test
+
+! Check bignum coercer
+TUPLE: bignum-coercer { n bignum initial: $[ 0 >bignum ] } ;
+
+[ 13 bignum ] [ 13.5 bignum-coercer boa n>> dup class ] unit-test
+
+[ 13 bignum ] [ bignum-coercer new 13.5 >>n n>> dup class ] unit-test
+
+! Check float coercer
+TUPLE: float-coercer { n float } ;
+
+[ 13.0 float ] [ 13 float-coercer boa n>> dup class ] unit-test
+
+[ 13.0 float ] [ float-coercer new 13 >>n n>> dup class ] unit-test
+
+! Check integer coercer
+TUPLE: integer-coercer { n integer } ;
+
+[ 13 fixnum ] [ 13.5 integer-coercer boa n>> dup class ] unit-test
+
+[ 13 fixnum ] [ integer-coercer new 13.5 >>n n>> dup class ] unit-test
 
 : foo ( a b -- c ) declared-types boa ;
 
@@ -734,3 +757,11 @@ ERROR: base-error x y ;
 ERROR: derived-error < base-error z ;
 
 [ (( x y z -- * )) ] [ \ derived-error stack-effect ] unit-test
+
+USE: classes.struct
+
+[ { } ] [
+    classes
+    [ "prototype" word-prop ] map
+    [ '[ _ hashcode drop f ] [ drop t ] recover ] filter
+] unit-test
old mode 100755 (executable)
new mode 100644 (file)
index 3e449e6..d5ae145
@@ -1,10 +1,11 @@
-! Copyright (C) 2005, 2008 Slava Pestov.
+! Copyright (C) 2005, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: arrays definitions hashtables kernel kernel.private math
 namespaces make sequences sequences.private strings vectors
 words quotations memory combinators generic classes
-classes.algebra classes.builtin classes.private slots.private
-slots math.private accessors assocs effects ;
+classes.algebra classes.algebra.private classes.builtin
+classes.private slots.private slots math.private accessors
+assocs effects ;
 IN: classes.tuple
 
 PREDICATE: tuple-class < class
@@ -120,25 +121,6 @@ ERROR: bad-superclass class ;
 : class-size ( class -- n )
     superclasses [ "slots" word-prop length ] map-sum ;
 
-: (instance-check-quot) ( class -- quot )
-    [
-        \ dup ,
-        [ "predicate" word-prop % ]
-        [ [ literalize , \ bad-slot-value , ] [ ] make , ] bi
-        \ unless ,
-    ] [ ] make ;
-
-: (fixnum-check-quot) ( class -- quot )
-    (instance-check-quot) fixnum "coercer" word-prop prepend ;
-
-: instance-check-quot ( class -- quot )
-    {
-        { [ dup object bootstrap-word eq? ] [ drop [ ] ] }
-        { [ dup "coercer" word-prop ] [ "coercer" word-prop ] }
-        { [ dup \ fixnum class<= ] [ (fixnum-check-quot) ] }
-        [ (instance-check-quot) ]
-    } cond ;
-
 : boa-check-quot ( class -- quot )
     all-slots [ class>> instance-check-quot ] map spread>quot
     f like ;
old mode 100755 (executable)
new mode 100644 (file)
index e0e86e4..4615d31
@@ -1,7 +1,8 @@
 ! Copyright (C) 2004, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: words sequences kernel assocs combinators classes
-classes.algebra namespaces arrays math quotations ;
+classes.algebra classes.algebra.private namespaces arrays math
+quotations ;
 IN: classes.union
 
 PREDICATE: union-class < class
old mode 100755 (executable)
new mode 100644 (file)
index 2e9440a..f8a23e1
@@ -58,7 +58,7 @@ $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 a single quotation to multiple values. The asterisk (" { $snippet "*" } ") suffixed to these words' names signifies that they are apply combinators."
+"The apply combinators apply a single quotation to multiple values. The asterisk (" { $snippet "@" } ") suffixed to these words' names signifies that they are apply combinators."
 $nl
 "Two quotations:"
 { $subsections bi@ 2bi@ }
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 2bef1a5..55cc55c
@@ -11,7 +11,9 @@ IN: combinators
 
 : execute-effect-unsafe ( word effect -- ) drop execute ;
 
-M: object throw 5 getenv [ die ] or (( error -- * )) call-effect-unsafe ;
+M: object throw
+    5 special-object [ die ] or
+    (( error -- * )) call-effect-unsafe ;
 
 PRIVATE>
 
index 8dce12f4114b5042df7ec93aa059cc3de0b0b5fb..48c3b6891c526bec3b5177d3eeea7859a4bfa1e4 100644 (file)
@@ -1,20 +1,13 @@
 USING: compiler definitions compiler.units tools.test arrays sequences words kernel
-accessors namespaces fry eval ;
+accessors namespaces fry eval quotations math ;
 IN: compiler.units.tests
 
 [ [ [ ] define-temp ] with-compilation-unit ] must-infer
 [ [ [ ] define-temp ] with-nested-compilation-unit ] must-infer
 
-[ flushed-dependency ] [ f flushed-dependency strongest-dependency ] unit-test
-[ flushed-dependency ] [ flushed-dependency f strongest-dependency ] unit-test
-[ inlined-dependency ] [ flushed-dependency inlined-dependency strongest-dependency ] unit-test
-[ inlined-dependency ] [ called-dependency inlined-dependency strongest-dependency ] unit-test
-[ flushed-dependency ] [ called-dependency flushed-dependency strongest-dependency ] unit-test
-[ called-dependency ] [ called-dependency f strongest-dependency ] unit-test
-
 ! Non-optimizing compiler bugs
 [ 1 1 ] [
-    "A" "B" <word> [ [ [ 1 ] dip ] 2array 1array modify-code-heap ] keep
+    "A" <uninterned-word> [ [ [ 1 ] dip ] 2array 1array modify-code-heap ] keep
     1 swap execute
 ] unit-test
 
@@ -63,3 +56,16 @@ DEFER: nesting-test
 [ ] [ "IN: compiler.units.tests << : nesting-test ( -- ) ; >>" eval( -- ) ] unit-test
 
 observer remove-definition-observer
+
+! Make sure that non-optimized calls to a generic word which
+! hasn't been compiled yet work properly
+GENERIC: uncompiled-generic-test ( a -- b )
+
+M: integer uncompiled-generic-test 1 + ;
+
+<< [ uncompiled-generic-test ] [ jit-compile ] [ suffix! ] bi >>
+"q" set
+
+[ 4 ] [ 3 "q" get call ] unit-test
+
+[ ] [ [ \ uncompiled-generic-test forget ] with-compilation-unit ] unit-test
index 8b6625d01457b4fcbf2345914361503f7ca4735a..a64080e510afce7f0a888dcc1acf196d9efe3c29 100644 (file)
@@ -3,7 +3,8 @@
 USING: accessors arrays kernel continuations assocs namespaces
 sequences words vocabs definitions hashtables init sets
 math math.order classes classes.algebra classes.tuple
-classes.tuple.private generic source-files.errors ;
+classes.tuple.private generic source-files.errors
+kernel.private ;
 IN: compiler.units
 
 SYMBOL: old-definitions
@@ -15,12 +16,16 @@ TUPLE: redefine-error def ;
     \ redefine-error boa
     { { "Continue" t } } throw-restarts drop ;
 
+<PRIVATE
+
 : add-once ( key assoc -- )
     2dup key? [ over redefine-error ] when conjoin ;
 
 : (remember-definition) ( definition loc assoc -- )
     [ over set-where ] dip add-once ;
 
+PRIVATE>
+
 : remember-definition ( definition loc -- )
     new-definitions get first (remember-definition) ;
 
@@ -40,8 +45,21 @@ SYMBOL: compiler-impl
 
 HOOK: recompile compiler-impl ( words -- alist )
 
+HOOK: to-recompile compiler-impl ( -- words )
+
+HOOK: process-forgotten-words compiler-impl ( words -- )
+
+: compile ( words -- ) recompile modify-code-heap ;
+
 ! Non-optimizing compiler
-M: f recompile [ dup def>> ] { } map>assoc ;
+M: f recompile
+    [ dup def>> ] { } map>assoc ;
+
+M: f to-recompile
+    changed-definitions get [ drop word? ] assoc-filter
+    changed-generics get assoc-union keys ;
+
+M: f process-forgotten-words drop ;
 
 : without-optimizer ( quot -- )
     [ f compiler-impl ] dip with-variable ; inline
@@ -50,8 +68,12 @@ M: f recompile [ dup def>> ] { } map>assoc ;
 ! during stage1 bootstrap, it would just waste time.
 SINGLETON: dummy-compiler
 
+M: dummy-compiler to-recompile f ;
+
 M: dummy-compiler recompile drop { } ;
 
+M: dummy-compiler process-forgotten-words drop ;
+
 : <definitions> ( -- pair ) { H{ } H{ } } [ clone ] map ;
 
 SYMBOL: definition-observers
@@ -59,11 +81,11 @@ SYMBOL: definition-observers
 GENERIC: definitions-changed ( assoc obj -- )
 
 [ V{ } clone definition-observers set-global ]
-"compiler.units" add-init-hook
+"compiler.units" add-startup-hook
 
 ! This goes here because vocabs cannot depend on init
 [ V{ } clone vocab-observers set-global ]
-"vocabs" add-init-hook
+"vocabs" add-startup-hook
 
 : add-definition-observer ( obj -- )
     definition-observers get push ;
@@ -75,6 +97,17 @@ GENERIC: definitions-changed ( assoc obj -- )
     definition-observers get
     [ definitions-changed ] with each ;
 
+! Incremented each time stack effects potentially changed, used
+! by compiler.tree.propagation.call-effect for call( and execute(
+! inline caching
+: effect-counter ( -- n ) 47 special-object ; inline
+
+GENERIC: bump-effect-counter* ( defspec -- ? )
+
+M: object bump-effect-counter* drop f ;
+
+<PRIVATE
+
 : changed-vocabs ( assoc -- vocabs )
     [ drop word? ] assoc-filter
     [ drop vocabulary>> dup [ vocab ] when dup ] assoc-map ;
@@ -87,72 +120,38 @@ GENERIC: definitions-changed ( assoc obj -- )
     dup changed-definitions get update
     dup dup changed-vocabs update ;
 
-: compile ( words -- ) recompile modify-code-heap ;
-
-: index>= ( obj1 obj2 seq -- ? )
-    [ index ] curry bi@ >= ;
-
-: dependency>= ( how1 how2 -- ? )
-    { called-dependency flushed-dependency inlined-dependency }
-    index>= ;
-
-: strongest-dependency ( how1 how2 -- how )
-    [ called-dependency or ] bi@ [ dependency>= ] most ;
-
-: weakest-dependency ( how1 how2 -- how )
-    [ inlined-dependency or ] bi@ [ dependency>= not ] most ;
-
-: compiled-usage ( word -- assoc )
-    compiled-crossref get at ;
-
-: (compiled-usages) ( word -- assoc )
-    #! If the word is not flushable anymore, we have to recompile
-    #! all words which flushable away a call (presumably when the
-    #! word was still flushable). If the word is flushable, we
-    #! don't have to recompile words that folded this away.
-    [ compiled-usage ]
-    [ "flushable" word-prop inlined-dependency flushed-dependency ? ] bi
-    [ dependency>= nip ] curry assoc-filter ;
-
-: compiled-usages ( assoc -- assocs )
-    [ drop word? ] assoc-filter
-    [ [ drop (compiled-usages) ] { } assoc>map ] keep suffix ;
-
-: compiled-generic-usage ( word -- assoc )
-    compiled-generic-crossref get at ;
-
-: (compiled-generic-usages) ( generic class -- assoc )
-    [ compiled-generic-usage ] dip
-    [
-        2dup [ valid-class? ] both?
-        [ classes-intersect? ] [ 2drop f ] if nip
-    ] curry assoc-filter ;
-
-: compiled-generic-usages ( assoc -- assocs )
-    [ (compiled-generic-usages) ] { } assoc>map ;
-
-: words-only ( assoc -- assoc' )
-    [ drop word? ] assoc-filter ;
-
-: to-recompile ( -- seq )
-    changed-definitions get compiled-usages
-    changed-generics get compiled-generic-usages
-    append assoc-combine keys ;
-
 : process-forgotten-definitions ( -- )
     forgotten-definitions get keys
-    [ [ word? ] filter [ delete-compiled-xref ] each ]
+    [ [ word? ] filter process-forgotten-words ]
     [ [ delete-definition-errors ] each ]
     bi ;
 
+: bump-effect-counter? ( -- ? )
+    changed-effects get new-words get assoc-diff assoc-empty? not
+    changed-definitions get [ drop bump-effect-counter* ] assoc-any?
+    or ;
+
+: bump-effect-counter ( -- )
+    bump-effect-counter? [
+        47 special-object 0 or
+        1 +
+        47 set-special-object
+    ] when ;
+
+: notify-observers ( -- )
+    updated-definitions dup assoc-empty?
+    [ drop ] [ notify-definition-observers notify-error-observers ] if ;
+
 : finish-compilation-unit ( -- )
     remake-generics
     to-recompile recompile
     update-tuples
     process-forgotten-definitions
     modify-code-heap
-    updated-definitions dup assoc-empty?
-    [ drop ] [ notify-definition-observers notify-error-observers ] if ;
+    bump-effect-counter
+    notify-observers ;
+
+PRIVATE>
 
 : with-nested-compilation-unit ( quot -- )
     [
@@ -161,6 +160,7 @@ GENERIC: definitions-changed ( assoc obj -- )
         H{ } clone changed-effects set
         H{ } clone outdated-generics set
         H{ } clone outdated-tuples set
+        H{ } clone new-words set
         H{ } clone new-classes set
         [ finish-compilation-unit ] [ ] cleanup
     ] with-scope ; inline
@@ -173,6 +173,7 @@ GENERIC: definitions-changed ( assoc obj -- )
         H{ } clone outdated-generics set
         H{ } clone forgotten-definitions set
         H{ } clone outdated-tuples set
+        H{ } clone new-words set
         H{ } clone new-classes set
         <definitions> new-definitions set
         <definitions> old-definitions set
index a2617d0ebbfda4df8da27e91fde0b5f9e167a1f9..988be0dd88a6bf3c5257cec15fed13fbec127cd3 100644 (file)
@@ -22,7 +22,7 @@ IN: continuations.tests
         ] with-scope
     ] callcc0 "x" get 5 = ;
 
-[ t ] [ 10 callcc1-test 10 reverse >vector = ] unit-test
+[ t ] [ 10 callcc1-test 10 iota reverse >vector = ] unit-test
 [ t ] [ callcc-namespace-test ] unit-test
 
 [ 5 throw ] [ 5 = ] must-fail-with
index 8e14f4a26ba770b83def7f6b3fcbabc778a88bd1..d63acae8836213fbbef3ae6ad5431717f06e55fa 100644 (file)
@@ -13,7 +13,7 @@ SYMBOL: restarts
 <PRIVATE
 
 : catchstack* ( -- catchstack )
-    1 getenv { vector } declare ; inline
+    1 special-object { vector } declare ; inline
 
 : >c ( continuation -- ) catchstack* push ;
 
@@ -23,13 +23,13 @@ SYMBOL: restarts
 : dummy-1 ( -- obj ) f ;
 : dummy-2 ( obj -- obj ) dup drop ;
 
-: init-catchstack ( -- ) V{ } clone 1 setenv ;
+: init-catchstack ( -- ) V{ } clone 1 set-special-object ;
 
 PRIVATE>
 
 : catchstack ( -- catchstack ) catchstack* clone ; inline
 
-: set-catchstack ( catchstack -- ) >vector 1 setenv ; inline
+: set-catchstack ( catchstack -- ) >vector 1 set-special-object ; inline
 
 TUPLE: continuation data call retain name catch ;
 
@@ -49,22 +49,6 @@ C: <continuation> continuation
     } cleave ;
 
 : ifcc ( capture restore -- )
-    #! After continuation is being captured, the stacks looks
-    #! like:
-    #! ( f continuation r:capture r:restore )
-    #! so the 'capture' branch is taken.
-    #!
-    #! Note that the continuation itself is not captured as part
-    #! of the datastack.
-    #!
-    #! BUT...
-    #!
-    #! After the continuation is resumed, (continue-with) pushes
-    #! the given value together with f,
-    #! so now, the stacks looks like:
-    #! ( value f r:capture r:restore )
-    #! Execution begins right after the call to 'continuation'.
-    #! The 'restore' branch is taken.
     [ dummy-1 continuation ] 2dip [ dummy-2 ] prepose ?if ; inline
 
 : callcc0 ( quot -- ) [ drop ] ifcc ; inline
@@ -87,12 +71,12 @@ PRIVATE>
 
 : continue-with ( obj continuation -- * )
     [
-        swap 4 setenv
+        swap 4 set-special-object
         >continuation<
         set-catchstack
         set-namestack
         set-retainstack
-        [ set-datastack drop 4 getenv f 4 setenv f ] dip
+        [ set-datastack drop 4 special-object f 4 set-special-object f ] dip
         set-callstack
     ] (( obj continuation -- * )) call-effect-unsafe ;
 
@@ -189,12 +173,12 @@ M: condition compute-restarts
     ! VM calls on error
     [
         ! 63 = self
-        63 getenv error-thread set-global
+        63 special-object error-thread set-global
         continuation error-continuation set-global
         rethrow
-    ] 5 setenv
+    ] 5 set-special-object
     ! VM adds this to kernel errors, so that user-space
     ! can identify them
-    "kernel-error" 6 setenv ;
+    "kernel-error" 6 set-special-object ;
 
 PRIVATE>
index f40769ae395ecd4a34becc9d986792dcd1ec207b..0d207d9cc670dea1c1313c0a3c99a5f730e49f7e 100644 (file)
@@ -20,7 +20,7 @@ $nl
 { $see-also "see" } ;
 
 ARTICLE: "definition-checking" "Definition sanity checking"
-"When a source file is reloaded, the parser compares the previous list of definitions with the current list; any definitions which are no longer present in the file are removed by a call to " { $link forget } ". A warning message is printed if any other definitions still depend on the removed definitions."
+"When a source file is reloaded, the parser compares the previous list of definitions with the current list; any definitions which are no longer present in the file are removed by a call to " { $link forget } "."
 $nl
 "The parser also catches forward references when reloading source files. This is best illustrated with an example. Suppose we load a source file " { $snippet "a.factor" } ":"
 { $code
index e2fb4b8161395867af8767dbb9f274e15e5aeb5e..597b195c36036475e6f8f52e43536b7eeda504c7 100644 (file)
@@ -7,15 +7,13 @@ MIXIN: definition
 
 ERROR: no-compilation-unit definition ;
 
-SYMBOLS: inlined-dependency flushed-dependency called-dependency ;
-
 : set-in-unit ( value key assoc -- )
     [ set-at ] [ no-compilation-unit ] if* ;
 
 SYMBOL: changed-definitions
 
 : changed-definition ( defspec -- )
-    inlined-dependency swap changed-definitions get set-in-unit ;
+    dup changed-definitions get set-in-unit ;
 
 SYMBOL: changed-effects
 
@@ -23,8 +21,16 @@ SYMBOL: changed-generics
 
 SYMBOL: outdated-generics
 
+SYMBOL: new-words
+
 SYMBOL: new-classes
 
+: new-word ( word -- )
+    dup new-words get set-in-unit ;
+
+: new-word? ( word -- ? )
+    new-words get key? ;
+
 : new-class ( word -- )
     dup new-classes get set-in-unit ;
 
index 3e57f498af6698f28ecd111d60388eafc0982cd9..ac3751e32ed8bf40fc96656de69ab7b935f5e701 100644 (file)
@@ -6,8 +6,6 @@ IN: destructors
 
 SYMBOL: disposables
 
-[ H{ } clone disposables set-global ] "destructors" add-init-hook
-
 ERROR: already-unregistered disposable ;
 
 SYMBOL: debug-leaks?
@@ -26,15 +24,11 @@ SLOT: continuation
 PRIVATE>
 
 TUPLE: disposable < identity-tuple
-{ id integer }
 { disposed boolean }
 continuation ;
 
-M: disposable hashcode* nip id>> ;
-
 : new-disposable ( class -- disposable )
-    new \ disposable counter >>id
-    dup register-disposable ; inline
+    new dup register-disposable ; inline
 
 GENERIC: dispose* ( disposable -- )
 
@@ -91,3 +85,14 @@ PRIVATE>
         [ do-error-destructors ]
         cleanup
     ] with-scope ; inline
+
+[
+    H{ } clone disposables set-global
+    V{ } clone always-destructors set-global
+    V{ } clone error-destructors set-global
+] "destructors" add-startup-hook
+
+[
+    do-always-destructors
+    do-error-destructors
+] "destructors" add-shutdown-hook
index 38b8ab4dad2986985777795cdb52f4dc9891e200..134faea0270bc5f10adeb087e2d828f4d2e41d8c 100644 (file)
@@ -56,7 +56,7 @@ HELP: effect>string
 { $values { "obj" object } { "str" string } }
 { $description "Turns a stack effect object into a string mnemonic." }
 { $examples
-    { $example "USING: effects io ;" "1 2 <effect> effect>string print" "( object -- object object )" }
+    { $example "USING: effects io ;" "{ \"x\" } { \"y\" \"z\" } <effect> effect>string print" "( x -- y z )" }
 } ;
 
 HELP: stack-effect
index 8adef62795081e24116fde8d3a1c4bb96b3f1f44..ffc0c9780b27daeeb35dca386d6fa3112607bd32 100644 (file)
@@ -2,11 +2,11 @@ USING: effects kernel tools.test prettyprint accessors
 quotations sequences ;
 IN: effects.tests
 
-[ t ] [ 1 1 <effect> 2 2 <effect> effect<= ] unit-test
-[ f ] [ 1 0 <effect> 2 2 <effect> effect<= ] unit-test
-[ t ] [ 2 2 <effect> 2 2 <effect> effect<= ] unit-test
-[ f ] [ 3 3 <effect> 2 2 <effect> effect<= ] unit-test
-[ f ] [ 2 3 <effect> 2 2 <effect> effect<= ] unit-test
+[ t ] [ { "a" } { "a" } <effect> { "a" "b" } { "a" "b" } <effect> effect<= ] unit-test
+[ f ] [ { "a" } { } <effect> { "a" "b" } { "a" "b" } <effect> effect<= ] unit-test
+[ t ] [ { "a" "b" } { "a" "b" } <effect> { "a" "b" } { "a" "b" } <effect> effect<= ] unit-test
+[ f ] [ { "a" "b" "c" } { "a" "b" "c" } <effect> { "a" "b" } { "a" "b" } <effect> effect<= ] unit-test
+[ f ] [ { "a" "b" } { "a" "b" "c" } <effect> { "a" "b" } { "a" "b" } <effect> effect<= ] unit-test
 [ 2 ] [ (( a b -- c )) in>> length ] unit-test
 [ 1 ] [ (( a b -- c )) out>> length ] unit-test
 
index 8c1699f8d654def0d58ae5bae2f4d2eb124e222c..1790399e04d2c47a964f98c52a8c608a98be2c99 100644 (file)
@@ -1,34 +1,33 @@
-! Copyright (C) 2006, 2009 Slava Pestov.
+! Copyright (C) 2006, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel math math.parser math.order namespaces make sequences strings
 words assocs combinators accessors arrays quotations ;
 IN: effects
 
-TUPLE: effect { in read-only } { out read-only } { terminated? read-only } ;
-
-GENERIC: effect-length ( obj -- n )
-M: sequence effect-length length ;
-M: integer effect-length ;
+TUPLE: effect
+{ in array read-only }
+{ out array read-only }
+{ terminated? read-only } ;
 
 : <effect> ( in out -- effect )
-    dup { "*" } sequence= [ drop { } t ] [ f ] if
+    dup { "*" } = [ drop { } t ] [ f ] if
     effect boa ;
 
 : effect-height ( effect -- n )
-    [ out>> effect-length ] [ in>> effect-length ] bi - ; inline
+    [ out>> length ] [ in>> length ] bi - ; inline
 
 : effect<= ( effect1 effect2 -- ? )
     {
         { [ over terminated?>> ] [ t ] }
         { [ dup terminated?>> ] [ f ] }
-        { [ 2dup [ in>> effect-length ] bi@ > ] [ f ] }
+        { [ 2dup [ in>> length ] bi@ > ] [ f ] }
         { [ 2dup [ effect-height ] bi@ = not ] [ f ] }
         [ t ]
     } cond 2nip ; inline
 
 : effect= ( effect1 effect2 -- ? )
-    [ [ in>> effect-length ] bi@ = ]
-    [ [ out>> effect-length ] bi@ = ]
+    [ [ in>> length ] bi@ = ]
+    [ [ out>> length ] bi@ = ]
     [ [ terminated?>> ] bi@ = ]
     2tri and and ;
 
@@ -40,7 +39,6 @@ M: integer effect>string number>string ;
 M: pair effect>string first2 [ effect>string ] bi@ ": " glue ;
 
 : stack-picture ( seq -- string )
-    dup integer? [ "object" <repetition> ] when
     [ [ effect>string % CHAR: \s , ] each ] "" make ;
 
 M: effect effect>string ( effect -- string )
@@ -56,10 +54,14 @@ M: effect effect>string ( effect -- string )
 GENERIC: effect>type ( obj -- type )
 M: object effect>type drop object ;
 M: word effect>type ;
-! attempting to specialize on callable breaks compiling
-! M: effect effect>type drop callable ;
 M: pair effect>type second effect>type ;
 
+: effect-in-types ( effect -- input-types )
+    in>> [ effect>type ] map ;
+
+: effect-out-types ( effect -- input-types )
+    out>> [ effect>type ] map ;
+
 GENERIC: stack-effect ( word -- effect/f )
 
 M: word stack-effect "declared-effect" word-prop ;
@@ -73,7 +75,7 @@ M: effect clone
     stack-effect effect-height ;
 
 : split-shuffle ( stack shuffle -- stack1 stack2 )
-    in>> effect-length cut* ;
+    in>> length cut* ;
 
 : shuffle-mapping ( effect -- mapping )
     [ out>> ] [ in>> ] bi [ index ] curry map ;
@@ -88,14 +90,9 @@ M: effect clone
     over terminated?>> [
         drop
     ] [
-        [ [ [ in>> effect-length ] [ out>> effect-length ] bi ] [ in>> effect-length ] bi* swap [-] + ]
-        [ [ out>> effect-length ] [ [ in>> effect-length ] [ out>> effect-length ] bi ] bi* [ [-] ] dip + ]
+        [ [ [ in>> length ] [ out>> length ] bi ] [ in>> length ] bi* swap [-] + ]
+        [ [ out>> length ] [ [ in>> length ] [ out>> length ] bi ] bi* [ [-] ] dip + ]
         [ nip terminated?>> ] 2tri
-        [ [ [ "obj" ] replicate ] bi@ ] dip
+        [ [ "x" <array> ] bi@ ] dip
         effect boa
     ] if ; inline
-
-: effect-in-types ( effect -- input-types )
-    in>> [ effect>type ] map ;
-: effect-out-types ( effect -- input-types )
-    out>> [ effect>type ] map ;
index d57fbd97074bf1e54548e17b975aac67a619235a..a77ea34c30c8d9230e5ca8de30b881499cff9168 100644 (file)
@@ -25,7 +25,7 @@ ERROR: bad-effect ;
 : parse-effect-tokens ( end -- tokens )
     [ parse-effect-token dup ] curry [ ] produce nip ;
 
-ERROR: stack-effect-omits-dashes effect ;
+ERROR: stack-effect-omits-dashes tokens ;
 
 : parse-effect ( end -- effect )
     parse-effect-tokens { "--" } split1 dup
index dea523538eec6384d9b51179269d4c2e22d3581b..240fdd96e0aab3c1a3a899adabe8baa3f182fed7 100644 (file)
@@ -11,15 +11,13 @@ $nl
 { $code
     "GENERIC: explain ( object -- )"
     "M: object explain drop \"an object\" print ;"
-    "M: number explain drop \"a number\" print ;"
-    "M: sequence explain drop \"a sequence\" print ;"
+    "M: generic explain drop \"a class word\" print ;"
+    "M: class explain drop \"a generic word\" print ;"
 }
 "The linear order is the following, from least-specific to most-specific:"
-{ $code "{ object sequence number }" }
-"Neither " { $link number } " nor " { $link sequence } " are subclasses of each other, yet their intersection is the non-empty " { $link integer } " class. Calling " { $snippet "explain" } " with an integer on the stack will print " { $snippet "a number" } " because " { $link number } " precedes " { $link sequence } " in the class linearization order. If this was not the desired outcome, define a method on the intersection:"
-{ $code "M: integer explain drop \"an integer\" print ;" }
-"Now, the linear order is the following, from least-specific to most-specific:"
-{ $code "{ object sequence number integer }" }
+{ $code "{ object generic class }" }
+"Neither " { $link class } " nor " { $link generic } " are subclasses of each other, and their intersection is non-empty. Calling " { $snippet "explain" } " with a word on the stack that is both a class and a generic word will print " { $snippet "a generic word" } " because " { $link class } " precedes " { $link generic } " in the class linearization order. (One example of a word which is both a class and a generic word is the class of classes, " { $link class } ", which is also a word to get the class of an object.)"
+$nl
 "The " { $link order } " word can be useful to clarify method dispatch order:"
 { $subsections order } ;
 
old mode 100755 (executable)
new mode 100644 (file)
index f5c2018..5a98173
@@ -3,7 +3,8 @@ classes.tuple classes.union compiler.units continuations
 definitions eval generic generic.math generic.standard
 hashtables io io.streams.string kernel layouts math math.order
 namespaces parser prettyprint quotations sequences sorting
-strings tools.test vectors words generic.single ;
+strings tools.test vectors words generic.single
+compiler.crossref ;
 IN: generic.tests
 
 GENERIC: foobar ( x -- y )
index ce048c41dafd8fa45c87375ec956eb5613221f49..11fb2b5b42fa7ca87f6bb54d5888b828be1f899b 100644 (file)
@@ -13,6 +13,9 @@ ERROR: not-in-a-method-error ;
 : create-method-in ( class generic -- method )
     create-method dup set-word dup save-location ;
 
+: define-inline-method ( class generic quot -- )
+    [ create-method-in ] dip [ define ] [ drop make-inline ] 2bi ;
+
 : CREATE-METHOD ( -- method )
     scan-word bootstrap-word scan-word create-method-in ;
 
index 1434acf5217e53c4009e24414cdff8eeb7886c9a..d0bc4e1600941e65a56bd7c807af700af76f5d26 100644 (file)
@@ -63,19 +63,18 @@ TUPLE: predicate-engine class methods ;
 
 C: <predicate-engine> predicate-engine
 
-: push-method ( method specializer atomic assoc -- )
+: push-method ( method class atomic assoc -- )
     dupd [
         [ ] [ H{ } clone <predicate-engine> ] ?if
         [ methods>> set-at ] keep
     ] change-at ;
 
-: flatten-method ( class method assoc -- )
-    [ [ flatten-class keys ] keep ] 2dip [
-        [ spin ] dip push-method
-    ] 3curry each ;
+: flatten-method ( method class assoc -- )
+    over flatten-class keys
+    [ swap push-method ] with with with each ;
 
 : flatten-methods ( assoc -- assoc' )
-    H{ } clone [ [ flatten-method ] curry assoc-each ] keep ;
+    H{ } clone [ [ swapd flatten-method ] curry assoc-each ] keep ;
 
 ! 2. Convert methods
 : split-methods ( assoc class -- first second )
old mode 100755 (executable)
new mode 100644 (file)
index 37d6de0..f239458
@@ -46,7 +46,8 @@ $nl
 $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." ;
+"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."
+{ $subsections hashcode hashcode* identity-hashcode } ;
 
 ARTICLE: "hashtables.utilities" "Hashtable utilities"
 "Utility words to create a new hashtable from a single key/value pair:"
index 05cc27f5e8bfc0e48e61ba4336de65717e7cd81f..541f98ab9ca3ecbe00ac4c3996f84343568d0346 100644 (file)
@@ -3,14 +3,12 @@ sequences.private hashtables io prettyprint assocs
 continuations ;
 IN: hashtables.tests
 
-[ f ] [ "hi" V{ 1 2 3 } at ] unit-test
-
 [ H{ } ] [ { } [ dup ] H{ } map>assoc ] unit-test
 
-[ ] [ 1000 [ dup sq ] H{ } map>assoc "testhash" set ] unit-test
+[ ] [ 1000 iota [ dup sq ] H{ } map>assoc "testhash" set ] unit-test
 
 [ V{ } ]
-[ 1000 [ dup sq swap "testhash" get at = not ] filter ]
+[ 1000 iota [ dup sq swap "testhash" get at = not ] filter ]
 unit-test
 
 [ t ]
@@ -118,7 +116,7 @@ H{ } clone "counting" set
 
 ! Resource leak...
 H{ } "x" set
-100 [ drop "x" get clear-assoc ] each
+100 [ drop "x" get clear-assoc ] each-integer
 
 ! Crash discovered by erg
 [ t ] [ 0.75 <hashtable> dup clone = ] unit-test
@@ -173,4 +171,4 @@ H{ } "x" set
 [ 1 ] [ 2 "h" get at ] unit-test
 
 ! Random test case
-[ "A" ] [ 100 [ dup ] H{ } map>assoc 32 over delete-at "A" 32 pick set-at 32 swap at ] unit-test
+[ "A" ] [ 100 iota [ dup ] H{ } map>assoc 32 over delete-at "A" 32 pick set-at 32 swap at ] unit-test
index 9faf587b51114d8e3c9dc6529a0f45875b1c62b7..e31ed925d15e55672974c115833368181f52c73f 100644 (file)
@@ -115,9 +115,7 @@ M: hashtable assoc-size ( hash -- n )
     [ count>> ] [ deleted>> ] bi - ; inline
 
 : rehash ( hash -- )
-    dup >alist [
-    dup clear-assoc
-    ] dip (rehash) ;
+    dup >alist [ dup clear-assoc ] dip (rehash) ;
 
 M: hashtable set-at ( value key hash -- )
     dup ?grow-hash
index e76b6e8fee053d8e7a3ceb2f9570ed64716c7988..0382c38dffb420ee114f50b4d3007148366a5b80 100644 (file)
@@ -4,40 +4,50 @@ IN: init
 HELP: boot
 { $description "Called on startup as part of the boot quotation  to initialize the runtime and prepare it for running user code." } ;
 
-{ boot boot-quot set-boot-quot } related-words
+{ boot startup-quot set-startup-quot } related-words
 
-HELP: boot-quot
+HELP: startup-quot
 { $values { "quot" quotation } }
 { $description "Outputs the initial quotation called by the VM on startup." } ;
 
-HELP: set-boot-quot
+HELP: set-startup-quot
 { $values { "quot" quotation } }
 { $description "Sets the initial quotation called by the VM on startup. This quotation must begin with a call to " { $link boot } ". The image must be saved for changes to the boot quotation to take effect." }
 { $notes "The " { $link "tools.deploy" } " tool uses this word." } ;
 
-HELP: init-hooks
+HELP: startup-hooks
 { $var-description "An association list mapping string identifiers to quotations to be run on startup." } ;
 
-HELP: do-init-hooks
+HELP: shutdown-hooks
+{ $var-description "An association list mapping string identifiers to quotations to be run on shutdown." } ;
+
+HELP: do-startup-hooks
 { $description "Calls all initialization hook quotations." } ;
 
-HELP: add-init-hook
+HELP: do-shutdown-hooks
+{ $description "Calls all shutdown hook quotations." } ;
+
+HELP: add-startup-hook
 { $values { "quot" quotation } { "name" string } }
 { $description "Registers a startup hook. The hook will always run when Factor is started. If the hook was not already defined, this word also calls it immediately." } ;
 
-{ init-hooks do-init-hooks add-init-hook } related-words
+{ startup-hooks do-startup-hooks add-startup-hook add-shutdown-hook do-shutdown-hooks shutdown-hooks } related-words
 
 ARTICLE: "init" "Initialization and startup"
 "When Factor starts, the first thing it does is call a word:"
 { $subsections boot }
 "Next, initialization hooks are called:"
-{ $subsections do-init-hooks }
+{ $subsections do-startup-hooks }
 "Initialization hooks can be defined:"
-{ $subsections add-init-hook }
+{ $subsections add-startup-hook }
+"Corresponding shutdown hooks may also be defined:"
+{ $subsections add-shutdown-hook }
 "The boot quotation can be changed:"
 { $subsections
-    boot-quot
-    set-boot-quot
-} ;
+    startup-quot
+    set-startup-quot
+}
+"When quitting Factor, shutdown hooks are called:"
+{ $subsection do-shutdown-hooks } ;
 
 ABOUT: "init"
index 5d8e88b85f5b2ee4a78109e618f868d8773cf913..4e2d4b16a156f98b756d8c46760ff9309e8ec7d8 100644 (file)
@@ -4,19 +4,35 @@ USING: continuations continuations.private kernel
 kernel.private sequences assocs namespaces namespaces.private ;
 IN: init
 
-SYMBOL: init-hooks
+SYMBOL: startup-hooks
+SYMBOL: shutdown-hooks
 
-init-hooks global [ drop V{ } clone ] cache drop
+startup-hooks global [ drop V{ } clone ] cache drop
+shutdown-hooks global [ drop V{ } clone ] cache drop
 
-: do-init-hooks ( -- )
-    init-hooks get [ nip call( -- ) ] assoc-each ;
+: do-hooks ( symbol -- )
+    get [ nip call( -- ) ] assoc-each ;
 
-: add-init-hook ( quot name -- )
-    dup init-hooks get at [ over call( -- ) ] unless
-    init-hooks get set-at ;
+: do-startup-hooks ( -- ) startup-hooks do-hooks ;
+
+: do-shutdown-hooks ( -- ) shutdown-hooks do-hooks ;
+
+: add-startup-hook ( quot name -- )
+    startup-hooks get
+    [ at [ drop ] [ call( -- ) ] if ]
+    [ set-at ] 3bi ;
+
+: add-shutdown-hook ( quot name -- )
+    shutdown-hooks get set-at ;
 
 : boot ( -- ) init-namespaces init-catchstack init-error-handler ;
 
-: boot-quot ( -- quot ) 20 getenv ;
+: startup-quot ( -- quot ) 20 special-object ;
+
+: set-startup-quot ( quot -- ) 20 set-special-object ;
+
+: shutdown-quot ( -- quot ) 22 special-object ;
+
+: set-shutdown-quot ( quot -- ) 22 set-special-object ;
 
-: set-boot-quot ( quot -- ) 20 setenv ;
+[ do-shutdown-hooks ] set-shutdown-quot
index 494ccbff22853c73eb35ef983894ddf5ee846135..ee50500754cb329f7b4c75c3229ef32f20b03c56 100644 (file)
@@ -29,9 +29,9 @@ M: object normalize-directory normalize-path ;
 
 : set-io-backend ( io-backend -- )
     io-backend set-global init-io init-stdio
-    "io.files" init-hooks get at call( -- ) ;
+    "io.files" startup-hooks get at call( -- ) ;
 
 ! Note that we have 'alien' in our using list so that the alien
 ! init hook runs before this one.
 [ init-io embedded? [ init-stdio ] unless ]
-"io.backend" add-init-hook
+"io.backend" add-startup-hook
old mode 100755 (executable)
new mode 100644 (file)
index 088131a..efebe7b
@@ -28,4 +28,4 @@ IN: io.encodings.utf8.tests
 
 [ 3 ] [ 2 "lápis" >utf8-index ] unit-test
 
-[ V{ } ] [ 100000 [ [ code-point-length ] [ 1string utf8 encode length ] bi = not ] filter ] unit-test
+[ V{ } ] [ 100000 iota [ [ code-point-length ] [ 1string utf8 encode length ] bi = not ] filter ] unit-test
old mode 100755 (executable)
new mode 100644 (file)
index 6387e47dfc3bb97d4db856a2ceceb07a6110be6e..da5d67065908a075f2fc24ea52530d8959b05866 100644 (file)
@@ -1,7 +1,8 @@
 USING: arrays debugger.threads destructors io io.directories
-io.encodings.8-bit io.encodings.ascii io.encodings.binary
-io.files io.files.private io.files.temp io.files.unique kernel
-make math sequences system threads tools.test generic.single ;
+io.encodings.ascii io.encodings.binary io.encodings.string
+io.encodings.8-bit.latin1 io.files io.files.private
+io.files.temp io.files.unique kernel make math sequences system
+threads tools.test generic.single ;
 IN: io.files.tests
 
 [ ] [ "append-test" temp-file dup exists? [ delete-file ] [ drop ] if ] unit-test
@@ -22,6 +23,20 @@ IN: io.files.tests
     [ read1 ] with-file-reader >fixnum
 ] unit-test
 
+[
+    "This" CHAR: \s
+] [
+    "vocab:io/test/read-until-test.txt" ascii
+    [ " " read-until ] with-file-reader
+] unit-test
+
+[
+    "This" CHAR: \s
+] [
+    "vocab:io/test/read-until-test.txt" binary
+    [ " " read-until [ ascii decode ] dip ] with-file-reader
+] unit-test
+
 [ ] [
     "It seems Jobs has lost his grasp on reality again.\n"
     "separator-test.txt" temp-file latin1 set-file-contents
@@ -158,4 +173,4 @@ USE: debugger.threads
 [ ] [
     "closing-twice" unique-file ascii <file-writer>
     [ dispose ] [ dispose ] bi
-] unit-test
\ No newline at end of file
+] unit-test
index 6779c6d09429bc14bc4d055354a2ed709e59bf22..86d02acdd1721961de654c83bcc24a97794bb09e 100644 (file)
@@ -57,7 +57,7 @@ PRIVATE>
 
 [
     cwd current-directory set-global
-    13 getenv alien>native-string cwd prepend-path \ image set-global
-    14 getenv alien>native-string cwd prepend-path \ vm set-global
+    13 special-object alien>native-string cwd prepend-path \ image set-global
+    14 special-object alien>native-string cwd prepend-path \ vm set-global
     image parent-directory "resource-path" set-global
-] "io.files" add-init-hook
+] "io.files" add-startup-hook
index ca36bc3b364a0dea34a540e641390f8a152ccf75..c134ba21086789f51cf3a8b26dbb683c2f73bdb6 100644 (file)
@@ -99,7 +99,7 @@ SYMBOL: error-stream
     } case ; inline
 
 : stream-element-exemplar ( stream -- exemplar )
-    stream-element-type (stream-element-exemplar) ;
+    stream-element-type (stream-element-exemplar) ; inline
 
 : element-exemplar ( -- exemplar )
     input-stream get stream-element-exemplar ; inline
index d722c71747f227cc2f3eb5b0f0b5a8c86d6fc3a7..8dacef6f8c5699f0277281a0312da233f104761b 100644 (file)
@@ -1,5 +1,5 @@
-USING: help.markup help.syntax io.backend io.files io.directories strings
-sequences io.pathnames.private ;
+USING: help.markup help.syntax io.backend io.files
+io.directories strings system sequences io.pathnames.private ;
 IN: io.pathnames
 
 HELP: path-separator?
@@ -90,7 +90,7 @@ HELP: pathname
 
 HELP: normalize-path
 { $values { "path" "a pathname string" } { "path'" "a new pathname string" } }
-{ $description "Prepends the " { $link current-directory } " to the pathname, resolves a " { $snippet "resource:" } " or " { $snippet "voacb:" } " prefix, if present, and performs any platform-specific pathname normalization." }
+{ $description "Prepends the " { $link current-directory } " to the pathname, resolves a " { $snippet "resource:" } " or " { $snippet "vocab:" } " prefix, if present (see " { $link "io.pathnames.special" } "). Also converts the path into a UNC path on Windows." }
 { $notes "High-level words, such as " { $link <file-reader> } " and " { $link delete-file } " call this word for you. It only needs to be called directly when passing pathnames to C functions or external processes. This is because Factor does not use the operating system's notion of a current directory, and instead maintains its own dynamically-scoped " { $link current-directory } " variable." }
 { $notes "On Windows NT platforms, this word does prepends the Unicode path prefix." }
 { $examples
@@ -106,7 +106,7 @@ HELP: absolute-path
     { "path" "a pathname string" }
     { "path'" "a pathname string" }
 }
-{ $description "Prepends the " { $link current-directory } " to the pathname and resolves a " { $snippet "resource:" } " prefix, if present." }
+{ $description "Prepends the " { $link current-directory } " to the pathname and resolves a " { $snippet "resource:" } " or " { $snippet "voacb:" } " prefix, if present (see " { $link "io.pathnames.special" } ")." }
 { $notes "This word is exaclty the same as " { $link normalize-path } ", except on Windows NT platforms, where it does not prepend the Unicode path prefix. Most code should call " { $link normalize-path } " instead." } ;
 
 HELP: resolve-symlinks
@@ -128,8 +128,24 @@ HELP: home
     }
 } ;
 
+ARTICLE: "io.pathnames.special" "Special pathnames"
+"If a pathname begins with " { $snippet "resource:" } ", it is resolved relative to the directory containing the current image (see " { $link image } ")."
+$nl
+"If a pathname begins with " { $snippet "vocab:" } ", then it will be searched for in all current vocabulary roots (see " { $link "add-vocab-roots" } ")." ;
+
+ARTICLE: "io.pathnames.presentations" "Pathname presentations"
+"Pathname presentations are objects that wrap a pathname string. Clicking a pathname presentation in the UI brings up the file in one of the supported editors. See " { $link "editor" } " for more details."
+{ $subsections
+    pathname
+    <pathname>
+}
+"Literal pathname presentations:"
+{ $subsections POSTPONE: P" }
+"Many words that accept pathname strings can also work on pathname presentations." ;
+    
 ARTICLE: "io.pathnames" "Pathnames"
-"Pathnames are objects that contain a string representing the path to a file on disk. Pathnames are cross-platform; Windows accepts both forward and backward slashes as directory separators and new separators are added as a forward slash on all platforms. Clicking a pathname object in the UI brings up the file in one of the supported editors, but otherwise, pathnames and strings are interchangeable. See " { $link "editor" } " for more details." $nl
+"Pathnames are strings that refer to a file on disk. Pathname semantics are platform-specific, and Factor makes no attempt to abstract away the differences. Note that on Windows, both forward and backward slashes are accepted as directory separators."
+$nl
 "Pathname introspection:"
 { $subsections
     parent-directory
@@ -143,18 +159,9 @@ ARTICLE: "io.pathnames" "Pathnames"
     prepend-path
     append-path
 }
-"Pathname presentations:"
-{ $subsections
-    pathname
-    <pathname>
-}
-"Literal pathnames:"
-{ $subsections POSTPONE: P" }
-"Normalizing pathnames for use with native APIs:"
-{ $subsections normalize-path }
-"Outputting an absolute path from a path:"
-{ $subsection absolute-path }
-"Removing symlinks from a path:"
-{ $subsections resolve-symlinks } ;
+"Normalizing pathnames:"
+{ $subsections normalize-path absolute-path resolve-symlinks }
+"Additional topics:"
+{ $subsections "io.pathnames.presentations" "io.pathnames.special" } ;
 
 ABOUT: "io.pathnames"
index 25eefd1105bef391bcefa27cfb1df829d37a1732..b307128efb2287bbd60d9a36ffa7866aac42ab9b 100644 (file)
@@ -102,8 +102,8 @@ PRIVATE>
             [ 2 head ] dip append
         ] }
         [
-            [ trim-tail-separators "/" ] dip
-            trim-head-separators 3append
+            [ trim-tail-separators ]
+            [ trim-head-separators ] bi* "/" glue
         ]
     } cond ;
 
old mode 100755 (executable)
new mode 100644 (file)
index 1da30fe..d26f03a
@@ -61,9 +61,9 @@ M: c-reader stream-read-until
 
 M: c-io-backend init-io ;
 
-: stdin-handle ( -- alien ) 11 getenv ;
-: stdout-handle ( -- alien ) 12 getenv ;
-: stderr-handle ( -- alien ) 61 getenv ;
+: stdin-handle ( -- alien ) 11 special-object ;
+: stdout-handle ( -- alien ) 12 special-object ;
+: stderr-handle ( -- alien ) 61 special-object ;
 
 : init-c-stdio ( -- )
     stdin-handle <c-reader>
@@ -73,7 +73,8 @@ M: c-io-backend init-io ;
 
 M: c-io-backend init-stdio init-c-stdio ;
 
-M: c-io-backend io-multiplex 60 60 * 1000 * 1000 * or (sleep) ;
+M: c-io-backend io-multiplex
+    dup 0 = [ drop ] [ 60 60 * 1000 * 1000 * or (sleep) ] if ;
 
 : fopen ( path mode -- alien )
     [ utf8 string>alien ] bi@ (fopen) ;
diff --git a/core/io/test/read-until-test.txt b/core/io/test/read-until-test.txt
new file mode 100644 (file)
index 0000000..a496efe
--- /dev/null
@@ -0,0 +1 @@
+This is a text file
index f70d9d42145ae9659c636faf7b548d40873f02b3..7c80990d7a214d97353d53cc836329c12e6f5e4c 100644 (file)
@@ -21,12 +21,10 @@ HELP: 2over                          $shuffle ;
 HELP: pick  ( x y z -- x y z x )     $shuffle ;
 HELP: swap  ( x y -- y x )           $shuffle ;
 
-HELP: spin                     $complex-shuffle ;
 HELP: rot   ( x y z -- y z x ) $complex-shuffle ;
 HELP: -rot  ( x y z -- z x y ) $complex-shuffle ;
 HELP: dupd  ( x y -- x x y )   $complex-shuffle ;
 HELP: swapd ( x y z -- y x z ) $complex-shuffle ;
-HELP: tuck  ( x y -- y x y )   $complex-shuffle ;
 
 HELP: datastack ( -- ds )
 { $values { "ds" array } }
@@ -48,9 +46,9 @@ HELP: callstack ( -- cs )
 { $values { "cs" callstack } }
 { $description "Outputs a copy of the call stack contents, with the top of the stack at the end of the vector. The stack frame of the caller word is " { $emphasis "not" } " included." } ;
 
-HELP: set-callstack ( cs -- )
+HELP: set-callstack ( cs -- )
 { $values { "cs" callstack } }
-{ $description "Replaces the call stack contents. The end of the vector becomes the top of the stack. Control flow is transferred immediately to the new call stack." } ;
+{ $description "Replaces the call stack contents. Control flow is transferred immediately to the innermost frame of the new call stack." } ;
 
 HELP: clear
 { $description "Clears the data stack." } ;
@@ -74,7 +72,11 @@ HELP: hashcode
 { $values { "obj" object } { "code" fixnum } }
 { $description "Computes the hashcode of an object with a default hashing depth. See " { $link hashcode* } " for the hashcode contract." } ;
 
-{ hashcode hashcode* } related-words
+HELP: identity-hashcode
+{ $values { "obj" object } { "code" fixnum } }
+{ $description "Outputs the identity hashcode of an object. The identity hashcode is not guaranteed to be unique, however it will not change during the object's lifetime." } ;
+
+{ hashcode hashcode* identity-hashcode } related-words
 
 HELP: =
 { $values { "obj1" object } { "obj2" object } { "?" "a boolean" } }
@@ -206,7 +208,7 @@ HELP: call
 
 { call POSTPONE: call( } related-words
 
-HELP: call-clear ( quot -- )
+HELP: call-clear ( quot -- )
 { $values { "quot" callable } }
 { $description "Calls a quotation with an empty call stack. If the quotation returns, Factor will exit.." }
 { $notes "Used to implement " { $link "threads" } "." } ;
@@ -653,13 +655,13 @@ HELP: tag ( object -- n )
 { $values { "object" object } { "n" "a tag number" } }
 { $description "Outputs an object's tag number, between zero and one less than " { $link num-types } ". This is implementation detail and user code should call " { $link class } " instead." } ;
 
-HELP: getenv ( n -- obj )
+HELP: special-object ( n -- obj )
 { $values { "n" "a non-negative integer" } { "obj" object } }
-{ $description "Reads an object from the Factor VM's environment table. User code never has to read the environment table directly; instead, use one of the callers of this word." } ;
+{ $description "Reads an object from the Factor VM's special object table. User code never has to read the special object table directly; instead, use one of the callers of this word." } ;
 
-HELP: setenv ( obj n -- )
+HELP: set-special-object ( obj n -- )
 { $values { "obj" object } { "n" "a non-negative integer" } }
-{ $description "Writes an object to the Factor VM's environment table. User code never has to write to the environment table directly; instead, use one of the callers of this word." } ;
+{ $description "Writes an object to the Factor VM's special object table. User code never has to write to the special object table directly; instead, use one of the callers of this word." } ;
 
 HELP: object
 { $class-description
@@ -821,14 +823,12 @@ $nl
 "Duplicating stack elements deep in the stack:"
 { $subsections
     dupd
-    tuck
 }
 "Permuting stack elements deep in the stack:"
 { $subsections
     swapd
     rot
     -rot
-    spin
 } ;
 
 ARTICLE: "shuffle-words" "Shuffle words"
index d9babb5fd7409d3663ece2b177d34c59a53c0fdc..bd21490542b6894c60bc93ccbbf5d794bf14d113 100644 (file)
@@ -13,11 +13,11 @@ IN: kernel.tests
 [ ] [ 10000 [ [ -1 f <array> ] ignore-errors ] times ] unit-test
 
 ! Make sure we report the correct error on stack underflow
-[ clear drop ] [ { "kernel-error" 11 f f } = ] must-fail-with
+[ clear drop ] [ { "kernel-error" 10 f f } = ] must-fail-with
 
 [ ] [ :c ] unit-test
 
-[ 3 [ { } set-retainstack ] dip ] [ { "kernel-error" 13 f f } = ] must-fail-with
+[ 3 [ { } set-retainstack ] dip ] [ { "kernel-error" 12 f f } = ] must-fail-with
 
 [ ] [ :c ] unit-test
 
@@ -34,15 +34,15 @@ IN: kernel.tests
 [ t "no-compile" set-word-prop ] each
 >>
 
-[ overflow-d ] [ { "kernel-error" 12 f f } = ] must-fail-with
+[ overflow-d ] [ { "kernel-error" 11 f f } = ] must-fail-with
 
 [ ] [ :c ] unit-test
 
-[ overflow-d-alt ] [ { "kernel-error" 12 f f } = ] must-fail-with
+[ overflow-d-alt ] [ { "kernel-error" 11 f f } = ] must-fail-with
 
 [ ] [ [ :c ] with-string-writer drop ] unit-test
 
-[ overflow-r ] [ { "kernel-error" 14 f f } = ] must-fail-with
+[ overflow-r ] [ { "kernel-error" 13 f f } = ] must-fail-with
 
 [ ] [ :c ] unit-test
 
@@ -164,8 +164,17 @@ IN: kernel.tests
     last-frame
 ] unit-test
 
+: throw-frame-test ( c -- * ) [ gc gc continue ] call-clear ;
+: throw-frame-test' ( -- ) [ throw-frame-test ] callcc0 ;
+
+[ ] [ throw-frame-test' ] unit-test
+
 [ 10 2 3 4 5 ] [ 1 2 3 4 5 [ 10 * ] 4dip ] unit-test
 
 [ 3 -1 5/6 ] [ 1 2 3 4 5 6 [ + ] [ - ] [ / ] 2tri* ] unit-test
 
 [ { 1 2 } { 3 4 } { 5 6 } ] [ 1 2 3 4 5 6 [ 2array ] 2tri@ ] unit-test
+
+[ t ] [ { } identity-hashcode fixnum? ] unit-test
+[ 123 ] [ 123 identity-hashcode ] unit-test
+[ t ] [ f identity-hashcode fixnum? ] unit-test
index a0934c2b17bcbc2d1201538d8fb62358f233a9dd..69d082ed2f954f32fa9076059a520093af440c30 100644 (file)
@@ -8,8 +8,6 @@ DEFER: 2dip
 DEFER: 3dip
 
 ! Stack stuff
-: spin ( x y z -- z y x ) swap rot ; inline
-
 : 2over ( x y z -- x y z x y ) pick pick ; inline
 
 : clear ( -- ) { } set-datastack ;
@@ -194,6 +192,16 @@ M: f hashcode* 2drop 31337 ; inline
 
 : hashcode ( obj -- code ) 3 swap hashcode* ; inline
 
+: identity-hashcode ( obj -- code )
+    dup tag 0 eq? [
+        dup tag 1 eq? [ drop 0 ] [
+            dup (identity-hashcode) dup 0 eq? [
+                drop dup compute-identity-hashcode
+                (identity-hashcode)
+            ] [ nip ] if
+        ] if
+    ] unless ; inline
+
 GENERIC: equal? ( obj1 obj2 -- ? )
 
 M: object equal? 2drop f ; inline
@@ -202,6 +210,8 @@ TUPLE: identity-tuple ;
 
 M: identity-tuple equal? 2drop f ; inline
 
+M: identity-tuple hashcode* nip identity-hashcode ; inline
+
 : = ( obj1 obj2 -- ? )
     2dup eq? [ 2drop t ] [
         2dup both-fixnums? [ 2drop f ] [ equal? ] if
index 7518dbf0cb13e5890e5110c9373f38eaeb0563c6..5edb5d1d7271d16fc5583c6e5c94be7ad54ad8b7 100644 (file)
@@ -16,19 +16,27 @@ SYMBOL: type-numbers
 
 SYMBOL: mega-cache-size
 
+SYMBOL: header-bits
+
 : type-number ( class -- n )
     type-numbers get at ;
 
 : tag-fixnum ( n -- tagged )
     tag-bits get shift ;
 
+: tag-header ( n -- tagged )
+    header-bits get shift ;
+
 : untag-fixnum ( n -- tagged )
     tag-bits get neg shift ;
 
+: hashcode-shift ( -- n )
+    tag-bits get header-bits get + ;
+
 ! We do this in its own compilation unit so that they can be
 ! folded below
 <<
-: cell ( -- n ) 7 getenv ; foldable
+: cell ( -- n ) 7 special-object ; foldable
 
 : (first-bignum) ( m -- n ) tag-bits get - 1 - 2^ ; foldable
 >>
index 220eb339606ae36704964dbe30e16e66c99dcbb5..84f993c5ac9a95dae1c149c22a7353909356dcdb 100644 (file)
@@ -1,4 +1,4 @@
-USING: kernel math math.constants tools.test sequences
+USING: kernel math math.constants math.order tools.test sequences
 grouping ;
 IN: math.floats.tests
 
@@ -58,7 +58,7 @@ unit-test
 
 [ 0 ] [ 1/0. >bignum ] unit-test
 
-[ t ] [ 64 [ 2^ 0.5 * ] map [ < ] monotonic? ] unit-test
+[ t ] [ 64 iota [ 2^ 0.5 * ] map [ < ] monotonic? ] unit-test
 
 [ 5 ] [ 10.5 1.9 /i ] unit-test
 
@@ -75,3 +75,6 @@ unit-test
 [ t ] [ -0.0 abs 0.0 fp-bitwise= ] unit-test
 [ 1.5 ] [ -1.5 abs ] unit-test
 [ 1.5 ] [ 1.5 abs ] unit-test
+
+[ 5.0 ] [ 3 5.0 max ] unit-test
+[ 3 ] [ 3 5.0 min ] unit-test
index bc419b94c52dde3c4ae9d3d5db0a4e9595cf30d4..97c6f7fc87659b71869eb35eb2c33c684f4b6dfe 100644 (file)
@@ -1,6 +1,6 @@
-! Copyright (C) 2004, 2009 Slava Pestov, Joe Groff.
+! Copyright (C) 2004, 2010 Slava Pestov, Joe Groff.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel math math.private ;
+USING: kernel math math.private math.order ;
 IN: math.floats.private
 
 : float-unordered? ( x y -- ? ) [ fp-nan? ] bi@ or ;
@@ -29,6 +29,9 @@ M: float u<= float-u<= ; inline
 M: float u>  float-u> ; inline
 M: float u>= float-u>= ; inline
 
+M: float min over float? [ float-min ] [ call-next-method ] if ; inline
+M: float max over float? [ float-max ] [ call-next-method ] if ; inline
+
 M: float + float+ ; inline
 M: float - float- ; inline
 M: float * float* ; inline
index c09f2950e4a2f555467a493fe9c94004cbd4d112..e25bbf13e2ba420062465342e95dbf85d55b1cae 100644 (file)
@@ -4,7 +4,7 @@ IN: math.integers
 ARTICLE: "integers" "Integers"
 { $subsections integer }
 "Integers come in two varieties -- fixnums and bignums. Fixnums fit in a machine word and are faster to manipulate; if the result of a fixnum operation is too large to fit in a fixnum, the result is upgraded to a bignum. Here is an example where two fixnums are multiplied yielding a bignum:"
-{ $example "USE: classes" "134217728 class ." "fixnum" }
+{ $example "USE: classes" "67108864 class ." "fixnum" }
 { $example "USE: classes" "128 class ." "fixnum" }
 { $example "134217728 128 * ." "17179869184" }
 { $example "USE: classes" "1 128 shift class ." "bignum" }
index 44c038b6ee5faaa95379a402bc18c25befb92c13..3f3ea7ba1bd0975df2192defafd6198556ffe5e5 100644 (file)
@@ -1,5 +1,6 @@
-USING: kernel math math.functions namespaces prettyprint
-math.private continuations tools.test sequences random ;
+USING: kernel math math.functions math.order namespaces
+prettyprint math.private continuations tools.test sequences
+random ;
 IN: math.integers.tests
 
 [ "-8" ] [ -8 unparse ] unit-test
@@ -23,8 +24,8 @@ IN: math.integers.tests
 
 [ -1 ] [ 1 neg ] unit-test
 [ -1 ] [ 1 >bignum neg ] unit-test
-[ 268435456 ] [ -268435456 >fixnum -1 * ] unit-test
-[ 268435456 ] [ -268435456 >fixnum neg ] unit-test
+[ 134217728 ] [ -134217728 >fixnum -1 * ] unit-test
+[ 134217728 ] [ -134217728 >fixnum neg ] unit-test
 
 [ 9 3 ] [ 93 10 /mod ] unit-test
 [ 9 3 ] [ 93 >bignum 10 /mod ] unit-test
@@ -100,12 +101,12 @@ unit-test
 [ 16 ] [ 13 next-power-of-2 ] unit-test
 [ 16 ] [ 16 next-power-of-2 ] unit-test
 
-[ 268435456 ] [ -268435456 >fixnum -1 /i ] unit-test
-[ 268435456 0 ] [ -268435456 >fixnum -1 /mod ] unit-test
-[ 0 ] [ -1 -268435456 >fixnum /i ] unit-test
+[ 134217728 ] [ -134217728 >fixnum -1 /i ] unit-test
+[ 134217728 0 ] [ -134217728 >fixnum -1 /mod ] unit-test
+[ 0 ] [ -1 -134217728 >fixnum /i ] unit-test
 [ 4420880996869850977 ] [ 13262642990609552931 3 /i ] unit-test
-[ 0 -1 ] [ -1 -268435456 >fixnum /mod ] unit-test
-[ 0 -1 ] [ -1 -268435456 >bignum /mod ] unit-test
+[ 0 -1 ] [ -1 -134217728 >fixnum /mod ] unit-test
+[ 0 -1 ] [ -1 -134217728 >bignum /mod ] unit-test
 [ 14355 ] [ 1591517158873146351817850880000000 32769 mod ] unit-test
 [ 8 530505719624382123 ] [ 13262642990609552931 1591517158873146351 /mod ] unit-test
 [ 8 ] [ 13262642990609552931 1591517158873146351 /i ] unit-test
@@ -117,7 +118,7 @@ unit-test
 [ f ] [ 30 zero? ] unit-test
 [ t ] [ 0 >bignum zero? ] unit-test
 
-[ 4294967280 ] [ 268435455 >fixnum 16 fixnum* ] unit-test
+[ 2147483632 ] [ 134217727 >fixnum 16 fixnum* ] unit-test
 
 [ 23603949310011464311086123800853779733506160743636399259558684142844552151041 ]
 [
@@ -156,7 +157,7 @@ unit-test
 [ 4294967296 ] [ 1 32 shift ] unit-test
 [ 1267650600228229401496703205376 ] [ 1 100 shift ] unit-test
 
-[ t ] [ 1 27 shift fixnum? ] unit-test
+[ t ] [ 1 26 shift fixnum? ] unit-test
 
 [ t ] [
     t
@@ -224,9 +225,12 @@ unit-test
         random-integer
         random-integer
         [ >float / ] [ /f ] 2bi 0.1 ~
-    ] all?
+    ] all-integers?
 ] unit-test
 
 ! Ensure that /f is accurate for fixnums > 2^53 on 64-bit platforms
 [ HEX: 1.758bec11492f9p-54 ] [ 1 12345678901234567 /f ] unit-test
 [ HEX: -1.758bec11492f9p-54 ] [ 1 -12345678901234567 /f ] unit-test
+
+[ 17 ] [ 17 >bignum 5 max ] unit-test
+[ 5 ] [ 17 >bignum 5 min ] unit-test
index e87d3a6a0db33f68954f8ce8af7db75226991f60..9f7543ca133d976f1ac9293a4a3baa78e45cd9a6 100644 (file)
@@ -1,8 +1,8 @@
-! Copyright (C) 2004, 2009 Slava Pestov.
+! Copyright (C) 2004, 2010 Slava Pestov.
 ! Copyright (C) 2008, Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel kernel.private sequences
-sequences.private math math.private combinators ;
+USING: kernel kernel.private sequences sequences.private math
+math.private math.order combinators ;
 IN: math.integers.private
 
 : fixnum-min ( x y -- z ) [ fixnum< ] most ; foldable
@@ -29,6 +29,9 @@ M: fixnum u<= fixnum<= ; inline
 M: fixnum u> fixnum> ; inline
 M: fixnum u>= fixnum>= ; inline
 
+M: fixnum min over fixnum? [ fixnum-min ] [ call-next-method ] if ; inline
+M: fixnum max over fixnum? [ fixnum-max ] [ call-next-method ] if ; inline
+
 M: fixnum + fixnum+ ; inline
 M: fixnum - fixnum- ; inline
 M: fixnum * fixnum* ; inline
index e56753887c3211db0960cabb9281f2d57d65e7ce..6af48d00de19270d6c53f050cfb066a769d8d752 100644 (file)
@@ -283,7 +283,7 @@ HELP: unless-zero
 { $examples "This word is equivalent to " { $link if-zero } " with an empty first quotation:"
     { $example
     "USING: sequences math prettyprint ;"
-    "3 [ ] [ sq ] if-empty ."
+    "3 [ ] [ sq ] if-zero ."
     "9"
     }
     { $example
old mode 100755 (executable)
new mode 100644 (file)
index 5d294c1f6f9edeb321a597734dd1867810ea7192..418107fcd158f9bf23c1054d0fa48fdb152ab817 100644 (file)
@@ -44,18 +44,18 @@ HELP: compare
 } ;
 
 HELP: max
-{ $values { "x" object } { "y" object } { "z" object } }
+{ $values { "obj1" object } { "obj2" object } { "obj" object } }
 { $description "Outputs the greatest of two ordered values." }
 { $notes "If one value is a floating point positive zero and the other is a negative zero, the result is undefined." } ;
 
 HELP: min
-{ $values { "x" object } { "y" object } { "z" object } }
+{ $values { "obj1" object } { "obj2" object } { "obj" object } }
 { $description "Outputs the smallest of two ordered values." }
 { $notes "If one value is a floating point positive zero and the other is a negative zero, the result is undefined." } ;
 
 HELP: clamp
 { $values { "x" object } { "min" object } { "max" object } { "y" object } }
-{ $description "Outputs " { $snippet "x" } " if contained in the interval " { $snippet "[min,max]" } " or outputs one of the endpoints." } ;
+{ $description "Outputs " { $snippet "x" } " if contained in the interval " { $snippet "[min,max]" } " or else outputs one of the endpoints." } ;
 
 HELP: between?
 { $values { "x" object } { "y" object } { "z" real } { "?" "a boolean" } }
index fe1454d1d873fab0b7f9a621dccdc95d0df531fb..499cf06e9a6394d04d514331a88dc7f2c2949580 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2008 Slava Pestov, Doug Coleman.
+! Copyright (C) 2008, 2010 Slava Pestov, Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel math ;
 IN: math.order
@@ -32,8 +32,12 @@ M: real after? ( obj1 obj2 -- ? ) > ; inline
 M: real before=? ( obj1 obj2 -- ? ) <= ; inline
 M: real after=? ( obj1 obj2 -- ? ) >= ; inline
 
-: min ( x y -- z ) [ before? ] most ;
-: max ( x y -- z ) [ after? ] most ;
+GENERIC: min ( obj1 obj2 -- obj )
+GENERIC: max ( obj1 obj2 -- obj )
+
+M: object min [ before? ] most ; inline
+M: object max [ after? ] most ; inline
+
 : clamp ( x min max -- y ) [ max ] dip min ; inline
 
 : between? ( x y z -- ? )
index cd0bb47bd5b39bd2a06d760c2f9d2969074eb2c8..0d039f2fe97bc2e6f5e09c0182018d237cef3af2 100644 (file)
@@ -29,12 +29,12 @@ $nl
 ABOUT: "number-strings"
 
 HELP: digits>integer
-{ $values { "seq" "a sequence of integers" } { "radix" "an integer between 2 and 36" } { "n/f" { $maybe integer } } }
+{ $values { "seq" "a sequence of integers" } { "radix" "an integer between 2 and 16" } { "n/f" { $maybe integer } } }
 { $description "Converts a sequence of digits (with most significant digit first) into an integer." }
 { $notes "This is one of the factors of " { $link string>number } "." } ;
 
 HELP: >digit
-{ $values { "n" "an integer between 0 and 35" } { "ch" "a character" } }
+{ $values { "n" "an integer between 0 and 15" } { "ch" "a character" } }
 { $description "Outputs a character representation of a digit." }
 { $notes "This is one of the factors of " { $link number>string } "." } ;
 
@@ -44,7 +44,7 @@ HELP: digit>
 { $notes "This is one of the factors of " { $link string>number } "." } ;
 
 HELP: base>
-{ $values { "str" string } { "radix" "an integer between 2 and 36" } { "n/f" "a real number or " { $link f } } }
+{ $values { "str" string } { "radix" "an integer between 2 and 16" } { "n/f" "a real number or " { $link f } } }
 { $description "Creates a real number from a string representation with the given radix. The radix is ignored for floating point literals; they are always taken to be in base 10."
 $nl
 "Outputs " { $link f } " if the string does not represent a number." } ;
@@ -84,7 +84,7 @@ $nl
 { >hex POSTPONE: HEX: hex> .h } related-words
 
 HELP: >base
-{ $values { "n" real } { "radix" "an integer between 2 and 36" } { "str" string } }
+{ $values { "n" real } { "radix" "an integer between 2 and 16" } { "str" string } }
 { $description "Converts a real number into a string representation using the given radix. If the number is a float, the radix is ignored and the output is always in base 10." } ;
 
 HELP: >bin
index d40705a53176b0f2eb4c3c725e13462e9cad89bb..acf187a33ab499fde0f98a8791b555abb2693fad 100644 (file)
@@ -2,42 +2,20 @@ USING: help.markup help.syntax debugger sequences kernel
 quotations math ;
 IN: memory
 
-HELP: begin-scan ( -- )
-{ $description "Disables the garbage collector and resets the heap scan pointer to point at the first object in the heap. The " { $link next-object } " word can then be called to advance the heap scan pointer and return successive objects."
-$nl
-"This word must always be paired with a call to " { $link end-scan } "." }
-{ $notes "This is a low-level facility and can be dangerous. Use the " { $link each-object } " combinator instead." } ;
-
-HELP: next-object ( -- obj )
-{ $values { "obj" object } }
-{ $description "Outputs the object at the heap scan pointer, and then advances the heap scan pointer. If the end of the heap has been reached, outputs " { $link f } ". This is unambiguous since the " { $link f } " object is tagged immediate and not actually stored in the heap." }
-{ $errors "Throws a " { $link heap-scan-error. } " if called outside a " { $link begin-scan } "/" { $link end-scan } " pair." }
-{ $notes "This is a low-level facility and can be dangerous. Use the " { $link each-object } " combinator instead." } ;
-
-HELP: end-scan ( -- )
-{ $description "Finishes a heap iteration by re-enabling the garbage collector. This word must always be paired with a call to " { $link begin-scan } "." }
-{ $notes "This is a low-level facility and can be dangerous. Use the " { $link each-object } " combinator instead." } ;
-
-HELP: each-object
-{ $values { "quot" { $quotation "( obj -- )" } } }
-{ $description "Applies a quotation to each object in the heap. The garbage collector is switched off while this combinator runs, so the given quotation must not allocate too much memory." }
-{ $notes "This word is the low-level facility used to implement the " { $link instances } " word." } ;
-
 HELP: instances
 { $values { "quot" { $quotation "( obj -- ? )" } } { "seq" "a fresh sequence" } }
-{ $description "Outputs a sequence of all objects in the heap which satisfy the quotation." }
-{ $notes "This word relies on " { $link each-object } ", so in particular the garbage collector is switched off while it runs and the given quotation must not allocate too much memory." } ;
+{ $description "Outputs a sequence of all objects in the heap which satisfy the quotation." } ;
 
 HELP: gc ( -- )
 { $description "Performs a full garbage collection." } ;
 
-HELP: data-room ( -- cards decks generations )
-{ $values { "cards" "number of kilobytes reserved for card marking" } { "decks" "number of kilobytes reserved for decks of cards" } { "generations" "array of free/total kilobytes pairs" } }
-{ $description "Queries the runtime for memory usage information." } ;
+HELP: data-room ( -- data-room )
+{ $values { "data-room" data-room } }
+{ $description "Queries the VM for memory usage information." } ;
 
-HELP: code-room ( -- code-total code-used code-free largest-free-block )
-{ $values { "code-total" "total kilobytes in the code heap" } { "code-used" "kilobytes used in the code heap" } { "code-free" "kilobytes free in the code heap" } { "largest-free-block" "size of largest free block" } }
-{ $description "Queries the runtime for memory usage information." } ;
+HELP: code-room ( -- code-room )
+{ $values { "code-room" code-room } }
+{ $description "Queries the VM for memory usage information." } ;
 
 HELP: size ( obj -- n )
 { $values { "obj" "an object" } { "n" "a size in bytes" } }
@@ -56,17 +34,6 @@ HELP: save-image-and-exit ( path -- )
 HELP: save
 { $description "Saves a snapshot of the heap to the current image file." } ;
 
-HELP: count-instances
-{ $values
-     { "quot" quotation }
-     { "n" integer } }
-{ $description "Applies the predicate quotation to each object in the heap and returns the number of objects that match. Since this word uses " { $link each-object } " with the garbage collector switched off, avoid allocating too much memory in the quotation." }
-{ $examples { $unchecked-example
-    "USING: memory words prettyprint ;"
-    "[ word? ] count-instances ."
-    "24210"
-} } ;
-
 ARTICLE: "images" "Images"
 "Factor has the ability to save the entire state of the system into an " { $emphasis "image file" } ". The image contains a complete dump of all data and code in the current Factor instance."
 { $subsections
old mode 100755 (executable)
new mode 100644 (file)
index 8ecf673..45e6090
@@ -31,4 +31,4 @@ TUPLE: testing x y z ;
 2 [ [ [ 3 throw ] instances ] must-fail ] times
 
 ! Bug found on Windows build box, having too many words in the image breaks 'become'
-[ ] [ 100000 [ f f <word> ] replicate { } { } become drop ] unit-test
+[ ] [ 100000 [ f <uninterned-word> ] replicate { } { } become drop ] unit-test
index 1c61e33d83542a8eb27a604b3ed6d404a67a2be3..4ab68a1ef1f81d7858bf1e23e464cc3cfa48f537 100644 (file)
@@ -1,26 +1,11 @@
 ! Copyright (C) 2005, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel continuations sequences vectors arrays system math
+USING: kernel continuations sequences system
 io.backend alien.strings memory.private ;
 IN: memory
 
-: (each-object) ( quot: ( obj -- ) -- )
-    next-object dup [
-        swap [ call ] keep (each-object)
-    ] [ 2drop ] if ; inline recursive
-
-: each-object ( quot -- )
-    gc begin-scan [ (each-object) ] [ end-scan ] [ ] cleanup ; inline
-
-: count-instances ( quot -- n )
-    0 swap [ 1 0 ? + ] compose each-object ; inline
-
 : instances ( quot -- seq )
-    #! To ensure we don't need to grow the vector while scanning
-    #! the heap, we do two scans, the first one just counts the
-    #! number of objects that satisfy the predicate.
-    [ count-instances 100 + <vector> ] keep swap
-    [ [ push-if ] 2curry each-object ] keep >array ; inline
+    [ all-instances ] dip filter ; inline
 
 : save-image ( path -- )
     normalize-path native-string>alien (save-image) ;
old mode 100755 (executable)
new mode 100644 (file)
index 9428445d267adb1d83321d1d4c01b143085012f5..40b1db8a3f39a83fcfb1955cd85ce3aaf3ab23e8 100644 (file)
@@ -6,7 +6,7 @@ IN: namespaces
 
 <PRIVATE
 
-: namestack* ( -- namestack ) 0 getenv { vector } declare ; inline
+: namestack* ( -- namestack ) 0 special-object { vector } declare ; inline
 : >n ( namespace -- ) namestack* push ;
 : ndrop ( -- ) namestack* pop* ;
 
@@ -14,8 +14,8 @@ PRIVATE>
 
 : namespace ( -- namespace ) namestack* last ; inline
 : namestack ( -- namestack ) namestack* clone ;
-: set-namestack ( namestack -- ) >vector 0 setenv ;
-: global ( -- g ) 21 getenv { hashtable } declare ; inline
+: set-namestack ( namestack -- ) >vector 0 set-special-object ;
+: global ( -- g ) 21 special-object { hashtable } declare ; inline
 : init-namespaces ( -- ) global 1array set-namestack ;
 : get ( variable -- value ) namestack* assoc-stack ; inline
 : set ( value variable -- ) namespace set-at ;
index 844581c6d98ae07b7f06350456962aa50b8a7cf0..97dbab384e5ec1ed9d052e44849e7d144f3d9606 100644 (file)
@@ -216,7 +216,7 @@ HELP: filter-moved
 { $description "Removes all definitions from " { $snippet "assoc2" } " which are in " { $snippet "assoc1" } " or are are no longer present in the current " { $link file } "." } ;
 
 HELP: forget-smudged
-{ $description "Forgets removed definitions and prints a warning message if any of them are still referenced from other source files." } ;
+{ $description "Forgets removed definitions." } ;
 
 HELP: finish-parsing
 { $values { "lines" "the lines of text just parsed" } { "quot" "the quotation just parsed" } }
index d920e1fc734767adfc95c518d4688a8c59478fd8..1433289f0a59fd8c02cd2e9c81ce34f32783647c 100644 (file)
@@ -55,8 +55,11 @@ ERROR: staging-violation word ;
     execute( accum -- accum ) ;
 
 : scan-object ( -- object )
-    scan-word dup parsing-word?
-    [ V{ } clone swap execute-parsing first ] when ;
+    scan-word {
+        { [ dup not ] [ unexpected-eof ] }
+        { [ dup parsing-word? ] [ V{ } clone swap execute-parsing first ] }
+        [ ]
+    } cond  ;
 
 : parse-step ( accum end -- accum ? )
     scan-word {
index b6be8d36f33c731c5747a2f4028f555fd0778d1e..e99a7ef695e6e6f75c3cbf6d3a8ce16fb876e901 100644 (file)
@@ -3,7 +3,9 @@ vectors kernel combinators ;
 IN: quotations
 
 ARTICLE: "quotations" "Quotations"
-"A quotation is an anonymous function (a value denoting a snippet of code) which can be used as a value and called. Quotations are delimited by square brackets (" { $snippet "[ ]" } "); see " { $link "syntax-quots" } " for details on their syntax."
+"A quotation is an anonymous function (a value denoting a snippet of code) which can be used as a value and called using the " { $link "call" } "."
+$nl
+"Quotation literals appearing in source code are delimited by square brackets, for example " { $snippet "[ 2 + ]" } "; see " { $link "syntax-quots" } " for details on their syntax."
 $nl
 "Quotations form a class of objects:"
 { $subsections
index f2b17b3f9da989da2b5e86d88a3a387401979072..2af94159f831ddb598a183ee0000e889187a9c87 100644 (file)
@@ -61,7 +61,7 @@ INSTANCE: curry immutable-sequence
 M: compose length
     [ first>> length ] [ second>> length ] bi + ;
 
-M: compose virtual-seq first>> ;
+M: compose virtual-exemplar first>> ;
 
 M: compose virtual@
     2dup first>> length < [
index ac3f565e5678784473968c1b752eedb3780a5cec..6711870f74c585a956f6aa65f65463d1688177e6 100644 (file)
@@ -21,4 +21,4 @@ IN: sbufs.tests
 
 [ fixnum ] [ 1 >bignum SBUF" " new-sequence length class ] unit-test
 
-[ fixnum ] [ 1 >bignum [ ] SBUF" " map-as length class ] unit-test
+[ fixnum ] [ 1 >bignum iota [ ] SBUF" " map-as length class ] unit-test
old mode 100755 (executable)
new mode 100644 (file)
index e50614a..9f570f9
@@ -999,10 +999,10 @@ HELP: pusher
      { "quot" quotation } { "accum" vector } }
 { $description "Creates a new vector to accumulate the values which return true for a predicate.  Returns a new quotation which accepts an object to be tested and stored in the accumulator if the test yields true. The accumulator is left on the stack for convenience." }
 { $example "! Find all the even numbers:" "USING: prettyprint sequences math kernel ;"
-           "10 [ even? ] pusher [ each ] dip ."
+           "10 iota [ even? ] pusher [ each ] dip ."
            "V{ 0 2 4 6 8 }"
 }
-{ $notes "Used to implement the " { $link filter } " word." } ;
+{ $notes "Used to implement the " { $link filter } " word. Compare this word with " { $link accumulator } ", which is an unfiltering version." } ;
 
 HELP: trim-head
 { $values
@@ -1140,9 +1140,9 @@ HELP: set-fourth
 
 HELP: replicate
 { $values
-     { "seq" sequence } { "quot" { $quotation "( -- elt )" } }
+     { "len" integer } { "quot" { $quotation "( -- elt )" } }
      { "newseq" sequence } }
-{ $description "Calls the quotation for every element of the sequence in order. However, the element is not passed to the quotation -- it is dropped, and the quotation produces an element of its own that is collected into a sequence of the same class as the input sequence." }
+     { $description "Calls the quotation " { $snippet "len" } " times, collecting results into a new array." }
 { $examples 
     { $unchecked-example "USING: kernel prettyprint random sequences ;"
         "5 [ 100 random ] replicate ."
@@ -1152,15 +1152,16 @@ HELP: replicate
 
 HELP: replicate-as
 { $values
-     { "seq" sequence } { "quot" quotation } { "exemplar" sequence }
+     { "len" integer } { "quot" quotation } { "exemplar" sequence }
      { "newseq" sequence } }
-{ $description "Calls the quotation for every element of the sequence in order. However, the element is not passed to the quotation -- it is dropped, and the quotation produces an element of its own that is collected into a sequence of the same class as the exemplar sequence." }
+ { $description "Calls the quotation " { $snippet "len" } " times, collecting results into a new sequence of the same type as the exemplar sequence." }
 { $examples 
     { $unchecked-example "USING: prettyprint kernel sequences ;"
         "5 [ 100 random ] B{ } replicate-as ."
         "B{ 44 8 2 33 18 }"
     }
 } ;
+
 { replicate replicate-as } related-words
 
 HELP: partition
@@ -1175,23 +1176,24 @@ HELP: partition
     }
 } ;
 
-HELP: virtual-seq
+HELP: virtual-exemplar
 { $values
      { "seq" sequence }
      { "seq'" sequence } }
-{ $description "Part of the virtual sequence protocol, this word is used to return an underlying array from which to look up a value at an index given by " { $link virtual@ } "." } ;
+{ $description "Part of the virtual sequence protocol, this word is used to return an exemplar of the underlying storage. This is used in words like " { $link new-sequence } "." } ;
 
 HELP: virtual@
 { $values
      { "n" integer } { "seq" sequence }
      { "n'" integer } { "seq'" sequence } }
-{ $description "Part of the sequence protocol, this word translates the input index " { $snippet "n" } " into an index into the underlying storage returned by " { $link virtual-seq } "." } ;
+{ $description "Part of the sequence protocol, this word translates the input index " { $snippet "n" } " into an index and the underlying storage this index points into." } ;
 
 HELP: 2map-reduce
 { $values
      { "seq1" sequence } { "seq2" sequence } { "map-quot" quotation } { "reduce-quot" quotation }
      { "result" object } }
-{ $description "Unclips the first element of each sequence and calls " { $snippet "map-quot" } " on both objects. The result of this calculation is passed, along with the rest of both sequences, to " { $link 2reduce } ", with the computed object as the identity." }
+ { $description "Calls " { $snippet "map-quot" } " on each pair of elements from " { $snippet "seq1" } " and " { $snippet "seq2" } " and combines the results using " { $snippet "reduce-quot" } " in the same manner as " { $link reduce } ", except that there is no identity element, and the sequence must have a length of at least 1." }
+{ $errors "Throws an error if the sequence is empty." }
 { $examples { $example "USING: sequences prettyprint math ;"
     "{ 10 30 50 } { 200 400 600 } [ + ] [ + ] 2map-reduce ."
     "1290"
@@ -1239,7 +1241,7 @@ HELP: binary-reduce
 { $description "Like " { $link reduce } ", but splits the sequence in half recursively until each sequence is small enough, and calls the quotation on these smaller sequences. If the quotation computes values that depend on the size of their input, such as bignum arithmetic, then this algorithm can be more efficient than using " { $link reduce } "." }
 { $examples "Computing factorial:"
     { $example "USING: prettyprint sequences math ;"
-    "40 rest-slice 1 [ * ] binary-reduce ."
+    "40 iota rest-slice 1 [ * ] binary-reduce ."
     "20397882081197443358640281739902897356800000000" }
 } ;
 
@@ -1289,7 +1291,8 @@ HELP: map-reduce
 { $values
      { "seq" sequence } { "map-quot" quotation } { "reduce-quot" quotation }
      { "result" object } }
-{ $description "Unclips the first element of the sequence, calls " { $snippet "map-quot" } " on that element, and proceeds like a " { $link reduce } ", where the calculated element is the identity element and the rest of the sequence is the sequence to reduce." }
+{ $description "Calls " { $snippet "map-quot" } " on each element and combines the results using " { $snippet "reduce-quot" } " in the same manner as " { $link reduce } ", except that there is no identity element, and the sequence must have a length of at least 1." }
+{ $errors "Throws an error if the sequence is empty." }
 { $examples { $example "USING: sequences prettyprint math ;"
     "{ 1 3 5 } [ sq ] [ + ] map-reduce ."
     "35"
@@ -1397,26 +1400,29 @@ $nl
 ARTICLE: "virtual-sequences-protocol" "Virtual sequence protocol"
 "Virtual sequences must know their length:"
 { $subsections length }
-"The underlying sequence to look up a value in:"
-{ $subsections virtual-seq }
-"The index of the value in the underlying sequence:"
+"An exemplar of the underlying storage:"
+{ $subsections virtual-exemplar }
+"The index and the underlying storage where the value is located:"
 { $subsections virtual@ } ;
 
 ARTICLE: "virtual-sequences" "Virtual sequences"
 "A virtual sequence is an implementation of the " { $link "sequence-protocol" } " which does not store its own elements, and instead computes them, either from scratch or by retrieving them from another sequence."
 $nl
 "Implementations include the following:"
-{ $subsections reversed slice iota }
-"Virtual sequences can be implemented with the " { $link "virtual-sequences-protocol" } ", by translating an index in the virtual sequence into an index in another sequence." ;
+{ $subsections reversed slice }
+"Virtual sequences can be implemented with the " { $link "virtual-sequences-protocol" } ", by translating an index in the virtual sequence into an index in another sequence."
+{ $see-also "sequences-integers" } ;
 
 ARTICLE: "sequences-integers" "Counted loops"
-"Integers support the sequence protocol in a trivial fashion; a non-negative integer presents its non-negative predecessors as elements. For example, the integer 3, when viewed as a sequence, contains the elements 0, 1, and 2. This is very useful for performing counted loops."
+"A virtual sequence is defined for iterating over integers from zero."
+{ $subsection iota }
+"For example, calling " { $link iota } " on the integer 3 produces a sequence containing the elements 0, 1, and 2. This is very useful for performing counted loops."
 $nl
-"For example, the " { $link each } " combinator, given an integer, simply calls a quotation that number of times, pushing a counter on each iteration that ranges from 0 up to that integer:"
-{ $example "3 [ . ] each" "0\n1\n2" }
+"This means the " { $link each } " combinator, given an integer, simply calls a quotation that number of times, pushing a counter on each iteration that ranges from 0 up to that integer:"
+{ $example "3 iota [ . ] each" "0\n1\n2" }
 "A common idiom is to iterate over a sequence, while also maintaining a loop counter. This can be done using " { $link each-index } ", " { $link map-index } " and " { $link reduce-index } "."
 $nl
-"Combinators that produce new sequences, such as " { $link map } ", will output an array if the input is an integer."
+"Combinators that produce new sequences, such as " { $link map } ", will output an array if the input is an instance of " { $link iota } "."
 $nl
 "More elaborate counted loops can be performed with " { $link "math.ranges" } "." ;
 
@@ -1671,6 +1677,19 @@ ARTICLE: "sequences-comparing" "Comparing sequences"
 ARTICLE: "sequences-f" "The f object as a sequence"
 "The " { $link f } " object supports the sequence protocol in a trivial way. It responds with a length of zero and throws an out of bounds error when an attempt is made to access elements." ;
 
+ARTICLE: "sequences-combinator-implementation" "Implementing sequence combinators"
+"Creating a new sequence unconditionally:"
+{ $subsections
+    accumulator
+    accumulator-for
+}
+"Creating a new sequence conditionally:"
+{ $subsections
+    pusher
+    pusher-for
+    2pusher
+} ;
+
 ARTICLE: "sequences" "Sequence operations"
 "A " { $emphasis "sequence" } " is a finite, linearly-ordered collection of elements. Words for working with sequences are in the " { $vocab-link "sequences" } " vocabulary."
 $nl
@@ -1708,6 +1727,8 @@ $nl
 "Using sequences for control flow:"
 { $subsections "sequences-if" }
 "For inner loops:"
-{ $subsections "sequences-unsafe" } ;
+{ $subsections "sequences-unsafe" }
+"Implemeting sequence combinators:"
+{ $subsections "sequences-combinator-implementation" } ;
 
 ABOUT: "sequences"
index c82caec3f9769772d61069f7a01fba6b122e7f23..10be0454b98f7c235cc45f01f9f16fb4f63577fc 100644 (file)
@@ -6,13 +6,13 @@ IN: sequences.tests
 [ "empty" ] [ { } [ "empty" ] [ "not empty" ] if-empty ] unit-test
 [ { 1 } "not empty" ] [ { 1 } [ "empty" ] [ "not empty" ] if-empty ] unit-test
 
-[ V{ 1 2 3 4 } ] [ 1 5 dup <slice> >vector ] unit-test
-[ 3 ] [ 1 4 dup <slice> length ] unit-test
+[ V{ 1 2 3 4 } ] [ 1 5 dup iota <slice> >vector ] unit-test
+[ 3 ] [ 1 4 dup iota <slice> length ] unit-test
 [ 2 ] [ 1 3 { 1 2 3 4 } <slice> length ] unit-test
 [ V{ 2 3 } ] [ 1 3 { 1 2 3 4 } <slice> >vector ] unit-test
 [ V{ 4 5 } ] [ { 1 2 3 4 5 } 2 tail-slice* >vector ] unit-test
-[ V{ 3 4 } ] [ 2 4 1 10 dup <slice> subseq >vector ] unit-test
-[ V{ 3 4 } ] [ 0 2 2 4 1 10 dup <slice> <slice> subseq >vector ] unit-test
+[ V{ 3 4 } ] [ 2 4 1 10 dup iota <slice> subseq >vector ] unit-test
+[ V{ 3 4 } ] [ 0 2 2 4 1 10 dup iota <slice> <slice> subseq >vector ] unit-test
 [ 0 10 "hello" <slice> ] must-fail
 [ -10 3 "hello" <slice> ] must-fail
 [ 2 1 "hello" <slice> ] must-fail
@@ -129,7 +129,7 @@ unit-test
 [ { 1 3 2 4 } ] [ { 1 2 3 4 } clone 1 2 pick exchange ] unit-test
 
 [ { "" "a" "aa" "aaa" } ]
-[ 4 [ CHAR: a <string> ] map ]
+[ 4 [ CHAR: a <string> ] { } map-integers ]
 unit-test
 
 [ V{ } ] [ "f" V{ } clone remove! ] unit-test
@@ -138,11 +138,11 @@ unit-test
 [ V{ "x" } ] [ "f" V{ "f" "x" "f" } clone remove! ] unit-test
 [ V{ "y" "x" } ] [ "f" V{ "y" "f" "x" "f" } clone remove! ] unit-test
 
-[ V{ 0 1 4 5 } ] [ 6 >vector 2 4 pick delete-slice ] unit-test
+[ V{ 0 1 4 5 } ] [ 6 iota >vector 2 4 pick delete-slice ] unit-test
 
 [ 6 >vector 2 8 pick delete-slice ] must-fail
 
-[ V{ } ] [ 6 >vector 0 6 pick delete-slice ] unit-test
+[ V{ } ] [ 6 iota >vector 0 6 pick delete-slice ] unit-test
 
 [ { 1 2 "a" "b" 5 6 7 } ] [
     { "a" "b" } 2 4 { 1 2 3 4 5 6 7 }
@@ -228,10 +228,10 @@ unit-test
 
 [ 0 ] [ f length ] unit-test
 [ f first ] must-fail
-[ 3 ] [ 3 10 nth ] unit-test
-[ 3 ] [ 3 10 nth-unsafe ] unit-test
-[ -3 10 nth ] must-fail
-[ 11 10 nth ] must-fail
+[ 3 ] [ 3 10 iota nth ] unit-test
+[ 3 ] [ 3 10 iota nth-unsafe ] unit-test
+[ -3 10 iota nth ] must-fail
+[ 11 10 iota nth ] must-fail
 
 [ -1/0. 0 remove-nth! ] must-fail
 [ "" ] [ "" [ CHAR: \s = ] trim ] unit-test
@@ -243,10 +243,10 @@ unit-test
 [ "asdf " ] [ " asdf " [ CHAR: \s = ] trim-head ] unit-test
 [ " asdf" ] [ " asdf " [ CHAR: \s = ] trim-tail ] unit-test
 
-[ 328350 ] [ 100 [ sq ] map-sum ] unit-test
+[ 328350 ] [ 100 iota [ sq ] map-sum ] unit-test
 
-[ 50 ] [ 100 [ even? ] count ] unit-test
-[ 50 ] [ 100 [ odd?  ] count ] unit-test
+[ 50 ] [ 100 iota [ even? ] count ] unit-test
+[ 50 ] [ 100 iota [ odd?  ] count ] unit-test
 
 [ { "b" "d" } ] [ { 1 3 } { "a" "b" "c" "d" } nths ] unit-test
 [ { "a" "b" "c" "d" } ] [ { 0 1 2 3 } { "a" "b" "c" "d" } nths ] unit-test
old mode 100755 (executable)
new mode 100644 (file)
index 1bcedb1..b8a8d5f
@@ -1,4 +1,4 @@
-! Copyright (C) 2005, 2009 Slava Pestov, Daniel Ehrenberg.
+! Copyright (C) 2005, 2010 Slava Pestov, Daniel Ehrenberg.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors kernel kernel.private slots.private math
 math.private math.order ;
@@ -98,12 +98,6 @@ M: f like drop [ f ] when-empty ; inline
 
 INSTANCE: f immutable-sequence
 
-! Integers used to support the sequence protocol
-M: integer length ; inline
-M: integer nth-unsafe drop ; inline
-
-INSTANCE: integer immutable-sequence
-
 PRIVATE>
 
 ! In the future, this will replace integer sequences
@@ -182,15 +176,15 @@ PRIVATE>
     2dup bounds-check? [ nth-unsafe ] [ 2drop f ] if ; inline
 
 MIXIN: virtual-sequence
-GENERIC: virtual-seq ( seq -- seq' )
+GENERIC: virtual-exemplar ( seq -- seq' )
 GENERIC: virtual@ ( n seq -- n' seq' )
 
 M: virtual-sequence nth virtual@ nth ; inline
 M: virtual-sequence set-nth virtual@ set-nth ; inline
 M: virtual-sequence nth-unsafe virtual@ nth-unsafe ; inline
 M: virtual-sequence set-nth-unsafe virtual@ set-nth-unsafe ; inline
-M: virtual-sequence like virtual-seq like ; inline
-M: virtual-sequence new-sequence virtual-seq new-sequence ; inline
+M: virtual-sequence like virtual-exemplar like ; inline
+M: virtual-sequence new-sequence virtual-exemplar new-sequence ; inline
 
 INSTANCE: virtual-sequence sequence
 
@@ -199,7 +193,7 @@ TUPLE: reversed { seq read-only } ;
 
 C: <reversed> reversed
 
-M: reversed virtual-seq seq>> ; inline
+M: reversed virtual-exemplar seq>> ; inline
 M: reversed virtual@ seq>> [ length swap - 1 - ] keep ; inline
 M: reversed length seq>> length ; inline
 
@@ -227,11 +221,11 @@ TUPLE: slice-error from to seq reason ;
     3tri ; inline
 
 : <slice> ( from to seq -- slice )
-    dup slice? [ collapse-slice ] when
     check-slice
+    dup slice? [ collapse-slice ] when
     slice boa ; inline
 
-M: slice virtual-seq seq>> ; inline
+M: slice virtual-exemplar seq>> ; inline
 
 M: slice virtual@ [ from>> + ] [ seq>> ] bi ; inline
 
@@ -426,11 +420,11 @@ PRIVATE>
 : map ( seq quot -- newseq )
     over map-as ; inline
 
-: replicate ( seq quot -- newseq )
-    [ drop ] prepose map ; inline
+: replicate-as ( len quot exemplar -- newseq )
+    [ [ drop ] prepose ] dip map-integers ; inline
 
-: replicate-as ( seq quot exemplar -- newseq )
-    [ [ drop ] prepose ] dip map-as ; inline
+: replicate ( len quot -- newseq )
+    { } replicate-as ; inline
 
 : map! ( seq quot -- seq )
     over [ map-into ] keep ; inline
@@ -466,7 +460,7 @@ PRIVATE>
     (2each) all-integers? ; inline
 
 : 3each ( seq1 seq2 seq3 quot -- )
-    (3each) each ; inline
+    (3each) each-integer ; inline
 
 : 3map-as ( seq1 seq2 seq3 quot exemplar -- newseq )
     [ (3each) ] dip map-integers ; inline
@@ -659,9 +653,9 @@ PRIVATE>
         [ 0 swap copy ] keep
     ] new-like ;
 
-: suffix! ( seq elt -- seq ) over push ;
+: suffix! ( seq elt -- seq ) over push ; inline
 
-: append! ( seq1 seq2 -- seq1 ) over push-all ;
+: append! ( seq1 seq2 -- seq1 ) over push-all ; inline
 
 : last ( seq -- elt ) [ length 1 - ] [ nth ] bi ;
 
@@ -842,6 +836,12 @@ PRIVATE>
         [ 3dup ] dip [ + swap nth-unsafe ] keep rot nth-unsafe =
     ] all? nip ; inline
 
+: prepare-2map-reduce ( seq1 seq2 map-quot -- initial length seq1 seq2 )
+    [ drop min-length dup 1 < [ "Empty sequence" throw ] when 1 - ]
+    [ drop [ [ 1 + ] 2dip 2nth-unsafe ] 2curry ]
+    [ [ [ first-unsafe ] bi@ ] dip call ]
+    3tri -rot ; inline
+
 PRIVATE>
 
 : start* ( subseq seq n -- i )
@@ -874,8 +874,8 @@ PRIVATE>
     compose reduce ; inline
 
 : 2map-reduce ( seq1 seq2 map-quot reduce-quot -- result )
-    [ [ 2unclip-slice ] dip [ call ] keep ] dip
-    compose 2reduce ; inline
+    [ [ prepare-2map-reduce ] keep ] dip
+    compose compose each-integer ; inline
 
 <PRIVATE
 
@@ -929,7 +929,8 @@ PRIVATE>
 : trim ( seq quot -- newseq )
     [ trim-slice ] [ drop ] 2bi like ; inline
 
-: sum ( seq -- n ) 0 [ + ] binary-reduce ;
+GENERIC: sum ( seq -- n )
+M: object sum 0 [ + ] binary-reduce ; inline
 
 : product ( seq -- n ) 1 [ * ] binary-reduce ;
 
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 957b525cb3115043e8fc972ca5affe6073066f31..3548e22c336428b7cea07841ef50874fc6fa3f17 100644 (file)
@@ -1,5 +1,5 @@
 USING: math accessors slots strings generic.single kernel
-tools.test generic words parser eval math.functions ;
+tools.test generic words parser eval math.functions arrays ;
 IN: slots.tests
 
 TUPLE: r/w-test foo ;
@@ -8,9 +8,9 @@ TUPLE: r/o-test { foo read-only } ;
 
 [ r/o-test new 123 >>foo ] [ no-method? ] must-fail-with
 
-TUPLE: decl-test { foo integer } ;
+TUPLE: decl-test { foo array } ;
 
-[ decl-test new 1.0 >>foo ] [ bad-slot-value? ] must-fail-with
+[ decl-test new "" >>foo ] [ bad-slot-value? ] must-fail-with
 
 TUPLE: hello length ;
 
old mode 100755 (executable)
new mode 100644 (file)
index 0422478..7b97748
@@ -1,4 +1,4 @@
-! Copyright (C) 2005, 2009 Slava Pestov.
+! Copyright (C) 2005, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: arrays byte-arrays kernel kernel.private math namespaces
 make sequences strings effects generic generic.standard
@@ -64,39 +64,29 @@ M: object reader-quot
 
 ERROR: bad-slot-value value class ;
 
-: writer-quot/object ( slot-spec -- )
-    offset>> , \ set-slot , ;
-
-: writer-quot/coerce ( slot-spec -- )
-    [ class>> "coercer" word-prop [ dip ] curry % ]
-    [ offset>> , \ set-slot , ]
-    bi ;
-
-: writer-quot/check ( slot-spec -- )
-    [ offset>> , ]
+: (instance-check-quot) ( class -- quot )
     [
-        \ pick ,
-        dup class>> "predicate" word-prop %
-        [ set-slot ] ,
-        class>> [ 2nip bad-slot-value ] curry [ ] like ,
-        \ if ,
-    ]
-    bi ;
+        \ dup ,
+        [ "predicate" word-prop % ]
+        [ [ bad-slot-value ] curry , ] bi
+        \ unless ,
+    ] [ ] make ;
 
-: writer-quot/fixnum ( slot-spec -- )
-    [ [ >fixnum ] dip ] % writer-quot/check ;
+: instance-check-quot ( class -- quot )
+    {
+        { [ dup object bootstrap-word eq? ] [ drop [ ] ] }
+        { [ dup "coercer" word-prop ] [ "coercer" word-prop ] }
+        { [ dup integer bootstrap-word eq? ] [ drop [ >integer ] ] }
+        [ (instance-check-quot) ]
+    } cond ;
 
 GENERIC# writer-quot 1 ( class slot-spec -- quot )
 
 M: object writer-quot
-    nip [
-        {
-            { [ dup class>> object bootstrap-word eq? ] [ writer-quot/object ] }
-            { [ dup class>> "coercer" word-prop ] [ writer-quot/coerce ] }
-            { [ dup class>> fixnum bootstrap-word class<= ] [ writer-quot/fixnum ] }
-            [ writer-quot/check ]
-        } cond
-    ] [ ] make ;
+    nip
+    [ class>> instance-check-quot dup empty? [ [ dip ] curry ] unless ]
+    [ offset>> [ set-slot ] curry ]
+    bi append ;
 
 : writer-props ( slot-spec -- assoc )
     "writing" associate ;
index 0bda4ba9b0be9e4324c69677d6734c4a7c1e3d3e..101cd75a5ba1f7aaf3a53bf49eba55ea584d754c 100644 (file)
@@ -5,7 +5,7 @@ IN: sorting.tests
 [ { } ] [ { } natural-sort ] unit-test
 
 [ { 270000000 270000001 } ]
-[ T{ slice f 270000000 270000002 270000002 } natural-sort ]
+[ T{ slice f 270000000 270000002 T{ iota f 270000002 } } natural-sort ]
 unit-test
 
 [ t ] [
@@ -14,7 +14,7 @@ unit-test
         100 [ 20 random [ 1000 random ] replicate ] replicate
         dup natural-sort
         [ set= ] [ nip [ before=? ] monotonic? ] 2bi and
-    ] all?
+    ] all-integers?
 ] unit-test
 
 [ ] [ { 1 2 } [ 2drop 1 ] sort drop ] unit-test
index ebacc90f633c7b906bc9447847b9520630e94134..b3b6daee5957174fdb8a559caa25333f6576e6e9 100644 (file)
@@ -20,7 +20,7 @@ M: source-file-error error-line [ error>> error-line ] [ line#>> ] bi or ;
 M: source-file-error compute-restarts error>> compute-restarts ;
 
 : sort-errors ( errors -- alist )
-    [ [ line#>> ] sort-with ] { } assoc-map-as sort-keys ;
+    [ [ line#>> 0 or ] sort-with ] { } assoc-map-as sort-keys ;
 
 : group-by-source-file ( errors -- assoc )
     H{ } clone [ [ push-at ] curry [ dup file>> ] prepose each ] keep ;
@@ -68,7 +68,7 @@ GENERIC: errors-changed ( observer -- )
 
 SYMBOL: error-observers
 
-[ V{ } clone error-observers set-global ] "source-files.errors" add-init-hook
+[ V{ } clone error-observers set-global ] "source-files.errors" add-startup-hook
 
 : add-error-observer ( observer -- ) error-observers get push ;
 
index 558018a147d404fef479c267564c1c1319fbfa65..4991a0860a6fde24f9fd88e58c6ba375bafc1479 100644 (file)
@@ -3,7 +3,7 @@
 USING: arrays definitions generic assocs kernel math namespaces
 sequences strings vectors words quotations io io.files
 io.pathnames combinators sorting splitting math.parser effects
-continuations checksums checksums.crc32 vocabs hashtables graphs
+continuations checksums checksums.crc32 vocabs hashtables
 compiler.units io.encodings.utf8 accessors source-files.errors ;
 IN: source-files
 
index 10fea15a6499bf082571d87bb2ead8401919d3e3..50855713121181367d318f1c2bb49efafce9ce1c 100644 (file)
@@ -13,6 +13,7 @@ ARTICLE: "sequences-split" "Splitting sequences"
     split1-last
     split1-last-slice
     split
+    split-when
 }
 "Splitting a string into lines:"
 { $subsections string-lines } ;
@@ -37,9 +38,14 @@ HELP: split1-last-slice
 
 { split1 split1-slice split1-last split1-last-slice } related-words
 
+HELP: split-when
+{ $values { "seq" "a sequence" } { "quot" { $quotation "( elt -- ? )" } } { "pieces" "a new array" } }
+{ $description "Splits " { $snippet "seq" } " at each occurrence of an element for which " { $snippet "quot" } " gives a true output and outputs an array of pieces. The pieces do not include the elements along which the sequence was split." }
+{ $examples { $example "USING: ascii kernel prettyprint splitting ;" "\"hello,world-how.are:you\" [ letter? not ] split-when ." "{ \"hello\" \"world\" \"how\" \"are\" \"you\" }" } } ;
+
 HELP: split
 { $values { "seq" "a sequence" } { "separators" "a sequence" } { "pieces" "a new array" } }
-{ $description "Splits " { $snippet "seq" } " at each occurrence of an element of " { $snippet "separators" } ", and outputs an array of pieces. The pieces do not include the elements along which the sequence was split." }
+{ $description "Splits " { $snippet "seq" } " at each occurrence of an element of " { $snippet "separators" } " and outputs an array of pieces. The pieces do not include the elements along which the sequence was split." }
 { $examples { $example "USING: prettyprint splitting ;" "\"hello world-how are you?\" \" -\" split ." "{ \"hello\" \"world\" \"how\" \"are\" \"you?\" }" } } ;
 
 HELP: ?head
index ed68038fa6ddc5579c48fc0c93cda31cec0772ac..e672624d9677363893a7704648b205b431f761c6 100644 (file)
@@ -1,4 +1,4 @@
-USING: splitting tools.test kernel sequences arrays strings ;
+USING: splitting tools.test kernel sequences arrays strings ascii ;
 IN: splitting.tests
 
 [ "hello" "world ." ] [ "hello world ." " " split1 ] unit-test
@@ -57,3 +57,6 @@ unit-test
 [ { "hello" "hi" } ] [ "hello\nhi" string-lines ] unit-test
 [ { "hello" "hi" } ] [ "hello\rhi" string-lines ] unit-test
 [ { "hello" "hi" } ] [ "hello\r\nhi" string-lines ] unit-test
+
+[ { "hey" "world" "what's" "happening" } ]
+[ "heyAworldBwhat'sChappening" [ LETTER? ] split-when ] unit-test
index 7aae30f20b356667fab9f1ef25ee456ff7ecc93d..7b805dffe55a2b169b87821c5329e4ae2a36eb2d 100644 (file)
@@ -55,17 +55,21 @@ PRIVATE>
 
 <PRIVATE
 
-: (split) ( separators n seq -- )
-    3dup rot [ member? ] curry find-from drop
-    [ [ swap subseq , ] 2keep 1 + swap (split) ]
-    [ swap [ tail ] unless-zero , drop ] if* ; inline recursive
+: (split) ( n seq quot: ( elt -- ? ) -- )
+    [ find-from drop ]
+    [ [ [ 3dup swapd subseq , ] dip [ drop 1 + ] 2dip (split) ] 3curry ]
+    [ drop [ swap [ tail ] unless-zero , ] 2curry ]
+    3tri if* ; inline recursive
 
-: split, ( seq separators -- ) 0 rot (split) ;
+: split, ( seq quot -- ) [ 0 ] 2dip (split) ; inline
 
 PRIVATE>
 
 : split ( seq separators -- pieces )
-    [ split, ] { } make ;
+    [ [ member? ] curry split, ] { } make ;
+
+: split-when ( seq quot -- pieces )
+    [ split, ] { } make ; inline
 
 GENERIC: string-lines ( str -- seq )
 
index 689d88be7156cc2c1b60ad09df47e4cf5456f3ce..b90d96a356e0809616fa2d87c698139d8c747307 100644 (file)
@@ -116,5 +116,5 @@ unit-test
         drop
         300 100 CHAR: \u123456
         [ <string> clone resize-string first ] keep =
-    ] all?
+    ] all-integers?
 ] unit-test
index ba9411fac69ccf41cd2952226807398f7549ee87..8ef3b3e42a4b5b9960ba27869705e39b4bbd3379 100644 (file)
@@ -16,9 +16,10 @@ ARTICLE: "system" "System interface"
 }
 "Getting the current time:"
 { $subsections
-    micros
-    millis
+    system-micros
 }
+"Getting a monotonically increasing nanosecond count:"
+{ $subsections nano-count }
 "Exiting the Factor VM:"
 { $subsections exit } ;
 
@@ -77,15 +78,15 @@ HELP: exit ( n -- )
 { $values { "n" "an integer exit code" } }
 { $description "Exits the Factor process." } ;
 
-HELP: micros ( -- us )
+HELP: system-micros ( -- us )
 { $values { "us" integer } }
-{ $description "Outputs the number of microseconds ellapsed since midnight January 1, 1970." }
-{ $notes "This is a low-level word. The " { $vocab-link "calendar" } " vocabulary provides features for date/time arithmetic and formatting." } ;
+{ $description "Outputs the number of microseconds elapsed since midnight January 1, 1970." }
+{ $notes "This is a low-level word. The " { $vocab-link "calendar" } " vocabulary provides features for date/time arithmetic and formatting. For timing code, use " { $link nano-count } "." } ;
 
-HELP: millis ( -- ms )
-{ $values { "ms" integer } }
-{ $description "Outputs the number of milliseconds ellapsed since midnight January 1, 1970." }
-{ $notes "This is a low-level word. The " { $vocab-link "calendar" } " vocabulary provides features for date/time arithmetic and formatting." } ;
+HELP: nano-count ( -- ns )
+{ $values { "ns" integer } }
+{ $description "Outputs a monotonically increasing count of nanoseconds elapsed since an arbitrary starting time. The difference of two calls to this word allows timing. This word is unaffected by system clock changes." }
+{ $notes "This is a low-level word. The " { $vocab-link "tools.time" } " vocabulary defines words to time code execution time. For system time, use " { $link system-micros } "." } ;
 
 HELP: image
 { $values { "path" "a pathname string" } }
index 38b4a5fd9bb5d9473d093856e31aa78edff8ef7b..715564c64dcf8c91cd8bd965890fb1ec2549b09a 100644 (file)
@@ -53,6 +53,6 @@ PRIVATE>
 
 : vm ( -- path ) \ vm get-global ;
 
-: embedded? ( -- ? ) 15 getenv ;
+: embedded? ( -- ? ) 15 special-object ;
 
-: millis ( -- ms ) micros 1000 /i ;
+: exit ( n -- ) do-shutdown-hooks (exit) ;
index 9052638e7da914b9e41c0b1e4a8d2d5b45c4388a..8f644963bf0594cc33c12144eb3a20a19256dbbf 100644 (file)
@@ -91,11 +91,11 @@ IN: vectors.tests
 [ 4 ] [ 5 V{ 1 2 3 4 5 } index ] unit-test
 
 [ t ] [
-    100 >array dup >vector <reversed> >array [ reverse ] dip =
+    100 iota >array dup >vector <reversed> >array [ reverse ] dip =
 ] unit-test
 
 [ fixnum ] [ 1 >bignum V{ } new-sequence length class ] unit-test
 
-[ fixnum ] [ 1 >bignum [ ] V{ } map-as length class ] unit-test
+[ fixnum ] [ 1 >bignum iota [ ] V{ } map-as length class ] unit-test
 
 [ V{ "lulz" } ] [ "lulz" 1vector ] unit-test
index 352ccdebd45fa2d864265aabc59819aec54cafbe..02a604ac320cdc9bc8c3610386f1ea390e2c65d6 100644 (file)
@@ -102,7 +102,7 @@ HELP: load-docs
 
 HELP: reload
 { $values { "name" "a vocabulary name" } }
-{ $description "Loads it's source code and documentation." }
+{ $description "Reloads the source code and documentation for a vocabulary." }
 { $errors "Throws a " { $link no-vocab } " error if the vocabulary does not exist on disk." } ;
 
 HELP: require
old mode 100755 (executable)
new mode 100644 (file)
index d88761db1fade3ff2b9e6c8054f722f7699e98ff..5722575ffdab0c75ccedcb781044e22ca7db2f57 100644 (file)
@@ -133,8 +133,8 @@ $nl
 ARTICLE: "word.private" "Word implementation details"
 "The " { $snippet "def" } " slot of a word holds a " { $link quotation } " instance that is called when the word is executed."
 $nl
-"An " { $emphasis "XT" } " (execution token) is the machine code address of a word:"
-{ $subsections word-xt } ;
+"A primitive to get the memory range storing the machine code for a word:"
+{ $subsections word-code } ;
 
 ARTICLE: "words.introspection" "Word introspection"
 "Word introspection facilities and implementation details are found in the " { $vocab-link "words" } " vocabulary."
@@ -209,9 +209,9 @@ HELP: remove-word-prop
 { $description "Removes a word property, so future lookups will output " { $link f } " until it is set again. Word property names are conventionally strings." }
 { $side-effects "word" } ;
 
-HELP: word-xt ( word -- start end )
+HELP: word-code ( word -- start end )
 { $values { "word" word } { "start" "the word's start address" } { "end" "the word's end address" } }
-{ $description "Outputs the machine code address of the word's definition." } ;
+{ $description "Outputs the memory range containing the word's machine code." } ;
 
 HELP: define
 { $values { "word" word } { "def" quotation } }
@@ -238,7 +238,8 @@ $low-level-note
 
 HELP: <word> ( name vocab -- word )
 { $values { "name" string } { "vocab" string } { "word" word } }
-{ $description "Allocates an uninterned word with the specified name and vocabulary, and a blank word property hashtable. User code should call " { $link gensym } " to create uninterned words and " { $link create } " to create interned words." } ;
+{ $description "Allocates an uninterned word with the specified name and vocabulary, and a blank word property hashtable. User code should call " { $link gensym } " to create uninterned words and " { $link create } " to create interned words." }
+{ $notes "This word must be called from inside " { $link with-compilation-unit } "." } ;
 
 HELP: gensym
 { $values { "word" word } }
@@ -279,12 +280,14 @@ HELP: check-create
 
 HELP: create
 { $values { "name" string } { "vocab" string } { "word" word } }
-{ $description "Creates a new word. If the vocabulary already contains a word with the requested name, outputs the existing word. The vocabulary must exist already; if it does not, you must call " { $link create-vocab } " first." } ;
+{ $description "Creates a new word. If the vocabulary already contains a word with the requested name, outputs the existing word. The vocabulary must exist already; if it does not, you must call " { $link create-vocab } " first." }
+{ $notes "This word must be called from inside " { $link with-compilation-unit } ". Parsing words should call " { $link create-in } " instead of this word." } ;
 
 HELP: constructor-word
 { $values { "name" string } { "vocab" string } { "word" word } }
 { $description "Creates a new word, surrounding " { $snippet "name" } " in angle brackets." }
-{ $examples { $example "USING: prettyprint words ;" "\"salmon\" \"scratchpad\" constructor-word ." "<salmon>" } } ;
+{ $notes "This word must be called from inside " { $link with-compilation-unit } "." }
+{ $examples { $example "USING: compiler.units prettyprint words ;" "[ \"salmon\" \"scratchpad\" constructor-word ] with-compilation-unit ." "<salmon>" } } ;
 
 { POSTPONE: FORGET: forget forget* forget-vocab } related-words
 
old mode 100755 (executable)
new mode 100644 (file)
index b9d6e80..4f30e9a
@@ -1,7 +1,7 @@
 USING: arrays generic assocs kernel math namespaces
 sequences tools.test words definitions parser quotations
 vocabs continuations classes.tuple compiler.units
-io.streams.string accessors eval words.symbol ;
+io.streams.string accessors eval words.symbol grouping ;
 IN: words.tests
 
 [ 4 ] [
@@ -25,7 +25,8 @@ DEFER: plist-test
     \ plist-test "sample-property" word-prop
 ] unit-test
 
-"create-test" "scratchpad" create { 1 2 } "testing" set-word-prop
+[ ] [ [ "create-test" "scratchpad" create { 1 2 } "testing" set-word-prop ] with-compilation-unit ] unit-test
+
 [ { 1 2 } ] [
     "create-test" "scratchpad" lookup "testing" word-prop
 ] unit-test
@@ -33,7 +34,7 @@ DEFER: plist-test
 [
     [ t ] [ \ array? "array?" "arrays" lookup = ] unit-test
 
-    [ ] [ "test-scope" "scratchpad" create drop ] unit-test
+    [ ] [ [ "test-scope" "scratchpad" create drop ] with-compilation-unit ] unit-test
 ] with-scope
 
 [ "test-scope" ] [
@@ -67,7 +68,7 @@ FORGET: another-forgotten
 DEFER: x
 [ x ] [ undefined? ] must-fail-with
 
-[ ] [ "no-loc" "words.tests" create drop ] unit-test
+[ ] [ [ "no-loc" "words.tests" create drop ] with-compilation-unit ] unit-test
 [ f ] [ "no-loc" "words.tests" lookup where ] unit-test
 
 [ ] [ "IN: words.tests : no-loc-2 ( -- ) ;" eval( -- ) ] unit-test
@@ -121,9 +122,9 @@ DEFER: x
 [ { } ]
 [
     all-words [
-        "compiled-uses" word-prop
+        "compiled-uses" word-prop 2 <groups>
         keys [ "forgotten" word-prop ] filter
     ] map harvest
 ] unit-test
 
-[ "hi" word-xt ] must-fail
+[ "hi" word-code ] must-fail
old mode 100755 (executable)
new mode 100644 (file)
index 45e014f..271dd55
@@ -1,9 +1,9 @@
-! Copyright (C) 2004, 2009 Slava Pestov.
+! Copyright (C) 2004, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors arrays definitions graphs kernel
-kernel.private slots.private math namespaces sequences
-strings vectors sbufs quotations assocs hashtables sorting vocabs
-math.order sets words.private ;
+USING: accessors arrays definitions kernel kernel.private
+slots.private math namespaces sequences strings vectors sbufs
+quotations assocs hashtables sorting vocabs math.order sets
+words.private ;
 IN: words
 
 : word ( -- word ) \ word get-global ;
@@ -21,20 +21,6 @@ M: word definer drop \ : \ ; ;
 
 M: word definition def>> ;
 
-ERROR: undefined ;
-
-PREDICATE: deferred < word ( obj -- ? )
-    def>> [ undefined ] = ;
-M: deferred definer drop \ DEFER: f ;
-M: deferred definition drop f ;
-
-PREDICATE: primitive < word ( obj -- ? )
-    [ def>> [ do-primitive ] tail? ]
-    [ sub-primitive>> >boolean ]
-    bi or ;
-M: primitive definer drop \ PRIMITIVE: f ;
-M: primitive definition drop f ;
-
 : word-prop ( word name -- value ) swap props>> at ;
 
 : remove-word-prop ( word name -- ) swap props>> delete-at ;
@@ -46,6 +32,16 @@ M: primitive definition drop f ;
 
 : reset-props ( word seq -- ) [ remove-word-prop ] with each ;
 
+ERROR: undefined ;
+
+PREDICATE: deferred < word ( obj -- ? ) def>> [ undefined ] = ;
+M: deferred definer drop \ DEFER: f ;
+M: deferred definition drop f ;
+
+PREDICATE: primitive < word ( obj -- ? ) "primitive" word-prop ;
+M: primitive definer drop \ PRIMITIVE: f ;
+M: primitive definition drop f ;
+
 : lookup ( name vocab -- word ) vocab-words at ;
 
 : target-word ( word -- target )
@@ -64,41 +60,6 @@ GENERIC: crossref? ( word -- ? )
 M: word crossref?
     dup "forgotten" word-prop [ drop f ] [ vocabulary>> >boolean ] if ;
 
-SYMBOL: compiled-crossref
-
-compiled-crossref [ H{ } clone ] initialize
-
-SYMBOL: compiled-generic-crossref
-
-compiled-generic-crossref [ H{ } clone ] initialize
-
-: (compiled-xref) ( word dependencies word-prop variable -- )
-    [ [ set-word-prop ] curry ]
-    [ [ get add-vertex* ] curry ]
-    bi* 2bi ;
-
-: compiled-xref ( word dependencies generic-dependencies -- )
-    [ [ drop crossref? ] { } assoc-filter-as f like ] bi@
-    [ "compiled-uses" compiled-crossref (compiled-xref) ]
-    [ "compiled-generic-uses" compiled-generic-crossref (compiled-xref) ]
-    bi-curry* bi ;
-
-: (compiled-unxref) ( word word-prop variable -- )
-    [ [ [ dupd word-prop ] dip get remove-vertex* ] 2curry ]
-    [ drop [ remove-word-prop ] curry ]
-    2bi bi ;
-
-: compiled-unxref ( word -- )
-    [ "compiled-uses" compiled-crossref (compiled-unxref) ]
-    [ "compiled-generic-uses" compiled-generic-crossref (compiled-unxref) ]
-    bi ;
-
-: delete-compiled-xref ( word -- )
-    [ compiled-unxref ]
-    [ compiled-crossref get delete-at ]
-    [ compiled-generic-crossref get delete-at ]
-    tri ;
-
 : inline? ( word -- ? ) "inline" word-prop ; inline
 
 GENERIC: subwords ( word -- seq )
@@ -170,10 +131,13 @@ M: word reset-word
     ] tri ;
 
 : <word> ( name vocab -- word )
-    2dup [ hashcode ] bi@ bitxor >fixnum (word) ;
+    2dup [ hashcode ] bi@ bitxor >fixnum (word) dup new-word ;
+
+: <uninterned-word> ( name -- word )
+    f \ <uninterned-word> counter >fixnum (word) ;
 
 : gensym ( -- word )
-    "( gensym )" f \ gensym counter >fixnum (word) ;
+    "( gensym )" <uninterned-word> ;
 
 : define-temp ( quot effect -- word )
     [ gensym dup ] 2dip define-declared ;
index 15c610ce7a6a5e5086ab23848730666e99097d3e..28600b6c48667452795f794d4138ee6d3892699b 100644 (file)
@@ -56,7 +56,7 @@ DEFER: check-status
         [ end-game ] 
         [ dup quit? [ quit-game ] [ repeat ] if ]
     if ;
-: build-quad ( -- array ) 4 [ 10 random ] replicate >array ;
+: build-quad ( -- array ) 4 [ 10 random ] replicate ;
 : 24-able? ( quad -- t/f ) [ makes-24? ] with-datastack first ;
 : 24-able ( -- vector ) build-quad dup 24-able? [ drop build-quad ] unless ;
 : set-commands ( -- ) { + - * / rot swap q } commands set ;
index 7a492ab0c56e8e0a89dd25895d0ef7bd003794b4..305ae6bdf236f4b7b2d07d23bd1e58218968abad 100644 (file)
@@ -1,9 +1,8 @@
 ! (c)Joe Groff bsd license
 USING: alien.data.map fry generalizations kernel locals math.vectors
-math.vectors.conversion math math.vectors.simd sequences
+math.vectors.conversion math math.vectors.simd math.ranges sequences
 specialized-arrays tools.test ;
 FROM: alien.c-types => uchar short int float ;
-SIMDS: float int short uchar ;
 SPECIALIZED-ARRAYS: int float float-4 uchar-16 ;
 IN: alien.data.map.tests
 
@@ -146,3 +145,11 @@ CONSTANT: plane-count 4
     B{  15  25  35  45  55  65  75  85  95 105 115 125 135 145 155 165 }
     fold-rgba-planes
 ] unit-test
+
+: data-map-compiler-bug-test ( n -- byte-array )
+    [ 0.0 1.0 1.0 ] dip /f <range>
+    [ ] data-map( object -- float ) ;
+
+[ float-array{ 0.0 0.5 1.0 } ]
+[ 2 data-map-compiler-bug-test byte-array>float-array ]
+unit-test
diff --git a/extra/animations/animations-docs.factor b/extra/animations/animations-docs.factor
deleted file mode 100644 (file)
index 3e426a2..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-USING: help.markup help.syntax ;
-IN: animations
-
-HELP: animate ( quot duration -- )
-
-{ $values
-    { "quot" "a quot which uses " { $link progress } }
-    { "duration" "a duration of time" }
-}
-{ $description
-    { $link animate } " calls " { $link reset-progress }
-    " , then continously calls the given quot until the"
-    " duration of time has elapsed. The quot should use "
-    { $link progress } " at least once."
-}
-{ $examples
-    { $unchecked-example 
-        "USING: animations calendar threads prettyprint ;"
-        "[ 1 sleep progress unparse write \" ms elapsed\" print ] "
-        "1/20 seconds animate ;"
-        "46 ms elapsed\n17 ms elapsed"
-    }
-    { $notes "The amount of time elapsed between these iterations will very." }
-} ;
-
-HELP: reset-progress ( -- )
-{ $description
-    "Initiates the timer. Call this before using "
-    "a loop which makes use of " { $link progress } "."
-} ;
-
-HELP: progress
-{ $values { "time" "an integer" } }
-{ $description
-    "Gives the time elapsed since the last time"
-    " this word was called, in milliseconds." 
-}
-{ $examples
-    { $unchecked-example
-        "USING: animations threads prettyprint ;"
-        "reset-progress 3 "
-        "[ 1 sleep progress unparse write \"ms elapsed\" print ] "
-        "times ;"
-        "31 ms elapsed\n18 ms elapsed\n16 ms elapsed"
-    }
-    { $notes "The amount of time elapsed between these iterations will very." }
-} ;
-
-ARTICLE: "animations" "Animations"
-"Provides a lightweight framework for properly simulating continuous"
-" functions of real time. This framework helps one create animations "
-"that use rates which do not change across platforms. The speed of the "
-"computer should correlate with the smoothness of the animation, not "
-"the speed of the animation!"
-{ $subsections
-    animate
-    reset-progress
-    progress
-}
-! A little talk about when to use progress and when to use animate
-    { $link progress } " specifically provides the length of time since "
-    { $link reset-progress } " was called, and also calls "
-    { $link reset-progress } " as its last action. This can be directly "
-    "used when one's quote runs for a specific number of iterations, instead "
-    "of a length of time. If the animation is like most, and is expected to "
-    "run for a specific length of time, " { $link animate } " should be used." ;
-ABOUT: "animations"
\ No newline at end of file
diff --git a/extra/animations/animations.factor b/extra/animations/animations.factor
deleted file mode 100644 (file)
index 8f416dc..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-! Small library for cross-platform continuous functions of real time
-
-USING: kernel shuffle system locals
-prettyprint math io namespaces threads calendar ;
-IN: animations
-
-SYMBOL: last-loop
-SYMBOL: sleep-period
-
-: reset-progress ( -- ) millis last-loop set ;
-! : my-progress ( -- progress ) millis 
-: progress ( -- time ) millis last-loop get - reset-progress ;
-: progress-peek ( -- progress ) millis last-loop get - ;
-: set-end ( duration -- end-time ) duration>milliseconds millis + ;
-: loop ( quot end -- ) dup millis > [ [ dup call ] dip loop ] [ 2drop ] if ; inline
-: animate ( quot duration -- ) reset-progress set-end loop ; inline
-: sample ( revs quot -- avg ) reset-progress dupd times progress swap / ; inline
diff --git a/extra/animations/authors.txt b/extra/animations/authors.txt
deleted file mode 100644 (file)
index 137b160..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Reginald Ford
\ No newline at end of file
old mode 100755 (executable)
new mode 100644 (file)
diff --git a/extra/audio/aiff/aiff.factor b/extra/audio/aiff/aiff.factor
new file mode 100644 (file)
index 0000000..5491340
--- /dev/null
@@ -0,0 +1,86 @@
+! (c)2009 Joe Groff bsd license
+USING: accessors alien alien.c-types alien.data audio
+audio.chunked-file classes.struct combinators
+combinators.short-circuit endian io io.binary
+io.encodings.binary io.files kernel locals math sequences
+audio.loader ;
+IN: audio.aiff
+
+CONSTANT: FORM-MAGIC "FORM"
+CONSTANT: AIFF-MAGIC "AIFF"
+CONSTANT: COMM-MAGIC "COMM"
+CONSTANT: SSND-MAGIC "SSND"
+
+STRUCT: aiff-chunk-header
+    { id char[4] }
+    { size char[4] } ;
+
+STRUCT: form-chunk
+    { header aiff-chunk-header }
+    { form-type char[4] } ;
+
+STRUCT: common-chunk
+    { header aiff-chunk-header }
+    { num-channels uchar[2] }
+    { num-sample-frames uchar[4] }
+    { sample-size uchar[2] }
+    { sample-rate uchar[10] } ;
+
+STRUCT: sound-data-chunk
+    { header aiff-chunk-header }
+    { offset uchar[4] }
+    { block-size uchar[4] }
+    { waveform-data uchar[0] } ;
+
+! cheesy long-double>integer converter that assumes the long double is a positive integer
+: sample-rate>integer ( byte[10] -- sample-rate )
+    [ 2 tail-slice be> ]
+    [ 2 head-slice be> 16383 - 63 - ] bi shift ;
+
+: read-form-chunk ( -- byte-array/f )
+    form-chunk heap-size ensured-read* ;
+
+: verify-aiff ( chunk -- )
+    {
+        [ FORM-MAGIC id= ]
+        [ form-chunk memory>struct form-type>> 4 memory>byte-array AIFF-MAGIC id= ] 
+    } 1&&
+    [ invalid-audio-file ] unless ;
+
+:: read-aiff-chunks ( -- comm ssnd )
+    f :> comm! f :> ssnd!
+    [ { [ comm ssnd and not ] [ read-chunk ] } 0&& dup ]
+    [ {
+        {
+            [ dup COMM-MAGIC common-chunk check-chunk ]
+            [ common-chunk memory>struct comm! ]
+        }
+        {
+            [ dup SSND-MAGIC sound-data-chunk check-chunk ]
+            [ sound-data-chunk memory>struct ssnd! ]
+        }
+        [ drop ]
+    } cond ] while drop
+    comm ssnd 2dup and [ invalid-audio-file ] unless ;
+
+: (read-aiff) ( -- audio )
+    read-aiff-chunks
+    [
+        [ num-channels>>    2 memory>byte-array be> ]
+        [ sample-size>>     2 memory>byte-array be> ]
+        [ sample-rate>>     sample-rate>integer ] tri
+    ] [
+        [ header>> size>> 4 memory>byte-array be> 8 - dup ]
+        [ waveform-data>> >c-ptr ] bi swap memory>byte-array
+    ] bi*
+    <audio> convert-data-endian ;
+
+: read-aiff ( filename -- audio )
+    big-endian [
+        binary [
+            read-form-chunk verify-aiff (read-aiff)
+        ] with-file-reader
+    ] with-endianness ;
+
+"aif"  [ read-aiff ] register-audio-extension
+"aiff" [ read-aiff ] register-audio-extension
diff --git a/extra/audio/chunked-file/chunked-file.factor b/extra/audio/chunked-file/chunked-file.factor
new file mode 100644 (file)
index 0000000..a450790
--- /dev/null
@@ -0,0 +1,28 @@
+! (c)2009 Joe Groff bsd license
+USING: accessors alien.c-types combinators endian io kernel
+math sequences ;
+IN: audio.chunked-file
+
+ERROR: invalid-audio-file ;
+
+: ensured-read ( count -- output/f )
+    [ read ] keep over length = [ drop f ] unless ;
+: ensured-read* ( count -- output )
+    ensured-read [ invalid-audio-file ] unless* ;
+
+: read-chunk ( -- byte-array/f )
+    4 ensured-read [ 4 ensured-read* dup endian> ensured-read* 3append ] [ f ] if* ;
+
+: id= ( chunk id -- ? )
+    [ 4 head ] dip sequence= ; inline
+
+: convert-data-endian ( audio -- audio )
+    dup sample-bits>> {
+        { 16 [ [ 2 seq>native-endianness ] change-data ] }
+        { 32 [ [ 4 seq>native-endianness ] change-data ] }
+        [ drop ]
+    } case ;
+
+: check-chunk ( chunk id class -- ? )
+    heap-size [ id= ] [ [ length ] dip >= ] bi-curry* bi and ;
+
diff --git a/extra/audio/engine/engine.factor b/extra/audio/engine/engine.factor
new file mode 100644 (file)
index 0000000..176fc3c
--- /dev/null
@@ -0,0 +1,322 @@
+! (c)2009 Joe Groff bsd license
+USING: accessors alien audio classes.struct fry calendar alarms
+combinators combinators.short-circuit destructors generalizations
+kernel literals locals math openal sequences specialized-arrays strings ;
+QUALIFIED-WITH: alien.c-types c
+SPECIALIZED-ARRAYS: c:float c:uchar c:uint ;
+IN: audio.engine
+
+TUPLE: audio-source
+    { position initial: { 0.0 0.0 0.0 } }
+    { gain float initial: 1.0 }
+    { velocity initial: { 0.0 0.0 0.0 } }
+    { relative? boolean initial: f }
+    { distance float initial: 1.0 }
+    { rolloff float initial: 1.0 } ;
+
+TUPLE: audio-orientation
+    { forward initial: { 0.0 0.0 -1.0 } }
+    { up initial: { 0.0 1.0 0.0 } } ;
+
+C: <audio-orientation> audio-orientation
+
+: orientation>float-array ( orientation -- float-array )
+    [ forward>> first3 ]
+    [ up>> first3 ] bi 6 float-array{ } nsequence ; inline
+
+TUPLE: audio-listener
+    { position initial: { 0.0 0.0 0.0 } }
+    { gain float initial: 1.0 }
+    { velocity initial: { 0.0 0.0 0.0 } }
+    { orientation initial: T{ audio-orientation } } ;
+
+GENERIC: audio-position ( source/listener -- position )
+GENERIC: audio-gain ( source/listener -- gain )
+GENERIC: audio-velocity ( source/listener -- velocity )
+GENERIC: audio-relative? ( source -- relative? )
+GENERIC: audio-distance ( source -- distance )
+GENERIC: audio-rolloff ( source -- rolloff )
+GENERIC: audio-orientation ( listener -- orientation )
+
+M: object audio-position drop { 0.0 0.0 0.0 } ; inline
+M: object audio-gain drop 1.0 ; inline
+M: object audio-velocity drop { 0.0 0.0 0.0 } ; inline
+M: object audio-relative? drop f ; inline
+M: object audio-distance drop 1.0 ; inline
+M: object audio-rolloff drop 1.0 ; inline
+M: object audio-orientation drop T{ audio-orientation } ; inline
+
+M: audio-source audio-position position>> ; inline
+M: audio-source audio-gain gain>> ; inline
+M: audio-source audio-velocity velocity>> ; inline
+M: audio-source audio-relative? relative?>> ; inline
+
+M: audio-listener audio-position position>> ; inline
+M: audio-listener audio-gain gain>> ; inline
+M: audio-listener audio-velocity velocity>> ; inline
+M: audio-listener audio-orientation orientation>> ; inline
+
+TUPLE: audio-engine < disposable
+    { voice-count integer }
+    { buffer-size integer }
+    { buffer-count integer }
+    { al-device c-ptr }
+    { al-context c-ptr }
+    al-sources
+    listener
+    { next-source integer }
+    clips
+    update-alarm ;
+
+TUPLE: audio-clip < disposable
+    { audio-engine audio-engine }
+    { audio audio }
+    source
+    { loop? boolean }
+    { al-source integer }
+    { al-buffers uint-array }
+    { next-data-offset integer } ;
+
+ERROR: audio-device-not-found device-name ;
+ERROR: audio-context-not-available device-name ;
+
+:: <audio-engine> ( device-name voice-count buffer-size buffer-count -- engine )
+    [
+        device-name alcOpenDevice :> al-device
+        al-device [ device-name audio-device-not-found ] unless
+        al-device |alcCloseDevice* drop
+
+        al-device f alcCreateContext :> al-context
+        al-context [ device-name audio-context-not-available ] unless
+        al-context |alcDestroyContext drop
+
+        al-context alcSuspendContext
+
+        audio-engine new-disposable
+            voice-count >>voice-count
+            al-device >>al-device
+            al-context >>al-context
+            buffer-size >>buffer-size
+            buffer-count >>buffer-count
+    ] with-destructors ;
+
+: <standard-audio-engine> ( -- engine )
+    f 16 8192 2 <audio-engine> ;
+
+<PRIVATE
+
+: make-engine-current ( audio-engine -- )
+    al-context>> alcMakeContextCurrent drop ; inline
+
+: allocate-sources ( audio-engine -- sources )
+    voice-count>> dup (uint-array) [ alGenSources ] keep ; inline
+
+:: flush-source ( source -- )
+    source alSourceStop
+    0 c:<uint> :> dummy-buffer
+    source AL_BUFFERS_PROCESSED get-source-param [
+        source 1 dummy-buffer alSourceUnqueueBuffers
+    ] times ;
+
+: free-sources ( sources -- )
+    [ length ] keep alDeleteSources ; inline
+
+:: (get-available-source) ( sources source# stop-source# -- next-source# al-source/f )
+    source# sources nth :> al-source
+    source# 1 + sources length mod :> next-source#
+    al-source {
+        [ AL_BUFFERS_PROCESSED get-source-param 0 = ]
+        [ AL_BUFFERS_QUEUED get-source-param 0 = ]
+        [ AL_SOURCE_STATE get-source-param { $ AL_INITIAL $ AL_STOPPED } member? ]
+    } 1&&
+    [ next-source# al-source ] [
+        next-source# stop-source# =
+        [ next-source# f ]
+        [ sources next-source# stop-source# (get-available-source) ] if
+    ] if ;
+
+:: get-available-source ( audio-engine -- al-source/f )
+    audio-engine [ al-sources>> ] [ next-source>> ] bi dup (get-available-source)
+        :> ( next-source al-source )
+    audio-engine next-source >>next-source drop
+    al-source ;
+
+:: (queue-clip-buffer) ( audio-clip al-buffer audio data size -- )
+    al-buffer audio openal-format data size audio sample-rate>> alBufferData
+    audio-clip al-source>> 1 al-buffer c:<uint> alSourceQueueBuffers
+
+    audio-clip [ size + ] change-next-data-offset drop ; inline
+
+:: queue-clip-buffer ( audio-clip al-buffer -- )
+    audio-clip audio-engine>> :> audio-engine
+    audio-engine buffer-size>> :> buffer-size
+    audio-clip audio>> :> audio
+    audio-clip next-data-offset>> :> next-data-offset
+    audio size>> next-data-offset - :> remaining-audio
+
+    {
+        { [ remaining-audio 0 <= ] [
+            audio-clip loop?>> [
+                audio-clip 0 >>next-data-offset
+                al-buffer queue-clip-buffer
+            ] when
+        ] }
+        { [ remaining-audio buffer-size < ] [
+            audio-clip loop?>> [
+                audio data>>
+                [ next-data-offset swap <displaced-alien> remaining-audio <direct-uchar-array> ]
+                [ buffer-size remaining-audio - <direct-uchar-array> ] bi append :> data
+                audio-clip al-buffer audio data buffer-size (queue-clip-buffer)
+
+                audio-clip [ audio size>> mod ] change-next-data-offset drop
+            ] [
+                next-data-offset audio data>> <displaced-alien> :> data
+                audio-clip al-buffer audio data remaining-audio (queue-clip-buffer)
+            ] if
+        ] }
+        [
+            next-data-offset audio data>> <displaced-alien> :> data
+            audio-clip al-buffer audio data buffer-size (queue-clip-buffer)
+        ]
+    } cond ;
+
+: update-listener ( audio-engine -- )
+    listener>> {
+        [ AL_POSITION swap audio-position first3 alListener3f ]
+        [ AL_GAIN swap audio-gain alListenerf ]
+        [ AL_VELOCITY swap audio-velocity first3 alListener3f ]
+        [ AL_ORIENTATION swap audio-orientation orientation>float-array alListenerfv ]
+    } cleave ;
+
+: update-source ( audio-clip -- )
+    [ al-source>> ] [ source>> ] bi {
+        [ AL_POSITION swap audio-position first3 alSource3f ]
+        [ AL_GAIN swap audio-gain alSourcef ]
+        [ AL_VELOCITY swap audio-velocity first3 alSource3f ]
+        [ AL_SOURCE_RELATIVE swap audio-relative? c:>c-bool alSourcei ]
+        [ AL_REFERENCE_DISTANCE swap audio-distance alSourcef ]
+        [ AL_ROLLOFF_FACTOR swap audio-rolloff alSourcef ]
+    } 2cleave ;
+
+:: update-audio-clip ( audio-clip -- )
+    audio-clip update-source
+    audio-clip al-source>> :> al-source
+    0 c:<uint> :> buffer*
+
+    al-source AL_SOURCE_STATE get-source-param AL_STOPPED =
+    [ audio-clip dispose ] [
+        al-source AL_BUFFERS_PROCESSED get-source-param [
+            al-source 1 buffer* alSourceUnqueueBuffers
+            audio-clip buffer* c:*uint queue-clip-buffer
+        ] times
+    ] if ;
+
+: clip-al-sources ( clips -- length sources )
+    [ length ] [ [ al-source>> ] uint-array{ } map-as ] bi ;
+
+PRIVATE>
+
+DEFER: update-audio
+
+: start-audio* ( audio-engine -- )
+    dup al-sources>> [ drop ] [
+        {
+            [ make-engine-current ]
+            [ al-context>> alcProcessContext ]
+            [
+                dup allocate-sources >>al-sources
+                0 >>next-source
+                V{ } clone >>clips
+                drop
+            ]
+            [ update-listener ]
+        } cleave
+    ] if ;
+
+: start-audio ( audio-engine -- )
+    dup start-audio*
+    dup '[ _ update-audio ] 20 milliseconds every >>update-alarm
+    drop ;
+
+: stop-audio ( audio-engine -- )
+    dup al-sources>> [
+        {
+            [ make-engine-current ]
+            [ update-alarm>> [ cancel-alarm ] when* ]
+            [ clips>> clone [ dispose ] each ]
+            [ al-sources>> free-sources ]
+            [
+                f >>al-sources
+                f >>clips
+                f >>update-alarm
+                drop
+            ]
+            [ al-context>> alcSuspendContext ]
+        } cleave
+    ] [ drop ] if ;
+
+M: audio-engine dispose*
+    dup stop-audio
+    [ [ alcDestroyContext ] when* f ] change-al-context
+    [ [ alcCloseDevice*   ] when* f ] change-al-device
+    drop ;
+
+:: (audio-clip) ( audio-engine audio source loop? -- audio-clip/f )
+    audio-engine get-available-source :> al-source
+
+    al-source [
+        audio-engine buffer-count>> :> buffer-count
+        buffer-count dup (uint-array) [ alGenBuffers ] keep :> al-buffers
+
+        audio-clip new-disposable
+            audio-engine >>audio-engine
+            audio >>audio
+            source >>source
+            loop? >>loop?
+            al-source >>al-source
+            al-buffers >>al-buffers
+            0 >>next-data-offset :> clip
+        al-buffers [ clip swap queue-clip-buffer ] each
+        clip audio-engine clips>> push
+
+        clip
+    ] [ f ] if ;
+
+M: audio-clip dispose*
+    {
+        [ al-source>> flush-source ]
+        [ al-buffers>> [ length ] keep alDeleteBuffers ]
+        [ dup audio-engine>> clips>> remove! drop ]
+    } cleave ;
+
+: play-clip ( audio-clip -- )
+    [ update-source ]
+    [ al-source>> alSourcePlay ] bi ;
+
+: play-clips ( audio-clips -- )
+    [ [ update-source ] each ]
+    [ clip-al-sources alSourcePlayv ] bi ;
+
+: <audio-clip> ( audio-engine audio source loop? -- audio-clip/f )
+    (audio-clip) dup play-clip ;
+
+: pause-clip ( audio-clip -- )
+    al-source>> alSourcePause ;
+
+: pause-clips ( audio-clip -- )
+    clip-al-sources alSourcePausev ;
+
+: stop-clip ( audio-clip -- )
+    dispose ;
+
+: stop-clips ( audio-clip -- )
+    [ clip-al-sources alSourceStopv ]
+    [ [ dispose ] each ] bi ;
+
+: update-audio ( audio-engine -- )
+    {
+        [ make-engine-current ]
+        [ update-listener ]
+        [ clips>> clone [ update-audio-clip ] each ]
+    } cleave ;
+
diff --git a/extra/audio/engine/test/loop.aiff b/extra/audio/engine/test/loop.aiff
new file mode 100644 (file)
index 0000000..d745e5d
Binary files /dev/null and b/extra/audio/engine/test/loop.aiff differ
diff --git a/extra/audio/engine/test/once.wav b/extra/audio/engine/test/once.wav
new file mode 100644 (file)
index 0000000..3fc85b0
Binary files /dev/null and b/extra/audio/engine/test/once.wav differ
diff --git a/extra/audio/engine/test/test.factor b/extra/audio/engine/test/test.factor
new file mode 100644 (file)
index 0000000..59834a9
--- /dev/null
@@ -0,0 +1,33 @@
+! (c)2009 Joe Groff bsd license
+USING: accessors alarms audio audio.engine audio.loader calendar
+destructors io kernel locals math math.functions ;
+IN: audio.engine.test
+
+:: audio-engine-test ( -- )
+    "vocab:audio/engine/test/loop.aiff" read-audio :> loop-sound
+    "vocab:audio/engine/test/once.wav" read-audio :> once-sound
+    0 :> i!
+    <standard-audio-engine> :> engine
+    engine start-audio*
+    engine loop-sound T{ audio-source f { 1.0 0.0 0.0 } 1.0 { 0.0 0.0 0.0 } f } t <audio-clip>
+        :> loop-clip
+
+    [
+        i 1 + i!
+        i 0.05 * sin :> s
+        loop-clip source>> { s 0.0 0.0 } >>position drop
+
+        i 50 mod zero? [
+            engine once-sound T{ audio-source f { 0.0 0.0 0.0 } 1.0 { 0.0 0.0 0.0 } f } f
+            <audio-clip> drop
+        ] when
+
+        engine update-audio
+    ] 20 milliseconds every :> alarm
+    "Press Enter to stop the test." print
+    readln drop
+    alarm cancel-alarm
+    engine dispose ;
+
+
+MAIN: audio-engine-test
diff --git a/extra/audio/loader/loader.factor b/extra/audio/loader/loader.factor
new file mode 100644 (file)
index 0000000..fb2c6a0
--- /dev/null
@@ -0,0 +1,20 @@
+! (c)2009 Joe Groff bsd license
+USING: ascii assocs io.pathnames kernel namespaces
+vocabs.loader ;
+IN: audio.loader
+
+ERROR: unknown-audio-extension extension ;
+
+SYMBOL: audio-types
+audio-types [ H{ } clone ] initialize
+
+: register-audio-extension ( extension quot -- )
+    swap audio-types get set-at ;
+
+: read-audio ( path -- audio )
+    dup file-extension >lower audio-types get ?at
+    [ call( path -- audio ) ]
+    [ unknown-audio-extension ] if ;
+
+"audio.wav" require
+"audio.aiff" require
index 89cd04ad60edff3ca6b916d3c5d79d73b2f17ac1..0a5c242db8c36b31939b51998671caf60e4df0a6 100644 (file)
@@ -1,7 +1,9 @@
-USING: alien.c-types alien.syntax audio combinators
+! (c)2009 Joe Groff bsd license
+USING: alien.c-types alien.syntax audio combinators endian
 combinators.short-circuit io io.binary io.encodings.binary
 io.files io.streams.byte-array kernel locals math
-sequences alien alien.data classes.struct accessors ;
+sequences alien alien.data classes.struct accessors
+audio.chunked-file audio.loader ;
 IN: audio.wav
 
 CONSTANT: RIFF-MAGIC "RIFF"
@@ -30,39 +32,25 @@ STRUCT: wav-data-chunk
     { header riff-chunk-header }
     { body uchar[0] } ;
 
-ERROR: invalid-wav-file ;
-
-: ensured-read ( count -- output/f )
-    [ read ] keep over length = [ drop f ] unless ;
-: ensured-read* ( count -- output )
-    ensured-read [ invalid-wav-file ] unless* ;
-
-: read-chunk ( -- byte-array/f )
-    4 ensured-read [ 4 ensured-read* dup le> ensured-read* 3append ] [ f ] if* ;
 : read-riff-chunk ( -- byte-array/f )
     riff-chunk heap-size ensured-read* ;
 
-: id= ( chunk id -- ? )
-    [ 4 head ] dip sequence= ; inline
-
-: check-chunk ( chunk id class -- ? )
-    heap-size [ id= ] [ [ length ] dip >= ] bi-curry* bi and ;
-
 :: read-wav-chunks ( -- fmt data )
     f :> fmt! f :> data!
     [ { [ fmt data and not ] [ read-chunk ] } 0&& dup ]
     [ {
         { [ dup FMT-MAGIC  wav-fmt-chunk  check-chunk ] [ wav-fmt-chunk  memory>struct fmt!  ] }
         { [ dup DATA-MAGIC wav-data-chunk check-chunk ] [ wav-data-chunk memory>struct data! ] }
+        [ drop ]
     } cond ] while drop
-    fmt data 2dup and [ invalid-wav-file ] unless ;
+    fmt data 2dup and [ invalid-audio-file ] unless ;
 
 : verify-wav ( chunk -- )
     {
         [ RIFF-MAGIC id= ]
         [ riff-chunk memory>struct format>> 4 memory>byte-array WAVE-MAGIC id= ]
     } 1&&
-    [ invalid-wav-file ] unless ;
+    [ invalid-audio-file ] unless ;
 
 : (read-wav) ( -- audio )
     read-wav-chunks
@@ -73,9 +61,14 @@ ERROR: invalid-wav-file ;
     ] [
         [ header>> size>> 4 memory>byte-array le> dup ]
         [ body>> >c-ptr ] bi swap memory>byte-array
-    ] bi* <audio> ;
+    ] bi*
+    <audio> convert-data-endian ;
 
 : read-wav ( filename -- audio )
-    binary [
-        read-riff-chunk verify-wav (read-wav)
-    ] with-file-reader ;
+    little-endian [
+        binary [
+            read-riff-chunk verify-wav (read-wav)
+        ] with-file-reader
+    ] with-endianness ;
+
+"wav" [ read-wav ] register-audio-extension
old mode 100755 (executable)
new mode 100644 (file)
index 31a4b75eb2e985bddb92e7b55d992bd2671c0f92..a379a03828a227d7269b5befdda8e5ce050e4b22 100644 (file)
@@ -63,7 +63,7 @@ C: <transaction> transaction
 
 : process-to-date ( account date -- account )
     over interest-last-paid>> 1 days time+
-    [ dupd process-day ] spin each-day ;
+    [ [ dupd process-day ] ] 2dip swap each-day ;
 
 : inserting-transactions ( account transactions -- account )
     [ [ date>> process-to-date ] keep >>transaction ] each ;
index 1b57bb902f27882db31e11b53095a648d716c6f5..563bf4558ce8648b5db9fb83f99427935c92c233 100644 (file)
@@ -1,7 +1,6 @@
 USING: kernel locals math math.matrices.simd math.order math.vectors
 math.vectors.simd prettyprint sequences typed ;
 QUALIFIED-WITH: alien.c-types c
-SIMD: c:float
 IN: benchmark.3d-matrix-vector
 
 : v2min ( xy -- xx )
old mode 100755 (executable)
new mode 100644 (file)
index 350a29f8659db7b5430cd8c5ac5c521f2cdaf416..95202f35f984f75e8a51d14a34008ca52f2cdaeb 100644 (file)
@@ -4,7 +4,7 @@ USING: math sequences kernel base64 ;
 IN: benchmark.base64
 
 : base64-benchmark ( -- )
-    65535 [ 255 bitand ] "" map-as
+    65535 iota [ 255 bitand ] "" map-as
     20 [ >base64 base64> ] times
     drop ;
 
old mode 100755 (executable)
new mode 100644 (file)
index ee9285a..ebffd4a
@@ -46,7 +46,7 @@ PRIVATE>
         [
             [
                 [ [ 1array $vocab-link ] with-cell ]
-                [ 1000000 /f pprint-cell ]
+                [ 1,000,000,000 /f pprint-cell ]
                 bi*
             ] with-row
         ] assoc-each
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 31c202b803716a6d1a02a088b3f93ab9e6573754..839bd89dc06792a632fdfc01b3f44e1c547d0011 100644 (file)
@@ -8,7 +8,7 @@ IN: benchmark.dawes
 : count-ones ( int-array -- n ) [ 1 = ] count ; inline
 
 : make-int-array ( -- int-array )
-    120000 [ 255 bitand ] int-array{ } map-as ; inline
+    120000 iota [ 255 bitand ] int-array{ } map-as ; inline
 
 : dawes-benchmark ( -- )
     200 make-int-array '[ _ count-ones ] replicate drop ;
index 87848cee9dfae4532333da07036f259e756e4ac7..7db583d42a397bcc6fe97c0316c3afd305739945 100644 (file)
@@ -5,8 +5,8 @@ IN: benchmark.dispatch2
 
 : sequences ( -- seq )
     [
-        1 ,
-        10 >bignum ,
+        1 iota ,
+        10 >bignum iota ,
         { 1 2 3 } ,
         "hello world" ,
         SBUF" sbuf world" ,
@@ -14,7 +14,7 @@ IN: benchmark.dispatch2
         double-array{ 1.0 2.0 3.0 } ,
         "hello world" 4 tail-slice ,
         10 f <repetition> ,
-        100 2 <sliced-groups> ,
+        100 iota 2 <sliced-groups> ,
         "hello" <reversed> ,
         { { 1 2 } { 3 4 } } 0 <column> ,
         ?{ t f t } ,
old mode 100755 (executable)
new mode 100644 (file)
index 2f989b7..685c92a
@@ -54,14 +54,14 @@ IN: benchmark.dispatch4
     20000000 [
         20 [
             foobar-1 drop
-        ] each
+        ] each-integer
     ] times ;
 
 : foobar-test-2 ( -- )
     20000000 [
         20 [
             foobar-2 drop
-        ] each
+        ] each-integer
     ] times ;
 
 MAIN: foobar-test-1
old mode 100755 (executable)
new mode 100644 (file)
index 7ef40aa65a0db40debd1965b9db1f5887383ead6..a7d875af3fe9c12aff922bd7dc486a4e5f22656a 100644 (file)
@@ -5,7 +5,7 @@ sequences ;
 IN: benchmark.e-decimals
 
 : D-factorial ( n -- D! )
-    D: 1 [ 0 <decimal> D: 1 D+ D* ] reduce ; inline
+    iota D: 1 [ 0 <decimal> D: 1 D+ D* ] reduce ; inline
 
 :: calculate-e-decimals ( n -- e )
     n [1,b] D: 1
index f09aee6adaa47a52e334d3ea18d51bf45ee356ce..a6541856a56a05ee9ab9fa4814280910ab5cae10 100644 (file)
@@ -2,7 +2,7 @@ USING: math math.private kernel sequences ;
 IN: benchmark.empty-loop-2
 
 : empty-loop-2 ( n -- )
-    [ drop ] each ;
+    iota [ drop ] each ;
 
 : empty-loop-main ( -- )
     50000000 empty-loop-2 ;
index 40dd54ca9974187b0b9cd908d8c1275e82472395..f3a41ca4a98dcc38e694dd9d789b76a0f74956fc 100644 (file)
@@ -24,7 +24,7 @@ IN: benchmark.fannkuch
 
 : fannkuch ( n -- )
     [
-        [ 0 0 ] dip [ 1 + ] B{ } map-as
+        [ 0 0 ] dip iota [ 1 + ] B{ } map-as
         [ fannkuch-step ] each-permutation nip
     ] keep
     "Pfannkuchen(" write pprint ") = " write . ;
old mode 100755 (executable)
new mode 100644 (file)
index 5ba285d..bd7ccaf
@@ -56,7 +56,7 @@ CONSTANT: homo-sapiens
     chars nth-unsafe ; inline
 
 : make-random-fasta ( seed len chars floats -- seed )
-    [ rot drop select-random ] 2curry "" map-as print ; inline
+    [ iota ] 2dip [ [ drop ] 2dip select-random ] 2curry "" map-as print ; inline
 
 : write-description ( desc id -- )
     ">" write write bl print ; inline
@@ -72,7 +72,7 @@ CONSTANT: homo-sapiens
 
 :: make-repeat-fasta ( k len alu -- k' )
     alu length :> kn
-    len [ k + kn mod alu nth-unsafe ] "" map-as print
+    len iota [ k + kn mod alu nth-unsafe ] "" map-as print
     k len + ; inline
 
 : write-repeat-fasta ( n alu desc id -- )
old mode 100755 (executable)
new mode 100644 (file)
index 4909496d125b65874f71e69b427b5d8c8517f125..91989f204a4e1aaa774f1a4c6d08e31e46f87fc2 100644 (file)
@@ -3,6 +3,6 @@
 USING: math sequences kernel ;
 IN: benchmark.gc1
 
-: gc1 ( -- ) 600000 [ >bignum 1 + ] map drop ;
+: gc1 ( -- ) 600000 iota [ >bignum 1 + ] map drop ;
 
 MAIN: gc1
index f49d21d5a36829664733903f94b73b54af176758..51cafbe1e8596b1f602e43df9e6da15c350e3b9b 100644 (file)
@@ -2,7 +2,7 @@ IN: benchmark.iteration
 USING: sequences vectors arrays strings sbufs math math.vectors
 kernel ;
 
-: <range> ( from to -- seq ) dup <slice> ; inline
+: <range> ( from to -- seq ) dup iota <slice> ; inline
 
 : vector-iter ( -- ) 100 [ 0 100000 <range> >vector [ ] map drop ] times ;
 : array-iter ( -- ) 100 [ 0 100000 <range> >array [ ] map drop ] times ;
index fb4f17cca5c768615975aa03451108ebf4bea86a..70fa1bb061b367cac6f1a825ef3a5efc546819fc 100644 (file)
@@ -1,4 +1,4 @@
-USING: kernel io io.files splitting strings io.encodings.ascii
+USING: kernel locals io io.files splitting strings io.encodings.ascii
        hashtables sequences assocs math namespaces prettyprint
        math.parser combinators arrays sorting unicode.case ;
 
@@ -21,14 +21,11 @@ IN: benchmark.knucleotide
     CHAR: \n swap remove >upper ;
 
 : tally ( x exemplar -- b )
-    clone tuck
-    [
-      [ [ 1 + ] [ 1 ] if* ] change-at
-    ] curry each ;
+    clone [ [ inc-at ] curry each ] keep ;
 
 : small-groups ( x n -- b )
     swap
-    [ length swap - 1 + ] 2keep
+    [ length swap - 1 + iota ] 2keep
     [ [ over + ] dip subseq ] 2curry map ;
 
 : handle-table ( inputs n -- )
@@ -42,10 +39,10 @@ IN: benchmark.knucleotide
     ] each
     drop ;
 
-: handle-n ( inputs x -- )
-    tuck length
-    small-groups H{ } tally
-    at [ 0 ] unless*
+:: handle-n ( inputs x -- )
+    inputs x length small-groups :> groups
+    groups H{ } tally :> b
+    x b at [ 0 ] unless*
     number>string 8 CHAR: \s pad-tail write ;
 
 : process-input ( input -- )
old mode 100755 (executable)
new mode 100644 (file)
index 6648c5263902e4a4a6ac90ee06a94f980524799f..2797558a4b878a8deb3562adfeafe05aadc127eb 100644 (file)
@@ -2,9 +2,8 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors alien.c-types fry kernel locals math
 math.constants math.functions math.vectors math.vectors.simd
-prettyprint combinators.smart sequences hints classes.struct
-specialized-arrays ;
-SIMD: double
+math.vectors.simd.cords prettyprint combinators.smart sequences
+hints classes.struct specialized-arrays ;
 IN: benchmark.nbody-simd
 
 : solar-mass ( -- x ) 4 pi sq * ; inline
index 023f5de5c24d8b21ba88629225294ef6fff92a38..aa6098a43458f4a82d61a51ff80977fd61d0a94d 100644 (file)
@@ -1,11 +1,11 @@
-! Copyright (C) 2008 Slava Pestov.
+! Copyright (C) 2008, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: math math.functions kernel io io.styles prettyprint
 combinators hints fry namespaces sequences ;
 IN: benchmark.partial-sums
 
 ! Helper words
-: summing-integers ( n quot -- y ) [ 0.0 ] 2dip '[ 1 + @ + ] each ; inline
+: summing-integers ( n quot -- y ) [ 0.0 ] [ iota ] [ ] tri* '[ 1 + @ + ] each ; inline
 : summing-floats ( n quot -- y ) '[ >float @ ] summing-integers ; inline
 : cube ( x -- y ) dup dup * * ; inline
 : -1^ ( n -- -1/1 ) 2 mod 2 * 1 - ; inline
old mode 100755 (executable)
new mode 100644 (file)
index 4eab7c1..b5abc4f
@@ -1,5 +1,5 @@
 USING: io io.files io.files.temp io.encodings.ascii random
-math.parser math ;
+math.parser math sequences ;
 IN: benchmark.random
 
 : random-numbers-path ( -- path )
index 5a3c232b5aab32be6f1b9325394a7a012999f7fd..dcdc911cbf676b08389f56a2b546c0b7935a159b 100644 (file)
@@ -3,10 +3,9 @@
 
 USING: arrays accessors io io.files io.files.temp
 io.encodings.binary kernel math math.constants math.functions
-math.vectors math.vectors.simd math.parser make sequences
-sequences.private words hints classes.struct ;
+math.vectors math.vectors.simd math.vectors.simd.cords math.parser
+make sequences sequences.private words hints classes.struct ;
 QUALIFIED-WITH: alien.c-types c
-SIMD: c:double
 IN: benchmark.raytracer-simd
 
 ! parameters
@@ -150,7 +149,7 @@ DEFER: create ( level c r -- scene )
     [ oversampling /f ] bi@ 0.0 0.0 double-4-boa ;
 
 : ss-grid ( -- ss-grid )
-    oversampling [ oversampling [ ss-point ] with map ] map ;
+    oversampling iota [ oversampling iota [ ss-point ] with map ] map ;
 
 : ray-grid ( point ss-grid -- ray-grid )
     [
@@ -162,8 +161,8 @@ DEFER: create ( level c r -- scene )
     [ [ swap cast-ray + ] with each ] with each ;
 
 : pixel-grid ( -- grid )
-    size reverse [
-        size [
+    size iota reverse [
+        size iota [
             [ size 0.5 * - ] bi@ swap size
             0.0 double-4-boa
         ] with map
old mode 100755 (executable)
new mode 100644 (file)
index 2413e7f..868743b
@@ -148,7 +148,7 @@ DEFER: create ( level c r -- scene )
     [ oversampling /f ] bi@ 0.0 double-array{ } 3sequence ;
 
 : ss-grid ( -- ss-grid )
-    oversampling [ oversampling [ ss-point ] with map ] map ;
+    oversampling iota [ oversampling iota [ ss-point ] with map ] map ;
 
 : ray-grid ( point ss-grid -- ray-grid )
     [
@@ -160,8 +160,8 @@ DEFER: create ( level c r -- scene )
     [ [ swap cast-ray + ] with each ] with each ;
 
 : pixel-grid ( -- grid )
-    size reverse [
-        size [
+    size iota reverse [
+        size iota [
             [ size 0.5 * - ] bi@ swap size
             double-array{ } 3sequence
         ] with map
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index ae918b7..08e8edb
@@ -13,7 +13,7 @@ SYMBOL: done
     ] times ;
 
 : send-messages ( messages target -- )
-    dupd [ send ] curry each [ receive drop ] times ; 
+    [ dup iota ] dip [ send ] curry each [ receive drop ] times ; 
 
 : destroy-ring ( target -- )
     done swap send [ done eq? ] receive-if drop ;
index ff0cb98a0096171c35569313c5c11450e7a7004c..e20b82c3c4907112424cd4e0420a11061a3c027f 100644 (file)
@@ -3,7 +3,6 @@
 USING: kernel io math math.functions math.parser math.vectors
 math.vectors.simd sequences specialized-arrays ;
 QUALIFIED-WITH: alien.c-types c
-SIMD: c:float
 SPECIALIZED-ARRAY: float-4
 IN: benchmark.simd-1
 
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 68efffe08313b3f056c3033a796804b1ddd21db1..386ffb0ae10c6aa4498bc2515e4620c6ecc5c188 100644 (file)
@@ -7,8 +7,8 @@ SPECIALIZED-ARRAY: double
 IN: benchmark.spectral-norm
 
 :: inner-loop ( u n quot -- seq )
-    n [| i |
-        n 0.0 [| j |
+    n iota [| i |
+        n iota 0.0 [| j |
             u i j quot call +
         ] reduce
     ] double-array{ } map-as ; inline
index b158dba5dd0ad751c20eb05cf5c17c9ad498888e..41c1152cbd64dc6255d8348f8a8733b4186f240c 100644 (file)
@@ -1,7 +1,6 @@
 ! (c)Joe Groff bsd license
 USING: io kernel math.vectors.simd terrain.generation threads ;
 FROM: alien.c-types => float ;
-SIMD: float
 IN: benchmark.terrain-generation
 
 : terrain-generation-benchmark ( -- )
index 38ce0087a2c209d74f61cd97848bf320c23b86ae..701db7713591de56154ca5c6a02218aa554ab84c 100644 (file)
@@ -9,7 +9,7 @@ TUPLE: point { x float } { y float } { z float } ;
 TUPLE-ARRAY: point
 
 : tuple-array-benchmark ( -- )
-    100 [
+    100 iota [
         drop 5000 <point-array> [
             [ 1 + ] change-x
             [ 1 - ] change-y
index 6fdbdaecf6d06ea5452799a56d7e68f5b75037b2..9d16f75e15d2da7b4ced9d835b34f04b01aa2ddd 100644 (file)
@@ -2,6 +2,6 @@ USING: ui.gadgets.panes prettyprint io sequences ;
 IN: benchmark.ui-panes
 
 : ui-pane-benchmark ( -- )
-    <pane> <pane-stream> [ 10000 [ . ] each ] with-output-stream* ;
+    <pane> <pane-stream> [ 10000 iota [ . ] each ] with-output-stream* ;
 
 MAIN: ui-pane-benchmark
index 024887991e9af4a12865846bd3cafecc2b994a84..b182b4f832ee703b18df1f437498400e3393ded7 100644 (file)
@@ -27,9 +27,9 @@ STRUCT: yuv_buffer
         h >>uv_height
         w >>y_stride
         w >>uv_stride
-        w h * [ dup * ] B{ } map-as malloc-byte-array &free >>y
-        w h * 2/ [ dup dup * * ] B{ } map-as malloc-byte-array &free >>u
-        w h * 2/ [ dup * dup * ] B{ } map-as malloc-byte-array &free >>v ;
+        w h * iota [ dup * ] B{ } map-as malloc-byte-array &free >>y
+        w h * 2/ iota [ dup dup * * ] B{ } map-as malloc-byte-array &free >>u
+        w h * 2/ iota [ dup * dup * ] B{ } map-as malloc-byte-array &free >>v ;
 
 : clamp ( n -- n )
     255 min 0 max ; inline
@@ -76,12 +76,12 @@ STRUCT: yuv_buffer
 
 : yuv>rgb-row ( index rgb yuv y -- index )
     over stride
-    pick y_width>>
+    pick y_width>> iota
     [ yuv>rgb-pixel ] with with with with each ; inline
 
 : yuv>rgb ( rgb yuv -- )
     [ 0 ] 2dip
-    dup y_height>>
+    dup y_height>> iota
     [ yuv>rgb-row ] with with each
     drop ;
 
index fa56aff8cc92898c8cf3c64c57054cc906c33f70..f4055ca9e06c74813889e190fd003a3996ef831f 100644 (file)
@@ -73,8 +73,8 @@ IN: bloom-filters.tests
 [ t ] [ 1000 iota [ drop most-positive-fixnum random 1000 + ] map
         full-bloom-filter
         [ bloom-filter-member? ] curry map
-        [ ] filter
+        [ ] count
         ! TODO: This should be 10, but the false positive rate is currently very
         ! high.  300 is large enough not to prevent builds from succeeding.
-        length 300 <=
+        300 <=
 ] unit-test
index ad24d74adffb00bd481869b37efaae500870009f..0f14ed1d975720323e0066f92c7ef4106c35390f 100644 (file)
@@ -4,7 +4,7 @@ USING: accessors arrays bit-arrays fry infix kernel layouts locals math
 math.functions multiline sequences ;
 IN: bloom-filters
 
-FROM: math.ranges => [1,b] [0,b) ;
+FROM: math.ranges => [1,b] ;
 FROM: math.intervals => (a,b) interval-contains? ;
 
 /*
@@ -121,7 +121,7 @@ PRIVATE>
     [infix hash0 + (index * hash1) + ((pow(index, 3) - index) / 6) infix] ;
 
 : enhanced-double-hashes ( hash0 hash1 n -- seq )
-    [0,b)
+    iota
     [ '[ _ _ enhanced-double-hash ] ] dip
     swap map ;
 
index e6ae0060b67ac9fd7a5e7a08509875b325f14691..51aa5f3817e32bba1208090fc7e256858ad58203 100644 (file)
@@ -1,6 +1,6 @@
 USING: accessors assocs bson.constants calendar fry io io.binary
 io.encodings io.encodings.utf8 kernel math math.bitwise namespaces
-sequences serialize ;
+sequences serialize locals ;
 
 FROM: kernel.private => declare ;
 FROM: io.encodings.private => (read-until) ;
@@ -62,22 +62,17 @@ GENERIC: element-binary-read ( length type -- object )
 : read-byte ( -- byte )
     read-byte-raw first ; inline
 
-: utf8-read-until ( seps stream encoding -- string/f sep/f )
-    [ { utf8 } declare decode-char dup [ dup rot member? ] [ 2drop f t ] if ]
-    3curry (read-until) ;
-
 : read-cstring ( -- string )
-    "\0" input-stream get utf8 utf8-read-until drop ; inline
+    "\0" read-until drop "" like ; inline
 
 : read-sized-string ( length -- string )
-    drop read-cstring ; inline
+    read 1 head-slice* "" like ; inline
 
 : read-element-type ( -- type )
     read-byte ; inline
 
-: push-element ( type name -- element )
-    element boa
-    [ get-state element>> push ] keep ; inline
+: push-element ( type name -- )
+    element boa get-state element>> push ; inline
 
 : pop-element ( -- element )
     get-state element>> pop ; inline
@@ -96,8 +91,7 @@ M: bson-object fix-result ( assoc type -- result )
     drop ;
 
 M: bson-array fix-result ( assoc type -- result )
-    drop
-    values ;
+    drop values ;
 
 GENERIC: end-element ( type -- )
 
@@ -108,25 +102,20 @@ M: bson-array end-element ( type -- )
     drop ;
 
 M: object end-element ( type -- )
-    drop
-    pop-element drop ;
+    pop-element 2drop ;
 
-M: bson-eoo element-read ( type -- cont? )
-    drop
-    get-state scope>> [ pop ] keep swap ! vec assoc
-    pop-element [ type>> ] keep       ! vec assoc element
-    [ fix-result ] dip
-    rot length 0 >                      ! assoc element 
-    [ name>> peek-scope set-at t ]
-    [ drop [ get-state ] dip >>result drop f ] if ;
-
-M: bson-not-eoo element-read ( type -- cont? )
-    [ peek-scope ] dip                                 ! scope type 
-    '[ _ read-cstring push-element [ name>> ] [ type>> ] bi 
-       [ element-data-read ] keep
-       end-element
-       swap
-    ] dip set-at t ;
+M:: bson-eoo element-read ( type -- cont? )
+    pop-element :> element
+    get-state scope>>
+    [ pop element type>> fix-result ] [ empty? ] bi
+    [ [ get-state ] dip >>result drop f ]
+    [ element name>> peek-scope set-at t ] if ;
+
+M:: bson-not-eoo element-read ( type -- cont? )
+    peek-scope :> scope
+    type read-cstring [ push-element ] 2keep
+    [ [ element-data-read ] [ end-element ] bi ]
+    [ scope set-at t ] bi* ;
 
 : [scope-changer] ( state -- state quot )
     dup exemplar>> '[ [ [ _ clone ] dip push ] keep ] ; inline
@@ -173,8 +162,7 @@ M: bson-regexp element-data-read ( type -- mdbregexp )
    read-cstring >>regexp read-cstring >>options ;
  
 M: bson-null element-data-read ( type -- bf  )
-    drop
-    f ;
+    drop f ;
 
 M: bson-oid element-data-read ( type -- oid )
     drop
index f9bd0eb392a45a3980c4454dfcd124776554151f..a07057994331203de6b0101b8f44cdc3539e0a10 100644 (file)
@@ -73,11 +73,9 @@ M: word bson-type? ( word -- type ) drop T_Binary ;
 M: quotation bson-type? ( quotation -- type ) drop T_Binary ; 
 M: byte-array bson-type? ( byte-array -- type ) drop T_Binary ; 
 
-: write-utf8-string ( string -- ) output-stream get '[ _ swap char>utf8 ] each ; inline
-
 : write-int32 ( int -- ) INT32-SIZE >le write ; inline
 : write-double ( real -- ) double>bits INT64-SIZE >le write ; inline
-: write-cstring ( string -- ) write-utf8-string 0 write1 ; inline
+: write-cstring ( string -- ) B{ } like write 0 write1 ; inline
 : write-longlong ( object -- ) INT64-SIZE >le write ; inline
 
 : write-eoo ( -- ) T_EOO write1 ; inline
@@ -127,9 +125,11 @@ M: sequence bson-write ( array -- )
    { $[ MDB_OID_FIELD MDB_META_FIELD ] } member? ; inline
 
 M: assoc bson-write ( assoc -- )
-    '[ _  [ write-oid ] keep
-       [ over skip-field? [ 2drop ] [ write-pair ] if ] assoc-each
-       write-eoo ] with-length-prefix ; 
+    '[
+        _  [ write-oid ] keep
+        [ over skip-field? [ 2drop ] [ write-pair ] if ] assoc-each
+        write-eoo
+    ] with-length-prefix ;
 
 : (serialize-code) ( code -- )
     object>bytes [ length write-int32 ] keep
old mode 100755 (executable)
new mode 100644 (file)
index b7400c4..bbb89f6
@@ -44,24 +44,17 @@ M: bunny-world draw-world*
         [ geom>> ] [ get-draw ] bi draw-bunny
     ] if ;
 
-M: bunny-world pref-dim* ( gadget -- dim )
-    drop { 640 480 } ;
-    
 bunny-world H{
     { T{ key-down f f "TAB" } [ next-draw ] }
 } set-gestures
 
-: bunny-window ( -- )
-    [
-        f T{ world-attributes
-            { world-class bunny-world }
-            { title "Bunny" }
-            { pixel-format-attributes {
-                windowed
-                double-buffered
-                T{ depth-bits { value 16 } }
-            } }
-        } open-window
-    ] with-ui ;
-
-MAIN: bunny-window
+MAIN-WINDOW: bunny-window {
+        { world-class bunny-world }
+        { title "Bunny" }
+        { pixel-format-attributes {
+            windowed
+            double-buffered
+            T{ depth-bits { value 16 } }
+        } }
+        { pref-dim { 640 480 } }
+    } ;
old mode 100755 (executable)
new mode 100644 (file)
index 7cf6a3e..1289caa
@@ -1,13 +1,14 @@
 USING: tools.deploy.config ;
 H{
-    { deploy-io 3 }
-    { deploy-word-defs? f }
-    { deploy-reflection 1 }
-    { deploy-c-types? f }
     { deploy-name "Bunny" }
-    { deploy-word-props? f }
-    { deploy-threads? t }
-    { "stop-after-last-window?" t }
     { deploy-ui? t }
+    { deploy-c-types? f }
+    { deploy-unicode? f }
+    { "stop-after-last-window?" t }
+    { deploy-io 3 }
+    { deploy-reflection 2 }
+    { deploy-word-props? f }
     { deploy-math? t }
+    { deploy-threads? t }
+    { deploy-word-defs? f }
 }
old mode 100755 (executable)
new mode 100644 (file)
index b9923d5..cfe9595
@@ -93,7 +93,7 @@ M: bunny-buffers bunny-geom
         { GL_VERTEX_ARRAY GL_NORMAL_ARRAY } [
             GL_FLOAT 0 0 buffer-offset glNormalPointer
             [
-                nv>> "float" heap-size * buffer-offset
+                nv>> c:float heap-size * buffer-offset
                 [ 3 GL_FLOAT 0 ] dip glVertexPointer
             ] [
                 ni>>
old mode 100755 (executable)
new mode 100644 (file)
index c972b8816cd55fa94eaa6b3aa2402d89ad0e5487..082827353de2677b78a4636b56ede642397ccc51 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2009 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors c.lexer kernel sequence-parser tools.test ;
+USING: accessors c.lexer kernel sequences.parser tools.test ;
 IN: c.lexer.tests
 
 [ 36 ]
index 962407e6ec84f33b77ad4d6fb67eb10a436e1aa6..57894217bd17f6cc5e4e47af7eee79d268975c61 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors combinators combinators.short-circuit
 generalizations kernel locals math.order math.ranges
-sequence-parser sequences sorting.functor sorting.slots
+sequences.parser sequences sorting.functor sorting.slots
 unicode.categories ;
 IN: c.lexer
 
index 3018fa7a2469d400d9ffd5930bea8b5fa646778f..d69583e12447c3b397c332f1e40c05468af18f00 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2009 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: sequence-parser io io.encodings.utf8 io.files
+USING: sequences.parser io io.encodings.utf8 io.files
 io.streams.string kernel combinators accessors io.pathnames
 fry sequences arrays locals namespaces io.directories
 assocs math splitting make unicode.categories
@@ -93,11 +93,11 @@ ERROR: header-file-missing path ;
     skip-whitespace/comments
     [ current { [ blank? ] [ CHAR: ( = ] } 1|| ] take-until ;
 
-: handle-define ( preprocessor-state sequence-parser -- )
-    [ take-define-identifier ]
-    [ skip-whitespace/comments take-rest ] bi 
-    "\\" ?tail [ readlns append ] when
-    spin symbol-table>> set-at ;
+:: handle-define ( preprocessor-state sequence-parser -- )
+    sequence-parser take-define-identifier :> ident
+    sequence-parser skip-whitespace/comments take-rest :> def
+    def "\\" ?tail [ readlns append ] when :> def
+    def ident preprocessor-state symbol-table>> set-at ;
 
 : handle-undef ( preprocessor-state sequence-parser -- )
     take-token swap symbol-table>> delete-at ;
diff --git a/extra/calendar/holidays/authors.txt b/extra/calendar/holidays/authors.txt
new file mode 100644 (file)
index 0000000..b4bd0e7
--- /dev/null
@@ -0,0 +1 @@
+Doug Coleman
\ No newline at end of file
diff --git a/extra/calendar/holidays/canada/authors.txt b/extra/calendar/holidays/canada/authors.txt
new file mode 100644 (file)
index 0000000..b4bd0e7
--- /dev/null
@@ -0,0 +1 @@
+Doug Coleman
\ No newline at end of file
diff --git a/extra/calendar/holidays/canada/canada-tests.factor b/extra/calendar/holidays/canada/canada-tests.factor
new file mode 100644 (file)
index 0000000..916f5ee
--- /dev/null
@@ -0,0 +1,7 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: calendar.holidays calendar.holidays.canada kernel
+tools.test ;
+IN: calendar.holidays.canada.tests
+
+[ ] [ 2009 canada holidays drop ] unit-test
diff --git a/extra/calendar/holidays/canada/canada.factor b/extra/calendar/holidays/canada/canada.factor
new file mode 100644 (file)
index 0000000..304388f
--- /dev/null
@@ -0,0 +1,11 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: calendar calendar.holidays ;
+IN: calendar.holidays.canada
+
+SINGLETONS: canada canadian-federal ;
+
+HOLIDAY: canadian-thanksgiving-day october 2 monday-of-month ;
+HOLIDAY-NAME: canadian-thanksgiving-day canadian-federal "Thanksgiving Day"
+
+HOLIDAY-NAME: armistice-day commonwealth-of-nations "Remembrance Day"
diff --git a/extra/calendar/holidays/holidays.factor b/extra/calendar/holidays/holidays.factor
new file mode 100644 (file)
index 0000000..0b8a1bb
--- /dev/null
@@ -0,0 +1,55 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: accessors assocs calendar fry kernel parser sequences
+shuffle vocabs words memoize ;
+IN: calendar.holidays
+
+SINGLETONS: all world commonwealth-of-nations ;
+
+<<
+SYNTAX: HOLIDAY:
+    CREATE-WORD
+    dup "holiday" word-prop [
+        dup H{ } clone "holiday" set-word-prop
+    ] unless
+    parse-definition (( timestamp/n -- timestamp )) define-declared ;
+
+SYNTAX: HOLIDAY-NAME:
+    scan-word "holiday" word-prop scan-word scan-object spin set-at ;
+>>
+
+GENERIC: holidays ( n singleton -- seq )
+
+<PRIVATE
+
+: (holidays) ( singleton -- seq )
+    all-words swap '[ "holiday" word-prop _ swap key? ] filter ;
+
+M: object holidays
+    (holidays) [ execute( timestamp -- timestamp' ) ] with map ;
+
+PRIVATE>
+
+M: all holidays
+    drop
+    all-words [ "holiday" word-prop key? ] with filter ;
+
+: holiday? ( timestamp/n singleton -- ? )
+    [ holidays ] [ drop ] 2bi '[ _ same-day? ] any? ;
+
+: holiday-assoc ( timestamp singleton -- assoc )
+    (holidays) swap
+    '[ [ _ swap execute( ts -- ts' ) >gmt midnight ] keep ] { } map>assoc ;
+
+: holiday-name ( singleton word -- string/f )
+    "holiday" word-prop at ;
+
+: holiday-names ( timestamp/n singleton -- seq )
+    [
+        [ >gmt midnight ] dip
+        [ drop ] [ holiday-assoc ] 2bi swap
+        '[ drop _ same-day? ] assoc-filter values
+    ] keep '[ _ swap "holiday" word-prop at ] map ;
+
+HOLIDAY: armistice-day november 11 >>day ;
+HOLIDAY-NAME: armistice-day world "Armistice Day"
diff --git a/extra/calendar/holidays/us/authors.txt b/extra/calendar/holidays/us/authors.txt
new file mode 100644 (file)
index 0000000..b4bd0e7
--- /dev/null
@@ -0,0 +1 @@
+Doug Coleman
\ No newline at end of file
diff --git a/extra/calendar/holidays/us/us-tests.factor b/extra/calendar/holidays/us/us-tests.factor
new file mode 100644 (file)
index 0000000..23ab535
--- /dev/null
@@ -0,0 +1,7 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: calendar.holidays calendar.holidays.us kernel sequences
+tools.test ;
+IN: calendar.holidays.us.tests
+
+[ 10 ] [ 2009 us-federal holidays length ] unit-test
diff --git a/extra/calendar/holidays/us/us.factor b/extra/calendar/holidays/us/us.factor
new file mode 100644 (file)
index 0000000..a4fb19c
--- /dev/null
@@ -0,0 +1,117 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: accessors assocs calendar calendar.holidays
+calendar.holidays.private combinators combinators.short-circuit
+fry kernel lexer math namespaces parser sequences shuffle
+vocabs words ;
+IN: calendar.holidays.us
+
+SINGLETONS: us us-federal ;
+
+<PRIVATE
+
+: adjust-federal-holiday ( timestamp -- timestamp' )
+    {
+        { [ dup saturday? ] [ 1 days time- ] }
+        { [ dup sunday? ] [ 1 days time+ ] }
+        [ ]
+    } cond ;
+
+PRIVATE>
+
+M: us-federal holidays
+    (holidays)
+    [ execute( timestamp -- timestamp' ) adjust-federal-holiday ] with map ;
+
+: us-post-office-open? ( timestamp -- ? )
+    { [ sunday? not ] [ us-federal holiday? not ] } 1&& ;
+
+HOLIDAY: new-years-day january 1 >>day ;
+HOLIDAY-NAME: new-years-day world "New Year's Day"
+HOLIDAY-NAME: new-years-day us-federal "New Year's Day"
+
+HOLIDAY: martin-luther-king-day january 3 monday-of-month ;
+HOLIDAY-NAME: martin-luther-king-day us-federal "Martin Luther King Day"
+
+HOLIDAY: inauguration-day year dup 4 neg rem + january 20 >>day ;
+HOLIDAY-NAME: inauguration-day us "Inauguration Day"
+
+HOLIDAY: washingtons-birthday february 3 monday-of-month ;
+HOLIDAY-NAME: washingtons-birthday us-federal "Washington's Birthday"
+
+HOLIDAY: memorial-day may last-monday-of-month ;
+HOLIDAY-NAME: memorial-day us-federal "Memorial Day"
+
+HOLIDAY: independence-day july 4 >>day ;
+HOLIDAY-NAME: independence-day us-federal "Independence Day"
+
+HOLIDAY: labor-day september 1 monday-of-month ;
+HOLIDAY-NAME: labor-day us-federal "Labor Day"
+
+HOLIDAY: columbus-day october 2 monday-of-month ;
+HOLIDAY-NAME: columbus-day us-federal "Columbus Day"
+
+HOLIDAY-NAME: armistice-day us-federal "Veterans Day"
+
+HOLIDAY: thanksgiving-day november 4 thursday-of-month ;
+HOLIDAY-NAME: thanksgiving-day us-federal "Thanksgiving Day"
+
+HOLIDAY: christmas-day december 25 >>day ;
+HOLIDAY-NAME: christmas-day world "Christmas Day"
+HOLIDAY-NAME: christmas-day us-federal "Christmas Day"
+
+HOLIDAY: belly-laugh-day january 24 >>day ;
+
+HOLIDAY: groundhog-day february 2 >>day ;
+
+HOLIDAY: lincolns-birthday february 12 >>day ;
+
+HOLIDAY: valentines-day february 14 >>day ;
+
+HOLIDAY: st-patricks-day march 17 >>day ;
+
+HOLIDAY: ash-wednesday easter 46 days time- ;
+
+ALIAS: first-day-of-lent ash-wednesday
+
+HOLIDAY: fat-tuesday ash-wednesday 1 days time- ;
+
+HOLIDAY: good-friday easter 2 days time- ;
+
+HOLIDAY: tax-day april 15 >>day ;
+
+HOLIDAY: earth-day april 22 >>day ;
+
+HOLIDAY: administrative-professionals-day april last-saturday-of-month wednesday ;
+
+HOLIDAY: cinco-de-mayo may 5 >>day ;
+
+HOLIDAY: mothers-day may 2 sunday-of-month ;
+
+HOLIDAY: armed-forces-day may 3 saturday-of-month ;
+
+HOLIDAY: flag-day june 14 >>day ;
+
+HOLIDAY: parents-day july 4 sunday-of-month ;
+
+HOLIDAY: grandparents-day labor-day 1 weeks time+ ;
+
+HOLIDAY: patriot-day september 11 >>day ;
+
+HOLIDAY: stepfamily-day september 16 >>day ;
+
+HOLIDAY: citizenship-day september 17 >>day ;
+
+HOLIDAY: bosss-day october 16 >>day ;
+
+HOLIDAY: sweetest-day october 3 saturday-of-month ;
+
+HOLIDAY: halloween october 31 >>day ;
+
+HOLIDAY: election-day november 1 monday-of-month 1 days time+ ;
+
+HOLIDAY: black-friday thanksgiving-day 1 days time+ ;
+
+HOLIDAY: pearl-harbor-remembrance-day december 7 >>day ;
+
+HOLIDAY: new-years-eve december 31 >>day ;
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 56a60d6..a76f07c
@@ -1,6 +1,6 @@
 ! Copyright (C) 2006, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel math math.functions math.parser models
+USING: arrays kernel math math.functions math.parser models
 models.arrow models.range models.product sequences ui
 ui.gadgets ui.gadgets.tracks ui.gadgets.labels ui.gadgets.packs
 ui.gadgets.sliders ui.pens.solid ui.render math.rectangles accessors
@@ -45,7 +45,5 @@ M: color-preview model-changed
             ] bi
         ] bi* ;
 
-: color-picker-window ( -- )
-    [ <color-picker> "Color Picker" open-window ] with-ui ;
-
-MAIN: color-picker-window
+MAIN-WINDOW: color-picker-window { { title "Color Picker" } }
+    <color-picker> >>gadgets ;
old mode 100755 (executable)
new mode 100644 (file)
index 0865dabcf7f17a69ae91fc6aa209102ef25e7654..a154ff82d0902e3392834e74f537d95f9858ca81 100644 (file)
@@ -37,7 +37,5 @@ M: color-renderer row-value
         10 >>min-rows
         10 >>max-rows ;
 
-: color-table-demo ( -- )
-    [ <color-table> <scroller> "Colors" open-window ] with-ui ;
-
-MAIN: color-table-demo
+MAIN-WINDOW: color-table-demo { { title "Colors" } }
+    <color-table> <scroller> >>gadgets ;
index 3cee3999255262ac981a48b72cde8953dd53b8e7..747c8f53fc1bdc47603e915a0af07e30e652a441 100644 (file)
@@ -49,8 +49,8 @@ MACRO:: slots>constructor ( class slots -- quot )
     reverse? [ reverse ] when
     '[ @ _ [ execute( obj -- obj ) ] each ] effect define-declared ;
 
-: scan-constructor ( -- class word )
-    scan-word [ name>> "<" ">" surround create-in ] keep ;
+: scan-constructor ( -- word class )
+    scan-word [ name>> "<" ">" surround create-in dup reset-generic ] keep ;
 
 : parse-constructor ( -- class word effect def )
     scan-constructor complete-effect parse-definition ;
old mode 100755 (executable)
new mode 100644 (file)
index da71acb07408a94b9446bfcaadaa8cca948ded10..ed5dd1268fa9042a445a176879a9e454a6dbad04 100644 (file)
@@ -2,8 +2,8 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors arrays assocs continuations debugger hashtables http
 http.client io io.encodings.string io.encodings.utf8 json.reader
-json.writer kernel make math math.parser namespaces sequences strings
-urls urls.encoding vectors ;
+json.writer kernel locals make math math.parser namespaces sequences
+strings urls urls.encoding vectors ;
 IN: couchdb
 
 ! NOTE: This code only works with the latest couchdb (0.9.*), because old
@@ -136,8 +136,9 @@ C: <db> db
 : attachments> ( assoc -- attachments ) "_attachments" swap at ;
 : >attachments ( assoc attachments -- assoc ) "_attachments" pick set-at ;
 
-: copy-key ( to from to-key from-key -- )
-    rot at spin set-at ;
+:: copy-key ( to from to-key from-key -- )
+    from-key from at
+    to-key to set-at ;
 
 : copy-id ( to from -- )
     "_id" "id" copy-key ;
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index a5a6709c6d61c2d555ecbf68560cc3a1ca208fd4..4891eab6902f25fd115c0c02ecb20457a4ef222e 100644 (file)
@@ -44,7 +44,7 @@ CONSTANT: AES_BLOCK_SIZE 16
 
 : inv-sbox ( -- array )
     256 0 <array>
-    dup 256 [ dup sbox nth rot set-nth ] with each ;
+    dup 256 [ dup sbox nth rot set-nth ] with each-integer ;
 
 : rcon ( -- array )
     {
@@ -72,7 +72,7 @@ CONSTANT: AES_BLOCK_SIZE 16
 
 MEMO:: t-table ( -- array )
     1024 0 <array>
-    dup 256 [ set-t ] with each ;
+    dup 256 [ set-t ] with each-integer ;
 
 :: set-d ( D i -- )
     i inv-sbox nth :> a1
@@ -91,7 +91,7 @@ MEMO:: t-table ( -- array )
     
 MEMO:: d-table ( -- array )
     1024 0 <array>
-    dup 256 [ set-d ] with each ;
+    dup 256 [ set-d ] with each-integer ;
 
 
 USE: multiline
index 4d6c77fd23c03388961911fd8ed27ecd5c0af8d0..69c6503aa282346657e3e6b760591b55ea658a37 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors alien.c-types alien.strings assocs byte-arrays
 combinators continuations destructors fry io.encodings.8-bit
-io io.encodings.string io.encodings.utf8 kernel math
+io io.encodings.string io.encodings.utf8 kernel locals math
 namespaces prettyprint sequences classes.struct
 strings threads curses.ffi ;
 IN: curses
@@ -123,8 +123,10 @@ PRIVATE>
 : curses-writef ( window string -- )
     [ window-ptr dup ] dip (curses-wprint) (curses-window-refresh) ;
 
-: (curses-read) ( window-ptr n encoding -- string )
-    [ [ <byte-array> tuck ] keep wgetnstr curses-error ] dip alien>string ;
+:: (curses-read) ( window-ptr n encoding -- string )
+    n <byte-array> :> buf
+    window-ptr buf n wgetnstr curses-error
+    buf encoding alien>string ;
 
 : curses-read ( window n -- string )
     utf8 [ window-ptr ] 2dip (curses-read) ;
index 29b9d98b38548e4fa8489ceeb13ddb40558d2a07..5bd0fb0fa3a3868a63045970540aa95873f2132a 100644 (file)
@@ -26,15 +26,15 @@ ERROR: decimal-test-failure D1 D2 quot ;
 : test-decimal-op ( quot1 quot2 -- ? )
     [ random-test-decimal random-test-decimal ] 2dip (test-decimal-op) ; inline
 
-[ t ] [ 1000 [ drop [ D+ ] [ + ] test-decimal-op ] all? ] unit-test
-[ t ] [ 1000 [ drop [ D- ] [ - ] test-decimal-op ] all? ] unit-test
-[ t ] [ 1000 [ drop [ D* ] [ * ] test-decimal-op ] all? ] unit-test
+[ t ] [ 1000 [ drop [ D+ ] [ + ] test-decimal-op ] all-integers? ] unit-test
+[ t ] [ 1000 [ drop [ D- ] [ - ] test-decimal-op ] all-integers? ] unit-test
+[ t ] [ 1000 [ drop [ D* ] [ * ] test-decimal-op ] all-integers? ] unit-test
 [ t ] [
     1000 [
         drop
         [ [ 100 D/ ] [ /f ] test-decimal-op ]
         [ { "kernel-error" 4 f f } = ] recover
-    ] all?
+    ] all-integers?
 ] unit-test
 
 [ t ] [ 
index cc12b4fed1822ec35349bd18b52de74a9c554d35..d5c62fee5e3d0d4fa4f87ff2f78b2aa18a1d11af 100644 (file)
@@ -37,7 +37,7 @@ SYNTAX: D: parse-decimal suffix! ;
     ] 2bi ;
 
 : scale-decimals ( D1 D2 -- D1' D2' )
-    scale-mantissas tuck [ <decimal> ] 2dip <decimal> ;
+    scale-mantissas [ <decimal> ] curry bi@ ;
 
 ERROR: decimal-types-expected d1 d2 ;
 
index dfd73f1236d84f758dd6589c03c75c1b95d1fe1e..9c60d8ad1a7eedcbd3d8e2f8520674b7ec8114e9 100644 (file)
@@ -11,6 +11,5 @@ IN: demos
 : <demo-runner> ( -- gadget )
     <pile> 1 >>fill { 2 2 } >>gap demo-vocabs [ <run-vocab-button> add-gadget ] each ;
 
-: demos ( -- ) [ <demo-runner> { 2 2 } <border> <scroller> "Demos" open-window ] with-ui ;
-
-MAIN: demos
\ No newline at end of file
+MAIN-WINDOW: demos { { title "Demos" } }
+    <demo-runner> { 2 2 } <border> <scroller> >>gadgets ;
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 2b33798..ccbe90f
@@ -44,7 +44,7 @@ DEFER: (topological-sort)
     ] if ;
 
 : topological-sort ( digraph -- seq )
-    dup clone V{ } clone spin
+    [ V{ } clone ] dip [ clone ] keep
     [ drop (topological-sort) ] assoc-each drop reverse ;
 
 : topological-sorted-values ( digraph -- seq )
diff --git a/extra/drills/deployed/deploy.factor b/extra/drills/deployed/deploy.factor
deleted file mode 100644 (file)
index c1e9307..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-USING: tools.deploy.config ;
-H{
-    { deploy-name "drills" }
-    { deploy-c-types? t }
-    { "stop-after-last-window?" t }
-    { deploy-unicode? t }
-    { deploy-threads? t }
-    { deploy-reflection 6 }
-    { deploy-word-defs? t }
-    { deploy-math? t }
-    { deploy-ui? t }
-    { deploy-word-props? t }
-    { deploy-io 3 }
-}
diff --git a/extra/drills/deployed/deployed.factor b/extra/drills/deployed/deployed.factor
deleted file mode 100644 (file)
index 5681c73..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-USING: arrays cocoa.dialogs combinators continuations
-fry grouping io.encodings.utf8 io.files io.styles kernel math
-math.parser models models.arrow models.history namespaces random
-sequences splitting ui ui.gadgets.alerts ui.gadgets.book-extras
-ui.gadgets.books ui.gadgets.buttons ui.gadgets.frames
-ui.gadgets.grids ui.gadgets.labels ui.gadgets.tracks fonts
-wrap.strings system ;
-EXCLUDE: accessors => change-model ;
-IN: drills.deployed
-SYMBOLS: it startLength ;
-: big ( gadget -- gadget ) T{ font { name "sans-serif" } { size 30 } } >>font ;
-: card ( model quot -- button ) <arrow> <label-control> big [ next ] <book-btn> ;
-: op ( quot str -- gadget ) <label> big swap <book-bevel-btn> ;
-
-: show ( model -- gadget ) dup it set-global [ random ] <arrow>
-   { [ [ first ] card ]
-     [ [ second ] card ]
-     [ '[ |<< it get _ model-changed ] "No" op ]
-          [ '[ |<< [ it get [
-        _ value>> swap remove
-        [ [ it get go-back ] "Drill Complete" alert return ] when-empty
-     ] change-model ] with-return ] "Yes" op ]
-   } cleave
-2array { 1 0 } <track> swap [ 0.5 track-add ] each
-3array <book*> 3 3 <frame> { 1 1 } >>filled-cell { 450 175 } >>pref-dim swap { 1 1 } grid-add
-it get [ length startLength get swap - number>string "/" startLength get number>string 3append ] <arrow> <label-control> { 1 2 } grid-add ;
-
-: drill ( -- ) [
-   open-panel [
-         [ utf8 file-lines [ "\t" split [ 25 wrap-string ] map ] map dup [ first2 swap 2array ] map append ] map concat
-            [ length startLength set-global ] keep <history> [ add-history ] [ show ] bi
-         "Got it?" open-window
-   ] [ 0 exit ] if*
-] with-ui ;
-
-MAIN: drill
\ No newline at end of file
diff --git a/extra/drills/deployed/tags.txt b/extra/drills/deployed/tags.txt
deleted file mode 100644 (file)
index 6bf6830..0000000
+++ /dev/null
@@ -1 +0,0 @@
-unportable
diff --git a/extra/drills/drills.factor b/extra/drills/drills.factor
deleted file mode 100644 (file)
index 1da1fca..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-USING: arrays cocoa.dialogs combinators continuations
-fry grouping io.encodings.utf8 io.files io.styles kernel math
-math.parser models models.arrow models.history namespaces random
-sequences splitting ui ui.gadgets.alerts ui.gadgets.book-extras
-ui.gadgets.books ui.gadgets.buttons ui.gadgets.frames
-ui.gadgets.grids ui.gadgets.labels ui.gadgets.tracks fonts
-wrap.strings ;
-EXCLUDE: accessors => change-model ;
-
-IN: drills
-SYMBOLS: it startLength ;
-: big ( gadget -- gadget ) T{ font { name "sans-serif" } { size 30 } } >>font ;
-: card ( model quot -- button ) <arrow> <label-control> big [ next ] <book-btn> ;
-: op ( quot str -- gadget ) <label> big swap <book-border-btn> ;
-
-: show ( model -- gadget ) dup it set-global [ random ] <arrow>
-   { [ [ first ] card ]
-     [ [ second ] card ]
-     [ '[ |<< it get _ model-changed ] "No" op ]
-          [ '[ |<< [ it get [
-        _ value>> swap remove
-        [ [ it get go-back ] "Drill Complete" alert return ] when-empty
-     ] change-model ] with-return ] "Yes" op ]
-   } cleave
-2array { 1 0 } <track> swap [ 0.5 track-add ] each
-3array <book*> 3 3 <frame> { 1 1 } >>filled-cell { 450 175 } >>pref-dim swap { 1 1 } grid-add
-it get [ length startLength get swap - number>string "/" startLength get number>string 3append ] <arrow> <label-control> { 1 2 } grid-add ;
-
-: drill ( -- ) [
-   open-panel [
-         [ utf8 file-lines [ "\t" split [ 25 wrap-string ] map ] map dup [ first2 swap 2array ] map append ] map concat
-            [ length startLength set-global ] keep <history> [ add-history ] [ show ] bi
-         "Got it?" open-window
-   ] when*
-] with-ui ;
-
-MAIN: drill
\ No newline at end of file
diff --git a/extra/drills/tags.txt b/extra/drills/tags.txt
deleted file mode 100644 (file)
index 6bf6830..0000000
+++ /dev/null
@@ -1 +0,0 @@
-unportable
index c4d889991edf25be4e0b5184ee42dd9f9412a4d0..8e285a0904a35625acb1a1e31237aaae582895a3 100644 (file)
@@ -50,7 +50,7 @@ PRIVATE>
 
 : get-private-key ( -- bin/f )
     ec-key-handle EC_KEY_get0_private_key
-    dup [ dup BN_num_bits bits>bytes <byte-array> tuck BN_bn2bin drop ] when ;
+    dup [ dup BN_num_bits bits>bytes <byte-array> [ BN_bn2bin drop ] keep ] when ;
 
 :: get-public-key ( -- bin/f )
     ec-key-handle :> KEY
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 133e8913ddf684ffd83e9abedf7241684a6c0d8c..3f970a86bfa91554c10bb2f823e9f7c64f6a9e48 100644 (file)
@@ -1,11 +1,15 @@
 USING: arrays vectors combinators effects kernel math sequences splitting
 strings.parser parser fry sequences.extras ;
+
+! a b c glue => acb
+! c b a [ append ] dip prepend
+
 IN: fries
 : str-fry ( str on -- quot ) split
-    [ unclip-last [ [ spin glue ] reduce-r ] 2curry ]
+    [ unclip-last [ [ [ append ] [ prepend ] bi* ] reduce-r ] 2curry ]
     [ length 1 - 1 <effect> [ call-effect ] 2curry ] bi ;
 : gen-fry ( str on -- quot ) split
-    [ unclip-last [ [ spin 1array glue ] reduce-r ] 2curry ]
+    [ unclip-last [ [ [ 1array ] [ append ] [ prepend ] tri* ] reduce-r ] 2curry ]
     [ length 1 - 1 <effect> [ call-effect ] 2curry ] bi ;
 
 SYNTAX: i" parse-string rest "_" str-fry append! ;
diff --git a/extra/furnace/mongodb/mongodb.factor b/extra/furnace/mongodb/mongodb.factor
new file mode 100644 (file)
index 0000000..3c53c35
--- /dev/null
@@ -0,0 +1,12 @@
+USING: accessors http.server http.server.filters io.pools kernel
+mongodb.driver mongodb.connection namespaces ;
+
+IN: furnace.mongodb
+
+TUPLE: mdb-persistence < filter-responder pool ;
+
+: <mdb-persistence> ( responder mdb -- responder' )
+    <mdb-pool> mdb-persistence boa ;
+
+M: mdb-persistence call-responder*
+    dup pool>> [ mdb-connection set call-next-method ] with-pooled-connection ;
diff --git a/extra/game/loop/authors.txt b/extra/game/loop/authors.txt
new file mode 100644 (file)
index 0000000..f13c9c1
--- /dev/null
@@ -0,0 +1 @@
+Joe Groff
diff --git a/extra/game/loop/loop-docs.factor b/extra/game/loop/loop-docs.factor
new file mode 100644 (file)
index 0000000..cd8660e
--- /dev/null
@@ -0,0 +1,106 @@
+! (c)2009 Joe Groff bsd license
+USING: help.markup help.syntax kernel math ui.gadgets.worlds ;
+IN: game.loop
+
+HELP: fps
+{ $values { "fps" real } { "micros" integer } }
+{ $description "Converts a frames per second value into an interval length in microseconds." } ;
+
+HELP: <game-loop>
+{ $values
+    { "tick-interval-micros" integer } { "delegate" "a " { $link "game.loop-delegates" } }
+    { "loop" game-loop }
+}
+{ $description "Constructs a new stopped " { $link game-loop } " object. When started, the game loop will call the " { $link tick* } " method on the " { $snippet "delegate" } " every " { $snippet "tick-interval-micros" } " microseconds, and " { $link draw* } " on the delegate as frequently as possible. The " { $link start-loop } " and " { $link stop-loop } " words start and stop the game loop." } ;
+
+HELP: benchmark-frames-per-second
+{ $values
+    { "loop" game-loop }
+    { "n" float }
+}
+{ $description "Returns the average number of times per second the game loop has called " { $link draw* } " on its delegate since the game loop was started with " { $link start-loop } " or since the benchmark counters have been reset with " { $link reset-loop-benchmark } "." } ;
+
+HELP: benchmark-ticks-per-second
+{ $values
+    { "loop" game-loop }
+    { "n" float }
+}
+{ $description "Returns the average number of times per second the game loop has called " { $link tick* } " on its delegate since the game loop was started with " { $link start-loop } " or since the benchmark counters have been reset with " { $link reset-loop-benchmark } "." } ;
+
+{ reset-loop-benchmark benchmark-frames-per-second benchmark-ticks-per-second } related-words
+
+HELP: draw*
+{ $values
+    { "tick-slice" float } { "delegate" "a " { $link "game.loop-delegates" } }
+}
+{ $description "This generic word is called by a " { $link game-loop } " on its " { $snippet "delegate" } " object in a tight loop while the game loop is running. The " { $snippet "tick-slice" } " value represents what fraction of the game loop's " { $snippet "tick-interval-micros" } " time period has passed since " { $link tick* } " was most recently called on the delegate." } ;
+
+HELP: game-loop
+{ $class-description "Objects of the " { $snippet "game-loop" } " class manage game loops. See " { $link "game.loop" } " for an overview of the game loop library. To construct a game loop, use " { $link <game-loop> } ". To start and stop a game loop, use the " { $link start-loop } " and " { $link stop-loop } " words." } ;
+
+HELP: game-loop-error
+{ $values
+    { "game-loop" game-loop } { "error" "an error object" }
+}
+{ $description "If an uncaught error is thrown from inside a game loop delegate's " { $link tick* } " or " { $link draw* } ", the game loop will catch the error, stop the game loop, and rethrow an error of this class." } ;
+
+HELP: reset-loop-benchmark
+{ $values
+    { "loop" game-loop }
+}
+{ $description "Resets the benchmark counters on a " { $link game-loop } ". Subsequent calls to " { $link benchmark-frames-per-second } " and " { $link benchmark-ticks-per-second } " will measure their values from the point " { $snippet "reset-loop-benchmark" } " was called." } ;
+
+HELP: start-loop
+{ $values
+    { "loop" game-loop }
+}
+{ $description "Starts running a " { $link game-loop } "." } ;
+
+HELP: stop-loop
+{ $values
+    { "loop" game-loop }
+}
+{ $description "Stops running a " { $link game-loop } "." } ;
+
+{ start-loop stop-loop } related-words
+
+HELP: tick*
+{ $values
+    { "delegate" "a " { $link "game.loop-delegates" } }
+}
+{ $description "This generic word is called by a " { $link game-loop } " on its " { $snippet "delegate" } " object at regular intervals while the game loop is running. The game loop's " { $snippet "tick-interval-micros" } " attribute determines the number of microseconds between invocations of " { $snippet "tick*" } "." } ;
+
+{ draw* tick* } related-words
+
+ARTICLE: "game.loop-delegates" "Game loop delegate"
+"A " { $link game-loop } " object requires a " { $snippet "delegate" } " that implements the logic that controls the game. A game loop delegate can be any object that provides two methods for the following generic words:"
+{ $subsections
+    tick*
+    draw*
+}
+{ $snippet "tick*" } " will be called at a regular interval determined by the game loop's " { $snippet "tick-interval-micros" } " attribute. " { $snippet "draw*" } " will be invoked in a tight loop, updating as frequently as possible." ;
+
+ARTICLE: "game.loop" "Game loops"
+"The " { $vocab-link "game.loop" } " vocabulary contains the implementation of a game loop. The game loop supports decoupled rendering and game logic timers; given a delegate object with methods on the " { $link tick* } " and " { $link draw* } " methods, the game loop will invoke the " { $snippet "tick*" } " method at regular intervals while invoking the " { $snippet "draw*" } " method as frequently as possible. Game loop objects must first be constructed:"
+{ $subsections
+    "game.loop-delegates"
+    <game-loop>
+}
+"Once constructed, the game loop can be started and stopped:"
+{ $subsections
+    start-loop
+    stop-loop
+}
+"The game loop maintains performance counters for measuring drawing frames and ticks per second:"
+{ $subsections
+    reset-loop-benchmark
+    benchmark-frames-per-second
+    benchmark-ticks-per-second
+}
+"The game loop manages errors that occur in the delegate's methods during the course of the game loop:"
+{ $subsections
+    game-loop-error
+}
+"The " { $vocab-link "game.worlds" } " vocabulary provides a convenient " { $link world } " subclass that integrates the game loop implementation with UI applications, managing the starting and stopping of the loop for you." ;
+
+ABOUT: "game.loop"
index 1346988fd187c7bf50a6f2222199498cbf968dfc..afe011cb7b8501eb98797958c0cb72556479dbf3 100644 (file)
@@ -1,10 +1,11 @@
+! (c)2009 Joe Groff bsd license
 USING: accessors calendar continuations destructors kernel math
 math.order namespaces system threads ui ui.gadgets.worlds
 sequences ;
 IN: game.loop
 
 TUPLE: game-loop
-    { tick-length integer read-only }
+    { tick-interval-micros integer read-only }
     delegate
     { last-tick integer }
     thread 
@@ -20,11 +21,11 @@ GENERIC: draw* ( tick-slice delegate -- )
 
 SYMBOL: game-loop
 
-: since-last-tick ( loop -- milliseconds )
-    last-tick>> millis swap - ;
+: since-last-tick ( loop -- microseconds )
+    last-tick>> system-micros swap - ;
 
 : tick-slice ( loop -- slice )
-    [ since-last-tick ] [ tick-length>> ] bi /f 1.0 min ;
+    [ since-last-tick ] [ tick-interval-micros>> ] bi /f 1.0 min ;
 
 CONSTANT: MAX-FRAMES-TO-SKIP 5
 
@@ -38,6 +39,9 @@ TUPLE: game-loop-error game-loop error ;
 : game-loop-error ( game-loop error -- )
     [ drop stop-loop ] [ \ game-loop-error boa ?ui-error ] 2bi ;
 
+: fps ( fps -- micros )
+    1,000,000 swap /i ; inline
+
 <PRIVATE
 
 : redraw ( loop -- )
@@ -49,12 +53,12 @@ TUPLE: game-loop-error game-loop error ;
 
 : increment-tick ( loop -- )
     [ 1 + ] change-tick-number
-    dup tick-length>> [ + ] curry change-last-tick
+    dup tick-interval-micros>> [ + ] curry change-last-tick
     drop ;
 
 : ?tick ( loop count -- )
-    [ millis >>last-tick drop ] [
-        over [ since-last-tick ] [ tick-length>> ] bi >=
+    [ system-micros >>last-tick drop ] [
+        over [ since-last-tick ] [ tick-interval-micros>> ] bi >=
         [ [ drop increment-tick ] [ drop tick ] [ 1 - ?tick ] 2tri ]
         [ 2drop ] if
     ] if-zero ;
@@ -69,24 +73,24 @@ TUPLE: game-loop-error game-loop error ;
     [ [ (run-loop) ] [ game-loop-error ] recover ]
     with-variable ;
 
-: benchmark-millis ( loop -- millis )
-    millis swap benchmark-time>> - ;
+: benchmark-micros ( loop -- micros )
+    system-micros swap benchmark-time>> - ;
 
 PRIVATE>
 
 : reset-loop-benchmark ( loop -- )
-    millis >>benchmark-time
+    system-micros >>benchmark-time
     dup tick-number>> >>benchmark-tick-number
     dup frame-number>> >>benchmark-frame-number
     drop ;
 
 : benchmark-ticks-per-second ( loop -- n )
-    [ tick-number>> ] [ benchmark-tick-number>> - ] [ benchmark-millis ] tri /f ;
+    [ tick-number>> ] [ benchmark-tick-number>> - ] [ benchmark-micros ] tri /f ;
 : benchmark-frames-per-second ( loop -- n )
-    [ frame-number>> ] [ benchmark-frame-number>> - ] [ benchmark-millis ] tri /f ;
+    [ frame-number>> ] [ benchmark-frame-number>> - ] [ benchmark-micros ] tri /f ;
 
 : start-loop ( loop -- )
-    millis >>last-tick
+    system-micros >>last-tick
     t >>running?
     [ reset-loop-benchmark ]
     [ [ run-loop ] curry "game loop" spawn ]
@@ -97,8 +101,8 @@ PRIVATE>
     f >>thread
     drop ;
 
-: <game-loop> ( tick-length delegate -- loop )
-    millis f f 0 0 millis 0 0
+: <game-loop> ( tick-interval-micros delegate -- loop )
+    system-micros f f 0 0 system-micros 0 0
     game-loop boa ;
 
 M: game-loop dispose
diff --git a/extra/game/loop/summary.txt b/extra/game/loop/summary.txt
new file mode 100644 (file)
index 0000000..e75ed94
--- /dev/null
@@ -0,0 +1 @@
+Game loop
diff --git a/extra/game/worlds/authors.txt b/extra/game/worlds/authors.txt
new file mode 100644 (file)
index 0000000..f13c9c1
--- /dev/null
@@ -0,0 +1 @@
+Joe Groff
diff --git a/extra/game/worlds/summary.txt b/extra/game/worlds/summary.txt
new file mode 100644 (file)
index 0000000..6a65cd7
--- /dev/null
@@ -0,0 +1 @@
+World class that integrates game loop and game input
diff --git a/extra/game/worlds/worlds-docs.factor b/extra/game/worlds/worlds-docs.factor
new file mode 100644 (file)
index 0000000..75aed4d
--- /dev/null
@@ -0,0 +1,54 @@
+! (c)2009 Joe Groff bsd license
+USING: audio.engine game.loop help.markup help.syntax kernel math method-chains
+ui ui.gadgets.worlds words ;
+IN: game.worlds
+
+HELP: game-attributes
+{ $class-description "Extends the " { $link world-attributes } " tuple class with extra attributes for " { $link game-world } "s:" }
+{ $list
+{ { $snippet "tick-interval-micros" } " specifies the number of microseconds between consecutive calls to the world's " { $link tick-game-world } " method by the game loop. An integer greater than zero must be provided." }
+{ { $snippet "use-game-input?" } " specifies whether the game world should initialize the " { $vocab-link "game.input" } " library for use by the game. False by default." }
+{ { $snippet "use-audio-engine?" } " specifies whether the game world should manage an " { $link audio-engine } " instance. False by default." }
+{ { $snippet "audio-engine-device" } " specifies the string name of the OpenAL device the audio engine, if any, should try to open. The default value of " { $link POSTPONE: f } " attempts to open the default OpenAL device." }
+{ { $snippet "audio-engine-voice-count" } " determines the number of independent voices the audio engine will make available. This determines how many individual audio clips can play simultaneously. This cannot exceed the OpenAL implementation's limit on supported voices." }
+{ { $snippet "audio-engine-buffer-size" } " determines the size in bytes of the audio buffers the audio engine will stream to the sound card." }
+{ { $snippet "audio-engine-buffer-count" } " determines the number of buffers the audio engine will allocate per audio clip played." }
+} ;
+
+HELP: game-world
+{ $class-description "A subclass of " { $link world } " that automatically sets up and manages connections to the " { $vocab-link "game.loop" } ", " { $vocab-link "game.input" } ", and " { $vocab-link "audio.engine" } " libraries. It does this by providing methods on " { $link begin-world } ", " { $link end-world } ", and " { $link draw* } ". Subclasses can provide their own world setup and teardown code by adding methods to the " { $link begin-game-world } " and " { $link end-game-world } " generic words."
+$nl
+"The game-world tuple has the following publicly accessible slots:"
+{ $list
+{ { $snippet "game-loop" } " contains the " { $link game-loop } " instance managed by the game world. If the world is inactive, this slot will contain " { $link POSTPONE: f } "." }
+{ { $snippet "audio-engine" } " contains the " { $link audio-engine } " instance managed by the game world. If the world is inactive, or the " { $snippet "use-audio-engine?" } " slot of the " { $link game-attributes } " object used to initialize the world was false, this slot will contain " { $link POSTPONE: f } "." }
+} } ;
+
+HELP: begin-game-world
+{ $values { "world" game-world } }
+{ $description "This generic word is called by the " { $link begin-world } " method for " { $link game-world } " subclasses immediately before the game world starts the game loop. If the game world has an " { $link audio-engine } ", it will be initialized and started before " { $snippet "begin-game-world" } " is called." } ;
+
+HELP: end-game-world
+{ $values { "world" game-world } }
+{ $description "This generic word is called by the " { $link end-world } " method for " { $link game-world } " subclasses immediately after the game world stops the game loop." } ;
+
+HELP: tick-game-world
+{ $values { "world" game-world } }
+{ $description "This generic word is called by the " { $link tick* } " method for " { $link game-world } " subclasses every time the game loop's tick interval occurs." } ;
+
+{ game-world begin-game-world end-game-world tick-game-world } related-words
+
+ARTICLE: "game.worlds" "Game worlds"
+"The " { $vocab-link "game.worlds" } " vocabulary provides a " { $link world } " subclass that integrates with " { $vocab-link "game.loop" } " and optionally " { $vocab-link "game.input" } " and " { $vocab-link "audio.engine" } " to quickly provide game infrastructure." 
+{ $subsections
+    game-world
+    game-attributes
+}
+"Subclasses of " { $link game-world } " can provide their own setup, teardown, and update code by providing methods for these generic words:"
+{ $subsections
+    begin-game-world
+    end-game-world
+    tick-game-world
+} ;
+
+ABOUT: "game.worlds"
index 399c5d19027689ec688a91b53ad81b03fee82a30..cf75d37b39c0c696605ed8482e0fc749a854e509 100644 (file)
@@ -1,23 +1,86 @@
-USING: accessors game.input game.loop kernel math ui.gadgets
-ui.gadgets.worlds ui.gestures threads ;
+! (c)2009 Joe Groff bsd license
+USING: accessors combinators fry game.input game.loop generic kernel math
+parser sequences ui ui.gadgets ui.gadgets.worlds ui.gestures threads
+words audio.engine destructors ;
 IN: game.worlds
 
 TUPLE: game-world < world
     game-loop
+    audio-engine
+    { tick-interval-micros fixnum }
+    { use-game-input? boolean }
+    { use-audio-engine? boolean }
+    { audio-engine-device initial: f }
+    { audio-engine-voice-count initial: 16 }
+    { audio-engine-buffer-size initial: 8192 }
+    { audio-engine-buffer-count initial: 2 }
     { tick-slice float initial: 0.0 } ;
 
-GENERIC: tick-length ( world -- millis )
+GENERIC: begin-game-world ( world -- )
+M: object begin-game-world drop ;
+
+GENERIC: end-game-world ( world -- )
+M: object end-game-world drop ;
+
+GENERIC: tick-game-world ( world -- )
+M: object tick-game-world drop ;
+
+M: game-world tick*
+    [ tick-game-world ]
+    [ audio-engine>> [ update-audio ] when* ] bi ;
 
 M: game-world draw*
     swap >>tick-slice relayout-1 yield ;
 
+<PRIVATE
+
+: open-game-audio-engine ( game-world -- audio-engine )
+    {
+        [ audio-engine-device>> ]
+        [ audio-engine-voice-count>> ]
+        [ audio-engine-buffer-size>> ]
+        [ audio-engine-buffer-count>> ]
+    } cleave <audio-engine>
+    [ start-audio* ] keep ; inline
+
+PRIVATE>
+
 M: game-world begin-world
-    open-game-input 
-    dup [ tick-length ] [ ] bi <game-loop> [ >>game-loop ] keep start-loop
+    dup use-game-input?>> [ open-game-input ] when
+    dup use-audio-engine?>> [ dup open-game-audio-engine >>audio-engine ] when
+    dup begin-game-world
+    dup [ tick-interval-micros>> ] [ ] bi <game-loop> [ >>game-loop ] keep start-loop
     drop ;
 
 M: game-world end-world
     [ [ stop-loop ] when* f ] change-game-loop
-    close-game-input
-    drop ;
+    [ end-game-world ]
+    [ audio-engine>> [ dispose ] when* ]
+    [ use-game-input?>> [ close-game-input ] when ] tri ;
+
+TUPLE: game-attributes < world-attributes
+    { tick-interval-micros fixnum }
+    { use-game-input? boolean initial: f }
+    { use-audio-engine? boolean initial: f }
+    { audio-engine-device initial: f }
+    { audio-engine-voice-count initial: 16 }
+    { audio-engine-buffer-size initial: 8192 }
+    { audio-engine-buffer-count initial: 2 } ;
+
+M: game-world apply-world-attributes
+    {
+        [ tick-interval-micros>> >>tick-interval-micros ]
+        [ use-game-input?>> >>use-game-input? ]
+        [ use-audio-engine?>> >>use-audio-engine? ]
+        [ audio-engine-device>> >>audio-engine-device ]
+        [ audio-engine-voice-count>> >>audio-engine-voice-count ]
+        [ audio-engine-buffer-size>> >>audio-engine-buffer-size ]
+        [ audio-engine-buffer-count>> >>audio-engine-buffer-count ]
+        [ call-next-method ]
+    } cleave ;
 
+SYNTAX: GAME:
+    CREATE
+    game-attributes parse-main-window-attributes
+    parse-definition
+    define-main-window ;
index bbd16b7ff47ffd51a95d1af271445210f4061b8a..c398bdde7aae956df300231a05e2da432d152182 100644 (file)
@@ -1,7 +1,8 @@
 ! Copyright (C) 2009 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: combinators combinators.smart csv io.encodings.8-bit
-math.parser memoize sequences kernel unicode.categories money ;
+math.parser memoize sequences kernel unicode.categories money
+io.encodings.8-bit.latin1 ;
 IN: geobytes
 
 ! GeoBytes is not free software.
old mode 100755 (executable)
new mode 100644 (file)
index 351a8b39b0c9432e8082cedeb3a4deef19ac3451..c29d9f2f102d14822cd2a7f7fd6d918066d685be 100644 (file)
@@ -1,7 +1,7 @@
 ! (c)2009 Joe Groff bsd license
 USING: accessors alien alien.c-types arrays byte-arrays
 combinators destructors gpu kernel locals math opengl opengl.gl
-ui.gadgets.worlds variants ;
+typed ui.gadgets.worlds variants ;
 IN: gpu.buffers
 
 VARIANT: buffer-upload-pattern
@@ -57,10 +57,10 @@ TUPLE: buffer < gpu-object
     } case ; inline
 
 : get-buffer-int ( target enum -- value )
-    0 <int> [ glGetBufferParameteriv ] keep *int ;
+    0 <int> [ glGetBufferParameteriv ] keep *int ; inline
 
 : bind-buffer ( buffer -- target )
-    [ kind>> gl-target dup ] [ handle>> glBindBuffer ] bi ;
+    [ kind>> gl-target dup ] [ handle>> glBindBuffer ] bi ; inline
 
 PRIVATE>
 
@@ -78,7 +78,7 @@ C: <buffer-range> buffer-range
 
 UNION: gpu-data-ptr buffer-ptr c-ptr ;
 
-: buffer-size ( buffer -- size )
+TYPED: buffer-size ( buffer: buffer -- size: integer )
     bind-buffer GL_BUFFER_SIZE get-buffer-int ;
 
 : buffer-ptr>range ( buffer-ptr -- buffer-range )
@@ -86,31 +86,42 @@ UNION: gpu-data-ptr buffer-ptr c-ptr ;
     2dup [ buffer-size ] dip -
     buffer-range boa ; inline
 
-:: allocate-buffer ( buffer size initial-data -- )
+TYPED:: allocate-buffer ( buffer: buffer size: integer initial-data -- )
     buffer bind-buffer :> target
     target size initial-data buffer gl-buffer-usage glBufferData ;
 
-: <buffer> ( upload usage kind size initial-data -- buffer )
+TYPED: <buffer> ( upload: buffer-upload-pattern
+                  usage: buffer-usage-pattern
+                  kind: buffer-kind
+                  size: integer
+                  initial-data
+                  --
+                  buffer: buffer )
     [ [ gen-gl-buffer ] 3dip buffer boa dup ] 2dip allocate-buffer
     window-resource ;
 
-: byte-array>buffer ( byte-array upload usage kind -- buffer )
+TYPED: byte-array>buffer ( byte-array
+                           upload: buffer-upload-pattern
+                           usage: buffer-usage-pattern
+                           kind: buffer-kind
+                           --
+                           buffer: buffer )
     [ ] 3curry dip
     [ byte-length ] [ ] bi <buffer> ;
 
-:: update-buffer ( buffer-ptr size data -- )
+TYPED:: update-buffer ( buffer-ptr: buffer-ptr size: integer data -- )
     buffer-ptr buffer>> :> buffer
     buffer bind-buffer :> target
     target buffer-ptr offset>> size data glBufferSubData ;
 
-:: read-buffer ( buffer-ptr size -- data )
+TYPED:: read-buffer ( buffer-ptr: buffer-ptr size: integer -- data: byte-array )
     buffer-ptr buffer>> :> buffer
     buffer bind-buffer :> target
     size <byte-array> :> data
     target buffer-ptr offset>> size data glGetBufferSubData
     data ;
 
-:: copy-buffer ( to-buffer-ptr from-buffer-ptr size -- )
+TYPED:: copy-buffer ( to-buffer-ptr: buffer-ptr from-buffer-ptr: buffer-ptr size: integer -- )
     GL_COPY_WRITE_BUFFER to-buffer-ptr buffer>> glBindBuffer
     GL_COPY_READ_BUFFER from-buffer-ptr buffer>> glBindBuffer
 
old mode 100755 (executable)
new mode 100644 (file)
index 0985326..b2f619c
@@ -1,17 +1,16 @@
 ! (c)2009 Joe Groff bsd license
 USING: accessors alien.c-types arrays classes.struct combinators
-combinators.short-circuit game.worlds gpu gpu.buffers
+combinators.short-circuit game.loop game.worlds gpu gpu.buffers
 gpu.util.wasd gpu.framebuffers gpu.render gpu.shaders gpu.state
 gpu.textures gpu.util grouping http.client images images.loader
 io io.encodings.ascii io.files io.files.temp kernel locals math
 math.matrices math.vectors.simd math.parser math.vectors
 method-chains namespaces sequences splitting threads ui ui.gadgets
 ui.gadgets.worlds ui.pixel-formats specialized-arrays
-specialized-vectors ;
+specialized-vectors literals ;
 FROM: alien.c-types => float ;
 SPECIALIZED-ARRAY: float
 SPECIALIZED-VECTOR: uint
-SIMD: float
 IN: gpu.demos.bunny
 
 GLSL-SHADER-FILE: bunny-vertex-shader vertex-shader "bunny.v.glsl"
@@ -215,7 +214,7 @@ CONSTANT: bunny-model-url "http://factorcode.org/bun_zipper.ply"
         dup 0 "vocab:gpu/demos/bunny/loading.tiff" load-image allocate-texture-image
         >>texture ;
 
-BEFORE: bunny-world begin-world
+M: bunny-world begin-game-world
     init-gpu
     
     { -0.2 0.13 0.1 } 1.1 0.2 set-wasd-view
@@ -294,24 +293,20 @@ M: bunny-world draw-world*
 AFTER: bunny-world resize-world
     [ sobel>> framebuffer>> ] [ dim>> ] bi resize-framebuffer ;
 
-M: bunny-world pref-dim* drop { 1024 768 } ;
-M: bunny-world tick-length drop 1000 30 /i ;
 M: bunny-world wasd-movement-speed drop 1/160. ;
 M: bunny-world wasd-near-plane drop 1/32. ;
 M: bunny-world wasd-far-plane drop 256.0 ;
 
-: bunny-window ( -- )
-    [
-        f T{ world-attributes
-            { world-class bunny-world }
-            { title "Bunny" }
-            { pixel-format-attributes {
-                windowed
-                double-buffered
-                T{ depth-bits { value 24 } }
-            } }
-            { grab-input? t }
-        } open-window
-    ] with-ui ;
-
-MAIN: bunny-window
+GAME: bunny-game {
+        { world-class bunny-world }
+        { title "Bunny" }
+        { pixel-format-attributes {
+            windowed
+            double-buffered
+            T{ depth-bits { value 24 } }
+        } }
+        { grab-input? t }
+        { use-game-input? t }
+        { pref-dim { 1024 768 } }
+        { tick-interval-micros $[ 60 fps ] }
+    } ;
diff --git a/extra/gpu/demos/raytrace/green-ball.aiff b/extra/gpu/demos/raytrace/green-ball.aiff
new file mode 100644 (file)
index 0000000..a7c0372
Binary files /dev/null and b/extra/gpu/demos/raytrace/green-ball.aiff differ
diff --git a/extra/gpu/demos/raytrace/mirror-ball.aiff b/extra/gpu/demos/raytrace/mirror-ball.aiff
new file mode 100644 (file)
index 0000000..a1cd163
Binary files /dev/null and b/extra/gpu/demos/raytrace/mirror-ball.aiff differ
index 5a3d5864fb09216fdde98b90785bf3d04e689def..54912544f1defa4ed9da9a497b208cb3ce8c5877 100644 (file)
@@ -1,9 +1,9 @@
 ! (c)2009 Joe Groff bsd license
 USING: accessors arrays combinators.tuple game.loop game.worlds
 generalizations gpu gpu.render gpu.shaders gpu.util gpu.util.wasd
-kernel literals math math.matrices math.order math.vectors
+kernel literals math math.libm math.matrices math.order math.vectors
 method-chains sequences ui ui.gadgets ui.gadgets.worlds
-ui.pixel-formats ;
+ui.pixel-formats audio.engine audio.loader locals ;
 IN: gpu.demos.raytrace
 
 GLSL-SHADER-FILE: raytrace-vertex-shader vertex-shader "raytrace.v.glsl"
@@ -49,6 +49,9 @@ TUPLE: raytrace-world < wasd-world
     [ [ axis>> ] [ theta>> ] bi rotation-matrix4 ]
     [ home>> ] bi m.v ;
 
+M: sphere audio-position sphere-center ; inline
+M: sphere audio-distance radius>> fsqrt 2.0 * ; inline
+
 : <sphere-uniforms> ( world -- uniforms )
     [ wasd-mv-inv-matrix ]
     [ fov>> ]
@@ -69,19 +72,36 @@ CONSTANT: initial-spheres {
     T{ sphere f { 1.0 0.0  0.0 } {  0.0 5.0 0.0 } 0.025 1.0 { 1.0 1.0 0.0 1.0 } }
 }
 
-BEFORE: raytrace-world begin-world
+:: set-up-audio ( world -- )
+    world audio-engine>> :> audio-engine
+    world spheres>> :> spheres
+
+    audio-engine world >>listener update-audio
+
+    audio-engine "vocab:gpu/demos/raytrace/mirror-ball.aiff" read-audio
+    spheres first t (audio-clip)
+    audio-engine "vocab:gpu/demos/raytrace/red-ball.aiff" read-audio
+    spheres second t (audio-clip)
+    audio-engine "vocab:gpu/demos/raytrace/green-ball.aiff" read-audio
+    spheres third t (audio-clip)
+    audio-engine "vocab:gpu/demos/raytrace/yellow-ball.aiff" read-audio
+    spheres fourth t (audio-clip)
+    
+    4array play-clips ;
+
+M: raytrace-world begin-game-world
     init-gpu
     { -2.0 6.25 10.0 } 0.19 0.55 set-wasd-view
     initial-spheres [ clone ] map >>spheres    
     raytrace-program <program-instance> <window-vertex-array> >>vertex-array
-    drop ;
+    set-up-audio ;
 
 CONSTANT: fov 0.7
 
 AFTER: raytrace-world resize-world
     dup dim>> dup first2 min >float v/n fov v*n >>fov drop ;
 
-AFTER: raytrace-world tick*
+AFTER: raytrace-world tick-game-world
     spheres>> [ tick-sphere ] each ;
 
 M: raytrace-world draw-world*
@@ -92,21 +112,19 @@ M: raytrace-world draw-world*
         { "vertex-array"   [ vertex-array>>              ] }
     } <render-set> render ;
 
-M: raytrace-world pref-dim* drop { 1024 768 } ;
-M: raytrace-world tick-length drop 1000 30 /i ;
 M: raytrace-world wasd-movement-speed drop 1/4. ;
 
-: raytrace-window ( -- )
-    [
-        f T{ world-attributes
-            { world-class raytrace-world }
-            { title "Raytracing" }
-            { pixel-format-attributes {
-                windowed
-                double-buffered
-            } }
-            { grab-input? t }
-        } open-window
-    ] with-ui ;
-
-MAIN: raytrace-window
+GAME: raytrace-game {
+        { world-class raytrace-world }
+        { title "Raytracing" }
+        { pixel-format-attributes {
+            windowed
+            double-buffered
+        } }
+        { grab-input? t }
+        { use-game-input? t }
+        { use-audio-engine? t }
+        { audio-engine-buffer-count 4 }
+        { pref-dim { 1024 768 } }
+        { tick-interval-micros $[ 60 fps ] }
+    } ;
diff --git a/extra/gpu/demos/raytrace/red-ball.aiff b/extra/gpu/demos/raytrace/red-ball.aiff
new file mode 100644 (file)
index 0000000..cd08e88
Binary files /dev/null and b/extra/gpu/demos/raytrace/red-ball.aiff differ
diff --git a/extra/gpu/demos/raytrace/yellow-ball.aiff b/extra/gpu/demos/raytrace/yellow-ball.aiff
new file mode 100644 (file)
index 0000000..63b3790
Binary files /dev/null and b/extra/gpu/demos/raytrace/yellow-ball.aiff differ
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index efd7178..1aa9ae3
@@ -3,7 +3,7 @@ USING: accessors alien.c-types arrays byte-arrays combinators
 destructors gpu gpu.buffers gpu.private gpu.textures
 gpu.textures.private images kernel locals math math.rectangles opengl
 opengl.framebuffers opengl.gl opengl.textures sequences
-specialized-arrays ui.gadgets.worlds variants ;
+specialized-arrays typed ui.gadgets.worlds variants ;
 SPECIALIZED-ARRAY: int
 SPECIALIZED-ARRAY: uint
 IN: gpu.framebuffers
@@ -22,7 +22,7 @@ TUPLE: renderbuffer < gpu-object
 
 PRIVATE>
 
-:: allocate-renderbuffer ( renderbuffer dim -- )
+TYPED:: allocate-renderbuffer ( renderbuffer: renderbuffer dim -- )
     GL_RENDERBUFFER renderbuffer handle>> glBindRenderbuffer
     GL_RENDERBUFFER
     renderbuffer samples>> dup zero?
@@ -30,12 +30,17 @@ PRIVATE>
     [ renderbuffer texture-gl-internal-format dim first2 glRenderbufferStorageMultisample ]
     if ;
 
-:: renderbuffer-dim ( renderbuffer -- dim )
+TYPED:: renderbuffer-dim ( renderbuffer: renderbuffer -- dim: array )
     GL_RENDERBUFFER renderbuffer handle>> glBindRenderbuffer
     GL_RENDERBUFFER_WIDTH get-framebuffer-int
     GL_RENDERBUFFER_HEIGHT get-framebuffer-int 2array ;
 
-: <renderbuffer> ( component-order component-type samples dim -- renderbuffer )
+TYPED: <renderbuffer> ( component-order: component-order
+                        component-type: component-type
+                        samples
+                        dim
+                        --
+                        renderbuffer )
     [ [ gen-renderbuffer ] 3dip renderbuffer boa dup ] dip
     [ allocate-renderbuffer ] [ drop ] if*
     window-resource ;
@@ -121,7 +126,10 @@ TUPLE: framebuffer-rect
 
 C: <framebuffer-rect> framebuffer-rect
 
-: framebuffer-attachment-at ( framebuffer attachment-ref -- attachment )
+TYPED: framebuffer-attachment-at ( framebuffer: framebuffer
+                                   attachment-ref: attachment-ref
+                                   --
+                                   attachment: framebuffer-attachment )
     {
         { default-attachment [ color-attachments>> first ] }
         { color-attachment [ swap color-attachments>> nth ] }
@@ -157,10 +165,13 @@ M: renderbuffer framebuffer-attachment-dim
     [ swap depth-attachment>>   [ swap call ] [ drop ] if* ]
     [ swap stencil-attachment>> [ swap call ] [ drop ] if* ] 2tri ; inline
 
-: each-attachment-target ( framebuffer quot: ( attachment-target attachment -- ) -- )
-    [ [ color-attachments>> ] dip [ GL_COLOR_ATTACHMENT0 + swap ] prepose each-index ]
-    [ swap depth-attachment>>   [ GL_DEPTH_ATTACHMENT   spin call ] [ drop ] if* ]
-    [ swap stencil-attachment>> [ GL_STENCIL_ATTACHMENT spin call ] [ drop ] if* ] 2tri ; inline
+:: each-attachment-target ( framebuffer quot: ( attachment-target attachment -- ) -- )
+    framebuffer color-attachments>>
+    [| attachment n | n GL_COLOR_ATTACHMENT0 + attachment quot call ] each-index
+    framebuffer depth-attachment>>
+    [| attachment | GL_DEPTH_ATTACHMENT attachment quot call ] when*
+    framebuffer stencil-attachment>>
+    [| attachment | GL_STENCIL_ATTACHMENT attachment quot call ] when* ; inline
 
 GENERIC: bind-framebuffer-attachment ( attachment-target attachment -- )
 
@@ -285,32 +296,42 @@ M: opengl-3 (clear-integer-color-attachment)
 
 PRIVATE>
 
-: <full-framebuffer-rect> ( framebuffer attachment -- framebuffer-rect )
+TYPED: <full-framebuffer-rect> ( framebuffer: any-framebuffer
+                                 attachment: attachment-ref
+                                 --
+                                 framebuffer-rect: framebuffer-rect )
     2dup framebuffer-attachment-at
     { 0 0 } swap framebuffer-attachment-dim <rect>
     <framebuffer-rect> ;
 
-: resize-framebuffer ( framebuffer dim -- )
+TYPED: resize-framebuffer ( framebuffer: framebuffer dim -- )
     [ allocate-framebuffer-attachment ] curry each-attachment ;
 
 :: attach-framebuffer-attachments ( framebuffer -- )
     GL_DRAW_FRAMEBUFFER framebuffer handle>> glBindFramebuffer
-    framebuffer [ bind-framebuffer-attachment ] each-attachment-target ;
+    framebuffer [ bind-framebuffer-attachment ] each-attachment-target ; inline
 
 M: framebuffer dispose
     [ [ delete-framebuffer ] when* f ] change-handle drop ;
 
-: dispose-framebuffer-attachments ( framebuffer -- )
+TYPED: dispose-framebuffer-attachments ( framebuffer: framebuffer -- )
     [ [ dispose ] when* ] each-attachment ;
 
-: <framebuffer> ( color-attachments depth-attachment stencil-attachment dim -- framebuffer )
+: <framebuffer> ( color-attachments
+                  depth-attachment: framebuffer-attachment
+                  stencil-attachment: framebuffer-attachment
+                  dim
+                  --
+                  framebuffer: framebuffer )
     [ [ 0 ] 3dip framebuffer boa dup ] dip
     [ resize-framebuffer ] [ drop ] if*
     gen-framebuffer >>handle
     dup attach-framebuffer-attachments
     window-resource ;
 
-:: clear-framebuffer-attachment ( framebuffer attachment-ref value -- )
+TYPED:: clear-framebuffer-attachment ( framebuffer: any-framebuffer
+                                       attachment-ref: attachment-ref
+                                       value -- )
     GL_DRAW_FRAMEBUFFER framebuffer framebuffer-handle glBindFramebuffer
     attachment-ref {
         { system-attachment [| side face |
@@ -332,9 +353,10 @@ M: framebuffer dispose
     } match ;
 
 : clear-framebuffer ( framebuffer alist -- )
-    [ first2 clear-framebuffer-attachment ] with each ;
+    [ first2 clear-framebuffer-attachment ] with each ; inline
 
-:: read-framebuffer-to ( framebuffer-rect gpu-data-ptr -- )
+TYPED:: read-framebuffer-to ( framebuffer-rect: framebuffer-rect
+                              gpu-data-ptr -- )
     GL_READ_FRAMEBUFFER framebuffer-rect framebuffer>> framebuffer-handle glBindFramebuffer
     framebuffer-rect [ framebuffer>> ] [ attachment>> ] bi gl-attachment glReadBuffer
     framebuffer-rect rect>> [ loc>> first2 ] [ dim>> first2 ] bi 
@@ -342,9 +364,9 @@ M: framebuffer dispose
     gpu-data-ptr pixel-pack-buffer [ glReadPixels ] with-gpu-data-ptr ;
     
 : read-framebuffer ( framebuffer-rect -- byte-array )
-    dup framebuffer-rect-size <byte-array> [ read-framebuffer-to ] keep ;
+    dup framebuffer-rect-size <byte-array> [ read-framebuffer-to ] keep ; inline
 
-: read-framebuffer-image ( framebuffer-rect -- image )
+TYPED: read-framebuffer-image ( framebuffer-rect -- image )
     [ <image> ] dip {
         [ rect>> dim>> >>dim ]
         [
@@ -354,7 +376,9 @@ M: framebuffer dispose
         [ read-framebuffer >>bitmap ] 
     } cleave ;
 
-:: copy-framebuffer ( to-fb-rect from-fb-rect depth? stencil? filter -- )
+TYPED:: copy-framebuffer ( to-fb-rect: framebuffer-rect
+                           from-fb-rect: framebuffer-rect
+                           depth? stencil? filter: texture-filter -- )
     GL_DRAW_FRAMEBUFFER to-fb-rect framebuffer>> framebuffer-handle glBindFramebuffer
     to-fb-rect [ framebuffer>> ] [ attachment>> ] bi gl-attachment glDrawBuffer
     GL_READ_FRAMEBUFFER from-fb-rect framebuffer>> framebuffer-handle glBindFramebuffer
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 1a13d3e55630cf73c72b142e5d418dd603eb337c..3baa6fcfca01b767c8af882a58b98439fa259353 100644 (file)
@@ -120,7 +120,7 @@ ERROR: invalid-uniform-type uniform ;
         { ubyte-indexes  [ GL_UNSIGNED_BYTE  ] }
         { ushort-indexes [ GL_UNSIGNED_SHORT ] }
         { uint-indexes   [ GL_UNSIGNED_INT   ] }
-    } case ;
+    } case ; inline
 
 : gl-primitive-mode ( primitive-mode -- gl-primitive-mode ) 
     {
@@ -131,7 +131,7 @@ ERROR: invalid-uniform-type uniform ;
         { triangles-mode      [ GL_TRIANGLES      ] }
         { triangle-strip-mode [ GL_TRIANGLE_STRIP ] }
         { triangle-fan-mode   [ GL_TRIANGLE_FAN   ] }
-    } case ;
+    } case ; inline
 
 GENERIC: render-vertex-indexes ( primitive-mode vertex-indexes -- )
 
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index fc6d495..2c321fe
@@ -8,7 +8,7 @@ literals locals math math.parser memoize multiline namespaces
 opengl opengl.gl opengl.shaders parser quotations sequences
 specialized-arrays splitting strings tr ui.gadgets.worlds
 variants vectors vocabs vocabs.loader vocabs.parser words
-words.constant half-floats ;
+words.constant half-floats typed ;
 QUALIFIED-WITH: alien.c-types c
 SPECIALIZED-ARRAY: int
 SPECIALIZED-ARRAY: void*
@@ -322,13 +322,17 @@ M: vertex-array dispose
     gen-vertex-array
     [ glBindVertexArray [ first2 bind-vertex-format ] with each ]
     [ -rot [ first buffer>> ] map vertex-array boa ] 3bi
-    window-resource ;
+    window-resource ; inline
 
-: buffer>vertex-array ( vertex-buffer program-instance format -- vertex-array )
+TYPED: buffer>vertex-array ( vertex-buffer: buffer
+                             program-instance: program-instance
+                             format: vertex-format
+                             --
+                             vertex-array: vertex-array )
     [ swap ] dip
     [ 0 <buffer-ptr> ] dip 2array 1array <vertex-array> ; inline
 
-: vertex-array-buffer ( vertex-array -- vertex-buffer )
+TYPED: vertex-array-buffer ( vertex-array: vertex-array -- vertex-buffer: buffer )
     vertex-buffers>> first ;
 
 TUPLE: compile-shader-error shader log ;
@@ -406,7 +410,7 @@ DEFER: <shader-instance>
 
 PRIVATE>
 
-:: refresh-program ( program -- )
+TYPED:: refresh-program ( program: program -- )
     program shaders>> [ refresh-shader-source ] each
     program instances>> [| world old-instance |
         old-instance valid-handle? [
@@ -426,10 +430,10 @@ PRIVATE>
     ] assoc-each
     reset-memos ;
 
-: <shader-instance> ( shader -- instance )
+TYPED: <shader-instance> ( shader: shader -- instance: shader-instance )
     [ find-shader-instance dup world get ] keep instances>> set-at ;
 
-: <program-instance> ( program -- instance )
+TYPED: <program-instance> ( program: program -- instance: program-instance )
     [ find-program-instance dup world get ] keep instances>> set-at ;
 
 <PRIVATE
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 1a840ea..3064ed4
@@ -1,7 +1,7 @@
 ! (c)2009 Joe Groff bsd license
 USING: accessors alien.c-types alien.data arrays byte-arrays
 combinators gpu kernel literals math math.rectangles opengl
-opengl.gl sequences variants specialized-arrays ;
+opengl.gl sequences typed variants specialized-arrays ;
 QUALIFIED-WITH: alien.c-types c
 FROM: math => float ;
 SPECIALIZED-ARRAY: int
@@ -439,15 +439,15 @@ M: mask-state set-gpu-state*
 
 PRIVATE>
 
-: get-viewport-state ( -- viewport-state )
+TYPED: get-viewport-state ( -- viewport-state: viewport-state )
     GL_VIEWPORT get-gl-rect <viewport-state> ;
 
-: get-scissor-state ( -- scissor-state )
+TYPED: get-scissor-state ( -- scissor-state: scissor-state )
     GL_SCISSOR_TEST get-gl-bool
     [ GL_SCISSOR_BOX get-gl-rect ] [ f ] if
     <scissor-state> ;
 
-: get-multisample-state ( -- multisample-state )
+TYPED: get-multisample-state ( -- multisample-state: multisample-state )
     GL_MULTISAMPLE gl-enabled?
     GL_SAMPLE_ALPHA_TO_COVERAGE gl-enabled?
     GL_SAMPLE_ALPHA_TO_ONE gl-enabled?
@@ -457,7 +457,7 @@ PRIVATE>
     ] [ f f ] if
     <multisample-state> ;
 
-: get-stencil-state ( -- stencil-state )
+TYPED: get-stencil-state ( -- stencil-state: stencil-state )
     GL_STENCIL_TEST gl-enabled? [
         GL_STENCIL_REF get-gl-int
         GL_STENCIL_VALUE_MASK get-gl-int
@@ -477,15 +477,15 @@ PRIVATE>
     ] [ f f ] if
     <stencil-state> ;
 
-: get-depth-range-state ( -- depth-range-state )
+TYPED: get-depth-range-state ( -- depth-range-state: depth-range-state )
     GL_DEPTH_RANGE 2 get-gl-floats first2 <depth-range-state> ;
 
-: get-depth-state ( -- depth-state )
+TYPED: get-depth-state ( -- depth-state: depth-state )
     GL_DEPTH_TEST gl-enabled?
     [ GL_DEPTH_FUNC get-gl-int gl-comparison> ] [ f ] if
     <depth-state> ;
 
-: get-blend-state ( -- blend-state )
+TYPED: get-blend-state ( -- blend-state: blend-state )
     GL_BLEND gl-enabled? [
         GL_BLEND_COLOR 4 get-gl-floats
 
@@ -501,34 +501,34 @@ PRIVATE>
     ] [ f f f ] if
     <blend-state> ;
 
-: get-mask-state ( -- mask-state )
+TYPED: get-mask-state ( -- mask-state: mask-state )
     GL_COLOR_WRITEMASK 4 get-gl-bools 
     GL_DEPTH_WRITEMASK get-gl-bool
     GL_STENCIL_WRITEMASK get-gl-int
     GL_STENCIL_BACK_WRITEMASK get-gl-int
     <mask-state> ;
 
-: get-triangle-cull-state ( -- triangle-cull-state )
+TYPED: get-triangle-cull-state ( -- triangle-cull-state: triangle-cull-state )
     GL_FRONT_FACE get-gl-int gl-triangle-face>
     GL_CULL_FACE gl-enabled?
     [ GL_CULL_FACE_MODE get-gl-int gl-triangle-cull> ]
     [ f ] if
     <triangle-cull-state> ;
 
-: get-triangle-state ( -- triangle-state )
+TYPED: get-triangle-state ( -- triangle-state: triangle-state )
     GL_POLYGON_MODE 2 get-gl-ints
     first2 [ gl-triangle-mode> ] bi@
     GL_POLYGON_SMOOTH gl-enabled?
     <triangle-state> ;
 
-: get-point-state ( -- point-state )
+TYPED: get-point-state ( -- point-state: point-state )
     GL_VERTEX_PROGRAM_POINT_SIZE gl-enabled?
     [ f ] [ GL_POINT_SIZE get-gl-float ] if
     GL_POINT_SPRITE_COORD_ORIGIN get-gl-int gl-point-sprite-origin> 
     GL_POINT_FADE_THRESHOLD_SIZE get-gl-float
     <point-state> ;
 
-: get-line-state ( -- line-state )
+TYPED: get-line-state ( -- line-state: line-state )
     GL_LINE_WIDTH get-gl-float
     GL_LINE_SMOOTH gl-enabled?
     <line-state> ;
index 2649f7c586607987e20e1543ca211790bcc3608f..ba2e2c32a0bd527ec4a0efe7598521af76f83f0c 100644 (file)
@@ -2,7 +2,7 @@
 USING: accessors alien.c-types arrays byte-arrays combinators
 destructors fry gpu gpu.buffers images kernel locals math
 opengl opengl.gl opengl.textures sequences
-specialized-arrays ui.gadgets.worlds variants ;
+specialized-arrays typed ui.gadgets.worlds variants ;
 FROM: alien.c-types => float ;
 SPECIALIZED-ARRAY: float
 IN: gpu.textures
@@ -72,9 +72,9 @@ TUPLE: texture-parameters
 
 GENERIC: texture-object ( texture-data-target -- texture )
 M: cube-map-face texture-object
-    texture>> ;
+    texture>> ; inline
 M: texture texture-object
-    ;
+    ; inline
 
 : gl-wrap ( wrap -- gl-wrap )
     {
@@ -82,20 +82,20 @@ M: texture texture-object
         { clamp-texcoord-to-border [ GL_CLAMP_TO_BORDER ] }
         { repeat-texcoord [ GL_REPEAT ] }
         { repeat-texcoord-mirrored [ GL_MIRRORED_REPEAT ] }
-    } case ;
+    } case ; inline
 
 : set-texture-gl-wrap ( target wraps -- )
     dup sequence? [ 1array ] unless 3 over last pad-tail {
         [ [ GL_TEXTURE_WRAP_S ] dip first  gl-wrap glTexParameteri ]
         [ [ GL_TEXTURE_WRAP_T ] dip second gl-wrap glTexParameteri ]
         [ [ GL_TEXTURE_WRAP_R ] dip third  gl-wrap glTexParameteri ]
-    } 2cleave ;
+    } 2cleave ; inline
 
 : gl-mag-filter ( filter -- gl-filter )
     {
         { filter-nearest [ GL_NEAREST ] }
         { filter-linear [ GL_LINEAR ] }
-    } case ;
+    } case ; inline
 
 : gl-min-filter ( filter mipmap-filter -- gl-filter )
     2array {
@@ -105,25 +105,25 @@ M: texture texture-object
         { { filter-linear  filter-nearest } [ GL_LINEAR_MIPMAP_NEAREST  ] }
         { { filter-linear  filter-linear  } [ GL_LINEAR_MIPMAP_LINEAR   ] }
         { { filter-nearest filter-linear  } [ GL_NEAREST_MIPMAP_LINEAR  ] }
-    } case ;
+    } case ; inline
 
 GENERIC: texture-gl-target ( texture -- target )
 GENERIC: texture-data-gl-target ( texture -- target )
 
-M: texture-1d        texture-gl-target drop GL_TEXTURE_1D ;
-M: texture-2d        texture-gl-target drop GL_TEXTURE_2D ;
-M: texture-rectangle texture-gl-target drop GL_TEXTURE_RECTANGLE ;
-M: texture-3d        texture-gl-target drop GL_TEXTURE_3D ;
-M: texture-cube-map  texture-gl-target drop GL_TEXTURE_CUBE_MAP ;
-M: texture-1d-array  texture-gl-target drop GL_TEXTURE_1D_ARRAY ;
-M: texture-2d-array  texture-gl-target drop GL_TEXTURE_2D_ARRAY ;
-
-M: texture-1d        texture-data-gl-target drop GL_TEXTURE_1D ;
-M: texture-2d        texture-data-gl-target drop GL_TEXTURE_2D ;
-M: texture-rectangle texture-data-gl-target drop GL_TEXTURE_RECTANGLE ;
-M: texture-3d        texture-data-gl-target drop GL_TEXTURE_3D ;
-M: texture-1d-array  texture-data-gl-target drop GL_TEXTURE_1D_ARRAY ;
-M: texture-2d-array  texture-data-gl-target drop GL_TEXTURE_2D_ARRAY ;
+M: texture-1d        texture-gl-target drop GL_TEXTURE_1D ; inline
+M: texture-2d        texture-gl-target drop GL_TEXTURE_2D ; inline
+M: texture-rectangle texture-gl-target drop GL_TEXTURE_RECTANGLE ; inline
+M: texture-3d        texture-gl-target drop GL_TEXTURE_3D ; inline
+M: texture-cube-map  texture-gl-target drop GL_TEXTURE_CUBE_MAP ; inline
+M: texture-1d-array  texture-gl-target drop GL_TEXTURE_1D_ARRAY ; inline
+M: texture-2d-array  texture-gl-target drop GL_TEXTURE_2D_ARRAY ; inline
+
+M: texture-1d        texture-data-gl-target drop GL_TEXTURE_1D ; inline
+M: texture-2d        texture-data-gl-target drop GL_TEXTURE_2D ; inline
+M: texture-rectangle texture-data-gl-target drop GL_TEXTURE_RECTANGLE ; inline
+M: texture-3d        texture-data-gl-target drop GL_TEXTURE_3D ; inline
+M: texture-1d-array  texture-data-gl-target drop GL_TEXTURE_1D_ARRAY ; inline
+M: texture-2d-array  texture-data-gl-target drop GL_TEXTURE_2D_ARRAY ; inline
 M: cube-map-face     texture-data-gl-target
     axis>> {
         { -X [ GL_TEXTURE_CUBE_MAP_NEGATIVE_X ] }
@@ -132,7 +132,7 @@ M: cube-map-face     texture-data-gl-target
         { +X [ GL_TEXTURE_CUBE_MAP_POSITIVE_X ] }
         { +Y [ GL_TEXTURE_CUBE_MAP_POSITIVE_Y ] }
         { +Z [ GL_TEXTURE_CUBE_MAP_POSITIVE_Z ] }
-    } case ;
+    } case ; inline
 
 : texture-gl-internal-format ( texture -- internal-format )
     [ component-order>> ] [ component-type>> ] bi image-internal-format ; inline
@@ -144,20 +144,20 @@ M: cube-map-face     texture-data-gl-target
         [ ptr>> ] bi
     ] [
         [ component-order>> ] [ component-type>> ] bi image-data-format f
-    ] if* ;
+    ] if* ; inline
 
 :: bind-tdt ( tdt -- texture )
     tdt texture-object :> texture
     texture [ texture-gl-target ] [ handle>> ] bi glBindTexture
-    texture ;
+    texture ; inline
 
 : get-texture-float ( target level enum -- value )
-    0 <float> [ glGetTexLevelParameterfv ] keep *float ;
+    0 <float> [ glGetTexLevelParameterfv ] keep *float ; inline
 : get-texture-int ( target level enum -- value )
-    0 <int> [ glGetTexLevelParameteriv ] keep *int ;
+    0 <int> [ glGetTexLevelParameteriv ] keep *int ; inline
 
 : ?product ( x -- y )
-    dup number? [ product ] unless ;
+    dup number? [ product ] unless ; inline
 
 PRIVATE>
 
@@ -228,39 +228,39 @@ M:: texture-3d-data-target texture-dim ( tdt level -- dim )
     3array ;
 
 : texture-data-size ( tdt level -- size )
-    [ texture-dim ?product ] [ drop texture-object bytes-per-pixel ] 2bi * ;
+    [ texture-dim ?product ] [ drop texture-object bytes-per-pixel ] 2bi * ; inline
 
-:: read-texture-to ( tdt level gpu-data-ptr -- )
+TYPED:: read-texture-to ( tdt: texture-data-target level: integer gpu-data-ptr -- )
     tdt bind-tdt :> texture
     tdt texture-data-gl-target level
     texture [ component-order>> ] [ component-type>> ] bi image-data-format
     gpu-data-ptr pixel-pack-buffer [ glGetTexImage ] with-gpu-data-ptr ;
 
-: read-texture ( tdt level -- byte-array )
+TYPED: read-texture ( tdt: texture-data-target level: integer -- byte-array: byte-array )
     2dup texture-data-size <byte-array>
     [ read-texture-to ] keep ;
 
 : allocate-texture-image ( tdt level image -- )
-    image>texture-data allocate-texture ;
+    image>texture-data allocate-texture ; inline
 
 : update-texture-image ( tdt level loc image -- )
-    image>texture-data update-texture ;
+    image>texture-data update-texture ; inline
 
 : read-texture-image ( tdt level -- image )
     [ texture-dim ]
     [ drop texture-object [ component-order>> ] [ component-type>> ] bi f ]
     [ read-texture ] 2tri
-    image boa ;
+    image boa ; inline
 
 <PRIVATE
 : bind-texture ( texture -- gl-target )
-    [ texture-gl-target dup ] [ handle>> ] bi glBindTexture ;
+    [ texture-gl-target dup ] [ handle>> ] bi glBindTexture ; inline
 PRIVATE>
 
 : generate-mipmaps ( texture -- )
-    bind-texture glGenerateMipmap ;
+    bind-texture glGenerateMipmap ; inline
 
-: set-texture-parameters ( texture parameters -- )
+TYPED: set-texture-parameters ( texture: texture parameters: texture-parameters -- )
     [ bind-texture ] dip {
         [ wrap>> set-texture-gl-wrap ]
         [
@@ -286,17 +286,17 @@ PRIVATE>
 PRIVATE>
 
 : <texture-1d> ( component-order component-type parameters -- texture )
-    texture-1d <texture> ;
+    texture-1d <texture> ; inline
 : <texture-2d> ( component-order component-type parameters -- texture )
-    texture-2d <texture> ;
+    texture-2d <texture> ; inline
 : <texture-3d> ( component-order component-type parameters -- texture )
-    texture-3d <texture> ;
+    texture-3d <texture> ; inline
 : <texture-cube-map> ( component-order component-type parameters -- texture )
-    texture-cube-map <texture> ;
+    texture-cube-map <texture> ; inline
 : <texture-rectangle> ( component-order component-type parameters -- texture )
-    texture-rectangle <texture> ;
+    texture-rectangle <texture> ; inline
 : <texture-1d-array> ( component-order component-type parameters -- texture )
-    texture-1d-array <texture> ;
+    texture-1d-array <texture> ; inline
 : <texture-2d-array> ( component-order component-type parameters -- texture )
-    texture-2d-array <texture> ;
+    texture-2d-array <texture> ; inline
 
index 1c9c8e629ccf3624f35fdc54dd2a4e0c14b45d3b..ccabd3d3087ed0aea81b56fb604aee0d263a887d 100644 (file)
@@ -59,7 +59,7 @@ CONSTANT: window-vertexes
 : <window-vertex-buffer> ( -- buffer )
     window-vertexes 
     static-upload draw-usage vertex-buffer
-    byte-array>buffer ;
+    byte-array>buffer ; inline
 
 : <window-vertex-array> ( program-instance -- vertex-array )
-    [ <window-vertex-buffer> ] dip window-vertex buffer>vertex-array ;
+    [ <window-vertex-buffer> ] dip window-vertex buffer>vertex-array ; inline
index b5ed28cc3d8947152a2cf7bb0a779eaf5fe52f66..8251fe21b6dd9723b5d21584fad3a76e06783ba5 100644 (file)
@@ -4,7 +4,7 @@ game.input.scancodes game.loop game.worlds
 gpu.render gpu.state kernel literals
 locals math math.constants math.functions math.matrices
 math.order math.vectors opengl.gl sequences
-ui ui.gadgets.worlds specialized-arrays ;
+ui ui.gadgets.worlds specialized-arrays audio.engine ;
 FROM: alien.c-types => float ;
 SPECIALIZED-ARRAY: float
 IN: gpu.util.wasd
@@ -87,6 +87,9 @@ CONSTANT: fov 0.7
     [ yaw>> ] [ ?pitch ] [ wasd-movement-speed ] tri
     { 1.0 0.0 0.0 } n*v eye-rotate ;
 
+M: wasd-world audio-position location>> ; inline
+M: wasd-world audio-orientation forward-vector { 0.0 1.0 0.0 } <audio-orientation> ; inline
+
 : walk-forward ( world -- )
     dup forward-vector [ v+ ] curry change-location drop ;
 : walk-backward ( world -- )
@@ -121,7 +124,7 @@ CONSTANT: fov 0.7
 : wasd-mouse-input ( world -- )
     read-mouse rotate-with-mouse ;
 
-M: wasd-world tick*
+M: wasd-world tick-game-world
     dup focused?>> [
         [ wasd-keyboard-input ] [ wasd-mouse-input ] bi
         reset-mouse
diff --git a/extra/grid-meshes/grid-meshes-tests.factor b/extra/grid-meshes/grid-meshes-tests.factor
new file mode 100644 (file)
index 0000000..ef71a66
--- /dev/null
@@ -0,0 +1,21 @@
+IN: grid-meshes.tests
+USING: alien.c-types grid-meshes grid-meshes.private
+specialized-arrays tools.test ;
+SPECIALIZED-ARRAY: float
+
+[
+    float-array{
+        0.0 0.0 0.0 1.0
+        0.0 0.0 0.5 1.0
+        0.5 0.0 0.0 1.0
+        0.5 0.0 0.5 1.0
+        1.0 0.0 0.0 1.0
+        1.0 0.0 0.5 1.0
+        0.0 0.0 0.5 1.0
+        0.0 0.0 1.0 1.0
+        0.5 0.0 0.5 1.0
+        0.5 0.0 1.0 1.0
+        1.0 0.0 0.5 1.0
+        1.0 0.0 1.0 1.0
+    }
+] [ { 2 2 } vertex-array byte-array>float-array ] unit-test
index ebde0b26416d340c6fcf81b9d227afecb7933320..47f649868ea4ec3ef7d5c0b6d99d6a720fda71c6 100644 (file)
@@ -3,7 +3,6 @@ USING: accessors alien.data.map arrays destructors fry grouping
 kernel math math.ranges math.vectors.simd opengl opengl.gl sequences
 sequences.product specialized-arrays ;
 FROM: alien.c-types => float ;
-SIMD: float
 SPECIALIZED-ARRAY: float-4
 IN: grid-meshes
 
old mode 100755 (executable)
new mode 100644 (file)
index 784c34cf7076a509216b1d5ec5d4505d153ccce1..ceff9857cb4b9e77e1af419521a67526281b7a4e 100644 (file)
@@ -1,14 +1,14 @@
 USING: tools.deploy.config ;
 H{
+    { deploy-name "Hello world" }
+    { deploy-ui? t }
     { deploy-c-types? f }
     { deploy-unicode? f }
-    { deploy-word-defs? f }
-    { deploy-name "Hello world" }
     { "stop-after-last-window?" t }
-    { deploy-reflection 1 }
-    { deploy-ui? t }
-    { deploy-math? t }
     { deploy-io 1 }
+    { deploy-reflection 1 }
     { deploy-word-props? f }
+    { deploy-math? t }
     { deploy-threads? t }
+    { deploy-word-defs? f }
 }
index 3843eec091301d8b9b49f5cb73461d7248c8bfcf..9ed9457d5ad5ed1483e0e99dea81e12875fe17b0 100644 (file)
@@ -1,7 +1,5 @@
-USING: ui ui.gadgets.labels ;
+USING: accessors ui ui.gadgets.labels ;
 IN: hello-ui
 
-: hello ( -- )
-    [ "Hello world" <label> "Hi" open-window ] with-ui ;
-
-MAIN: hello
+MAIN-WINDOW: hello { { title "Hi" } }
+    "Hello world" <label> >>gadgets ;
index 4374db20031d427d2e216163d155b1ab74d3bf5c..f088fdd53b65b5ab791e1da249b4c95428310ee1 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: ui.gadgets.panes ui.gadgets.borders ui io io.styles ;
+USING: accessors ui.gadgets.panes ui.gadgets.borders ui io io.styles ;
 IN: hello-unicode
 
 : <hello-gadget> ( -- gadget )
@@ -15,6 +15,5 @@ IN: hello-unicode
         ] with-style
     ] make-pane { 10 10 } <border> ;
 
-: hello-unicode ( -- ) [ <hello-gadget> "გამარჯობა" open-window ] with-ui ;
-
-MAIN: hello-unicode
\ No newline at end of file
+MAIN-WINDOW: hello-unicode { { title "გამარჯობა" } }
+    <hello-gadget> >>gadgets ;
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 10fcd9c..2d0b951
@@ -61,10 +61,10 @@ TUPLE: link attributes clickable ;
     ] map ;
 
 : find-by-id ( vector id -- vector' elt/f )
-    '[ attributes>> "id" at _ = ] find ;
+    '[ attributes>> "id" swap at _ = ] find ;
     
 : find-by-class ( vector id -- vector' elt/f )
-    '[ attributes>> "class" at _ = ] find ;
+    '[ attributes>> "class" swap at _ = ] find ;
 
 : find-by-name ( vector string -- vector elt/f )
     >lower '[ name>> _ = ] find ;
index 9fcbffd0db31daa220a9e18a125bb3c324cb70be..8d506cda28539a3b3efc098c5c7e8baa1fc7668a 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2008 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors arrays hashtables sequence-parser
+USING: accessors arrays hashtables sequences.parser
 html.parser.utils kernel namespaces sequences math
 unicode.case unicode.categories combinators.short-circuit
 quoting fry ;
old mode 100755 (executable)
new mode 100644 (file)
index 9bb755807771054a1aaf8cda2a74ec6abd8f058d..bc3a387fd0cc4aa4b5e0bee8593de40527c5788a 100644 (file)
@@ -43,4 +43,4 @@ IN: id3.tests
 
 
 [ t ]
-[ 10000 [ synchsafe>seq seq>synchsafe ] map [ < ] monotonic? ] unit-test
+[ 10000 iota [ synchsafe>seq seq>synchsafe ] map [ < ] monotonic? ] unit-test
index 917480dd3ffe89a276158b4857c4f31fcf2aaf82..9c42bf256b84138e44984a73583ccf02264a5955 100644 (file)
@@ -68,9 +68,9 @@ $nl
 "Please note: in Factor " { $emphasis "fixnums are sequences too." } " If you are not careful with sequence accesses you may introduce subtle bugs:"
 { $example
     "USING: arrays infix locals ;"
-    ":: add-2nd-element ( x y -- res )"
+    ":: add-2nd-elements ( x y -- res )"
     "    [infix x[1] + y[1] infix] ;"
-    "{ 1 2 3 } 5 add-2nd-element ."
+    "{ 1 2 3 } { 0 1 2 3 } add-2nd-elements ."
     "3"
 }
 ;
index 1d1e217ba0ce9ee9102749da0c1366fcd8e6b49d..172786126914ed5e37c54c1add614a6ce03964f0 100644 (file)
@@ -1,6 +1,7 @@
 ! Copyright (C) 2008 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: alien.syntax classes.struct kernel sequences system ;
+USING: alien.c-types alien.syntax classes.struct kernel
+sequences system ;
 IN: io.serial.unix.termios
 
 CONSTANT: NCCS 20
index 0982339cf8994913072a4105f018ad86f858c191..1e9dce49c7174248846dfe570b2e31dd2cfaa4d8 100644 (file)
@@ -1,6 +1,7 @@
 ! Copyright (C) 2008 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: alien.syntax classes.struct kernel system unix ;
+USING: alien.c-types alien.syntax classes.struct kernel system
+unix ;
 IN: io.serial.unix.termios
 
 CONSTANT: NCCS 32
old mode 100755 (executable)
new mode 100644 (file)
index 551fd16..645e493
@@ -11,8 +11,7 @@ IN: io.serial.windows
 
 : get-comm-state ( duplex -- dcb )
     in>> handle>>
-    DCB <struct> tuck
-    GetCommState win32-error=0/f ;
+    DCB <struct> [ GetCommState win32-error=0/f ] keep ;
 
 : set-comm-state ( duplex dcb -- )
     [ in>> handle>> ] dip
index 3f6cf4945d8df49402d5b558584383c92bd46895..8a87c1a6132b9151b0ace18ebb4bf4a5f1110fd7 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2009 Bruno Deferrari
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors concurrency.mailboxes kernel calendar io.sockets io.encodings.8-bit
-destructors arrays sequences ;
+USING: accessors concurrency.mailboxes kernel calendar io.sockets
+destructors arrays sequences io.encodings.8-bit.latin1 ;
 IN: irc.client.chats
 
 CONSTANT: irc-port 6667 ! Default irc port
old mode 100755 (executable)
new mode 100644 (file)
index ef1695f5634ed6a588a645f4c59dd8a2aa53a8c9..f2030e87b018bab93d3c9059668ee4638e8eaa84 100644 (file)
@@ -26,7 +26,7 @@ IN: irc.client.internals
     irc> [ connect>> ] [ reconnect-attempts>> ] bi do-connect ;
 
 : /JOIN ( channel password -- )
-    [ " :" swap 3append ] when* "JOIN " prepend irc-print ;
+    [ " :" glue ] when* "JOIN " prepend irc-print ;
 
 : try-connect ( -- stream/f )
     irc> profile>> [ server>> ] [ port>> ] bi /CONNECT ;
index 161a81d555cca122d66373cedcd1941b82246e5d..0963765482275ba61681a2b3411f9df6a4000579 100644 (file)
@@ -1,8 +1,9 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: fry irc.client irc.client.chats kernel namespaces
-sequences threads io.encodings.8-bit io.launcher io splitting
-make mason.common mason.updates calendar math alarms ;
+sequences threads io.launcher io splitting
+make mason.common mason.updates calendar math alarms
+io.encodings.8-bit.latin1 ;
 IN: irc.gitbot
 
 : bot-profile ( -- obj )
index 976a3832f47fdbe0b210bafe651e1c345357f8e1..0bc4d71707c3aa9084a2fda6ac5d6d5fc5d718dc 100644 (file)
@@ -3,7 +3,7 @@
 USING: accessors calendar calendar.format destructors fry io io.encodings.8-bit
 io.files io.pathnames irc.client irc.client.chats irc.messages
 irc.messages.base kernel make namespaces sequences threads
-irc.logbot.log-line ;
+irc.logbot.log-line io.encodings.8-bit.latin1 ;
 IN: irc.logbot
 
 CONSTANT: bot-channel "#concatenative"
old mode 100755 (executable)
new mode 100644 (file)
index 60e9e39d9f5abf8d3611841355eedb5e683b3a24..9e5d248c989726c93149a44476af3196109ece06 100644 (file)
@@ -3,7 +3,7 @@
 USING: accessors alien.c-types jamshred.game jamshred.oint
 jamshred.player jamshred.tunnel kernel math math.constants
 math.functions math.vectors opengl opengl.gl opengl.glu
-opengl.demo-support sequences specialized-arrays ;
+opengl.demo-support sequences specialized-arrays locals ;
 FROM: alien.c-types => float ;
 SPECIALIZED-ARRAY: float
 IN: jamshred.gl
@@ -44,14 +44,15 @@ CONSTANT: wall-drawing-offset 0.15
 
 : equally-spaced-radians ( n -- seq )
     #! return a sequence of n numbers between 0 and 2pi
-    dup [ / pi 2 * * ] curry map ;
+    [ iota ] keep [ / pi 2 * * ] curry map ;
 
 : draw-segment-vertex ( segment theta -- )
     over color>> gl-color segment-vertex-and-normal
     gl-normal gl-vertex ;
 
-: draw-vertex-pair ( theta next-segment segment -- )
-    rot tuck draw-segment-vertex draw-segment-vertex ;
+:: draw-vertex-pair ( theta next-segment segment -- )
+    segment theta draw-segment-vertex
+    next-segment theta draw-segment-vertex ;
 
 : draw-segment ( next-segment segment -- )
     GL_QUAD_STRIP [
index ae981ae1b3fc5a021b729a2863a4b575c037a114..96e88cb6627cab288152cdfc15dd0d0df17df7f0 100644 (file)
@@ -79,7 +79,5 @@ jamshred-gadget H{
     { mouse-scroll [ handle-mouse-scroll ] }
 } set-gestures
 
-: jamshred-window ( -- )
-    [ <jamshred> <jamshred-gadget> "Jamshred" open-window ] with-ui ;
-
-MAIN: jamshred-window
+MAIN-WINDOW: jamshred-window { { title "Jamshred" } }
+    <jamshred> <jamshred-gadget> >>gadgets ;
index ae72bd847cadfe687b14df90116817641ba89321..1b1d87fbab4f0ac093419c93cd9bd0e6f3cb8f90 100644 (file)
@@ -34,7 +34,7 @@ C: <oint> oint
 
 : random-float+- ( n -- m )
     #! find a random float between -n/2 and n/2
-    dup 10000 * >fixnum random 10000 / swap 2 / - ;
+    dup 10000 * >integer random 10000 / swap 2 / - ;
 
 : random-turn ( oint theta -- )
     2 / 2dup random-float+- left-pivot random-float+- up-pivot ;
@@ -53,13 +53,13 @@ C: <oint> oint
 
 : scalar-projection ( v1 v2 -- n )
     #! the scalar projection of v1 onto v2
-    tuck v. swap norm / ;
+    [ v. ] [ norm ] bi / ;
 
 : proj-perp ( u v -- w )
     dupd proj v- ;
 
 : perpendicular-distance ( oint oint -- distance )
-    tuck distance-vector swap 2dup left>> scalar-projection abs
+    [ distance-vector ] keep 2dup left>> scalar-projection abs
     -rot up>> scalar-projection abs + ;
 
 :: reflect ( v n -- v' )
index baeacd750bccbd38014b11c26a82ecb171eed501..49536e257058cf5dbdcdc6bc2eb979cd0a4a20dd 100644 (file)
@@ -31,20 +31,17 @@ CONSTANT: max-speed 30.0
     forward-pivot ;
 
 : to-tunnel-start ( player -- )
-    [ tunnel>> first dup location>> ]
-    [ tuck (>>location) (>>nearest-segment) ] bi ;
+    dup tunnel>> first
+    [ >>nearest-segment ]
+    [ location>> >>location ] bi drop ;
 
 : play-in-tunnel ( player segments -- )
     >>tunnel to-tunnel-start ;
 
-: update-nearest-segment ( player -- )
-    [ tunnel>> ] [ dup nearest-segment>> nearest-segment ]
-    [ (>>nearest-segment) ] tri ;
-
 : update-time ( player -- seconds-passed )
-    millis swap [ last-move>> - 1000 / ] [ (>>last-move) ] 2bi ;
+    system-micros swap [ last-move>> - 1000000 / ] [ (>>last-move) ] 2bi ;
 
-: moved ( player -- ) millis swap (>>last-move) ;
+: moved ( player -- ) system-micros swap (>>last-move) ;
 
 : speed-range ( -- range )
     max-speed [0,b] ;
index e2e1c2012254509d31cefa8cff5aa0912e4f32cf..ac696f54445bcaafcbb5e9481ce6e193c111e509 100644 (file)
@@ -6,19 +6,6 @@ alien.c-types ;
 SPECIALIZED-ARRAY: float
 IN: jamshred.tunnel.tests
 
-[ 0 ] [ T{ segment f { 0 0 0 } f f f 0 }
-        T{ segment f { 1 1 1 } f f f 1 }
-        T{ oint f { 0 0 0.25 } }
-        nearer-segment number>> ] unit-test
-
-[ 0 ] [ T{ oint f { 0 0 0 } } <straight-tunnel> find-nearest-segment number>> ] unit-test
-[ 1 ] [ T{ oint f { 0 0 -1 } } <straight-tunnel> find-nearest-segment number>> ] unit-test
-[ 2 ] [ T{ oint f { 0 0.1 -2.1 } } <straight-tunnel> find-nearest-segment number>> ] unit-test
-
-[ 3 ] [ <straight-tunnel> T{ oint f { 0 0 -3.25 } } 0 nearest-segment-forward number>> ] unit-test
-
-[ float-array{ 0 0 0 } ] [ <straight-tunnel> T{ oint f { 0 0 -0.25 } } over first nearest-segment location>> ] unit-test
-
 : test-segment-oint ( -- oint )
     { 0 0 0 } { 0 0 -1 } { 0 1 0 } { -1 0 0 } <oint> ;
 
index f7eac9d02cab343f611abc49532e3c237adcbb8f..f94fc979ce630961f78d8272d383763473d777f2 100644 (file)
@@ -63,32 +63,6 @@ CONSTANT: default-segment-radius 1
     #! valid values
     [ '[ _ clamp-length ] bi@ ] keep <slice> ;
 
-: nearer-segment ( segment segment oint -- segment )
-    #! return whichever of the two segments is nearer to the oint
-    [ 2dup ] dip tuck distance [ distance ] dip < -rot ? ;
-
-: (find-nearest-segment) ( nearest next oint -- nearest ? )
-    #! find the nearest of 'next' and 'nearest' to 'oint', and return
-    #! t if the nearest hasn't changed
-    pick [ nearer-segment dup ] dip = ;
-
-: find-nearest-segment ( oint segments -- segment )
-    dup first swap rest-slice rot [ (find-nearest-segment) ] curry
-    find 2drop ;
-    
-: nearest-segment-forward ( segments oint start -- segment )
-    rot dup length swap <slice> find-nearest-segment ;
-
-: nearest-segment-backward ( segments oint start -- segment )
-    swapd 1 + 0 spin <slice> <reversed> find-nearest-segment ;
-
-: nearest-segment ( segments oint start-segment -- segment )
-    #! find the segment nearest to 'oint', and return it.
-    #! start looking at segment 'start-segment'
-    number>> over [
-        [ nearest-segment-forward ] 3keep nearest-segment-backward
-    ] dip nearer-segment ;
-
 : get-segment ( segments n -- segment )
     over clamp-length swap nth ;
 
old mode 100755 (executable)
new mode 100644 (file)
index 90e2859..05440c8
@@ -50,10 +50,10 @@ CONSTANT: pov-polygons
     [ [ 0.0 ] unless* ] tri@
     [ (xy>loc) ] dip (z>loc) ;
 
-: move-axis ( gadget x y z -- )
-    (xyz>loc) rot tuck
-    [ indicator>>   (>>loc) ]
-    [ z-indicator>> (>>loc) ] 2bi* ;
+:: move-axis ( gadget x y z -- )
+    x y z (xyz>loc) :> ( xy z )
+    xy gadget   indicator>> (>>loc)
+    z  gadget z-indicator>> (>>loc) ;
 
 : move-pov ( gadget pov -- )
     swap pov>> [ interior>> -rot = COLOR: gray COLOR: white ? >>color drop ]
@@ -82,10 +82,10 @@ TUPLE: joystick-demo-gadget < pack axis raxis controller buttons alarm ;
     [ >>controller ] [ product-string <label> add-gadget ] bi ;
 
 : add-axis-gadget ( gadget shelf -- gadget shelf )
-    <axis-gadget> tuck [ >>axis ] [ add-gadget-with-border ] 2bi* ;
+    <axis-gadget> [ >>axis ] [ add-gadget-with-border ] bi-curry bi* ;
 
 : add-raxis-gadget ( gadget shelf -- gadget shelf )
-    <axis-gadget> tuck [ >>raxis ] [ add-gadget-with-border ] 2bi* ;
+    <axis-gadget> [ >>raxis ] [ add-gadget-with-border ] bi-curry bi* ;
 
 :: (add-button-gadgets) ( gadget shelf -- )
     gadget controller>> read-controller buttons>> length [
@@ -138,7 +138,7 @@ M: joystick-demo-gadget ungraft*
 : joystick-demo ( -- )
     [
         open-game-input
-        0.1 seconds sleep ! It might take a moment to find devices...
+        100 milliseconds sleep ! It might take a moment to find devices...
         get-controllers [ joystick-window ] each
     ] with-ui ;
 
old mode 100755 (executable)
new mode 100644 (file)
index da901ed..585ca2d
@@ -173,9 +173,5 @@ M: key-caps-gadget ungraft*
 M: key-caps-gadget handle-gesture
     drop [ key-down? ] [ key-up? ] bi or not ;
 
-: key-caps ( -- )
-    [
-        <key-caps-gadget> { 5 5 } <border> "Key Caps" open-window
-    ] with-ui ;
-
-MAIN: key-caps
+MAIN-WINDOW: key-caps { { title "Key Caps" } }
+    <key-caps-gadget> { 5 5 } <border> >>gadgets ;
index b5171bece01aac07060274a3e334365050b852d7..fafd68ca68db138d274012732a812e1a9e247ffa 100644 (file)
@@ -7,4 +7,4 @@ TUPLE: key-handler < border handlers ;
 : <keys> ( gadget -- key-handler ) key-handler new-border { 0 0 } >>size ;
 
 M: key-handler handle-gesture
-    tuck handlers>> at [ call( gadget -- ) f ] [ drop t ] if* ;
\ No newline at end of file
+    [ handlers>> at ] keep swap [ call( gadget -- ) f ] [ drop t ] if* ;
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 59efec1..c35ba6a
@@ -1,6 +1,6 @@
 ! Copyright (C) 2006, 2007 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors arrays hashtables assocs io kernel math
+USING: accessors arrays hashtables assocs io kernel locals math
 math.vectors math.matrices math.matrices.elimination namespaces
 parser prettyprint sequences words combinators math.parser
 splitting sorting shuffle sets math.order ;
@@ -71,10 +71,10 @@ SYMBOL: terms
     [ natural-sort ] keep [ index ] curry map ;
 
 : (inversions) ( n seq -- n )
-    [ > ] with filter length ;
+    [ > ] with count ;
 
 : inversions ( seq -- n )
-    0 swap [ length ] keep [
+    0 swap [ length iota ] keep [
         [ nth ] 2keep swap 1 + tail-slice (inversions) +
     ] curry each ;
 
@@ -145,12 +145,12 @@ DEFER: (d)
     [ dup length pick nth push ] reduce ;
 
 : nth-basis-elt ( generators n -- elt )
-    over length [
+    over length iota [
         3dup bit? [ nth ] [ 2drop f ] if
     ] map sift 2nip ;
 
 : basis ( generators -- seq )
-    natural-sort dup length 2^ [ nth-basis-elt ] with map ;
+    natural-sort dup length 2^ iota [ nth-basis-elt ] with map ;
 
 : (tensor) ( seq1 seq2 -- seq )
     [
@@ -180,7 +180,7 @@ DEFER: (d)
     dim-im/ker-d ;
 
 : graded-ker/im-d ( graded-basis -- seq )
-    [ length ] keep [ (graded-ker/im-d) ] curry map ;
+    [ length iota ] keep [ (graded-ker/im-d) ] curry map ;
 
 : graded-betti ( generators -- seq )
     basis graded graded-ker/im-d unzip but-last 0 prefix v- ;
@@ -191,12 +191,12 @@ DEFER: (d)
     [ ?nth ?nth ] 3keep [ [ 2 + ] dip 1 - ] dip ?nth ?nth
     dim-im/ker-d ;
 
-: bigraded-ker/im-d ( bigraded-basis -- seq )
-    dup length [
-        over first length [
-            [ 2dup ] dip spin (bigraded-ker/im-d)
-        ] map 2nip
-    ] with map ;
+:: bigraded-ker/im-d ( basis -- seq )
+    basis length iota [| z |
+         basis first length iota [| u |
+            u z basis (bigraded-ker/im-d)
+        ] map
+    ] map ;
 
 : bigraded-betti ( u-generators z-generators -- seq )
     [ basis graded ] bi@ tensor bigraded-ker/im-d
@@ -229,14 +229,12 @@ DEFER: (d)
 : laplacian-betti ( basis1 basis2 basis3 -- n )
     laplacian-matrix null/rank drop ;
 
-: laplacian-kernel ( basis1 basis2 basis3 -- basis )
-    [ tuck ] dip
-    laplacian-matrix dup empty-matrix? [
-        2drop f
-    ] [
-        nullspace [
-            [ [ wedge (alt+) ] 2each ] with-terms
-        ] with map
+:: laplacian-kernel ( basis1 basis2 basis3 -- basis )
+    basis1 basis2 basis3 laplacian-matrix :> lap
+    lap empty-matrix? [ f ] [
+        lap nullspace [| x |
+            basis2 x [ [ wedge (alt+) ] 2each ] with-terms
+        ] map
     ] if ;
 
 : graded-triple ( seq n -- triple )
@@ -270,12 +268,12 @@ DEFER: (d)
     3tri
     3array ;
 
-: bigraded-triples ( grid -- triples )
-    dup length [
-        over first length [
-            [ 2dup ] dip spin bigraded-triple
-        ] map 2nip
-    ] with map ;
+:: bigraded-triples ( grid -- triples )
+    grid length iota [| z |
+        grid first length iota [| u |
+            u z grid bigraded-triple
+        ] map
+    ] map ;
 
 : bigraded-laplacian ( u-generators z-generators quot -- seq )
     [ [ basis graded ] bi@ tensor bigraded-triples ] dip
old mode 100755 (executable)
new mode 100644 (file)
index 1801ee2..0056df0
@@ -1,34 +1,28 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors sequences kernel math io calendar grouping
-calendar.format calendar.model fonts arrays models models.arrow
-namespaces ui.gadgets ui.gadgets.labels ui ;
+USING: accessors calendar.format calendar.model fonts fry
+grouping kernel math models.arrow namespaces sequences ui
+ui.gadgets.labels ;
 IN: lcd
 
-: lcd-digit ( row digit -- str )
-    dup CHAR: : = [ drop 10 ] [ CHAR: 0 - ] if swap {
+: lcd-digit ( digit row -- str )
+    [ dup CHAR: : = [ drop 10 ] [ CHAR: 0 - ] if ] dip {
         "  _       _  _       _   _   _   _   _      "
         " | |  |   _| _| |_| |_  |_    | |_| |_|  *  "
         " |_|  |  |_  _|   |  _| |_|   | |_|   |  *  "
         "                                            "
     } nth 4 <groups> nth ;
 
-: lcd-row ( num row -- string )
-    [ swap lcd-digit ] curry { } map-as concat ;
+: lcd-row ( row digit -- string )
+    '[ _ lcd-digit ] { } map-as concat ;
 
 : lcd ( digit-str -- string )
-    4 [ lcd-row ] with map "\n" join ;
+    4 iota [ lcd-row ] with map "\n" join ;
 
-: hh:mm:ss ( timestamp -- string )
-    [ hour>> ] [ minute>> ] [ second>> >fixnum ] tri
-    3array [ pad-00 ] map ":" join ;
-
-: <time-display> ( timestamp -- gadget )
-    [ hh:mm:ss lcd ] <arrow> <label-control>
+: <time-display> ( model -- gadget )
+    [ timestamp>hms lcd ] <arrow> <label-control>
     "99:99:99" lcd >>string
     monospace-font >>font ;
 
-: time-window ( -- )
-    [ time get <time-display> "Time" open-window ] with-ui ;
-
-MAIN: time-window
+MAIN-WINDOW: time-window { { title "Time" } }
+    time get <time-display> >>gadgets ;
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 095cbd1a80aa16ed726bc7085679db377ba17326..6d7f9732962e706127b76c140baadefd65472163 100644 (file)
@@ -2,7 +2,7 @@ IN: mason.common.tests
 USING: prettyprint mason.common mason.config
 namespaces calendar tools.test io.files io.files.temp io.encodings.utf8 ;
 
-[ "00:01:01" ] [ 61000 milli-seconds>time ] unit-test
+[ "00:01:02" ] [ 62,000,000,000 nanos>time ] unit-test
 
 [ "/home/bobby/builds/factor" ] [
     [
old mode 100755 (executable)
new mode 100644 (file)
index 71ac313..cac4180
@@ -3,7 +3,7 @@
 USING: kernel namespaces sequences splitting system accessors
 math.functions make io io.files io.pathnames io.directories
 io.directories.hierarchy io.launcher io.encodings.utf8 prettyprint
-combinators.short-circuit parser combinators calendar
+combinators.short-circuit parser combinators math calendar
 calendar.format arrays mason.config locals debugger fry
 continuations strings io.sockets ;
 IN: mason.common
@@ -30,6 +30,7 @@ M: windows really-delete-tree
 M: unix really-delete-tree delete-tree ;
 
 : retry ( n quot -- )
+    [ iota ] dip
     '[ drop @ f ] attempt-all drop ; inline
 
 :: upload-safely ( local username host remote -- )
@@ -57,10 +58,8 @@ M: unix really-delete-tree delete-tree ;
         } cleave
     ] { } make [ pad-00 ] map "-" join ;
 
-: milli-seconds>time ( n -- string )
-    millis>timestamp
-    [ hour>> ] [ minute>> ] [ second>> floor ] tri 3array
-    [ pad-00 ] map ":" join ;
+: nanos>time ( n -- string )
+    1,000,000,000 /i 60 /mod [ 60 /mod ] dip 3array [ pad-00 ] map ":" join ;
 
 SYMBOL: stamp
 
index d6be8654c5473d313eb4343e476ba2ce16fc0835..2a33c5240b572c25572daf0f31fdd0822e4d30cb 100644 (file)
@@ -17,4 +17,4 @@ IN: mason.platform
     target-os get target-cpu get arch ;
 
 : boot-image-name ( -- string )
-    "boot." boot-image-arch ".image" 3append ;
+    boot-image-arch "boot." ".image" surround ;
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 4a2138323c117cef4de157bbe4f014d0e9a3a627..c5567c9c970fb287b319b2f32386096f14c47034 100644 (file)
@@ -7,12 +7,16 @@ prettyprint sequences xml.syntax xml.writer combinators.short-circuit
 literals splitting ;
 IN: mason.report
 
+: git-link ( id -- link )
+    [ "http://github.com/slavapestov/factor/commit/" prepend ] keep
+    [XML <a href=<->><-></a> XML] ;
+
 : common-report ( -- xml )
     target-os get
     target-cpu get
     short-host-name
     build-dir
-    current-git-id get
+    current-git-id get git-link
     [XML
     <h1>Build report for <->/<-></h1>
     <table>
@@ -67,7 +71,7 @@ IN: mason.report
         benchmark-time-file
         html-help-time-file
     } [
-        dup eval-file milli-seconds>time
+        dup eval-file nanos>time
         [XML <tr><td><-></td><td><-></td></tr> XML]
     ] map [XML <h2>Timings</h2> <table><-></table> XML] ;
 
@@ -82,9 +86,16 @@ IN: mason.report
 
 : benchmarks-table ( assoc -- xml )
     [
-        1000000 /f
+        1,000,000,000 /f
         [XML <tr><td><-></td><td><-></td></tr> XML]
-    ] { } assoc>map [XML <h2>Benchmarks</h2> <table><-></table> XML] ;
+    ] { } assoc>map
+    [XML
+        <h2>Benchmarks</h2>
+        <table>
+            <tr><th>Benchmark</th><th>Time (seconds)</th></tr>
+            <->
+        </table>
+    XML] ;
 
 : successful-report ( -- )
     [
index d50c77f71b8cac7a125561858e6f2e71e670ba6e..034d86b9c68c905ea28054fab2e460c2fe520719 100644 (file)
@@ -51,9 +51,6 @@ M: method-body word-vocabulary "method-generic" word-prop word-vocabulary ;
     compiler-error-messages-file
     do-step ;
 
-: benchmark-ms ( quot -- ms )
-    benchmark 1000 /i ; inline
-
 : check-boot-image ( -- )
     "" to-refresh drop 2dup [ empty? not ] either?
     [
@@ -67,12 +64,12 @@ M: method-body word-vocabulary "method-generic" word-prop word-vocabulary ;
     ".." [
         bootstrap-time get boot-time-file to-file
         check-boot-image
-        [ do-load ] benchmark-ms load-time-file to-file
-        [ generate-help ] benchmark-ms html-help-time-file to-file
-        [ do-tests ] benchmark-ms test-time-file to-file
-        [ do-help-lint ] benchmark-ms help-lint-time-file to-file
-        [ do-benchmarks ] benchmark-ms benchmark-time-file to-file
+        [ do-load ] benchmark load-time-file to-file
+        [ generate-help ] benchmark html-help-time-file to-file
+        [ do-tests ] benchmark test-time-file to-file
+        [ do-help-lint ] benchmark help-lint-time-file to-file
+        [ do-benchmarks ] benchmark benchmark-time-file to-file
         do-compile-errors
     ] with-directory ;
 
-MAIN: do-all
\ No newline at end of file
+MAIN: do-all
index 7d63bbfac8cacf88074a6f0e57fa268ccf4cb536..e8315cdf202062cfb8ef72929fc1c00c4f31bde9 100644 (file)
@@ -41,7 +41,7 @@ CONSTANT: identity-transform T{ affine-transform f { 1.0 0.0 } { 0.0 1.0 } { 0.0
     [ [ y>> second     ] [ x>> second neg ] bi 2array ]
     [ [ y>> first  neg ] [ x>> first      ] bi 2array ]
     [ |a| ] tri
-    tuck [ v/n ] 2bi@ ;
+    [ v/n ] curry bi@ ;
 
 : inverse-axes ( a -- a^-1 )
     (inverted-axes) { 0.0 0.0 } <affine-transform> ;
old mode 100755 (executable)
new mode 100644 (file)
index 6d01744..e405283
@@ -18,7 +18,7 @@ CONSTANT: gamma-p6
     }
 
 : gamma-z ( x n -- seq )
-    [ + recip ] with map 1.0 0 pick set-nth ;
+    [ + recip ] with { } map-integers 1.0 0 pick set-nth ;
 
 : (gamma-lanczos6) ( x -- log[gamma[x+1]] )
     #! log(gamma(x+1)
index 4bd1bc1b81fcc3c0022386327db20f3ead24dee7..5f1ec0c0177306b061f49ced552474fb0961fd6d 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2008 John Benediktsson
 ! See http://factorcode.org/license.txt for BSD license
 
-USING: sequences kernel arrays vectors accessors assocs sorting math math.functions ;
+USING: sequences kernel arrays vectors accessors assocs shuffle sorting locals math math.functions ;
 
 IN: math.binpack 
 
@@ -9,10 +9,12 @@ IN: math.binpack
     [ [ values sum ] map ] keep
     zip sort-keys values first push ;
 
-: binpack ( assoc n -- bins )
-    [ sort-values <reversed> dup length ] dip
-    tuck / ceiling <array> [ <vector> ] map
-    tuck [ (binpack) ] curry each ;
+:: binpack ( assoc n -- bins )
+    assoc sort-values <reversed> :> values
+    values length :> #values
+    n #values n / ceiling <array> [ <vector> ] map :> bins
+    values [ bins (binpack) ] each
+    bins ;
 
 : binpack* ( items n -- bins )
     [ dup zip ] dip binpack [ keys ] map ;
index 5954b08c9b3649331aafe2c0d666dc73c6defd7b..f1c608bad912017f37f4afce36f527952f61544c 100644 (file)
@@ -7,7 +7,7 @@ IN: math.finance
 <PRIVATE
 
 : weighted ( x y a -- z )
-    tuck [ * ] [ 1 - neg * ] 2bi* + ;
+    [ * ] [ 1 - neg * ] bi-curry bi* + ;
 
 : a ( n -- a )
     1 + 2 swap / ;
index 25482c8e1ea60b5c1d292495e95a8d2c66a2d924..b27abcae67cf796d1fc91ced2097f7735a7b4c52 100644 (file)
@@ -3,7 +3,6 @@ USING: classes.struct math.matrices.simd math.vectors.simd math
 literals math.constants math.functions specialized-arrays tools.test ;
 QUALIFIED-WITH: alien.c-types c
 FROM: math.matrices => m~ ;
-SIMD: c:float
 SPECIALIZED-ARRAY: float-4
 IN: math.matrices.simd.tests
 
index 97290964eb62e53029459aece396d7980bd05435..4e1fd0e96ce4962e94495cdc0270fe4015ce1171 100644 (file)
@@ -4,7 +4,6 @@ math math.combinatorics math.functions math.matrices.simd math.vectors
 math.vectors.simd sequences sequences.private specialized-arrays
 typed ;
 QUALIFIED-WITH: alien.c-types c
-SIMD: c:float
 SPECIALIZED-ARRAY: float-4
 IN: math.matrices.simd
 
index e4642a863b4e4d4e6606b674ecd467b2d7201518..892b846e9ee331bbee49fd4ebf0fb0053b0ab622 100644 (file)
@@ -3,9 +3,9 @@
 USING: kernel locals math math.functions ;
 IN: math.quadratic
 
-: monic ( c b a -- c' b' ) tuck [ / ] 2bi@ ;
+: monic ( c b a -- c' b' ) [ / ] curry bi@ ;
 
-: discriminant ( c b -- b d ) tuck sq 4 / swap - sqrt ;
+: discriminant ( c b -- b d ) [ nip ] [ sq 4 / swap - sqrt ] 2bi ;
 
 : critical ( b d -- -b/2 d ) [ -2 / ] dip ;
 
old mode 100755 (executable)
new mode 100644 (file)
index 422036d..5b2af13
@@ -83,7 +83,7 @@ SYMBOL: and-needed?
         first 3digits>text
     ] [
         [ set-conjunction "" ] [ length ] [ ] tri
-        [ (recombine) ] curry each
+        [ (recombine) ] curry each-integer
     ] if ;
 
 : (number>text) ( n -- str )
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index c0623d96b6a64eb6da66f3797ed8ede3c8c94780..5d0d55b64e0957595a19af469c94f98e934bc922 100644 (file)
@@ -44,7 +44,7 @@ SYMBOL: visited
     line-width 2 - glLineWidth
     line-width 2 - glPointSize
     1.0 1.0 1.0 1.0 glColor4d
-    dup [ drop t <array> ] with map visited set
+    dup iota [ drop t <array> ] with map visited set
     GL_LINE_STRIP glBegin
     { 0 0 } dup vertex (draw-maze)
     glEnd ;
@@ -61,7 +61,7 @@ M: maze draw-gadget* [ n draw-maze ] draw-canvas ;
 
 M: maze pref-dim* drop { 400 400 } ;
 
-: maze-window ( -- )
-    [ <maze> "Maze" open-window ] with-ui ;
+MAIN-WINDOW: maze-window { { title "Maze" } }
+    <maze> >>gadgets ;
 
 MAIN: maze-window
index 33d1fbedcbc58fb36f51b36caed11f844f306fad..a053c058537d23333999916659b15aaada4d69a6 100644 (file)
@@ -1,6 +1,6 @@
 ! (c)2009 Joe Groff bsd license
 USING: accessors arrays bit-arrays classes
-classes.tuple.private fry kernel locals parser
+classes.tuple.private fry kernel locals math parser
 sequences sequences.private vectors words ;
 IN: memory.pools
 
@@ -10,7 +10,7 @@ TUPLE: pool
 
 : <pool> ( size class -- pool )
     [ nip new ]
-    [ [ iota ] dip '[ _ new ] V{ } replicate-as ] 2bi
+    [ '[ _ new ] V{ } replicate-as ] 2bi
     pool boa ;
 
 : pool-size ( pool -- size )
@@ -20,7 +20,7 @@ TUPLE: pool
 
 :: copy-tuple ( from to -- to )
     from tuple-size :> size
-    size [| n | n from array-nth n to set-array-nth ] each
+    size [| n | n from array-nth n to set-array-nth ] each-integer
     to ; inline
 
 : (pool-new) ( pool -- object )
index ee9207e4caff4121d83fe92e08798862116cc801..a990dd30c42765d6d7acc9d146e2232b52951e6e 100644 (file)
@@ -4,7 +4,11 @@ ui.gadgets ui.gadgets.buttons ui.gadgets.labeled
 ui.gadgets.tracks ui.gadgets.labels ui.gadgets.glass
 math.rectangles cocoa.dialogs ;
 IN: merger
-: main ( -- ) [
+
+MAIN-WINDOW: merger-window {
+        { title "Merging" }
+        { pref-dim { 300 220 } }
+    }
    vertical <track>
     { "From:" "To:" } f <model> f <model> 2array
     [
@@ -25,7 +29,5 @@ IN: merger
          ] with-directory
       ] keep hide-glass
     ] [ drop ] if ]
-    "merge" swap <border-button> 0.4 track-add { 300 220 } >>pref-dim "Merging" open-window
-] with-ui ;
-
-MAIN: main
\ No newline at end of file
+    "merge" swap <border-button> 0.4 track-add
+    >>gadgets ;
diff --git a/extra/method-chains/method-chains-docs.factor b/extra/method-chains/method-chains-docs.factor
new file mode 100644 (file)
index 0000000..3e8e0e9
--- /dev/null
@@ -0,0 +1,22 @@
+! (c)2009 Joe Groff bsd license
+USING: help.markup help.syntax ;
+IN: method-chains
+
+HELP: AFTER:
+{ $syntax "AFTER: class generic
+    implementation ;" }
+{ $description "Defines a method on " { $snippet "generic" } " for " { $snippet "class" } " which executes the new " { $snippet "implementation" } " code after invoking the parent class method on " { $snippet "generic" } "." } ;
+
+HELP: BEFORE:
+{ $syntax "BEFORE: class generic
+    implementation ;" }
+{ $description "Defines a method on " { $snippet "generic" } " for " { $snippet "class" } " which executes the new " { $snippet "implementation" } " code, then invokes the parent class method on " { $snippet "generic" } "." } ;
+
+ARTICLE: "method-chains" "Method chaining syntax"
+"The " { $vocab-link "method-chains" } " vocabulary provides syntax for extending method implementations in class hierarchies." 
+{ $subsections
+    POSTPONE: AFTER:
+    POSTPONE: BEFORE:
+} ;
+
+ABOUT: "method-chains"
diff --git a/extra/method-chains/summary.txt b/extra/method-chains/summary.txt
new file mode 100644 (file)
index 0000000..dc80f82
--- /dev/null
@@ -0,0 +1 @@
+BEFORE: and AFTER: syntax for extending methods in class hierarchies
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
diff --git a/extra/models/combinators/authors.txt b/extra/models/combinators/authors.txt
deleted file mode 100644 (file)
index 2300f69..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Sam Anklesaria
diff --git a/extra/models/combinators/combinators-docs.factor b/extra/models/combinators/combinators-docs.factor
deleted file mode 100644 (file)
index 8ac3657..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-USING: help.markup help.syntax models models.arrow sequences monads ;
-IN: models.combinators
-
-HELP: merge
-{ $values { "models" "a list of models" } { "model" basic-model } }
-{ $description "Creates a model that merges the updates of others" } ;
-
-HELP: filter-model
-{ $values { "model" model } { "quot" "quotation with stack effect ( a b -- c )" } { "filter-model" filter-model } }
-{ $description "Creates a model that uses the updates of another model only when they satisfy a given predicate" } ;
-
-HELP: fold
-{ $values { "model" model } { "oldval" "starting value" } { "quot" "applied to update and previous values" } { "model" model } }
-{ $description "Similar to " { $link reduce } " but works on models, applying a quotation to the previous and new values at each update" } ;
-
-HELP: switch-models
-{ $values { "model1" model } { "model2" model } { "model'" model } }
-{ $description "Creates a model that starts with the behavior of model2 and switches to the behavior of model1 on its update" } ;
-
-HELP: <mapped>
-{ $values { "model" model } { "quot" "applied to model's value on updates" } { "model" model } }
-{ $description "An expanded version of " { $link <arrow> } ". Use " { $link fmap } " instead." } ;
-
-HELP: when-model
-{ $values { "model" model } { "quot" "called on the model if the quot yields true" } { "cond" "a quotation called on the model's value, yielding a boolean value"  } }
-{ $description "Calls quot when model updates if its value meets the condition set in cond" } ;
-
-HELP: with-self
-{ $values { "quot" "quotation that recieves its own return value" } { "model" model } }
-{ $description "Fixed points for models: the quot reacts to the same model to gives" } ;
-
-HELP: #1
-{ $values { "model" model } { "model'" model } }
-{ $description "Moves a model to the top of its dependencies' connections, thus being notified before the others" } ;
-
-ARTICLE: "models.combinators" "Extending models"
-"The " { $vocab-link "models.combinators" } " library expands models to have discrete start and end times. "
-"Also, it provides methods of manipulating and combining models, expecially useful when programming user interfaces: "
-"The output models of some gadgets (see " { $vocab-link "ui.gadgets.controls" } " ) can be manipulated and used as the input models of others. " ;
-
-ABOUT: "models.combinators"
diff --git a/extra/models/combinators/combinators.factor b/extra/models/combinators/combinators.factor
deleted file mode 100644 (file)
index c7b864d..0000000
+++ /dev/null
@@ -1,105 +0,0 @@
-USING: accessors arrays kernel models models.product monads
-sequences sequences.extras ;
-FROM: syntax => >> ;
-IN: models.combinators
-
-TUPLE: multi-model < model important? ;
-GENERIC: (model-changed) ( model observer -- )
-: <multi-model> ( models kind -- model ) f swap new-model [ [ add-dependency ] curry each ] keep ;
-M: multi-model model-changed over value>> [ (model-changed) ] [ 2drop ] if ;
-M: multi-model model-activated dup dependencies>> [ value>> ] find nip
-   [ swap model-changed ] [ drop ] if* ;
-
-: #1 ( model -- model' ) t >>important? ;
-
-IN: models
-: notify-connections ( model -- )
-    dup connections>> dup [ dup multi-model? [ important?>> ] [ drop f ] if ] find-all
-    [ second tuck [ remove ] dip prefix ] each
-    [ model-changed ] with each ;
-IN: models.combinators
-
-TUPLE: basic-model < multi-model ;
-M: basic-model (model-changed) [ value>> ] dip set-model ;
-: merge ( models -- model ) basic-model <multi-model> ;
-: 2merge ( model1 model2 -- model ) 2array merge ;
-: <basic> ( value -- model ) basic-model new-model ;
-
-TUPLE: filter-model < multi-model quot ;
-M: filter-model (model-changed) [ value>> ] dip 2dup quot>> call( a -- ? )
-   [ set-model ] [ 2drop ] if ;
-: filter-model ( model quot -- filter-model ) [ 1array \ filter-model <multi-model> ] dip >>quot ;
-
-TUPLE: fold-model < multi-model quot base values ;
-M: fold-model (model-changed) 2dup base>> =
-    [ [ [ value>> ] [ [ values>> ] [ quot>> ] bi ] bi* swapd reduce* ] keep set-model ]
-    [ [ [ value>> ] [ values>> ] bi* push ]
-      [ [ [ value>> ] [ [ value>> ] [ quot>> ] bi ] bi* call( val oldval -- newval ) ] keep set-model ] 2bi
-    ] if ;
-M: fold-model model-activated drop ;
-: new-fold-model ( deps -- model ) fold-model <multi-model> V{ } clone >>values ;
-: fold ( model oldval quot -- model ) rot 1array new-fold-model swap >>quot
-   swap >>value ;
-: fold* ( model oldmodel quot -- model ) over [ [ 2array new-fold-model ] dip >>quot ]
-    dip [ >>base ] [ value>> >>value ] bi ;
-
-TUPLE: updater-model < multi-model values updates ;
-M: updater-model (model-changed) [ tuck updates>> =
-   [ [ values>> value>> ] keep set-model ]
-   [ drop ] if ] keep f swap (>>value) ;
-: updates ( values updates -- model ) [ 2array updater-model <multi-model> ] 2keep
-   [ >>values ] [ >>updates ] bi* ;
-
-SYMBOL: switch
-TUPLE: switch-model < multi-model original switcher on ;
-M: switch-model (model-changed) 2dup switcher>> =
-   [ [ value>> ] dip over switch = [ nip [ original>> ] keep f >>on model-changed ] [ t >>on set-model ] if ]
-   [ dup on>> [ 2drop ] [ [ value>> ] dip over [ set-model ] [ 2drop ] if ] if ] if ;
-: switch-models ( model1 model2 -- model' ) swap [ 2array switch-model <multi-model> ] 2keep
-   [ [ value>> >>value ] [ >>original ] bi ] [ >>switcher ] bi* ;
-M: switch-model model-activated [ original>> ] keep model-changed ;
-: >behavior ( event -- behavior ) t >>value ;
-
-TUPLE: mapped-model < multi-model model quot ;
-: new-mapped-model ( model quot class -- mapped-model ) [ over 1array ] dip
-   <multi-model> swap >>quot swap >>model ;
-: <mapped> ( model quot -- model ) mapped-model new-mapped-model ;
-M: mapped-model (model-changed)
-    [ [ value>> ] [ quot>> ] bi* call( old -- new ) ] [ nip ] 2bi
-    set-model ;
-
-TUPLE: side-effect-model < mapped-model ;
-M: side-effect-model (model-changed) [ value>> ] dip [ quot>> call( old -- ) ] 2keep set-model ;
-
-TUPLE: quot-model < mapped-model ;
-M: quot-model (model-changed) nip [ quot>> call( -- b ) ] keep set-model ;
-
-TUPLE: action-value < basic-model parent ;
-: <action-value> ( parent value -- model ) action-value new-model swap >>parent ;
-M: action-value model-activated dup parent>> dup activate-model model-changed ; ! a fake dependency of sorts
-
-TUPLE: action < multi-model quot ;
-M: action (model-changed) [ [ value>> ] [ quot>> ] bi* call( a -- b ) ] keep value>>
-   [ swap add-connection ] 2keep model-changed ;
-: <action> ( model quot -- action-model ) [ 1array action <multi-model> ] dip >>quot dup f <action-value> >>value value>> ;
-
-TUPLE: collection < multi-model ;
-: <collection> ( models -- product ) collection <multi-model> ;
-M: collection (model-changed)
-    nip
-    dup dependencies>> [ value>> ] all?
-    [ dup [ value>> ] product-value swap set-model ]
-    [ drop ] if ;
-M: collection model-activated dup (model-changed) ;
-
-! for side effects
-TUPLE: (when-model) < multi-model quot cond ;
-: when-model ( model quot cond -- model ) rot 1array (when-model) <multi-model> swap >>cond swap >>quot ;
-M: (when-model) (model-changed) [ quot>> ] 2keep
-    [ value>> ] [ cond>> ] bi* call( a -- ? ) [ call( model -- ) ] [ 2drop ] if ;
-
-! only used in construction
-: with-self ( quot: ( model -- model ) -- model ) [ f <basic> dup ] dip call swap [ add-dependency ] keep ; inline
-
-USE: models.combinators.templates
-<< { "$>" "<$" "fmap" } [ fmaps ] each >>
\ No newline at end of file
diff --git a/extra/models/combinators/summary.txt b/extra/models/combinators/summary.txt
deleted file mode 100644 (file)
index 1e5347e..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Model combination and manipulation
\ No newline at end of file
diff --git a/extra/models/combinators/templates/templates.factor b/extra/models/combinators/templates/templates.factor
deleted file mode 100644 (file)
index 685ad93..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-USING: kernel sequences functors fry macros generalizations ;
-IN: models.combinators.templates
-FROM: models.combinators => <collection> #1 ;
-FUNCTOR: fmaps ( W -- )
-W        IS ${W}
-w-n      DEFINES ${W}-n
-w-2      DEFINES 2${W}
-w-3      DEFINES 3${W}
-w-4      DEFINES 4${W}
-w-n*     DEFINES ${W}-n*
-w-2*     DEFINES 2${W}*
-w-3*     DEFINES 3${W}*
-w-4*     DEFINES 4${W}*
-WHERE
-MACRO: w-n ( int -- quot ) dup '[ [ _ narray <collection> ] dip [ _ firstn ] prepend W ] ;
-: w-2 ( a b quot -- mapped ) 2 w-n ; inline
-: w-3 ( a b c quot -- mapped ) 3 w-n ; inline
-: w-4 ( a b c d quot -- mapped ) 4 w-n ; inline
-MACRO: w-n* ( int -- quot ) dup '[ [ _ narray <collection> #1 ] dip [ _ firstn ] prepend W ] ;
-: w-2* ( a b quot -- mapped ) 2 w-n* ; inline
-: w-3* ( a b c quot -- mapped ) 3 w-n* ; inline
-: w-4* ( a b c d quot -- mapped ) 4 w-n* ; inline
-;FUNCTOR
\ No newline at end of file
diff --git a/extra/models/illusion/authors.txt b/extra/models/illusion/authors.txt
new file mode 100644 (file)
index 0000000..ce0899f
--- /dev/null
@@ -0,0 +1 @@
+Sam Anklesaria
\ No newline at end of file
diff --git a/extra/models/illusion/illusion.factor b/extra/models/illusion/illusion.factor
new file mode 100644 (file)
index 0000000..0016979
--- /dev/null
@@ -0,0 +1,15 @@
+USING: accessors models models.arrow inverse kernel ;
+IN: models.illusion
+
+TUPLE: illusion < arrow ;
+
+: <illusion> ( model quot -- illusion )
+    illusion new V{ } clone >>connections V{ } clone >>dependencies 0 >>ref
+    swap >>quot over >>model [ add-dependency ] keep ;
+
+: <activated-illusion> ( model quot -- illusion ) <illusion> dup activate-model ;
+
+: backtalk ( value object -- )
+   [ quot>> [undo] call( a -- b ) ] [ model>> ] bi set-model ;
+
+M: illusion update-model ( model -- ) [ [ value>> ] keep backtalk ] with-locked-model ;
\ No newline at end of file
diff --git a/extra/models/illusion/summary.txt b/extra/models/illusion/summary.txt
new file mode 100644 (file)
index 0000000..8ea7cf1
--- /dev/null
@@ -0,0 +1 @@
+Two Way Arrows
\ No newline at end of file
index ad8c5016052688153f4694ef424b4a89e4ebc316..399b5c4e8cbccf717e82c6a501dc309e0d149506 100644 (file)
@@ -224,15 +224,15 @@ CONSTANT: DOC-LARGE H{ { "base_url" "http://www.example.com/test-me" }
       [ index>> bchar ] keep
       lasterror>> bchar
       trial-size ] dip
-    1000000 / /i
-    "%-18s: {batch:%s,index:%s;errchk:%s} %10s docs/s"
+      1000000000 / [ /i ] [ result get batch>> [ [ batch-size /i ] dip ] when /i ] 2bi
+    "%-18s: {batch:%s,index:%s;errchk:%s} %10s docs/s %10s ops/s"
     sprintf print flush ; 
 
 : print-separator ( -- )
-    "----------------------------------------------------------------" print flush ; inline
+    "---------------------------------------------------------------------------------" print flush ; inline
 
 : print-separator-bold ( -- )
-    "================================================================" print flush ; inline
+    "=================================================================================" print flush ; inline
 
 : print-header ( -- )
     trial-size
index 294672523cbb6c237d2870cbcc92c4a36235cc0e..78d0b627345c162f16062c896f89ff9fb07526f7 100644 (file)
@@ -165,9 +165,7 @@ M: mdb-collection create-collection
 : fix-query-collection ( mdb-query -- mdb-query )
     [ check-collection ] change-collection ; inline
 
-GENERIC: get-more ( mdb-cursor -- mdb-cursor seq )
-
-M: mdb-cursor get-more 
+: get-more ( mdb-cursor -- mdb-cursor seq )
     [ [ query>> dup [ collection>> ] [ return#>> ] bi ]
       [ id>> ] bi <mdb-getmore-msg> swap >>query send-query ] 
     [ f f ] if* ;
@@ -177,21 +175,20 @@ PRIVATE>
 : <query> ( collection assoc -- mdb-query-msg )
     <mdb-query-msg> ; inline
 
-GENERIC# limit 1 ( mdb-query-msg limit# -- mdb-query-msg )
-
-M: mdb-query-msg limit 
+: limit ( mdb-query-msg limit# -- mdb-query-msg )
     >>return# ; inline
 
-GENERIC# skip 1 ( mdb-query-msg skip# -- mdb-query-msg )
-
-M: mdb-query-msg skip 
+: skip ( mdb-query-msg skip# -- mdb-query-msg )
     >>skip# ; inline
 
 : asc ( key -- spec ) 1 2array ; inline
 : desc ( key -- spec ) -1 2array ; inline
 
 : sort ( mdb-query-msg sort-quot -- mdb-query-msg )
-    output>array [ 1array >hashtable ] map >>orderby ; inline
+    output>array >hashtable >>orderby ; inline
+
+: filter-fields ( mdb-query-msg filterseq -- mdb-query-msg )
+    [ asc ] map >hashtable >>returnfields ; inline
 
 : key-spec ( spec-quot -- spec-assoc )
     output>array >hashtable ; inline
@@ -209,21 +206,15 @@ M: mdb-query-msg find
 M: mdb-cursor find
     get-more ;
 
-GENERIC: explain. ( mdb-query-msg -- )
-
-M: mdb-query-msg explain.
+: explain. ( mdb-query-msg -- )
     t >>explain find nip . ;
 
-GENERIC: find-one ( mdb-query-msg -- result/f )
-
-M: mdb-query-msg find-one
+: find-one ( mdb-query-msg -- result/f )
     fix-query-collection 
     1 >>return# send-query-plain objects>>
     dup empty? [ drop f ] [ first ] if ;
 
-GENERIC: count ( mdb-query-msg -- result )
-
-M: mdb-query-msg count    
+: count ( mdb-query-msg -- result )
     [ collection>> "count" H{ } clone [ set-at ] keep ] keep
     query>> [ over [ "query" ] dip set-at ] when*
     [ cmd-collection ] dip <mdb-query-msg> find-one 
@@ -251,18 +242,15 @@ M: mdb-collection validate.
 
 PRIVATE>
 
-GENERIC: save ( collection assoc -- )
-M: assoc save
+: save ( collection assoc -- )
     [ check-collection ] dip
     <mdb-insert-msg> send-message-check-error ;
 
-GENERIC: save-unsafe ( collection assoc -- )
-M: assoc save-unsafe
+: save-unsafe ( collection assoc -- )
     [ check-collection ] dip
     <mdb-insert-msg> send-message ;
 
-GENERIC: ensure-index ( index-spec -- )
-M: index-spec ensure-index
+: ensure-index ( index-spec -- )
     <linked-hash> [ [ uuid1 "_id" ] dip set-at ] keep
     [ { [ [ name>> "name" ] dip set-at ]
         [ [ ns>> index-ns "ns" ] dip set-at ]
@@ -285,24 +273,23 @@ M: index-spec ensure-index
 : >upsert ( mdb-update-msg -- mdb-update-msg )
     1 >>upsert? ; 
 
-GENERIC: update ( mdb-update-msg -- )
-M: mdb-update-msg update
+: update ( mdb-update-msg -- )
     send-message-check-error ;
 
-GENERIC: update-unsafe ( mdb-update-msg -- )
-M: mdb-update-msg update-unsafe
+: update-unsafe ( mdb-update-msg -- )
     send-message ;
  
-GENERIC: delete ( collection selector -- )
-M: assoc delete
+: delete ( collection selector -- )
     [ check-collection ] dip
     <mdb-delete-msg> send-message-check-error ;
 
-GENERIC: delete-unsafe ( collection selector -- )
-M: assoc delete-unsafe
+: delete-unsafe ( collection selector -- )
     [ check-collection ] dip
     <mdb-delete-msg> send-message ;
 
+: kill-cursor ( mdb-cursor -- )
+    id>> <mdb-killcursors-msg> send-message ;
+
 : load-index-list ( -- index-list )
     index-collection
     H{ } clone <mdb-query-msg> find nip ;
index dd8bae84386952acef313ca87245204e3bb105c0..ada0ab42d06dcdc18e41a1141957eaf89d0a462e 100644 (file)
@@ -29,7 +29,7 @@ TUPLE: mdb-query-msg < mdb-msg
 { return# integer initial: 0 }
 { query assoc }
 { returnfields assoc }
-{ orderby sequence }
+{ orderby assoc }
 explain hint ;
 
 TUPLE: mdb-insert-msg < mdb-msg
@@ -94,7 +94,7 @@ M: sequence <mdb-insert-msg> ( collection sequence -- mdb-insert-msg )
 M: assoc <mdb-insert-msg> ( collection assoc -- mdb-insert-msg )
     [ mdb-insert-msg new ] 2dip
     [ >>collection ] dip
-    V{ } clone tuck push
+    [ V{ } clone ] dip suffix!
     >>objects OP_Insert >>opcode ;
 
 
index 7e99c52aacf6d95085815e7ceef72565fb26f1eb..108f61094083fca6373fcde8c87ddf6dba53715f 100644 (file)
@@ -107,7 +107,7 @@ USE: tools.walker
 
 :: build-query-object ( query -- selector )
     H{ } clone :> selector
-    query { [ orderby>> [ "orderby" selector set-at ] when* ]
+    query { [ orderby>> [ "$orderby" selector set-at ] when* ]
       [ explain>> [ "$explain" selector set-at ] when* ]
       [ hint>> [ "$hint" selector set-at ] when* ] 
       [ query>> "query" selector set-at ]
index fc521eca3ef375378e5d846c19fe3629d29d198b..9ea66fba520b875a881b317a55a2a32971c11cba 100644 (file)
@@ -50,13 +50,13 @@ TUPLE: cond-value value quot ;
 
 CONSTRUCTOR: cond-value ( value quot -- cond-value ) ;
 
-: write-mdb-persistent ( value quot: ( tuple -- assoc ) -- value' )
+: write-mdb-persistent ( value quot -- value' )
    over [ call( tuple -- assoc ) ] dip 
    [ [ tuple-collection name>> ] [ >toid ] bi ] keep
    [ add-storable ] dip
-   [ tuple-collection name>> ] [ id>> ] bi <objref> ; inline
+   [ tuple-collection name>> ] [ id>> ] bi <objref> ;
 
-: write-field ( value quot: ( tuple -- assoc ) -- value' )
+: write-field ( value quot -- value' )
    <cond-value> {
       { [ dup value>> mdb-special-value? ] [ value>> ]  }
       { [ dup value>> mdb-persistent? ]
@@ -66,7 +66,7 @@ CONSTRUCTOR: cond-value ( value quot -- cond-value ) ;
       { [ dup value>> [ hashtable? ] [ linked-assoc? ] bi or ]
         [ [ value>> ] [ quot>> ] bi '[ _ write-field ] assoc-map ] }
       [ value>> ]
-   } cond ; inline recursive
+   } cond ;
 
 : write-tuple-fields ( mirror tuple assoc quot: ( tuple -- assoc ) -- )
    swap ! m t q q a 
index ec1b8865ab2c8be470f95872f5ae885cb34f3445..bbae2b039959c09487b95ee29de0026b7ec3b1d6 100644 (file)
@@ -10,7 +10,7 @@ CONSTANT: MDB_TUPLE_INFO       "_mfd_t_info"
 PRIVATE>
 
 : <tuple-info> ( tuple -- tuple-info )
-    class V{ } clone tuck  
+    class [ V{ } clone ] dip over
     [ [ name>> ] dip push ]
     [ [ vocabulary>> ] dip push ] 2bi ; inline
 
old mode 100755 (executable)
new mode 100644 (file)
index de131df..6bed6d5
@@ -21,7 +21,7 @@ SYMBOL: total
 : canonicalize-specializer-1 ( specializer -- specializer' )
     [
         [ class? ] filter
-        [ length <reversed> [ 1 + neg ] map ] keep zip
+        [ length iota <reversed> [ 1 + neg ] map ] keep zip
         [ length args [ max ] change ] keep
     ]
     [
@@ -111,7 +111,7 @@ SYMBOL: total
     swap "predicate" word-prop append ;
 
 : multi-predicate ( classes -- quot )
-    dup length <reversed>
+    dup length iota <reversed>
     [ picker 2array ] 2map
     [ drop object eq? not ] assoc-filter
     [ [ t ] ] [
index a483a492b3f1ed69f073ea9dca760c082318b343..b0ab2c1bc3499788995bfbd99a83eb7f83153f77 100644 (file)
@@ -6,14 +6,14 @@ DEFER: fake
 \ fake H{ } clone "multi-methods" set-word-prop
 << (( -- )) \ fake set-stack-effect >>
 
-[ "fake-{ }" ] [ { } \ fake method-word-name ] unit-test
+[
+    [ "fake-{ }" ] [ { } \ fake method-word-name ] unit-test
 
-[ H{ { "multi-method-generic" fake } { "multi-method-specializer" { } } } ]
-[ { } \ fake method-word-props ] unit-test
+    [ H{ { "multi-method-generic" fake } { "multi-method-specializer" { } } } ]
+    [ { } \ fake method-word-props ] unit-test
 
-[ t ] [ { } \ fake <method> method-body? ] unit-test
+    [ t ] [ { } \ fake <method> method-body? ] unit-test
 
-[
     [ { } [ ] ] [ \ fake methods prepare-methods [ sort-methods ] dip ] unit-test
 
     [ t ] [ { } \ fake multi-dispatch-quot callable? ] unit-test
index 1a77b501f0d561d31721da7d0af6557606901ba3..d28bbdb9043ca01563ef851b2d66f50b09c6f437 100644 (file)
@@ -1,5 +1,5 @@
 USING: arrays kernel math opengl opengl.gl opengl.glu
-opengl.demo-support ui ui.gadgets ui.render ;
+opengl.demo-support ui ui.gadgets ui.render literals accessors ;
 IN: nehe.2
 
 TUPLE: nehe2-gadget < gadget ;
@@ -10,9 +10,6 @@ CONSTANT: height 256
 : <nehe2-gadget> (  -- gadget )
   nehe2-gadget new ;
 
-M: nehe2-gadget pref-dim* ( gadget -- dim )
-  drop width height 2array ;
-
 M: nehe2-gadget draw-gadget* ( gadget -- )
   drop
   GL_PROJECTION glMatrixMode
@@ -42,5 +39,5 @@ M: nehe2-gadget draw-gadget* ( gadget -- )
     -1.0 -1.0 0.0 glVertex3f
   ] do-state ;
 
-: run2 ( -- )
-  <nehe2-gadget> "NeHe Tutorial 2" open-window ;
+MAIN-WINDOW: run2 { { title "NeHe Tutorial 2" } { pref-dim { $ width $ height } } }
+  <nehe2-gadget> >>gadgets ;
index 228107618b43146b31b7b0fa37842400eb9d427a..1a3181dfbac92f461270d864beca05c5bca3adc7 100644 (file)
@@ -1,5 +1,5 @@
 USING: arrays kernel math opengl opengl.gl opengl.glu
-opengl.demo-support ui ui.gadgets ui.render ;
+opengl.demo-support ui ui.gadgets ui.render literals accessors ;
 IN: nehe.3
 
 TUPLE: nehe3-gadget < gadget ;
@@ -10,9 +10,6 @@ CONSTANT: height 256
 : <nehe3-gadget> (  -- gadget )
   nehe3-gadget new ;
 
-M: nehe3-gadget pref-dim* ( gadget -- dim )
-  drop width height 2array ;
-
 M: nehe3-gadget draw-gadget* ( gadget -- )
   drop
   GL_PROJECTION glMatrixMode
@@ -46,5 +43,5 @@ M: nehe3-gadget draw-gadget* ( gadget -- )
     -1.0 -1.0 0.0 glVertex3f
   ] do-state ;
 
-: run3 ( -- )
-  <nehe3-gadget> "NeHe Tutorial 3" open-window ;
+MAIN-WINDOW: run3 { { title "NeHe Tutorial 3" } { pref-dim { $ width $ height } } }
+  <nehe3-gadget> >>gadgets ;
index 63d334510a604459c01a680f6457a38815b54631..0cddcfcaa3ca3b62f1753d5f91283ef4a4050a39 100644 (file)
@@ -1,6 +1,6 @@
 USING: arrays kernel math opengl opengl.gl opengl.glu
 opengl.demo-support ui ui.gadgets ui.render threads accessors
-calendar ;
+calendar literals ;
 IN: nehe.4
 
 TUPLE: nehe4-gadget < gadget rtri rquad thread quit? ;
@@ -14,9 +14,6 @@ CONSTANT: height 256
     0.0 >>rtri
     0.0 >>rquad ;
 
-M: nehe4-gadget pref-dim* ( gadget -- dim )
-  drop width height 2array ;
-
 M: nehe4-gadget draw-gadget* ( gadget -- )
   GL_PROJECTION glMatrixMode
   glLoadIdentity
@@ -71,5 +68,5 @@ M: nehe4-gadget graft* ( gadget -- )
 M: nehe4-gadget ungraft* ( gadget -- )
   t >>quit? drop ;
 
-: run4 ( -- )
-  <nehe4-gadget> "NeHe Tutorial 4" open-window ;
+MAIN-WINDOW: run4 { { title "NeHe Tutorial 4" } { pref-dim { $ width $ height } } }
+  <nehe4-gadget> >>gadgets ;
old mode 100755 (executable)
new mode 100644 (file)
index 60662b9..e6f5c6e
@@ -1,6 +1,6 @@
 USING: arrays kernel math opengl opengl.gl opengl.glu\r
 opengl.demo-support ui ui.gadgets ui.render threads accessors\r
-calendar ;\r
+calendar literals ;\r
 IN: nehe.5\r
 \r
 TUPLE: nehe5-gadget < gadget rtri rquad thread quit? ;\r
@@ -13,9 +13,6 @@ CONSTANT: height 256
     0.0 >>rtri\r
     0.0 >>rquad ;\r
 \r
-M: nehe5-gadget pref-dim* ( gadget -- dim )\r
-  drop width height 2array ;\r
-\r
 M: nehe5-gadget draw-gadget* ( gadget -- )\r
   GL_PROJECTION glMatrixMode\r
   glLoadIdentity\r
@@ -123,6 +120,5 @@ M: nehe5-gadget graft* ( gadget -- )
 M: nehe5-gadget ungraft* ( gadget -- )\r
   t >>quit? drop ;\r
 \r
-\r
-: run5 ( -- )\r
-  <nehe5-gadget> "NeHe Tutorial 5" open-window ;\r
+MAIN-WINDOW: run5 { { title "NeHe Tutorial 5" } { pref-dim { $ width $ height } } }\r
+  <nehe5-gadget> >>gadgets ;\r
old mode 100755 (executable)
new mode 100644 (file)
index 70ab0f0f5da66fa23a9f6839af8be4b40547b237..a4c2aedf23e41425b5448583d83e5c68f4e6cece 100644 (file)
@@ -1,15 +1,13 @@
 USING: ui.gadgets.buttons ui.gadgets.packs ui.gadgets ui
-nehe.2 nehe.3 nehe.4 nehe.5 kernel ;
+nehe.2 nehe.3 nehe.4 nehe.5 kernel accessors ;
 IN: nehe
 
-: nehe-window ( -- )
-    [
-        <filled-pile>
-            "Nehe 2" [ drop run2 ] <border-button> add-gadget
-            "Nehe 3" [ drop run3 ] <border-button> add-gadget
-            "Nehe 4" [ drop run4 ] <border-button> add-gadget
-            "Nehe 5" [ drop run5 ] <border-button> add-gadget
-        "Nehe examples" open-window
-    ] with-ui ;
+MAIN-WINDOW: nehe-window { { title "Nehe Examples" } }
+    <filled-pile>
+        "Nehe 2" [ drop run2 ] <border-button> add-gadget
+        "Nehe 3" [ drop run3 ] <border-button> add-gadget
+        "Nehe 4" [ drop run4 ] <border-button> add-gadget
+        "Nehe 5" [ drop run5 ] <border-button> add-gadget
+        >>gadgets ;
 
 MAIN: nehe-window
diff --git a/extra/noise/noise-tests.factor b/extra/noise/noise-tests.factor
new file mode 100644 (file)
index 0000000..e216637
--- /dev/null
@@ -0,0 +1,4 @@
+IN: noise.tests
+USING: noise tools.test sequences math ;
+
+[ t ] [ { 100 100 } perlin-noise-map-coords [ [ 100 <= ] all? ] all? ] unit-test
index 91e040d35f28d614f9c0a46506887c94c88cbd1d..9204fa55f124473314b2f452a7ff8e0e5fb9cd0a 100644 (file)
@@ -4,7 +4,6 @@ math.libm math.matrices.simd math.vectors math.vectors.conversion math.vectors.s
 memoize random random.mersenne-twister sequences sequences.private specialized-arrays
 typed ;
 QUALIFIED-WITH: alien.c-types c
-SIMDS: c:float c:int c:short c:ushort c:uchar ;
 SPECIALIZED-ARRAYS: c:float c:uchar float-4 uchar-16 ;
 IN: noise
 
@@ -121,7 +120,7 @@ TYPED:: perlin-noise ( table: byte-array point: float-4 -- value: float )
     faded trilerp ;
 
 MEMO: perlin-noise-map-coords ( dim -- coords )
-    first2 [| x y | x [ y 0.0 0.0 float-4-boa ] float-4-array{ } map-as ] with map concat ; 
+    first2 iota [| x y | x iota [ y 0.0 0.0 float-4-boa ] float-4-array{ } map-as ] with map concat ;
 
 TYPED:: perlin-noise-map ( table: byte-array transform: matrix4 coords: float-4-array -- map: float-array )
     coords [| coord | table transform coord m4.v perlin-noise ] data-map( float-4 -- c:float )
index bccdec14200a1da41e422bb7b90595380660fdd3..85b150ce09d584d29e2b6469db8a134705846ad5 100644 (file)
@@ -3,7 +3,7 @@
 USING: kernel accessors arrays alien system combinators
 alien.syntax namespaces alien.c-types sequences vocabs.loader
 shuffle openal.backend alien.libraries generalizations
-specialized-arrays ;
+specialized-arrays alien.destructors ;
 FROM: alien.c-types => float short ;
 SPECIALIZED-ARRAY: uint
 IN: openal
@@ -183,6 +183,75 @@ FUNCTION: void alDopplerVelocity ( ALfloat value ) ;
 FUNCTION: void alSpeedOfSound ( ALfloat value ) ;
 FUNCTION: void alDistanceModel ( ALenum distanceModel ) ;
 
+C-TYPE: ALCdevice
+C-TYPE: ALCcontext
+TYPEDEF: char ALCboolean
+TYPEDEF: char ALCchar
+TYPEDEF: int ALCenum
+TYPEDEF: int ALCint
+TYPEDEF: int ALCsizei
+TYPEDEF: uint ALCuint
+
+CONSTANT: ALC_FALSE                                0
+CONSTANT: ALC_TRUE                                 1
+CONSTANT: ALC_FREQUENCY                            HEX: 1007
+CONSTANT: ALC_REFRESH                              HEX: 1008
+CONSTANT: ALC_SYNC                                 HEX: 1009
+CONSTANT: ALC_MONO_SOURCES                         HEX: 1010
+CONSTANT: ALC_STEREO_SOURCES                       HEX: 1011
+
+CONSTANT: ALC_NO_ERROR                             0
+
+CONSTANT: ALC_INVALID_DEVICE                       HEX: A001
+CONSTANT: ALC_INVALID_CONTEXT                      HEX: A002
+CONSTANT: ALC_INVALID_ENUM                         HEX: A003
+CONSTANT: ALC_INVALID_VALUE                        HEX: A004
+CONSTANT: ALC_OUT_OF_MEMORY                        HEX: A005
+
+CONSTANT: ALC_DEFAULT_DEVICE_SPECIFIER             HEX: 1004
+CONSTANT: ALC_DEVICE_SPECIFIER                     HEX: 1005
+CONSTANT: ALC_EXTENSIONS                           HEX: 1006
+
+CONSTANT: ALC_MAJOR_VERSION                        HEX: 1000
+CONSTANT: ALC_MINOR_VERSION                        HEX: 1001
+
+CONSTANT: ALC_ATTRIBUTES_SIZE                      HEX: 1002
+CONSTANT: ALC_ALL_ATTRIBUTES                       HEX: 1003
+CONSTANT: ALC_DEFAULT_ALL_DEVICES_SPECIFIER        HEX: 1012
+CONSTANT: ALC_ALL_DEVICES_SPECIFIER                HEX: 1013
+CONSTANT: ALC_CAPTURE_DEVICE_SPECIFIER             HEX: 310
+CONSTANT: ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER     HEX: 311
+CONSTANT: ALC_CAPTURE_SAMPLES                      HEX: 312
+
+FUNCTION: ALCdevice* alcOpenDevice ( ALCchar* deviceSpecifier ) ;
+FUNCTION: ALCboolean alcCloseDevice ( ALCdevice* deviceHandle ) ;
+
+: alcCloseDevice* ( deviceHandle -- )
+    alcCloseDevice drop ;
+
+FUNCTION: ALCcontext* alcCreateContext ( ALCdevice* deviceHandle, ALCint* attrList ) ;
+FUNCTION: ALCboolean alcMakeContextCurrent ( ALCcontext* context ) ;
+FUNCTION: void alcProcessContext ( ALCcontext* context ) ;
+FUNCTION: void alcSuspendContext ( ALCcontext* context ) ;
+FUNCTION: void alcDestroyContext ( ALCcontext* context ) ;
+FUNCTION: ALCcontext* alcGetCurrentContext ( ) ;
+FUNCTION: ALCdevice* alcGetContextsDevice ( ALCcontext* context ) ;
+FUNCTION: ALCboolean alcIsExtensionPresent ( ALCdevice* deviceHandle, ALCchar* extName ) ;
+FUNCTION: void* alcGetProcAddress ( ALCdevice* deviceHandle, ALCchar* funcName ) ;
+FUNCTION: ALCenum alcGetEnumValue ( ALCdevice* deviceHandle, ALCchar* enumName ) ;
+FUNCTION: ALCenum alcGetError ( ALCdevice* deviceHandle ) ;
+FUNCTION: ALCchar* alcGetString ( ALCdevice* deviceHandle, ALCenum token ) ;
+FUNCTION: void alcGetIntegerv ( ALCdevice* deviceHandle, ALCenum token, ALCsizei size, ALCint* dest ) ;
+
+FUNCTION: ALCdevice* alcCaptureOpenDevice ( ALCchar* deviceName, ALCuint freq, ALCenum fmt, ALCsizei bufsize ) ;
+FUNCTION: ALCboolean alcCaptureCloseDevice ( ALCdevice* device ) ;
+FUNCTION: void alcCaptureStart ( ALCdevice* device ) ;
+FUNCTION: void alcCaptureStop ( ALCdevice* device ) ;
+FUNCTION: void alcCaptureSamples ( ALCdevice* device, void* buf, ALCsizei samps ) ;
+
+DESTRUCTOR: alcCloseDevice*
+DESTRUCTOR: alcDestroyContext
+
 LIBRARY: alut
 
 CONSTANT: ALUT_API_MAJOR_VERSION 1
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 7a73561..c2e3e34
@@ -1,7 +1,7 @@
 ! Copyright (C) 2004 Chris Double.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: lists lists.lazy promises kernel sequences strings math
-arrays splitting quotations combinators namespaces
+arrays splitting quotations combinators namespaces locals
 unicode.case unicode.categories sequences.deep accessors ;
 IN: parser-combinators
 
@@ -58,9 +58,11 @@ C: <token-parser> token-parser
 
 : case-insensitive-token ( string -- parser ) t <token-parser> ;
 
-M: token-parser parse ( input parser -- list )
-    [ string>> ] [ ignore-case?>> ] bi
-    [ tuck ] dip ?string-head
+M:: token-parser parse ( input parser -- list )
+    parser string>> :> str
+    parser ignore-case?>> :> case?
+
+    str input str case? ?string-head
     [ <parse-results> ] [ 2drop nil ] if ;
 
 : 1token ( n -- parser ) 1string token ;
@@ -319,7 +321,7 @@ LAZY: <(+)> ( parser -- parser )
     <& &> ;
 
 : nonempty-list-of ( items separator -- parser )
-    [ over &> <*> <&:> ] keep <?> tuck pack ;
+    [ over &> <*> <&:> ] keep <?> [ nip ] 2keep pack ;
 
 : list-of ( items separator -- parser )
     #! Given a parser for the separator and for the
old mode 100755 (executable)
new mode 100644 (file)
index d6fdefd1aa2b0fd474d4319ee8590c7cdb9530c5..fb7f00f62912d0a69591202e782ba2fbc5e98f47 100644 (file)
@@ -1,12 +1,12 @@
 USING: namespaces math partial-continuations tools.test
-kernel sequences ;
+kernel sequences fry ;
 IN: partial-continuations.tests
 
 SYMBOL: sum
 
 : range ( r from to -- n )
     over - 1 + rot [ 
-        -rot [ over + pick call drop ] each 2drop f  
+        '[ over + @ drop ] each-integer drop f
     ] bshift 2nip ; inline
 
 [ 55 ] [
index fef47b859c212d40a21c8e33fb88b84499e6fd45..ecdcf3f59108e6142fc52c68afc1e255465c0866 100644 (file)
@@ -1,46 +1,16 @@
-USING: help.markup help.syntax strings ;
+USING: help.markup help.syntax math sequences strings ;
 IN: poker
 
-HELP: <hand>
-{ $values { "str" string } { "hand" "a new " { $link hand } } }
-{ $description "Creates a new poker hand containing the cards specified in " { $snippet "str" } "." }
+HELP: best-holdem-hand
+{ $values { "hand" sequence } { "n" integer } { "cards" sequence } }
+{ $description "Creates a new poker hand containing the best possible combination of the cards specified in " { $snippet "seq" } "." }
 { $examples
-    { $example "USING: kernel math.order poker prettyprint ;"
-        "\"AC KC QC JC TC\" \"7C 6D 5H 4S 2C\" [ <hand> ] bi@ <=> ." "+lt+" }
     { $example "USING: kernel poker prettyprint ;"
-        "\"TC 9C 8C 7C 6C\" \"TH 9H 8H 7H 6H\" [ <hand> ] bi@ = ." "t" }
-}
-{ $notes "Cards may be specified in any order. Hands are directly comparable to each other on the basis of their computed value. Two hands are considered equal when they would tie in a game (despite being composed of different cards)." } ;
-
-HELP: best-hand
-{ $values { "str" string } { "hand" "a new " { $link hand } } }
-{ $description "Creates a new poker hand containing the best possible combination of the cards specified in " { $snippet "str" } "." }
-{ $examples
-    { $example "USING: kernel poker prettyprint ;"
-        "\"AS KD JC KH 2D 2S KC\" best-hand >value ." "\"Full House\"" }
+        "HAND{ AS KD JC KH 2D 2S KC } best-holdem-hand drop value>hand-name ."
+        """"Full House""""
+    }
 } ;
 
-HELP: >cards
-{ $values { "hand" hand } { "str" string } }
-{ $description "Outputs a string representation of a hand's cards." }
-{ $examples
-    { $example "USING: poker prettyprint ;"
-        "\"AC KC QC JC TC\" <hand> >cards ." "\"AC KC QC JC TC\"" }
-} ;
-
-HELP: >value
-{ $values { "hand" hand } { "str" string } }
-{ $description "Outputs a string representation of a hand's value." }
-{ $examples
-    { $example "USING: poker prettyprint ;"
-        "\"AC KC QC JC TC\" <hand> >value ." "\"Straight Flush\"" }
-}
-{ $notes "This should not be used as a basis for hand comparison." } ;
-
 HELP: <deck>
-{ $values { "deck" "a new " { $link deck } } }
-{ $description "Creates a standard deck of 52 cards." } ;
-
-HELP: shuffle
-{ $values { "deck" deck } { "deck" "a shuffled " { $link deck } } }
-{ $description "Shuffles the cards in " { $snippet "deck" } ", in-place, using the Fisher-Yates algorithm." } ;
+{ $values { "deck" sequence } }
+{ $description "Returns a vector containing a standard, shuffled deck of 52 cards." } ;
index 6b05178462bfc4ffddb13fa2cb815ecb720471d3..fc10a136595e82d76dd4ed11f88fe78c455efaf2 100644 (file)
@@ -1,30 +1,28 @@
-USING: accessors kernel math.order poker poker.private tools.test ;
+USING: accessors kernel math math.order poker poker.private
+tools.test ;
 IN: poker.tests
 
 [ 134236965 ] [ "KD" >ckf ] unit-test
 [ 529159 ] [ "5s" >ckf ] unit-test
 [ 33589533 ] [ "jc" >ckf ] unit-test
 
-[ 7462 ] [ "7C 5D 4H 3S 2C" <hand> value>> ] unit-test
-[ 1601 ] [ "KD QS JC TH 9S" <hand> value>> ] unit-test
-[ 11 ] [ "AC AD AH AS KC" <hand> value>> ] unit-test
-[ 9 ] [ "6C 5C 4C 3C 2C" <hand> value>> ] unit-test
-[ 1 ] [ "AC KC QC JC TC" <hand> value>> ] unit-test
+[ 7462 ] [ "7C 5D 4H 3S 2C" string>value ] unit-test
+[ 1601 ] [ "KD QS JC TH 9S" string>value ] unit-test
+[ 11 ] [ "AC AD AH AS KC" string>value ] unit-test
+[ 9 ] [ "6C 5C 4C 3C 2C" string>value ] unit-test
+[ 1 ] [ "AC KC QC JC TC" string>value ] unit-test
 
-[ "High Card" ] [ "7C 5D 4H 3S 2C" <hand> >value ] unit-test
-[ "Straight" ] [ "KD QS JC TH 9S" <hand> >value ] unit-test
-[ "Four of a Kind" ] [ "AC AD AH AS KC" <hand> >value ] unit-test
-[ "Straight Flush" ] [ "6C 5C 4C 3C 2C" <hand> >value ] unit-test
+[ "High Card" ] [ "7C 5D 4H 3S 2C" string>hand-name ] unit-test
+[ "Straight" ] [ "KD QS JC TH 9S" string>hand-name ] unit-test
+[ "Four of a Kind" ] [ "AC AD AH AS KC" string>hand-name ] unit-test
+[ "Straight Flush" ] [ "6C 5C 4C 3C 2C" string>hand-name ] unit-test
 
-[ "6C 5C 4C 3C 2C" ] [ "6C 5C 4C 3C 2C" <hand> >cards ] unit-test
+[ t ] [ "7C 5D 4H 3S 2C" "KD QS JC TH 9S" [ string>value ] bi@ > ] unit-test
+[ t ] [ "AC AD AH AS KC" "KD QS JC TH 9S" [ string>value ] bi@ < ] unit-test
+[ t ] [ "7C 5D 4H 3S 2C" "7D 5D 4D 3C 2S" [ string>value ] bi@ = ] unit-test
 
-[ +gt+ ] [ "7C 5D 4H 3S 2C" "KD QS JC TH 9S" [ <hand> ] bi@ <=> ] unit-test
-[ +lt+ ] [ "AC AD AH AS KC" "KD QS JC TH 9S" [ <hand> ] bi@ <=> ] unit-test
-[ +eq+ ] [ "7C 5D 4H 3S 2C" "7D 5D 4D 3C 2S" [ <hand> ] bi@ <=> ] unit-test
+[ t ] [ "7C 5D 4H 3S 2C" "2C 3S 4H 5D 7C" [ string>value ] bi@ = ] unit-test
 
-[ t ] [ "7C 5D 4H 3S 2C" "2C 3S 4H 5D 7C" [ <hand> ] bi@ = ] unit-test
+[ t ] [ "7C 5D 4H 3S 2C" "7D 5D 4D 3C 2S" [ string>value ] bi@ = ] unit-test
 
-[ t ] [ "7C 5D 4H 3S 2C" "7D 5D 4D 3C 2S" [ <hand> ] bi@ = ] unit-test
-[ f ] [ "7C 5D 4H 3S 2C" "7D 5D 4D 3C 2S" [ <hand> ] bi@ eq? ] unit-test
-
-[ 190 ] [ "AS KD JC KH 2D 2S KC" best-hand value>> ] unit-test
+[ 190 ] [ "AS KD JC KH 2D 2S KC" string>value ] unit-test
index a5a5a936284f4cfa2d6d31e0e4e6c38d76a4a4aa..59f50509e4513bf7c6a106cf98253a0426df7816 100644 (file)
@@ -1,9 +1,11 @@
 ! Copyright (c) 2009 Aaron Schaefer. All rights reserved.
+! Copyright (c) 2009 Doug Coleman.
 ! The contents of this file are licensed under the Simplified BSD License
 ! A copy of the license is available at http://factorcode.org/license.txt
-USING: accessors arrays ascii binary-search combinators kernel locals math
-    math.bitwise math.combinatorics math.order poker.arrays random sequences
-    sequences.product splitting ;
+USING: accessors arrays ascii assocs binary-search combinators
+fry kernel locals math math.bitwise math.combinatorics
+math.order math.statistics poker.arrays random sequences
+sequences.product splitting grouping lexer strings ;
 IN: poker
 
 ! The algorithm used is based on Cactus Kev's Poker Hand Evaluator with
@@ -108,11 +110,13 @@ CONSTANT: VALUE_STR { "Straight Flush" "Four of a Kind" "Full House" "Flush"
 :: (>ckf) ( rank suit -- n )
     rank rank suit rank card-bitfield ;
 
-: >ckf ( str -- n )
-    #! Cactus Kev Format
-    >upper 1 cut (>ckf) ;
+#! Cactus Kev Format
+GENERIC: >ckf ( string -- n )
 
-: parse-cards ( str -- seq )
+M: string >ckf >upper 1 cut (>ckf) ;
+M: integer >ckf ;
+
+: parse-cards ( string -- seq )
     " " split [ >ckf ] map ;
 
 : flush? ( cards -- ? )
@@ -148,10 +152,10 @@ CONSTANT: VALUE_STR { "Straight Flush" "Four of a Kind" "Full House" "Flush"
         ] if
     ] if ;
 
-: >card-rank ( card -- str )
+: >card-rank ( card -- string )
     -8 shift HEX: F bitand RANK_STR nth ;
 
-: >card-suit ( card -- str )
+: >card-suit ( card -- string )
     {
         { [ dup 15 bit? ] [ drop "C" ] }
         { [ dup 14 bit? ] [ drop "D" ] }
@@ -159,7 +163,7 @@ CONSTANT: VALUE_STR { "Straight Flush" "Four of a Kind" "Full House" "Flush"
         [ drop "S" ]
     } cond ;
 
-: hand-rank ( value -- rank )
+: value>rank ( value -- rank )
     {
         { [ dup 6185 > ] [ drop HIGH_CARD ] }        ! 1277 high card
         { [ dup 3325 > ] [ drop ONE_PAIR ] }         ! 2860 one pair
@@ -172,38 +176,92 @@ CONSTANT: VALUE_STR { "Straight Flush" "Four of a Kind" "Full House" "Flush"
         [ drop STRAIGHT_FLUSH ]                      !   10 straight-flushes
     } cond ;
 
-: card>string ( card -- str )
+: card>string ( n -- string )
     [ >card-rank ] [ >card-suit ] bi append ;
 
 PRIVATE>
 
-TUPLE: hand
-    { cards sequence }
-    { value integer initial: 9999 } ;
-
-M: hand <=> [ value>> ] compare ;
-M: hand equal?
-    over hand? [ [ value>> ] bi@ = ] [ 2drop f ] if ;
-
-: <hand> ( str -- hand )
-    parse-cards dup hand-value hand boa ;
-
-: best-hand ( str -- hand )
-    parse-cards 5 hand new
-    [ dup hand-value hand boa min ] reduce-combinations ;
-
-: >cards ( hand -- str )
-    cards>> [ card>string ] map " " join ;
-
-: >value ( hand -- str )
-    value>> hand-rank VALUE_STR nth ;
-
-TUPLE: deck
-    { cards sequence } ;
-
 : <deck> ( -- deck )
-    RANK_STR SUIT_STR 2array [ concat >ckf ] product-map deck boa ;
-
-: shuffle ( deck -- deck )
-    [ randomize ] change-cards ;
-
+    RANK_STR SUIT_STR 2array
+    [ concat >ckf ] V{ } product-map-as randomize ;
+
+: best-holdem-hand ( hand -- n cards )
+    5 [ [ hand-value ] [ ] bi ] { } map>assoc-combinations
+    infimum first2 ;
+
+: value>string ( n -- string )
+    value>rank VALUE_STR nth ;
+
+: hand>card-names ( hand -- string )
+    [ card>string ] map ;
+
+: string>value ( string -- value )
+    parse-cards best-holdem-hand drop ;
+
+ERROR: no-card card deck ;
+
+: draw-specific-card ( card deck -- card )
+    [ >ckf ] dip
+    2dup index [ swap remove-nth! drop ] [ no-card ] if* ;
+
+: start-hands ( seq -- seq' deck )
+    <deck> [ '[ [ _ draw-specific-card ] map ] map ] keep ;
+
+:: holdem-hand% ( hole1 deck community n -- x )
+    community length 5 swap - 2 + :> #samples
+    n [
+        drop
+        deck #samples sample :> sampled
+        sampled 2 cut :> ( hole2 community2 )
+        hole1 community community2 3append :> hand1
+        hole2 community community2 3append :> hand2
+        hand1 hand2 [ best-holdem-hand 2array ] bi@ <=> +lt+ =
+    ] count ;
+
+:: compare-holdem-hands ( holes deck n -- seq )
+    n [
+        holes deck 5 sample '[
+            [ _ append best-holdem-hand drop ] keep
+        ] { } map>assoc infimum second
+    ] replicate histogram ;
+
+: (best-omaha-hand) ( seq -- pair )
+    4 cut
+    [ 2 all-combinations ] [ 3 all-combinations ] bi*
+    2array [ concat [ best-holdem-hand drop ] keep ] { } product-map>assoc ;
+
+: best-omaha-hand ( seq -- n cards ) (best-omaha-hand) infimum first2 ;
+
+:: compare-omaha-hands ( holes deck n -- seq )
+    n [
+        holes deck 5 sample '[
+            [ _ append best-omaha-hand drop ] keep
+        ] { } map>assoc infimum second
+    ] replicate histogram ;
+
+ERROR: bad-suit-symbol ch ;
+
+: symbol>suit ( ch -- ch' )
+    ch>upper
+    H{
+        { CHAR: ♠ CHAR: S }
+        { CHAR: ♦ CHAR: D }
+        { CHAR: ♥ CHAR: H }
+        { CHAR: ♣ CHAR: C }
+        { CHAR: S CHAR: S }
+        { CHAR: D CHAR: D }
+        { CHAR: H CHAR: H }
+        { CHAR: C CHAR: C }
+    } ?at [ bad-suit-symbol ] unless ;
+
+: card> ( string -- card )
+    1 over [ symbol>suit ] change-nth >ckf ;
+
+: value>hand-name ( value -- string )
+    value>rank VALUE_STR nth ;
+
+: string>hand-name ( string -- string' )
+    string>value value>hand-name ;
+
+SYNTAX: HAND{
+    "}" parse-tokens [ card> ] { } map-as suffix! ;
index d59b9103449c5832c57fc9770bc35693764afa3e..5bf44eddc6ef1eb0ff164cec80d34f24d88593dd 100644 (file)
@@ -47,14 +47,14 @@ PRIVATE>
 
 
 : euler001b ( -- answer )
-    1000 [0,b) [ [ 5 mod ] [ 3 mod ] bi [ 0 = ] either? ] filter sum ;
+    1000 iota [ [ 5 mod ] [ 3 mod ] bi [ 0 = ] either? ] filter sum ;
 
 ! [ euler001b ] 100 ave-time
 ! 0 ms ave run time - 0.06 SD (100 trials)
 
 
 : euler001c ( -- answer )
-    1000 [0,b) [ { 3 5 } [ divisor? ] with any? ] filter sum ;
+    1000 iota [ { 3 5 } [ divisor? ] with any? ] filter sum ;
 
 ! [ euler001c ] 100 ave-time
 ! 0 ms ave run time - 0.06 SD (100 trials)
index 9995e434e7cec04337409aa2c633f36f757e71b3..63d6eac8b438bf59879faacbc440492f8e61183c 100644 (file)
@@ -31,7 +31,7 @@ PRIVATE>
     V{ 0 } clone 1 rot (fib-upto) ;
 
 : euler002 ( -- answer )
-    4000000 fib-upto [ even? ] filter sum ;
+    4,000,000 fib-upto [ even? ] filter sum ;
 
 ! [ euler002 ] 100 ave-time
 ! 0 ms ave run time - 0.22 SD (100 trials)
@@ -41,11 +41,11 @@ PRIVATE>
 ! -------------------
 
 : fib-upto* ( n -- seq )
-    0 1 [ pick over >= ] [ tuck + dup ] produce [ 3drop ] dip
+    0 1 [ pick over >= ] [ [ nip ] 2keep + dup ] produce [ 3drop ] dip
     but-last-slice { 0 1 } prepend ;
 
 : euler002a ( -- answer )
-    4000000 fib-upto* [ even? ] filter sum ;
+    4,000,000 fib-upto* [ even? ] filter sum ;
 
 ! [ euler002a ] 100 ave-time
 ! 0 ms ave run time - 0.2 SD (100 trials)
@@ -54,7 +54,7 @@ PRIVATE>
 <PRIVATE
 
 : next-fibs ( x y -- y x+y )
-    tuck + ;
+    [ nip ] [ + ] 2bi ;
 
 : ?retotal ( total fib- fib+ -- retotal fib- fib+ )
     dup even? [ [ nip + ] 2keep ] when ;
index beed787fba1504fb86708b992623b3e386fa72bb..241fc2b626355c7ff0f14387367225a3dd7164c3 100644 (file)
@@ -72,12 +72,12 @@ IN: project-euler.011
 
 : pad-front ( matrix -- matrix )
     [
-        length [ 0 <repetition> ] map
+        length iota [ 0 <repetition> ] map
     ] keep [ append ] 2map ;
 
 : pad-back ( matrix -- matrix )
     <reversed> [
-        length [ 0 <repetition> ] map
+        length iota [ 0 <repetition> ] map
     ] keep [ <reversed> append ] 2map ;
 
 : diagonal/ ( -- matrix )
index 49680177d525fb57bb69218141e32e270b1ab91c..cbf45c9e326281ab44a10276424cb421d97aa6cf 100644 (file)
@@ -47,7 +47,7 @@ PRIVATE>
     [ [ dup 1 > ] [ dup , next-collatz ] while , ] { } make ;
 
 : euler014 ( -- answer )
-    1000000 [1,b] 0 [ collatz longest ] reduce first ;
+    1000000 [1,b] { } [ collatz longest ] reduce first ;
 
 ! [ euler014 ] time
 ! 52868 ms run / 483 ms GC time
@@ -64,7 +64,7 @@ PRIVATE>
 PRIVATE>
 
 : euler014a ( -- answer )
-    500000 1000000 [a,b] 1 [
+    500000 1000000 [a,b] { 1 } [
         dup worth-calculating? [ collatz longest ] [ drop ] if
     ] reduce first ;
 
old mode 100755 (executable)
new mode 100644 (file)
index f6b4d49..71e44cc
@@ -1,6 +1,7 @@
 ! Copyright (c) 2008 Aaron Schaefer.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel math.combinatorics math.parser project-euler.common ;
+USING: kernel math.combinatorics math.parser project-euler.common
+sequences ;
 IN: project-euler.024
 
 ! http://projecteuler.net/index.php?section=problems&id=24
@@ -23,7 +24,7 @@ IN: project-euler.024
 ! --------
 
 : euler024 ( -- answer )
-    999999 10 permutation 10 digits>integer ;
+    999999 10 iota permutation 10 digits>integer ;
 
 ! [ euler024 ] 100 ave-time
 ! 0 ms ave run time - 0.27 SD (100 trials)
index f97d8e9e0ddd700dc6b2b339a817d980c0d36908..0c697236aaa63d86dc05e17d46853db172e5c23c 100644 (file)
@@ -46,7 +46,7 @@ IN: project-euler.027
 <PRIVATE
 
 : source-027 ( -- seq )
-    1000 [0,b) [ prime? ] filter [ dup [ neg ] map append ] keep
+    1000 iota [ prime? ] filter [ dup [ neg ] map append ] keep
     cartesian-product [ first2 < ] filter ;
 
 : quadratic ( b a n -- m )
index 25d78d9465f58b533dcffe60980e7cdd6151b89a..6db9707f7323385378927b03e6e727d1b20ecfc1 100644 (file)
@@ -38,7 +38,7 @@ IN: project-euler.030
 PRIVATE>
 
 : euler030 ( -- answer )
-    325537 [0,b) [ dup sum-fifth-powers = ] filter sum 1 - ;
+    325537 iota [ dup sum-fifth-powers = ] filter sum 1 - ;
 
 ! [ euler030 ] 100 ave-time
 ! 1700 ms ave run time - 64.84 SD (100 trials)
old mode 100755 (executable)
new mode 100644 (file)
index 814f8a5..8fb7a2b
@@ -28,7 +28,7 @@ IN: project-euler.032
 
 : source-032 ( -- seq )
     9 factorial iota [
-        9 permutation [ 1 + ] map 10 digits>integer
+        9 iota permutation [ 1 + ] map 10 digits>integer
     ] map ;
 
 : 1and4 ( n -- ? )
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index cf4955750636a769bdb4ba2e88086991ae5109e9..4991d65a895c4f7c032ed0f68c134d774c35d23b 100644 (file)
@@ -40,13 +40,13 @@ IN: project-euler.043
 
 : interesting? ( seq -- ? )
     {
-        [ 17 8 rot subseq-divisible? ]
-        [ 13 7 rot subseq-divisible? ]
-        [ 11 6 rot subseq-divisible? ]
-        [ 7  5 rot subseq-divisible? ]
-        [ 5  4 rot subseq-divisible? ]
-        [ 3  3 rot subseq-divisible? ]
-        [ 2  2 rot subseq-divisible? ]
+        [ [ 17 8 ] dip subseq-divisible? ]
+        [ [ 13 7 ] dip subseq-divisible? ]
+        [ [ 11 6 ] dip subseq-divisible? ]
+        [ [ 7  5 ] dip subseq-divisible? ]
+        [ [ 5  4 ] dip subseq-divisible? ]
+        [ [ 3  3 ] dip subseq-divisible? ]
+        [ [ 2  2 ] dip subseq-divisible? ]
     } 1&& ;
 
 PRIVATE>
@@ -82,7 +82,7 @@ PRIVATE>
     [ unclip 1 head prefix concat ] map [ all-unique? ] filter ;
 
 : add-missing-digit ( seq -- seq )
-    dup natural-sort 10 swap diff prepend ;
+    dup natural-sort 10 iota swap diff prepend ;
 
 : interesting-pandigitals ( -- seq )
     17 candidates { 13 11 7 5 3 2 } [
old mode 100755 (executable)
new mode 100644 (file)
index 037cc87288420e13ab0823aaaef63ba22287663d..ae603c81fd498bf4f1e96c2139bc231b476e4cfd 100644 (file)
@@ -24,7 +24,7 @@ IN: project-euler.052
 <PRIVATE
 
 : map-nx ( n x -- seq )
-    [ 1 + * ] with map ; inline
+    iota [ 1 + * ] with map ; inline
 
 : all-same-digits? ( seq -- ? )
     [ number>digits natural-sort ] map all-equal? ;
index faca6a8ad56ce5c372767e0683282937ffb4f226..2e2d31740192e3df3f9181cd66a1f5b79732de2e 100644 (file)
@@ -27,7 +27,7 @@ IN: project-euler.053
 ! --------
 
 : euler053 ( -- answer )
-    23 100 [a,b] [ dup [ nCk 1000000 > ] with count ] map-sum ;
+    23 100 [a,b] [ dup iota [ nCk 1000000 > ] with count ] map-sum ;
 
 ! [ euler053 ] 100 ave-time
 ! 52 ms ave run time - 4.44 SD (100 trials)
index 5cf42737fb1237258905e4207c3eb0285b6131da..dedd769059dcb2e6f20a0dc432477e85f888be29 100644 (file)
@@ -76,7 +76,7 @@ IN: project-euler.054
 PRIVATE>
 
 : euler054 ( -- answer )
-    source-054 [ [ <hand> ] map first2 before? ] count ;
+    source-054 [ [ string>value ] map first2 before? ] count ;
 
 ! [ euler054 ] 100 ave-time
 ! 34 ms ave run time - 2.65 SD (100 trials)
index 09663d241fea5b13a467e0f72fd304faa96d9e7f..1d8967ff6ce68b3961e3a602e3c4265189f0ce2c 100644 (file)
@@ -61,7 +61,7 @@ IN: project-euler.055
 PRIVATE>
 
 : euler055 ( -- answer )
-    10000 [0,b) [ lychrel? ] count ;
+    10000 iota [ lychrel? ] count ;
 
 ! [ euler055 ] 100 ave-time
 ! 478 ms ave run time - 30.63 SD (100 trials)
index 97789944fe9b74ced76c1bfa7c19f53110f55273..4e35c9da58b2358bad80ef72099adae145857489 100644 (file)
@@ -36,7 +36,7 @@ IN: project-euler.057
     >fraction [ number>string length ] bi@ > ; inline
 
 : euler057 ( -- answer )
-    0 1000 [0,b) [ drop 2 + recip dup 1 + longer-numerator? ] count nip ;
+    0 1000 iota [ drop 2 + recip dup 1 + longer-numerator? ] count nip ;
 
 ! [ euler057 ] 100 ave-time
 ! 1728 ms ave run time - 80.81 SD (100 trials)
diff --git a/extra/project-euler/062/062-tests.factor b/extra/project-euler/062/062-tests.factor
new file mode 100644 (file)
index 0000000..d8e0b96
--- /dev/null
@@ -0,0 +1,4 @@
+USING: project-euler.062 tools.test ;
+IN: project-euler.062.tests
+
+[ 127035954683 ] [ euler062 ] unit-test
diff --git a/extra/project-euler/062/062.factor b/extra/project-euler/062/062.factor
new file mode 100644 (file)
index 0000000..037cdc1
--- /dev/null
@@ -0,0 +1,54 @@
+! Copyright (c) 2009 Guillaume Nargeot.
+! See http://factorcode.org/license.txt for BSD license.
+USING: arrays assocs hashtables kernel math math.functions
+project-euler.common sequences sorting ;
+IN: project-euler.062
+
+! http://projecteuler.net/index.php?section=problems&id=062
+
+! DESCRIPTION
+! -----------
+
+! The cube, 41063625 (345^3), can be permuted to produce two
+! other cubes: 56623104 (384^3) and 66430125 (405^3). In
+! fact, 41063625 is the smallest cube which has exactly three
+! permutations of its digits which are also cube.
+
+! Find the smallest cube for which exactly five permutations of
+! its digits are cube.
+
+
+! SOLUTION
+! --------
+
+<PRIVATE
+
+: cube ( n -- n^3 ) 3 ^ ; inline
+: >key ( n -- k ) cube number>digits natural-sort ; inline
+: has-entry? ( n assoc -- ? ) [ >key ] dip key? ; inline
+
+: (euler062) ( n assoc -- n )
+    2dup has-entry? [
+        2dup [ >key ] dip
+        [ dup 0 swap [ 1 + ] change-nth ] change-at
+        2dup [ >key ] dip at first 5 =
+        [ 
+            [ >key ] dip at second
+        ] [
+            [ 1 + ] dip (euler062)
+        ] if
+    ] [
+        2dup 1 pick cube 2array -rot
+        [ >key ] dip set-at [ 1 + ] dip
+        (euler062)
+    ] if ;
+
+PRIVATE>
+
+: euler062 ( -- answer )
+    1 1 <hashtable> (euler062) ;
+
+! [ euler062 ] 100 ave-time
+! 78 ms ave run time - 0.9 SD (100 trials)
+
+SOLUTION: euler062
diff --git a/extra/project-euler/062/authors.txt b/extra/project-euler/062/authors.txt
new file mode 100644 (file)
index 0000000..6eb6698
--- /dev/null
@@ -0,0 +1 @@
+Guillaume Nargeot
old mode 100755 (executable)
new mode 100644 (file)
index 35bc1f10678f184237c0f9e14dfff56a2e27b1db..cc5e93d7a86412702e52cf175c1151c1b3162273 100644 (file)
@@ -60,7 +60,7 @@ IN: project-euler.081
     3dup minimal-path-sum-to '[ _ + ] change-matrix ;
 
 : (euler081) ( matrix -- n )
-    dup first length [0,b) dup cartesian-product
+    dup first length iota dup cartesian-product
     [ first2 pick update-minimal-path-sum ] each
     last last ;
 
diff --git a/extra/project-euler/089/089-tests.factor b/extra/project-euler/089/089-tests.factor
new file mode 100644 (file)
index 0000000..9b26b34
--- /dev/null
@@ -0,0 +1,4 @@
+USING: project-euler.089 tools.test ;
+IN: project-euler.089.tests
+
+[ 743 ] [ euler089 ] unit-test
diff --git a/extra/project-euler/089/089.factor b/extra/project-euler/089/089.factor
new file mode 100644 (file)
index 0000000..34b40a7
--- /dev/null
@@ -0,0 +1,48 @@
+! Copyright (c) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: io.encodings.ascii io.files kernel math
+project-euler.common roman sequences ;
+IN: project-euler.089
+
+! http://projecteuler.net/index.php?section=problems&id=089
+
+! DESCRIPTION
+! -----------
+
+! The rules for writing Roman numerals allow for many ways of writing
+! each number (see FAQ: Roman Numerals). However, there is always a
+! "best" way of writing a particular number.
+
+! For example, the following represent all of the legitimate ways of
+! writing the number sixteen:
+
+! IIIIIIIIIIIIIIII
+! VIIIIIIIIIII
+! VVIIIIII
+! XIIIIII
+! VVVI
+! XVI
+
+! The last example being considered the most efficient, as it uses
+! the least number of numerals.
+
+! The 11K text file, roman.txt (right click and 'Save Link/Target As...'),
+! contains one thousand numbers written in valid, but not necessarily
+! minimal, Roman numerals; that is, they are arranged in descending units
+! and obey the subtractive pair rule (see FAQ for the definitive rules
+! for this problem).
+
+! Find the number of characters saved by writing each of these in their minimal form.
+
+! SOLUTION
+! --------
+
+: euler089 ( -- n )
+    "resource:extra/project-euler/089/roman.txt" ascii file-lines
+    [ ] [ [ roman> >roman ] map ] bi
+    [ [ length ] map-sum ] bi@ - ;
+
+! [ euler089 ] 100 ave-time
+! 14 ms ave run time - 0.27 SD (100 trials)
+
+SOLUTION: euler089
diff --git a/extra/project-euler/089/authors.txt b/extra/project-euler/089/authors.txt
new file mode 100644 (file)
index 0000000..7c1b2f2
--- /dev/null
@@ -0,0 +1 @@
+Doug Coleman
diff --git a/extra/project-euler/089/roman.txt b/extra/project-euler/089/roman.txt
new file mode 100644 (file)
index 0000000..721ab99
--- /dev/null
@@ -0,0 +1,1000 @@
+MMMMDCLXXII\r
+MMDCCCLXXXIII\r
+MMMDLXVIIII\r
+MMMMDXCV\r
+DCCCLXXII\r
+MMCCCVI\r
+MMMCDLXXXVII\r
+MMMMCCXXI\r
+MMMCCXX\r
+MMMMDCCCLXXIII\r
+MMMCCXXXVII\r
+MMCCCLXXXXIX\r
+MDCCCXXIIII\r
+MMCXCVI\r
+CCXCVIII\r
+MMMCCCXXXII\r
+MDCCXXX\r
+MMMDCCCL\r
+MMMMCCLXXXVI\r
+MMDCCCXCVI\r
+MMMDCII\r
+MMMCCXII\r
+MMMMDCCCCI\r
+MMDCCCXCII\r
+MDCXX\r
+CMLXXXVII\r
+MMMXXI\r
+MMMMCCCXIV\r
+MLXXII\r
+MCCLXXVIIII\r
+MMMMCCXXXXI\r
+MMDCCCLXXII\r
+MMMMXXXI\r
+MMMDCCLXXX\r
+MMDCCCLXXIX\r
+MMMMLXXXV\r
+MCXXI\r
+MDCCCXXXVII\r
+MMCCCLXVII\r
+MCDXXXV\r
+CCXXXIII\r
+CMXX\r
+MMMCLXIV\r
+MCCCLXXXVI\r
+DCCCXCVIII\r
+MMMDCCCCXXXIV\r
+CDXVIIII\r
+MMCCXXXV\r
+MDCCCXXXII\r
+MMMMD\r
+MMDCCLXIX\r
+MMMMCCCLXXXXVI\r
+MMDCCXLII\r
+MMMDCCCVIIII\r
+DCCLXXXIIII\r
+MDCCCCXXXII\r
+MMCXXVII\r
+DCCCXXX\r
+CCLXIX\r
+MMMXI\r
+MMMMCMLXXXXVIII\r
+MMMMDLXXXVII\r
+MMMMDCCCLX\r
+MMCCLIV\r
+CMIX\r
+MMDCCCLXXXIIII\r
+CLXXXII\r
+MMCCCCXXXXV\r
+MMMMDLXXXVIIII\r
+MMMDCCCXXI\r
+MMDCCCCLXXVI\r
+MCCCCLXX\r
+MMCDLVIIII\r
+MMMDCCCLIX\r
+MMMMCCCCXIX\r
+MMMDCCCLXXV\r
+XXXI\r
+CDLXXXIII\r
+MMMCXV\r
+MMDCCLXIII\r
+MMDXXX\r
+MMMMCCCLVII\r
+MMMDCI\r
+MMMMCDLXXXIIII\r
+MMMMCCCXVI\r
+CCCLXXXVIII\r
+MMMMCML\r
+MMMMXXIV\r
+MMMCCCCXXX\r
+DCCX\r
+MMMCCLX\r
+MMDXXXIII\r
+CCCLXIII\r
+MMDCCXIII\r
+MMMCCCXLIV\r
+CLXXXXI\r
+CXVI\r
+MMMMCXXXIII\r
+CLXX\r
+DCCCXVIII\r
+MLXVII\r
+DLXXXX\r
+MMDXXI\r
+MMMMDLXXXXVIII\r
+MXXII\r
+LXI\r
+DCCCCXLIII\r
+MMMMDV\r
+MMMMXXXIV\r
+MDCCCLVIII\r
+MMMCCLXXII\r
+MMMMDCCXXXVI\r
+MMMMLXXXIX\r
+MDCCCLXXXI\r
+MMMMDCCCXV\r
+MMMMCCCCXI\r
+MMMMCCCLIII\r
+MDCCCLXXI\r
+MMCCCCXI\r
+MLXV\r
+MMCDLXII\r
+MMMMDXXXXII\r
+MMMMDCCCXL\r
+MMMMCMLVI\r
+CCLXXXIV\r
+MMMDCCLXXXVI\r
+MMCLII\r
+MMMCCCCXV\r
+MMLXXXIII\r
+MMMV\r
+MMMV\r
+DCCLXII\r
+MMDCCCCXVI\r
+MMDCXLVIII\r
+CCLIIII\r
+CCCXXV\r
+MMDCCLXXXVIIII\r
+MMMMDCLXXVIII\r
+MMMMDCCCXCI\r
+MMMMCCCXX\r
+MMCCXLV\r
+MMMDCCCLXIX\r
+MMCCLXIIII\r
+MMMDCCCXLIX\r
+MMMMCCCLXIX\r
+CMLXXXXI\r
+MCMLXXXIX\r
+MMCDLXI\r
+MMDCLXXVIII\r
+MMMMDCCLXI\r
+MCDXXV\r
+DL\r
+CCCLXXII\r
+MXVIIII\r
+MCCCCLXVIII\r
+CIII\r
+MMMDCCLXXIIII\r
+MMMDVIII\r
+MMMMCCCLXXXXVII\r
+MMDXXVII\r
+MMDCCLXXXXV\r
+MMMMCXLVI\r
+MMMDCCLXXXII\r
+MMMDXXXVI\r
+MCXXII\r
+CLI\r
+DCLXXXIX\r
+MMMCLI\r
+MDCLXIII\r
+MMMMDCCXCVII\r
+MMCCCLXXXV\r
+MMMDCXXVIII\r
+MMMCDLX\r
+MMMCMLII\r
+MMMIV\r
+MMMMDCCCLVIII\r
+MMMDLXXXVIII\r
+MCXXIV\r
+MMMMLXXVI\r
+CLXXIX\r
+MMMCCCCXXVIIII\r
+DCCLXXXV\r
+MMMDCCCVI\r
+LI\r
+CLXXXVI\r
+MMMMCCCLXXVI\r
+MCCCLXVI\r
+CCXXXIX\r
+MMDXXXXI\r
+MMDCCCXLI\r
+DCCCLXXXVIII\r
+MMMMDCCCIV\r
+MDCCCCXV\r
+MMCMVI\r
+MMMMCMLXXXXV\r
+MMDCCLVI\r
+MMMMCCXLVIII\r
+DCCCCIIII\r
+MMCCCCIII\r
+MMMDCCLXXXVIIII\r
+MDCCCLXXXXV\r
+DVII\r
+MMMV\r
+DCXXV\r
+MMDCCCXCV\r
+DCVIII\r
+MMCDLXVI\r
+MCXXVIII\r
+MDCCXCVIII\r
+MMDCLX\r
+MMMDCCLXIV\r
+MMCDLXXVII\r
+MMDLXXXIIII\r
+MMMMCCCXXII\r
+MMMDCCCXLIIII\r
+DCCCCLXVII\r
+MMMCLXXXXIII\r
+MCCXV\r
+MMMMDCXI\r
+MMMMDCLXXXXV\r
+MMMCCCLII\r
+MMCMIX\r
+MMDCCXXV\r
+MMDLXXXVI\r
+MMMMDCXXVIIII\r
+DCCCCXXXVIIII\r
+MMCCXXXIIII\r
+MMDCCLXXVIII\r
+MDCCLXVIIII\r
+MMCCLXXXV\r
+MMMMDCCCLXXXVIII\r
+MMCMXCI\r
+MDXLII\r
+MMMMDCCXIV\r
+MMMMLI\r
+DXXXXIII\r
+MMDCCXI\r
+MMMMCCLXXXIII\r
+MMMDCCCLXXIII\r
+MDCLVII\r
+MMCD\r
+MCCCXXVII\r
+MMMMDCCIIII\r
+MMMDCCXLVI\r
+MMMCLXXXVII\r
+MMMCCVIIII\r
+MCCCCLXXIX\r
+DL\r
+DCCCLXXVI\r
+MMDXCI\r
+MMMMDCCCCXXXVI\r
+MMCII\r
+MMMDCCCXXXXV\r
+MMMCDXLV\r
+MMDCXXXXIV\r
+MMD\r
+MDCCCLXXXX\r
+MMDCXLIII\r
+MMCCXXXII\r
+MMDCXXXXVIIII\r
+DCCCLXXI\r
+MDXCVIIII\r
+MMMMCCLXXVIII\r
+MDCLVIIII\r
+MMMCCCLXXXIX\r
+MDCLXXXV\r
+MDLVIII\r
+MMMMCCVII\r
+MMMMDCXIV\r
+MMMCCCLXIIII\r
+MMIIII\r
+MMMMCCCLXXIII\r
+CCIII\r
+MMMCCLV\r
+MMMDXIII\r
+MMMCCCXC\r
+MMMDCCCXXI\r
+MMMMCCCCXXXII\r
+CCCLVI\r
+MMMCCCLXXXVI\r
+MXVIIII\r
+MMMCCCCXIIII\r
+CLXVII\r
+MMMCCLXX\r
+CCCCLXIV\r
+MMXXXXII\r
+MMMMCCLXXXX\r
+MXL\r
+CCXVI\r
+CCCCLVIIII\r
+MMCCCII\r
+MCCCLVIII\r
+MMMMCCCX\r
+MCDLXXXXIV\r
+MDCCCXIII\r
+MMDCCCXL\r
+MMMMCCCXXIII\r
+DXXXIV\r
+CVI\r
+MMMMDCLXXX\r
+DCCCVII\r
+MMCMLXIIII\r
+MMMDCCCXXXIII\r
+DCCC\r
+MDIII\r
+MMCCCLXVI\r
+MMMCCCCLXXI\r
+MMDCCCCXVIII\r
+CCXXXVII\r
+CCCXXV\r
+MDCCCXII\r
+MMMCMV\r
+MMMMCMXV\r
+MMMMDCXCI\r
+DXXI\r
+MMCCXLVIIII\r
+MMMMCMLII\r
+MDLXXX\r
+MMDCLXVI\r
+CXXI\r
+MMMDCCCLIIII\r
+MMMCXXI\r
+MCCIII\r
+MMDCXXXXI\r
+CCXCII\r
+MMMMDXXXV\r
+MMMCCCLXV\r
+MMMMDLXV\r
+MMMCCCCXXXII\r
+MMMCCCVIII\r
+DCCCCLXXXXII\r
+MMCLXIV\r
+MMMMCXI\r
+MLXXXXVII\r
+MMMCDXXXVIII\r
+MDXXII\r
+MLV\r
+MMMMDLXVI\r
+MMMCXII\r
+XXXIII\r
+MMMMDCCCXXVI\r
+MMMLXVIIII\r
+MMMLX\r
+MMMCDLXVII\r
+MDCCCLVII\r
+MMCXXXVII\r
+MDCCCCXXX\r
+MMDCCCLXIII\r
+MMMMDCXLIX\r
+MMMMCMXLVIII\r
+DCCCLXXVIIII\r
+MDCCCLIII\r
+MMMCMLXI\r
+MMMMCCLXI\r
+MMDCCCLIII\r
+MMMDCCCVI\r
+MMDXXXXIX\r
+MMCLXXXXV\r
+MMDXXX\r
+MMMXIII\r
+DCLXXIX\r
+DCCLXII\r
+MMMMDCCLXVIII\r
+MDCCXXXXIII\r
+CCXXXII\r
+MMMMDCXXV\r
+MMMCCCXXVIII\r
+MDCVIII\r
+MMMCLXXXXIIII\r
+CLXXXI\r
+MDCCCCXXXIII\r
+MMMMDCXXX\r
+MMMDCXXIV\r
+MMMCCXXXVII\r
+MCCCXXXXIIII\r
+CXVIII\r
+MMDCCCCIV\r
+MMMMCDLXXV\r
+MMMDLXIV\r
+MDXCIII\r
+MCCLXXXI\r
+MMMDCCCXXIV\r
+MCXLIII\r
+MMMDCCCI\r
+MCCLXXX\r
+CCXV\r
+MMDCCLXXI\r
+MMDLXXXIII\r
+MMMMDCXVII\r
+MMMCMLXV\r
+MCLXVIII\r
+MMMMCCLXXVI\r
+MMMDCCLXVIIII\r
+MMMMDCCCIX\r
+DLXXXXIX\r
+DCCCXXII\r
+MMMMIII\r
+MMMMCCCLXXVI\r
+DCCCXCIII\r
+DXXXI\r
+MXXXIIII\r
+CCXII\r
+MMMDCCLXXXIIII\r
+MMMCXX\r
+MMMCMXXVII\r
+DCCCXXXX\r
+MMCDXXXVIIII\r
+MMMMDCCXVIII\r
+LV\r
+MMMDCCCCVI\r
+MCCCII\r
+MMCMLXVIIII\r
+MDCCXI\r
+MMMMDLXVII\r
+MMCCCCLXI\r
+MMDCCV\r
+MMMCCCXXXIIII\r
+MMMMDI\r
+MMMDCCCXCV\r
+MMDCCLXXXXI\r
+MMMDXXVI\r
+MMMDCCCLVI\r
+MMDCXXX\r
+MCCCVII\r
+MMMMCCCLXII\r
+MMMMXXV\r
+MMCMXXV\r
+MMLVI\r
+MMDXXX\r
+MMMMCVII\r
+MDC\r
+MCCIII\r
+MMMMDCC\r
+MMCCLXXV\r
+MMDCCCXXXXVI\r
+MMMMCCCLXV\r
+CDXIIII\r
+MLXIIII\r
+CCV\r
+MMMCMXXXI\r
+CCCCLXVI\r
+MDXXXII\r
+MMMMCCCLVIII\r
+MMV\r
+MMMCLII\r
+MCMLI\r
+MMDCCXX\r
+MMMMCCCCXXXVI\r
+MCCLXXXI\r
+MMMCMVI\r
+DCCXXX\r
+MMMMCCCLXV\r
+DCCCXI\r
+MMMMDCCCXIV\r
+CCCXXI\r
+MMDLXXV\r
+CCCCLXXXX\r
+MCCCLXXXXII\r
+MMDCIX\r
+DCCXLIIII\r
+DXIV\r
+MMMMCLII\r
+CDLXI\r
+MMMCXXVII\r
+MMMMDCCCCLXIII\r
+MMMDCLIIII\r
+MCCCCXXXXII\r
+MMCCCLX\r
+CCCCLIII\r
+MDCCLXXVI\r
+MCMXXIII\r
+MMMMDLXXVIII\r
+MMDCCCCLX\r
+MMMCCCLXXXX\r
+MMMCDXXVI\r
+MMMDLVIII\r
+CCCLXI\r
+MMMMDCXXII\r
+MMDCCCXXI\r
+MMDCCXIII\r
+MMMMCLXXXVI\r
+MDCCCCXXVI\r
+MDV\r
+MMDCCCCLXXVI\r
+MMMMCCXXXVII\r
+MMMDCCLXXVIIII\r
+MMMCCCCLXVII\r
+DCCXLI\r
+MMCLXXXVIII\r
+MCCXXXVI\r
+MMDCXLVIII\r
+MMMMCXXXII\r
+MMMMDCCLXVI\r
+MMMMCMLI\r
+MMMMCLXV\r
+MMMMDCCCXCIV\r
+MCCLXXVII\r
+LXXVIIII\r
+DCCLII\r
+MMMCCCXCVI\r
+MMMCLV\r
+MMDCCCXXXXVIII\r
+DCCCXV\r
+MXC\r
+MMDCCLXXXXVII\r
+MMMMCML\r
+MMDCCCLXXVIII\r
+DXXI\r
+MCCCXLI\r
+DCLXXXXI\r
+MMCCCLXXXXVIII\r
+MDCCCCLXXVIII\r
+MMMMDXXV\r
+MMMDCXXXVI\r
+MMMCMXCVII\r
+MMXVIIII\r
+MMMDCCLXXIV\r
+MMMCXXV\r
+DXXXVIII\r
+MMMMCLXVI\r
+MDXII\r
+MMCCCLXX\r
+CCLXXI\r
+DXIV\r
+MMMCLIII\r
+DLII\r
+MMMCCCXLIX\r
+MMCCCCXXVI\r
+MMDCXLIII\r
+MXXXXII\r
+CCCLXXXV\r
+MDCLXXVI\r
+MDCXII\r
+MMMCCCLXXXIII\r
+MMDCCCCLXXXII\r
+MMMMCCCLXXXV\r
+MMDCXXI\r
+DCCCXXX\r
+MMMDCCCCLII\r
+MMMDCCXXII\r
+MMMMCDXCVIII\r
+MMMCCLXVIIII\r
+MMXXV\r
+MMMMCDXIX\r
+MMMMCCCX\r
+MMMCCCCLXVI\r
+MMMMDCLXXVIIII\r
+MMMMDCXXXXIV\r
+MMMCMXII\r
+MMMMXXXIII\r
+MMMMDLXXXII\r
+DCCCLIV\r
+MDXVIIII\r
+MMMCLXXXXV\r
+CCCCXX\r
+MMDIX\r
+MMCMLXXXVIII\r
+DCCXLIII\r
+DCCLX\r
+D\r
+MCCCVII\r
+MMMMCCCLXXXIII\r
+MDCCCLXXIIII\r
+MMMDCCCCLXXXVII\r
+MMMMCCCVII\r
+MMMDCCLXXXXVI\r
+CDXXXIV\r
+MCCLXVIII\r
+MMMMDLX\r
+MMMMDXII\r
+MMMMCCCCLIIII\r
+MCMLXXXXIII\r
+MMMMDCCCIII\r
+MMDCLXXXIII\r
+MDCCCXXXXIV\r
+XXXXVII\r
+MMMDCCCXXXII\r
+MMMDCCCXLII\r
+MCXXXV\r
+MDCXXVIIII\r
+MMMCXXXXIIII\r
+MMMMCDXVII\r
+MMMDXXIII\r
+MMMMCCCCLXI\r
+DCLXXXXVIIII\r
+LXXXXI\r
+CXXXIII\r
+MCDX\r
+MCCLVII\r
+MDCXXXXII\r
+MMMCXXIV\r
+MMMMLXXXX\r
+MMDCCCCXLV\r
+MLXXX\r
+MMDCCCCLX\r
+MCDLIII\r
+MMMCCCLXVII\r
+MMMMCCCLXXIV\r
+MMMDCVIII\r
+DCCCCXXIII\r
+MMXCI\r
+MMDCCIV\r
+MMMMDCCCXXXIV\r
+CCCLXXI\r
+MCCLXXXII\r
+MCMIII\r
+CCXXXI\r
+DCCXXXVIII\r
+MMMMDCCXLVIIII\r
+MMMMCMXXXV\r
+DCCCLXXV\r
+DCCXCI\r
+MMMMDVII\r
+MMMMDCCCLXVIIII\r
+CCCXCV\r
+MMMMDCCXX\r
+MCCCCII\r
+MMMCCCXC\r
+MMMCCCII\r
+MMDCCLXXVII\r
+MMDCLIIII\r
+CCXLIII\r
+MMMDCXVIII\r
+MMMCCCIX\r
+MCXV\r
+MMCCXXV\r
+MLXXIIII\r
+MDCCXXVI\r
+MMMCCCXX\r
+MMDLXX\r
+MMCCCCVI\r
+MMDCCXX\r
+MMMMDCCCCXCV\r
+MDCCCXXXII\r
+MMMMDCCCCXXXX\r
+XCIV\r
+MMCCCCLX\r
+MMXVII\r
+MLXXI\r
+MMMDXXVIII\r
+MDCCCCII\r
+MMMCMLVII\r
+MMCLXXXXVIII\r
+MDCCCCLV\r
+MCCCCLXXIIII\r
+MCCCLII\r
+MCDXLVI\r
+MMMMDXVIII\r
+DCCLXXXIX\r
+MMMDCCLXIV\r
+MDCCCCXLIII\r
+CLXXXXV\r
+MMMMCCXXXVI\r
+MMMDCCCXXI\r
+MMMMCDLXXVII\r
+MCDLIII\r
+MMCCXLVI\r
+DCCCLV\r
+MCDLXX\r
+DCLXXVIII\r
+MMDCXXXIX\r
+MMMMDCLX\r
+MMDCCLI\r
+MMCXXXV\r
+MMMCCXII\r
+MMMMCMLXII\r
+MMMMCCV\r
+MCCCCLXIX\r
+MMMMCCIII\r
+CLXVII\r
+MCCCLXXXXIIII\r
+MMMMDCVIII\r
+MMDCCCLXI\r
+MMLXXIX\r
+CMLXIX\r
+MMDCCCXLVIIII\r
+DCLXII\r
+MMMCCCXLVII\r
+MDCCCXXXV\r
+MMMMDCCXCVI\r
+DCXXX\r
+XXVI\r
+MMLXIX\r
+MMCXI\r
+DCXXXVII\r
+MMMMCCCXXXXVIII\r
+MMMMDCLXI\r
+MMMMDCLXXIIII\r
+MMMMVIII\r
+MMMMDCCCLXII\r
+MDCXCI\r
+MMCCCXXIIII\r
+CCCCXXXXV\r
+MMDCCCXXI\r
+MCVI\r
+MMDCCLXVIII\r
+MMMMCXL\r
+MLXVIII\r
+CMXXVII\r
+CCCLV\r
+MDCCLXXXIX\r
+MMMCCCCLXV\r
+MMDCCLXII\r
+MDLXVI\r
+MMMCCCXVIII\r
+MMMMCCLXXXI\r
+MMCXXVII\r
+MMDCCCLXVIII\r
+MMMCXCII\r
+MMMMDCLVIII\r
+MMMMDCCCXXXXII\r
+MMDCCCCLXXXXVI\r
+MDCCXL\r
+MDCCLVII\r
+MMMMDCCCLXXXVI\r
+DCCXXXIII\r
+MMMMDCCCCLXXXV\r
+MMCCXXXXVIII\r
+MMMCCLXXVIII\r
+MMMDCLXXVIII\r
+DCCCI\r
+MMMMLXXXXVIIII\r
+MMMCCCCLXXII\r
+MMCLXXXVII\r
+CCLXVI\r
+MCDXLIII\r
+MMCXXVIII\r
+MDXIV\r
+CCCXCVIII\r
+CLXXVIII\r
+MMCXXXXVIIII\r
+MMMDCLXXXIV\r
+CMLVIII\r
+MCDLIX\r
+MMMMDCCCXXXII\r
+MMMMDCXXXIIII\r
+MDCXXI\r
+MMMDCXLV\r
+MCLXXVIII\r
+MCDXXII\r
+IV\r
+MCDLXXXXIII\r
+MMMMDCCLXV\r
+CCLI\r
+MMMMDCCCXXXVIII\r
+DCLXII\r
+MCCCLXVII\r
+MMMMDCCCXXXVI\r
+MMDCCXLI\r
+MLXI\r
+MMMCDLXVIII\r
+MCCCCXCIII\r
+XXXIII\r
+MMMDCLXIII\r
+MMMMDCL\r
+DCCCXXXXIIII\r
+MMDLVII\r
+DXXXVII\r
+MCCCCXXIIII\r
+MCVII\r
+MMMMDCCXL\r
+MMMMCXXXXIIII\r
+MCCCCXXIV\r
+MMCLXVIII\r
+MMXCIII\r
+MDCCLXXX\r
+MCCCLIIII\r
+MMDCLXXI\r
+MXI\r
+MCMLIV\r
+MMMCCIIII\r
+DCCLXXXVIIII\r
+MDCLIV\r
+MMMDCXIX\r
+CMLXXXI\r
+DCCLXXXVII\r
+XXV\r
+MMMXXXVI\r
+MDVIIII\r
+CLXIII\r
+MMMCDLVIIII\r
+MMCCCCVII\r
+MMMLXX\r
+MXXXXII\r
+MMMMCCCLXVIII\r
+MMDCCCXXVIII\r
+MMMMDCXXXXI\r
+MMMMDCCCXXXXV\r
+MMMXV\r
+MMMMCCXVIIII\r
+MMDCCXIIII\r
+MMMXXVII\r
+MDCCLVIIII\r
+MMCXXIIII\r
+MCCCLXXIV\r
+DCLVIII\r
+MMMLVII\r
+MMMCXLV\r
+MMXCVII\r
+MMMCCCLXXXVII\r
+MMMMCCXXII\r
+DXII\r
+MMMDLV\r
+MCCCLXXVIII\r
+MMMCLIIII\r
+MMMMCLXXXX\r
+MMMCLXXXIIII\r
+MDCXXIII\r
+MMMMCCXVI\r
+MMMMDLXXXIII\r
+MMMDXXXXIII\r
+MMMMCCCCLV\r
+MMMDLXXXI\r
+MMMCCLXXVI\r
+MMMMXX\r
+MMMMDLVI\r
+MCCCCLXXX\r
+MMMXXII\r
+MMXXII\r
+MMDCCCCXXXI\r
+MMMDXXV\r
+MMMDCLXXXVIIII\r
+MMMDLXXXXVII\r
+MDLXIIII\r
+CMXC\r
+MMMXXXVIII\r
+MDLXXXVIII\r
+MCCCLXXVI\r
+MMCDLIX\r
+MMDCCCXVIII\r
+MDCCCXXXXVI\r
+MMMMCMIV\r
+MMMMDCIIII\r
+MMCCXXXV\r
+XXXXVI\r
+MMMMCCXVII\r
+MMCCXXIV\r
+MCMLVIIII\r
+MLXXXIX\r
+MMMMLXXXIX\r
+CLXXXXIX\r
+MMMDCCCCLVIII\r
+MMMMCCLXXIII\r
+MCCCC\r
+DCCCLIX\r
+MMMCCCLXXXII\r
+MMMCCLXVIIII\r
+MCLXXXV\r
+CDLXXXVII\r
+DCVI\r
+MMX\r
+MMCCXIII\r
+MMMMDCXX\r
+MMMMXXVIII\r
+DCCCLXII\r
+MMMMCCCXLIII\r
+MMMMCLXV\r
+DXCI\r
+MMMMCLXXX\r
+MMMDCCXXXXI\r
+MMMMXXXXVI\r
+DCLX\r
+MMMCCCXI\r
+MCCLXXX\r
+MMCDLXXII\r
+DCCLXXI\r
+MMMCCCXXXVI\r
+MCCCCLXXXVIIII\r
+CDLVIII\r
+DCCLVI\r
+MMMMDCXXXVIII\r
+MMCCCLXXXIII\r
+MMMMDCCLXXV\r
+MMMXXXVI\r
+CCCLXXXXIX\r
+CV\r
+CCCCXIII\r
+CCCCXVI\r
+MDCCCLXXXIIII\r
+MMDCCLXXXII\r
+MMMMCCCCLXXXI\r
+MXXV\r
+MMCCCLXXVIIII\r
+MMMCCXII\r
+MMMMCCXXXIII\r
+MMCCCLXXXVI\r
+MMMDCCCLVIIII\r
+MCCXXXVII\r
+MDCLXXV\r
+XXXV\r
+MMDLI\r
+MMMCCXXX\r
+MMMMCXXXXV\r
+CCCCLIX\r
+MMMMDCCCLXXIII\r
+MMCCCXVII\r
+DCCCXVI\r
+MMMCCCXXXXV\r
+MDCCCCXCV\r
+CLXXXI\r
+MMMMDCCLXX\r
+MMMDCCCIII\r
+MMCLXXVII\r
+MMMDCCXXIX\r
+MMDCCCXCIIII\r
+MMMCDXXIIII\r
+MMMMXXVIII\r
+MMMMDCCCCLXVIII\r
+MDCCCXX\r
+MMMMCDXXI\r
+MMMMDLXXXIX\r
+CCXVI\r
+MDVIII\r
+MMCCLXXI\r
+MMMDCCCLXXI\r
+MMMCCCLXXVI\r
+MMCCLXI\r
+MMMMDCCCXXXIV\r
+DLXXXVI\r
+MMMMDXXXII\r
+MMMXXIIII\r
+MMMMCDIV\r
+MMMMCCCXLVIII\r
+MMMMCXXXVIII\r
+MMMCCCLXVI\r
+MDCCXVIII\r
+MMCXX\r
+CCCLIX\r
+MMMMDCCLXXII\r
+MDCCCLXXV\r
+MMMMDCCCXXIV\r
+DCCCXXXXVIII\r
+MMMDCCCCXXXVIIII\r
+MMMMCCXXXV\r
+MDCLXXXIII\r
+MMCCLXXXIV\r
+MCLXXXXIIII\r
+DXXXXIII\r
+MCCCXXXXVIII\r
+MMCLXXIX\r
+MMMMCCLXIV\r
+MXXII\r
+MMMCXIX\r
+MDCXXXVII\r
+MMDCCVI\r
+MCLXXXXVIII\r
+MMMCXVI\r
+MCCCLX\r
+MMMCDX\r
+CCLXVIIII\r
+MMMCCLX\r
+MCXXVIII\r
+LXXXII\r
+MCCCCLXXXI\r
+MMMI\r
+MMMCCCLXIV\r
+MMMCCCXXVIIII\r
+CXXXVIII\r
+MMCCCXX\r
+MMMCCXXVIIII\r
+MCCLXVI\r
+MMMCCCCXXXXVI\r
+MMDCCXCIX\r
+MCMLXXI\r
+MMCCLXVIII\r
+CDLXXXXIII\r
+MMMMDCCXXII\r
+MMMMDCCLXXXVII\r
+MMMDCCLIV\r
+MMCCLXIII\r
+MDXXXVII\r
+DCCXXXIIII\r
+MCII\r
+MMMDCCCLXXI\r
+MMMLXXIII\r
+MDCCCLIII\r
+MMXXXVIII\r
+MDCCXVIIII\r
+MDCCCCXXXVII\r
+MMCCCXVI\r
+MCMXXII\r
+MMMCCCLVIII\r
+MMMMDCCCXX\r
+MCXXIII\r
+MMMDLXI\r
+MMMMDXXII\r
+MDCCCX\r
+MMDXCVIIII\r
+MMMDCCCCVIII\r
+MMMMDCCCCXXXXVI\r
+MMDCCCXXXV\r
+MMCXCIV\r
+MCMLXXXXIII\r
+MMMCCCLXXVI\r
+MMMMDCLXXXV\r
+CMLXIX\r
+DCXCII\r
+MMXXVIII\r
+MMMMCCCXXX\r
+XXXXVIIII
\ No newline at end of file
index 72584d833ec842bc4eca1d5e7ea344ba224e2981..55a108aa68f29b8521d8b9120b9939b58e7ad727 100644 (file)
@@ -5,19 +5,18 @@ IN: project-euler.100
 
 ! http://projecteuler.net/index.php?section=problems&id=100
 
-! DESCRIPTION
-! -----------
+! DESCRIPTION ! -----------
 
 ! If a box contains twenty-one coloured discs, composed of fifteen blue discs
-! and six red discs, and two discs were taken at random, it can be seen that
-! the probability of taking two blue discs, P(BB) = (15/21)*(14/20) = 1/2.
+!  and six red discs, and two discs were taken at random, it can be seen that
+!  the probability of taking two blue discs, P(BB) = (15/21)*(14/20) = 1/2.
 
 ! The next such arrangement, for which there is exactly 50% chance of taking
-! two blue discs at random, is a box containing eighty-five blue discs and
-! thirty-five red discs.
+!  two blue discs at random, is a box containing eighty-five blue discs and
+!  thirty-five red discs.
 
 ! By finding the first arrangement to contain over 10^12 = 1,000,000,000,000
-! discs in total, determine the number of blue discs that the box would contain.
+!  discs in total, determine the number of blue discs that the box would contain.
 
 
 ! SOLUTION
@@ -26,7 +25,7 @@ IN: project-euler.100
 : euler100 ( -- answer )
     1 1
     [ dup dup 1 - * 2 * 10 24 ^ <= ]
-    [ tuck 6 * swap - 2 - ] while nip ;
+    [ [ 6 * swap - 2 - ] keep swap ] while nip ;
 
 ! TODO: solution needs generalization
 
index 0d4ec782269f4b1d4777da7e7dd8045c06ccc1ff..60daa7224e8634827c6df8ffa983656a2a60b7bb 100644 (file)
@@ -31,7 +31,7 @@ IN: project-euler.117
     [ 4 short tail* sum ] keep push ;
 
 : (euler117) ( n -- m )
-    V{ 1 } clone tuck [ next ] curry times last ;
+    [ V{ 1 } clone ] dip over [ next ] curry times last ;
 
 PRIVATE>
 
index e6278a1e172297e77e4b7105274340352138ddb9..6e64d6ad3080a491121c003aca5ba5bc5f28f32e 100644 (file)
@@ -55,9 +55,9 @@ IN: project-euler.150
 
 :: (euler150) ( m -- n )
     sums-triangle :> table
-    m [| x |
-        x 1 + [| y |
-            m x - [0,b) [| z |
+    m iota [| x |
+        x 1 + iota [| y |
+            m x - iota [| z |
                 x z + table nth-unsafe
                 [ y z + 1 + swap nth-unsafe ]
                 [ y        swap nth-unsafe ] bi -
index ccdb76d80e05ca679f5b464c27b6adf5bb9fd396..b8db55e886e00421e9f7a1443b99540faff6f4e5 100644 (file)
@@ -62,7 +62,7 @@ DEFER: (euler151)
         { { 0 0 1 0 } [ { 0 0 0 1 } (euler151) 1 + ] }
         { { 0 1 0 0 } [ { 0 0 1 1 } (euler151) 1 + ] }
         { { 1 0 0 0 } [ { 0 1 1 1 } (euler151) 1 + ] }
-        [ [ dup length [ pick-sheet ] with map sum ] [ sum ] bi / ]
+        [ [ dup length iota [ pick-sheet ] with map sum ] [ sum ] bi / ]
      } case ] cache ;
 
 : euler151 ( -- answer )
index af8b7e49c064d3de79794f7602ce04f4edf0dbc7..be5d40df9b92aefd9405ab47c8fa0e6a1f5003bd 100644 (file)
@@ -18,7 +18,7 @@ IN: project-euler.164
 <PRIVATE
 
 : next-keys ( key -- keys )
-    [ last ] [ 10 swap sum - ] bi [ 2array ] with map ;
+    [ last ] [ 10 swap sum - iota ] bi [ 2array ] with map ;
 
 : next-table ( assoc -- assoc )
     H{ } clone swap
index ed4f03dda1aabc8a3a13e5004234bc20260b1b77..922a28cb22c51f21a0212937bc635b545f0a3129 100644 (file)
@@ -45,7 +45,7 @@ IN: project-euler.186
     55 [1,b] [ (generator) ] map <circular> ;
 
 : advance ( lag -- )
-    [ { 0 31 } swap nths sum 1000000 rem ] keep push-circular ;
+    [ { 0 31 } swap nths sum 1000000 rem ] keep circular-push ;
 
 : next ( lag -- n )
     [ first ] [ advance ] bi ;
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index f2d6b89afcb1c215768cc7bdf3ca7e35aa4d3df0..1fb41b61c0d799f135b1d522fc7c2fb65908bbe3 100644 (file)
@@ -9,14 +9,6 @@ HELP: collect-benchmarks
     $nl
     "A nicer word for interactive use is " { $link ave-time } "." } ;
 
-HELP: nth-place
-{ $values { "x" float } { "n" integer } { "y" float } }
-{ $description "Rounds a floating point number to " { $snippet "n" } " decimal places." }
-{ $examples
-    "This word is useful for display purposes when showing 15 decimal places is not desired:"
-    { $unchecked-example "3.141592653589793 3 nth-place number>string" "\"3.142\"" }
-} ;
-
 HELP: ave-time
 { $values { "quot" quotation } { "n" integer } }
 { $description "Runs a quotation " { $snippet "n" } " times, then prints the average run time and standard deviation." }
diff --git a/extra/project-euler/ave-time/ave-time-tests.factor b/extra/project-euler/ave-time/ave-time-tests.factor
new file mode 100644 (file)
index 0000000..86b0048
--- /dev/null
@@ -0,0 +1,5 @@
+IN: project-euler.ave-time.tests
+USING: tools.test math arrays project-euler.ave-time ;
+
+{ 0 3 } [ 1 2 [ + ] 10 collect-benchmarks ] must-infer-as
+[ 1 2 t ] [ 1 2 [ + ] 10 collect-benchmarks array? ] unit-test
index dc521d4d70f0bd2520877b2f3c684439ace125f0..ec190fed187da15b7c51c00c970a1b1cc855f3c2 100644 (file)
@@ -1,24 +1,16 @@
 ! Copyright (c) 2007, 2008 Aaron Schaefer.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: continuations fry io kernel make math math.functions
-math.parser math.statistics memory tools.time ;
+USING: combinators.smart formatting fry io kernel macros math
+math.functions math.statistics memory sequences tools.time ;
 IN: project-euler.ave-time
 
-: nth-place ( x n -- y )
-    10^ [ * round >integer ] keep /f ;
-
-: collect-benchmarks ( quot n -- seq )
-    [
-        [ datastack ]
-        [
-            '[ _ gc benchmark 1000 / , ] tuck
-            '[ _ _ with-datastack drop ]
-        ]
-        [ 1 - ] tri* swap times call
-    ] { } make ; inline
+MACRO: collect-benchmarks ( quot n -- seq )
+    swap '[ _ [ [ [ _ nullary ] preserving ] gc benchmark 1000 / ] replicate ] ;
 
 : ave-time ( quot n -- )
-    [ collect-benchmarks ] keep swap
-    [ std 2 nth-place ] [ mean round >integer ] bi [
-        # " ms ave run time - " % # " SD (" % # " trials)" %
-    ] "" make print flush ; inline
+    [
+        collect-benchmarks
+        [ mean round >integer ]
+        [ std ] bi
+    ] keep
+    "%d ms ave run time - %.2f SD (%d trials)\n" printf flush ; inline
index 9eb9e968ca161c60b1f679206b873d88bf2772a4..a84f4fa48b3aff39506e2713581a89bc6fa142e4 100644 (file)
@@ -39,7 +39,7 @@ IN: project-euler.common
 <PRIVATE
 
 : max-children ( seq -- seq )
-    [ dup length 1 - [ nth-pair max , ] with each ] { } make ;
+    [ dup length 1 - iota [ nth-pair max , ] with each ] { } make ;
 
 ! Propagate one row into the upper one
 : propagate ( bottom top -- newtop )
index e64bd618522f3b2c8b541134e5b1f4fe318a3916..66f42968273d3fd6466e88cbf088d04efa9e9cdd 100644 (file)
@@ -16,16 +16,16 @@ USING: definitions io io.files io.pathnames kernel math math.parser
     project-euler.045 project-euler.046 project-euler.047 project-euler.048
     project-euler.049 project-euler.051 project-euler.052 project-euler.053
     project-euler.054 project-euler.055 project-euler.056 project-euler.057
-    project-euler.058 project-euler.059 project-euler.063 project-euler.065
-    project-euler.067 project-euler.069 project-euler.071 project-euler.072
-    project-euler.073 project-euler.074 project-euler.075 project-euler.076
-    project-euler.079 project-euler.081 project-euler.085 project-euler.092
-    project-euler.097 project-euler.099 project-euler.100 project-euler.102
-    project-euler.112 project-euler.116 project-euler.117 project-euler.124
-    project-euler.134 project-euler.148 project-euler.150 project-euler.151
-    project-euler.164 project-euler.169 project-euler.173 project-euler.175
-    project-euler.186 project-euler.188 project-euler.190 project-euler.203
-    project-euler.215 ;
+    project-euler.058 project-euler.059 project-euler.062 project-euler.063
+    project-euler.065 project-euler.067 project-euler.069 project-euler.071
+    project-euler.072 project-euler.073 project-euler.074 project-euler.075
+    project-euler.076 project-euler.079 project-euler.081 project-euler.085
+    project-euler.092 project-euler.097 project-euler.099 project-euler.100
+    project-euler.102 project-euler.112 project-euler.116 project-euler.117
+    project-euler.124 project-euler.134 project-euler.148 project-euler.150
+    project-euler.151 project-euler.164 project-euler.169 project-euler.173
+    project-euler.175 project-euler.186 project-euler.188 project-euler.190
+    project-euler.203 project-euler.215 ;
 IN: project-euler
 
 <PRIVATE
index 6fe361b556c565ae6a39052a925fde8243909f57..7c2bdd0d28007546253a9b696c72f5651ae1da9e 100644 (file)
@@ -1,5 +1,5 @@
 ! (c) 2009 Joe Groff, see BSD license
-USING: assocs kernel math.rectangles combinators accessors
+USING: assocs kernel math.rectangles combinators accessors locals
 math.vectors vectors sequences math combinators.short-circuit arrays fry ;
 IN: quadtrees
 
@@ -89,8 +89,9 @@ DEFER: in-rect*
 : insert ( value point tree -- )
     dup leaf?>> [ leaf-insert ] [ node-insert ] if ;
 
-: leaf-at-point ( point leaf -- value/f ? )
-    tuck point>> = [ value>> t ] [ drop f f ] if ;
+:: leaf-at-point ( point leaf -- value/f ? )
+    point leaf point>> =
+    [ leaf value>> t ] [ f f ] if ;
 
 : node-at-point ( point node -- value/f ? )
     descend at-point ;
@@ -103,15 +104,15 @@ DEFER: in-rect*
 : node-in-rect* ( values rect node -- values )
     [ (node-in-rect*) ] with each-quadrant ;
 
-: leaf-in-rect* ( values rect leaf -- values ) 
-    tuck { [ nip point>> ] [ point>> swap contains-point? ] } 2&&
-    [ value>> over push ] [ drop ] if ;
+:: leaf-in-rect* ( values rect leaf -- values ) 
+    { [ leaf point>> ] [ leaf point>> rect contains-point? ] } 0&&
+    [ values leaf value>> suffix! ] [ values ] if ;
 
 : in-rect* ( values rect tree -- values )
     dup leaf?>> [ leaf-in-rect* ] [ node-in-rect* ] if ;
 
-: leaf-erase ( point leaf -- )
-    tuck point>> = [ f >>point f >>value ] when drop ;
+:: leaf-erase ( point leaf -- )
+    point leaf point>> = [ leaf f >>point f >>value drop ] when ;
 
 : node-erase ( point node -- )
     descend erase ;
index 4b0dee642e7e9d7c4314c3a5a6b0da460a41af0b..0a397ddc6ddec7e18350400f5fcbc55bb35da97e 100644 (file)
@@ -22,7 +22,7 @@ IN: blum-blum-shub.tests
 
 [ 3716213681 ]
 [
-    100 T{ blum-blum-shub f 200352954495 846054538649 } clone tuck [
+    T{ blum-blum-shub f 200352954495 846054538649 } clone 100 over [
         random-32* drop
     ] curry times
     random-32*
diff --git a/extra/recipes/authors.txt b/extra/recipes/authors.txt
deleted file mode 100644 (file)
index ce0899f..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Sam Anklesaria
\ No newline at end of file
diff --git a/extra/recipes/icons/back.tiff b/extra/recipes/icons/back.tiff
deleted file mode 100644 (file)
index 27b8112..0000000
Binary files a/extra/recipes/icons/back.tiff and /dev/null differ
diff --git a/extra/recipes/icons/hate.tiff b/extra/recipes/icons/hate.tiff
deleted file mode 100644 (file)
index d7d5f8e..0000000
Binary files a/extra/recipes/icons/hate.tiff and /dev/null differ
diff --git a/extra/recipes/icons/love.tiff b/extra/recipes/icons/love.tiff
deleted file mode 100644 (file)
index ae2fa7b..0000000
Binary files a/extra/recipes/icons/love.tiff and /dev/null differ
diff --git a/extra/recipes/icons/more.tiff b/extra/recipes/icons/more.tiff
deleted file mode 100644 (file)
index b4ec27b..0000000
Binary files a/extra/recipes/icons/more.tiff and /dev/null differ
diff --git a/extra/recipes/icons/submit.tiff b/extra/recipes/icons/submit.tiff
deleted file mode 100644 (file)
index 7c98267..0000000
Binary files a/extra/recipes/icons/submit.tiff and /dev/null differ
diff --git a/extra/recipes/recipes.factor b/extra/recipes/recipes.factor
deleted file mode 100644 (file)
index d546859..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-USING: accessors arrays colors.constants combinators
-db.sqlite db.tuples db.types kernel locals math
-monads persistency sequences sequences.extras ui ui.gadgets.controls
-ui.gadgets.layout models.combinators ui.gadgets.labels
-ui.gadgets.scrollers ui.pens.solid io.files.temp ;
-FROM: sets => prune ;
-IN: recipes
-
-STORED-TUPLE: recipe { title { VARCHAR 100 } } { votes INTEGER } { txt TEXT } { genre { VARCHAR 100 } } ;
-: <recipe> ( title genre text -- recipe ) recipe new swap >>txt swap >>genre swap >>title 0 >>votes ;
-"recipes.db" temp-file <sqlite-db> recipe define-db
-: top-recipes ( offset search -- recipes ) <query> T{ recipe } rot >>title >>tuple
-    "votes" >>order 30 >>limit swap >>offset get-tuples ;
-: top-genres ( -- genres ) f f top-recipes [ genre>> ] map prune 4 short head-slice ;
-
-: interface ( -- book ) [ 
-     [
-        [ $ TOOLBAR $ ] <hbox> COLOR: AliceBlue <solid> >>interior ,
-        [ "Genres:" <label> , <spacer> $ ALL $ $ GENRES $ ] <hbox>
-            { 5 0 } >>gap COLOR: gray <solid> >>interior ,
-        $ RECIPES $
-     ] <vbox> ,
-     [
-        [ "Title:" <label> , $ TITLE $ "Genre:" <label> , $ GENRE $ ] <hbox> ,
-        $ BODY $
-        $ BUTTON $
-     ] <vbox> ,
-  ] <book*> { 350 245 } >>pref-dim ;
-  
-:: recipe-browser ( -- ) [ [
-    interface
-      <table*> :> tbl
-      "okay" <model-border-btn> BUTTON -> :> ok
-      IMG-MODEL-BTN: submit [ store-tuple ] >>value TOOLBAR -> :> submit
-      IMG-MODEL-BTN: love 1 >>value TOOLBAR ->
-      IMG-MODEL-BTN: hate -1 >>value -> 2array merge :> votes
-      IMG-MODEL-BTN: back -> [ -30 ] <$
-      IMG-MODEL-BTN: more -> [ 30 ] <$ 2array merge :> viewed
-      <spacer> <model-field*> ->% 1 :> search
-      submit ok [ [ drop ] ] <$ 2array merge [ drop ] >>value :> quot
-      viewed 0 [ + ] fold search ok t <basic> "all" <model-btn> ALL ->
-      tbl selection>> votes [ [ + ] curry change-votes modify-tuple ] 2$>
-        4array merge
-        [ drop [ f ] [ "%" dup surround <pattern> ] if-empty top-recipes ] 3fmap :> ups
-      ups [ top-genres [ <model-btn> GENRES -> ] map merge ] bind*
-        [ text>> T{ recipe } swap >>genre get-tuples ] fmap
-      tbl swap ups 2merge >>model
-        [ [ title>> ] [ genre>> ] bi 2array ] >>quot
-        { "Title" "Genre" } >>column-titles dup <scroller> RECIPES ,% 1 actions>>
-      submit [ "" dup dup <recipe> ] <$ 2array merge
-        { [ [ title>> ] fmap <model-field> TITLE ->% .5 ]
-          [ [ genre>> ] fmap <model-field> GENRE ->% .5 ]
-          [ [ txt>> ] fmap <model-editor> BODY ->% 1 ]
-        } cleave
-        [ <recipe> ] 3fmap
-      [ [ 1 ] <$ ]
-      [ quot ok updates #1 [ call( recipe -- ) 0 ] 2fmap ] bi
-      2merge 0 <basic> switch-models >>model
-   ] with-interface "recipes" open-window ] with-ui ;
-
-MAIN: recipe-browser
\ No newline at end of file
diff --git a/extra/recipes/summary.txt b/extra/recipes/summary.txt
deleted file mode 100644 (file)
index 98b1ece..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Database backed recipe sharing
\ No newline at end of file
index 466fdc9937ae709f2ee2f7f3992ac40e86a0a8bb..51d0c21a94e3fed17204af2e2d4368cad9bef631 100644 (file)
@@ -1,8 +1,8 @@
 ! Copyright (C) 2009 Bruno Deferrari
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors io io.encodings.8-bit io.sockets
-io.streams.duplex kernel redis.command-writer
-redis.response-parser splitting ;
+USING: accessors io io.sockets io.streams.duplex kernel
+redis.command-writer redis.response-parser splitting
+io.encodings.8-bit.latin1 ;
 IN: redis
 
 #! Connection
old mode 100755 (executable)
new mode 100644 (file)
index 9eb2804..cc6c9ee
@@ -49,15 +49,12 @@ IN: reports.noise
         { nkeep 5 }\r
         { npick 6 }\r
         { nrot 5 }\r
-        { ntuck 6 }\r
         { nwith 4 }\r
         { over 2 }\r
         { pick 4 }\r
         { rot 3 }\r
-        { spin 3 }\r
         { swap 1 }\r
         { swapd 3 }\r
-        { tuck 2 }\r
         { with 1/2 }\r
 \r
         { bi 1/2 }\r
index 6663381522aeb2fbcde56cd4f2b526184c1cd0f7..c8f08bcf30a1cfbcba5804c21a1f2895ac640e24 100644 (file)
@@ -3,7 +3,7 @@
 USING: kernel math sequences strings io combinators ascii ;
 IN: rot13
 
-: rotate ( ch base -- ch ) tuck - 13 + 26 mod + ;
+: rotate ( ch base -- ch ) [ - 13 + 26 mod ] [ + ] bi ;
 
 : rot-letter ( ch -- ch )
     {
index dda3e7f2009e67e67f91dba5987f845fb1397440..6f9c10010da2d4e06031979aa53e60528f906a93 100644 (file)
@@ -108,13 +108,14 @@ $nl
 "To use the api you must set the variables " { $link key-id } " and " \r
 { $link secret-key } " to your Amazon S3 key and secret key respectively. Once "\r
 "this is done you can call any of the words below."\r
-{ $subsection buckets }\r
-{ $subsection create-bucket }\r
-{ $subsection delete-bucket }\r
-{ $subsection keys }\r
-{ $subsection get-object }\r
-{ $subsection put-object }\r
-{ $subsection delete-object }\r
+{ $subsections buckets\r
+    create-bucket\r
+    delete-bucket\r
+    keys\r
+    get-object\r
+    put-object\r
+    delete-object\r
+}\r
 ;\r
 \r
-ABOUT: "s3"
\ No newline at end of file
+ABOUT: "s3"\r
diff --git a/extra/sequence-parser/sequence-parser-tests.factor b/extra/sequence-parser/sequence-parser-tests.factor
deleted file mode 100644 (file)
index af13e5b..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-USING: tools.test sequence-parser unicode.categories kernel
-accessors ;
-IN: sequence-parser.tests
-
-[ "hello" ]
-[ "hello" [ take-rest ] parse-sequence ] unit-test
-
-[ "hi" " how are you?" ]
-[
-    "hi how are you?"
-    [ [ [ current blank? ] take-until ] [ take-rest ] bi ] parse-sequence
-] unit-test
-
-[ "foo" ";bar" ]
-[
-    "foo;bar" [
-        [ CHAR: ; take-until-object ] [ take-rest ] bi
-    ] parse-sequence
-] unit-test
-
-[ "foo " "and bar" ]
-[
-    "foo and bar" [
-        [ "and" take-until-sequence ] [ take-rest ] bi 
-    ] parse-sequence
-] unit-test
-
-[ "foo " " bar" ]
-[
-    "foo and bar" [
-        [ "and" take-until-sequence ]
-        [ "and" take-sequence drop ]
-        [ take-rest ] tri
-    ] parse-sequence
-] unit-test
-
-[ "foo " " bar" ]
-[
-    "foo and bar" [
-        [ "and" take-until-sequence* ]
-        [ take-rest ] bi
-    ] parse-sequence
-] unit-test
-
-[ { 1 2 } ]
-[ { 1 2 3 4 } <sequence-parser> { 3 4 } take-until-sequence ] unit-test
-
-[ f "aaaa" ]
-[
-    "aaaa" <sequence-parser>
-    [ "b" take-until-sequence ] [ take-rest ] bi
-] unit-test
-
-[ 6 ]
-[
-    "      foo   " [ skip-whitespace n>> ] parse-sequence
-] unit-test
-
-[ { 1 2 } ]
-[ { 1 2 3 } <sequence-parser> [ current 3 = ] take-until ] unit-test
-
-[ "ab" ]
-[ "abcd" <sequence-parser> "ab" take-sequence ] unit-test
-
-[ f ]
-[ "abcd" <sequence-parser> "lol" take-sequence ] unit-test
-
-[ "ab" ]
-[
-    "abcd" <sequence-parser>
-    [ "lol" take-sequence drop ] [ "ab" take-sequence ] bi
-] unit-test
-
-[ "" ]
-[ "abcd" <sequence-parser> "" take-sequence ] unit-test
-
-[ "cd" ]
-[ "abcd" <sequence-parser> [ "ab" take-sequence drop ] [ "cd" take-sequence ] bi ] unit-test
-
-[ f ]
-[ "" <sequence-parser> take-rest ] unit-test
-
-[ f ]
-[ "abc" <sequence-parser> dup "abc" take-sequence drop take-rest ] unit-test
-
-[ f ]
-[ "abc" <sequence-parser> "abcdefg" take-sequence ] unit-test
-
-[ "1234" ]
-[ "1234f" <sequence-parser> take-integer ] unit-test
-
-[ "yes" ]
-[
-    "yes1234f" <sequence-parser>
-    [ take-integer drop ] [ "yes" take-sequence ] bi 
-] unit-test
-
-[ f ] [ "" <sequence-parser> 4 take-n ] unit-test
-[ "abcd" ] [ "abcd" <sequence-parser> 4 take-n ] unit-test
-[ "abcd" "efg" ] [ "abcdefg" <sequence-parser> [ 4 take-n ] [ take-rest ] bi ] unit-test
-
-[ f ]
-[ "\n" <sequence-parser> take-integer ] unit-test
-
-[ "\n" ] [ "\n" <sequence-parser> [ ] take-while ] unit-test
-[ f ] [ "\n" <sequence-parser> [ not ] take-while ] unit-test
diff --git a/extra/sequence-parser/sequence-parser.factor b/extra/sequence-parser/sequence-parser.factor
deleted file mode 100644 (file)
index d14a770..0000000
+++ /dev/null
@@ -1,148 +0,0 @@
-! Copyright (C) 2005, 2009 Daniel Ehrenberg, Doug Coleman.
-! See http://factorcode.org/license.txt for BSD license.
-USING: accessors circular combinators.short-circuit fry io
-kernel locals math math.order sequences sorting.functor
-sorting.slots unicode.categories ;
-IN: sequence-parser
-
-TUPLE: sequence-parser sequence n ;
-
-: <sequence-parser> ( sequence -- sequence-parser )
-    sequence-parser new
-        swap >>sequence
-        0 >>n ;
-
-:: with-sequence-parser ( sequence-parser quot -- seq/f )
-    sequence-parser n>> :> n
-    sequence-parser quot call [
-        n sequence-parser (>>n) f
-    ] unless* ; inline
-
-: offset  ( sequence-parser offset -- char/f )
-    swap
-    [ n>> + ] [ sequence>> ?nth ] bi ; inline
-
-: current ( sequence-parser -- char/f ) 0 offset ; inline
-
-: previous ( sequence-parser -- char/f ) -1 offset ; inline
-
-: peek-next ( sequence-parser -- char/f ) 1 offset ; inline
-
-: advance ( sequence-parser -- sequence-parser )
-    [ 1 + ] change-n ; inline
-
-: advance* ( sequence-parser -- )
-    advance drop ; inline
-
-: next ( sequence-parser -- obj ) [ current ] [ advance* ] bi ;
-
-: get+increment ( sequence-parser -- char/f )
-    [ current ] [ advance drop ] bi ; inline
-
-:: skip-until ( sequence-parser quot: ( obj -- ? ) -- )
-    sequence-parser current [
-        sequence-parser quot call
-        [ sequence-parser advance quot skip-until ] unless
-    ] when ; inline recursive
-
-: sequence-parse-end? ( sequence-parser -- ? ) current not ;
-
-: take-until ( sequence-parser quot: ( obj -- ? ) -- sequence/f )
-    over sequence-parse-end? [
-        2drop f
-    ] [
-        [ drop n>> ]
-        [ skip-until ]
-        [ drop [ n>> ] [ sequence>> ] bi ] 2tri subseq f like
-    ] if ; inline
-
-: take-while ( sequence-parser quot: ( obj -- ? ) -- sequence/f )
-    [ not ] compose take-until ; inline
-
-: <safe-slice> ( from to seq -- slice/f )
-    3dup {
-        [ 2drop 0 < ]
-        [ [ drop ] 2dip length > ]
-        [ drop > ]
-    } 3|| [ 3drop f ] [ slice boa ] if ; inline
-
-:: take-sequence ( sequence-parser sequence -- obj/f )
-    sequence-parser [ n>> dup sequence length + ] [ sequence>> ] bi
-    <safe-slice> sequence sequence= [
-        sequence
-        sequence-parser [ sequence length + ] change-n drop
-    ] [
-        f
-    ] if ;
-
-: take-sequence* ( sequence-parser sequence -- )
-    take-sequence drop ;
-
-:: take-until-sequence ( sequence-parser sequence -- sequence'/f )
-    sequence-parser n>> :> saved
-    sequence length <growing-circular> :> growing
-    sequence-parser
-    [
-        current growing push-growing-circular
-        sequence growing sequence=
-    ] take-until :> found
-    growing sequence sequence= [
-        found dup length
-        growing length 1 - - head
-        sequence-parser [ growing length - 1 + ] change-n drop
-        ! sequence-parser advance drop
-    ] [
-        saved sequence-parser (>>n)
-        f
-    ] if ;
-
-:: take-until-sequence* ( sequence-parser sequence -- sequence'/f )
-    sequence-parser sequence take-until-sequence :> out
-    out [
-        sequence-parser [ sequence length + ] change-n drop
-    ] when out ;
-
-: skip-whitespace ( sequence-parser -- sequence-parser )
-    [ [ current blank? not ] take-until drop ] keep ;
-
-: skip-whitespace-eol ( sequence-parser -- sequence-parser )
-    [ [ current " \t\r" member? not ] take-until drop ] keep ;
-
-: take-rest-slice ( sequence-parser -- sequence/f )
-    [ sequence>> ] [ n>> ] bi
-    2dup [ length ] dip < [ 2drop f ] [ tail-slice ] if ; inline
-
-: take-rest ( sequence-parser -- sequence )
-    [ take-rest-slice ] [ sequence>> like ] bi f like ;
-
-: take-until-object ( sequence-parser obj -- sequence )
-    '[ current _ = ] take-until ;
-
-: parse-sequence ( sequence quot -- )
-    [ <sequence-parser> ] dip call ; inline
-
-: take-integer ( sequence-parser -- n/f )
-    [ current digit? ] take-while ;
-
-:: take-n ( sequence-parser n -- seq/f )
-    n sequence-parser [ n>> + ] [ sequence>> length ] bi > [
-        sequence-parser take-rest
-    ] [
-        sequence-parser n>> dup n + sequence-parser sequence>> subseq
-        sequence-parser [ n + ] change-n drop
-    ] if ;
-
-<< "length" [ length ] define-sorting >>
-
-: sort-tokens ( seq -- seq' )
-    { length>=< <=> } sort-by ;
-
-: take-first-matching ( sequence-parser seq -- seq )
-    swap
-    '[ _ [ swap take-sequence ] with-sequence-parser ] find nip ;
-
-: take-longest ( sequence-parser seq -- seq )
-    sort-tokens take-first-matching ;
-
-: write-full ( sequence-parser -- ) sequence>> write ;
-: write-rest ( sequence-parser -- ) take-rest write ;
index 6770a48a3a835c98e98157a306f1f4d89ec9d995..2dc22477838594feadc25add3c85cfe4ad39741a 100644 (file)
@@ -12,7 +12,7 @@ IN: sequences.abbrev
     [ prefixes ] keep 1array '[ _ ] H{ } map>assoc ;
 
 : assoc-merge ( assoc1 assoc2 -- assoc3 )
-    tuck '[ over _ at dup [ append ] [ drop ] if ] assoc-map assoc-union ;
+    [ '[ over _ at dup [ append ] [ drop ] if ] assoc-map ] keep swap assoc-union ;
 
 PRIVATE>
 
index d552f2dc77a9ede9af6930d911df60a5a9146eb4..73fcc651bda4ef2de50b06751743de0de069c421 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2008 Alex Chapman
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors arrays kernel math math.order
+USING: accessors arrays kernel locals math math.order
 sequences sequences.private shuffle ;
 IN: sequences.modified
 
@@ -21,7 +21,7 @@ TUPLE: 1modified < modified seq ;
 M: modified length seq>> length ;
 M: modified set-length seq>> set-length ;
 
-M: 1modified virtual-seq seq>> ;
+M: 1modified virtual-exemplar seq>> ;
 
 TUPLE: scaled < 1modified c ;
 C: <scaled> scaled
@@ -32,9 +32,9 @@ C: <scaled> scaled
 M: scaled modified-nth ( n seq -- elt )
     [ seq>> nth ] [ c>> * ] bi ;
 
-M: scaled modified-set-nth ( elt n seq -- elt )
+M:: scaled modified-set-nth ( elt n seq -- elt )
     ! don't set c to 0!
-    tuck [ c>> / ] 2dip seq>> set-nth ;
+    elt seq c>> / n seq seq>> set-nth ;
 
 TUPLE: offset < 1modified n ;
 C: <offset> offset
@@ -45,8 +45,8 @@ C: <offset> offset
 M: offset modified-nth ( n seq -- elt )
     [ seq>> nth ] [ n>> + ] bi ;
 
-M: offset modified-set-nth ( elt n seq -- )
-    tuck [ n>> - ] 2dip seq>> set-nth ;
+M:: offset modified-set-nth ( elt n seq -- )
+    elt seq n>> - n seq seq>> set-nth ;
 
 TUPLE: summed < modified seqs ;
 C: <summed> summed
@@ -71,7 +71,8 @@ M: summed modified-set-nth ( elt n seq -- ) immutable ;
 M: summed set-length ( n seq -- )
     seqs>> [ set-length ] with each ;
 
-M: summed virtual-seq ( summed -- seq ) [ ] { } map-as ;
+M: summed virtual-exemplar ( summed -- seq )
+    seqs>> [ f ] [ first ] if-empty ;
 
 : <2summed> ( seq seq -- summed-seq ) 2array <summed> ;
 : <3summed> ( seq seq seq -- summed-seq ) 3array <summed> ;
index 77fddd551021305a9e52eebca18dc040d3422609..7157e3f025a059f1cc51f3de1061ac838bf43d12 100644 (file)
@@ -16,6 +16,6 @@ M: repeating set-length (>>len) ;
 
 M: repeating virtual@ ( n seq -- n' seq' ) circular>> ;
 
-M: repeating virtual-seq circular>> ;
+M: repeating virtual-exemplar circular>> ;
 
 INSTANCE: repeating virtual-sequence
index 04731b0e27d6210833b4c500a029090ba7d2a4a1..80d8bf224695914714862a7264ed4d225ff0cef7 100644 (file)
@@ -1,9 +1,9 @@
-USING: accessors assocs fry generalizations kernel math
-namespaces parser sequences words ;
+USING: accessors assocs fry generalizations kernel locals math
+namespaces parser sequences shuffle words ;
 IN: set-n
 : get* ( var n -- val ) namestack dup length rot - head assoc-stack ;
 
 : set* ( val var n -- ) 1 + namestack [ length swap - ] keep nth set-at ;
 
 ! dynamic lambda
-SYNTAX: :| (:) dup in>> dup length [ spin '[ _ narray _ swap zip _ bind ] ] 2curry dip define-declared ;
\ No newline at end of file
+SYNTAX: :| (:) dup in>> dup length [ spin '[ _ narray _ swap zip _ bind ] ] 2curry dip define-declared ;
index 535c8cd6261e942548cd35f027b07ed5fc475114..dcae438679e80c4eacd9e2adbd7e17e0ab1a8899 100644 (file)
@@ -10,7 +10,7 @@ SYMBOL: site-watcher-frequency
 5 minutes site-watcher-frequency set-global
  
 SYMBOL: running-site-watcher
-[ f running-site-watcher set-global ] "site-watcher" add-init-hook
+[ f running-site-watcher set-global ] "site-watcher" add-startup-hook
 
 <PRIVATE
 
old mode 100755 (executable)
new mode 100644 (file)
index 19b0dea..fe552a7
@@ -1,4 +1,4 @@
-! Copyright (C) 2007, 2009 Slava Pestov.
+! Copyright (C) 2007, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: arrays hashtables help.markup help.stylesheet io
 io.styles kernel math models namespaces sequences ui ui.gadgets
@@ -94,7 +94,7 @@ TUPLE: slides < book ;
     [ first3 ] dip head 3array ;
 
 : strip-tease ( data -- seq )
-    dup third length 1 - [
+    dup third length 1 - iota [
         2 + (strip-tease)
     ] with map ;
 
index 81b38f2c1450946e8794fb2f017a21b0d519575e..afbeea61108daac1f2af7943404ffef7e0593afa 100644 (file)
@@ -10,7 +10,7 @@ IN: smalltalk.compiler.tests
     ] with-compilation-unit ;
 
 : test-inference ( ast -- in# out# )
-    test-compilation infer [ in>> ] [ out>> ] bi ;
+    test-compilation infer [ in>> ] [ out>> ] bi [ length ] bi@ ;
 
 [ 2 1 ] [
     T{ ast-block f
index 2ea1e99afd1ce349fa6e1871f449c756d7a63192..609498634574e2eb834adca3f4f186f524d7e50c 100644 (file)
@@ -1,6 +1,6 @@
-! Copyright (C) 2009 Slava Pestov.
+! Copyright (C) 2009, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: combinators effects generic generic.standard
+USING: arrays combinators effects generic generic.standard
 kernel sequences words lexer ;
 IN: smalltalk.selectors
 
@@ -15,9 +15,9 @@ SYMBOLS: unary binary keyword ;
 
 : selector>effect ( selector -- effect )
     dup selector-type {
-        { unary [ drop 0 ] }
-        { binary [ drop 1 ] }
-        { keyword [ [ CHAR: : = ] count ] }
+        { unary [ drop { } ] }
+        { binary [ drop { "x" } ] }
+        { keyword [ [ CHAR: : = ] count "x" <array> ] }
     } case "receiver" suffix { "result" } <effect> ;
 
 : selector>generic ( selector -- generic )
old mode 100755 (executable)
new mode 100644 (file)
index 07b5608..17e277f
@@ -14,7 +14,9 @@ USING:
     io.files
     io.pathnames
     kernel 
+    locals
     math
+    math.order
     openal
     opengl.gl
     sequences
@@ -40,12 +42,11 @@ CONSTANT: game-height 256
   #! Point is a {x y}.
   first2 game-width 3 * * swap 3 * + ;
 
-: set-bitmap-pixel ( color point array -- )
-  #! 'color' is a {r g b}. Point is {x y}.
-  [ bitmap-index ] dip ! color index array
-  [ [ first ] 2dip set-nth ] 3keep
-  [ [ second ] 2dip [ 1 + ] dip set-nth ] 3keep
-  [ third ] 2dip [ 2 + ] dip set-nth ;
+:: set-bitmap-pixel ( bitmap point color -- )
+    point bitmap-index :> index
+    color first  index     bitmap set-nth
+    color second index 1 + bitmap set-nth
+    color third  index 2 + bitmap set-nth ;
 
 : get-bitmap-pixel ( point array -- color )
   #! Point is a {x y}. color is a {r g b} 
@@ -71,16 +72,16 @@ CONSTANT: SOUND-UFO-HIT      8
 : init-sounds ( cpu -- )
   init-openal
   [ 9 gen-sources swap (>>sounds) ] keep
-  [ SOUND-SHOT        "resource:extra/space-invaders/resources/Shot.wav" init-sound ] keep 
-  [ SOUND-UFO         "resource:extra/space-invaders/resources/Ufo.wav" init-sound ] keep 
+  [ SOUND-SHOT        "vocab:space-invaders/resources/Shot.wav" init-sound ] keep 
+  [ SOUND-UFO         "vocab:space-invaders/resources/Ufo.wav" init-sound ] keep 
   [ sounds>> SOUND-UFO swap nth AL_LOOPING AL_TRUE set-source-param ] keep
-  [ SOUND-BASE-HIT    "resource:extra/space-invaders/resources/BaseHit.wav" init-sound ] keep 
-  [ SOUND-INVADER-HIT "resource:extra/space-invaders/resources/InvHit.Wav" init-sound ] keep 
-  [ SOUND-WALK1       "resource:extra/space-invaders/resources/Walk1.wav" init-sound ] keep 
-  [ SOUND-WALK2       "resource:extra/space-invaders/resources/Walk2.wav" init-sound ] keep 
-  [ SOUND-WALK3       "resource:extra/space-invaders/resources/Walk3.wav" init-sound ] keep 
-  [ SOUND-WALK4       "resource:extra/space-invaders/resources/Walk4.wav" init-sound ] keep 
-  [ SOUND-UFO-HIT    "resource:extra/space-invaders/resources/UfoHit.wav" init-sound ] keep
+  [ SOUND-BASE-HIT    "vocab:space-invaders/resources/BaseHit.wav" init-sound ] keep 
+  [ SOUND-INVADER-HIT "vocab:space-invaders/resources/InvHit.Wav" init-sound ] keep 
+  [ SOUND-WALK1       "vocab:space-invaders/resources/Walk1.wav" init-sound ] keep 
+  [ SOUND-WALK2       "vocab:space-invaders/resources/Walk2.wav" init-sound ] keep 
+  [ SOUND-WALK3       "vocab:space-invaders/resources/Walk3.wav" init-sound ] keep 
+  [ SOUND-WALK4       "vocab:space-invaders/resources/Walk4.wav" init-sound ] keep 
+  [ SOUND-UFO-HIT    "vocab:space-invaders/resources/UfoHit.wav" init-sound ] keep
   f swap (>>looping?) ;
 
 : cpu-init ( cpu -- cpu )
@@ -139,8 +140,8 @@ M: space-invaders read-port ( port cpu -- byte )
   #! Setting this value affects the value read from port 3
   (>>port2o) ;
 
-: bit-newly-set? ( old-value new-value bit -- bool )
-  tuck bit? [ bit? not ] dip and ;
+:: bit-newly-set? ( old-value new-value bit -- bool )
+  new-value bit bit? [ old-value bit bit? not ] dip and ;
 
 : port3-newly-set? ( new-value cpu bit -- bool )
   [ port3o>> swap ] dip bit-newly-set? ;
@@ -317,19 +318,15 @@ CONSTANT: red   { 255 0 0 }
 
 : plot-bitmap-pixel ( bitmap point color -- )
   #! point is a {x y}. color is a {r g b}.
-  spin set-bitmap-pixel ;
-
-: within ( n a b -- bool )
-  #! n >= a and n <= b
-  rot tuck swap <= [ swap >= ] dip and ;
+  set-bitmap-pixel ;
 
 : get-point-color ( point -- color )
   #! Return the color to use for the given x/y position.
   first2
   {
-    { [ dup 184 238 within pick 0 223 within and ] [ 2drop green ] }
-    { [ dup 240 247 within pick 16 133 within and ] [ 2drop green ] }
-    { [ dup 247 215 - 247 184 - within pick 0 223 within and ] [ 2drop red ] }
+    { [ dup 184 238 between? pick 0 223 between? and ] [ 2drop green ] }
+    { [ dup 240 247 between? pick 16 133 between? and ] [ 2drop green ] }
+    { [ dup 247 215 - 247 184 - between? pick 0 223 between? and ] [ 2drop red ] }
     [ 2drop white ]
   } cond ;
 
@@ -359,12 +356,12 @@ M: space-invaders update-video ( value addr cpu -- )
     3drop
   ] if ;
 
-: sync-frame ( millis -- millis )
+: sync-frame ( micros -- micros )
   #! Sleep until the time for the next frame arrives.
-  1000 60 / >fixnum + system:millis - dup 0 >
-  [ milliseconds threads:sleep ] [ drop threads:yield ] if system:millis ;
+  1000 60 / >fixnum + system:system-micros - dup 0 >
+  [ milliseconds threads:sleep ] [ drop threads:yield ] if system:system-micros ;
 
-: invaders-process ( millis gadget -- )
+: invaders-process ( micros gadget -- )
   #! Run a space invaders gadget inside a 
   #! concurrent process. Messages can be sent to
   #! signal key presses, etc.
@@ -380,7 +377,7 @@ M: space-invaders update-video ( value addr cpu -- )
 M: invaders-gadget graft* ( gadget -- )
   dup cpu>> init-sounds
   f over (>>quit?)
-  [ system:millis swap invaders-process ] curry
+  [ system:system-micros swap invaders-process ] curry
   "Space invaders" threads:spawn drop ;
 
 M: invaders-gadget ungraft* ( gadget -- )
old mode 100755 (executable)
new mode 100644 (file)
index b7431ca..819dbe8
@@ -196,9 +196,6 @@ M: spheres-world end-world
         [ plane-program>> [ delete-gl-program ] when* ]
     } cleave ;
 
-M: spheres-world pref-dim*
-    drop { 640 480 } ;
-
 :: (draw-sphere) ( program center radius -- )
     program "center" glGetAttribLocation center first3 glVertexAttrib3f
     program "radius" glGetAttribLocation radius glVertexAttrib1f
@@ -299,17 +296,13 @@ M: spheres-world draw-world*
         ]
     } cleave ;
 
-: spheres-window ( -- )
-    [
-        f T{ world-attributes
-            { world-class spheres-world }
-            { title "Spheres" }
-            { pixel-format-attributes {
-                windowed
-                double-buffered
-                T{ depth-bits { value 16 } }
-            } }
-        } open-window
-    ] with-ui ;
-
-MAIN: spheres-window
+MAIN-WINDOW: spheres-window {
+        { world-class spheres-world }
+        { title "Spheres" }
+        { pixel-format-attributes {
+            windowed
+            double-buffered
+            T{ depth-bits { value 16 } }
+        } }
+        { pref-dim { 640 480 } }
+    } ;
index 4ce998294b283c26b12adb972281c5b379231346..c8ea4734d28a79294a182ecd33c04d9bcc57f2e7 100644 (file)
@@ -57,7 +57,7 @@ fetched-in parsed-html links processed-in fetched-at ;
     [ filter-base-links ] 2keep
     depth>> 1 + swap
     [ add-nonmatching ]
-    [ tuck [ apply-filters ] 2dip add-todo ] 2bi ;
+    [ dup '[ _ apply-filters ] curry 2dip add-todo ] 2bi ;
 
 : normalize-hrefs ( base links -- links' )
     [ derive-url ] with map ;
index 9003b56b15939e64f90c8b864cfd9c14fed76d9a..f660674b63c7232fda7797fe6c732f7d5605d78e 100644 (file)
@@ -30,7 +30,7 @@ TUPLE: unique-deque assoc deque ;
 
 : peek-url ( unique-deque -- todo-url ) deque>> peek-front ;
 
-:: slurp-deque-when ( deque quot1 quot2: ( value -- ) -- )
+:: slurp-deque-when ( deque quot1: ( value -- ) quot2: ( value -- ) -- )
     deque deque-empty? [
         deque pop-front dup quot1 call
         [ quot2 call t ] [ drop f ] if
old mode 100755 (executable)
new mode 100644 (file)
diff --git a/extra/sudoku/sudoku-tests.factor b/extra/sudoku/sudoku-tests.factor
new file mode 100644 (file)
index 0000000..60babf0
--- /dev/null
@@ -0,0 +1,4 @@
+IN: sudoku.tests
+USING: tools.test sudoku ;
+
+[ ] [ sudoku-demo ] unit-test
old mode 100755 (executable)
new mode 100644 (file)
index 555f1e6..848d647
@@ -19,7 +19,7 @@ SYMBOL: board
 
 : box-any? ( n x y -- ? )
     [ 3 /i 3 * ] bi@
-    9 [ [ 3dup ] dip cell-any? ] any?
+    9 iota [ [ 3dup ] dip cell-any? ] any?
     [ 3drop ] dip ;
 
 DEFER: search
@@ -35,7 +35,7 @@ DEFER: search
         [ assume ]
     } cond ;
 
-: solve ( x y -- ) 9 [ 1 + 2over attempt ] each 2drop ;
+: solve ( x y -- ) 9 [ 1 + 2over attempt ] each-integer 2drop ;
 
 : board. ( board -- )
     standard-table-style [
@@ -52,7 +52,7 @@ DEFER: search
                 ] each
             ] with-row
         ] each
-    ] tabular-output ;
+    ] tabular-output nl ;
 
 : solution. ( -- )
     solutions inc "Solution:" print board get board. ;
diff --git a/extra/sudokus/authors.txt b/extra/sudokus/authors.txt
deleted file mode 100644 (file)
index ce0899f..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Sam Anklesaria
\ No newline at end of file
diff --git a/extra/sudokus/sudokus.factor b/extra/sudokus/sudokus.factor
deleted file mode 100644 (file)
index ff20f15..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-USING: accessors arrays combinators.short-circuit grouping kernel lists
-lists.lazy locals math math.functions math.parser math.ranges
-models.product monads random sequences sets ui ui.gadgets.controls
-ui.gadgets.layout models.combinators ui.gadgets.alerts vectors fry
-ui.gadgets.labels shuffle ;
-IN: sudokus
-
-: row ( index -- row ) 1 + 9 / ceiling ;
-: col ( index -- col ) 9 mod 1 + ;
-: sq ( index -- square ) [ row ] [ col ] bi [ 3 / ceiling ] bi@ 2array ;
-: near ( a pos -- ? ) { [ [ row ] bi@ = ] [ [ col ] bi@ = ] [ [ sq ] bi@ = ] } 2|| ;
-: nth-or-lower ( n seq -- elt ) [ length 1 - 2dup > [ nip ] [ drop ] if ] keep nth ;
-
-:: solutions ( puzzle random? -- solutions )
-    f puzzle random? [ indices [ f ] [ random? swap nth-or-lower ] if-empty ] [ index ] if
-    [ :> pos
-      1 9 [a,b] 80 iota [ pos near ] filter [ puzzle nth ] map prune diff
-      [ 1array puzzle pos cut-slice rest surround ] map >list [ random? solutions ] bind
-    ] [ puzzle list-monad return ] if* ;
-
-: solution ( puzzle random? -- solution ) dupd solutions dup +nil+ = [ drop "Unsolvable" alert* ] [ nip car ] if ;
-: hint ( puzzle -- puzzle' ) [ [ f swap indices random dup ] [ f solution ] bi nth ] keep swapd >vector [ set-nth ] keep ;
-: create ( difficulty -- puzzle ) 81 [ f ] replicate
-    40 random solution [ [ dup length random f spin set-nth ] curry times ] keep ;
-
-: do-sudoku ( -- ) [ [
-        [
-            81 [ "" ] replicate <basic> switch-models [ [ <basic> ] map 9 group [ 3 group ] map 3 group
-               [ [ [ <spacer> [ [ <model-field> ->% 2 [ string>number ] fmap ]
-                    map <spacer> ] map concat ] <hbox> , ] map concat <spacer> ] map concat <product>
-               [ "Difficulty:" <label> , "1" <basic> <model-field> -> [ string>number 1 or 1 + 10 * ] fmap
-               "Generate" <model-border-btn> -> updates [ create ] fmap <spacer>
-               "Hint" <model-border-btn> -> "Solve" <model-border-btn> -> ] <hbox> ,
-               roll [ swap updates ] curry bi@
-               [ [ hint ] fmap ] [ [ f solution ] fmap ] bi* 3array merge [ [ [ number>string ] [ "" ] if* ] map ] fmap
-           ] bind
-        ] with-self , ] <vbox> { 280 220 } >>pref-dim
-    "Sudoku Sleuth" open-window ] with-ui ;
-
-MAIN: do-sudoku
diff --git a/extra/sudokus/summary.txt b/extra/sudokus/summary.txt
deleted file mode 100644 (file)
index d66e7be..0000000
+++ /dev/null
@@ -1 +0,0 @@
-graphical sudoku solver
\ No newline at end of file
old mode 100755 (executable)
new mode 100644 (file)
index 251f60e6d7ddedab514ee9815b1da9cc37f6cecd..4541a15eca34c04cad80305d4bbb701921d049d5 100644 (file)
@@ -9,6 +9,7 @@ ERROR: fica-base-unknown ;
 
 : fica-base-rate ( year -- x )
     H{
+        { 2009 106800 }
         { 2008 102000 }
         { 2007  97500 }
     } at [ fica-base-unknown ] unless* ;
index 86f532badab9d38b128701fd03d0b6eab89246c6..3ed4af3b1d21098cba5792cce0947ff3f229eea2 100644 (file)
@@ -3,7 +3,6 @@ combinators.smart fry grouping images kernel math
 math.matrices.simd math.order math.vectors noise random
 sequences math.vectors.simd typed ;
 FROM: alien.c-types => float uchar ;
-SIMDS: float uchar ;
 IN: terrain.generation
 
 CONSTANT: terrain-segment-size { 512 512 }
index f1da877c3e0ce04c5eff7d1ccd54860b131b32bb..27bd7df403550bf3c98d0519d223bf4fbcc587ac 100644 (file)
@@ -6,12 +6,11 @@ math.vectors opengl opengl.capabilities opengl.gl
 opengl.shaders opengl.textures opengl.textures.private
 sequences sequences.product specialized-arrays
 terrain.generation terrain.shaders typed ui ui.gadgets
-ui.gadgets.worlds ui.pixel-formats game.worlds method-chains
+ui.gadgets.worlds ui.pixel-formats game.worlds
 math.matrices.simd noise ui.gestures combinators.short-circuit
 destructors grid-meshes math.vectors.simd ;
 QUALIFIED-WITH: alien.c-types c
 SPECIALIZED-ARRAY: c:float
-SIMD: c:float
 IN: terrain
 
 CONSTANT: FOV $[ 2.0 sqrt 1 + ]
@@ -22,14 +21,14 @@ CONSTANT: VELOCITY-MODIFIER-NORMAL float-4{ 1.0 1.0 1.0 0.0 }
 CONSTANT: VELOCITY-MODIFIER-FAST float-4{ 2.0 1.0 2.0 0.0 }
 CONSTANT: BOUNCE float-4{ 1.0 -0.2 1.0 1.0 }
 CONSTANT: PLAYER-HEIGHT 1/256.
-CONSTANT: GRAVITY float-4{ 0.0 -1/4096. 0.0 0.0 }
-CONSTANT: JUMP 1/1024.
-CONSTANT: MOUSE-SCALE 1/10.
-CONSTANT: MOVEMENT-SPEED 1/16384.
-CONSTANT: FRICTION float-4{ 0.95 0.99 0.95 1.0 }
+CONSTANT: GRAVITY float-4{ 0.0 -1/8192. 0.0 0.0 }
+CONSTANT: JUMP 1/2048.
+CONSTANT: MOUSE-SCALE 1/20.
+CONSTANT: MOVEMENT-SPEED 1/32768.
+CONSTANT: FRICTION float-4{ 0.97 0.995 0.97 1.0 }
 CONSTANT: COMPONENT-SCALE float-4{ 0.5 0.01 0.0005 0.0 }
-CONSTANT: SKY-PERIOD 1200
-CONSTANT: SKY-SPEED 0.0005
+CONSTANT: SKY-PERIOD 2400
+CONSTANT: SKY-SPEED 0.00025
 
 CONSTANT: terrain-vertex-size { 512 512 }
 
@@ -56,9 +55,6 @@ TUPLE: terrain-world < game-world
         float-4{ 0.0 0.0 0.0 1.0 } >>velocity
         VELOCITY-MODIFIER-NORMAL >>velocity-modifier ;
 
-M: terrain-world tick-length
-    drop 1000 30 /i ;
-
 : frustum ( dim -- -x x -y y near far )
     dup first2 min v/n
     NEAR-PLANE FOV / v*n first2 [ [ neg ] keep ] bi@
@@ -221,7 +217,7 @@ terrain-world H{
     [ tick-player-reverse ]
     [ tick-player-forward ] if ;
 
-M: terrain-world tick*
+M: terrain-world tick-game-world
     [ dup focused?>> [ handle-input ] [ drop ] if ]
     [ dup player>> tick-player ] bi ;
 
@@ -237,7 +233,7 @@ M: terrain-world tick*
 : sky-theta ( world -- theta )
     game-loop>> tick-number>> SKY-SPEED * ;
 
-BEFORE: terrain-world begin-world
+M: terrain-world begin-game-world
     "2.0" { "GL_ARB_vertex_buffer_object" "GL_ARB_shader_objects" }
     require-gl-version-or-extensions
     GL_DEPTH_TEST glEnable
@@ -258,7 +254,7 @@ BEFORE: terrain-world begin-world
     terrain-vertex-size <grid-mesh> >>terrain-mesh
     drop ;
 
-AFTER: terrain-world end-world
+M: terrain-world end-game-world
     {
         [ terrain-mesh>> dispose ]
         [ terrain-program>> delete-gl-program ]
@@ -291,20 +287,16 @@ M: terrain-world draw-world*
         ] with-gl-program ]
     } cleave gl-error ;
 
-M: terrain-world pref-dim* drop { 1024 768 } ;
-
-: terrain-window ( -- )
-    [
-        f T{ world-attributes
-            { world-class terrain-world }
-            { title "Terrain" }
-            { pixel-format-attributes {
-                windowed
-                double-buffered
-                T{ depth-bits { value 24 } }
-            } }
-            { grab-input? t }
-        } open-window
-    ] with-ui ;
-
-MAIN: terrain-window
+GAME: terrain-game {
+        { world-class terrain-world }
+        { title "Terrain" }
+        { pixel-format-attributes {
+            windowed
+            double-buffered
+            T{ depth-bits { value 24 } }
+        } }
+        { use-game-input? t }
+        { grab-input? t }
+        { pref-dim { 1024 768 } }
+        { tick-interval-micros $[ 60 fps ] }
+    } ;
index 1f12dcabe6454a5dd02ecc0651c2d255b40f05a4..2346999bcbc822ae69686dad6b97e191470d8842 100644 (file)
@@ -6,7 +6,7 @@ IN: tetris.board
 TUPLE: board { width integer } { height integer } rows ;
 
 : make-rows ( width height -- rows )
-    [ drop f <array> ] with map ;
+    iota [ drop f <array> ] with map ;
 
 : <board> ( width height -- board )
     2dup make-rows board boa ;
@@ -24,8 +24,8 @@ TUPLE: board { width integer } { height integer } rows ;
 : block-free? ( board block -- ? ) block not ;
 
 : block-in-bounds? ( board block -- ? )
-    [ first swap width>> bounds-check? ] 2keep
-    second swap height>> bounds-check? and ;
+    [ first swap width>> iota bounds-check? ]
+    [ second swap height>> iota bounds-check? ] 2bi and ;
 
 : location-valid? ( board block -- ? )
     2dup block-in-bounds? [ block-free? ] [ 2drop f ] if ;
old mode 100755 (executable)
new mode 100644 (file)
index e1b5867f64ed684ae5095036171bd144b60da824..a45e6551317ebc44cf97f256eedd9ebd92ce22ff 100644 (file)
@@ -35,10 +35,10 @@ CONSTANT: default-height 20
     rows>> 1 + 10 / ceiling ;
 
 : update-interval ( tetris -- interval )
-    level>> 1 - 60 * 1000 swap - ;
+    level>> 1 - 60 * 1000000 swap - ;
 
 : add-block ( tetris block -- )
-    over board>> spin current-piece tetromino>> colour>> set-block ;
+    over [ board>> ] 2dip current-piece tetromino>> colour>> set-block ;
 
 : game-over? ( tetris -- ? )
     [ board>> ] [ next-piece ] bi piece-valid? not ;
@@ -104,10 +104,10 @@ CONSTANT: default-height 20
     dup { 0 1 } tetris-move [ move-drop ] [ lock-piece ] if ;
 
 : update ( tetris -- )
-    millis over last-update>> -
+    system-micros over last-update>> -
     over update-interval > [
         dup move-down
-        millis >>last-update
+        system-micros >>last-update
     ] when drop ;
 
 : ?update ( tetris -- )
index 0169249e81952ffe15cf1f86394d798c8721a5b4..8326da35842d586c979dc179b37ef472be584dc9 100644 (file)
@@ -26,10 +26,10 @@ IN: tetris.gl
     [ gl-color 2array draw-block ] [ 3drop ] if ;
 
 : draw-row ( y row -- )
-    dup length -rot [ (draw-row) ] 2curry each ;
+    [ length iota swap ] keep [ (draw-row) ] 2curry each ;
 
 : draw-board ( board -- )
-    rows>> dup length swap
+    rows>> [ length iota ] keep
     [ dupd nth draw-row ] curry each ;
 
 : scale-board ( width height board -- )
index 2ebbfc07d68480b1a1e95cc3cf1e4474fdd3a097..0a24b2033c30163ef122242d49d044c10edd4f83 100644 (file)
@@ -37,7 +37,7 @@ TUPLE: piece
 
 : modulo ( n m -- n )
   #! -2 7 mod => -2, -2 7 modulo =>  5
-  tuck mod over + swap mod ;
+  [ mod ] [ + ] [ mod ] tri ;
 
 : (rotate-piece) ( rotation inc n-states -- rotation' )
     [ + ] dip modulo ;
index dbdb666e4a39042aedff5c9276023441a3567b0a..66df0cdb2d7161f82549b5891ec92c045f60abef 100644 (file)
@@ -13,8 +13,9 @@ M: tetris-gadget pref-dim* drop { 200 400 } ;
 
 : update-status ( gadget -- )
     dup tetris>> [
-        "Level: " % dup level>> #
-        " Score: " % score>> #
+        [ "Level: " % level>> # ]
+        [ " Score: " % score>> # ]
+        [ paused?>> [ " (Paused)" % ] when ] tri
     ] "" make swap show-status ;
 
 M: tetris-gadget draw-gadget* ( gadget -- )
@@ -25,17 +26,24 @@ M: tetris-gadget draw-gadget* ( gadget -- )
 : new-tetris ( gadget -- gadget )
     [ <new-tetris> ] change-tetris ;
 
+: unless-paused ( tetris quot -- )
+    over tetris>> paused?>> [
+        2drop
+    ] [
+        call
+    ] if ; inline
+
 tetris-gadget H{
     { T{ button-down f f 1 }     [ request-focus ] }
-    { T{ key-down f f "UP" }     [ tetris>> rotate-right ] }
-    { T{ key-down f f "d" }      [ tetris>> rotate-left ] }
-    { T{ key-down f f "f" }      [ tetris>> rotate-right ] }
-    { T{ key-down f f "e" }      [ tetris>> rotate-left ] } ! dvorak d
-    { T{ key-down f f "u" }      [ tetris>> rotate-right ] } ! dvorak f
-    { T{ key-down f f "LEFT" }   [ tetris>> move-left ] }
-    { T{ key-down f f "RIGHT" }  [ tetris>> move-right ] }
-    { T{ key-down f f "DOWN" }   [ tetris>> move-down ] }
-    { T{ key-down f f " " }      [ tetris>> move-drop ] }
+    { T{ key-down f f "UP" }     [ [ tetris>> rotate-right ] unless-paused ] }
+    { T{ key-down f f "d" }      [ [ tetris>> rotate-left ] unless-paused ] }
+    { T{ key-down f f "f" }      [ [ tetris>> rotate-right ] unless-paused ] }
+    { T{ key-down f f "e" }      [ [ tetris>> rotate-left ] unless-paused ] }
+    { T{ key-down f f "u" }      [ [ tetris>> rotate-right ] unless-paused ] }
+    { T{ key-down f f "LEFT" }   [ [ tetris>> move-left ] unless-paused ] }
+    { T{ key-down f f "RIGHT" }  [ [ tetris>> move-right ] unless-paused ] }
+    { T{ key-down f f "DOWN" }   [ [ tetris>> move-down ] unless-paused ] }
+    { T{ key-down f f " " }      [ [ tetris>> move-drop ] unless-paused ] }
     { T{ key-down f f "p" }      [ tetris>> toggle-pause ] }
     { T{ key-down f f "n" }      [ new-tetris drop ] }
 } set-gestures
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 122e6133874fbdbb0e8bbbad8b21e00043620d74..de160f5598ea3ddbb590489c834e098a0bac4c4f 100644 (file)
@@ -45,7 +45,7 @@ M: TYPE >alist ( db -- alist )
     [ DBKEYS dup ] keep '[ dup _ at 2array ] map! drop ;
 
 M: TYPE set-at ( value key db -- )
-    handle>> spin [ object>bytes dup length ] bi@ DBPUT drop ;
+    handle>> swap rot [ object>bytes dup length ] bi@ DBPUT drop ;
 
 M: TYPE delete-at ( key db -- )
     handle>> swap object>bytes dup length DBOUT drop ;
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 04c7022..4903307
@@ -1,7 +1,7 @@
 ! Copyright (C) 2007 Alex Chapman
 ! See http://factorcode.org/license.txt for BSD license.
 USING: combinators kernel generic math math.functions
-math.parser namespaces io sequences trees
+math.parser namespaces io sequences trees shuffle
 assocs parser accessors math.order prettyprint.custom ;
 IN: trees.avl
 
index c07357fbdf7a5ba91a25fad87c6de7a962478fdb..d858a14795d9c38d4df347ea24cd524c7c54129f 100644 (file)
@@ -5,10 +5,10 @@ sequences random sets make grouping ;
 IN: trees.splay.tests
 
 : randomize-numeric-splay-tree ( splay-tree -- )
-    100 [ drop 100 random swap at drop ] with each ;
+    100 iota [ drop 100 random swap at drop ] with each ;
 
 : make-numeric-splay-tree ( n -- splay-tree )
-    <splay> [ [ conjoin ] curry each ] keep ;
+    iota <splay> [ [ conjoin ] curry each ] keep ;
 
 [ t ] [
     100 make-numeric-splay-tree dup randomize-numeric-splay-tree
old mode 100755 (executable)
new mode 100644 (file)
index 66ef154..67b2f6b
@@ -1,7 +1,7 @@
 ! Copyright (c) 2005 Mackenzie Straight.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: arrays kernel math namespaces sequences assocs parser
-trees generic math.order accessors prettyprint.custom ;
+trees generic math.order accessors prettyprint.custom shuffle ;
 IN: trees.splay
 
 TUPLE: splay < tree ;
old mode 100755 (executable)
new mode 100644 (file)
index 62f4d8f..77e5e5b
@@ -2,7 +2,8 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel generic math sequences arrays io namespaces
 prettyprint.private kernel.private assocs random combinators
-parser math.order accessors deques make prettyprint.custom ;
+parser math.order accessors deques make prettyprint.custom 
+shuffle ;
 IN: trees
 
 TUPLE: tree root count ;
diff --git a/extra/ui/gadgets/alerts/alerts.factor b/extra/ui/gadgets/alerts/alerts.factor
deleted file mode 100644 (file)
index 70943e6..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-USING: accessors models monads macros generalizations kernel
-ui ui.gadgets.controls models.combinators ui.gadgets.layout ui.gadgets
-ui.gadgets.labels ui.gadgets.editors ui.gadgets.buttons
-ui.gadgets.packs locals sequences fonts io.styles
-wrap.strings ;
-
-IN: ui.gadgets.alerts
-:: alert ( quot string -- ) <pile> { 10 10 } >>gap 1 >>align
-   string 22 wrap-lines <label> T{ font { name "sans-serif" } { size 18 } } >>font { 200 100 } >>pref-dim add-gadget 
-   "okay" [ close-window ] quot append <border-button> add-gadget "" open-window ;
-
-: alert* ( str -- ) [ ] swap alert ;
-
-:: ask-user ( string -- model' )
-    [
-        string <label>  T{ font { name "sans-serif" } { size 14 } } >>font dup , :> lbl
-        <model-field*> ->% 1 :> fldm
-        "okay" <model-border-btn> :> btn
-        btn -> [ fldm swap updates ]
-               [ [ drop lbl close-window ] $> , ] bi
-    ] <vbox> { 161 86 } >>pref-dim "" open-window ;
-
-MACRO: ask-buttons ( buttons -- quot ) dup length [
-      [ swap
-         [ 22 wrap-lines <label> T{ font { name "sans-serif" } { size 18 } } >>font ,
-         [ [ <model-border-btn> [ close-window ] >>hook -> ] map ] <hbox> , ] <vbox>
-         "" open-window
-      ] dip firstn
-   ] 2curry ;
diff --git a/extra/ui/gadgets/alerts/authors.txt b/extra/ui/gadgets/alerts/authors.txt
deleted file mode 100644 (file)
index ce0899f..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Sam Anklesaria
\ No newline at end of file
diff --git a/extra/ui/gadgets/alerts/summary.txt b/extra/ui/gadgets/alerts/summary.txt
deleted file mode 100644 (file)
index f1cd420..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Really simple dialog boxes
\ No newline at end of file
diff --git a/extra/ui/gadgets/comboboxes/authors.txt b/extra/ui/gadgets/comboboxes/authors.txt
deleted file mode 100644 (file)
index ce0899f..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Sam Anklesaria
\ No newline at end of file
diff --git a/extra/ui/gadgets/comboboxes/comboboxes.factor b/extra/ui/gadgets/comboboxes/comboboxes.factor
deleted file mode 100644 (file)
index 3eb1180..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-USING: accessors arrays kernel math.rectangles sequences
-ui.gadgets.controls models.combinators ui.gadgets ui.gadgets.glass
-ui.gadgets.labels ui.gestures ;
-QUALIFIED-WITH: ui.gadgets.tables tbl
-IN: ui.gadgets.comboboxes
-
-TUPLE: combo-table < table spawner ;
-
-M: combo-table handle-gesture [ call-next-method drop ] 2keep swap
-   T{ button-up } = [
-      [ spawner>> ]
-      [ tbl:selected-row [ swap set-control-value ] [ 2drop ] if ]
-      [ hide-glass ] tri
-   ] [ drop ] if t ;
-
-TUPLE: combobox < label-control table ;
-combobox H{
-   { T{ button-down } [ dup table>> over >>spawner <zero-rect> show-glass ] }
-} set-gestures
-
-: <combobox> ( options -- combobox ) [ first [ combobox new-label ] keep <basic> >>model ] keep
-    <basic> combo-table new-table [ 1array ] >>quot >>table ;
\ No newline at end of file
diff --git a/extra/ui/gadgets/comboboxes/summary.txt b/extra/ui/gadgets/comboboxes/summary.txt
deleted file mode 100644 (file)
index 0f2ce2b..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Combo boxes have a model choosen from a list of options
\ No newline at end of file
diff --git a/extra/ui/gadgets/controls/authors.txt b/extra/ui/gadgets/controls/authors.txt
deleted file mode 100644 (file)
index 2300f69..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Sam Anklesaria
diff --git a/extra/ui/gadgets/controls/controls-docs.factor b/extra/ui/gadgets/controls/controls-docs.factor
deleted file mode 100644 (file)
index 1df6005..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-USING: accessors help.markup help.syntax ui.gadgets.buttons
-ui.gadgets.editors models ui.gadgets ;
-IN: ui.gadgets.controls
-
-HELP: <model-btn>
-{ $values { "gadget" "the button's label" } { "button" button } }
-{ $description "Creates an button whose signal updates on clicks.  " } ;
-
-HELP: <model-border-btn>
-{ $values { "text" "the button's label" } { "button" button } }
-{ $description "Creates an button whose signal updates on clicks.  " } ;
-
-HELP: <table>
-{ $values { "model" "values the table is to display" } { "table" table } }
-{ $description "Creates an " { $link table } } ;
-
-HELP: <table*>
-{ $values { "table" table } }
-{ $description "Creates an " { $link table } " with no initial values to display" } ;
-
-HELP: <list>
-{ $values { "column-model" "values the table is to display" } { "table" table } }
-{ $description "Creates an " { $link table } " with a val-quot that renders each element as its own row" } ;
-
-HELP: <list*>
-{ $values { "table" table } }
-{ $description "Creates an model-list with no initial values to display" } ;
-
-HELP: indexed
-{ $values { "table" table } }
-{ $description "Sets the output model of an table to the selected-index, rather than the selected-value" } ;
-
-HELP: <model-field>
-{ $values { "model" model } { "gadget" model-field } }
-{ $description "Creates a field with an initial value" } ;
-
-HELP: <model-field*>
-{ $values { "field" model-field } }
-{ $description "Creates a field with an empty initial value" } ;
-
-HELP: <empty-field>
-{ $values { "model" model } { "field" model-field } }
-{ $description "Creates a field with an empty initial value that switches to another signal on its update" } ;
-
-HELP: <model-editor>
-{ $values { "model" model } { "gadget" model-field } }
-{ $description "Creates an editor with an initial value" } ;
-
-HELP: <model-editor*>
-{ $values { "editor" "an editor" } }
-{ $description "Creates a editor with an empty initial value" } ;
-
-HELP: <empty-editor>
-{ $values { "model" model } { "editor" "an editor" } }
-{ $description "Creates a field with an empty initial value that switches to another signal on its update" } ;
-
-HELP: <model-action-field>
-{ $values { "field" action-field } }
-{ $description "Field that updates its model with its contents when the user hits the return key" } ;
-
-HELP: IMG-MODEL-BTN:
-{ $syntax "IMAGE-MODEL-BTN: filename" }
-{ $description "Creates a button using a tiff image named as specified found in the icons subdirectory of the vocabulary path" } ;
-
-HELP: IMG-BTN:
-{ $syntax "[ do-something ] IMAGE-BTN: filename" }
-{ $description "Creates a button using a tiff image named as specified found in the icons subdirectory of the vocabulary path, calling the specified quotation on click" } ;
-
-HELP: output-model
-{ $values { "gadget" gadget } { "model" model } }
-{ $description "Returns the model a gadget uses for output. Often the same as " { $link model>> } } ;
\ No newline at end of file
diff --git a/extra/ui/gadgets/controls/controls.factor b/extra/ui/gadgets/controls/controls.factor
deleted file mode 100644 (file)
index 5de6da8..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-USING: accessors assocs arrays kernel models monads sequences
-models.combinators ui.gadgets ui.gadgets.borders ui.gadgets.buttons
-ui.gadgets.buttons.private ui.gadgets.editors ui.gadgets.editors.private
-words images.loader ui.gadgets.scrollers ui.images vocabs.parser lexer
-models.range ui.gadgets.sliders ;
-QUALIFIED-WITH: ui.gadgets.sliders slider
-QUALIFIED-WITH: ui.gadgets.tables tbl
-EXCLUDE: ui.gadgets.editors => model-field ;
-IN: ui.gadgets.controls
-
-TUPLE: model-btn < button hook value ;
-: <model-btn> ( gadget -- button ) [
-      [ dup hook>> [ call( button -- ) ] [ drop ] if* ]
-      [ [ [ value>> ] [ ] bi or ] keep set-control-value ]
-      [ model>> f swap (>>value) ] tri
-   ] model-btn new-button f <basic> >>model ;
-: <model-border-btn> ( text -- button ) <model-btn> border-button-theme ;
-
-TUPLE: table < tbl:table { quot initial: [ ] } { val-quot initial: [ ] } color-quot column-titles column-alignment actions ;
-M: table tbl:column-titles column-titles>> ;
-M: table tbl:column-alignment column-alignment>> ;
-M: table tbl:row-columns quot>> [ call( a -- b ) ] [ drop f ] if* ;
-M: table tbl:row-value val-quot>> [ call( a -- b ) ]  [ drop f ] if* ;
-M: table tbl:row-color color-quot>> [ call( a -- b ) ]  [ drop f ] if* ;
-
-: new-table ( model class -- table ) f swap tbl:new-table dup >>renderer
-   f <basic> >>actions dup actions>> [ set-model ] curry >>action ;
-: <table> ( model -- table ) table new-table ;
-: <table*> ( -- table ) V{ } clone <model> <table> ;
-: <list> ( column-model -- table ) <table> [ 1array ] >>quot ;
-: <list*> ( -- table ) V{ } clone <model> <list> ;
-: indexed ( table -- table ) f >>val-quot ;
-
-TUPLE: model-field < field model* ;
-: init-field ( model -- model' ) [ [ ] [ "" ] if* ] change-value ;
-: <model-field> ( model -- gadget ) model-field new-field swap init-field >>model* ;
-M: model-field graft*
-    [ [ model*>> value>> ] [ editor>> ] bi set-editor-string ]
-    [ dup editor>> model>> add-connection ]
-    [ dup model*>> add-connection ] tri ;
-M: model-field ungraft*
-   [ dup editor>> model>> remove-connection ]
-   [ dup model*>> remove-connection ] bi ;
-M: model-field model-changed 2dup model*>> =
-    [ [ value>> ] [ editor>> ] bi* set-editor-string ]
-    [ nip [ editor>> editor-string ] [ model*>> ] bi set-model ] if ;
-: (new-field) ( editor field -- gadget ) [ new-editor ] dip new-border dup gadget-child >>editor
-    field-theme { 1 0 } >>align ; inline
-: <model-field*> ( -- field ) "" <model> <model-field> ;
-: <empty-field> ( model -- field ) "" <model> switch-models <model-field> ;
-: <model-editor> ( model -- gadget ) multiline-editor model-field (new-field) swap init-field >>model* ;
-: <model-editor*> ( -- editor ) "" <model> <model-editor> ;
-: <empty-editor> ( model -- editor ) "" <model> switch-models <model-editor> ;
-
-: <model-action-field> ( -- field ) f <action-field> dup [ set-control-value ] curry >>quot
-    f <model> >>model ;
-
-: <slider> ( init page min max step -- slider ) <range> horizontal slider:<slider> ;
-
-: image-prep ( -- image ) scan current-vocab name>> "vocab:" "/icons/" surround ".tiff" surround <image-name> dup cached-image drop ;
-SYNTAX: IMG-MODEL-BTN: image-prep [ <model-btn> ] curry append! ;
-
-SYNTAX: IMG-BTN: image-prep [ swap <button> ] curry append! ;
-
-GENERIC: output-model ( gadget -- model )
-M: gadget output-model model>> ;
-M: table output-model dup val-quot>> [ selection>> ] [ selection-index>> ] if ;
-M: model-field output-model model*>> ;
-M: scroller output-model viewport>> children>> first output-model ;
-M: slider output-model model>> range-model ;
-
-IN: accessors
-M: model-btn text>> children>> first text>> ;
-
-IN: ui.gadgets.controls
-
-SINGLETON: gadget-monad
-INSTANCE: gadget-monad monad
-INSTANCE: gadget monad
-M: gadget monad-of drop gadget-monad ;
-M: gadget-monad return drop <gadget> swap >>model ;
-M: gadget >>= output-model [ swap call( x -- y ) ] curry ; 
diff --git a/extra/ui/gadgets/controls/summary.txt b/extra/ui/gadgets/controls/summary.txt
deleted file mode 100644 (file)
index eeef94d..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Gadgets with expanded model usage
\ No newline at end of file
diff --git a/extra/ui/gadgets/layout/authors.txt b/extra/ui/gadgets/layout/authors.txt
deleted file mode 100644 (file)
index 2300f69..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Sam Anklesaria
diff --git a/extra/ui/gadgets/layout/layout-docs.factor b/extra/ui/gadgets/layout/layout-docs.factor
deleted file mode 100644 (file)
index cd8f62b..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-USING: help.markup help.syntax models ui.gadgets.tracks ;
-IN: ui.gadgets.layout
-
-HELP: ,
-{ $values { "item" "a gadget or model" } }
-{ $description "Used in a series of gadgets created by a box, accumulating the gadget" } ;
-
-HELP: ,%
-{ $syntax "gadget ,% width" }
-{ $description "Like ',' but stretches the gadget to always fill a percent of the parent" } ;
-
-HELP: ->
-{ $values { "uiitem" "a gadget or model" } { "model" model } }
-{ $description "Like ',' but passes its model on for further use." } ;
-
-HELP: ->%
-{ $syntax "gadget ,% width" }
-{ $description "Like '->' but stretches the gadget to always fill a percent of the parent" } ;
-
-HELP: <spacer>
-{ $description "Grows to fill any empty space in a box" } ;
-
-HELP: <hbox>
-{ $values { "gadgets" "a list of gadgets" } { "track" track } }
-{ $syntax "[ gadget , gadget , ... ] <hbox>" }
-{ $description "Creates an horizontal track containing the gadgets listed in the quotation" } ;
-
-HELP: <vbox>
-{ $values { "gadgets" "a list of gadgets" } { "track" track } }
-{ $syntax "[ gadget , gadget , ... ] <hbox>" }
-{ $description "Creates an vertical track containing the gadgets listed in the quotation" } ;
-
-HELP: $
-{ $syntax "$ PLACEHOLDER-NAME $" }
-{ $description "Defines an insertion point in a template named PLACEHOLDER-NAME which can be used by calling its name" } ;
-
-HELP: with-interface
-{ $values { "quot" "quotation that builds a template and inserts into it" } }
-{ $description "Create templates, used with " { $link POSTPONE: $ } } ;
-
-ARTICLE: "ui.gadgets.layout" "GUI Layout"
-"Laying out GUIs works the same way as building lists with " { $vocab-link "make" }
-". Gadgets are layed out using " { $vocab-link "ui.gadgets.tracks" } " through " { $link <hbox> } " and " { $link <vbox> } ", which allow both fixed and percentage widths. "
-{ $link , } " and " { $link -> }  " add a model or gadget to the gadget you're building. "
-"Also, books can be made with " { $link <book> } ". "
-{ $link <spacer> } "s add flexable space between items. " $nl
-"Using " { $link with-interface } ", one can pre-build templates to add items to later: "
-"Like in the StringTemplate framework for java, placeholders are defined using $ PLACERHOLDER-NAME $ "
-"Using PLACEHOLDER-NAME again sets it as the current insertion point. "
-"For examples using normal layout, see the " { $vocab-link "sudokus" } " demo. "
-"For examples of templating, see the " { $vocab-link "recipes" } " demo. " ;
-
-ABOUT: "ui.gadgets.layout"
\ No newline at end of file
diff --git a/extra/ui/gadgets/layout/layout.factor b/extra/ui/gadgets/layout/layout.factor
deleted file mode 100644 (file)
index 7bdde95..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-USING: accessors assocs arrays fry kernel lexer make math.parser
-models monads namespaces parser sequences
-sequences.extras models.combinators ui.gadgets
-ui.gadgets.tracks words ui.gadgets.controls ;
-QUALIFIED: make
-QUALIFIED-WITH: ui.gadgets.books book
-IN: ui.gadgets.layout
-
-SYMBOL: templates
-TUPLE: layout gadget size ; C: <layout> layout
-TUPLE: placeholder < gadget members ;
-: <placeholder> ( -- placeholder ) placeholder new V{ } clone >>members ;
-
-: (remove-members) ( placeholder members -- ) [ [ model? ] filter swap parent>> model>> [ remove-connection ] curry each ]
-    [ nip [ gadget? ] filter [ unparent ] each ] 2bi ;
-
-: remove-members ( placeholder -- ) dup members>> [ drop ] [ [ (remove-members) ] keep delete-all ] if-empty ;
-: add-member ( obj placeholder -- ) over layout? [ [ gadget>> ] dip ] when members>> push ;
-
-: , ( item -- ) make:, ;
-: make* ( quot -- list ) { } make ; inline
-
-! Just take the previous mentioned placeholder and use it
-! If there is no previously mentioned placeholder, we're probably making a box, and will create the placeholder ourselves
-DEFER: with-interface
-: insertion-quot ( quot -- quot' ) make:building get [ [ placeholder? ] find-last nip [ <placeholder> dup , ] unless*
-    templates get spin '[ [ _ templates set _ , @ ] with-interface ] ] when* ;
-
-SYNTAX: ,% scan string>number [ <layout> , ] curry append! ;
-SYNTAX: ->% scan string>number '[ [ _ <layout> , ] [ output-model ] bi ] append! ;
-
-GENERIC: -> ( uiitem -- model )
-M: gadget -> dup , output-model ;
-M: model -> dup , ;
-
-: <spacer> ( -- ) <gadget> 1 <layout> , ;
-
-: add-layout ( track layout -- track ) [ gadget>> ] [ size>> ] bi track-add ;
-: layouts ( sized? gadgets -- layouts ) [ [ gadget? ] [ layout? ] bi or ] filter swap
-   [ [ dup layout? [ f <layout> ] unless ] map ]
-   [ [ dup gadget? [ gadget>> ] unless ] map ] if ;
-: make-layout ( building sized? -- models layouts ) [ swap layouts ] curry
-   [ make* [ [ model? ] filter ] ] dip bi ; inline
-: <box> ( gadgets type -- track )
-   [ t make-layout ] dip <track>
-   swap [ add-layout ] each
-   swap [ <collection> >>model ] unless-empty ; inline
-: <hbox> ( gadgets -- track ) horizontal <box> ; inline
-: <vbox> ( gadgets -- track ) vertical <box> ; inline
-
-: make-book ( models gadgets model -- book ) book:<book> swap [ "No models in books" throw ] unless-empty ;
-: <book> ( quot: ( -- model ) -- book ) f make-layout rot 0 >>value make-book ; inline
-: <book*> ( quot -- book ) f make-layout f make-book ; inline
-
-ERROR: not-in-template word ;
-SYNTAX: $ CREATE-WORD dup
-    [ [ dup templates get at [ nip , ] [ not-in-template ] if* ] curry (( -- )) define-declared "$" expect ]
-    [ [ <placeholder> [ swap templates get set-at ] keep , ] curry ] bi append! ;
-
-: insert-gadget ( number parent gadget -- ) -rot [ but-last insert-nth ] change-children drop ;
-: insert-size ( number parent size -- ) -rot [ but-last insert-nth ] change-sizes drop ;
-: insertion-point ( placeholder -- number parent ) dup parent>> [ children>> index ] keep ;
-
-GENERIC: >layout ( gadget -- layout )
-M: gadget >layout f <layout> ;
-M: layout >layout ;
-
-GENERIC# (add-gadget-at) 2 ( parent item n -- )
-M: gadget (add-gadget-at) -rot [ add-gadget ] keep insert-gadget ;
-M: track (add-gadget-at) -rot >layout [ add-layout ] keep [ gadget>> insert-gadget ] [ size>> insert-size ] 3bi ;
-
-GENERIC# add-gadget-at 1 ( item location -- )
-M: object add-gadget-at insertion-point -rot (add-gadget-at) ;
-M: model add-gadget-at parent>> dup book:book? [ "No models in books" throw ]
-   [ dup model>> dup collection? [ nip swap add-connection ] [ drop [ 1array <collection> ] dip (>>model) ] if ] if ;
-: track-add-at ( item location size -- ) swap [ <layout> ] dip add-gadget-at ;
-: (track-add-at) ( parent item n size -- ) swap [ <layout> ] dip (add-gadget-at) ;
-
-: insert-item ( item location -- ) [ dup get [ drop ] [ remove-members ] if ] [ on ] [ ] tri
-    [ add-member ] 2keep add-gadget-at ;
-
-: insert-items ( makelist -- ) t swap [ dup placeholder? [ nip ] [ over insert-item ] if ] each drop ;
-
-: with-interface ( quot -- ) [ make* ] curry H{ } clone templates rot with-variable [ insert-items ] with-scope ; inline
-
-M: model >>= [ swap insertion-quot <action> ] curry ;
-M: model fmap insertion-quot <mapped> ;
-M: model $> insertion-quot side-effect-model new-mapped-model ;
-M: model <$ insertion-quot quot-model new-mapped-model ;
diff --git a/extra/ui/gadgets/layout/summary.txt b/extra/ui/gadgets/layout/summary.txt
deleted file mode 100644 (file)
index 30b5ef5..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Syntax for easily building GUIs and using templates
\ No newline at end of file
index 8730c0acc48330bd553edc4d7a93b3f2125c7dd1..06f1de6bc8c05d4c2ba0ae7ef21f95ad28f1501e 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2006, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors math.vectors classes.tuple math.rectangles colors
-kernel sequences models opengl math math.order namespaces
+kernel locals sequences models opengl math math.order namespaces
 ui.commands ui.gestures ui.render ui.gadgets ui.gadgets.labels
 ui.gadgets.scrollers ui.gadgets.presentations ui.gadgets.viewports
 ui.gadgets.packs ;
@@ -78,7 +78,7 @@ M: list focusable-child* drop t ;
     dup list-empty? [
         2drop
     ] [
-        tuck control-value length rem >>index
+        [ control-value length rem ] [ (>>index) ] [ ] tri
         [ relayout-1 ] [ scroll>selected ] bi
     ] if ;
 
@@ -95,9 +95,9 @@ M: list focusable-child* drop t ;
         [ index>> ] keep nth-gadget invoke-secondary
     ] if ;
 
-: select-gadget ( gadget list -- )
-    tuck children>> index
-    [ swap select-index ] [ drop ] if* ;
+:: select-gadget ( gadget list -- )
+    gadget list children>> index
+    [ list select-index ] when* ;
 
 : clamp-loc ( point max -- point )
     vmin { 0 0 } vmax ;
diff --git a/extra/ui/gadgets/poppers/authors.txt b/extra/ui/gadgets/poppers/authors.txt
deleted file mode 100644 (file)
index ce0899f..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Sam Anklesaria
\ No newline at end of file
diff --git a/extra/ui/gadgets/poppers/poppers.factor b/extra/ui/gadgets/poppers/poppers.factor
deleted file mode 100644 (file)
index 1c815d5..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-! Copyright (C) 2009 Sam Anklesaria
-! See http://factorcode.org/license.txt for BSD license.
-USING: arrays accessors combinators kernel math
-models models.combinators namespaces sequences
-ui.gadgets ui.gadgets.controls ui.gadgets.layout
-ui.gadgets.tracks ui.gestures ui.gadgets.line-support ;
-EXCLUDE: ui.gadgets.editors => model-field ;
-IN: ui.gadgets.poppers
-
-TUPLE: popped < model-field { fatal? initial: t } ;
-TUPLE: popped-editor < multiline-editor ;
-: <popped> ( text -- gadget ) <basic> init-field popped-editor popped (new-field) swap >>model* ;
-
-: set-expansion ( popped size -- ) over dup parent>> [ children>> index ] [ sizes>> ] bi set-nth relayout ;
-: new-popped ( popped -- ) insertion-point "" <popped>
-    [ rot 1 + f (track-add-at) ] keep [ relayout ] [ request-focus ] bi ;
-: focus-prev ( popped -- ) dup parent>> children>> length 1 =
-    [ drop ] [
-        insertion-point [ 1 - dup -1 = [ drop 1 ] when ] [ children>> ] bi* nth
-        [ request-focus ] [ editor>> end-of-document ] bi
-    ] if ;
-: initial-popped ( popper -- ) "" <popped> [ f track-add drop ] keep request-focus ;
-
-TUPLE: popper < track { unfocus-hook initial: [ drop ] } ;
-! list of strings is model (make shown objects implement sequence protocol)
-: <popper> ( model -- popper ) vertical popper new-track swap >>model ;
-
-M: popped handle-gesture swap {
-    { gain-focus [ 1 set-expansion f ] }
-    { lose-focus [ dup parent>>
-        [ [ unfocus-hook>> call( a -- ) ] curry [ f set-expansion ] bi ]
-        [ drop ] if* f
-    ] }
-    { T{ key-up f f "RET" } [ dup editor>> delete-previous-character new-popped f ] }
-    { T{ key-up f f "BACKSPACE" } [ dup editor>> editor-string "" =
-        [ dup fatal?>> [ [ focus-prev ] [ unparent ] bi ] [ t >>fatal? drop ] if ]
-        [ f >>fatal? drop ] if f
-    ] }
-    [ swap call-next-method ]
-} case ;
-
-M: popper handle-gesture swap T{ button-down f f 1 } =
-    [ hand-click# get 2 = [ initial-popped ] [ drop ] if ] [ drop ] if f ;
-
-M: popper model-changed
-    [ children>> [ unparent ] each ]
-    [ [ value>> [ <popped> ] map ] dip [ f track-add ] reduce request-focus ] bi ;
-
-M: popped pref-dim* editor>> [ pref-dim* first ] [ line-height ] bi 2array ;
-M: popper focusable-child* children>> [ t ] [ first ] if-empty ;
\ No newline at end of file
index 0f116f0d51fe6c52c9e411d38ff9923d7ee9aebf..eb0e1c1d5c5fde0f8a8b3e50a96c4c3b09e69605 100644 (file)
@@ -7,7 +7,6 @@ M: null-world begin-world drop ;
 M: null-world end-world drop ;
 M: null-world draw-world* drop ;
 M: null-world resize-world drop ;
-M: null-world pref-dim* drop { 512 512 } ;
 
 : null-window ( title -- world )
     <world-attributes>
@@ -19,6 +18,7 @@ M: null-world pref-dim* drop { 512 512 } ;
             backing-store
             T{ depth-bits f 24 }
         } >>pixel-format-attributes
+        { 512 512 } >>pref-dim
     f swap open-window* ;
 
 : into-window ( world quot -- world )
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 96497b8..5d0fa1c
@@ -10,7 +10,7 @@ IN: units.tests
 [ t ] [ 5 m 1 m d- 4 m = ] unit-test
 [ t ] [ 5 m 2 m d* 10 m^2 = ] unit-test
 [ t ] [ 5 m 2 m d/ 5/2 { } { } <dimensioned> = ] unit-test
-[ t ] [ 5 m 2 m tuck d/ drop 2 m = ] unit-test
+[ t ] [ 2 m 5 m 2 m d/ drop 2 m = ] unit-test
 
 [ 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
old mode 100755 (executable)
new mode 100644 (file)
index b8e3f45..a293d79
@@ -28,9 +28,9 @@ M: dimensions-not-equal summary drop "Dimensions do not match" ;
     dimensioned boa ;
 
 : >dimensioned< ( d -- n top bot )
-    [ value>> ] [ top>> ] [ bot>> ] tri ;
+    [ bot>> ] [ top>> ] [ value>> ] tri ;
 
-\ <dimensioned> [ >dimensioned< ] define-inverse
+\ <dimensioned> [ [ dimensioned boa ] undo ] define-inverse
 
 : dimensions ( dimensioned -- top bot )
     [ top>> ] [ bot>> ] bi ;
@@ -65,7 +65,7 @@ M: dimensions-not-equal summary drop "Dimensions do not match" ;
 : d-sq ( d -- d ) dup d* ;
 
 : d-recip ( d -- d' )
-    >dimensioned< spin recip dimension-op> ;
+    >dimensioned< recip dimension-op> ;
 
 : d/ ( d d -- d ) d-recip d* ;
 
index 0ee2a114dd7b486702f1bb3d08a7f3bafc868a1f..29f710061c4b02ecfad9120d63f4a0fa83aa7baa 100644 (file)
@@ -48,7 +48,7 @@ MEMO: cities-named ( name -- cities )
 
 MEMO: cities-named-in ( name state -- cities )
     cities [
-        tuck [ name>> = ] [ state>> = ] 2bi* and
+        [ name>> = ] [ state>> = ] bi-curry bi* and
     ] with with filter ;
 
 : find-zip-code ( code -- city )
diff --git a/extra/vocabs/git/authors.txt b/extra/vocabs/git/authors.txt
new file mode 100644 (file)
index 0000000..f13c9c1
--- /dev/null
@@ -0,0 +1 @@
+Joe Groff
diff --git a/extra/vocabs/git/git.factor b/extra/vocabs/git/git.factor
new file mode 100644 (file)
index 0000000..eb945b5
--- /dev/null
@@ -0,0 +1,28 @@
+! (c)2009 Joe Groff bsd license
+USING: fry io io.directories io.encodings.ascii
+io.encodings.utf8 io.launcher io.pathnames kernel lexer
+namespaces parser sequences splitting vocabs vocabs.loader ;
+IN: vocabs.git
+
+<PRIVATE
+: git-object-id ( filename rev -- id/f )
+    [ [ parent-directory ] [ file-name ] bi ] dip swap '[
+        { "git" "ls-tree" } _ suffix _ suffix ascii [
+            readln
+            [ " " split1 nip " " split1 nip "\t" split1 drop ]
+            [ f ] if*
+        ] with-process-reader
+    ] with-directory ;
+
+: with-git-object-stream ( id quot -- )
+    [ { "git" "cat-file" "-p" } swap suffix utf8 ] dip with-process-reader ; inline
+PRIVATE>
+
+ERROR: git-revision-not-found path ;
+
+: use-vocab-rev ( vocab-name rev -- )
+    [ create-vocab vocab-source-path dup ] dip git-object-id 
+    [ [ input-stream get swap parse-stream call( -- ) ] with-git-object-stream ]
+    [ git-revision-not-found ] if* ;
+
+SYNTAX: USE-REV: scan scan use-vocab-rev ;
old mode 100755 (executable)
new mode 100644 (file)
index 637ffa6dd81f700b664f1be56d608199393df214..42f15d28731cbe8fd0c9d707d4add87dffd910b0 100644 (file)
@@ -83,10 +83,6 @@ CONSTANT: cpus
     [ validate-os/cpu ] >>init
     [ current-builder last-report>> "text/html" <content> ] >>display ;
 
-: git-link ( id -- link )
-    [ "http://github.com/slavapestov/factor/commit/" prepend ] keep
-    [XML <a href=<->><-></a> XML] ;
-
 : building ( builder string -- xml )
     swap current-git-id>> git-link
     [XML <-> for <-> XML] ;
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
diff --git a/extra/zoneinfo/africa b/extra/zoneinfo/africa
new file mode 100644 (file)
index 0000000..0a6185d
--- /dev/null
@@ -0,0 +1,915 @@
+# @(#)africa   8.18
+# <pre>
+
+# This data is by no means authoritative; if you think you know better,
+# go ahead and edit the file (and please send any changes to
+# tz@elsie.nci.nih.gov for general use in the future).
+
+# From Paul Eggert (2006-03-22):
+#
+# A good source for time zone historical data outside the U.S. is
+# Thomas G. Shanks and Rique Pottenger, The International Atlas (6th edition),
+# San Diego: ACS Publications, Inc. (2003).
+#
+# Gwillim Law writes that a good source
+# for recent time zone data is the International Air Transport
+# Association's Standard Schedules Information Manual (IATA SSIM),
+# published semiannually.  Law sent in several helpful summaries
+# of the IATA's data after 1990.
+#
+# Except where otherwise noted, Shanks & Pottenger is the source for
+# entries through 1990, and IATA SSIM is the source for entries afterwards.
+#
+# Another source occasionally used is Edward W. Whitman, World Time Differences,
+# Whitman Publishing Co, 2 Niagara Av, Ealing, London (undated), which
+# I found in the UCLA library.
+#
+# A reliable and entertaining source about time zones is
+# Derek Howse, Greenwich time and longitude, Philip Wilson Publishers (1997).
+#
+# Previous editions of this database used WAT, CAT, SAT, and EAT
+# for +0:00 through +3:00, respectively,
+# but Mark R V Murray reports that
+# `SAST' is the official abbreviation for +2:00 in the country of South Africa,
+# `CAT' is commonly used for +2:00 in countries north of South Africa, and
+# `WAT' is probably the best name for +1:00, as the common phrase for
+# the area that includes Nigeria is ``West Africa''.
+# He has heard of ``Western Sahara Time'' for +0:00 but can find no reference.
+#
+# To make things confusing, `WAT' seems to have been used for -1:00 long ago;
+# I'd guess that this was because people needed _some_ name for -1:00,
+# and at the time, far west Africa was the only major land area in -1:00.
+# This usage is now obsolete, as the last use of -1:00 on the African
+# mainland seems to have been 1976 in Western Sahara.
+#
+# To summarize, the following abbreviations seem to have some currency:
+#      -1:00   WAT     West Africa Time (no longer used)
+#       0:00   GMT     Greenwich Mean Time
+#       2:00   CAT     Central Africa Time
+#       2:00   SAST    South Africa Standard Time
+# and Murray suggests the following abbreviation:
+#       1:00   WAT     West Africa Time
+# I realize that this leads to `WAT' being used for both -1:00 and 1:00
+# for times before 1976, but this is the best I can think of
+# until we get more information.
+#
+# I invented the following abbreviations; corrections are welcome!
+#       2:00   WAST    West Africa Summer Time
+#       2:30   BEAT    British East Africa Time (no longer used)
+#       2:44:45 BEAUT  British East Africa Unified Time (no longer used)
+#       3:00   CAST    Central Africa Summer Time (no longer used)
+#       3:00   SAST    South Africa Summer Time (no longer used)
+#       3:00   EAT     East Africa Time
+#       4:00   EAST    East Africa Summer Time (no longer used)
+
+# Algeria
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Algeria 1916    only    -       Jun     14      23:00s  1:00    S
+Rule   Algeria 1916    1919    -       Oct     Sun>=1  23:00s  0       -
+Rule   Algeria 1917    only    -       Mar     24      23:00s  1:00    S
+Rule   Algeria 1918    only    -       Mar      9      23:00s  1:00    S
+Rule   Algeria 1919    only    -       Mar      1      23:00s  1:00    S
+Rule   Algeria 1920    only    -       Feb     14      23:00s  1:00    S
+Rule   Algeria 1920    only    -       Oct     23      23:00s  0       -
+Rule   Algeria 1921    only    -       Mar     14      23:00s  1:00    S
+Rule   Algeria 1921    only    -       Jun     21      23:00s  0       -
+Rule   Algeria 1939    only    -       Sep     11      23:00s  1:00    S
+Rule   Algeria 1939    only    -       Nov     19       1:00   0       -
+Rule   Algeria 1944    1945    -       Apr     Mon>=1   2:00   1:00    S
+Rule   Algeria 1944    only    -       Oct      8       2:00   0       -
+Rule   Algeria 1945    only    -       Sep     16       1:00   0       -
+Rule   Algeria 1971    only    -       Apr     25      23:00s  1:00    S
+Rule   Algeria 1971    only    -       Sep     26      23:00s  0       -
+Rule   Algeria 1977    only    -       May      6       0:00   1:00    S
+Rule   Algeria 1977    only    -       Oct     21       0:00   0       -
+Rule   Algeria 1978    only    -       Mar     24       1:00   1:00    S
+Rule   Algeria 1978    only    -       Sep     22       3:00   0       -
+Rule   Algeria 1980    only    -       Apr     25       0:00   1:00    S
+Rule   Algeria 1980    only    -       Oct     31       2:00   0       -
+# Shanks & Pottenger give 0:09:20 for Paris Mean Time; go with Howse's
+# more precise 0:09:21.
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Africa/Algiers  0:12:12 -       LMT     1891 Mar 15 0:01
+                       0:09:21 -       PMT     1911 Mar 11    # Paris Mean Time
+                       0:00    Algeria WE%sT   1940 Feb 25 2:00
+                       1:00    Algeria CE%sT   1946 Oct  7
+                       0:00    -       WET     1956 Jan 29
+                       1:00    -       CET     1963 Apr 14
+                       0:00    Algeria WE%sT   1977 Oct 21
+                       1:00    Algeria CE%sT   1979 Oct 26
+                       0:00    Algeria WE%sT   1981 May
+                       1:00    -       CET
+
+# Angola
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Africa/Luanda   0:52:56 -       LMT     1892
+                       0:52:04 -       AOT     1911 May 26 # Angola Time
+                       1:00    -       WAT
+
+# Benin
+# Whitman says they switched to 1:00 in 1946, not 1934;
+# go with Shanks & Pottenger.
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone Africa/Porto-Novo 0:10:28 -       LMT     1912
+                       0:00    -       GMT     1934 Feb 26
+                       1:00    -       WAT
+
+# Botswana
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Africa/Gaborone 1:43:40 -       LMT     1885
+                       2:00    -       CAT     1943 Sep 19 2:00
+                       2:00    1:00    CAST    1944 Mar 19 2:00
+                       2:00    -       CAT
+
+# Burkina Faso
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone Africa/Ouagadougou        -0:06:04 -      LMT     1912
+                        0:00   -       GMT
+
+# Burundi
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone Africa/Bujumbura  1:57:28 -       LMT     1890
+                       2:00    -       CAT
+
+# Cameroon
+# Whitman says they switched to 1:00 in 1920; go with Shanks & Pottenger.
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Africa/Douala   0:38:48 -       LMT     1912
+                       1:00    -       WAT
+
+# Cape Verde
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone Atlantic/Cape_Verde -1:34:04 -    LMT     1907                    # Praia
+                       -2:00   -       CVT     1942 Sep
+                       -2:00   1:00    CVST    1945 Oct 15
+                       -2:00   -       CVT     1975 Nov 25 2:00
+                       -1:00   -       CVT
+
+# Central African Republic
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Africa/Bangui   1:14:20 -       LMT     1912
+                       1:00    -       WAT
+
+# Chad
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Africa/Ndjamena 1:00:12 -       LMT     1912
+                       1:00    -       WAT     1979 Oct 14
+                       1:00    1:00    WAST    1980 Mar  8
+                       1:00    -       WAT
+
+# Comoros
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Indian/Comoro   2:53:04 -       LMT     1911 Jul   # Moroni, Gran Comoro
+                       3:00    -       EAT
+
+# Democratic Republic of Congo
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone Africa/Kinshasa   1:01:12 -       LMT     1897 Nov 9
+                       1:00    -       WAT
+Zone Africa/Lubumbashi 1:49:52 -       LMT     1897 Nov 9
+                       2:00    -       CAT
+
+# Republic of the Congo
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone Africa/Brazzaville        1:01:08 -       LMT     1912
+                       1:00    -       WAT
+
+# Cote D'Ivoire
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Africa/Abidjan  -0:16:08 -      LMT     1912
+                        0:00   -       GMT
+
+# Djibouti
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Africa/Djibouti 2:52:36 -       LMT     1911 Jul
+                       3:00    -       EAT
+
+###############################################################################
+
+# Egypt
+
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Egypt   1940    only    -       Jul     15      0:00    1:00    S
+Rule   Egypt   1940    only    -       Oct      1      0:00    0       -
+Rule   Egypt   1941    only    -       Apr     15      0:00    1:00    S
+Rule   Egypt   1941    only    -       Sep     16      0:00    0       -
+Rule   Egypt   1942    1944    -       Apr      1      0:00    1:00    S
+Rule   Egypt   1942    only    -       Oct     27      0:00    0       -
+Rule   Egypt   1943    1945    -       Nov      1      0:00    0       -
+Rule   Egypt   1945    only    -       Apr     16      0:00    1:00    S
+Rule   Egypt   1957    only    -       May     10      0:00    1:00    S
+Rule   Egypt   1957    1958    -       Oct      1      0:00    0       -
+Rule   Egypt   1958    only    -       May      1      0:00    1:00    S
+Rule   Egypt   1959    1981    -       May      1      1:00    1:00    S
+Rule   Egypt   1959    1965    -       Sep     30      3:00    0       -
+Rule   Egypt   1966    1994    -       Oct      1      3:00    0       -
+Rule   Egypt   1982    only    -       Jul     25      1:00    1:00    S
+Rule   Egypt   1983    only    -       Jul     12      1:00    1:00    S
+Rule   Egypt   1984    1988    -       May      1      1:00    1:00    S
+Rule   Egypt   1989    only    -       May      6      1:00    1:00    S
+Rule   Egypt   1990    1994    -       May      1      1:00    1:00    S
+# IATA (after 1990) says transitions are at 0:00.
+# Go with IATA starting in 1995, except correct 1995 entry from 09-30 to 09-29.
+Rule   Egypt   1995    max     -       Apr     lastFri  0:00s  1:00    S
+Rule   Egypt   1995    2005    -       Sep     lastThu 23:00s  0       -
+# From Steffen Thorsen (2006-09-19):
+# The Egyptian Gazette, issue 41,090 (2006-09-18), page 1, reports:
+# Egypt will turn back clocks by one hour at the midnight of Thursday
+# after observing the daylight saving time since May.
+# http://news.gom.com.eg/gazette/pdf/2006/09/18/01.pdf
+Rule   Egypt   2006    only    -       Sep     21      23:00s  0       -
+# From Dirk Losch (2007-08-14):
+# I received a mail from an airline which says that the daylight
+# saving time in Egypt will end in the night of 2007-09-06 to 2007-09-07.
+# From Jesper Norgaard Welen (2007-08-15): [The following agree:]
+# http://www.nentjes.info/Bill/bill5.htm 
+# http://www.timeanddate.com/worldclock/city.html?n=53
+# From Steffen Thorsen (2007-09-04): The official information...:
+# http://www.sis.gov.eg/En/EgyptOnline/Miscellaneous/000002/0207000000000000001580.htm
+Rule   Egypt   2007    only    -       Sep     Thu>=1  23:00s  0       -
+# From Abdelrahman Hassan (2007-09-06):
+# Due to the Hijri (lunar Islamic calendar) year being 11 days shorter
+# than the year of the Gregorian calendar, Ramadan shifts earlier each
+# year. This year it will be observed September 13 (September is quite
+# hot in Egypt), and the idea is to make fasting easier for workers by
+# shifting business hours one hour out of daytime heat. Consequently,
+# unless discontinued, next DST may end Thursday 28 August 2008.
+# From Paul Eggert (2007-08-17):
+# For lack of better info, assume the new rule is last Thursday in August.
+Rule   Egypt   2008    max     -       Aug     lastThu 23:00s  0       -
+
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Africa/Cairo    2:05:00 -       LMT     1900 Oct
+                       2:00    Egypt   EE%sT
+
+# Equatorial Guinea
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Africa/Malabo   0:35:08 -       LMT     1912
+                       0:00    -       GMT     1963 Dec 15
+                       1:00    -       WAT
+
+# Eritrea
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Africa/Asmara   2:35:32 -       LMT     1870
+                       2:35:32 -       AMT     1890          # Asmara Mean Time
+                       2:35:20 -       ADMT    1936 May 5    # Adis Dera MT
+                       3:00    -       EAT
+
+# Ethiopia
+# From Paul Eggert (2006-03-22):
+# Shanks & Pottenger write that Ethiopia had six narrowly-spaced time zones
+# between 1870 and 1890, and that they merged to 38E50 (2:35:20) in 1890.
+# We'll guess that 38E50 is for Adis Dera.
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone Africa/Addis_Ababa        2:34:48 -       LMT     1870
+                       2:35:20 -       ADMT    1936 May 5    # Adis Dera MT
+                       3:00    -       EAT
+
+# Gabon
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone Africa/Libreville 0:37:48 -       LMT     1912
+                       1:00    -       WAT
+
+# Gambia
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Africa/Banjul   -1:06:36 -      LMT     1912
+                       -1:06:36 -      BMT     1935    # Banjul Mean Time
+                       -1:00   -       WAT     1964
+                        0:00   -       GMT
+
+# Ghana
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+# Whitman says DST was observed from 1931 to ``the present'';
+# go with Shanks & Pottenger.
+Rule   Ghana   1936    1942    -       Sep      1      0:00    0:20    GHST
+Rule   Ghana   1936    1942    -       Dec     31      0:00    0       GMT
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Africa/Accra    -0:00:52 -      LMT     1918
+                        0:00   Ghana   %s
+
+# Guinea
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Africa/Conakry  -0:54:52 -      LMT     1912
+                        0:00   -       GMT     1934 Feb 26
+                       -1:00   -       WAT     1960
+                        0:00   -       GMT
+
+# Guinea-Bissau
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Africa/Bissau   -1:02:20 -      LMT     1911 May 26
+                       -1:00   -       WAT     1975
+                        0:00   -       GMT
+
+# Kenya
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Africa/Nairobi  2:27:16 -       LMT     1928 Jul
+                       3:00    -       EAT     1930
+                       2:30    -       BEAT    1940
+                       2:44:45 -       BEAUT   1960
+                       3:00    -       EAT
+
+# Lesotho
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Africa/Maseru   1:50:00 -       LMT     1903 Mar
+                       2:00    -       SAST    1943 Sep 19 2:00
+                       2:00    1:00    SAST    1944 Mar 19 2:00
+                       2:00    -       SAST
+
+# Liberia
+# From Paul Eggert (2006-03-22):
+# In 1972 Liberia was the last country to switch
+# from a UTC offset that was not a multiple of 15 or 20 minutes.
+# Howse reports that it was in honor of their president's birthday.
+# Shank & Pottenger report the date as May 1, whereas Howse reports Jan;
+# go with Shanks & Pottenger.
+# For Liberia before 1972, Shanks & Pottenger report -0:44, whereas Howse and
+# Whitman each report -0:44:30; go with the more precise figure.
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Africa/Monrovia -0:43:08 -      LMT     1882
+                       -0:43:08 -      MMT     1919 Mar # Monrovia Mean Time
+                       -0:44:30 -      LRT     1972 May # Liberia Time
+                        0:00   -       GMT
+
+###############################################################################
+
+# Libya
+
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Libya   1951    only    -       Oct     14      2:00    1:00    S
+Rule   Libya   1952    only    -       Jan      1      0:00    0       -
+Rule   Libya   1953    only    -       Oct      9      2:00    1:00    S
+Rule   Libya   1954    only    -       Jan      1      0:00    0       -
+Rule   Libya   1955    only    -       Sep     30      0:00    1:00    S
+Rule   Libya   1956    only    -       Jan      1      0:00    0       -
+Rule   Libya   1982    1984    -       Apr      1      0:00    1:00    S
+Rule   Libya   1982    1985    -       Oct      1      0:00    0       -
+Rule   Libya   1985    only    -       Apr      6      0:00    1:00    S
+Rule   Libya   1986    only    -       Apr      4      0:00    1:00    S
+Rule   Libya   1986    only    -       Oct      3      0:00    0       -
+Rule   Libya   1987    1989    -       Apr      1      0:00    1:00    S
+Rule   Libya   1987    1989    -       Oct      1      0:00    0       -
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Africa/Tripoli  0:52:44 -       LMT     1920
+                       1:00    Libya   CE%sT   1959
+                       2:00    -       EET     1982
+                       1:00    Libya   CE%sT   1990 May  4
+# The following entries are from Shanks & Pottenger;
+# the IATA SSIM data contain some obvious errors.
+                       2:00    -       EET     1996 Sep 30
+                       1:00    -       CET     1997 Apr  4
+                       1:00    1:00    CEST    1997 Oct  4
+                       2:00    -       EET
+
+# Madagascar
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone Indian/Antananarivo 3:10:04 -     LMT     1911 Jul
+                       3:00    -       EAT     1954 Feb 27 23:00s
+                       3:00    1:00    EAST    1954 May 29 23:00s
+                       3:00    -       EAT
+
+# Malawi
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Africa/Blantyre 2:20:00 -       LMT     1903 Mar
+                       2:00    -       CAT
+
+# Mali
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Africa/Bamako   -0:32:00 -      LMT     1912
+                        0:00   -       GMT     1934 Feb 26
+                       -1:00   -       WAT     1960 Jun 20
+                        0:00   -       GMT
+
+# Mauritania
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone Africa/Nouakchott -1:03:48 -      LMT     1912
+                        0:00   -       GMT     1934 Feb 26
+                       -1:00   -       WAT     1960 Nov 28
+                        0:00   -       GMT
+
+# Mauritius
+
+# From Steffen Thorsen (2008-06-25):
+# Mauritius plans to observe DST from 2008-11-01 to 2009-03-31 on a trial
+# basis....
+# It seems that Mauritius observed daylight saving time from 1982-10-10 to 
+# 1983-03-20 as well, but that was not successful....
+# http://www.timeanddate.com/news/time/mauritius-daylight-saving-time.html
+
+# From Alex Krivenyshev (2008-06-25):
+# http://economicdevelopment.gov.mu/portal/site/Mainhomepage/menuitem.a42b24128104d9845dabddd154508a0c/?content_id=0a7cee8b5d69a110VgnVCM1000000a04a8c0RCRD
+
+# From Arthur David Olson (2008-06-30):
+# The www.timeanddate.com article cited by Steffen Thorsen notes that "A
+# final decision has yet to be made on the times that daylight saving
+# would begin and end on these dates." As a place holder, use midnight.
+
+# From Paul Eggert (2008-06-30):
+# Follow Thorsen on DST in 1982/1983, instead of Shanks & Pottenger.
+
+# From Steffen Thorsen (2008-07-10):
+# According to
+# <a href="http://www.lexpress.mu/display_article.php?news_id=111216">
+# http://www.lexpress.mu/display_article.php?news_id=111216
+# </a>
+# (in French), Mauritius will start and end their DST a few days earlier
+# than previously announced (2008-11-01 to 2009-03-31).  The new start
+# date is 2008-10-26 at 02:00 and the new end date is 2009-03-27 (no time
+# given, but it is probably at either 2 or 3 wall clock time).
+# 
+# A little strange though, since the article says that they moved the date 
+# to align itself with Europe and USA which also change time on that date, 
+# but that means they have not paid attention to what happened in 
+# USA/Canada last year (DST ends first Sunday in November). I also wonder 
+# why that they end on a Friday, instead of aligning with Europe which 
+# changes two days later.
+
+# From Alex Krivenyshev (2008-07-11):
+# Seems that English language article "The revival of daylight saving
+# time:  Energy conservation?"-# No. 16578 (07/11/2008) was originally
+# published on Monday, June 30, 2008...
+#
+# I guess that article in French "Le gouvernement avance l'introduction
+# de l'heure d'ete" stating that DST in Mauritius starting on October 26
+# and ending on March 27, 2009 is the most recent one.
+# ...
+# <a href="http://www.worldtimezone.com/dst_news/dst_news_mauritius02.html">
+# http://www.worldtimezone.com/dst_news/dst_news_mauritius02.html
+# </a>
+
+# From Riad M. Hossen Ally (2008-08-03):
+# The Government of Mauritius weblink
+# <a href="http://www.gov.mu/portal/site/pmosite/menuitem.4ca0efdee47462e7440a600248a521ca/?content_id=3D4728ca68b2a5b110VgnVCM1000000a04a8c0RCRD">
+# http://www.gov.mu/portal/site/pmosite/menuitem.4ca0efdee47462e7440a600248a521ca/?content_id=3D4728ca68b2a5b110VgnVCM1000000a04a8c0RCRD
+# </a>
+# Cabinet Decision of July 18th, 2008 states as follows:
+#
+# 4. ...Cabinet has agreed to the introduction into the National Assembly
+# of the Time Bill which provides for the introduction of summer time in
+# Mauritius. The summer time period which will be of one hour ahead of
+# the standard time, will be aligned with that in Europe and the United
+# States of America. It will start at two o'clock in the morning on the
+# last Sunday of October and will end at two o'clock in the morning on
+# the last Sunday of March the following year. The summer time for the
+# year 2008 - 2009 will, therefore, be effective as from 26 October 2008
+# and end on 29 March 2009.
+
+# From Ed Maste (2008-10-07):
+# THE TIME BILL (No. XXVII of 2008) Explanatory Memorandum states the
+# beginning / ending of summer time is 2 o'clock standard time in the
+# morning of the last Sunday of October / last Sunday of March.
+# <a href="http://www.gov.mu/portal/goc/assemblysite/file/bill2708.pdf">
+# http://www.gov.mu/portal/goc/assemblysite/file/bill2708.pdf
+# </a>
+
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule Mauritius 1982    only    -       Oct     10      0:00    1:00    S
+Rule Mauritius 1983    only    -       Mar     21      0:00    0       -
+Rule Mauritius 2008    max     -       Oct     lastSun 2:00s   1:00    S
+Rule Mauritius 2009    max     -       Mar     lastSun 2:00s   0       -
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone Indian/Mauritius  3:50:00 -       LMT     1907            # Port Louis
+                       4:00 Mauritius  MU%sT   # Mauritius Time
+# Agalega Is, Rodriguez
+# no information; probably like Indian/Mauritius
+
+# Mayotte
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Indian/Mayotte  3:00:56 -       LMT     1911 Jul        # Mamoutzou
+                       3:00    -       EAT
+
+# Morocco
+# See the `europe' file for Spanish Morocco (Africa/Ceuta).
+
+# From Alex Krivenyshev (2008-05-09):
+# Here is an article that Morocco plan to introduce Daylight Saving Time between
+# 1 June, 2008 and 27 September, 2008.
+#
+# "... Morocco is to save energy by adjusting its clock during summer so it will
+# be one hour ahead of GMT between 1 June and 27 September, according to
+# Communication Minister and Gov ernment Spokesman, Khalid Naciri...."
+#
+# <a href="http://www.worldtimezone.net/dst_news/dst_news_morocco01.html">
+# http://www.worldtimezone.net/dst_news/dst_news_morocco01.html
+# </a>
+# OR
+# <a href="http://en.afrik.com/news11892.html">
+# http://en.afrik.com/news11892.html
+# </a>
+
+# From Alex Krivenyshev (2008-05-09):
+# The Morocco time change can be confirmed on Morocco web site Maghreb Arabe Presse:
+# <a href="http://www.map.ma/eng/sections/box3/morocco_shifts_to_da/view">
+# http://www.map.ma/eng/sections/box3/morocco_shifts_to_da/view
+# </a>
+#
+# Morocco shifts to daylight time on June 1st through September 27, Govt.
+# spokesman.
+
+# From Patrice Scattolin (2008-05-09):
+# According to this article:
+# <a href="http://www.avmaroc.com/actualite/heure-dete-comment-a127896.html">
+# http://www.avmaroc.com/actualite/heure-dete-comment-a127896.html
+# </a>
+# (and republished here:
+# <a href="http://www.actu.ma/heure-dete-comment_i127896_0.html">
+# http://www.actu.ma/heure-dete-comment_i127896_0.html
+# </a>
+# )
+# the changes occurs at midnight:
+#
+# saturday night may 31st at midnight (which in french is to be
+# intrepreted as the night between saturday and sunday)
+# sunday night the 28th  at midnight
+#
+# Seeing that the 28th is monday, I am guessing that she intends to say
+# the midnight of the 28th which is the midnight between sunday and
+# monday, which jives with other sources that say that it's inclusive
+# june1st to sept 27th.
+#
+# The decision was taken by decree *2-08-224 *but I can't find the decree
+# published on the web.
+#
+# It's also confirmed here:
+# <a href="http://www.maroc.ma/NR/exeres/FACF141F-D910-44B0-B7FA-6E03733425D1.htm">
+# http://www.maroc.ma/NR/exeres/FACF141F-D910-44B0-B7FA-6E03733425D1.htm
+# </a>
+# on a government portal as being  between june 1st and sept 27th (not yet
+# posted in english).
+#
+# The following google query will generate many relevant hits:
+# <a href="http://www.google.com/search?hl=en&q=Conseil+de+gouvernement+maroc+heure+avance&btnG=Search">
+# http://www.google.com/search?hl=en&q=Conseil+de+gouvernement+maroc+heure+avance&btnG=Search
+# </a>
+
+# From Alex Krivenyshev (2008-05-09):
+# Is Western Sahara (part which administrated by Morocco) going to follow
+# Morocco DST changes?  Any information?  What about other part of
+# Western Sahara - under administration of POLISARIO Front (also named
+# SADR Saharawi Arab Democratic Republic)?
+
+# From Arthur David Olson (2008-05-09):
+# XXX--guess that it is only Morocco for now; guess only 2008 for now.
+
+# From Steffen Thorsen (2008-08-27):
+# Morocco will change the clocks back on the midnight between August 31 
+# and September 1. They originally planned to observe DST to near the end 
+# of September:
+#
+# One article about it (in French):
+# <a href="http://www.menara.ma/fr/Actualites/Maroc/Societe/ci.retour_a_l_heure_gmt_a_partir_du_dimanche_31_aout_a_minuit_officiel_.default">
+# http://www.menara.ma/fr/Actualites/Maroc/Societe/ci.retour_a_l_heure_gmt_a_partir_du_dimanche_31_aout_a_minuit_officiel_.default
+# </a>
+#
+# We have some further details posted here:
+# <a href="http://www.timeanddate.com/news/time/morocco-ends-dst-early-2008.html">
+# http://www.timeanddate.com/news/time/morocco-ends-dst-early-2008.html
+# </a>
+
+# From Steffen Thorsen (2009-03-17):
+# Morocco will observe DST from 2009-06-01 00:00 to 2009-08-21 00:00 according
+# to many sources, such as
+# <a href="http://news.marweb.com/morocco/entertainment/morocco-daylight-saving.html">
+# http://news.marweb.com/morocco/entertainment/morocco-daylight-saving.html
+# </a>
+# <a href="http://www.medi1sat.ma/fr/depeche.aspx?idp=2312">
+# http://www.medi1sat.ma/fr/depeche.aspx?idp=2312
+# </a>
+# (French)
+#
+# Our summary:
+# <a href="http://www.timeanddate.com/news/time/morocco-starts-dst-2009.html">
+# http://www.timeanddate.com/news/time/morocco-starts-dst-2009.html
+# </a>
+
+# From Alexander Krivenyshev (2009-03-17):
+# Here is a link to official document from Royaume du Maroc Premier Ministre,
+# Ministere de la Modernisation des Secteurs Publics
+#
+# Under Article 1 of Royal Decree No. 455-67 of Act 23 safar 1387 (2 june 1967)
+# concerning the amendment of the legal time, the Ministry of Modernization of
+# Public Sectors announced that the official time in the Kingdom will be
+# advanced 60 minutes from Sunday 31 May 2009 at midnight.
+#
+# <a href="http://www.mmsp.gov.ma/francais/Actualites_fr/PDF_Actualites_Fr/HeureEte_FR.pdf">
+# http://www.mmsp.gov.ma/francais/Actualites_fr/PDF_Actualites_Fr/HeureEte_FR.pdf
+# </a>
+#
+# <a href="http://www.worldtimezone.com/dst_news/dst_news_morocco03.html">
+# http://www.worldtimezone.com/dst_news/dst_news_morocco03.html
+# </a>
+
+# RULE NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+
+Rule   Morocco 1939    only    -       Sep     12       0:00   1:00    S
+Rule   Morocco 1939    only    -       Nov     19       0:00   0       -
+Rule   Morocco 1940    only    -       Feb     25       0:00   1:00    S
+Rule   Morocco 1945    only    -       Nov     18       0:00   0       -
+Rule   Morocco 1950    only    -       Jun     11       0:00   1:00    S
+Rule   Morocco 1950    only    -       Oct     29       0:00   0       -
+Rule   Morocco 1967    only    -       Jun      3      12:00   1:00    S
+Rule   Morocco 1967    only    -       Oct      1       0:00   0       -
+Rule   Morocco 1974    only    -       Jun     24       0:00   1:00    S
+Rule   Morocco 1974    only    -       Sep      1       0:00   0       -
+Rule   Morocco 1976    1977    -       May      1       0:00   1:00    S
+Rule   Morocco 1976    only    -       Aug      1       0:00   0       -
+Rule   Morocco 1977    only    -       Sep     28       0:00   0       -
+Rule   Morocco 1978    only    -       Jun      1       0:00   1:00    S
+Rule   Morocco 1978    only    -       Aug      4       0:00   0       -
+Rule   Morocco 2008    only    -       Jun      1       0:00   1:00    S
+Rule   Morocco 2008    only    -       Sep      1       0:00   0       -
+Rule   Morocco 2009    only    -       Jun      1       0:00   1:00    S
+Rule   Morocco 2009    only    -       Aug      21      0:00   0       -
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone Africa/Casablanca -0:30:20 -      LMT     1913 Oct 26
+                        0:00   Morocco WE%sT   1984 Mar 16
+                        1:00   -       CET     1986
+                        0:00   Morocco WE%sT
+# Western Sahara
+Zone Africa/El_Aaiun   -0:52:48 -      LMT     1934 Jan
+                       -1:00   -       WAT     1976 Apr 14
+                        0:00   -       WET
+
+# Mozambique
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Africa/Maputo   2:10:20 -       LMT     1903 Mar
+                       2:00    -       CAT
+
+# Namibia
+# The 1994-04-03 transition is from Shanks & Pottenger.
+# Shanks & Pottenger report no DST after 1998-04; go with IATA.
+
+# From Petronella Sibeene (2007-03-30) in
+# <http://allafrica.com/stories/200703300178.html>:
+# While the entire country changes its time, Katima Mulilo and other
+# settlements in Caprivi unofficially will not because the sun there
+# rises and sets earlier compared to other regions.  Chief of
+# Forecasting Riaan van Zyl explained that the far eastern parts of
+# the country are close to 40 minutes earlier in sunrise than the rest
+# of the country.
+# 
+# From Paul Eggert (2007-03-31):
+# Apparently the Caprivi Strip informally observes Botswana time, but
+# we have no details.  In the meantime people there can use Africa/Gaborone.
+
+# RULE NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Namibia 1994    max     -       Sep     Sun>=1  2:00    1:00    S
+Rule   Namibia 1995    max     -       Apr     Sun>=1  2:00    0       -
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Africa/Windhoek 1:08:24 -       LMT     1892 Feb 8
+                       1:30    -       SWAT    1903 Mar        # SW Africa Time
+                       2:00    -       SAST    1942 Sep 20 2:00
+                       2:00    1:00    SAST    1943 Mar 21 2:00
+                       2:00    -       SAST    1990 Mar 21 # independence
+                       2:00    -       CAT     1994 Apr  3
+                       1:00    Namibia WA%sT
+
+# Niger
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Africa/Niamey    0:08:28 -      LMT     1912
+                       -1:00   -       WAT     1934 Feb 26
+                        0:00   -       GMT     1960
+                        1:00   -       WAT
+
+# Nigeria
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Africa/Lagos    0:13:36 -       LMT     1919 Sep
+                       1:00    -       WAT
+
+# Reunion
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Indian/Reunion  3:41:52 -       LMT     1911 Jun        # Saint-Denis
+                       4:00    -       RET     # Reunion Time
+#
+# Scattered Islands (Iles Eparses) administered from Reunion are as follows.
+# The following information about them is taken from
+# Iles Eparses (www.outre-mer.gouv.fr/domtom/ile.htm, 1997-07-22, in French;
+# no longer available as of 1999-08-17).
+# We have no info about their time zone histories.
+#
+# Bassas da India - uninhabited
+# Europa Island - inhabited from 1905 to 1910 by two families
+# Glorioso Is - inhabited until at least 1958
+# Juan de Nova - uninhabited
+# Tromelin - inhabited until at least 1958
+
+# Rwanda
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Africa/Kigali   2:00:16 -       LMT     1935 Jun
+                       2:00    -       CAT
+
+# St Helena
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone Atlantic/St_Helena        -0:22:48 -      LMT     1890            # Jamestown
+                       -0:22:48 -      JMT     1951    # Jamestown Mean Time
+                        0:00   -       GMT
+# The other parts of the St Helena territory are similar:
+#      Tristan da Cunha: on GMT, say Whitman and the CIA
+#      Ascension: on GMT, says usno1995 and the CIA
+#      Gough (scientific station since 1955; sealers wintered previously):
+#              on GMT, says the CIA
+#      Inaccessible, Nightingale: no information, but probably GMT
+
+# Sao Tome and Principe
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Africa/Sao_Tome  0:26:56 -      LMT     1884
+                       -0:36:32 -      LMT     1912    # Lisbon Mean Time
+                        0:00   -       GMT
+
+# Senegal
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Africa/Dakar    -1:09:44 -      LMT     1912
+                       -1:00   -       WAT     1941 Jun
+                        0:00   -       GMT
+
+# Seychelles
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Indian/Mahe     3:41:48 -       LMT     1906 Jun        # Victoria
+                       4:00    -       SCT     # Seychelles Time
+# From Paul Eggert (2001-05-30):
+# Aldabra, Farquhar, and Desroches, originally dependencies of the
+# Seychelles, were transferred to the British Indian Ocean Territory
+# in 1965 and returned to Seychelles control in 1976.  We don't know
+# whether this affected their time zone, so omit this for now.
+# Possibly the islands were uninhabited.
+
+# Sierra Leone
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+# Whitman gives Mar 31 - Aug 31 for 1931 on; go with Shanks & Pottenger.
+Rule   SL      1935    1942    -       Jun      1      0:00    0:40    SLST
+Rule   SL      1935    1942    -       Oct      1      0:00    0       WAT
+Rule   SL      1957    1962    -       Jun      1      0:00    1:00    SLST
+Rule   SL      1957    1962    -       Sep      1      0:00    0       GMT
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Africa/Freetown -0:53:00 -      LMT     1882
+                       -0:53:00 -      FMT     1913 Jun # Freetown Mean Time
+                       -1:00   SL      %s      1957
+                        0:00   SL      %s
+
+# Somalia
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone Africa/Mogadishu  3:01:28 -       LMT     1893 Nov
+                       3:00    -       EAT     1931
+                       2:30    -       BEAT    1957
+                       3:00    -       EAT
+
+# South Africa
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   SA      1942    1943    -       Sep     Sun>=15 2:00    1:00    -
+Rule   SA      1943    1944    -       Mar     Sun>=15 2:00    0       -
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone Africa/Johannesburg 1:52:00 -     LMT     1892 Feb 8
+                       1:30    -       SAST    1903 Mar
+                       2:00    SA      SAST
+# Marion and Prince Edward Is
+# scientific station since 1947
+# no information
+
+# Sudan
+#
+# From <a href="http://www.sunanews.net/sn13jane.html">
+# Sudan News Agency (2000-01-13)
+# </a>, also reported by Michael De Beukelaer-Dossche via Steffen Thorsen:
+# Clocks will be moved ahead for 60 minutes all over the Sudan as of noon
+# Saturday....  This was announced Thursday by Caretaker State Minister for
+# Manpower Abdul-Rahman Nur-Eddin.
+#
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Sudan   1970    only    -       May      1      0:00    1:00    S
+Rule   Sudan   1970    1985    -       Oct     15      0:00    0       -
+Rule   Sudan   1971    only    -       Apr     30      0:00    1:00    S
+Rule   Sudan   1972    1985    -       Apr     lastSun 0:00    1:00    S
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Africa/Khartoum 2:10:08 -       LMT     1931
+                       2:00    Sudan   CA%sT   2000 Jan 15 12:00
+                       3:00    -       EAT
+
+# Swaziland
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Africa/Mbabane  2:04:24 -       LMT     1903 Mar
+                       2:00    -       SAST
+
+# Tanzania
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone Africa/Dar_es_Salaam 2:37:08 -    LMT     1931
+                       3:00    -       EAT     1948
+                       2:44:45 -       BEAUT   1961
+                       3:00    -       EAT
+
+# Togo
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Africa/Lome     0:04:52 -       LMT     1893
+                       0:00    -       GMT
+
+# Tunisia
+
+# From Gwillim Law (2005-04-30):
+# My correspondent, Risto Nykanen, has alerted me to another adoption of DST,
+# this time in Tunisia.  According to Yahoo France News
+# <http://fr.news.yahoo.com/050426/5/4dumk.html>, in a story attributed to AP
+# and dated 2005-04-26, "Tunisia has decided to advance its official time by
+# one hour, starting on Sunday, May 1.  Henceforth, Tunisian time will be
+# UTC+2 instead of UTC+1.  The change will take place at 23:00 UTC next
+# Saturday."  (My translation)
+#
+# From Oscar van Vlijmen (2005-05-02):
+# LaPresse, the first national daily newspaper ...
+# <http://www.lapresse.tn/archives/archives280405/actualites/lheure.html>
+# ... DST for 2005: on: Sun May 1 0h standard time, off: Fri Sept. 30,
+# 1h standard time.
+#
+# From Atef Loukil (2006-03-28):
+# The daylight saving time will be the same each year:
+# Beginning      : the last Sunday of March at 02:00
+# Ending         : the last Sunday of October at 03:00 ...
+# http://www.tap.info.tn/en/index.php?option=com_content&task=view&id=1188&Itemid=50
+
+# From Steffen Thorsen (2009-03-16):
+# According to several news sources, Tunisia will not observe DST this year.
+# (Arabic)
+# <a href="http://www.elbashayer.com/?page=viewn&nid=42546">
+# http://www.elbashayer.com/?page=viewn&nid=42546
+# </a>
+# <a href="http://www.babnet.net/kiwidetail-15295.asp">
+# http://www.babnet.net/kiwidetail-15295.asp
+# </a>
+#
+# We have also confirmed this with the US embassy in Tunisia.
+# We have a wrap-up about this on the following page:
+# <a href="http://www.timeanddate.com/news/time/tunisia-cancels-dst-2009.html">
+# http://www.timeanddate.com/news/time/tunisia-cancels-dst-2009.html
+# </a>
+
+# From Alexander Krivenyshev (2009-03-17):
+# Here is a link to Tunis Afrique Presse News Agency
+#
+# Standard time to be kept the whole year long (tap.info.tn):
+#
+# (in English)
+# <a href="http://www.tap.info.tn/en/index.php?option=com_content&task=view&id=26813&Itemid=157">
+# http://www.tap.info.tn/en/index.php?option=com_content&task=view&id=26813&Itemid=157
+# </a>
+#
+# (in Arabic)
+# <a href="http://www.tap.info.tn/ar/index.php?option=com_content&task=view&id=61240&Itemid=1">
+# http://www.tap.info.tn/ar/index.php?option=com_content&task=view&id=61240&Itemid=1
+# </a>
+
+# From Arthur David Olson (2009--3-18):
+# The Tunis Afrique Presse News Agency notice contains this: "This measure is due to the fact
+# that the fasting month of ramadan coincides with the period concerned by summer time.
+# Therefore, the standard time will be kept unchanged the whole year long."
+# So foregoing DST seems to be an exception (albeit one that may be repeated in the  future).
+
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Tunisia 1939    only    -       Apr     15      23:00s  1:00    S
+Rule   Tunisia 1939    only    -       Nov     18      23:00s  0       -
+Rule   Tunisia 1940    only    -       Feb     25      23:00s  1:00    S
+Rule   Tunisia 1941    only    -       Oct      6       0:00   0       -
+Rule   Tunisia 1942    only    -       Mar      9       0:00   1:00    S
+Rule   Tunisia 1942    only    -       Nov      2       3:00   0       -
+Rule   Tunisia 1943    only    -       Mar     29       2:00   1:00    S
+Rule   Tunisia 1943    only    -       Apr     17       2:00   0       -
+Rule   Tunisia 1943    only    -       Apr     25       2:00   1:00    S
+Rule   Tunisia 1943    only    -       Oct      4       2:00   0       -
+Rule   Tunisia 1944    1945    -       Apr     Mon>=1   2:00   1:00    S
+Rule   Tunisia 1944    only    -       Oct      8       0:00   0       -
+Rule   Tunisia 1945    only    -       Sep     16       0:00   0       -
+Rule   Tunisia 1977    only    -       Apr     30       0:00s  1:00    S
+Rule   Tunisia 1977    only    -       Sep     24       0:00s  0       -
+Rule   Tunisia 1978    only    -       May      1       0:00s  1:00    S
+Rule   Tunisia 1978    only    -       Oct      1       0:00s  0       -
+Rule   Tunisia 1988    only    -       Jun      1       0:00s  1:00    S
+Rule   Tunisia 1988    1990    -       Sep     lastSun  0:00s  0       -
+Rule   Tunisia 1989    only    -       Mar     26       0:00s  1:00    S
+Rule   Tunisia 1990    only    -       May      1       0:00s  1:00    S
+Rule   Tunisia 2005    only    -       May      1       0:00s  1:00    S
+Rule   Tunisia 2005    only    -       Sep     30       1:00s  0       -
+Rule   Tunisia 2006    2008    -       Mar     lastSun  2:00s  1:00    S
+Rule   Tunisia 2006    2008    -       Oct     lastSun  2:00s  0       -
+Rule   Tunisia 2010    max     -       Mar     lastSun  2:00s  1:00    S
+Rule   Tunisia 2010    max     -       Oct     lastSun  2:00s  0       -
+# Shanks & Pottenger give 0:09:20 for Paris Mean Time; go with Howse's
+# more precise 0:09:21.
+# Shanks & Pottenger say the 1911 switch was on Mar 9; go with Howse's Mar 11.
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Africa/Tunis    0:40:44 -       LMT     1881 May 12
+                       0:09:21 -       PMT     1911 Mar 11    # Paris Mean Time
+                       1:00    Tunisia CE%sT
+
+# Uganda
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Africa/Kampala  2:09:40 -       LMT     1928 Jul
+                       3:00    -       EAT     1930
+                       2:30    -       BEAT    1948
+                       2:44:45 -       BEAUT   1957
+                       3:00    -       EAT
+
+# Zambia
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Africa/Lusaka   1:53:08 -       LMT     1903 Mar
+                       2:00    -       CAT
+
+# Zimbabwe
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Africa/Harare   2:04:12 -       LMT     1903 Mar
+                       2:00    -       CAT
diff --git a/extra/zoneinfo/antarctica b/extra/zoneinfo/antarctica
new file mode 100644 (file)
index 0000000..ef279cb
--- /dev/null
@@ -0,0 +1,327 @@
+# @(#)antarctica       8.4
+# <pre>
+
+# From Paul Eggert (1999-11-15):
+# To keep things manageable, we list only locations occupied year-round; see
+# <a href="http://www.comnap.aq/comnap/comnap.nsf/P/Stations/">
+# COMNAP - Stations and Bases
+# </a>
+# and
+# <a href="http://www.spri.cam.ac.uk/bob/periant.htm">
+# Summary of the Peri-Antarctic Islands (1998-07-23)
+# </a>
+# for information.
+# Unless otherwise specified, we have no time zone information.
+#
+# Except for the French entries,
+# I made up all time zone abbreviations mentioned here; corrections welcome!
+# FORMAT is `zzz' and GMTOFF is 0 for locations while uninhabited.
+
+# These rules are stolen from the `europe' file.
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   RussAQ  1981    1984    -       Apr      1       0:00   1:00    S
+Rule   RussAQ  1981    1983    -       Oct      1       0:00   0       -
+Rule   RussAQ  1984    1991    -       Sep     lastSun  2:00s  0       -
+Rule   RussAQ  1985    1991    -       Mar     lastSun  2:00s  1:00    S
+Rule   RussAQ  1992    only    -       Mar     lastSat  23:00  1:00    S
+Rule   RussAQ  1992    only    -       Sep     lastSat  23:00  0       -
+Rule   RussAQ  1993    max     -       Mar     lastSun  2:00s  1:00    S
+Rule   RussAQ  1993    1995    -       Sep     lastSun  2:00s  0       -
+Rule   RussAQ  1996    max     -       Oct     lastSun  2:00s  0       -
+
+# These rules are stolen from the `southamerica' file.
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   ArgAQ   1964    1966    -       Mar      1      0:00    0       -
+Rule   ArgAQ   1964    1966    -       Oct     15      0:00    1:00    S
+Rule   ArgAQ   1967    only    -       Apr      2      0:00    0       -
+Rule   ArgAQ   1967    1968    -       Oct     Sun>=1  0:00    1:00    S
+Rule   ArgAQ   1968    1969    -       Apr     Sun>=1  0:00    0       -
+Rule   ArgAQ   1974    only    -       Jan     23      0:00    1:00    S
+Rule   ArgAQ   1974    only    -       May      1      0:00    0       -
+Rule   ChileAQ 1972    1986    -       Mar     Sun>=9  3:00u   0       -
+Rule   ChileAQ 1974    1987    -       Oct     Sun>=9  4:00u   1:00    S
+Rule   ChileAQ 1987    only    -       Apr     12      3:00u   0       -
+Rule   ChileAQ 1988    1989    -       Mar     Sun>=9  3:00u   0       -
+Rule   ChileAQ 1988    only    -       Oct     Sun>=1  4:00u   1:00    S
+Rule   ChileAQ 1989    only    -       Oct     Sun>=9  4:00u   1:00    S
+Rule   ChileAQ 1990    only    -       Mar     18      3:00u   0       -
+Rule   ChileAQ 1990    only    -       Sep     16      4:00u   1:00    S
+Rule   ChileAQ 1991    1996    -       Mar     Sun>=9  3:00u   0       -
+Rule   ChileAQ 1991    1997    -       Oct     Sun>=9  4:00u   1:00    S
+Rule   ChileAQ 1997    only    -       Mar     30      3:00u   0       -
+Rule   ChileAQ 1998    only    -       Mar     Sun>=9  3:00u   0       -
+Rule   ChileAQ 1998    only    -       Sep     27      4:00u   1:00    S
+Rule   ChileAQ 1999    only    -       Apr      4      3:00u   0       -
+Rule   ChileAQ 1999    max     -       Oct     Sun>=9  4:00u   1:00    S
+Rule   ChileAQ 2000    max     -       Mar     Sun>=9  3:00u   0       -
+
+
+# Argentina - year-round bases
+# Belgrano II, Confin Coast, -770227-0343737, since 1972-02-05
+# Esperanza, San Martin Land, -6323-05659, since 1952-12-17
+# Jubany, Potter Peninsula, King George Island, -6414-0602320, since 1982-01
+# Marambio, Seymour I, -6414-05637, since 1969-10-29
+# Orcadas, Laurie I, -6016-04444, since 1904-02-22
+# San Martin, Debenham I, -6807-06708, since 1951-03-21
+#      (except 1960-03 / 1976-03-21)
+
+# Australia - territories
+# Heard Island, McDonald Islands (uninhabited)
+#      previously sealers and scientific personnel wintered
+#      <a href="http://web.archive.org/web/20021204222245/http://www.dstc.qut.edu.au/DST/marg/daylight.html">
+#      Margaret Turner reports
+#      </a> (1999-09-30) that they're UTC+5, with no DST;
+#      presumably this is when they have visitors.
+#
+# year-round bases
+# Casey, Bailey Peninsula, -6617+11032, since 1969
+# Davis, Vestfold Hills, -6835+07759, since 1957-01-13
+#      (except 1964-11 - 1969-02)
+# Mawson, Holme Bay, -6736+06253, since 1954-02-13
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone Antarctica/Casey  0       -       zzz     1969
+                       8:00    -       WST     # Western (Aus) Standard Time
+Zone Antarctica/Davis  0       -       zzz     1957 Jan 13
+                       7:00    -       DAVT    1964 Nov # Davis Time
+                       0       -       zzz     1969 Feb
+                       7:00    -       DAVT
+Zone Antarctica/Mawson 0       -       zzz     1954 Feb 13
+                       6:00    -       MAWT    # Mawson Time
+# References:
+# <a href="http://www.antdiv.gov.au/aad/exop/sfo/casey/casey_aws.html">
+# Casey Weather (1998-02-26)
+# </a>
+# <a href="http://www.antdiv.gov.au/aad/exop/sfo/davis/video.html">
+# Davis Station, Antarctica (1998-02-26)
+# </a>
+# <a href="http://www.antdiv.gov.au/aad/exop/sfo/mawson/video.html">
+# Mawson Station, Antarctica (1998-02-25)
+# </a>
+
+# Brazil - year-round base
+# Comandante Ferraz, King George Island, -6205+05824, since 1983/4
+
+# Chile - year-round bases and towns
+# Escudero, South Shetland Is, -621157-0585735, since 1994
+# Presidente Eduadro Frei, King George Island, -6214-05848, since 1969-03-07
+# General Bernardo O'Higgins, Antarctic Peninsula, -6319-05704, since 1948-02
+# Capitan Arturo Prat, -6230-05941
+# Villa Las Estrellas (a town), around the Frei base, since 1984-04-09
+# These locations have always used Santiago time; use TZ='America/Santiago'.
+
+# China - year-round bases
+# Great Wall, King George Island, -6213-05858, since 1985-02-20
+# Zhongshan, Larsemann Hills, Prydz Bay, -6922+07623, since 1989-02-26
+
+# France - year-round bases
+#
+# From Antoine Leca (1997-01-20):
+# Time data are from Nicole Pailleau at the IFRTP
+# (French Institute for Polar Research and Technology).
+# She confirms that French Southern Territories and Terre Adelie bases
+# don't observe daylight saving time, even if Terre Adelie supplies came
+# from Tasmania.
+#
+# French Southern Territories with year-round inhabitants
+#
+# Martin-de-Vivies Base, Amsterdam Island, -374105+0773155, since 1950
+# Alfred-Faure Base, Crozet Islands, -462551+0515152, since 1964
+# Port-aux-Francais, Kerguelen Islands, -492110+0701303, since 1951;
+#      whaling & sealing station operated 1908/1914, 1920/1929, and 1951/1956
+#
+# St Paul Island - near Amsterdam, uninhabited
+#      fishing stations operated variously 1819/1931
+#
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone Indian/Kerguelen  0       -       zzz     1950    # Port-aux-Francais
+                       5:00    -       TFT     # ISO code TF Time
+#
+# year-round base in the main continent
+# Dumont-d'Urville, Ile des Petrels, -6640+14001, since 1956-11
+#
+# Another base at Port-Martin, 50km east, began operation in 1947.
+# It was destroyed by fire on 1952-01-14.
+#
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone Antarctica/DumontDUrville 0 -     zzz     1947
+                       10:00   -       PMT     1952 Jan 14 # Port-Martin Time
+                       0       -       zzz     1956 Nov
+                       10:00   -       DDUT    # Dumont-d'Urville Time
+# Reference:
+# <a href="http://en.wikipedia.org/wiki/Dumont_d'Urville_Station">
+# Dumont d'Urville Station (2005-12-05)
+# </a>
+
+# Germany - year-round base
+# Georg von Neumayer, -7039-00815
+
+# India - year-round base
+# Dakshin Gangotri, -7005+01200
+
+# Japan - year-round bases
+# Dome Fuji, -7719+03942
+# Syowa, -690022+0393524
+#
+# From Hideyuki Suzuki (1999-02-06):
+# In all Japanese stations, +0300 is used as the standard time.
+#
+# Syowa station, which is the first antarctic station of Japan,
+# was established on 1957-01-29.  Since Syowa station is still the main
+# station of Japan, it's appropriate for the principal location.
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone Antarctica/Syowa  0       -       zzz     1957 Jan 29
+                       3:00    -       SYOT    # Syowa Time
+# See:
+# <a href="http://www.nipr.ac.jp/english/ara01.html">
+# NIPR Antarctic Research Activities (1999-08-17)
+# </a>
+
+# S Korea - year-round base
+# King Sejong, King George Island, -6213-05847, since 1988
+
+# New Zealand - claims
+# Balleny Islands (never inhabited)
+# Scott Island (never inhabited)
+#
+# year-round base
+# Scott, Ross Island, since 1957-01, is like Antarctica/McMurdo.
+#
+# These rules for New Zealand are stolen from the `australasia' file.
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   NZAQ    1974    only    -       Nov      3      2:00s   1:00    D
+Rule   NZAQ    1975    1988    -       Oct     lastSun 2:00s   1:00    D
+Rule   NZAQ    1989    only    -       Oct      8      2:00s   1:00    D
+Rule   NZAQ    1990    2006    -       Oct     Sun>=1  2:00s   1:00    D
+Rule   NZAQ    1975    only    -       Feb     23      2:00s   0       S
+Rule   NZAQ    1976    1989    -       Mar     Sun>=1  2:00s   0       S
+Rule   NZAQ    1990    2007    -       Mar     Sun>=15 2:00s   0       S
+Rule   NZAQ    2007    max     -       Sep     lastSun 2:00s   1:00    D
+Rule   NZAQ    2008    max     -       Apr     Sun>=1  2:00s   0       S
+
+# Norway - territories
+# Bouvet (never inhabited)
+#
+# claims
+# Peter I Island (never inhabited)
+
+# Poland - year-round base
+# Arctowski, King George Island, -620945-0582745, since 1977
+
+# Russia - year-round bases
+# Bellingshausen, King George Island, -621159-0585337, since 1968-02-22
+# Mirny, Davis coast, -6633+09301, since 1956-02
+# Molodezhnaya, Alasheyev Bay, -6740+04551,
+#      year-round from 1962-02 to 1999-07-01
+# Novolazarevskaya, Queen Maud Land, -7046+01150,
+#      year-round from 1960/61 to 1992
+
+# Vostok, since 1957-12-16, temporarily closed 1994-02/1994-11
+# <a href="http://quest.arc.nasa.gov/antarctica/QA/computers/Directions,Time,ZIP">
+# From Craig Mundell (1994-12-15)</a>:
+# Vostok, which is one of the Russian stations, is set on the same
+# time as Moscow, Russia.
+#
+# From Lee Hotz (2001-03-08):
+# I queried the folks at Columbia who spent the summer at Vostok and this is
+# what they had to say about time there:
+# ``in the US Camp (East Camp) we have been on New Zealand (McMurdo)
+# time, which is 12 hours ahead of GMT. The Russian Station Vostok was
+# 6 hours behind that (although only 2 miles away, i.e. 6 hours ahead
+# of GMT). This is a time zone I think two hours east of Moscow. The
+# natural time zone is in between the two: 8 hours ahead of GMT.''
+#
+# From Paul Eggert (2001-05-04):
+# This seems to be hopelessly confusing, so I asked Lee Hotz about it
+# in person.  He said that some Antartic locations set their local
+# time so that noon is the warmest part of the day, and that this
+# changes during the year and does not necessarily correspond to mean
+# solar noon.  So the Vostok time might have been whatever the clocks
+# happened to be during their visit.  So we still don't really know what time
+# it is at Vostok.  But we'll guess UTC+6.
+#
+Zone Antarctica/Vostok 0       -       zzz     1957 Dec 16
+                       6:00    -       VOST    # Vostok time
+
+# S Africa - year-round bases
+# Marion Island, -4653+03752
+# Sanae, -7141-00250
+
+# UK
+#
+# British Antarctic Territories (BAT) claims
+# South Orkney Islands
+#      scientific station from 1903
+#      whaling station at Signy I 1920/1926
+# South Shetland Islands
+#
+# year-round bases
+# Bird Island, South Georgia, -5400-03803, since 1983
+# Deception Island, -6259-06034, whaling station 1912/1931,
+#      scientific station 1943/1967,
+#      previously sealers and a scientific expedition wintered by accident,
+#      and a garrison was deployed briefly
+# Halley, Coates Land, -7535-02604, since 1956-01-06
+#      Halley is on a moving ice shelf and is periodically relocated
+#      so that it is never more than 10km from its nominal location.
+# Rothera, Adelaide Island, -6734-6808, since 1976-12-01
+#
+# From Paul Eggert (2002-10-22)
+# <http://webexhibits.org/daylightsaving/g.html> says Rothera is -03 all year.
+#
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone Antarctica/Rothera        0       -       zzz     1976 Dec  1
+                       -3:00   -       ROTT    # Rothera time
+
+# Uruguay - year round base
+# Artigas, King George Island, -621104-0585107
+
+# USA - year-round bases
+#
+# Palmer, Anvers Island, since 1965 (moved 2 miles in 1968)
+#
+# From Ethan Dicks (1996-10-06):
+# It keeps the same time as Punta Arenas, Chile, because, just like us
+# and the South Pole, that's the other end of their supply line....
+# I verified with someone who was there that since 1980,
+# Palmer has followed Chile.  Prior to that, before the Falklands War,
+# Palmer used to be supplied from Argentina.
+#
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone Antarctica/Palmer 0       -       zzz     1965
+                       -4:00   ArgAQ   AR%sT   1969 Oct 5
+                       -3:00   ArgAQ   AR%sT   1982 May
+                       -4:00   ChileAQ CL%sT
+#
+#
+# McMurdo, Ross Island, since 1955-12
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone Antarctica/McMurdo        0       -       zzz     1956
+                       12:00   NZAQ    NZ%sT
+#
+# Amundsen-Scott, South Pole, continuously occupied since 1956-11-20
+#
+# From Paul Eggert (1996-09-03):
+# Normally it wouldn't have a separate entry, since it's like the
+# larger Antarctica/McMurdo since 1970, but it's too famous to omit.
+#
+# From Chris Carrier (1996-06-27):
+# Siple, the first commander of the South Pole station,
+# stated that he would have liked to have kept GMT at the station,
+# but that he found it more convenient to keep GMT+12
+# as supplies for the station were coming from McMurdo Sound,
+# which was on GMT+12 because New Zealand was on GMT+12 all year
+# at that time (1957).  (Source: Siple's book 90 degrees SOUTH.)
+#
+# From Susan Smith
+# http://www.cybertours.com/whs/pole10.html
+# (1995-11-13 16:24:56 +1300, no longer available):
+# We use the same time as McMurdo does.
+# And they use the same time as Christchurch, NZ does....
+# One last quirk about South Pole time.
+# All the electric clocks are usually wrong.
+# Something about the generators running at 60.1hertz or something
+# makes all of the clocks run fast.  So every couple of days,
+# we have to go around and set them back 5 minutes or so.
+# Maybe if we let them run fast all of the time, we'd get to leave here sooner!!
+#
+Link   Antarctica/McMurdo      Antarctica/South_Pole
diff --git a/extra/zoneinfo/asia b/extra/zoneinfo/asia
new file mode 100644 (file)
index 0000000..2c3dc38
--- /dev/null
@@ -0,0 +1,2152 @@
+# @(#)asia     8.30
+# <pre>
+
+# This data is by no means authoritative; if you think you know better,
+# go ahead and edit the file (and please send any changes to
+# tz@elsie.nci.nih.gov for general use in the future).
+
+# From Paul Eggert (2006-03-22):
+#
+# A good source for time zone historical data outside the U.S. is
+# Thomas G. Shanks and Rique Pottenger, The International Atlas (6th edition),
+# San Diego: ACS Publications, Inc. (2003).
+#
+# Gwillim Law writes that a good source
+# for recent time zone data is the International Air Transport
+# Association's Standard Schedules Information Manual (IATA SSIM),
+# published semiannually.  Law sent in several helpful summaries
+# of the IATA's data after 1990.
+#
+# Except where otherwise noted, Shanks & Pottenger is the source for
+# entries through 1990, and IATA SSIM is the source for entries afterwards.
+#
+# Another source occasionally used is Edward W. Whitman, World Time Differences,
+# Whitman Publishing Co, 2 Niagara Av, Ealing, London (undated), which
+# I found in the UCLA library.
+#
+# A reliable and entertaining source about time zones is
+# Derek Howse, Greenwich time and longitude, Philip Wilson Publishers (1997).
+#
+# I invented the abbreviations marked `*' in the following table;
+# the rest are from earlier versions of this file, or from other sources.
+# Corrections are welcome!
+#           std  dst
+#           LMT        Local Mean Time
+#      2:00 EET  EEST  Eastern European Time
+#      2:00 IST  IDT   Israel
+#      3:00 AST  ADT   Arabia*
+#      3:30 IRST IRDT  Iran
+#      4:00 GST        Gulf*
+#      5:30 IST        India
+#      7:00 ICT        Indochina*
+#      7:00 WIT        west Indonesia
+#      8:00 CIT        central Indonesia
+#      8:00 CST        China
+#      9:00 CJT        Central Japanese Time (1896/1937)*
+#      9:00 EIT        east Indonesia
+#      9:00 JST  JDT   Japan
+#      9:00 KST  KDT   Korea
+#      9:30 CST        (Australian) Central Standard Time
+#
+# See the `europe' file for Russia and Turkey in Asia.
+
+# From Guy Harris:
+# Incorporates data for Singapore from Robert Elz' asia 1.1, as well as
+# additional information from Tom Yap, Sun Microsystems Intercontinental
+# Technical Support (including a page from the Official Airline Guide -
+# Worldwide Edition).  The names for time zones are guesses.
+
+###############################################################################
+
+# These rules are stolen from the `europe' file.
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   EUAsia  1981    max     -       Mar     lastSun  1:00u  1:00    S
+Rule   EUAsia  1979    1995    -       Sep     lastSun  1:00u  0       -
+Rule   EUAsia  1996    max     -       Oct     lastSun  1:00u  0       -
+Rule E-EurAsia 1981    max     -       Mar     lastSun  0:00   1:00    S
+Rule E-EurAsia 1979    1995    -       Sep     lastSun  0:00   0       -
+Rule E-EurAsia 1996    max     -       Oct     lastSun  0:00   0       -
+Rule RussiaAsia        1981    1984    -       Apr     1        0:00   1:00    S
+Rule RussiaAsia        1981    1983    -       Oct     1        0:00   0       -
+Rule RussiaAsia        1984    1991    -       Sep     lastSun  2:00s  0       -
+Rule RussiaAsia        1985    1991    -       Mar     lastSun  2:00s  1:00    S
+Rule RussiaAsia        1992    only    -       Mar     lastSat 23:00   1:00    S
+Rule RussiaAsia        1992    only    -       Sep     lastSat 23:00   0       -
+Rule RussiaAsia        1993    max     -       Mar     lastSun  2:00s  1:00    S
+Rule RussiaAsia        1993    1995    -       Sep     lastSun  2:00s  0       -
+Rule RussiaAsia        1996    max     -       Oct     lastSun  2:00s  0       -
+
+# Afghanistan
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Asia/Kabul      4:36:48 -       LMT     1890
+                       4:00    -       AFT     1945
+                       4:30    -       AFT
+
+# Armenia
+# From Paul Eggert (2006-03-22):
+# Shanks & Pottenger have Yerevan switching to 3:00 (with Russian DST)
+# in spring 1991, then to 4:00 with no DST in fall 1995, then
+# readopting Russian DST in 1997.  Go with Shanks & Pottenger, even
+# when they disagree with others.  Edgar Der-Danieliantz
+# reported (1996-05-04) that Yerevan probably wouldn't use DST
+# in 1996, though it did use DST in 1995.  IATA SSIM (1991/1998) reports that
+# Armenia switched from 3:00 to 4:00 in 1998 and observed DST after 1991,
+# but started switching at 3:00s in 1998.
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Asia/Yerevan    2:58:00 -       LMT     1924 May  2
+                       3:00    -       YERT    1957 Mar    # Yerevan Time
+                       4:00 RussiaAsia YER%sT  1991 Mar 31 2:00s
+                       3:00    1:00    YERST   1991 Sep 23 # independence
+                       3:00 RussiaAsia AM%sT   1995 Sep 24 2:00s
+                       4:00    -       AMT     1997
+                       4:00 RussiaAsia AM%sT
+
+# Azerbaijan
+# From Rustam Aliyev of the Azerbaijan Internet Forum (2005-10-23):
+# According to the resolution of Cabinet of Ministers, 1997
+# Resolution available at: http://aif.az/docs/daylight_res.pdf
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Azer    1997    max     -       Mar     lastSun  4:00   1:00    S
+Rule   Azer    1997    max     -       Oct     lastSun  5:00   0       -
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Asia/Baku       3:19:24 -       LMT     1924 May  2
+                       3:00    -       BAKT    1957 Mar    # Baku Time
+                       4:00 RussiaAsia BAK%sT  1991 Mar 31 2:00s
+                       3:00    1:00    BAKST   1991 Aug 30 # independence
+                       3:00 RussiaAsia AZ%sT   1992 Sep lastSat 23:00
+                       4:00    -       AZT     1996 # Azerbaijan time
+                       4:00    EUAsia  AZ%sT   1997
+                       4:00    Azer    AZ%sT
+
+# Bahrain
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Asia/Bahrain    3:22:20 -       LMT     1920            # Al Manamah
+                       4:00    -       GST     1972 Jun
+                       3:00    -       AST
+
+# Bangladesh
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Asia/Dhaka      6:01:40 -       LMT     1890
+                       5:53:20 -       HMT     1941 Oct    # Howrah Mean Time?
+                       6:30    -       BURT    1942 May 15 # Burma Time
+                       5:30    -       IST     1942 Sep
+                       6:30    -       BURT    1951 Sep 30
+                       6:00    -       DACT    1971 Mar 26 # Dacca Time
+                       6:00    -       BDT     # Bangladesh Time
+
+# Bhutan
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Asia/Thimphu    5:58:36 -       LMT     1947 Aug 15 # or Thimbu
+                       5:30    -       IST     1987 Oct
+                       6:00    -       BTT     # Bhutan Time
+
+# British Indian Ocean Territory
+# Whitman and the 1995 CIA time zone map say 5:00, but the
+# 1997 and later maps say 6:00.  Assume the switch occurred in 1996.
+# We have no information as to when standard time was introduced;
+# assume it occurred in 1907, the same year as Mauritius (which
+# then contained the Chagos Archipelago).
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Indian/Chagos   4:49:40 -       LMT     1907
+                       5:00    -       IOT     1996 # BIOT Time
+                       6:00    -       IOT
+
+# Brunei
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Asia/Brunei     7:39:40 -       LMT     1926 Mar   # Bandar Seri Begawan
+                       7:30    -       BNT     1933
+                       8:00    -       BNT
+
+# Burma / Myanmar
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Asia/Rangoon    6:24:40 -       LMT     1880            # or Yangon
+                       6:24:36 -       RMT     1920       # Rangoon Mean Time?
+                       6:30    -       BURT    1942 May   # Burma Time
+                       9:00    -       JST     1945 May 3
+                       6:30    -       MMT                # Myanmar Time
+
+# Cambodia
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Asia/Phnom_Penh 6:59:40 -       LMT     1906 Jun  9
+                       7:06:20 -       SMT     1911 Mar 11 0:01 # Saigon MT?
+                       7:00    -       ICT     1912 May
+                       8:00    -       ICT     1931 May
+                       7:00    -       ICT
+
+# China
+
+# From Guy Harris:
+# People's Republic of China.  Yes, they really have only one time zone.
+
+# From Bob Devine (1988-01-28):
+# No they don't.  See TIME mag, 1986-02-17 p.52.  Even though
+# China is across 4 physical time zones, before Feb 1, 1986 only the
+# Peking (Bejing) time zone was recognized.  Since that date, China
+# has two of 'em -- Peking's and Urumqi (named after the capital of
+# the Xinjiang Uyghur Autonomous Region).  I don't know about DST for it.
+#
+# . . .I just deleted the DST table and this editor makes it too
+# painful to suck in another copy..  So, here is what I have for
+# DST start/end dates for Peking's time zone (info from AP):
+#
+#     1986 May 4 - Sept 14
+#     1987 mid-April - ??
+
+# From U. S. Naval Observatory (1989-01-19):
+# CHINA               8 H  AHEAD OF UTC  ALL OF CHINA, INCL TAIWAN
+# CHINA               9 H  AHEAD OF UTC  APR 17 - SEP 10
+
+# From Paul Eggert (2006-03-22):
+# Shanks & Pottenger write that China (except for Hong Kong and Macau)
+# has had a single time zone since 1980 May 1, observing summer DST
+# from 1986 through 1991; this contradicts Devine's
+# note about Time magazine, though apparently _something_ happened in 1986.
+# Go with Shanks & Pottenger for now.  I made up names for the other
+# pre-1980 time zones.
+
+# From Shanks & Pottenger:
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Shang   1940    only    -       Jun      3      0:00    1:00    D
+Rule   Shang   1940    1941    -       Oct      1      0:00    0       S
+Rule   Shang   1941    only    -       Mar     16      0:00    1:00    D
+Rule   PRC     1986    only    -       May      4      0:00    1:00    D
+Rule   PRC     1986    1991    -       Sep     Sun>=11 0:00    0       S
+Rule   PRC     1987    1991    -       Apr     Sun>=10 0:00    1:00    D
+
+# From Anthony Fok (2001-12-20):
+# BTW, I did some research on-line and found some info regarding these five
+# historic timezones from some Taiwan websites.  And yes, there are official
+# Chinese names for these locales (before 1949).
+#
+# From Jesper Norgaard Welen (2006-07-14):
+# I have investigated the timezones around 1970 on the
+# http://www.astro.com/atlas site [with provinces and county
+# boundaries summarized below]....  A few other exceptions were two
+# counties on the Sichuan side of the Xizang-Sichuan border,
+# counties Dege and Baiyu which lies on the Sichuan side and are
+# therefore supposed to be GMT+7, Xizang region being GMT+6, but Dege
+# county is GMT+8 according to astro.com while Baiyu county is GMT+6
+# (could be true), for the moment I am assuming that those two
+# counties are mistakes in the astro.com data.
+
+# From Paul Eggert (2008-02-11):
+# I just now checked Google News for western news sources that talk
+# about China's single time zone, and couldn't find anything before 1986
+# talking about China being in one time zone.  (That article was: Jim
+# Mann, "A clumsy embrace for another western custom: China on daylight
+# time--sort of", Los Angeles Times, 1986-05-05.  By the way, this
+# article confirms the tz database's data claiming that China began
+# observing daylight saving time in 1986.
+#
+# From Thomas S. Mullaney (2008-02-11):
+# I think you're combining two subjects that need to treated 
+# separately: daylight savings (which, you're correct, wasn't 
+# implemented until the 1980s) and the unified time zone centered near 
+# Beijing (which was implemented in 1949). Briefly, there was also a 
+# "Lhasa Time" in Tibet and "Urumqi Time" in Xinjiang. The first was 
+# ceased, and the second eventually recognized (again, in the 1980s).
+#
+# From Paul Eggert (2008-06-30):
+# There seems to be a good chance China switched to a single time zone in 1949
+# rather than in 1980 as Shanks & Pottenger have it, but we don't have a
+# reliable documentary source saying so yet, so for now we still go with
+# Shanks & Pottenger.
+
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+# Changbai Time ("Long-white Time", Long-white = Heilongjiang area)
+# Heilongjiang (except Mohe county), Jilin
+Zone   Asia/Harbin     8:26:44 -       LMT     1928 # or Haerbin
+                       8:30    -       CHAT    1932 Mar # Changbai Time
+                       8:00    -       CST     1940
+                       9:00    -       CHAT    1966 May
+                       8:30    -       CHAT    1980 May
+                       8:00    PRC     C%sT
+# Zhongyuan Time ("Central plain Time")
+# most of China
+Zone   Asia/Shanghai   8:05:52 -       LMT     1928
+                       8:00    Shang   C%sT    1949
+                       8:00    PRC     C%sT
+# Long-shu Time (probably due to Long and Shu being two names of that area)
+# Guangxi, Guizhou, Hainan, Ningxia, Sichuan, Shaanxi, and Yunnan;
+# most of Gansu; west Inner Mongolia; west Qinghai; and the Guangdong
+# counties Deqing, Enping, Kaiping, Luoding, Taishan, Xinxing,
+# Yangchun, Yangjiang, Yu'nan, and Yunfu.
+Zone   Asia/Chongqing  7:06:20 -       LMT     1928 # or Chungking
+                       7:00    -       LONT    1980 May # Long-shu Time
+                       8:00    PRC     C%sT
+# Xin-zang Time ("Xinjiang-Tibet Time")
+# The Gansu counties Aksay, Anxi, Dunhuang, Subei; west Qinghai;
+# the Guangdong counties  Xuwen, Haikang, Suixi, Lianjiang,
+# Zhanjiang, Wuchuan, Huazhou, Gaozhou, Maoming, Dianbai, and Xinyi;
+# east Tibet, including Lhasa, Chamdo, Shigaise, Jimsar, Shawan and Hutubi;
+# east Xinjiang, including Urumqi, Turpan, Karamay, Korla, Minfeng, Jinghe,
+# Wusu, Qiemo, Xinyan, Wulanwusu, Jinghe, Yumin, Tacheng, Tuoli, Emin,
+# Shihezi, Changji, Yanqi, Heshuo, Tuokexun, Tulufan, Shanshan, Hami,
+# Fukang, Kuitun, Kumukuli, Miquan, Qitai, and Turfan.
+Zone   Asia/Urumqi     5:50:20 -       LMT     1928 # or Urumchi
+                       6:00    -       URUT    1980 May # Urumqi Time
+                       8:00    PRC     C%sT
+# Kunlun Time
+# West Tibet, including Pulan, Aheqi, Shufu, Shule;
+# West Xinjiang, including Aksu, Atushi, Yining, Hetian, Cele, Luopu, Nileke,
+# Zhaosu, Tekesi, Gongliu, Chabuchaer, Huocheng, Bole, Pishan, Suiding,
+# and Yarkand.
+Zone   Asia/Kashgar    5:03:56 -       LMT     1928 # or Kashi or Kaxgar
+                       5:30    -       KAST    1940     # Kashgar Time
+                       5:00    -       KAST    1980 May
+                       8:00    PRC     C%sT
+
+# Hong Kong (Xianggang)
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   HK      1946    only    -       Apr     20      3:30    1:00    S
+Rule   HK      1946    only    -       Dec     1       3:30    0       -
+Rule   HK      1947    only    -       Apr     13      3:30    1:00    S
+Rule   HK      1947    only    -       Dec     30      3:30    0       -
+Rule   HK      1948    only    -       May     2       3:30    1:00    S
+Rule   HK      1948    1952    -       Oct     lastSun 3:30    0       -
+Rule   HK      1949    1953    -       Apr     Sun>=1  3:30    1:00    S
+Rule   HK      1953    only    -       Nov     1       3:30    0       -
+Rule   HK      1954    1964    -       Mar     Sun>=18 3:30    1:00    S
+Rule   HK      1954    only    -       Oct     31      3:30    0       -
+Rule   HK      1955    1964    -       Nov     Sun>=1  3:30    0       -
+Rule   HK      1965    1977    -       Apr     Sun>=16 3:30    1:00    S
+Rule   HK      1965    1977    -       Oct     Sun>=16 3:30    0       -
+Rule   HK      1979    1980    -       May     Sun>=8  3:30    1:00    S
+Rule   HK      1979    1980    -       Oct     Sun>=16 3:30    0       -
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Asia/Hong_Kong  7:36:36 -       LMT     1904 Oct 30
+                       8:00    HK      HK%sT
+
+
+###############################################################################
+
+# Taiwan
+
+# Shanks & Pottenger write that Taiwan observed DST during 1945, when it
+# was still controlled by Japan.  This is hard to believe, but we don't
+# have any other information.
+
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Taiwan  1945    1951    -       May     1       0:00    1:00    D
+Rule   Taiwan  1945    1951    -       Oct     1       0:00    0       S
+Rule   Taiwan  1952    only    -       Mar     1       0:00    1:00    D
+Rule   Taiwan  1952    1954    -       Nov     1       0:00    0       S
+Rule   Taiwan  1953    1959    -       Apr     1       0:00    1:00    D
+Rule   Taiwan  1955    1961    -       Oct     1       0:00    0       S
+Rule   Taiwan  1960    1961    -       Jun     1       0:00    1:00    D
+Rule   Taiwan  1974    1975    -       Apr     1       0:00    1:00    D
+Rule   Taiwan  1974    1975    -       Oct     1       0:00    0       S
+Rule   Taiwan  1980    only    -       Jun     30      0:00    1:00    D
+Rule   Taiwan  1980    only    -       Sep     30      0:00    0       S
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Asia/Taipei     8:06:00 -       LMT     1896 # or Taibei or T'ai-pei
+                       8:00    Taiwan  C%sT
+
+# Macau (Macao, Aomen)
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Macau   1961    1962    -       Mar     Sun>=16 3:30    1:00    S
+Rule   Macau   1961    1964    -       Nov     Sun>=1  3:30    0       -
+Rule   Macau   1963    only    -       Mar     Sun>=16 0:00    1:00    S
+Rule   Macau   1964    only    -       Mar     Sun>=16 3:30    1:00    S
+Rule   Macau   1965    only    -       Mar     Sun>=16 0:00    1:00    S
+Rule   Macau   1965    only    -       Oct     31      0:00    0       -
+Rule   Macau   1966    1971    -       Apr     Sun>=16 3:30    1:00    S
+Rule   Macau   1966    1971    -       Oct     Sun>=16 3:30    0       -
+Rule   Macau   1972    1974    -       Apr     Sun>=15 0:00    1:00    S
+Rule   Macau   1972    1973    -       Oct     Sun>=15 0:00    0       -
+Rule   Macau   1974    1977    -       Oct     Sun>=15 3:30    0       -
+Rule   Macau   1975    1977    -       Apr     Sun>=15 3:30    1:00    S
+Rule   Macau   1978    1980    -       Apr     Sun>=15 0:00    1:00    S
+Rule   Macau   1978    1980    -       Oct     Sun>=15 0:00    0       -
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Asia/Macau      7:34:20 -       LMT     1912
+                       8:00    Macau   MO%sT   1999 Dec 20 # return to China
+                       8:00    PRC     C%sT
+
+
+###############################################################################
+
+# Cyprus
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Cyprus  1975    only    -       Apr     13      0:00    1:00    S
+Rule   Cyprus  1975    only    -       Oct     12      0:00    0       -
+Rule   Cyprus  1976    only    -       May     15      0:00    1:00    S
+Rule   Cyprus  1976    only    -       Oct     11      0:00    0       -
+Rule   Cyprus  1977    1980    -       Apr     Sun>=1  0:00    1:00    S
+Rule   Cyprus  1977    only    -       Sep     25      0:00    0       -
+Rule   Cyprus  1978    only    -       Oct     2       0:00    0       -
+Rule   Cyprus  1979    1997    -       Sep     lastSun 0:00    0       -
+Rule   Cyprus  1981    1998    -       Mar     lastSun 0:00    1:00    S
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Asia/Nicosia    2:13:28 -       LMT     1921 Nov 14
+                       2:00    Cyprus  EE%sT   1998 Sep
+                       2:00    EUAsia  EE%sT
+# IATA SSIM (1998-09) has Cyprus using EU rules for the first time.
+
+# Classically, Cyprus belongs to Asia; e.g. see Herodotus, Histories, I.72.
+# However, for various reasons many users expect to find it under Europe.
+Link   Asia/Nicosia    Europe/Nicosia
+
+# Georgia
+# From Paul Eggert (1994-11-19):
+# Today's _Economist_ (p 60) reports that Georgia moved its clocks forward
+# an hour recently, due to a law proposed by Zurab Murvanidze,
+# an MP who went on a hunger strike for 11 days to force discussion about it!
+# We have no details, but we'll guess they didn't move the clocks back in fall.
+#
+# From Mathew Englander, quoting AP (1996-10-23 13:05-04):
+# Instead of putting back clocks at the end of October, Georgia
+# will stay on daylight savings time this winter to save energy,
+# President Eduard Shevardnadze decreed Wednesday.
+#
+# From the BBC via Joseph S. Myers (2004-06-27):
+#
+# Georgia moved closer to Western Europe on Sunday...  The former Soviet
+# republic has changed its time zone back to that of Moscow.  As a result it
+# is now just four hours ahead of Greenwich Mean Time, rather than five hours
+# ahead.  The switch was decreed by the pro-Western president of Georgia,
+# Mikhail Saakashvili, who said the change was partly prompted by the process
+# of integration into Europe.
+
+# From Teimuraz Abashidze (2005-11-07):
+# Government of Georgia ... decided to NOT CHANGE daylight savings time on
+# [Oct.] 30, as it was done before during last more than 10 years.
+# Currently, we are in fact GMT +4:00, as before 30 October it was GMT
+# +3:00.... The problem is, there is NO FORMAL LAW or governmental document
+# about it.  As far as I can find, I was told, that there is no document,
+# because we just DIDN'T ISSUE document about switching to winter time....
+# I don't know what can be done, especially knowing that some years ago our
+# DST rules where changed THREE TIMES during one month.
+
+
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Asia/Tbilisi    2:59:16 -       LMT     1880
+                       2:59:16 -       TBMT    1924 May  2 # Tbilisi Mean Time
+                       3:00    -       TBIT    1957 Mar    # Tbilisi Time
+                       4:00 RussiaAsia TBI%sT  1991 Mar 31 2:00s
+                       3:00    1:00    TBIST   1991 Apr  9 # independence
+                       3:00 RussiaAsia GE%sT   1992 # Georgia Time
+                       3:00 E-EurAsia  GE%sT   1994 Sep lastSun
+                       4:00 E-EurAsia  GE%sT   1996 Oct lastSun
+                       4:00    1:00    GEST    1997 Mar lastSun
+                       4:00 E-EurAsia  GE%sT   2004 Jun 27
+                       3:00 RussiaAsia GE%sT   2005 Mar lastSun 2:00
+                       4:00    -       GET
+
+# East Timor
+
+# See Indonesia for the 1945 transition.
+
+# From Joao Carrascalao, brother of the former governor of East Timor, in
+# <a href="http://etan.org/et99c/december/26-31/30ETMAY.htm">
+# East Timor may be late for its millennium
+# </a> (1999-12-26/31):
+# Portugal tried to change the time forward in 1974 because the sun
+# rises too early but the suggestion raised a lot of problems with the
+# Timorese and I still don't think it would work today because it
+# conflicts with their way of life.
+
+# From Paul Eggert (2000-12-04):
+# We don't have any record of the above attempt.
+# Most likely our records are incomplete, but we have no better data.
+
+# <a href="http://www.hri.org/news/world/undh/last/00-08-16.undh.html">
+# From Manoel de Almeida e Silva, Deputy Spokesman for the UN Secretary-General
+# (2000-08-16)</a>:
+# The Cabinet of the East Timor Transition Administration decided
+# today to advance East Timor's time by one hour.  The time change,
+# which will be permanent, with no seasonal adjustment, will happen at
+# midnight on Saturday, September 16.
+
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Asia/Dili       8:22:20 -       LMT     1912
+                       8:00    -       TLT     1942 Feb 21 23:00 # E Timor Time
+                       9:00    -       JST     1945 Sep 23
+                       9:00    -       TLT     1976 May  3
+                       8:00    -       CIT     2000 Sep 17 00:00
+                       9:00    -       TLT
+
+# India
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Asia/Kolkata    5:53:28 -       LMT     1880    # Kolkata
+                       5:53:20 -       HMT     1941 Oct    # Howrah Mean Time?
+                       6:30    -       BURT    1942 May 15 # Burma Time
+                       5:30    -       IST     1942 Sep
+                       5:30    1:00    IST     1945 Oct 15
+                       5:30    -       IST
+# The following are like Asia/Kolkata:
+#      Andaman Is
+#      Lakshadweep (Laccadive, Minicoy and Amindivi Is)
+#      Nicobar Is
+
+# Indonesia
+#
+# From Gwillim Law (2001-05-28), overriding Shanks & Pottenger:
+# <http://www.sumatera-inc.com/go_to_invest/about_indonesia.asp#standtime>
+# says that Indonesia's time zones changed on 1988-01-01.  Looking at some
+# time zone maps, I think that must refer to Western Borneo (Kalimantan Barat
+# and Kalimantan Tengah) switching from UTC+8 to UTC+7.
+#
+# From Paul Eggert (2007-03-10):
+# Here is another correction to Shanks & Pottenger.
+# JohnTWB writes that Japanese forces did not surrender control in
+# Indonesia until 1945-09-01 00:00 at the earliest (in Jakarta) and
+# other formal surrender ceremonies were September 9, 11, and 13, plus
+# September 12 for the regional surrender to Mountbatten in Singapore.
+# These would be the earliest possible times for a change.
+# Regimes horaires pour le monde entier, by Henri Le Corre, (Editions
+# Traditionnelles, 1987, Paris) says that Java and Madura switched
+# from JST to UTC+07:30 on 1945-09-23, and gives 1944-09-01 for Jayapura
+# (Hollandia).  For now, assume all Indonesian locations other than Jayapura
+# switched on 1945-09-23.
+#
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone Asia/Jakarta      7:07:12 -       LMT     1867 Aug 10
+# Shanks & Pottenger say the next transition was at 1924 Jan 1 0:13,
+# but this must be a typo.
+                       7:07:12 -       JMT     1923 Dec 31 23:47:12 # Jakarta
+                       7:20    -       JAVT    1932 Nov         # Java Time
+                       7:30    -       WIT     1942 Mar 23
+                       9:00    -       JST     1945 Sep 23
+                       7:30    -       WIT     1948 May
+                       8:00    -       WIT     1950 May
+                       7:30    -       WIT     1964
+                       7:00    -       WIT
+Zone Asia/Pontianak    7:17:20 -       LMT     1908 May
+                       7:17:20 -       PMT     1932 Nov    # Pontianak MT
+                       7:30    -       WIT     1942 Jan 29
+                       9:00    -       JST     1945 Sep 23
+                       7:30    -       WIT     1948 May
+                       8:00    -       WIT     1950 May
+                       7:30    -       WIT     1964
+                       8:00    -       CIT     1988 Jan  1
+                       7:00    -       WIT
+Zone Asia/Makassar     7:57:36 -       LMT     1920
+                       7:57:36 -       MMT     1932 Nov    # Macassar MT
+                       8:00    -       CIT     1942 Feb  9
+                       9:00    -       JST     1945 Sep 23
+                       8:00    -       CIT
+Zone Asia/Jayapura     9:22:48 -       LMT     1932 Nov
+                       9:00    -       EIT     1944 Sep  1
+                       9:30    -       CST     1964
+                       9:00    -       EIT
+
+# Iran
+
+# From Roozbeh Pournader (2003-03-15):
+# This is an English translation of what I just found (originally in Persian).
+# The Gregorian dates in brackets are mine:
+#
+#      Official Newspaper No. 13548-1370/6/25 [1991-09-16]
+#      No. 16760/T233 H                                1370/6/10 [1991-09-01]
+#
+#      The Rule About Change of the Official Time of the Country
+#
+#      The Board of Ministers, in the meeting dated 1370/5/23 [1991-08-14],
+#      based on the suggestion number 2221/D dated 1370/4/22 [1991-07-13]
+#      of the Country's Organization for Official and Employment Affairs,
+#      and referring to the law for equating the working hours of workers
+#      and officers in the whole country dated 1359/4/23 [1980-07-14], and
+#      for synchronizing the official times of the country, agreed that:
+#
+#      The official time of the country will should move forward one hour
+#      at the 24[:00] hours of the first day of Farvardin and should return
+#      to its previous state at the 24[:00] hours of the 30th day of
+#      Shahrivar.
+#
+#      First Deputy to the President - Hassan Habibi
+#
+# From personal experience, that agrees with what has been followed
+# for at least the last 5 years.  Before that, for a few years, the
+# date used was the first Thursday night of Farvardin and the last
+# Thursday night of Shahrivar, but I can't give exact dates....
+# I have also changed the abbreviations to what is considered correct
+# here in Iran, IRST for regular time and IRDT for daylight saving time.
+#
+# From Roozbeh Pournader (2005-04-05):
+# The text of the Iranian law, in effect since 1925, clearly mentions
+# that the true solar year is the measure, and there is no arithmetic
+# leap year calculation involved.  There has never been any serious
+# plan to change that law....
+#
+# From Paul Eggert (2006-03-22):
+# Go with Shanks & Pottenger before Sept. 1991, and with Pournader thereafter.
+# I used Ed Reingold's cal-persia in GNU Emacs 21.2 to check Persian dates,
+# stopping after 2037 when 32-bit time_t's overflow.
+# That cal-persia used Birashk's approximation, which disagrees with the solar
+# calendar predictions for the year 2025, so I corrected those dates by hand.
+#
+# From Oscar van Vlijmen (2005-03-30), writing about future
+# discrepancies between cal-persia and the Iranian calendar:
+# For 2091 solar-longitude-after yields 2091-03-20 08:40:07.7 UT for
+# the vernal equinox and that gets so close to 12:00 some local
+# Iranian time that the definition of the correct location needs to be
+# known exactly, amongst other factors.  2157 is even closer:
+# 2157-03-20 08:37:15.5 UT.  But the Gregorian year 2025 should give
+# no interpretation problem whatsoever.  By the way, another instant
+# in the near future where there will be a discrepancy between
+# arithmetical and astronomical Iranian calendars will be in 2058:
+# vernal equinox on 2058-03-20 09:03:05.9 UT.  The Java version of
+# Reingold's/Dershowitz' calculator gives correctly the Gregorian date
+# 2058-03-21 for 1 Farvardin 1437 (astronomical).
+#
+# From Steffen Thorsen (2006-03-22):
+# Several of my users have reported that Iran will not observe DST anymore:
+# http://www.irna.ir/en/news/view/line-17/0603193812164948.htm
+#
+# From Reuters (2007-09-16), with a heads-up from Jesper Norgaard Welen:
+# ... the Guardian Council ... approved a law on Sunday to re-introduce
+# daylight saving time ...
+# http://uk.reuters.com/article/oilRpt/idUKBLA65048420070916
+#
+# From Roozbeh Pournader (2007-11-05):
+# This is quoted from Official Gazette of the Islamic Republic of
+# Iran, Volume 63, Number 18242, dated Tuesday 1386/6/24
+# [2007-10-16]. I am doing the best translation I can:...
+# The official time of the country will be moved forward for one hour
+# on the 24 hours of the first day of the month of Farvardin and will
+# be changed back to its previous state on the 24 hours of the
+# thirtieth day of Shahrivar.
+#
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Iran    1978    1980    -       Mar     21      0:00    1:00    D
+Rule   Iran    1978    only    -       Oct     21      0:00    0       S
+Rule   Iran    1979    only    -       Sep     19      0:00    0       S
+Rule   Iran    1980    only    -       Sep     23      0:00    0       S
+Rule   Iran    1991    only    -       May      3      0:00    1:00    D
+Rule   Iran    1992    1995    -       Mar     22      0:00    1:00    D
+Rule   Iran    1991    1995    -       Sep     22      0:00    0       S
+Rule   Iran    1996    only    -       Mar     21      0:00    1:00    D
+Rule   Iran    1996    only    -       Sep     21      0:00    0       S
+Rule   Iran    1997    1999    -       Mar     22      0:00    1:00    D
+Rule   Iran    1997    1999    -       Sep     22      0:00    0       S
+Rule   Iran    2000    only    -       Mar     21      0:00    1:00    D
+Rule   Iran    2000    only    -       Sep     21      0:00    0       S
+Rule   Iran    2001    2003    -       Mar     22      0:00    1:00    D
+Rule   Iran    2001    2003    -       Sep     22      0:00    0       S
+Rule   Iran    2004    only    -       Mar     21      0:00    1:00    D
+Rule   Iran    2004    only    -       Sep     21      0:00    0       S
+Rule   Iran    2005    only    -       Mar     22      0:00    1:00    D
+Rule   Iran    2005    only    -       Sep     22      0:00    0       S
+Rule   Iran    2008    only    -       Mar     21      0:00    1:00    D
+Rule   Iran    2008    only    -       Sep     21      0:00    0       S
+Rule   Iran    2009    2011    -       Mar     22      0:00    1:00    D
+Rule   Iran    2009    2011    -       Sep     22      0:00    0       S
+Rule   Iran    2012    only    -       Mar     21      0:00    1:00    D
+Rule   Iran    2012    only    -       Sep     21      0:00    0       S
+Rule   Iran    2013    2015    -       Mar     22      0:00    1:00    D
+Rule   Iran    2013    2015    -       Sep     22      0:00    0       S
+Rule   Iran    2016    only    -       Mar     21      0:00    1:00    D
+Rule   Iran    2016    only    -       Sep     21      0:00    0       S
+Rule   Iran    2017    2019    -       Mar     22      0:00    1:00    D
+Rule   Iran    2017    2019    -       Sep     22      0:00    0       S
+Rule   Iran    2020    only    -       Mar     21      0:00    1:00    D
+Rule   Iran    2020    only    -       Sep     21      0:00    0       S
+Rule   Iran    2021    2023    -       Mar     22      0:00    1:00    D
+Rule   Iran    2021    2023    -       Sep     22      0:00    0       S
+Rule   Iran    2024    only    -       Mar     21      0:00    1:00    D
+Rule   Iran    2024    only    -       Sep     21      0:00    0       S
+Rule   Iran    2025    2027    -       Mar     22      0:00    1:00    D
+Rule   Iran    2025    2027    -       Sep     22      0:00    0       S
+Rule   Iran    2028    2029    -       Mar     21      0:00    1:00    D
+Rule   Iran    2028    2029    -       Sep     21      0:00    0       S
+Rule   Iran    2030    2031    -       Mar     22      0:00    1:00    D
+Rule   Iran    2030    2031    -       Sep     22      0:00    0       S
+Rule   Iran    2032    2033    -       Mar     21      0:00    1:00    D
+Rule   Iran    2032    2033    -       Sep     21      0:00    0       S
+Rule   Iran    2034    2035    -       Mar     22      0:00    1:00    D
+Rule   Iran    2034    2035    -       Sep     22      0:00    0       S
+Rule   Iran    2036    2037    -       Mar     21      0:00    1:00    D
+Rule   Iran    2036    2037    -       Sep     21      0:00    0       S
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Asia/Tehran     3:25:44 -       LMT     1916
+                       3:25:44 -       TMT     1946    # Tehran Mean Time
+                       3:30    -       IRST    1977 Nov
+                       4:00    Iran    IR%sT   1979
+                       3:30    Iran    IR%sT
+
+
+# Iraq
+#
+# From Jonathan Lennox (2000-06-12):
+# An article in this week's Economist ("Inside the Saddam-free zone", p. 50 in
+# the U.S. edition) on the Iraqi Kurds contains a paragraph:
+# "The three northern provinces ... switched their clocks this spring and
+# are an hour ahead of Baghdad."
+#
+# But Rives McDow (2000-06-18) quotes a contact in Iraqi-Kurdistan as follows:
+# In the past, some Kurdish nationalists, as a protest to the Iraqi
+# Government, did not adhere to daylight saving time.  They referred
+# to daylight saving as Saddam time.  But, as of today, the time zone
+# in Iraqi-Kurdistan is on standard time with Baghdad, Iraq.
+#
+# So we'll ignore the Economist's claim.
+
+# From Steffen Thorsen (2008-03-10):
+# The cabinet in Iraq abolished DST last week, according to the following
+# news sources (in Arabic):
+# <a href="http://www.aljeeran.net/wesima_articles/news-20080305-98602.html">
+# http://www.aljeeran.net/wesima_articles/news-20080305-98602.html
+# </a>
+# <a href="http://www.aswataliraq.info/look/article.tpl?id=2047&IdLanguage=17&IdPublication=4&NrArticle=71743&NrIssue=1&NrSection=10">
+# http://www.aswataliraq.info/look/article.tpl?id=2047&IdLanguage=17&IdPublication=4&NrArticle=71743&NrIssue=1&NrSection=10
+# </a>
+#
+# We have published a short article in English about the change:
+# <a href="http://www.timeanddate.com/news/time/iraq-dumps-daylight-saving.html">
+# http://www.timeanddate.com/news/time/iraq-dumps-daylight-saving.html
+# </a>
+
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Iraq    1982    only    -       May     1       0:00    1:00    D
+Rule   Iraq    1982    1984    -       Oct     1       0:00    0       S
+Rule   Iraq    1983    only    -       Mar     31      0:00    1:00    D
+Rule   Iraq    1984    1985    -       Apr     1       0:00    1:00    D
+Rule   Iraq    1985    1990    -       Sep     lastSun 1:00s   0       S
+Rule   Iraq    1986    1990    -       Mar     lastSun 1:00s   1:00    D
+# IATA SSIM (1991/1996) says Apr 1 12:01am UTC; guess the `:01' is a typo.
+# Shanks & Pottenger say Iraq did not observe DST 1992/1997; ignore this.
+#
+Rule   Iraq    1991    2007    -       Apr      1      3:00s   1:00    D
+Rule   Iraq    1991    2007    -       Oct      1      3:00s   0       S
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Asia/Baghdad    2:57:40 -       LMT     1890
+                       2:57:36 -       BMT     1918        # Baghdad Mean Time?
+                       3:00    -       AST     1982 May
+                       3:00    Iraq    A%sT
+
+
+###############################################################################
+
+# Israel
+
+# From Ephraim Silverberg (2001-01-11):
+#
+# I coined "IST/IDT" circa 1988.  Until then there were three
+# different abbreviations in use:
+#
+# JST  Jerusalem Standard Time [Danny Braniss, Hebrew University]
+# IZT  Israel Zonal (sic) Time [Prof. Haim Papo, Technion]
+# EEST Eastern Europe Standard Time [used by almost everyone else]
+#
+# Since timezones should be called by country and not capital cities,
+# I ruled out JST.  As Israel is in Asia Minor and not Eastern Europe,
+# EEST was equally unacceptable.  Since "zonal" was not compatible with
+# any other timezone abbreviation, I felt that 'IST' was the way to go
+# and, indeed, it has received almost universal acceptance in timezone
+# settings in Israeli computers.
+#
+# In any case, I am happy to share timezone abbreviations with India,
+# high on my favorite-country list (and not only because my wife's
+# family is from India).
+
+# From Shanks & Pottenger:
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Zion    1940    only    -       Jun      1      0:00    1:00    D
+Rule   Zion    1942    1944    -       Nov      1      0:00    0       S
+Rule   Zion    1943    only    -       Apr      1      2:00    1:00    D
+Rule   Zion    1944    only    -       Apr      1      0:00    1:00    D
+Rule   Zion    1945    only    -       Apr     16      0:00    1:00    D
+Rule   Zion    1945    only    -       Nov      1      2:00    0       S
+Rule   Zion    1946    only    -       Apr     16      2:00    1:00    D
+Rule   Zion    1946    only    -       Nov      1      0:00    0       S
+Rule   Zion    1948    only    -       May     23      0:00    2:00    DD
+Rule   Zion    1948    only    -       Sep      1      0:00    1:00    D
+Rule   Zion    1948    1949    -       Nov      1      2:00    0       S
+Rule   Zion    1949    only    -       May      1      0:00    1:00    D
+Rule   Zion    1950    only    -       Apr     16      0:00    1:00    D
+Rule   Zion    1950    only    -       Sep     15      3:00    0       S
+Rule   Zion    1951    only    -       Apr      1      0:00    1:00    D
+Rule   Zion    1951    only    -       Nov     11      3:00    0       S
+Rule   Zion    1952    only    -       Apr     20      2:00    1:00    D
+Rule   Zion    1952    only    -       Oct     19      3:00    0       S
+Rule   Zion    1953    only    -       Apr     12      2:00    1:00    D
+Rule   Zion    1953    only    -       Sep     13      3:00    0       S
+Rule   Zion    1954    only    -       Jun     13      0:00    1:00    D
+Rule   Zion    1954    only    -       Sep     12      0:00    0       S
+Rule   Zion    1955    only    -       Jun     11      2:00    1:00    D
+Rule   Zion    1955    only    -       Sep     11      0:00    0       S
+Rule   Zion    1956    only    -       Jun      3      0:00    1:00    D
+Rule   Zion    1956    only    -       Sep     30      3:00    0       S
+Rule   Zion    1957    only    -       Apr     29      2:00    1:00    D
+Rule   Zion    1957    only    -       Sep     22      0:00    0       S
+Rule   Zion    1974    only    -       Jul      7      0:00    1:00    D
+Rule   Zion    1974    only    -       Oct     13      0:00    0       S
+Rule   Zion    1975    only    -       Apr     20      0:00    1:00    D
+Rule   Zion    1975    only    -       Aug     31      0:00    0       S
+Rule   Zion    1985    only    -       Apr     14      0:00    1:00    D
+Rule   Zion    1985    only    -       Sep     15      0:00    0       S
+Rule   Zion    1986    only    -       May     18      0:00    1:00    D
+Rule   Zion    1986    only    -       Sep      7      0:00    0       S
+Rule   Zion    1987    only    -       Apr     15      0:00    1:00    D
+Rule   Zion    1987    only    -       Sep     13      0:00    0       S
+Rule   Zion    1988    only    -       Apr      9      0:00    1:00    D
+Rule   Zion    1988    only    -       Sep      3      0:00    0       S
+
+# From Ephraim Silverberg
+# (1997-03-04, 1998-03-16, 1998-12-28, 2000-01-17, 2000-07-25, 2004-12-22,
+# and 2005-02-17):
+
+# According to the Office of the Secretary General of the Ministry of
+# Interior, there is NO set rule for Daylight-Savings/Standard time changes.
+# One thing is entrenched in law, however: that there must be at least 150
+# days of daylight savings time annually.  From 1993-1998, the change to
+# daylight savings time was on a Friday morning from midnight IST to
+# 1 a.m IDT; up until 1998, the change back to standard time was on a
+# Saturday night from midnight daylight savings time to 11 p.m. standard
+# time.  1996 is an exception to this rule where the change back to standard
+# time took place on Sunday night instead of Saturday night to avoid
+# conflicts with the Jewish New Year.  In 1999, the change to
+# daylight savings time was still on a Friday morning but from
+# 2 a.m. IST to 3 a.m. IDT; furthermore, the change back to standard time
+# was also on a Friday morning from 2 a.m. IDT to 1 a.m. IST for
+# 1999 only.  In the year 2000, the change to daylight savings time was
+# similar to 1999, but although the change back will be on a Friday, it
+# will take place from 1 a.m. IDT to midnight IST.  Starting in 2001, all
+# changes to/from will take place at 1 a.m. old time, but now there is no
+# rule as to what day of the week it will take place in as the start date
+# (except in 2003) is the night after the Passover Seder (i.e. the eve
+# of the 16th of Nisan in the lunar Hebrew calendar) and the end date
+# (except in 2002) is three nights before Yom Kippur [Day of Atonement]
+# (the eve of the 7th of Tishrei in the lunar Hebrew calendar).
+
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Zion    1989    only    -       Apr     30      0:00    1:00    D
+Rule   Zion    1989    only    -       Sep      3      0:00    0       S
+Rule   Zion    1990    only    -       Mar     25      0:00    1:00    D
+Rule   Zion    1990    only    -       Aug     26      0:00    0       S
+Rule   Zion    1991    only    -       Mar     24      0:00    1:00    D
+Rule   Zion    1991    only    -       Sep      1      0:00    0       S
+Rule   Zion    1992    only    -       Mar     29      0:00    1:00    D
+Rule   Zion    1992    only    -       Sep      6      0:00    0       S
+Rule   Zion    1993    only    -       Apr      2      0:00    1:00    D
+Rule   Zion    1993    only    -       Sep      5      0:00    0       S
+
+# The dates for 1994-1995 were obtained from Office of the Spokeswoman for the
+# Ministry of Interior, Jerusalem, Israel.  The spokeswoman can be reached by
+# calling the office directly at 972-2-6701447 or 972-2-6701448.
+
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Zion    1994    only    -       Apr      1      0:00    1:00    D
+Rule   Zion    1994    only    -       Aug     28      0:00    0       S
+Rule   Zion    1995    only    -       Mar     31      0:00    1:00    D
+Rule   Zion    1995    only    -       Sep      3      0:00    0       S
+
+# The dates for 1996 were determined by the Minister of Interior of the
+# time, Haim Ramon.  The official announcement regarding 1996-1998
+# (with the dates for 1997-1998 no longer being relevant) can be viewed at:
+#
+#   ftp://ftp.cs.huji.ac.il/pub/tz/announcements/1996-1998.ramon.ps.gz
+#
+# The dates for 1997-1998 were altered by his successor, Rabbi Eli Suissa.
+#
+# The official announcements for the years 1997-1999 can be viewed at:
+#
+#   ftp://ftp.cs.huji.ac.il/pub/tz/announcements/YYYY.ps.gz
+#
+#       where YYYY is the relevant year.
+
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Zion    1996    only    -       Mar     15      0:00    1:00    D
+Rule   Zion    1996    only    -       Sep     16      0:00    0       S
+Rule   Zion    1997    only    -       Mar     21      0:00    1:00    D
+Rule   Zion    1997    only    -       Sep     14      0:00    0       S
+Rule   Zion    1998    only    -       Mar     20      0:00    1:00    D
+Rule   Zion    1998    only    -       Sep      6      0:00    0       S
+Rule   Zion    1999    only    -       Apr      2      2:00    1:00    D
+Rule   Zion    1999    only    -       Sep      3      2:00    0       S
+
+# The Knesset Interior Committee has changed the dates for 2000 for
+# the third time in just over a year and have set new dates for the
+# years 2001-2004 as well.
+#
+# The official announcement for the start date of 2000 can be viewed at:
+#
+#      ftp://ftp.cs.huji.ac.il/pub/tz/announcements/2000-start.ps.gz
+#
+# The official announcement for the end date of 2000 and the dates
+# for the years 2001-2004 can be viewed at:
+#
+#      ftp://ftp.cs.huji.ac.il/pub/tz/announcements/2000-2004.ps.gz
+
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Zion    2000    only    -       Apr     14      2:00    1:00    D
+Rule   Zion    2000    only    -       Oct      6      1:00    0       S
+Rule   Zion    2001    only    -       Apr      9      1:00    1:00    D
+Rule   Zion    2001    only    -       Sep     24      1:00    0       S
+Rule   Zion    2002    only    -       Mar     29      1:00    1:00    D
+Rule   Zion    2002    only    -       Oct      7      1:00    0       S
+Rule   Zion    2003    only    -       Mar     28      1:00    1:00    D
+Rule   Zion    2003    only    -       Oct      3      1:00    0       S
+Rule   Zion    2004    only    -       Apr      7      1:00    1:00    D
+Rule   Zion    2004    only    -       Sep     22      1:00    0       S
+
+# The proposed law agreed upon by the Knesset Interior Committee on
+# 2005-02-14 is that, for 2005 and beyond, DST starts at 02:00 the
+# last Friday before April 2nd (i.e. the last Friday in March or April
+# 1st itself if it falls on a Friday) and ends at 02:00 on the Saturday
+# night _before_ the fast of Yom Kippur.
+#
+# Those who can read Hebrew can view the announcement at:
+#
+#      ftp://ftp.cs.huji.ac.il/pub/tz/announcements/2005+beyond.ps
+
+# From Paul Eggert (2005-02-22):
+# I used Ephraim Silverberg's dst-israel.el program
+# <ftp://ftp.cs.huji.ac.il/pub/tz/software/dst-israel.el> (2005-02-20)
+# along with Ed Reingold's cal-hebrew in GNU Emacs 21.4,
+# to generate the transitions in this list.
+# (I replaced "lastFri" with "Fri>=26" by hand.)
+# The spring transitions below all correspond to the following Rule:
+#
+# Rule Zion    2005    max     -       Mar     Fri>=26 2:00    1:00    D
+#
+# but older zic implementations (e.g., Solaris 8) do not support
+# "Fri>=26" to mean April 1 in years like 2005, so for now we list the
+# springtime transitions explicitly.
+
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Zion    2005    only    -       Apr      1      2:00    1:00    D
+Rule   Zion    2005    only    -       Oct      9      2:00    0       S
+Rule   Zion    2006    2010    -       Mar     Fri>=26 2:00    1:00    D
+Rule   Zion    2006    only    -       Oct      1      2:00    0       S
+Rule   Zion    2007    only    -       Sep     16      2:00    0       S
+Rule   Zion    2008    only    -       Oct      5      2:00    0       S
+Rule   Zion    2009    only    -       Sep     27      2:00    0       S
+Rule   Zion    2010    only    -       Sep     12      2:00    0       S
+Rule   Zion    2011    only    -       Apr      1      2:00    1:00    D
+Rule   Zion    2011    only    -       Oct      2      2:00    0       S
+Rule   Zion    2012    2015    -       Mar     Fri>=26 2:00    1:00    D
+Rule   Zion    2012    only    -       Sep     23      2:00    0       S
+Rule   Zion    2013    only    -       Sep      8      2:00    0       S
+Rule   Zion    2014    only    -       Sep     28      2:00    0       S
+Rule   Zion    2015    only    -       Sep     20      2:00    0       S
+Rule   Zion    2016    only    -       Apr      1      2:00    1:00    D
+Rule   Zion    2016    only    -       Oct      9      2:00    0       S
+Rule   Zion    2017    2021    -       Mar     Fri>=26 2:00    1:00    D
+Rule   Zion    2017    only    -       Sep     24      2:00    0       S
+Rule   Zion    2018    only    -       Sep     16      2:00    0       S
+Rule   Zion    2019    only    -       Oct      6      2:00    0       S
+Rule   Zion    2020    only    -       Sep     27      2:00    0       S
+Rule   Zion    2021    only    -       Sep     12      2:00    0       S
+Rule   Zion    2022    only    -       Apr      1      2:00    1:00    D
+Rule   Zion    2022    only    -       Oct      2      2:00    0       S
+Rule   Zion    2023    2032    -       Mar     Fri>=26 2:00    1:00    D
+Rule   Zion    2023    only    -       Sep     24      2:00    0       S
+Rule   Zion    2024    only    -       Oct      6      2:00    0       S
+Rule   Zion    2025    only    -       Sep     28      2:00    0       S
+Rule   Zion    2026    only    -       Sep     20      2:00    0       S
+Rule   Zion    2027    only    -       Oct     10      2:00    0       S
+Rule   Zion    2028    only    -       Sep     24      2:00    0       S
+Rule   Zion    2029    only    -       Sep     16      2:00    0       S
+Rule   Zion    2030    only    -       Oct      6      2:00    0       S
+Rule   Zion    2031    only    -       Sep     21      2:00    0       S
+Rule   Zion    2032    only    -       Sep     12      2:00    0       S
+Rule   Zion    2033    only    -       Apr      1      2:00    1:00    D
+Rule   Zion    2033    only    -       Oct      2      2:00    0       S
+Rule   Zion    2034    2037    -       Mar     Fri>=26 2:00    1:00    D
+Rule   Zion    2034    only    -       Sep     17      2:00    0       S
+Rule   Zion    2035    only    -       Oct      7      2:00    0       S
+Rule   Zion    2036    only    -       Sep     28      2:00    0       S
+Rule   Zion    2037    only    -       Sep     13      2:00    0       S
+
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Asia/Jerusalem  2:20:56 -       LMT     1880
+                       2:20:40 -       JMT     1918    # Jerusalem Mean Time?
+                       2:00    Zion    I%sT
+
+
+
+###############################################################################
+
+# Japan
+
+# `9:00' and `JST' is from Guy Harris.
+
+# From Paul Eggert (1995-03-06):
+# Today's _Asahi Evening News_ (page 4) reports that Japan had
+# daylight saving between 1948 and 1951, but ``the system was discontinued
+# because the public believed it would lead to longer working hours.''
+
+# From Mayumi Negishi in the 2005-08-10 Japan Times
+# <http://www.japantimes.co.jp/cgi-bin/getarticle.pl5?nn20050810f2.htm>:
+# Occupation authorities imposed daylight-saving time on Japan on
+# [1948-05-01]....  But lack of prior debate and the execution of
+# daylight-saving time just three days after the bill was passed generated
+# deep hatred of the concept....  The Diet unceremoniously passed a bill to
+# dump the unpopular system in October 1951, less than a month after the San
+# Francisco Peace Treaty was signed.  (A government poll in 1951 showed 53%
+# of the Japanese wanted to scrap daylight-saving time, as opposed to 30% who
+# wanted to keep it.)
+
+# From Paul Eggert (2006-03-22):
+# Shanks & Pottenger write that DST in Japan during those years was as follows:
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Japan   1948    only    -       May     Sun>=1  2:00    1:00    D
+Rule   Japan   1948    1951    -       Sep     Sat>=8  2:00    0       S
+Rule   Japan   1949    only    -       Apr     Sun>=1  2:00    1:00    D
+Rule   Japan   1950    1951    -       May     Sun>=1  2:00    1:00    D
+# but the only locations using it (for birth certificates, presumably, since
+# their audience is astrologers) were US military bases.  For now, assume
+# that for most purposes daylight-saving time was observed; otherwise, what
+# would have been the point of the 1951 poll?
+
+# From Hideyuki Suzuki (1998-11-09):
+# 'Tokyo' usually stands for the former location of Tokyo Astronomical
+# Observatory: E 139 44' 40".90 (9h 18m 58s.727), N 35 39' 16".0.
+# This data is from 'Rika Nenpyou (Chronological Scientific Tables) 1996'
+# edited by National Astronomical Observatory of Japan....
+# JST (Japan Standard Time) has been used since 1888-01-01 00:00 (JST).
+# The law is enacted on 1886-07-07.
+
+# From Hideyuki Suzuki (1998-11-16):
+# The ordinance No. 51 (1886) established "standard time" in Japan,
+# which stands for the time on E 135 degree.
+# In the ordinance No. 167 (1895), "standard time" was renamed to "central
+# standard time".  And the same ordinance also established "western standard
+# time", which stands for the time on E 120 degree....  But "western standard
+# time" was abolished in the ordinance No. 529 (1937).  In the ordinance No.
+# 167, there is no mention regarding for what place western standard time is
+# standard....
+#
+# I wrote "ordinance" above, but I don't know how to translate.
+# In Japanese it's "chokurei", which means ordinance from emperor.
+
+# Shanks & Pottenger claim JST in use since 1896, and that a few
+# places (e.g. Ishigaki) use +0800; go with Suzuki.  Guess that all
+# ordinances took effect on Jan 1.
+
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Asia/Tokyo      9:18:59 -       LMT     1887 Dec 31 15:00u
+                       9:00    -       JST     1896
+                       9:00    -       CJT     1938
+                       9:00    Japan   J%sT
+# Since 1938, all Japanese possessions have been like Asia/Tokyo.
+
+# Jordan
+#
+# From <a href="http://star.arabia.com/990701/JO9.html">
+# Jordan Week (1999-07-01) </a> via Steffen Thorsen (1999-09-09):
+# Clocks in Jordan were forwarded one hour on Wednesday at midnight,
+# in accordance with the government's decision to implement summer time
+# all year round.
+#
+# From <a href="http://star.arabia.com/990930/JO9.html">
+# Jordan Week (1999-09-30) </a> via Steffen Thorsen (1999-11-09):
+# Winter time starts today Thursday, 30 September. Clocks will be turned back
+# by one hour.  This is the latest government decision and it's final!
+# The decision was taken because of the increase in working hours in
+# government's departments from six to seven hours.
+#
+# From Paul Eggert (2005-11-22):
+# Starting 2003 transitions are from Steffen Thorsen's web site timeanddate.com.
+#
+# From Steffen Thorsen (2005-11-23):
+# For Jordan I have received multiple independent user reports every year
+# about DST end dates, as the end-rule is different every year.
+#
+# From Steffen Thorsen (2006-10-01), after a heads-up from Hilal Malawi:
+# http://www.petranews.gov.jo/nepras/2006/Sep/05/4000.htm
+# "Jordan will switch to winter time on Friday, October 27".
+#
+
+# From Phil Pizzey (2009-04-02):
+# ...I think I may have spotted an error in the timezone data for
+# Jordan.
+# The current (2009d) asia file shows Jordan going to daylight
+# saving
+# time on the last Thursday in March.
+#
+# Rule  Jordan      2000  max  -  Mar   lastThu     0:00s 1:00  S
+#
+# However timeanddate.com, which I usually find reliable, shows Jordan
+# going to daylight saving time on the last Friday in March since 2002.
+# Please see
+# <a href="http://www.timeanddate.com/worldclock/timezone.html?n=11">
+# http://www.timeanddate.com/worldclock/timezone.html?n=11
+# </a>
+
+# From Steffen Thorsen (2009-04-02):
+# This single one might be good enough, (2009-03-24, Arabic):
+# <a href="http://petra.gov.jo/Artical.aspx?Lng=2&Section=8&Artical=95279">
+# http://petra.gov.jo/Artical.aspx?Lng=2&Section=8&Artical=95279
+# </a>
+#
+# Google's translation:
+#
+# > The Council of Ministers decided in 2002 to adopt the principle of timely
+# > submission of the summer at 60 minutes as of midnight on the last Thursday
+# > of the month of March of each year.
+#
+# So - this means the midnight between Thursday and Friday since 2002.
+
+# From Arthur David Olson (2009-04-06):
+# We still have Jordan switching to DST on Thursdays in 2000 and 2001.
+
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Jordan  1973    only    -       Jun     6       0:00    1:00    S
+Rule   Jordan  1973    1975    -       Oct     1       0:00    0       -
+Rule   Jordan  1974    1977    -       May     1       0:00    1:00    S
+Rule   Jordan  1976    only    -       Nov     1       0:00    0       -
+Rule   Jordan  1977    only    -       Oct     1       0:00    0       -
+Rule   Jordan  1978    only    -       Apr     30      0:00    1:00    S
+Rule   Jordan  1978    only    -       Sep     30      0:00    0       -
+Rule   Jordan  1985    only    -       Apr     1       0:00    1:00    S
+Rule   Jordan  1985    only    -       Oct     1       0:00    0       -
+Rule   Jordan  1986    1988    -       Apr     Fri>=1  0:00    1:00    S
+Rule   Jordan  1986    1990    -       Oct     Fri>=1  0:00    0       -
+Rule   Jordan  1989    only    -       May     8       0:00    1:00    S
+Rule   Jordan  1990    only    -       Apr     27      0:00    1:00    S
+Rule   Jordan  1991    only    -       Apr     17      0:00    1:00    S
+Rule   Jordan  1991    only    -       Sep     27      0:00    0       -
+Rule   Jordan  1992    only    -       Apr     10      0:00    1:00    S
+Rule   Jordan  1992    1993    -       Oct     Fri>=1  0:00    0       -
+Rule   Jordan  1993    1998    -       Apr     Fri>=1  0:00    1:00    S
+Rule   Jordan  1994    only    -       Sep     Fri>=15 0:00    0       -
+Rule   Jordan  1995    1998    -       Sep     Fri>=15 0:00s   0       -
+Rule   Jordan  1999    only    -       Jul      1      0:00s   1:00    S
+Rule   Jordan  1999    2002    -       Sep     lastFri 0:00s   0       -
+Rule   Jordan  2000    2001    -       Mar     lastThu 0:00s   1:00    S
+Rule   Jordan  2002    max     -       Mar     lastFri 0:00s   1:00    S
+Rule   Jordan  2003    only    -       Oct     24      0:00s   0       -
+Rule   Jordan  2004    only    -       Oct     15      0:00s   0       -
+Rule   Jordan  2005    only    -       Sep     lastFri 0:00s   0       -
+Rule   Jordan  2006    max     -       Oct     lastFri 0:00s   0       -
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Asia/Amman      2:23:44 -       LMT     1931
+                       2:00    Jordan  EE%sT
+
+
+# Kazakhstan
+
+# From Paul Eggert (1996-11-22):
+# Andrew Evtichov (1996-04-13) writes that Kazakhstan
+# stayed in sync with Moscow after 1990, and that Aqtobe (formerly Aktyubinsk)
+# and Aqtau (formerly Shevchenko) are the largest cities in their zones.
+# Guess that Aqtau and Aqtobe diverged in 1995, since that's the first time
+# IATA SSIM mentions a third time zone in Kazakhstan.
+
+# From Paul Eggert (2006-03-22):
+# German Iofis, ELSI, Almaty (2001-10-09) reports that Kazakhstan uses
+# RussiaAsia rules, instead of switching at 00:00 as the IATA has it.
+# Go with Shanks & Pottenger, who have them always using RussiaAsia rules.
+# Also go with the following claims of Shanks & Pottenger:
+#
+# - Kazakhstan did not observe DST in 1991.
+# - Qyzylorda switched from +5:00 to +6:00 on 1992-01-19 02:00.
+# - Oral switched from +5:00 to +4:00 in spring 1989.
+
+# <a href="http://www.kazsociety.org.uk/news/2005/03/30.htm">
+# From Kazakhstan Embassy's News Bulletin #11 (2005-03-21):
+# </a>
+# The Government of Kazakhstan passed a resolution March 15 abolishing
+# daylight saving time citing lack of economic benefits and health
+# complications coupled with a decrease in productivity.
+#
+# From Branislav Kojic (in Astana) via Gwillim Law (2005-06-28):
+# ... what happened was that the former Kazakhstan Eastern time zone
+# was "blended" with the Central zone.  Therefore, Kazakhstan now has
+# two time zones, and difference between them is one hour.  The zone
+# closer to UTC is the former Western zone (probably still called the
+# same), encompassing four provinces in the west: Aqtobe, Atyrau,
+# Mangghystau, and West Kazakhstan.  The other zone encompasses
+# everything else....  I guess that would make Kazakhstan time zones
+# de jure UTC+5 and UTC+6 respectively.
+
+#
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+#
+# Almaty (formerly Alma-Ata), representing most locations in Kazakhstan
+Zone   Asia/Almaty     5:07:48 -       LMT     1924 May  2 # or Alma-Ata
+                       5:00    -       ALMT    1930 Jun 21 # Alma-Ata Time
+                       6:00 RussiaAsia ALM%sT  1991
+                       6:00    -       ALMT    1992
+                       6:00 RussiaAsia ALM%sT  2005 Mar 15
+                       6:00    -       ALMT
+# Qyzylorda (aka Kyzylorda, Kizilorda, Kzyl-Orda, etc.)
+Zone   Asia/Qyzylorda  4:21:52 -       LMT     1924 May  2
+                       4:00    -       KIZT    1930 Jun 21 # Kizilorda Time
+                       5:00    -       KIZT    1981 Apr  1
+                       5:00    1:00    KIZST   1981 Oct  1
+                       6:00    -       KIZT    1982 Apr  1
+                       5:00 RussiaAsia KIZ%sT  1991
+                       5:00    -       KIZT    1991 Dec 16 # independence
+                       5:00    -       QYZT    1992 Jan 19 2:00
+                       6:00 RussiaAsia QYZ%sT  2005 Mar 15
+                       6:00    -       QYZT
+# Aqtobe (aka Aktobe, formerly Akt'ubinsk)
+Zone   Asia/Aqtobe     3:48:40 -       LMT     1924 May  2
+                       4:00    -       AKTT    1930 Jun 21 # Aktyubinsk Time
+                       5:00    -       AKTT    1981 Apr  1
+                       5:00    1:00    AKTST   1981 Oct  1
+                       6:00    -       AKTT    1982 Apr  1
+                       5:00 RussiaAsia AKT%sT  1991
+                       5:00    -       AKTT    1991 Dec 16 # independence
+                       5:00 RussiaAsia AQT%sT  2005 Mar 15 # Aqtobe Time
+                       5:00    -       AQTT
+# Mangghystau
+# Aqtau was not founded until 1963, but it represents an inhabited region,
+# so include time stamps before 1963.
+Zone   Asia/Aqtau      3:21:04 -       LMT     1924 May  2
+                       4:00    -       FORT    1930 Jun 21 # Fort Shevchenko T
+                       5:00    -       FORT    1963
+                       5:00    -       SHET    1981 Oct  1 # Shevchenko Time
+                       6:00    -       SHET    1982 Apr  1
+                       5:00 RussiaAsia SHE%sT  1991
+                       5:00    -       SHET    1991 Dec 16 # independence
+                       5:00 RussiaAsia AQT%sT  1995 Mar lastSun 2:00 # Aqtau Time
+                       4:00 RussiaAsia AQT%sT  2005 Mar 15
+                       5:00    -       AQTT
+# West Kazakhstan
+Zone   Asia/Oral       3:25:24 -       LMT     1924 May  2 # or Ural'sk
+                       4:00    -       URAT    1930 Jun 21 # Ural'sk time
+                       5:00    -       URAT    1981 Apr  1
+                       5:00    1:00    URAST   1981 Oct  1
+                       6:00    -       URAT    1982 Apr  1
+                       5:00 RussiaAsia URA%sT  1989 Mar 26 2:00
+                       4:00 RussiaAsia URA%sT  1991
+                       4:00    -       URAT    1991 Dec 16 # independence
+                       4:00 RussiaAsia ORA%sT  2005 Mar 15 # Oral Time
+                       5:00    -       ORAT
+
+# Kyrgyzstan (Kirgizstan)
+# Transitions through 1991 are from Shanks & Pottenger.
+
+# From Paul Eggert (2005-08-15):
+# According to an article dated today in the Kyrgyzstan Development Gateway
+# <http://eng.gateway.kg/cgi-bin/page.pl?id=1&story_name=doc9979.shtml>
+# Kyrgyzstan is canceling the daylight saving time system.  I take the article
+# to mean that they will leave their clocks at 6 hours ahead of UTC.
+# From Malik Abdugaliev (2005-09-21):
+# Our government cancels daylight saving time 6th of August 2005.
+# From 2005-08-12 our GMT-offset is +6, w/o any daylight saving.
+
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Kyrgyz  1992    1996    -       Apr     Sun>=7  0:00s   1:00    S
+Rule   Kyrgyz  1992    1996    -       Sep     lastSun 0:00    0       -
+Rule   Kyrgyz  1997    2005    -       Mar     lastSun 2:30    1:00    S
+Rule   Kyrgyz  1997    2004    -       Oct     lastSun 2:30    0       -
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Asia/Bishkek    4:58:24 -       LMT     1924 May  2
+                       5:00    -       FRUT    1930 Jun 21 # Frunze Time
+                       6:00 RussiaAsia FRU%sT  1991 Mar 31 2:00s
+                       5:00    1:00    FRUST   1991 Aug 31 2:00 # independence
+                       5:00    Kyrgyz  KG%sT   2005 Aug 12    # Kyrgyzstan Time
+                       6:00    -       KGT
+
+###############################################################################
+
+# Korea (North and South)
+
+# From Annie I. Bang (2006-07-10) in
+# <http://www.koreaherald.co.kr/SITE/data/html_dir/2006/07/10/200607100012.asp>:
+# The Ministry of Commerce, Industry and Energy has already
+# commissioned a research project [to reintroduce DST] and has said
+# the system may begin as early as 2008....  Korea ran a daylight
+# saving program from 1949-61 but stopped it during the 1950-53 Korean War.
+
+# From Shanks & Pottenger:
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   ROK     1960    only    -       May     15      0:00    1:00    D
+Rule   ROK     1960    only    -       Sep     13      0:00    0       S
+Rule   ROK     1987    1988    -       May     Sun>=8  0:00    1:00    D
+Rule   ROK     1987    1988    -       Oct     Sun>=8  0:00    0       S
+
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Asia/Seoul      8:27:52 -       LMT     1890
+                       8:30    -       KST     1904 Dec
+                       9:00    -       KST     1928
+                       8:30    -       KST     1932
+                       9:00    -       KST     1954 Mar 21
+                       8:00    ROK     K%sT    1961 Aug 10
+                       8:30    -       KST     1968 Oct
+                       9:00    ROK     K%sT
+Zone   Asia/Pyongyang  8:23:00 -       LMT     1890
+                       8:30    -       KST     1904 Dec
+                       9:00    -       KST     1928
+                       8:30    -       KST     1932
+                       9:00    -       KST     1954 Mar 21
+                       8:00    -       KST     1961 Aug 10
+                       9:00    -       KST
+
+###############################################################################
+
+# Kuwait
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+# From the Arab Times (2007-03-14):
+# The Civil Service Commission (CSC) has approved a proposal forwarded
+# by MP Ahmad Baqer on implementing the daylight saving time (DST) in
+# Kuwait starting from April until the end of Sept this year, reports Al-Anba.
+# <http://www.arabtimesonline.com/arabtimes/kuwait/Viewdet.asp?ID=9950>.
+# From Paul Eggert (2007-03-29):
+# We don't know the details, or whether the approval means it'll happen,
+# so for now we assume no DST.
+Zone   Asia/Kuwait     3:11:56 -       LMT     1950
+                       3:00    -       AST
+
+# Laos
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Asia/Vientiane  6:50:24 -       LMT     1906 Jun  9 # or Viangchan
+                       7:06:20 -       SMT     1911 Mar 11 0:01 # Saigon MT?
+                       7:00    -       ICT     1912 May
+                       8:00    -       ICT     1931 May
+                       7:00    -       ICT
+
+# Lebanon
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Lebanon 1920    only    -       Mar     28      0:00    1:00    S
+Rule   Lebanon 1920    only    -       Oct     25      0:00    0       -
+Rule   Lebanon 1921    only    -       Apr     3       0:00    1:00    S
+Rule   Lebanon 1921    only    -       Oct     3       0:00    0       -
+Rule   Lebanon 1922    only    -       Mar     26      0:00    1:00    S
+Rule   Lebanon 1922    only    -       Oct     8       0:00    0       -
+Rule   Lebanon 1923    only    -       Apr     22      0:00    1:00    S
+Rule   Lebanon 1923    only    -       Sep     16      0:00    0       -
+Rule   Lebanon 1957    1961    -       May     1       0:00    1:00    S
+Rule   Lebanon 1957    1961    -       Oct     1       0:00    0       -
+Rule   Lebanon 1972    only    -       Jun     22      0:00    1:00    S
+Rule   Lebanon 1972    1977    -       Oct     1       0:00    0       -
+Rule   Lebanon 1973    1977    -       May     1       0:00    1:00    S
+Rule   Lebanon 1978    only    -       Apr     30      0:00    1:00    S
+Rule   Lebanon 1978    only    -       Sep     30      0:00    0       -
+Rule   Lebanon 1984    1987    -       May     1       0:00    1:00    S
+Rule   Lebanon 1984    1991    -       Oct     16      0:00    0       -
+Rule   Lebanon 1988    only    -       Jun     1       0:00    1:00    S
+Rule   Lebanon 1989    only    -       May     10      0:00    1:00    S
+Rule   Lebanon 1990    1992    -       May     1       0:00    1:00    S
+Rule   Lebanon 1992    only    -       Oct     4       0:00    0       -
+Rule   Lebanon 1993    max     -       Mar     lastSun 0:00    1:00    S
+Rule   Lebanon 1993    1998    -       Sep     lastSun 0:00    0       -
+Rule   Lebanon 1999    max     -       Oct     lastSun 0:00    0       -
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Asia/Beirut     2:22:00 -       LMT     1880
+                       2:00    Lebanon EE%sT
+
+# Malaysia
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   NBorneo 1935    1941    -       Sep     14      0:00    0:20    TS # one-Third Summer
+Rule   NBorneo 1935    1941    -       Dec     14      0:00    0       -
+#
+# peninsular Malaysia
+# The data here are taken from Mok Ly Yng (2003-10-30)
+# <http://www.math.nus.edu.sg/aslaksen/teaching/timezone.html>.
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone Asia/Kuala_Lumpur 6:46:46 -       LMT     1901 Jan  1
+                       6:55:25 -       SMT     1905 Jun  1 # Singapore M.T.
+                       7:00    -       MALT    1933 Jan  1 # Malaya Time
+                       7:00    0:20    MALST   1936 Jan  1
+                       7:20    -       MALT    1941 Sep  1
+                       7:30    -       MALT    1942 Feb 16
+                       9:00    -       JST     1945 Sep 12
+                       7:30    -       MALT    1982 Jan  1
+                       8:00    -       MYT     # Malaysia Time
+# Sabah & Sarawak
+# From Paul Eggert (2006-03-22):
+# The data here are mostly from Shanks & Pottenger, but the 1942, 1945 and 1982
+# transition dates are from Mok Ly Yng.
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone Asia/Kuching      7:21:20 -       LMT     1926 Mar
+                       7:30    -       BORT    1933    # Borneo Time
+                       8:00    NBorneo BOR%sT  1942 Feb 16
+                       9:00    -       JST     1945 Sep 12
+                       8:00    -       BORT    1982 Jan  1
+                       8:00    -       MYT
+
+# Maldives
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Indian/Maldives 4:54:00 -       LMT     1880    # Male
+                       4:54:00 -       MMT     1960    # Male Mean Time
+                       5:00    -       MVT             # Maldives Time
+
+# Mongolia
+
+# Shanks & Pottenger say that Mongolia has three time zones, but
+# usno1995 and the CIA map Standard Time Zones of the World (2005-03)
+# both say that it has just one.
+
+# From Oscar van Vlijmen (1999-12-11):
+# <a href="http://www.mongoliatourism.gov.mn/general.htm">
+# General Information Mongolia
+# </a> (1999-09)
+# "Time: Mongolia has two time zones. Three westernmost provinces of
+# Bayan-Ulgii, Uvs, and Hovd are one hour earlier than the capital city, and
+# the rest of the country follows the Ulaanbaatar time, which is UTC/GMT plus
+# eight hours."
+
+# From Rives McDow (1999-12-13):
+# Mongolia discontinued the use of daylight savings time in 1999; 1998
+# being the last year it was implemented.  The dates of implementation I am
+# unsure of, but most probably it was similar to Russia, except for the time
+# of implementation may have been different....
+# Some maps in the past have indicated that there was an additional time
+# zone in the eastern part of Mongolia, including the provinces of Dornod,
+# Suhbaatar, and possibly Khentij.
+
+# From Paul Eggert (1999-12-15):
+# Naming and spelling is tricky in Mongolia.
+# We'll use Hovd (also spelled Chovd and Khovd) to represent the west zone;
+# the capital of the Hovd province is sometimes called Hovd, sometimes Dund-Us,
+# and sometimes Jirgalanta (with variant spellings), but the name Hovd
+# is good enough for our purposes.
+
+# From Rives McDow (2001-05-13):
+# In addition to Mongolia starting daylight savings as reported earlier
+# (adopted DST on 2001-04-27 02:00 local time, ending 2001-09-28),
+# there are three time zones.
+#
+# Provinces [at 7:00]: Bayan-ulgii, Uvs, Khovd, Zavkhan, Govi-Altai
+# Provinces [at 8:00]: Khovsgol, Bulgan, Arkhangai, Khentii, Tov,
+#      Bayankhongor, Ovorkhangai, Dundgovi, Dornogovi, Omnogovi
+# Provinces [at 9:00]: Dornod, Sukhbaatar
+#
+# [The province of Selenge is omitted from the above lists.]
+
+# From Ganbold Ts., Ulaanbaatar (2004-04-17):
+# Daylight saving occurs at 02:00 local time last Saturday of March.
+# It will change back to normal at 02:00 local time last Saturday of
+# September.... As I remember this rule was changed in 2001.
+#
+# From Paul Eggert (2004-04-17):
+# For now, assume Rives McDow's informant got confused about Friday vs
+# Saturday, and that his 2001 dates should have 1 added to them.
+
+# From Paul Eggert (2005-07-26):
+# We have wildly conflicting information about Mongolia's time zones.
+# Bill Bonnet (2005-05-19) reports that the US Embassy in Ulaanbaatar says
+# there is only one time zone and that DST is observed, citing Microsoft
+# Windows XP as the source.  Risto Nykanen (2005-05-16) reports that
+# travelmongolia.org says there are two time zones (UTC+7, UTC+8) with no DST.
+# Oscar van Vlijmen (2005-05-20) reports that the Mongolian Embassy in
+# Washington, DC says there are two time zones, with DST observed.
+# He also found
+# <http://ubpost.mongolnews.mn/index.php?subaction=showcomments&id=1111634894&archive=&start_from=&ucat=1&>
+# which also says that there is DST, and which has a comment by "Toddius"
+# (2005-03-31 06:05 +0700) saying "Mongolia actually has 3.5 time zones.
+# The West (OLGII) is +7 GMT, most of the country is ULAT is +8 GMT
+# and some Eastern provinces are +9 GMT but Sukhbaatar Aimag is SUHK +8.5 GMT.
+# The SUKH timezone is new this year, it is one of the few things the
+# parliament passed during the tumultuous winter session."
+# For now, let's ignore this information, until we have more confirmation.
+
+# From Ganbold Ts. (2007-02-26):
+# Parliament of Mongolia has just changed the daylight-saving rule in February.
+# They decided not to adopt daylight-saving time....
+# http://www.mongolnews.mn/index.php?module=unuudur&sec=view&id=15742
+
+# From Deborah Goldsmith (2008-03-30):
+# We received a bug report claiming that the tz database UTC offset for
+# Asia/Choibalsan (GMT+09:00) is incorrect, and that it should be GMT
+# +08:00 instead. Different sources appear to disagree with the tz
+# database on this, e.g.:
+#
+# <a href="http://www.timeanddate.com/worldclock/city.html?n=1026">
+# http://www.timeanddate.com/worldclock/city.html?n=1026
+# </a>
+# <a href="http://www.worldtimeserver.com/current_time_in_MN.aspx">
+# http://www.worldtimeserver.com/current_time_in_MN.aspx
+# </a>
+#
+# both say GMT+08:00.
+
+# From Steffen Thorsen (2008-03-31):
+# eznis airways, which operates several domestic flights, has a flight
+# schedule here:
+# <a href="http://www.eznis.com/Container.jsp?id=112">
+# http://www.eznis.com/Container.jsp?id=112
+# </a>
+# (click the English flag for English)
+#
+# There it appears that flights between Choibalsan and Ulaanbatar arrive
+# about 1:35 - 1:50 hours later in local clock time, no matter the
+# direction, while Ulaanbaatar-Khvod takes 2 hours in the Eastern
+# direction and 3:35 back, which indicates that Ulaanbatar and Khvod are
+# in different time zones (like we know about), while Choibalsan and
+# Ulaanbatar are in the same time zone (correction needed).
+
+# From Arthur David Olson (2008-05-19):
+# Assume that Choibalsan is indeed offset by 8:00.
+# XXX--in the absence of better information, assume that transition
+# was at the start of 2008-03-31 (the day of Steffen Thorsen's report);
+# this is almost surely wrong.
+
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Mongol  1983    1984    -       Apr     1       0:00    1:00    S
+Rule   Mongol  1983    only    -       Oct     1       0:00    0       -
+# Shanks & Pottenger and IATA SSIM say 1990s switches occurred at 00:00,
+# but McDow says the 2001 switches occurred at 02:00.  Also, IATA SSIM
+# (1996-09) says 1996-10-25.  Go with Shanks & Pottenger through 1998.
+#
+# Shanks & Pottenger say that the Sept. 1984 through Sept. 1990 switches
+# in Choibalsan (more precisely, in Dornod and Sukhbaatar) took place
+# at 02:00 standard time, not at 00:00 local time as in the rest of
+# the country.  That would be odd, and possibly is a result of their
+# correction of 02:00 (in the previous edition) not being done correctly
+# in the latest edition; so ignore it for now.
+
+Rule   Mongol  1985    1998    -       Mar     lastSun 0:00    1:00    S
+Rule   Mongol  1984    1998    -       Sep     lastSun 0:00    0       -
+# IATA SSIM (1999-09) says Mongolia no longer observes DST.
+Rule   Mongol  2001    only    -       Apr     lastSat 2:00    1:00    S
+Rule   Mongol  2001    2006    -       Sep     lastSat 2:00    0       -
+Rule   Mongol  2002    2006    -       Mar     lastSat 2:00    1:00    S
+
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+# Hovd, a.k.a. Chovd, Dund-Us, Dzhargalant, Khovd, Jirgalanta
+Zone   Asia/Hovd       6:06:36 -       LMT     1905 Aug
+                       6:00    -       HOVT    1978    # Hovd Time
+                       7:00    Mongol  HOV%sT
+# Ulaanbaatar, a.k.a. Ulan Bataar, Ulan Bator, Urga
+Zone   Asia/Ulaanbaatar 7:07:32 -      LMT     1905 Aug
+                       7:00    -       ULAT    1978    # Ulaanbaatar Time
+                       8:00    Mongol  ULA%sT
+# Choibalsan, a.k.a. Bajan Tuemen, Bajan Tumen, Chojbalsan,
+# Choybalsan, Sanbejse, Tchoibalsan
+Zone   Asia/Choibalsan 7:38:00 -       LMT     1905 Aug
+                       7:00    -       ULAT    1978
+                       8:00    -       ULAT    1983 Apr
+                       9:00    Mongol  CHO%sT  2008 Mar 31 # Choibalsan Time
+                       8:00    Mongol  CHO%sT
+
+# Nepal
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Asia/Kathmandu  5:41:16 -       LMT     1920
+                       5:30    -       IST     1986
+                       5:45    -       NPT     # Nepal Time
+
+# Oman
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Asia/Muscat     3:54:20 -       LMT     1920
+                       4:00    -       GST
+
+# Pakistan
+
+# From Rives McDow (2002-03-13):
+# I have been advised that Pakistan has decided to adopt dst on a
+# TRIAL basis for one year, starting 00:01 local time on April 7, 2002
+# and ending at 00:01 local time October 6, 2002.  This is what I was
+# told, but I believe that the actual time of change may be 00:00; the
+# 00:01 was to make it clear which day it was on.
+
+# From Paul Eggert (2002-03-15):
+# Jesper Norgaard found this URL:
+# http://www.pak.gov.pk/public/news/app/app06_dec.htm
+# (dated 2001-12-06) which says that the Cabinet adopted a scheme "to
+# advance the clocks by one hour on the night between the first
+# Saturday and Sunday of April and revert to the original position on
+# 15th October each year".  This agrees with McDow's 04-07 at 00:00,
+# but disagrees about the October transition, and makes it sound like
+# it's not on a trial basis.  Also, the "between the first Saturday
+# and Sunday of April" phrase, if taken literally, means that the
+# transition takes place at 00:00 on the first Sunday on or after 04-02.
+
+# From Paul Eggert (2003-02-09):
+# DAWN <http://www.dawn.com/2002/10/06/top13.htm> reported on 2002-10-05
+# that 2002 DST ended that day at midnight.  Go with McDow for now.
+
+# From Steffen Thorsen (2003-03-14):
+# According to http://www.dawn.com/2003/03/07/top15.htm
+# there will be no DST in Pakistan this year:
+#
+# ISLAMABAD, March 6: Information and Media Development Minister Sheikh
+# Rashid Ahmed on Thursday said the cabinet had reversed a previous
+# decision to advance clocks by one hour in summer and put them back by
+# one hour in winter with the aim of saving light hours and energy.
+#
+# The minister told a news conference that the experiment had rather
+# shown 8 per cent higher consumption of electricity.
+
+# From Alex Krivenyshev (2008-05-15):
+# 
+# Here is an article that Pakistan plan to introduce Daylight Saving Time 
+# on June 1, 2008 for 3 months.
+# 
+# "... The federal cabinet on Wednesday announced a new conservation plan to help 
+# reduce load shedding by approving the closure of commercial centres at 9pm and 
+# moving clocks forward by one hour for the next three months. 
+# ...."
+# 
+# <a href="http://www.worldtimezone.net/dst_news/dst_news_pakistan01.html">
+# http://www.worldtimezone.net/dst_news/dst_news_pakistan01.html
+# </a>
+# OR
+# <a href="http://www.dailytimes.com.pk/default.asp?page=2008%5C05%5C15%5Cstory_15-5-2008_pg1_4">
+# http://www.dailytimes.com.pk/default.asp?page=2008%5C05%5C15%5Cstory_15-5-2008_pg1_4
+# </a>
+
+# From Arthur David Olson (2008-05-19):
+# XXX--midnight transitions is a guess; 2008 only is a guess.
+
+# From Alexander Krivenyshev (2008-08-28):
+# Pakistan government has decided to keep the watches one-hour advanced
+# for another 2 months--plan to return to Standard Time on October 31
+# instead of August 31.
+#
+# <a href="http://www.worldtimezone.com/dst_news/dst_news_pakistan02.html">
+# http://www.worldtimezone.com/dst_news/dst_news_pakistan02.html
+# </a>
+# OR
+# <a href="http://dailymailnews.com/200808/28/news/dmbrn03.html">
+# http://dailymailnews.com/200808/28/news/dmbrn03.html
+# </a>
+
+# From Alexander Krivenyshev (2009-04-08):
+# Based on previous media reports that "... proposed plan to
+# advance clocks by one hour from May 1 will cause disturbance
+# to the working schedules rather than bringing discipline in
+# official working."
+# <a href="http://www.thenews.com.pk/daily_detail.asp?id=171280">
+# http://www.thenews.com.pk/daily_detail.asp?id=171280
+# </a>
+#
+# recent news that instead of May 2009 - Pakistan plan to
+# introduce DST from April 15, 2009
+#
+# FYI: Associated Press Of Pakistan
+# April 08, 2009
+# Cabinet okays proposal to advance clocks by one hour from April 15
+# <a href="http://www.app.com.pk/en_/index.php?option=com_content&task=view&id=73043&Itemid=1">
+# http://www.app.com.pk/en_/index.php?option=com_content&task=view&id=73043&Itemid=1
+# </a>
+#
+# or
+#
+# <a href="http://www.worldtimezone.com/dst_news/dst_news_pakistan05.html">
+# http://www.worldtimezone.com/dst_news/dst_news_pakistan05.html
+# </a>
+#
+# ....
+# The Federal Cabinet on Wednesday approved the proposal to
+# advance clocks in the country by one hour from April 15 to
+# conserve energy"
+
+# From Arthur David Olson (2009-04-10):
+# Assume for now that Pakistan will end DST in 2009 as it did in 2008.
+
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule Pakistan  2002    only    -       Apr     Sun>=2  0:01    1:00    S
+Rule Pakistan  2002    only    -       Oct     Sun>=2  0:01    0       -
+Rule Pakistan  2008    only    -       Jun     1       0:00    1:00    S
+Rule Pakistan  2008    only    -       Nov     1       0:00    0       -
+Rule Pakistan  2009    only    -       Apr     15      0:00    1:00    S
+Rule Pakistan  2009    only    -       Nov     1       0:00    0       -
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Asia/Karachi    4:28:12 -       LMT     1907
+                       5:30    -       IST     1942 Sep
+                       5:30    1:00    IST     1945 Oct 15
+                       5:30    -       IST     1951 Sep 30
+                       5:00    -       KART    1971 Mar 26 # Karachi Time
+                       5:00 Pakistan   PK%sT   # Pakistan Time
+
+# Palestine
+
+# From Amos Shapir (1998-02-15):
+#
+# From 1917 until 1948-05-15, all of Palestine, including the parts now
+# known as the Gaza Strip and the West Bank, was under British rule.
+# Therefore the rules given for Israel for that period, apply there too...
+#
+# The Gaza Strip was under Egyptian rule between 1948-05-15 until 1967-06-05
+# (except a short occupation by Israel from 1956-11 till 1957-03, but no
+# time zone was affected then).  It was never formally annexed to Egypt,
+# though.
+#
+# The rest of Palestine was under Jordanian rule at that time, formally
+# annexed in 1950 as the West Bank (and the word "Trans" was dropped from
+# the country's previous name of "the Hashemite Kingdom of the
+# Trans-Jordan").  So the rules for Jordan for that time apply.  Major
+# towns in that area are Nablus (Shchem), El-Halil (Hebron), Ramallah, and
+# East Jerusalem.
+#
+# Both areas were occupied by Israel in June 1967, but not annexed (except
+# for East Jerusalem).  They were on Israel time since then; there might
+# have been a Military Governor's order about time zones, but I'm not aware
+# of any (such orders may have been issued semi-annually whenever summer
+# time was in effect, but maybe the legal aspect of time was just neglected).
+#
+# The Palestinian Authority was established in 1993, and got hold of most
+# towns in the West Bank and Gaza by 1995.  I know that in order to
+# demonstrate...independence, they have been switching to
+# summer time and back on a different schedule than Israel's, but I don't
+# know when this was started, or what algorithm is used (most likely the
+# Jordanian one).
+#
+# To summarize, the table should probably look something like that:
+#
+# Area \ when | 1918-1947 | 1948-1967 | 1967-1995 | 1996-
+# ------------+-----------+-----------+-----------+-----------
+# Israel      | Zion      | Zion      | Zion      | Zion
+# West bank   | Zion      | Jordan    | Zion      | Jordan
+# Gaza        | Zion      | Egypt     | Zion      | Jordan
+#
+# I guess more info may be available from the PA's web page (if/when they
+# have one).
+
+# From Paul Eggert (2006-03-22):
+# Shanks & Pottenger write that Gaza did not observe DST until 1957, but go
+# with Shapir and assume that it observed DST from 1940 through 1947,
+# and that it used Jordanian rules starting in 1996.
+# We don't yet need a separate entry for the West Bank, since
+# the only differences between it and Gaza that we know about
+# occurred before our cutoff date of 1970.
+# However, as we get more information, we may need to add entries
+# for parts of the West Bank as they transitioned from Israel's rules
+# to Palestine's rules.  If you have more info about this, please
+# send it to tz@elsie.nci.nih.gov for incorporation into future editions.
+
+# From IINS News Service - Israel - 1998-03-23 10:38:07 Israel time,
+# forwarded by Ephraim Silverberg:
+#
+# Despite the fact that Israel changed over to daylight savings time
+# last week, the PLO Authority (PA) has decided not to turn its clocks
+# one-hour forward at this time.  As a sign of independence from Israeli rule,
+# the PA has decided to implement DST in April.
+
+# From Paul Eggert (1999-09-20):
+# Daoud Kuttab writes in
+# <a href="http://www.jpost.com/com/Archive/22.Apr.1999/Opinion/Article-2.html">
+# Holiday havoc
+# </a> (Jerusalem Post, 1999-04-22) that
+# the Palestinian National Authority changed to DST on 1999-04-15.
+# I vaguely recall that they switch back in October (sorry, forgot the source).
+# For now, let's assume that the spring switch was at 24:00,
+# and that they switch at 0:00 on the 3rd Fridays of April and October.
+
+# From Paul Eggert (2005-11-22):
+# Starting 2004 transitions are from Steffen Thorsen's web site timeanddate.com.
+
+# From Steffen Thorsen (2005-11-23):
+# A user from Gaza reported that Gaza made the change early because of
+# the Ramadan.  Next year Ramadan will be even earlier, so I think
+# there is a good chance next year's end date will be around two weeks
+# earlier--the same goes for Jordan.
+
+# From Steffen Thorsen (2006-08-17):
+# I was informed by a user in Bethlehem that in Bethlehem it started the
+# same day as Israel, and after checking with other users in the area, I
+# was informed that they started DST one day after Israel.  I was not
+# able to find any authoritative sources at the time, nor details if
+# Gaza changed as well, but presumed Gaza to follow the same rules as
+# the West Bank.
+
+# From Steffen Thorsen (2006-09-26):
+# according to the Palestine News Network (2006-09-19):
+# http://english.pnn.ps/index.php?option=com_content&task=view&id=596&Itemid=5
+# > The Council of Ministers announced that this year its winter schedule
+# > will begin early, as of midnight Thursday.  It is also time to turn
+# > back the clocks for winter.  Friday will begin an hour late this week.
+# I guess it is likely that next year's date will be moved as well,
+# because of the Ramadan.
+
+# From Jesper Norgaard Welen (2007-09-18):
+# According to Steffen Thorsen's web site the Gaza Strip and the rest of the
+# Palestinian territories left DST early on 13.th. of September at 2:00.
+
+# From Paul Eggert (2007-09-20):
+# My understanding is that Gaza and the West Bank disagree even over when
+# the weekend is (Thursday+Friday versus Friday+Saturday), so I'd be a bit
+# surprised if they agreed about DST.  But for now, assume they agree.
+# For lack of better information, predict that future changes will be
+# the 2nd Thursday of September at 02:00.
+
+# From Alexander Krivenyshev (2008-08-28):
+# Here is an article, that Mideast running on different clocks at Ramadan.
+#
+# Gaza Strip (as Egypt) ended DST at midnight Thursday (Aug 28, 2008), while
+# the West Bank will end Daylight Saving Time at midnight Sunday (Aug 31, 2008).
+#
+# <a href="http://www.guardian.co.uk/world/feedarticle/7759001">
+# http://www.guardian.co.uk/world/feedarticle/7759001
+# </a>
+# <a href="http://www.abcnews.go.com/International/wireStory?id=5676087">
+# http://www.abcnews.go.com/International/wireStory?id=5676087
+# </a>
+# or
+# <a href="http://www.worldtimezone.com/dst_news/dst_news_gazastrip01.html">
+# http://www.worldtimezone.com/dst_news/dst_news_gazastrip01.html
+# </a>
+
+# From Alexander Krivenyshev (2009-03-26):
+# According to the Palestine News Network (arabic.pnn.ps), Palestinian
+# government decided to start Daylight Time on Thursday night March
+# 26 and continue until the night of 27 September 2009.
+#
+# (in Arabic)
+# <a href="http://arabic.pnn.ps/index.php?option=com_content&task=view&id=50850">
+# http://arabic.pnn.ps/index.php?option=com_content&task=view&id=50850
+# </a>
+#
+# or
+# (English translation)
+# <a href="http://www.worldtimezone.com/dst_news/dst_news_westbank01.html">
+# http://www.worldtimezone.com/dst_news/dst_news_westbank01.html
+# </a>
+
+# The rules for Egypt are stolen from the `africa' file.
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule EgyptAsia 1957    only    -       May     10      0:00    1:00    S
+Rule EgyptAsia 1957    1958    -       Oct      1      0:00    0       -
+Rule EgyptAsia 1958    only    -       May      1      0:00    1:00    S
+Rule EgyptAsia 1959    1967    -       May      1      1:00    1:00    S
+Rule EgyptAsia 1959    1965    -       Sep     30      3:00    0       -
+Rule EgyptAsia 1966    only    -       Oct      1      3:00    0       -
+
+Rule Palestine 1999    2005    -       Apr     Fri>=15 0:00    1:00    S
+Rule Palestine 1999    2003    -       Oct     Fri>=15 0:00    0       -
+Rule Palestine 2004    only    -       Oct      1      1:00    0       -
+Rule Palestine 2005    only    -       Oct      4      2:00    0       -
+Rule Palestine 2006    2008    -       Apr      1      0:00    1:00    S
+Rule Palestine 2006    only    -       Sep     22      0:00    0       -
+Rule Palestine 2007    only    -       Sep     Thu>=8  2:00    0       -
+Rule Palestine 2008    only    -       Aug     lastFri 2:00    0       -
+Rule Palestine 2009    max     -       Mar     lastFri 0:00    1:00    S
+Rule Palestine 2009    max     -       Sep     lastMon 2:00    0       -
+
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Asia/Gaza       2:17:52 -       LMT     1900 Oct
+                       2:00    Zion    EET     1948 May 15
+                       2:00 EgyptAsia  EE%sT   1967 Jun  5
+                       2:00    Zion    I%sT    1996
+                       2:00    Jordan  EE%sT   1999
+                       2:00 Palestine  EE%sT
+
+# Paracel Is
+# no information
+
+# Philippines
+# On 1844-08-16, Narciso Claveria, governor-general of the
+# Philippines, issued a proclamation announcing that 1844-12-30 was to
+# be immediately followed by 1845-01-01.  Robert H. van Gent has a
+# transcript of the decree in <http://www.phys.uu.nl/~vgent/idl/idl.htm>.
+# The rest of the data are from Shanks & Pottenger.
+
+# From Paul Eggert (2006-04-25):
+# Tomorrow's Manila Standard reports that the Philippines Department of
+# Trade and Industry is considering adopting DST this June when the
+# rainy season begins.  See
+# <http://www.manilastandardtoday.com/?page=politics02_april26_2006>.
+# For now, we'll ignore this, since it's not definite and we lack details.
+#
+# From Jesper Norgaard Welen (2006-04-26):
+# ... claims that Philippines had DST last time in 1990:
+# http://story.philippinetimes.com/p.x/ct/9/id/145be20cc6b121c0/cid/3e5bbccc730d258c/
+# [a story dated 2006-04-25 by Cris Larano of Dow Jones Newswires,
+# but no details]
+
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Phil    1936    only    -       Nov     1       0:00    1:00    S
+Rule   Phil    1937    only    -       Feb     1       0:00    0       -
+Rule   Phil    1954    only    -       Apr     12      0:00    1:00    S
+Rule   Phil    1954    only    -       Jul     1       0:00    0       -
+Rule   Phil    1978    only    -       Mar     22      0:00    1:00    S
+Rule   Phil    1978    only    -       Sep     21      0:00    0       -
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Asia/Manila     -15:56:00 -     LMT     1844 Dec 31
+                       8:04:00 -       LMT     1899 May 11
+                       8:00    Phil    PH%sT   1942 May
+                       9:00    -       JST     1944 Nov
+                       8:00    Phil    PH%sT
+
+# Qatar
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Asia/Qatar      3:26:08 -       LMT     1920    # Al Dawhah / Doha
+                       4:00    -       GST     1972 Jun
+                       3:00    -       AST
+
+# Saudi Arabia
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Asia/Riyadh     3:06:52 -       LMT     1950
+                       3:00    -       AST
+
+# Singapore
+# The data here are taken from Mok Ly Yng (2003-10-30)
+# <http://www.math.nus.edu.sg/aslaksen/teaching/timezone.html>.
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Asia/Singapore  6:55:25 -       LMT     1901 Jan  1
+                       6:55:25 -       SMT     1905 Jun  1 # Singapore M.T.
+                       7:00    -       MALT    1933 Jan  1 # Malaya Time
+                       7:00    0:20    MALST   1936 Jan  1
+                       7:20    -       MALT    1941 Sep  1
+                       7:30    -       MALT    1942 Feb 16
+                       9:00    -       JST     1945 Sep 12
+                       7:30    -       MALT    1965 Aug  9 # independence
+                       7:30    -       SGT     1982 Jan  1 # Singapore Time
+                       8:00    -       SGT
+
+# Spratly Is
+# no information
+
+# Sri Lanka
+# From Paul Eggert (1996-09-03):
+# "Sri Lanka advances clock by an hour to avoid blackout"
+# (www.virtual-pc.com/lankaweb/news/items/240596-2.html, 1996-05-24,
+# no longer available as of 1999-08-17)
+# reported ``the country's standard time will be put forward by one hour at
+# midnight Friday (1830 GMT) `in the light of the present power crisis'.''
+#
+# From Dharmasiri Senanayake, Sri Lanka Media Minister (1996-10-24), as quoted
+# by Shamindra in
+# <a href="news:54rka5$m5h@mtinsc01-mgt.ops.worldnet.att.net">
+# Daily News - Hot News Section (1996-10-26)
+# </a>:
+# With effect from 12.30 a.m. on 26th October 1996
+# Sri Lanka will be six (06) hours ahead of GMT.
+
+# From Jesper Norgaard Welen (2006-04-14), quoting Sri Lanka News Online
+# <http://news.sinhalaya.com/wmview.php?ArtID=11002> (2006-04-13):
+# 0030 hrs on April 15, 2006 (midnight of April 14, 2006 +30 minutes)
+# at present, become 2400 hours of April 14, 2006 (midnight of April 14, 2006).
+
+# From Peter Apps and Ranga Sirila of Reuters (2006-04-12) in:
+# <http://today.reuters.co.uk/news/newsArticle.aspx?type=scienceNews&storyID=2006-04-12T172228Z_01_COL295762_RTRIDST_0_SCIENCE-SRILANKA-TIME-DC.XML>
+# [The Tamil Tigers] never accepted the original 1996 time change and simply
+# kept their clocks set five and a half hours ahead of Greenwich Mean
+# Time (GMT), in line with neighbor India.
+# From Paul Eggert (2006-04-18):
+# People who live in regions under Tamil control can use [TZ='Asia/Kolkata'],
+# as that zone has agreed with the Tamil areas since our cutoff date of 1970.
+
+# From K Sethu (2006-04-25):
+# I think the abbreviation LKT originated from the world of computers at
+# the time of or subsequent to the time zone changes by SL Government
+# twice in 1996 and probably SL Government or its standardization
+# agencies never declared an abbreviation as a national standard.
+#
+# I recollect before the recent change the government annoucemments
+# mentioning it as simply changing Sri Lanka Standard Time or Sri Lanka
+# Time and no mention was made about the abbreviation.
+#
+# If we look at Sri Lanka Department of Government's "Official News
+# Website of Sri Lanka" ... http://www.news.lk/ we can see that they
+# use SLT as abbreviation in time stamp at the beginning of each news
+# item....
+#
+# Within Sri Lanka I think LKT is well known among computer users and
+# adminsitrators.  In my opinion SLT may not be a good choice because the
+# nation's largest telcom / internet operator Sri Lanka Telcom is well
+# known by that abbreviation - simply as SLT (there IP domains are
+# slt.lk and sltnet.lk).
+#
+# But if indeed our government has adopted SLT as standard abbreviation
+# (that we have not known so far) then  it is better that it be used for
+# all computers.
+
+# From Paul Eggert (2006-04-25):
+# One possibility is that we wait for a bit for the dust to settle down
+# and then see what people actually say in practice.
+
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Asia/Colombo    5:19:24 -       LMT     1880
+                       5:19:32 -       MMT     1906    # Moratuwa Mean Time
+                       5:30    -       IST     1942 Jan  5
+                       5:30    0:30    IHST    1942 Sep
+                       5:30    1:00    IST     1945 Oct 16 2:00
+                       5:30    -       IST     1996 May 25 0:00
+                       6:30    -       LKT     1996 Oct 26 0:30
+                       6:00    -       LKT     2006 Apr 15 0:30
+                       5:30    -       IST
+
+# Syria
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Syria   1920    1923    -       Apr     Sun>=15 2:00    1:00    S
+Rule   Syria   1920    1923    -       Oct     Sun>=1  2:00    0       -
+Rule   Syria   1962    only    -       Apr     29      2:00    1:00    S
+Rule   Syria   1962    only    -       Oct     1       2:00    0       -
+Rule   Syria   1963    1965    -       May     1       2:00    1:00    S
+Rule   Syria   1963    only    -       Sep     30      2:00    0       -
+Rule   Syria   1964    only    -       Oct     1       2:00    0       -
+Rule   Syria   1965    only    -       Sep     30      2:00    0       -
+Rule   Syria   1966    only    -       Apr     24      2:00    1:00    S
+Rule   Syria   1966    1976    -       Oct     1       2:00    0       -
+Rule   Syria   1967    1978    -       May     1       2:00    1:00    S
+Rule   Syria   1977    1978    -       Sep     1       2:00    0       -
+Rule   Syria   1983    1984    -       Apr     9       2:00    1:00    S
+Rule   Syria   1983    1984    -       Oct     1       2:00    0       -
+Rule   Syria   1986    only    -       Feb     16      2:00    1:00    S
+Rule   Syria   1986    only    -       Oct     9       2:00    0       -
+Rule   Syria   1987    only    -       Mar     1       2:00    1:00    S
+Rule   Syria   1987    1988    -       Oct     31      2:00    0       -
+Rule   Syria   1988    only    -       Mar     15      2:00    1:00    S
+Rule   Syria   1989    only    -       Mar     31      2:00    1:00    S
+Rule   Syria   1989    only    -       Oct     1       2:00    0       -
+Rule   Syria   1990    only    -       Apr     1       2:00    1:00    S
+Rule   Syria   1990    only    -       Sep     30      2:00    0       -
+Rule   Syria   1991    only    -       Apr      1      0:00    1:00    S
+Rule   Syria   1991    1992    -       Oct      1      0:00    0       -
+Rule   Syria   1992    only    -       Apr      8      0:00    1:00    S
+Rule   Syria   1993    only    -       Mar     26      0:00    1:00    S
+Rule   Syria   1993    only    -       Sep     25      0:00    0       -
+# IATA SSIM (1998-02) says 1998-04-02;
+# (1998-09) says 1999-03-29 and 1999-09-29; (1999-02) says 1999-04-02,
+# 2000-04-02, and 2001-04-02; (1999-09) says 2000-03-31 and 2001-03-31;
+# (2006) says 2006-03-31 and 2006-09-22;
+# for now ignore all these claims and go with Shanks & Pottenger,
+# except for the 2006-09-22 claim (which seems right for Ramadan).
+Rule   Syria   1994    1996    -       Apr      1      0:00    1:00    S
+Rule   Syria   1994    2005    -       Oct      1      0:00    0       -
+Rule   Syria   1997    1998    -       Mar     lastMon 0:00    1:00    S
+Rule   Syria   1999    2006    -       Apr      1      0:00    1:00    S
+# From Stephen Colebourne (2006-09-18):
+# According to IATA data, Syria will change DST on 21st September [21:00 UTC]
+# this year [only]....  This is probably related to Ramadan, like Egypt.
+Rule   Syria   2006    only    -       Sep     22      0:00    0       -
+# From Paul Eggert (2007-03-29):
+# Today the AP reported "Syria will switch to summertime at midnight Thursday."
+# http://www.iht.com/articles/ap/2007/03/29/africa/ME-GEN-Syria-Time-Change.php
+Rule   Syria   2007    only    -       Mar     lastFri 0:00    1:00    S
+# From Jesper Norgard (2007-10-27):
+# The sister center ICARDA of my work CIMMYT is confirming that Syria DST will
+# not take place 1.st November at 0:00 o'clock but 1.st November at 24:00 or
+# rather Midnight between Thursday and Friday. This does make more sence than
+# having it between Wednesday and Thursday (two workdays in Syria) since the
+# weekend in Syria is not Saturday and Sunday, but Friday and Saturday. So now
+# it is implemented at midnight of the last workday before weekend...
+# 
+# From Steffen Thorsen (2007-10-27):
+# Jesper Norgaard Welen wrote:
+# 
+# > "Winter local time in Syria will be observed at midnight of Thursday 1
+# > November 2007, and the clock will be put back 1 hour."
+# 
+# I found confirmation on this in this gov.sy-article (Arabic):
+# http://wehda.alwehda.gov.sy/_print_veiw.asp?FileName=12521710520070926111247
+# 
+# which using Google's translate tools says:
+# Council of Ministers also approved the commencement of work on 
+# identifying the winter time as of Friday, 2/11/2007 where the 60th 
+# minute delay at midnight Thursday 1/11/2007.
+Rule   Syria   2007    only    -       Nov      Fri>=1 0:00    0       -
+
+# From Stephen Colebourne (2008-03-17):
+# For everyone's info, I saw an IATA time zone change for [Syria] for
+# this month (March 2008) in the last day or so...This is the data IATA
+# are now using:
+# Country     Time Standard   --- DST Start ---   --- DST End ---  DST
+# Name        Zone Variation   Time    Date        Time    Date
+# Variation
+# Syrian Arab
+# Republic    SY    +0200      2200  03APR08       2100  30SEP08   +0300
+#                              2200  02APR09       2100  30SEP09   +0300
+#                              2200  01APR10       2100  30SEP10   +0300
+
+# From Arthur David Olson (2008-03-17):
+# Here's a link to English-language coverage by the Syrian Arab News
+# Agency (SANA)...
+# <a href="http://www.sana.sy/eng/21/2008/03/11/165173.htm">
+# http://www.sana.sy/eng/21/2008/03/11/165173.htm
+# </a>...which reads (in part) "The Cabinet approved the suggestion of the
+# Ministry of Electricity to begin daylight savings time on Friday April
+# 4th, advancing clocks one hour ahead on midnight of Thursday April 3rd."
+# Since Syria is two hours east of UTC, the 2200 and 2100 transition times
+# shown above match up with midnight in Syria.
+
+# From Arthur David Olson (2008-03-18):
+# My buest guess at a Syrian rule is "the Friday nearest April 1";
+# coding that involves either using a "Mar Fri>=29" construct that old time zone
+# compilers can't handle  or having multiple Rules (a la Israel).
+# For now, use "Apr Fri>=1", and go with IATA on a uniform Sep 30 end.
+
+# From Steffen Thorsen (2008-10-07):
+# Syria has now officially decided to end DST on 2008-11-01 this year,
+# according to the following article in the Syrian Arab News Agency (SANA).
+#
+# The article is in Arabic, and seems to tell that they will go back to
+# winter time on 2008-11-01 at 00:00 local daylight time (delaying/setting
+# clocks back 60 minutes).
+#
+# <a href="http://sana.sy/ara/2/2008/10/07/195459.htm">
+# http://sana.sy/ara/2/2008/10/07/195459.htm
+# </a>
+
+# From Steffen Thorsen (2009-03-19):
+# Syria will start DST on 2009-03-27 00:00 this year according to many sources,
+# two examples:
+#
+# <a href="http://www.sana.sy/eng/21/2009/03/17/217563.htm">
+# http://www.sana.sy/eng/21/2009/03/17/217563.htm
+# </a>
+# (English, Syrian Arab News # Agency)
+# <a href="http://thawra.alwehda.gov.sy/_View_news2.asp?FileName=94459258720090318012209">
+# http://thawra.alwehda.gov.sy/_View_news2.asp?FileName=94459258720090318012209
+# </a>
+# (Arabic, gov-site)
+#
+# We have not found any sources saying anything about when DST ends this year.
+#
+# Our summary
+# <a href="http://www.timeanddate.com/news/time/syria-dst-starts-march-27-2009.html">
+# http://www.timeanddate.com/news/time/syria-dst-starts-march-27-2009.html
+# </a>
+
+Rule   Syria   2008    only    -       Apr     Fri>=1  0:00    1:00    S
+Rule   Syria   2008    max     -       Nov     1       0:00    0       -
+Rule   Syria   2009    max     -       Mar     lastFri 0:00    1:00    S
+
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Asia/Damascus   2:25:12 -       LMT     1920    # Dimashq
+                       2:00    Syria   EE%sT
+
+# Tajikistan
+# From Shanks & Pottenger.
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Asia/Dushanbe   4:35:12 -       LMT     1924 May  2
+                       5:00    -       DUST    1930 Jun 21 # Dushanbe Time
+                       6:00 RussiaAsia DUS%sT  1991 Mar 31 2:00s
+                       5:00    1:00    DUSST   1991 Sep  9 2:00s
+                       5:00    -       TJT                 # Tajikistan Time
+
+# Thailand
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Asia/Bangkok    6:42:04 -       LMT     1880
+                       6:42:04 -       BMT     1920 Apr # Bangkok Mean Time
+                       7:00    -       ICT
+
+# Turkmenistan
+# From Shanks & Pottenger.
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Asia/Ashgabat   3:53:32 -       LMT     1924 May  2 # or Ashkhabad
+                       4:00    -       ASHT    1930 Jun 21 # Ashkhabad Time
+                       5:00 RussiaAsia ASH%sT  1991 Mar 31 2:00
+                       4:00 RussiaAsia ASH%sT  1991 Oct 27 # independence
+                       4:00 RussiaAsia TM%sT   1992 Jan 19 2:00
+                       5:00    -       TMT
+
+# United Arab Emirates
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Asia/Dubai      3:41:12 -       LMT     1920
+                       4:00    -       GST
+
+# Uzbekistan
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Asia/Samarkand  4:27:12 -       LMT     1924 May  2
+                       4:00    -       SAMT    1930 Jun 21 # Samarkand Time
+                       5:00    -       SAMT    1981 Apr  1
+                       5:00    1:00    SAMST   1981 Oct  1
+                       6:00    -       TAST    1982 Apr  1 # Tashkent Time
+                       5:00 RussiaAsia SAM%sT  1991 Sep  1 # independence
+                       5:00 RussiaAsia UZ%sT   1992
+                       5:00    -       UZT
+Zone   Asia/Tashkent   4:37:12 -       LMT     1924 May  2
+                       5:00    -       TAST    1930 Jun 21 # Tashkent Time
+                       6:00 RussiaAsia TAS%sT  1991 Mar 31 2:00
+                       5:00 RussiaAsia TAS%sT  1991 Sep  1 # independence
+                       5:00 RussiaAsia UZ%sT   1992
+                       5:00    -       UZT
+
+# Vietnam
+
+# From Arthur David Olson (2008-03-18):
+# The English-language name of Vietnam's most populous city is "Ho Chi Min City";
+# we use Ho_Chi_Minh below to avoid a name of more than 14 characters.
+
+# From Shanks & Pottenger:
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Asia/Ho_Chi_Minh        7:06:40 -       LMT     1906 Jun  9
+                       7:06:20 -       SMT     1911 Mar 11 0:01 # Saigon MT?
+                       7:00    -       ICT     1912 May
+                       8:00    -       ICT     1931 May
+                       7:00    -       ICT
+
+# Yemen
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Asia/Aden       3:00:48 -       LMT     1950
+                       3:00    -       AST
diff --git a/extra/zoneinfo/australasia b/extra/zoneinfo/australasia
new file mode 100644 (file)
index 0000000..41608cd
--- /dev/null
@@ -0,0 +1,1454 @@
+# @(#)australasia      8.9
+# <pre>
+
+# This file also includes Pacific islands.
+
+# Notes are at the end of this file
+
+###############################################################################
+
+# Australia
+
+# Please see the notes below for the controversy about "EST" versus "AEST" etc.
+
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Aus     1917    only    -       Jan      1      0:01    1:00    -
+Rule   Aus     1917    only    -       Mar     25      2:00    0       -
+Rule   Aus     1942    only    -       Jan      1      2:00    1:00    -
+Rule   Aus     1942    only    -       Mar     29      2:00    0       -
+Rule   Aus     1942    only    -       Sep     27      2:00    1:00    -
+Rule   Aus     1943    1944    -       Mar     lastSun 2:00    0       -
+Rule   Aus     1943    only    -       Oct      3      2:00    1:00    -
+# Go with Whitman and the Australian National Standards Commission, which
+# says W Australia didn't use DST in 1943/1944.  Ignore Whitman's claim that
+# 1944/1945 was just like 1943/1944.
+
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+# Northern Territory
+Zone Australia/Darwin   8:43:20 -      LMT     1895 Feb
+                        9:00   -       CST     1899 May
+                        9:30   Aus     CST
+# Western Australia
+#
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   AW      1974    only    -       Oct     lastSun 2:00s   1:00    -
+Rule   AW      1975    only    -       Mar     Sun>=1  2:00s   0       -
+Rule   AW      1983    only    -       Oct     lastSun 2:00s   1:00    -
+Rule   AW      1984    only    -       Mar     Sun>=1  2:00s   0       -
+Rule   AW      1991    only    -       Nov     17      2:00s   1:00    -
+Rule   AW      1992    only    -       Mar     Sun>=1  2:00s   0       -
+Rule   AW      2006    only    -       Dec      3      2:00s   1:00    -
+Rule   AW      2007    2009    -       Mar     lastSun 2:00s   0       -
+Rule   AW      2007    2008    -       Oct     lastSun 2:00s   1:00    -
+Zone Australia/Perth    7:43:24 -      LMT     1895 Dec
+                        8:00   Aus     WST     1943 Jul
+                        8:00   AW      WST
+Zone Australia/Eucla    8:35:28 -      LMT     1895 Dec
+                        8:45   Aus     CWST    1943 Jul
+                        8:45   AW      CWST
+
+# Queensland
+#
+# From Alex Livingston (1996-11-01):
+# I have heard or read more than once that some resort islands off the coast
+# of Queensland chose to keep observing daylight-saving time even after
+# Queensland ceased to.
+#
+# From Paul Eggert (1996-11-22):
+# IATA SSIM (1993-02/1994-09) say that the Holiday Islands (Hayman, Lindeman,
+# Hamilton) observed DST for two years after the rest of Queensland stopped.
+# Hamilton is the largest, but there is also a Hamilton in Victoria,
+# so use Lindeman.
+#
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   AQ      1971    only    -       Oct     lastSun 2:00s   1:00    -
+Rule   AQ      1972    only    -       Feb     lastSun 2:00s   0       -
+Rule   AQ      1989    1991    -       Oct     lastSun 2:00s   1:00    -
+Rule   AQ      1990    1992    -       Mar     Sun>=1  2:00s   0       -
+Rule   Holiday 1992    1993    -       Oct     lastSun 2:00s   1:00    -
+Rule   Holiday 1993    1994    -       Mar     Sun>=1  2:00s   0       -
+Zone Australia/Brisbane        10:12:08 -      LMT     1895
+                       10:00   Aus     EST     1971
+                       10:00   AQ      EST
+Zone Australia/Lindeman  9:55:56 -     LMT     1895
+                       10:00   Aus     EST     1971
+                       10:00   AQ      EST     1992 Jul
+                       10:00   Holiday EST
+
+# South Australia
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   AS      1971    1985    -       Oct     lastSun 2:00s   1:00    -
+Rule   AS      1986    only    -       Oct     19      2:00s   1:00    -
+Rule   AS      1987    2007    -       Oct     lastSun 2:00s   1:00    -
+Rule   AS      1972    only    -       Feb     27      2:00s   0       -
+Rule   AS      1973    1985    -       Mar     Sun>=1  2:00s   0       -
+Rule   AS      1986    1989    -       Mar     Sun>=15 2:00s   0       -
+Rule   AS      1990    only    -       Mar     Sun>=18 2:00s   0       -
+Rule   AS      1991    only    -       Mar     Sun>=1  2:00s   0       -
+Rule   AS      1992    only    -       Mar     Sun>=18 2:00s   0       -
+Rule   AS      1993    only    -       Mar     Sun>=1  2:00s   0       -
+Rule   AS      1994    only    -       Mar     Sun>=18 2:00s   0       -
+Rule   AS      1995    2005    -       Mar     lastSun 2:00s   0       -
+Rule   AS      2006    only    -       Apr     Sun>=1  2:00s   0       -
+Rule   AS      2007    only    -       Mar     lastSun 2:00s   0       -
+Rule   AS      2008    max     -       Apr     Sun>=1  2:00s   0       -
+Rule   AS      2008    max     -       Oct     Sun>=1  2:00s   1:00    -
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone Australia/Adelaide        9:14:20 -       LMT     1895 Feb
+                       9:00    -       CST     1899 May
+                       9:30    Aus     CST     1971
+                       9:30    AS      CST
+
+# Tasmania
+#
+# From Paul Eggert (2005-08-16):
+# <http://www.bom.gov.au/climate/averages/tables/dst_times.shtml>
+# says King Island didn't observe DST from WWII until late 1971.
+#
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   AT      1967    only    -       Oct     Sun>=1  2:00s   1:00    -
+Rule   AT      1968    only    -       Mar     lastSun 2:00s   0       -
+Rule   AT      1968    1985    -       Oct     lastSun 2:00s   1:00    -
+Rule   AT      1969    1971    -       Mar     Sun>=8  2:00s   0       -
+Rule   AT      1972    only    -       Feb     lastSun 2:00s   0       -
+Rule   AT      1973    1981    -       Mar     Sun>=1  2:00s   0       -
+Rule   AT      1982    1983    -       Mar     lastSun 2:00s   0       -
+Rule   AT      1984    1986    -       Mar     Sun>=1  2:00s   0       -
+Rule   AT      1986    only    -       Oct     Sun>=15 2:00s   1:00    -
+Rule   AT      1987    1990    -       Mar     Sun>=15 2:00s   0       -
+Rule   AT      1987    only    -       Oct     Sun>=22 2:00s   1:00    -
+Rule   AT      1988    1990    -       Oct     lastSun 2:00s   1:00    -
+Rule   AT      1991    1999    -       Oct     Sun>=1  2:00s   1:00    -
+Rule   AT      1991    2005    -       Mar     lastSun 2:00s   0       -
+Rule   AT      2000    only    -       Aug     lastSun 2:00s   1:00    -
+Rule   AT      2001    max     -       Oct     Sun>=1  2:00s   1:00    -
+Rule   AT      2006    only    -       Apr     Sun>=1  2:00s   0       -
+Rule   AT      2007    only    -       Mar     lastSun 2:00s   0       -
+Rule   AT      2008    max     -       Apr     Sun>=1  2:00s   0       -
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone Australia/Hobart  9:49:16 -       LMT     1895 Sep
+                       10:00   -       EST     1916 Oct 1 2:00
+                       10:00   1:00    EST     1917 Feb
+                       10:00   Aus     EST     1967
+                       10:00   AT      EST
+Zone Australia/Currie  9:35:28 -       LMT     1895 Sep
+                       10:00   -       EST     1916 Oct 1 2:00
+                       10:00   1:00    EST     1917 Feb
+                       10:00   Aus     EST     1971 Jul
+                       10:00   AT      EST
+
+# Victoria
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   AV      1971    1985    -       Oct     lastSun 2:00s   1:00    -
+Rule   AV      1972    only    -       Feb     lastSun 2:00s   0       -
+Rule   AV      1973    1985    -       Mar     Sun>=1  2:00s   0       -
+Rule   AV      1986    1990    -       Mar     Sun>=15 2:00s   0       -
+Rule   AV      1986    1987    -       Oct     Sun>=15 2:00s   1:00    -
+Rule   AV      1988    1999    -       Oct     lastSun 2:00s   1:00    -
+Rule   AV      1991    1994    -       Mar     Sun>=1  2:00s   0       -
+Rule   AV      1995    2005    -       Mar     lastSun 2:00s   0       -
+Rule   AV      2000    only    -       Aug     lastSun 2:00s   1:00    -
+Rule   AV      2001    2007    -       Oct     lastSun 2:00s   1:00    -
+Rule   AV      2006    only    -       Apr     Sun>=1  2:00s   0       -
+Rule   AV      2007    only    -       Mar     lastSun 2:00s   0       -
+Rule   AV      2008    max     -       Apr     Sun>=1  2:00s   0       -
+Rule   AV      2008    max     -       Oct     Sun>=1  2:00s   1:00    -
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone Australia/Melbourne 9:39:52 -     LMT     1895 Feb
+                       10:00   Aus     EST     1971
+                       10:00   AV      EST
+
+# New South Wales
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   AN      1971    1985    -       Oct     lastSun 2:00s   1:00    -
+Rule   AN      1972    only    -       Feb     27      2:00s   0       -
+Rule   AN      1973    1981    -       Mar     Sun>=1  2:00s   0       -
+Rule   AN      1982    only    -       Apr     Sun>=1  2:00s   0       -
+Rule   AN      1983    1985    -       Mar     Sun>=1  2:00s   0       -
+Rule   AN      1986    1989    -       Mar     Sun>=15 2:00s   0       -
+Rule   AN      1986    only    -       Oct     19      2:00s   1:00    -
+Rule   AN      1987    1999    -       Oct     lastSun 2:00s   1:00    -
+Rule   AN      1990    1995    -       Mar     Sun>=1  2:00s   0       -
+Rule   AN      1996    2005    -       Mar     lastSun 2:00s   0       -
+Rule   AN      2000    only    -       Aug     lastSun 2:00s   1:00    -
+Rule   AN      2001    2007    -       Oct     lastSun 2:00s   1:00    -
+Rule   AN      2006    only    -       Apr     Sun>=1  2:00s   0       -
+Rule   AN      2007    only    -       Mar     lastSun 2:00s   0       -
+Rule   AN      2008    max     -       Apr     Sun>=1  2:00s   0       -
+Rule   AN      2008    max     -       Oct     Sun>=1  2:00s   1:00    -
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone Australia/Sydney  10:04:52 -      LMT     1895 Feb
+                       10:00   Aus     EST     1971
+                       10:00   AN      EST
+Zone Australia/Broken_Hill 9:25:48 -   LMT     1895 Feb
+                       10:00   -       EST     1896 Aug 23
+                       9:00    -       CST     1899 May
+                       9:30    Aus     CST     1971
+                       9:30    AN      CST     2000
+                       9:30    AS      CST
+
+# Lord Howe Island
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   LH      1981    1984    -       Oct     lastSun 2:00    1:00    -
+Rule   LH      1982    1985    -       Mar     Sun>=1  2:00    0       -
+Rule   LH      1985    only    -       Oct     lastSun 2:00    0:30    -
+Rule   LH      1986    1989    -       Mar     Sun>=15 2:00    0       -
+Rule   LH      1986    only    -       Oct     19      2:00    0:30    -
+Rule   LH      1987    1999    -       Oct     lastSun 2:00    0:30    -
+Rule   LH      1990    1995    -       Mar     Sun>=1  2:00    0       -
+Rule   LH      1996    2005    -       Mar     lastSun 2:00    0       -
+Rule   LH      2000    only    -       Aug     lastSun 2:00    0:30    -
+Rule   LH      2001    2007    -       Oct     lastSun 2:00    0:30    -
+Rule   LH      2006    only    -       Apr     Sun>=1  2:00    0       -
+Rule   LH      2007    only    -       Mar     lastSun 2:00    0       -
+Rule   LH      2008    max     -       Apr     Sun>=1  2:00    0       -
+Rule   LH      2008    max     -       Oct     Sun>=1  2:00    0:30    -
+Zone Australia/Lord_Howe 10:36:20 -    LMT     1895 Feb
+                       10:00   -       EST     1981 Mar
+                       10:30   LH      LHST
+
+# Australian miscellany
+#
+# Ashmore Is, Cartier
+# no indigenous inhabitants; only seasonal caretakers
+# no times are set
+#
+# Coral Sea Is
+# no indigenous inhabitants; only meteorologists
+# no times are set
+#
+# Macquarie
+# permanent occupation (scientific station) since 1948;
+# sealing and penguin oil station operated 1888/1917
+# like Australia/Hobart
+
+# Christmas
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone Indian/Christmas  7:02:52 -       LMT     1895 Feb
+                       7:00    -       CXT     # Christmas Island Time
+
+# Cook Is
+# From Shanks & Pottenger:
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Cook    1978    only    -       Nov     12      0:00    0:30    HS
+Rule   Cook    1979    1991    -       Mar     Sun>=1  0:00    0       -
+Rule   Cook    1979    1990    -       Oct     lastSun 0:00    0:30    HS
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone Pacific/Rarotonga -10:39:04 -     LMT     1901            # Avarua
+                       -10:30  -       CKT     1978 Nov 12     # Cook Is Time
+                       -10:00  Cook    CK%sT
+
+# Cocos
+# These islands were ruled by the Ross family from about 1830 to 1978.
+# We don't know when standard time was introduced; for now, we guess 1900.
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Indian/Cocos    6:27:40 -       LMT     1900
+                       6:30    -       CCT     # Cocos Islands Time
+
+# Fiji
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Fiji    1998    1999    -       Nov     Sun>=1  2:00    1:00    S
+Rule   Fiji    1999    2000    -       Feb     lastSun 3:00    0       -
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Pacific/Fiji    11:53:40 -      LMT     1915 Oct 26     # Suva
+                       12:00   Fiji    FJ%sT   # Fiji Time
+
+# French Polynesia
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Pacific/Gambier  -8:59:48 -     LMT     1912 Oct        # Rikitea
+                        -9:00  -       GAMT    # Gambier Time
+Zone   Pacific/Marquesas -9:18:00 -    LMT     1912 Oct
+                        -9:30  -       MART    # Marquesas Time
+Zone   Pacific/Tahiti   -9:58:16 -     LMT     1912 Oct        # Papeete
+                       -10:00  -       TAHT    # Tahiti Time
+# Clipperton (near North America) is administered from French Polynesia;
+# it is uninhabited.
+
+# Guam
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Pacific/Guam    -14:21:00 -     LMT     1844 Dec 31
+                        9:39:00 -      LMT     1901            # Agana
+                       10:00   -       GST     2000 Dec 23     # Guam
+                       10:00   -       ChST    # Chamorro Standard Time
+
+# Kiribati
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone Pacific/Tarawa     11:32:04 -     LMT     1901            # Bairiki
+                        12:00  -       GILT             # Gilbert Is Time
+Zone Pacific/Enderbury -11:24:20 -     LMT     1901
+                       -12:00  -       PHOT    1979 Oct # Phoenix Is Time
+                       -11:00  -       PHOT    1995
+                        13:00  -       PHOT
+Zone Pacific/Kiritimati        -10:29:20 -     LMT     1901
+                       -10:40  -       LINT    1979 Oct # Line Is Time
+                       -10:00  -       LINT    1995
+                        14:00  -       LINT
+
+# N Mariana Is
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone Pacific/Saipan    -14:17:00 -     LMT     1844 Dec 31
+                        9:43:00 -      LMT     1901
+                        9:00   -       MPT     1969 Oct # N Mariana Is Time
+                       10:00   -       MPT     2000 Dec 23
+                       10:00   -       ChST    # Chamorro Standard Time
+
+# Marshall Is
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone Pacific/Majuro    11:24:48 -      LMT     1901
+                       11:00   -       MHT     1969 Oct # Marshall Islands Time
+                       12:00   -       MHT
+Zone Pacific/Kwajalein 11:09:20 -      LMT     1901
+                       11:00   -       MHT     1969 Oct
+                       -12:00  -       KWAT    1993 Aug 20     # Kwajalein Time
+                       12:00   -       MHT
+
+# Micronesia
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone Pacific/Truk      10:07:08 -      LMT     1901
+                       10:00   -       TRUT                    # Truk Time
+Zone Pacific/Ponape    10:32:52 -      LMT     1901            # Kolonia
+                       11:00   -       PONT                    # Ponape Time
+Zone Pacific/Kosrae    10:51:56 -      LMT     1901
+                       11:00   -       KOST    1969 Oct        # Kosrae Time
+                       12:00   -       KOST    1999
+                       11:00   -       KOST
+
+# Nauru
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Pacific/Nauru   11:07:40 -      LMT     1921 Jan 15     # Uaobe
+                       11:30   -       NRT     1942 Mar 15     # Nauru Time
+                       9:00    -       JST     1944 Aug 15
+                       11:30   -       NRT     1979 May
+                       12:00   -       NRT
+
+# New Caledonia
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   NC      1977    1978    -       Dec     Sun>=1  0:00    1:00    S
+Rule   NC      1978    1979    -       Feb     27      0:00    0       -
+Rule   NC      1996    only    -       Dec      1      2:00s   1:00    S
+# Shanks & Pottenger say the following was at 2:00; go with IATA.
+Rule   NC      1997    only    -       Mar      2      2:00s   0       -
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Pacific/Noumea  11:05:48 -      LMT     1912 Jan 13
+                       11:00   NC      NC%sT
+
+
+###############################################################################
+
+# New Zealand
+
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   NZ      1927    only    -       Nov      6      2:00    1:00    S
+Rule   NZ      1928    only    -       Mar      4      2:00    0       M
+Rule   NZ      1928    1933    -       Oct     Sun>=8  2:00    0:30    S
+Rule   NZ      1929    1933    -       Mar     Sun>=15 2:00    0       M
+Rule   NZ      1934    1940    -       Apr     lastSun 2:00    0       M
+Rule   NZ      1934    1940    -       Sep     lastSun 2:00    0:30    S
+Rule   NZ      1946    only    -       Jan      1      0:00    0       S
+# Since 1957 Chatham has been 45 minutes ahead of NZ, but there's no
+# convenient notation for this so we must duplicate the Rule lines.
+Rule   NZ      1974    only    -       Nov     Sun>=1  2:00s   1:00    D
+Rule   Chatham 1974    only    -       Nov     Sun>=1  2:45s   1:00    D
+Rule   NZ      1975    only    -       Feb     lastSun 2:00s   0       S
+Rule   Chatham 1975    only    -       Feb     lastSun 2:45s   0       S
+Rule   NZ      1975    1988    -       Oct     lastSun 2:00s   1:00    D
+Rule   Chatham 1975    1988    -       Oct     lastSun 2:45s   1:00    D
+Rule   NZ      1976    1989    -       Mar     Sun>=1  2:00s   0       S
+Rule   Chatham 1976    1989    -       Mar     Sun>=1  2:45s   0       S
+Rule   NZ      1989    only    -       Oct     Sun>=8  2:00s   1:00    D
+Rule   Chatham 1989    only    -       Oct     Sun>=8  2:45s   1:00    D
+Rule   NZ      1990    2006    -       Oct     Sun>=1  2:00s   1:00    D
+Rule   Chatham 1990    2006    -       Oct     Sun>=1  2:45s   1:00    D
+Rule   NZ      1990    2007    -       Mar     Sun>=15 2:00s   0       S
+Rule   Chatham 1990    2007    -       Mar     Sun>=15 2:45s   0       S
+Rule   NZ      2007    max     -       Sep     lastSun 2:00s   1:00    D
+Rule   Chatham 2007    max     -       Sep     lastSun 2:45s   1:00    D
+Rule   NZ      2008    max     -       Apr     Sun>=1  2:00s   0       S
+Rule   Chatham 2008    max     -       Apr     Sun>=1  2:45s   0       S
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone Pacific/Auckland  11:39:04 -      LMT     1868 Nov  2
+                       11:30   NZ      NZ%sT   1946 Jan  1
+                       12:00   NZ      NZ%sT
+Zone Pacific/Chatham   12:13:48 -      LMT     1957 Jan  1
+                       12:45   Chatham CHA%sT
+
+
+# Auckland Is
+# uninhabited; Maori and Moriori, colonial settlers, pastoralists, sealers,
+# and scientific personnel have wintered
+
+# Campbell I
+# minor whaling stations operated 1909/1914
+# scientific station operated 1941/1995;
+# previously whalers, sealers, pastoralists, and scientific personnel wintered
+# was probably like Pacific/Auckland
+
+###############################################################################
+
+
+# Niue
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Pacific/Niue    -11:19:40 -     LMT     1901            # Alofi
+                       -11:20  -       NUT     1951    # Niue Time
+                       -11:30  -       NUT     1978 Oct 1
+                       -11:00  -       NUT
+
+# Norfolk
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Pacific/Norfolk 11:11:52 -      LMT     1901            # Kingston
+                       11:12   -       NMT     1951    # Norfolk Mean Time
+                       11:30   -       NFT             # Norfolk Time
+
+# Palau (Belau)
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone Pacific/Palau     8:57:56 -       LMT     1901            # Koror
+                       9:00    -       PWT     # Palau Time
+
+# Papua New Guinea
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone Pacific/Port_Moresby 9:48:40 -    LMT     1880
+                       9:48:32 -       PMMT    1895    # Port Moresby Mean Time
+                       10:00   -       PGT             # Papua New Guinea Time
+
+# Pitcairn
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone Pacific/Pitcairn  -8:40:20 -      LMT     1901            # Adamstown
+                       -8:30   -       PNT     1998 Apr 27 00:00
+                       -8:00   -       PST     # Pitcairn Standard Time
+
+# American Samoa
+Zone Pacific/Pago_Pago  12:37:12 -     LMT     1879 Jul  5
+                       -11:22:48 -     LMT     1911
+                       -11:30  -       SAMT    1950            # Samoa Time
+                       -11:00  -       NST     1967 Apr        # N=Nome
+                       -11:00  -       BST     1983 Nov 30     # B=Bering
+                       -11:00  -       SST                     # S=Samoa
+
+# Samoa
+Zone Pacific/Apia       12:33:04 -     LMT     1879 Jul  5
+                       -11:26:56 -     LMT     1911
+                       -11:30  -       SAMT    1950            # Samoa Time
+                       -11:00  -       WST                     # Samoa Time
+
+# Solomon Is
+# excludes Bougainville, for which see Papua New Guinea
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone Pacific/Guadalcanal 10:39:48 -    LMT     1912 Oct        # Honiara
+                       11:00   -       SBT     # Solomon Is Time
+
+# Tokelau Is
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Pacific/Fakaofo -11:24:56 -     LMT     1901
+                       -10:00  -       TKT     # Tokelau Time
+
+# Tonga
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Tonga   1999    only    -       Oct      7      2:00s   1:00    S
+Rule   Tonga   2000    only    -       Mar     19      2:00s   0       -
+Rule   Tonga   2000    2001    -       Nov     Sun>=1  2:00    1:00    S
+Rule   Tonga   2001    2002    -       Jan     lastSun 2:00    0       -
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone Pacific/Tongatapu 12:19:20 -      LMT     1901
+                       12:20   -       TOT     1941 # Tonga Time
+                       13:00   -       TOT     1999
+                       13:00   Tonga   TO%sT
+
+# Tuvalu
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone Pacific/Funafuti  11:56:52 -      LMT     1901
+                       12:00   -       TVT     # Tuvalu Time
+
+
+# US minor outlying islands
+
+# Howland, Baker
+# Howland was mined for guano by American companies 1857-1878 and British
+# 1886-1891; Baker was similar but exact dates are not known.
+# Inhabited by civilians 1935-1942; U.S. military bases 1943-1944;
+# uninhabited thereafter.
+# Howland observed Hawaii Standard Time (UTC-10:30) in 1937;
+# see page 206 of Elgen M. Long and Marie K. Long,
+# Amelia Earhart: the Mystery Solved, Simon & Schuster (2000).
+# So most likely Howland and Baker observed Hawaii Time from 1935
+# until they were abandoned after the war.
+
+# Jarvis
+# Mined for guano by American companies 1857-1879 and British 1883?-1891?.
+# Inhabited by civilians 1935-1942; IGY scientific base 1957-1958;
+# uninhabited thereafter.
+# no information; was probably like Pacific/Kiritimati
+
+# Johnston
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone Pacific/Johnston  -10:00  -       HST
+
+# Kingman
+# uninhabited
+
+# Midway
+#
+# From Mark Brader (2005-01-23):
+# [Fallacies and Fantasies of Air Transport History, by R.E.G. Davies,
+# published 1994 by Paladwr Press, McLean, VA, USA; ISBN 0-9626483-5-3]
+# reproduced a Pan American Airways timeables from 1936, for their weekly
+# "Orient Express" flights between San Francisco and Manila, and connecting
+# flights to Chicago and the US East Coast.  As it uses some time zone
+# designations that I've never seen before:....
+# Fri. 6:30A Lv. HONOLOLU (Pearl Harbor), H.I.   H.L.T. Ar. 5:30P Sun.
+#  "   3:00P Ar. MIDWAY ISLAND . . . . . . . . . M.L.T. Lv. 6:00A  "
+#
+Zone Pacific/Midway    -11:49:28 -     LMT     1901
+                       -11:00  -       NST     1956 Jun  3
+                       -11:00  1:00    NDT     1956 Sep  2
+                       -11:00  -       NST     1967 Apr        # N=Nome
+                       -11:00  -       BST     1983 Nov 30     # B=Bering
+                       -11:00  -       SST                     # S=Samoa
+
+# Palmyra
+# uninhabited since World War II; was probably like Pacific/Kiritimati
+
+# Wake
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Pacific/Wake    11:06:28 -      LMT     1901
+                       12:00   -       WAKT    # Wake Time
+
+
+# Vanuatu
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Vanuatu 1983    only    -       Sep     25      0:00    1:00    S
+Rule   Vanuatu 1984    1991    -       Mar     Sun>=23 0:00    0       -
+Rule   Vanuatu 1984    only    -       Oct     23      0:00    1:00    S
+Rule   Vanuatu 1985    1991    -       Sep     Sun>=23 0:00    1:00    S
+Rule   Vanuatu 1992    1993    -       Jan     Sun>=23 0:00    0       -
+Rule   Vanuatu 1992    only    -       Oct     Sun>=23 0:00    1:00    S
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Pacific/Efate   11:13:16 -      LMT     1912 Jan 13             # Vila
+                       11:00   Vanuatu VU%sT   # Vanuatu Time
+
+# Wallis and Futuna
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Pacific/Wallis  12:15:20 -      LMT     1901
+                       12:00   -       WFT     # Wallis & Futuna Time
+
+###############################################################################
+
+# NOTES
+
+# This data is by no means authoritative; if you think you know better,
+# go ahead and edit the file (and please send any changes to
+# tz@elsie.nci.nih.gov for general use in the future).
+
+# From Paul Eggert (2006-03-22):
+# A good source for time zone historical data outside the U.S. is
+# Thomas G. Shanks and Rique Pottenger, The International Atlas (6th edition),
+# San Diego: ACS Publications, Inc. (2003).
+#
+# Gwillim Law writes that a good source
+# for recent time zone data is the International Air Transport
+# Association's Standard Schedules Information Manual (IATA SSIM),
+# published semiannually.  Law sent in several helpful summaries
+# of the IATA's data after 1990.
+#
+# Except where otherwise noted, Shanks & Pottenger is the source for
+# entries through 1990, and IATA SSIM is the source for entries afterwards.
+#
+# Another source occasionally used is Edward W. Whitman, World Time Differences,
+# Whitman Publishing Co, 2 Niagara Av, Ealing, London (undated), which
+# I found in the UCLA library.
+#
+# A reliable and entertaining source about time zones is
+# Derek Howse, Greenwich time and longitude, Philip Wilson Publishers (1997).
+#
+# I invented the abbreviations marked `*' in the following table;
+# the rest are from earlier versions of this file, or from other sources.
+# Corrections are welcome!
+#              std dst
+#              LMT     Local Mean Time
+#        8:00  WST WST Western Australia
+#        8:45  CWST CWST Central Western Australia*
+#        9:00  JST     Japan
+#        9:30  CST CST Central Australia
+#       10:00  EST EST Eastern Australia
+#       10:00  ChST    Chamorro
+#       10:30  LHST LHST Lord Howe*
+#       11:30  NZMT NZST New Zealand through 1945
+#       12:00  NZST NZDT New Zealand 1946-present
+#       12:45  CHAST CHADT Chatham*
+#      -11:00  SST     Samoa
+#      -10:00  HST     Hawaii
+#      - 8:00  PST     Pitcairn*
+#
+# See the `northamerica' file for Hawaii.
+# See the `southamerica' file for Easter I and the Galapagos Is.
+
+###############################################################################
+
+# Australia
+
+# From Paul Eggert (2005-12-08):
+# <a href="http://www.bom.gov.au/climate/averages/tables/dst_times.shtml">
+# Implementation Dates of Daylight Saving Time within Australia
+# </a> summarizes daylight saving issues in Australia.
+
+# From Arthur David Olson (2005-12-12):
+# <a href="http://www.lawlink.nsw.gov.au/lawlink/Corporate/ll_agdinfo.nsf/pages/community_relations_daylight_saving">
+# Lawlink NSW:Daylight Saving in New South Wales
+# </a> covers New South Wales in particular.
+
+# From John Mackin (1991-03-06):
+# We in Australia have _never_ referred to DST as `daylight' time.
+# It is called `summer' time.  Now by a happy coincidence, `summer'
+# and `standard' happen to start with the same letter; hence, the
+# abbreviation does _not_ change...
+# The legislation does not actually define abbreviations, at least
+# in this State, but the abbreviation is just commonly taken to be the
+# initials of the phrase, and the legislation here uniformly uses
+# the phrase `summer time' and does not use the phrase `daylight
+# time'.
+# Announcers on the Commonwealth radio network, the ABC (for Australian
+# Broadcasting Commission), use the phrases `Eastern Standard Time'
+# or `Eastern Summer Time'.  (Note, though, that as I say in the
+# current australasia file, there is really no such thing.)  Announcers
+# on its overseas service, Radio Australia, use the same phrases
+# prefixed by the word `Australian' when referring to local times;
+# time announcements on that service, naturally enough, are made in UTC.
+
+# From Arthur David Olson (1992-03-08):
+# Given the above, what's chosen for year-round use is:
+#      CST     for any place operating at a GMTOFF of 9:30
+#      WST     for any place operating at a GMTOFF of 8:00
+#      EST     for any place operating at a GMTOFF of 10:00
+
+# From Chuck Soper (2006-06-01):
+# I recently found this Australian government web page on time zones:
+# <http://www.australia.gov.au/about-australia-13time>
+# And this government web page lists time zone names and abbreviations:
+# <http://www.bom.gov.au/climate/averages/tables/daysavtm.shtml>
+
+# From Paul Eggert (2001-04-05), summarizing a long discussion about "EST"
+# versus "AEST" etc.:
+#
+# I see the following points of dispute:
+#
+# * How important are unique time zone abbreviations?
+#
+#   Here I tend to agree with the point (most recently made by Chris
+#   Newman) that unique abbreviations should not be essential for proper
+#   operation of software.  We have other instances of ambiguity
+#   (e.g. "IST" denoting both "Israel Standard Time" and "Indian
+#   Standard Time"), and they are not likely to go away any time soon.
+#   In the old days, some software mistakenly relied on unique
+#   abbreviations, but this is becoming less true with time, and I don't
+#   think it's that important to cater to such software these days.
+#
+#   On the other hand, there is another motivation for unambiguous
+#   abbreviations: it cuts down on human confusion.  This is
+#   particularly true for Australia, where "EST" can mean one thing for
+#   time T and a different thing for time T plus 1 second.
+#
+# * Does the relevant legislation indicate which abbreviations should be used?
+#
+#   Here I tend to think that things are a mess, just as they are in
+#   many other countries.  We Americans are currently disagreeing about
+#   which abbreviation to use for the newly legislated Chamorro Standard
+#   Time, for example.
+#
+#   Personally, I would prefer to use common practice; I would like to
+#   refer to legislation only for examples of common practice, or as a
+#   tiebreaker.
+#
+# * Do Australians more often use "Eastern Daylight Time" or "Eastern
+#   Summer Time"?  Do they typically prefix the time zone names with
+#   the word "Australian"?
+#
+#   My own impression is that both "Daylight Time" and "Summer Time" are
+#   common and are widely understood, but that "Summer Time" is more
+#   popular; and that the leading "A" is also common but is omitted more
+#   often than not.  I just used AltaVista advanced search and got the
+#   following count of page hits:
+#
+#     1,103 "Eastern Summer Time" AND domain:au
+#       971 "Australian Eastern Summer Time" AND domain:au
+#       613 "Eastern Daylight Time" AND domain:au
+#       127 "Australian Eastern Daylight Time" AND domain:au
+#
+#   Here "Summer" seems quite a bit more popular than "Daylight",
+#   particularly when we know the time zone is Australian and not US,
+#   say.  The "Australian" prefix seems to be popular for Eastern Summer
+#   Time, but unpopular for Eastern Daylight Time.
+#
+#   For abbreviations, tools like AltaVista are less useful because of
+#   ambiguity.  Many hits are not really time zones, unfortunately, and
+#   many hits denote US time zones and not Australian ones.  But here
+#   are the hit counts anyway:
+#
+#     161,304 "EST" and domain:au
+#      25,156 "EDT" and domain:au
+#      18,263 "AEST" and domain:au
+#      10,416 "AEDT" and domain:au
+#
+#      14,538 "CST" and domain:au
+#       5,728 "CDT" and domain:au
+#         176 "ACST" and domain:au
+#          29 "ACDT" and domain:au
+#
+#       7,539 "WST" and domain:au
+#          68 "AWST" and domain:au
+#
+#   This data suggest that Australians tend to omit the "A" prefix in
+#   practice.  The situation for "ST" versus "DT" is less clear, given
+#   the ambiguities involved.
+#
+# * How do Australians feel about the abbreviations in the tz database?
+#
+#   If you just count Australians on this list, I count 2 in favor and 3
+#   against.  One of the "against" votes (David Keegel) counseled delay,
+#   saying that both AEST/AEDT and EST/EST are widely used and
+#   understood in Australia.
+
+# From Paul Eggert (1995-12-19):
+# Shanks & Pottenger report 2:00 for all autumn changes in Australia and NZ.
+# Mark Prior writes that his newspaper
+# reports that NSW's fall 1995 change will occur at 2:00,
+# but Robert Elz says it's been 3:00 in Victoria since 1970
+# and perhaps the newspaper's `2:00' is referring to standard time.
+# For now we'll continue to assume 2:00s for changes since 1960.
+
+# From Eric Ulevik (1998-01-05):
+#
+# Here are some URLs to Australian time legislation. These URLs are stable,
+# and should probably be included in the data file. There are probably more
+# relevant entries in this database.
+#
+# NSW (including LHI and Broken Hill):
+# <a href="http://www.austlii.edu.au/au/legis/nsw/consol_act/sta1987137/index.html">
+# Standard Time Act 1987 (updated 1995-04-04)
+# </a>
+# ACT
+# <a href="http://www.austlii.edu.au/au/legis/act/consol_act/stasta1972279/index.html">
+# Standard Time and Summer Time Act 1972
+# </a>
+# SA
+# <a href="http://www.austlii.edu.au/au/legis/sa/consol_act/sta1898137/index.html">
+# Standard Time Act, 1898
+# </a>
+
+# From David Grosz (2005-06-13):
+# It was announced last week that Daylight Saving would be extended by
+# one week next year to allow for the 2006 Commonwealth Games.
+# Daylight Saving is now to end for next year only on the first Sunday
+# in April instead of the last Sunday in March.
+#
+# From Gwillim Law (2005-06-14):
+# I did some Googling and found that all of those states (and territory) plan
+# to extend DST together in 2006.
+# ACT: http://www.cmd.act.gov.au/mediareleases/fileread.cfm?file=86.txt
+# New South Wales: http://www.thecouriermail.news.com.au/common/story_page/0,5936,15538869%255E1702,00.html
+# South Australia: http://www.news.com.au/story/0,10117,15555031-1246,00.html
+# Tasmania: http://www.media.tas.gov.au/release.php?id=14772
+# Victoria: I wasn't able to find anything separate, but the other articles
+# allude to it.
+# But not Queensland
+# http://www.news.com.au/story/0,10117,15564030-1248,00.html.
+
+# Northern Territory
+
+# From George Shepherd via Simon Woodhead via Robert Elz (1991-03-06):
+# # The NORTHERN TERRITORY..  [ Courtesy N.T. Dept of the Chief Minister ]
+# #                                    [ Nov 1990 ]
+# #    N.T. have never utilised any DST due to sub-tropical/tropical location.
+# ...
+# Zone        Australia/North         9:30    -       CST
+
+# From Bradley White (1991-03-04):
+# A recent excerpt from an Australian newspaper...
+# the Northern Territory do[es] not have daylight saving.
+
+# Western Australia
+
+# From George Shepherd via Simon Woodhead via Robert Elz (1991-03-06):
+# #  The state of WESTERN AUSTRALIA..  [ Courtesy W.A. dept Premier+Cabinet ]
+# #                                            [ Nov 1990 ]
+# #    W.A. suffers from a great deal of public and political opposition to
+# #    DST in principle. A bill is brought before parliament in most years, but
+# #    usually defeated either in the upper house, or in party caucus
+# #    before reaching parliament.
+# ...
+# Zone Australia/West          8:00    AW      %sST
+# ...
+# Rule AW      1974    only    -       Oct     lastSun 2:00    1:00    D
+# Rule AW      1975    only    -       Mar     Sun>=1  3:00    0       W
+# Rule AW      1983    only    -       Oct     lastSun 2:00    1:00    D
+# Rule AW      1984    only    -       Mar     Sun>=1  3:00    0       W
+
+# From Bradley White (1991-03-04):
+# A recent excerpt from an Australian newspaper...
+# Western Australia...do[es] not have daylight saving.
+
+# From John D. Newman via Bradley White (1991-11-02):
+# Western Australia is still on "winter time". Some DH in Sydney
+# rang me at home a few days ago at 6.00am. (He had just arrived at
+# work at 9.00am.)
+# W.A. is switching to Summer Time on Nov 17th just to confuse
+# everybody again.
+
+# From Arthur David Olson (1992-03-08):
+# The 1992 ending date used in the rules is a best guess;
+# it matches what was used in the past.
+
+# <a href="http://www.bom.gov.au/faq/faqgen.htm">
+# The Australian Bureau of Meteorology FAQ
+# </a> (1999-09-27) writes that Giles Meteorological Station uses
+# South Australian time even though it's located in Western Australia.
+
+# Queensland
+# From George Shepherd via Simon Woodhead via Robert Elz (1991-03-06):
+# #   The state of QUEENSLAND.. [ Courtesy Qld. Dept Premier Econ&Trade Devel ]
+# #                                            [ Dec 1990 ]
+# ...
+# Zone Australia/Queensland    10:00   AQ      %sST
+# ...
+# Rule AQ      1971    only    -       Oct     lastSun 2:00    1:00    D
+# Rule AQ      1972    only    -       Feb     lastSun 3:00    0       E
+# Rule AQ      1989    max     -       Oct     lastSun 2:00    1:00    D
+# Rule AQ      1990    max     -       Mar     Sun>=1  3:00    0       E
+
+# From Bradley White (1989-12-24):
+# "Australia/Queensland" now observes daylight time (i.e. from
+# October 1989).
+
+# From Bradley White (1991-03-04):
+# A recent excerpt from an Australian newspaper...
+# ...Queensland...[has] agreed to end daylight saving
+# at 3am tomorrow (March 3)...
+
+# From John Mackin (1991-03-06):
+# I can certainly confirm for my part that Daylight Saving in NSW did in fact
+# end on Sunday, 3 March.  I don't know at what hour, though.  (It surprised
+# me.)
+
+# From Bradley White (1992-03-08):
+# ...there was recently a referendum in Queensland which resulted
+# in the experimental daylight saving system being abandoned. So, ...
+# ...
+# Rule QLD     1989    1991    -       Oct     lastSun 2:00    1:00    D
+# Rule QLD     1990    1992    -       Mar     Sun>=1  3:00    0       S
+# ...
+
+# From Arthur David Olson (1992-03-08):
+# The chosen rules the union of the 1971/1972 change and the 1989-1992 changes.
+
+# From Christopher Hunt (2006-11-21), after an advance warning
+# from Jesper Norgaard Welen (2006-11-01):
+# WA are trialing DST for three years.
+# <http://www.parliament.wa.gov.au/parliament/bills.nsf/9A1B183144403DA54825721200088DF1/$File/Bill175-1B.pdf>
+
+# From Rives McDow (2002-04-09):
+# The most interesting region I have found consists of three towns on the
+# southern coast....  South Australia observes daylight saving time; Western
+# Australia does not.  The two states are one and a half hours apart.  The
+# residents decided to forget about this nonsense of changing the clock so
+# much and set the local time 20 hours and 45 minutes from the
+# international date line, or right in the middle of the time of South
+# Australia and Western Australia....
+#
+# From Paul Eggert (2002-04-09):
+# This is confirmed by the section entitled
+# "What's the deal with time zones???" in
+# <http://www.earthsci.unimelb.edu.au/~awatkins/null.html>.
+#
+# From Alex Livingston (2006-12-07):
+# ... it was just on four years ago that I drove along the Eyre Highway,
+# which passes through eastern Western Australia close to the southern
+# coast of the continent.
+#
+# I paid particular attention to the time kept there. There can be no
+# dispute that UTC+08:45 was considered "the time" from the border
+# village just inside the border with South Australia to as far west
+# as just east of Caiguna. There can also be no dispute that Eucla is
+# the largest population centre in this zone....
+#
+# Now that Western Australia is observing daylight saving, the
+# question arose whether this part of the state would follow suit. I
+# just called the border village and confirmed that indeed they have,
+# meaning that they are now observing UTC+09:45.
+#
+# (2006-12-09):
+# I personally doubt that either experimentation with daylight saving
+# in WA or its introduction in SA had anything to do with the genesis
+# of this time zone.  My hunch is that it's been around since well
+# before 1975.  I remember seeing it noted on road maps decades ago.
+
+# From Paul Eggert (2006-12-15):
+# For lack of better info, assume the tradition dates back to the
+# introduction of standard time in 1895.
+
+
+# southeast Australia
+#
+# From Paul Eggert (2007-07-23):
+# Starting autumn 2008 Victoria, NSW, South Australia, Tasmania and the ACT
+# end DST the first Sunday in April and start DST the first Sunday in October.
+# http://www.theage.com.au/news/national/daylight-savings-to-span-six-months/2007/06/27/1182623966703.html
+
+
+# South Australia
+
+# From Bradley White (1991-03-04):
+# A recent excerpt from an Australian newspaper...
+# ...South Australia...[has] agreed to end daylight saving
+# at 3am tomorrow (March 3)...
+
+# From George Shepherd via Simon Woodhead via Robert Elz (1991-03-06):
+# #   The state of SOUTH AUSTRALIA....[ Courtesy of S.A. Dept of Labour ]
+# #                                            [ Nov 1990 ]
+# ...
+# Zone Australia/South         9:30    AS      %sST
+# ...
+# Rule  AS     1971    max     -       Oct     lastSun 2:00    1:00    D
+# Rule  AS     1972    1985    -       Mar     Sun>=1  3:00    0       C
+# Rule  AS     1986    1990    -       Mar     Sun>=15 3:00    0       C
+# Rule  AS     1991    max     -       Mar     Sun>=1  3:00    0       C
+
+# From Bradley White (1992-03-11):
+# Recent correspondence with a friend in Adelaide
+# contained the following exchange:  "Due to the Adelaide Festival,
+# South Australia delays setting back our clocks for a few weeks."
+
+# From Robert Elz (1992-03-13):
+# I heard that apparently (or at least, it appears that)
+# South Aus will have an extra 3 weeks daylight saving every even
+# numbered year (from 1990).  That's when the Adelaide Festival
+# is on...
+
+# From Robert Elz (1992-03-16, 00:57:07 +1000):
+# DST didn't end in Adelaide today (yesterday)....
+# But whether it's "4th Sunday" or "2nd last Sunday" I have no idea whatever...
+# (it's just as likely to be "the Sunday we pick for this year"...).
+
+# From Bradley White (1994-04-11):
+# If Sun, 15 March, 1992 was at +1030 as kre asserts, but yet Sun, 20 March,
+# 1994 was at +0930 as John Connolly's customer seems to assert, then I can
+# only conclude that the actual rule is more complicated....
+
+# From John Warburton (1994-10-07):
+# The new Daylight Savings dates for South Australia ...
+# was gazetted in the Government Hansard on Sep 26 1994....
+# start on last Sunday in October and end in last sunday in March.
+
+# From Paul Eggert (2007-07-23):
+# See "southeast Australia" above for 2008 and later.
+
+# Tasmania
+
+# The rules for 1967 through 1991 were reported by George Shepherd
+# via Simon Woodhead via Robert Elz (1991-03-06):
+# #  The state of TASMANIA.. [Courtesy Tasmanian Dept of Premier + Cabinet ]
+# #                                    [ Nov 1990 ]
+
+# From Bill Hart via Guy Harris (1991-10-10):
+# Oh yes, the new daylight savings rules are uniquely tasmanian, we have
+# 6 weeks a year now when we are out of sync with the rest of Australia
+# (but nothing new about that).
+
+# From Alex Livingston (1999-10-04):
+# I heard on the ABC (Australian Broadcasting Corporation) radio news on the
+# (long) weekend that Tasmania, which usually goes its own way in this regard,
+# has decided to join with most of NSW, the ACT, and most of Victoria
+# (Australia) and start daylight saving on the last Sunday in August in 2000
+# instead of the first Sunday in October.
+
+# Sim Alam (2000-07-03) reported a legal citation for the 2000/2001 rules:
+# http://www.thelaw.tas.gov.au/fragview/42++1968+GS3A@EN+2000070300
+
+# From Paul Eggert (2007-07-23):
+# See "southeast Australia" above for 2008 and later.
+
+# Victoria
+
+# The rules for 1971 through 1991 were reported by George Shepherd
+# via Simon Woodhead via Robert Elz (1991-03-06):
+# #   The state of VICTORIA.. [ Courtesy of Vic. Dept of Premier + Cabinet ]
+# #                                            [ Nov 1990 ]
+
+# From Scott Harrington (2001-08-29):
+# On KQED's "City Arts and Lectures" program last night I heard an
+# interesting story about daylight savings time.  Dr. John Heilbron was
+# discussing his book "The Sun in the Church: Cathedrals as Solar
+# Observatories"[1], and in particular the Shrine of Remembrance[2] located
+# in Melbourne, Australia.
+#
+# Apparently the shrine's main purpose is a beam of sunlight which
+# illuminates a special spot on the floor at the 11th hour of the 11th day
+# of the 11th month (Remembrance Day) every year in memory of Australia's
+# fallen WWI soldiers.  And if you go there on Nov. 11, at 11am local time,
+# you will indeed see the sunbeam illuminate the special spot at the
+# expected time.
+#
+# However, that is only because of some special mirror contraption that had
+# to be employed, since due to daylight savings time, the true solar time of
+# the remembrance moment occurs one hour later (or earlier?).  Perhaps
+# someone with more information on this jury-rig can tell us more.
+#
+# [1] http://www.hup.harvard.edu/catalog/HEISUN.html
+# [2] http://www.shrine.org.au
+
+# From Paul Eggert (2007-07-23):
+# See "southeast Australia" above for 2008 and later.
+
+# New South Wales
+
+# From Arthur David Olson:
+# New South Wales and subjurisdictions have their own ideas of a fun time.
+# Based on law library research by John Mackin,
+# who notes:
+#      In Australia, time is not legislated federally, but rather by the
+#      individual states.  Thus, while such terms as ``Eastern Standard Time''
+#      [I mean, of course, Australian EST, not any other kind] are in common
+#      use, _they have NO REAL MEANING_, as they are not defined in the
+#      legislation.  This is very important to understand.
+#      I have researched New South Wales time only...
+
+# From Eric Ulevik (1999-05-26):
+# DST will start in NSW on the last Sunday of August, rather than the usual
+# October in 2000.  [See: Matthew Moore,
+# <a href="http://www.smh.com.au/news/9905/26/pageone/pageone4.html">
+# Two months more daylight saving
+# </a>
+# Sydney Morning Herald (1999-05-26).]
+
+# From Paul Eggert (1999-09-27):
+# See the following official NSW source:
+# <a href="http://dir.gis.nsw.gov.au/cgi-bin/genobject/document/other/daylightsaving/tigGmZ">
+# Daylight Saving in New South Wales.
+# </a>
+#
+# Narrabri Shire (NSW) council has announced it will ignore the extension of
+# daylight saving next year.  See:
+# <a href="http://abc.net.au/news/regionals/neweng/monthly/regeng-22jul1999-1.htm">
+# Narrabri Council to ignore daylight saving
+# </a> (1999-07-22).  For now, we'll wait to see if this really happens.
+#
+# Victoria will following NSW.  See:
+# <a href="http://abc.net.au/local/news/olympics/1999/07/item19990728112314_1.htm">
+# Vic to extend daylight saving
+# </a> (1999-07-28).
+#
+# However, South Australia rejected the DST request.  See:
+# <a href="http://abc.net.au/news/olympics/1999/07/item19990719151754_1.htm">
+# South Australia rejects Olympics daylight savings request
+# </a> (1999-07-19).
+#
+# Queensland also will not observe DST for the Olympics.  See:
+# <a href="http://abc.net.au/news/olympics/1999/06/item19990601114608_1.htm">
+# Qld says no to daylight savings for Olympics
+# </a> (1999-06-01), which quotes Queensland Premier Peter Beattie as saying
+# ``Look you've got to remember in my family when this came up last time
+# I voted for it, my wife voted against it and she said to me it's all very
+# well for you, you don't have to worry about getting the children out of
+# bed, getting them to school, getting them to sleep at night.
+# I've been through all this argument domestically...my wife rules.''
+#
+# Broken Hill will stick with South Australian time in 2000.  See:
+# <a href="http://abc.net.au/news/regionals/brokenh/monthly/regbrok-21jul1999-6.htm">
+# Broken Hill to be behind the times
+# </a> (1999-07-21).
+
+# IATA SSIM (1998-09) says that the spring 2000 change for Australian
+# Capital Territory, New South Wales except Lord Howe Island and Broken
+# Hill, and Victoria will be August 27, presumably due to the Sydney Olympics.
+
+# From Eric Ulevik, referring to Sydney's Sun Herald (2000-08-13), page 29:
+# The Queensland Premier Peter Beattie is encouraging northern NSW
+# towns to use Queensland time.
+
+# From Paul Eggert (2007-07-23):
+# See "southeast Australia" above for 2008 and later.
+
+# Yancowinna
+
+# From John Mackin (1989-01-04):
+# `Broken Hill' means the County of Yancowinna.
+
+# From George Shepherd via Simon Woodhead via Robert Elz (1991-03-06):
+# # YANCOWINNA..  [ Confirmation courtesy of Broken Hill Postmaster ]
+# #                                    [ Dec 1990 ]
+# ...
+# # Yancowinna uses Central Standard Time, despite [its] location on the
+# # New South Wales side of the S.A. border. Most business and social dealings
+# # are with CST zones, therefore CST is legislated by local government
+# # although the switch to Summer Time occurs in line with N.S.W. There have
+# # been years when this did not apply, but the historical data is not
+# # presently available.
+# Zone Australia/Yancowinna    9:30     AY     %sST
+# ...
+# Rule  AY     1971    1985    -       Oct     lastSun 2:00    1:00    D
+# Rule  AY     1972    only    -       Feb     lastSun 3:00    0       C
+# [followed by other Rules]
+
+# Lord Howe Island
+
+# From George Shepherd via Simon Woodhead via Robert Elz (1991-03-06):
+# LHI...               [ Courtesy of Pauline Van Winsen ]
+#                                      [ Dec 1990 ]
+# Lord Howe Island is located off the New South Wales coast, and is half an
+# hour ahead of NSW time.
+
+# From James Lonergan, Secretary, Lord Howe Island Board (2000-01-27):
+# Lord Howe Island summer time in 2000/2001 will commence on the same
+# date as the rest of NSW (i.e. 2000-08-27).  For your information the
+# Lord Howe Island Board (controlling authority for the Island) is
+# seeking the community's views on various options for summer time
+# arrangements on the Island, e.g. advance clocks by 1 full hour
+# instead of only 30 minutes.  Dependant on the wishes of residents
+# the Board may approach the NSW government to change the existing
+# arrangements.  The starting date for summer time on the Island will
+# however always coincide with the rest of NSW.
+
+# From James Lonergan, Secretary, Lord Howe Island Board (2000-10-25):
+# Lord Howe Island advances clocks by 30 minutes during DST in NSW and retards
+# clocks by 30 minutes when DST finishes. Since DST was most recently
+# introduced in NSW, the "changeover" time on the Island has been 02:00 as
+# shown on clocks on LHI. I guess this means that for 30 minutes at the start
+# of DST, LHI is actually 1 hour ahead of the rest of NSW.
+
+# From Paul Eggert (2006-03-22):
+# For Lord Howe dates we use Shanks & Pottenger through 1989, and
+# Lonergan thereafter.  For times we use Lonergan.
+
+# From Paul Eggert (2007-07-23):
+# See "southeast Australia" above for 2008 and later.
+
+###############################################################################
+
+# New Zealand
+
+# From Mark Davies (1990-10-03):
+# the 1989/90 year was a trial of an extended "daylight saving" period.
+# This trial was deemed successful and the extended period adopted for
+# subsequent years (with the addition of a further week at the start).
+# source -- phone call to Ministry of Internal Affairs Head Office.
+
+# From George Shepherd via Simon Woodhead via Robert Elz (1991-03-06):
+# # The Country of New Zealand   (Australia's east island -) Gee they hate that!
+# #                               or is Australia the west island of N.Z.
+# #    [ courtesy of Geoff Tribble.. Auckland N.Z. ]
+# #                            [ Nov 1990 ]
+# ...
+# Rule NZ      1974    1988    -       Oct     lastSun 2:00    1:00    D
+# Rule NZ      1989    max     -       Oct     Sun>=1  2:00    1:00    D
+# Rule NZ      1975    1989    -       Mar     Sun>=1  3:00    0       S
+# Rule NZ      1990    max     -       Mar     lastSun 3:00    0       S
+# ...
+# Zone NZ                      12:00   NZ              NZ%sT   # New Zealand
+# Zone NZ-CHAT                 12:45   -               NZ-CHAT # Chatham Island
+
+# From Arthur David Olson (1992-03-08):
+# The chosen rules use the Davies October 8 values for the start of DST in 1989
+# rather than the October 1 value.
+
+# From Paul Eggert (1995-12-19);
+# Shank & Pottenger report 2:00 for all autumn changes in Australia and NZ.
+# Robert Uzgalis writes that the New Zealand Daylight
+# Savings Time Order in Council dated 1990-06-18 specifies 2:00 standard
+# time on both the first Sunday in October and the third Sunday in March.
+# As with Australia, we'll assume the tradition is 2:00s, not 2:00.
+#
+# From Paul Eggert (2006-03-22):
+# The Department of Internal Affairs (DIA) maintains a brief history,
+# as does Carol Squires; see tz-link.htm for the full references.
+# Use these sources in preference to Shanks & Pottenger.
+#
+# For Chatham, IATA SSIM (1991/1999) gives the NZ rules but with
+# transitions at 2:45 local standard time; this confirms that Chatham
+# is always exactly 45 minutes ahead of Auckland.
+
+# From Colin Sharples (2007-04-30):
+# DST will now start on the last Sunday in September, and end on the
+# first Sunday in April.  The changes take effect this year, meaning
+# that DST will begin on 2007-09-30 2008-04-06.
+# http://www.dia.govt.nz/diawebsite.nsf/wpg_URL/Services-Daylight-Saving-Daylight-saving-to-be-extended
+
+###############################################################################
+
+
+# Fiji
+
+# Howse writes (p 153) that in 1879 the British governor of Fiji
+# enacted an ordinance standardizing the islands on Antipodean Time
+# instead of the American system (which was one day behind).
+
+# From Rives McDow (1998-10-08):
+# Fiji will introduce DST effective 0200 local time, 1998-11-01
+# until 0300 local time 1999-02-28.  Each year the DST period will
+# be from the first Sunday in November until the last Sunday in February.
+
+# From Paul Eggert (2000-01-08):
+# IATA SSIM (1999-09) says DST ends 0100 local time.  Go with McDow.
+
+# From the BBC World Service (1998-10-31 11:32 UTC):
+# The Fijiian government says the main reasons for the time change is to
+# improve productivity and reduce road accidents.  But correspondents say it
+# also hopes the move will boost Fiji's ability to compete with other pacific
+# islands in the effort to attract tourists to witness the dawning of the new
+# millenium.
+
+# http://www.fiji.gov.fj/press/2000_09/2000_09_13-05.shtml (2000-09-13)
+# reports that Fiji has discontinued DST.
+
+# Johnston
+
+# Johnston data is from usno1995.
+
+
+# Kiribati
+
+# From Paul Eggert (1996-01-22):
+# Today's _Wall Street Journal_ (page 1) reports that Kiribati
+# ``declared it the same day throught the country as of Jan. 1, 1995''
+# as part of the competition to be first into the 21st century.
+
+
+# Kwajalein
+
+# In comp.risks 14.87 (26 August 1993), Peter Neumann writes:
+# I wonder what happened in Kwajalein, where there was NO Friday,
+# 1993-08-20.  Thursday night at midnight Kwajalein switched sides with
+# respect to the International Date Line, to rejoin its fellow islands,
+# going from 11:59 p.m. Thursday to 12:00 m. Saturday in a blink.
+
+
+# N Mariana Is, Guam
+
+# Howse writes (p 153) ``The Spaniards, on the other hand, reached the
+# Philippines and the Ladrones from America,'' and implies that the Ladrones
+# (now called the Marianas) kept American date for quite some time.
+# For now, we assume the Ladrones switched at the same time as the Philippines;
+# see Asia/Manila.
+
+# US Public Law 106-564 (2000-12-23) made UTC+10 the official standard time,
+# under the name "Chamorro Standard Time".  There is no official abbreviation,
+# but Congressman Robert A. Underwood, author of the bill that became law,
+# wrote in a press release (2000-12-27) that he will seek the use of "ChST".
+
+
+# Micronesia
+
+# Alan Eugene Davis writes (1996-03-16),
+# ``I am certain, having lived there for the past decade, that "Truk"
+# (now properly known as Chuuk) ... is in the time zone GMT+10.''
+#
+# Shanks & Pottenger write that Truk switched from UTC+10 to UTC+11
+# on 1978-10-01; ignore this for now.
+
+# From Paul Eggert (1999-10-29):
+# The Federated States of Micronesia Visitors Board writes in
+# <a href="http://www.fsmgov.org/info/clocks.html">
+# The Federated States of Micronesia - Visitor Information
+# </a> (1999-01-26)
+# that Truk and Yap are UTC+10, and Ponape and Kosrae are UTC+11.
+# We don't know when Kosrae switched from UTC+12; assume January 1 for now.
+
+
+# Midway
+
+# From Charles T O'Connor, KMTH DJ (1956),
+# quoted in the KTMH section of the Radio Heritage Collection
+# <http://radiodx.com/spdxr/KMTH.htm> (2002-12-31):
+# For the past two months we've been on what is known as Daylight
+# Saving Time.  This time has put us on air at 5am in the morning,
+# your time down there in New Zealand.  Starting September 2, 1956
+# we'll again go back to Standard Time.  This'll mean that we'll go to
+# air at 6am your time.
+#
+# From Paul Eggert (2003-03-23):
+# We don't know the date of that quote, but we'll guess they
+# started DST on June 3.  Possibly DST was observed other years
+# in Midway, but we have no record of it.
+
+
+# Pitcairn
+
+# From Rives McDow (1999-11-08):
+# A Proclamation was signed by the Governor of Pitcairn on the 27th March 1998
+# with regard to Pitcairn Standard Time.  The Proclamation is as follows.
+#
+#      The local time for general purposes in the Islands shall be
+#      Co-ordinated Universal time minus 8 hours and shall be known
+#      as Pitcairn Standard Time.
+#
+# ... I have also seen Pitcairn listed as UTC minus 9 hours in several
+# references, and can only assume that this was an error in interpretation
+# somehow in light of this proclamation.
+
+# From Rives McDow (1999-11-09):
+# The Proclamation regarding Pitcairn time came into effect on 27 April 1998
+# ... at midnight.
+
+# From Howie Phelps (1999-11-10), who talked to a Pitcairner via shortwave:
+# Betty Christian told me yesterday that their local time is the same as
+# Pacific Standard Time. They used to be 1/2 hour different from us here in
+# Sacramento but it was changed a couple of years ago.
+
+
+# Samoa
+
+# Howse writes (p 153, citing p 10 of the 1883-11-18 New York Herald)
+# that in 1879 the King of Samoa decided to change
+# ``the date in his kingdom from the Antipodean to the American system,
+# ordaining -- by a masterpiece of diplomatic flattery -- that
+# the Fourth of July should be celebrated twice in that year.''
+
+
+# Tonga
+
+# From Paul Eggert (1996-01-22):
+# Today's _Wall Street Journal_ (p 1) reports that ``Tonga has been plotting
+# to sneak ahead of [New Zealanders] by introducing daylight-saving time.''
+# Since Kiribati has moved the Date Line it's not clear what Tonga will do.
+
+# Don Mundell writes in the 1997-02-20 Tonga Chronicle
+# <a href="http://www.tongatapu.net.to/tonga/homeland/timebegins.htm">
+# How Tonga became `The Land where Time Begins'
+# </a>:
+
+# Until 1941 Tonga maintained a standard time 50 minutes ahead of NZST
+# 12 hours and 20 minutes ahead of GMT.  When New Zealand adjusted its
+# standard time in 1940s, Tonga had the choice of subtracting from its
+# local time to come on the same standard time as New Zealand or of
+# advancing its time to maintain the differential of 13 degrees
+# (approximately 50 minutes ahead of New Zealand time).
+#
+# Because His Majesty King Taufa'ahau Tupou IV, then Crown Prince
+# Tungi, preferred to ensure Tonga's title as the land where time
+# begins, the Legislative Assembly approved the latter change.
+#
+# But some of the older, more conservative members from the outer
+# islands objected. "If at midnight on Dec. 31, we move ahead 40
+# minutes, as your Royal Highness wishes, what becomes of the 40
+# minutes we have lost?"
+#
+# The Crown Prince, presented an unanswerable argument: "Remember that
+# on the World Day of Prayer, you would be the first people on Earth
+# to say your prayers in the morning."
+
+# From Paul Eggert (2006-03-22):
+# Shanks & Pottenger say the transition was on 1968-10-01; go with Mundell.
+
+# From Eric Ulevik (1999-05-03):
+# Tonga's director of tourism, who is also secretary of the National Millenium
+# Committee, has a plan to get Tonga back in front.
+# He has proposed a one-off move to tropical daylight saving for Tonga from
+# October to March, which has won approval in principle from the Tongan
+# Government.
+
+# From Steffen Thorsen (1999-09-09):
+# * Tonga will introduce DST in November
+#
+# I was given this link by John Letts:
+# <a href="http://news.bbc.co.uk/hi/english/world/asia-pacific/newsid_424000/424764.stm">
+# http://news.bbc.co.uk/hi/english/world/asia-pacific/newsid_424000/424764.stm
+# </a>
+#
+# I have not been able to find exact dates for the transition in November
+# yet. By reading this article it seems like Fiji will be 14 hours ahead
+# of UTC as well, but as far as I know Fiji will only be 13 hours ahead
+# (12 + 1 hour DST).
+
+# From Arthur David Olson (1999-09-20):
+# According to <a href="http://www.tongaonline.com/news/sept1799.html">
+# http://www.tongaonline.com/news/sept1799.html
+# </a>:
+# "Daylight Savings Time will take effect on Oct. 2 through April 15, 2000
+# and annually thereafter from the first Saturday in October through the
+# third Saturday of April.  Under the system approved by Privy Council on
+# Sept. 10, clocks must be turned ahead one hour on the opening day and
+# set back an hour on the closing date."
+# Alas, no indication of the time of day.
+
+# From Rives McDow (1999-10-06):
+# Tonga started its Daylight Saving on Saturday morning October 2nd at 0200am.
+# Daylight Saving ends on April 16 at 0300am which is Sunday morning.
+
+# From Steffen Thorsen (2000-10-31):
+# Back in March I found a notice on the website http://www.tongaonline.com
+# that Tonga changed back to standard time one month early, on March 19
+# instead of the original reported date April 16. Unfortunately, the article
+# is no longer available on the site, and I did not make a copy of the
+# text, and I have forgotten to report it here.
+# (Original URL was: http://www.tongaonline.com/news/march162000.htm )
+
+# From Rives McDow (2000-12-01):
+# Tonga is observing DST as of 2000-11-04 and will stop on 2001-01-27.
+
+# From Sione Moala-Mafi (2001-09-20) via Rives McDow:
+# At 2:00am on the first Sunday of November, the standard time in the Kingdom
+# shall be moved forward by one hour to 3:00am.  At 2:00am on the last Sunday
+# of January the standard time in the Kingdom shall be moved backward by one
+# hour to 1:00am.
+
+# From Pulu 'Anau (2002-11-05):
+# The law was for 3 years, supposedly to get renewed.  It wasn't.
+
+
+# Wake
+
+# From Vernice Anderson, Personal Secretary to Philip Jessup,
+# US Ambassador At Large (oral history interview, 1971-02-02):
+#
+# Saturday, the 14th [of October, 1950] -- ...  The time was all the
+# more confusing at that point, because we had crossed the
+# International Date Line, thus getting two Sundays.  Furthermore, we
+# discovered that Wake Island had two hours of daylight saving time
+# making calculation of time in Washington difficult if not almost
+# impossible.
+#
+# http://www.trumanlibrary.org/wake/meeting.htm
+
+# From Paul Eggert (2003-03-23):
+# We have no other report of DST in Wake Island, so omit this info for now.
+
+###############################################################################
+
+# The International Date Line
+
+# From Gwillim Law (2000-01-03):
+#
+# The International Date Line is not defined by any international standard,
+# convention, or treaty.  Mapmakers are free to draw it as they please.
+# Reputable mapmakers will simply ensure that every point of land appears on
+# the correct side of the IDL, according to the date legally observed there.
+#
+# When Kiribati adopted a uniform date in 1995, thereby moving the Phoenix and
+# Line Islands to the west side of the IDL (or, if you prefer, moving the IDL
+# to the east side of the Phoenix and Line Islands), I suppose that most
+# mapmakers redrew the IDL following the boundary of Kiribati.  Even that line
+# has a rather arbitrary nature.  The straight-line boundaries between Pacific
+# island nations that are shown on many maps are based on an international
+# convention, but are not legally binding national borders.... The date is
+# governed by the IDL; therefore, even on the high seas, there may be some
+# places as late as fourteen hours later than UTC.  And, since the IDL is not
+# an international standard, there are some places on the high seas where the
+# correct date is ambiguous.
+
+# From Wikipedia <http://en.wikipedia.org/wiki/Time_zone> (2005-08-31):
+# Before 1920, all ships kept local apparent time on the high seas by setting
+# their clocks at night or at the morning sight so that, given the ship's
+# speed and direction, it would be 12 o'clock when the Sun crossed the ship's
+# meridian (12 o'clock = local apparent noon).  During 1917, at the
+# Anglo-French Conference on Time-keeping at Sea, it was recommended that all
+# ships, both military and civilian, should adopt hourly standard time zones
+# on the high seas.  Whenever a ship was within the territorial waters of any
+# nation it would use that nation's standard time.  The captain was permitted
+# to change his ship's clocks at a time of his choice following his ship's
+# entry into another zone time--he often chose midnight.  These zones were
+# adopted by all major fleets between 1920 and 1925 but not by many
+# independent merchant ships until World War II.
+
+# From Paul Eggert, using references suggested by Oscar van Vlijmen
+# (2005-03-20):
+#
+# The American Practical Navigator (2002)
+# <http://pollux.nss.nima.mil/pubs/pubs_j_apn_sections.html?rid=187>
+# talks only about the 180-degree meridian with respect to ships in
+# international waters; it ignores the international date line.
diff --git a/extra/zoneinfo/authors.txt b/extra/zoneinfo/authors.txt
new file mode 100644 (file)
index 0000000..b4bd0e7
--- /dev/null
@@ -0,0 +1 @@
+Doug Coleman
\ No newline at end of file
diff --git a/extra/zoneinfo/europe b/extra/zoneinfo/europe
new file mode 100644 (file)
index 0000000..09f3e1e
--- /dev/null
@@ -0,0 +1,2647 @@
+# @(#)europe   8.20
+# <pre>
+
+# This data is by no means authoritative; if you think you know better,
+# go ahead and edit the file (and please send any changes to
+# tz@elsie.nci.nih.gov for general use in the future).
+
+# From Paul Eggert (2006-03-22):
+# A good source for time zone historical data outside the U.S. is
+# Thomas G. Shanks and Rique Pottenger, The International Atlas (6th edition),
+# San Diego: ACS Publications, Inc. (2003).
+#
+# Gwillim Law writes that a good source
+# for recent time zone data is the International Air Transport
+# Association's Standard Schedules Information Manual (IATA SSIM),
+# published semiannually.  Law sent in several helpful summaries
+# of the IATA's data after 1990.
+#
+# Except where otherwise noted, Shanks & Pottenger is the source for
+# entries through 1991, and IATA SSIM is the source for entries afterwards.
+#
+# Other sources occasionally used include:
+#
+#      Edward W. Whitman, World Time Differences,
+#      Whitman Publishing Co, 2 Niagara Av, Ealing, London (undated),
+#      which I found in the UCLA library.
+#
+#      <a href="http://www.pettswoodvillage.co.uk/Daylight_Savings_William_Willett.pdf">
+#      William Willett, The Waste of Daylight, 19th edition
+#      </a> (1914-03)
+#
+#      Brazil's Departamento Servico da Hora (DSH),
+#      <a href="http://pcdsh01.on.br/HISTHV.htm">
+#      History of Summer Time
+#      </a> (1998-09-21, in Portuguese)
+
+#
+# I invented the abbreviations marked `*' in the following table;
+# the rest are from earlier versions of this file, or from other sources.
+# Corrections are welcome!
+#                   std dst  2dst
+#                   LMT           Local Mean Time
+#       -4:00       AST ADT       Atlantic
+#       -3:00       WGT WGST      Western Greenland*
+#       -1:00       EGT EGST      Eastern Greenland*
+#        0:00       GMT BST  BDST Greenwich, British Summer
+#        0:00       GMT IST       Greenwich, Irish Summer
+#        0:00       WET WEST WEMT Western Europe
+#        0:19:32.13 AMT NST       Amsterdam, Netherlands Summer (1835-1937)*
+#        0:20       NET NEST      Netherlands (1937-1940)*
+#        1:00       CET CEST CEMT Central Europe
+#        1:00:14    SET           Swedish (1879-1899)*
+#        2:00       EET EEST      Eastern Europe
+#        3:00       MSK MSD       Moscow
+#
+# A reliable and entertaining source about time zones, especially in Britain,
+# Derek Howse, Greenwich time and longitude, Philip Wilson Publishers (1997).
+
+# From Peter Ilieve (1994-12-04),
+# The original six [EU members]: Belgium, France, (West) Germany, Italy,
+# Luxembourg, the Netherlands.
+# Plus, from 1 Jan 73: Denmark, Ireland, United Kingdom.
+# Plus, from 1 Jan 81: Greece.
+# Plus, from 1 Jan 86: Spain, Portugal.
+# Plus, from 1 Jan 95: Austria, Finland, Sweden. (Norway negotiated terms for
+# entry but in a referendum on 28 Nov 94 the people voted No by 52.2% to 47.8%
+# on a turnout of 88.6%. This was almost the same result as Norway's previous
+# referendum in 1972, they are the only country to have said No twice.
+# Referendums in the other three countries voted Yes.)
+# ...
+# Estonia ... uses EU dates but not at 01:00 GMT, they use midnight GMT.
+# I don't think they know yet what they will do from 1996 onwards.
+# ...
+# There shouldn't be any [current members who are not using EU rules].
+# A Directive has the force of law, member states are obliged to enact
+# national law to implement it. The only contentious issue was the
+# different end date for the UK and Ireland, and this was always allowed
+# in the Directive.
+
+
+###############################################################################
+
+# Britain (United Kingdom) and Ireland (Eire)
+
+# From Peter Ilieve (1994-07-06):
+#
+# On 17 Jan 1994 the Independent, a UK quality newspaper, had a piece about
+# historical vistas along the Thames in west London. There was a photo
+# and a sketch map showing some of the sightlines involved. One paragraph
+# of the text said:
+#
+# `An old stone obelisk marking a forgotten terrestrial meridian stands
+# beside the river at Kew. In the 18th century, before time and longitude
+# was standardised by the Royal Observatory in Greenwich, scholars observed
+# this stone and the movement of stars from Kew Observatory nearby. They
+# made their calculations and set the time for the Horse Guards and Parliament,
+# but now the stone is obscured by scrubwood and can only be seen by walking
+# along the towpath within a few yards of it.'
+#
+# I have a one inch to one mile map of London and my estimate of the stone's
+# position is 51 deg. 28' 30" N, 0 deg. 18' 45" W. The longitude should
+# be within about +-2". The Ordnance Survey grid reference is TQ172761.
+#
+# [This yields GMTOFF = -0:01:15 for London LMT in the 18th century.]
+
+# From Paul Eggert (1993-11-18):
+#
+# Howse writes that Britain was the first country to use standard time.
+# The railways cared most about the inconsistencies of local mean time,
+# and it was they who forced a uniform time on the country.
+# The original idea was credited to Dr. William Hyde Wollaston (1766-1828)
+# and was popularized by Abraham Follett Osler (1808-1903).
+# The first railway to adopt London time was the Great Western Railway
+# in November 1840; other railways followed suit, and by 1847 most
+# (though not all) railways used London time.  On 1847-09-22 the
+# Railway Clearing House, an industry standards body, recommended that GMT be
+# adopted at all stations as soon as the General Post Office permitted it.
+# The transition occurred on 12-01 for the L&NW, the Caledonian,
+# and presumably other railways; the January 1848 Bradshaw's lists many
+# railways as using GMT.  By 1855 the vast majority of public
+# clocks in Britain were set to GMT (though some, like the great clock
+# on Tom Tower at Christ Church, Oxford, were fitted with two minute hands,
+# one for local time and one for GMT).  The last major holdout was the legal
+# system, which stubbornly stuck to local time for many years, leading
+# to oddities like polls opening at 08:13 and closing at 16:13.
+# The legal system finally switched to GMT when the Statutes (Definition
+# of Time) Act took effect; it received the Royal Assent on 1880-08-02.
+#
+# In the tables below, we condense this complicated story into a single
+# transition date for London, namely 1847-12-01.  We don't know as much
+# about Dublin, so we use 1880-08-02, the legal transition time.
+
+# From Paul Eggert (2003-09-27):
+# Summer Time was first seriously proposed by William Willett (1857-1915),
+# a London builder and member of the Royal Astronomical Society
+# who circulated a pamphlet ``The Waste of Daylight'' (1907)
+# that proposed advancing clocks 20 minutes on each of four Sundays in April,
+# and retarding them by the same amount on four Sundays in September.
+# A bill was drafted in 1909 and introduced in Parliament several times,
+# but it met with ridicule and opposition, especially from farming interests.
+# Later editions of the pamphlet proposed one-hour summer time, and
+# it was eventually adopted as a wartime measure in 1916.
+# See: Summer Time Arrives Early, The Times (2000-05-18).
+# A monument to Willett was unveiled on 1927-05-21, in an open space in
+# a 45-acre wood near Chislehurst, Kent that was purchased by popular
+# subscription and open to the public.  On the south face of the monolith,
+# designed by G. W. Miller, is the the William Willett Memorial Sundial,
+# which is permanently set to Summer Time.
+
+# From Winston Churchill (1934-04-28):
+# It is one of the paradoxes of history that we should owe the boon of
+# summer time, which gives every year to the people of this country
+# between 160 and 170 hours more daylight leisure, to a war which
+# plunged Europe into darkness for four years, and shook the
+# foundations of civilization throughout the world.
+#      -- <a href="http://www.winstonchurchill.org/fh114willett.htm">
+#      "A Silent Toast to William Willett", Pictorial Weekly
+#      </a>
+
+# From Paul Eggert (1996-09-03):
+# The OED Supplement says that the English originally said ``Daylight Saving''
+# when they were debating the adoption of DST in 1908; but by 1916 this
+# term appears only in quotes taken from DST's opponents, whereas the
+# proponents (who eventually won the argument) are quoted as using ``Summer''.
+
+# From Arthur David Olson (1989-01-19):
+#
+# A source at the British Information Office in New York avers that it's
+# known as "British" Summer Time in all parts of the United Kingdom.
+
+# Date: 4 Jan 89 08:57:25 GMT (Wed)
+# From: Jonathan Leffler
+# [British Summer Time] is fixed annually by Act of Parliament.
+# If you can predict what Parliament will do, you should be in
+# politics making a fortune, not computing.
+
+# From Chris Carrier (1996-06-14):
+# I remember reading in various wartime issues of the London Times the
+# acronym BDST for British Double Summer Time.  Look for the published
+# time of sunrise and sunset in The Times, when BDST was in effect, and
+# if you find a zone reference it will say, "All times B.D.S.T."
+
+# From Joseph S. Myers (1999-09-02):
+# ... some military cables (WO 219/4100 - this is a copy from the
+# main SHAEF archives held in the US National Archives, SHAEF/5252/8/516)
+# agree that the usage is BDST (this appears in a message dated 17 Feb 1945).
+
+# From Joseph S. Myers (2000-10-03):
+# On 18th April 1941, Sir Stephen Tallents of the BBC wrote to Sir
+# Alexander Maxwell of the Home Office asking whether there was any
+# official designation; the reply of the 21st was that there wasn't
+# but he couldn't think of anything better than the "Double British
+# Summer Time" that the BBC had been using informally.
+# http://student.cusu.cam.ac.uk/~jsm28/british-time/bbc-19410418.png
+# http://student.cusu.cam.ac.uk/~jsm28/british-time/ho-19410421.png
+
+# From Sir Alexander Maxwell in the above-mentioned letter (1941-04-21):
+# [N]o official designation has as far as I know been adopted for the time
+# which is to be introduced in May....
+# I cannot think of anything better than "Double British Summer Time"
+# which could not be said to run counter to any official description.
+
+# From Paul Eggert (2000-10-02):
+# Howse writes (p 157) `DBST' too, but `BDST' seems to have been common
+# and follows the more usual convention of putting the location name first,
+# so we use `BDST'.
+
+# Peter Ilieve (1998-04-19) described at length
+# the history of summer time legislation in the United Kingdom.
+# Since 1998 Joseph S. Myers has been updating
+# and extending this list, which can be found in
+# <a href="http://student.cusu.cam.ac.uk/~jsm28/british-time/">
+# History of legal time in Britain
+# </a>
+
+# From Joseph S. Myers (1998-01-06):
+#
+# The legal time in the UK outside of summer time is definitely GMT, not UTC;
+# see Lord Tanlaw's speech
+# <a href="http://www.parliament.the-stationery-office.co.uk/pa/ld199697/ldhansrd/pdvn/lds97/text/70611-20.htm#70611-20_head0">
+# (Lords Hansard 11 June 1997 columns 964 to 976)
+# </a>.
+
+# From Paul Eggert (2006-03-22):
+#
+# For lack of other data, follow Shanks & Pottenger for Eire in 1940-1948.
+#
+# Given Ilieve and Myers's data, the following claims by Shanks & Pottenger
+# are incorrect:
+#     * Wales did not switch from GMT to daylight saving time until
+#      1921 Apr 3, when they began to conform with the rest of Great Britain.
+# Actually, Wales was identical after 1880.
+#     * Eire had two transitions on 1916 Oct 1.
+# It actually just had one transition.
+#     * Northern Ireland used single daylight saving time throughout WW II.
+# Actually, it conformed to Britain.
+#     * GB-Eire changed standard time to 1 hour ahead of GMT on 1968-02-18.
+# Actually, that date saw the usual switch to summer time.
+# Standard time was not changed until 1968-10-27 (the clocks didn't change).
+#
+# Here is another incorrect claim by Shanks & Pottenger:
+#     * Jersey, Guernsey, and the Isle of Man did not switch from GMT
+#      to daylight saving time until 1921 Apr 3, when they began to
+#      conform with Great Britain.
+# S.R.&O. 1916, No. 382 and HO 45/10811/312364 (quoted above) say otherwise.
+#
+# The following claim by Shanks & Pottenger is possible though doubtful;
+# we'll ignore it for now.
+#     * Dublin's 1971-10-31 switch was at 02:00, even though London's was 03:00.
+#
+#
+# Whitman says Dublin Mean Time was -0:25:21, which is more precise than
+# Shanks & Pottenger.
+# Perhaps this was Dunsink Observatory Time, as Dunsink Observatory
+# (8 km NW of Dublin's center) seemingly was to Dublin as Greenwich was
+# to London.  For example:
+#
+#   "Timeball on the ballast office is down.  Dunsink time."
+#   -- James Joyce, Ulysses
+
+# From Joseph S. Myers (2005-01-26):
+# Irish laws are available online at www.irishstatutebook.ie.  These include
+# various relating to legal time, for example:
+#
+# ZZA13Y1923.html ZZA12Y1924.html ZZA8Y1925.html ZZSIV20PG1267.html
+#
+# ZZSI71Y1947.html ZZSI128Y1948.html ZZSI23Y1949.html ZZSI41Y1950.html
+# ZZSI27Y1951.html ZZSI73Y1952.html
+#
+# ZZSI11Y1961.html ZZSI232Y1961.html ZZSI182Y1962.html
+# ZZSI167Y1963.html ZZSI257Y1964.html ZZSI198Y1967.html
+# ZZA23Y1968.html ZZA17Y1971.html
+#
+# ZZSI67Y1981.html ZZSI212Y1982.html ZZSI45Y1986.html
+# ZZSI264Y1988.html ZZSI52Y1990.html ZZSI371Y1992.html
+# ZZSI395Y1994.html ZZSI484Y1997.html ZZSI506Y2001.html
+#
+# [These are all relative to the root, e.g., the first is
+# <http://www.irishstatutebook.ie/ZZA13Y1923.html>.]
+#
+# (These are those I found, but there could be more.  In any case these
+# should allow various updates to the comments in the europe file to cover
+# the laws applicable in Ireland.)
+#
+# (Note that the time in the Republic of Ireland since 1968 has been defined
+# in terms of standard time being GMT+1 with a period of winter time when it
+# is GMT, rather than standard time being GMT with a period of summer time
+# being GMT+1.)
+
+# From Paul Eggert (1999-03-28):
+# Clive Feather (<news:859845706.26043.0@office.demon.net>, 1997-03-31)
+# reports that Folkestone (Cheriton) Shuttle Terminal uses Concession Time
+# (CT), equivalent to French civil time.
+# Julian Hill (<news:36118128.5A14@virgin.net>, 1998-09-30) reports that
+# trains between Dollands Moor (the freight facility next door)
+# and Frethun run in CT.
+# My admittedly uninformed guess is that the terminal has two authorities,
+# the French concession operators and the British civil authorities,
+# and that the time depends on who you're talking to.
+# If, say, the British police were called to the station for some reason,
+# I would expect the official police report to use GMT/BST and not CET/CEST.
+# This is a borderline case, but for now let's stick to GMT/BST.
+
+# From an anonymous contributor (1996-06-02):
+# The law governing time in Ireland is under Statutory Instrument SI 395/94,
+# which gives force to European Union 7th Council Directive # 94/21/EC.
+# Under this directive, the Minister for Justice in Ireland makes appropriate
+# regulations. I spoke this morning with the Secretary of the Department of
+# Justice (tel +353 1 678 9711) who confirmed to me that the correct name is
+# "Irish Summer Time", abbreviated to "IST".
+
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+# Summer Time Act, 1916
+Rule   GB-Eire 1916    only    -       May     21      2:00s   1:00    BST
+Rule   GB-Eire 1916    only    -       Oct      1      2:00s   0       GMT
+# S.R.&O. 1917, No. 358
+Rule   GB-Eire 1917    only    -       Apr      8      2:00s   1:00    BST
+Rule   GB-Eire 1917    only    -       Sep     17      2:00s   0       GMT
+# S.R.&O. 1918, No. 274
+Rule   GB-Eire 1918    only    -       Mar     24      2:00s   1:00    BST
+Rule   GB-Eire 1918    only    -       Sep     30      2:00s   0       GMT
+# S.R.&O. 1919, No. 297
+Rule   GB-Eire 1919    only    -       Mar     30      2:00s   1:00    BST
+Rule   GB-Eire 1919    only    -       Sep     29      2:00s   0       GMT
+# S.R.&O. 1920, No. 458
+Rule   GB-Eire 1920    only    -       Mar     28      2:00s   1:00    BST
+# S.R.&O. 1920, No. 1844
+Rule   GB-Eire 1920    only    -       Oct     25      2:00s   0       GMT
+# S.R.&O. 1921, No. 363
+Rule   GB-Eire 1921    only    -       Apr      3      2:00s   1:00    BST
+Rule   GB-Eire 1921    only    -       Oct      3      2:00s   0       GMT
+# S.R.&O. 1922, No. 264
+Rule   GB-Eire 1922    only    -       Mar     26      2:00s   1:00    BST
+Rule   GB-Eire 1922    only    -       Oct      8      2:00s   0       GMT
+# The Summer Time Act, 1922
+Rule   GB-Eire 1923    only    -       Apr     Sun>=16 2:00s   1:00    BST
+Rule   GB-Eire 1923    1924    -       Sep     Sun>=16 2:00s   0       GMT
+Rule   GB-Eire 1924    only    -       Apr     Sun>=9  2:00s   1:00    BST
+Rule   GB-Eire 1925    1926    -       Apr     Sun>=16 2:00s   1:00    BST
+# The Summer Time Act, 1925
+Rule   GB-Eire 1925    1938    -       Oct     Sun>=2  2:00s   0       GMT
+Rule   GB-Eire 1927    only    -       Apr     Sun>=9  2:00s   1:00    BST
+Rule   GB-Eire 1928    1929    -       Apr     Sun>=16 2:00s   1:00    BST
+Rule   GB-Eire 1930    only    -       Apr     Sun>=9  2:00s   1:00    BST
+Rule   GB-Eire 1931    1932    -       Apr     Sun>=16 2:00s   1:00    BST
+Rule   GB-Eire 1933    only    -       Apr     Sun>=9  2:00s   1:00    BST
+Rule   GB-Eire 1934    only    -       Apr     Sun>=16 2:00s   1:00    BST
+Rule   GB-Eire 1935    only    -       Apr     Sun>=9  2:00s   1:00    BST
+Rule   GB-Eire 1936    1937    -       Apr     Sun>=16 2:00s   1:00    BST
+Rule   GB-Eire 1938    only    -       Apr     Sun>=9  2:00s   1:00    BST
+Rule   GB-Eire 1939    only    -       Apr     Sun>=16 2:00s   1:00    BST
+# S.R.&O. 1939, No. 1379
+Rule   GB-Eire 1939    only    -       Nov     Sun>=16 2:00s   0       GMT
+# S.R.&O. 1940, No. 172 and No. 1883
+Rule   GB-Eire 1940    only    -       Feb     Sun>=23 2:00s   1:00    BST
+# S.R.&O. 1941, No. 476
+Rule   GB-Eire 1941    only    -       May     Sun>=2  1:00s   2:00    BDST
+Rule   GB-Eire 1941    1943    -       Aug     Sun>=9  1:00s   1:00    BST
+# S.R.&O. 1942, No. 506
+Rule   GB-Eire 1942    1944    -       Apr     Sun>=2  1:00s   2:00    BDST
+# S.R.&O. 1944, No. 932
+Rule   GB-Eire 1944    only    -       Sep     Sun>=16 1:00s   1:00    BST
+# S.R.&O. 1945, No. 312
+Rule   GB-Eire 1945    only    -       Apr     Mon>=2  1:00s   2:00    BDST
+Rule   GB-Eire 1945    only    -       Jul     Sun>=9  1:00s   1:00    BST
+# S.R.&O. 1945, No. 1208
+Rule   GB-Eire 1945    1946    -       Oct     Sun>=2  2:00s   0       GMT
+Rule   GB-Eire 1946    only    -       Apr     Sun>=9  2:00s   1:00    BST
+# The Summer Time Act, 1947
+Rule   GB-Eire 1947    only    -       Mar     16      2:00s   1:00    BST
+Rule   GB-Eire 1947    only    -       Apr     13      1:00s   2:00    BDST
+Rule   GB-Eire 1947    only    -       Aug     10      1:00s   1:00    BST
+Rule   GB-Eire 1947    only    -       Nov      2      2:00s   0       GMT
+# Summer Time Order, 1948 (S.I. 1948/495)
+Rule   GB-Eire 1948    only    -       Mar     14      2:00s   1:00    BST
+Rule   GB-Eire 1948    only    -       Oct     31      2:00s   0       GMT
+# Summer Time Order, 1949 (S.I. 1949/373)
+Rule   GB-Eire 1949    only    -       Apr      3      2:00s   1:00    BST
+Rule   GB-Eire 1949    only    -       Oct     30      2:00s   0       GMT
+# Summer Time Order, 1950 (S.I. 1950/518)
+# Summer Time Order, 1951 (S.I. 1951/430)
+# Summer Time Order, 1952 (S.I. 1952/451)
+Rule   GB-Eire 1950    1952    -       Apr     Sun>=14 2:00s   1:00    BST
+Rule   GB-Eire 1950    1952    -       Oct     Sun>=21 2:00s   0       GMT
+# revert to the rules of the Summer Time Act, 1925
+Rule   GB-Eire 1953    only    -       Apr     Sun>=16 2:00s   1:00    BST
+Rule   GB-Eire 1953    1960    -       Oct     Sun>=2  2:00s   0       GMT
+Rule   GB-Eire 1954    only    -       Apr     Sun>=9  2:00s   1:00    BST
+Rule   GB-Eire 1955    1956    -       Apr     Sun>=16 2:00s   1:00    BST
+Rule   GB-Eire 1957    only    -       Apr     Sun>=9  2:00s   1:00    BST
+Rule   GB-Eire 1958    1959    -       Apr     Sun>=16 2:00s   1:00    BST
+Rule   GB-Eire 1960    only    -       Apr     Sun>=9  2:00s   1:00    BST
+# Summer Time Order, 1961 (S.I. 1961/71)
+# Summer Time (1962) Order, 1961 (S.I. 1961/2465)
+# Summer Time Order, 1963 (S.I. 1963/81)
+Rule   GB-Eire 1961    1963    -       Mar     lastSun 2:00s   1:00    BST
+Rule   GB-Eire 1961    1968    -       Oct     Sun>=23 2:00s   0       GMT
+# Summer Time (1964) Order, 1963 (S.I. 1963/2101)
+# Summer Time Order, 1964 (S.I. 1964/1201)
+# Summer Time Order, 1967 (S.I. 1967/1148)
+Rule   GB-Eire 1964    1967    -       Mar     Sun>=19 2:00s   1:00    BST
+# Summer Time Order, 1968 (S.I. 1968/117)
+Rule   GB-Eire 1968    only    -       Feb     18      2:00s   1:00    BST
+# The British Standard Time Act, 1968
+#      (no summer time)
+# The Summer Time Act, 1972
+Rule   GB-Eire 1972    1980    -       Mar     Sun>=16 2:00s   1:00    BST
+Rule   GB-Eire 1972    1980    -       Oct     Sun>=23 2:00s   0       GMT
+# Summer Time Order, 1980 (S.I. 1980/1089)
+# Summer Time Order, 1982 (S.I. 1982/1673)
+# Summer Time Order, 1986 (S.I. 1986/223)
+# Summer Time Order, 1988 (S.I. 1988/931)
+Rule   GB-Eire 1981    1995    -       Mar     lastSun 1:00u   1:00    BST
+Rule   GB-Eire 1981    1989    -       Oct     Sun>=23 1:00u   0       GMT
+# Summer Time Order, 1989 (S.I. 1989/985)
+# Summer Time Order, 1992 (S.I. 1992/1729)
+# Summer Time Order 1994 (S.I. 1994/2798)
+Rule   GB-Eire 1990    1995    -       Oct     Sun>=22 1:00u   0       GMT
+# Summer Time Order 1997 (S.I. 1997/2982)
+# See EU for rules starting in 1996.
+
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Europe/London   -0:01:15 -      LMT     1847 Dec  1 0:00s
+                        0:00   GB-Eire %s      1968 Oct 27
+                        1:00   -       BST     1971 Oct 31 2:00u
+                        0:00   GB-Eire %s      1996
+                        0:00   EU      GMT/BST
+Link   Europe/London   Europe/Jersey
+Link   Europe/London   Europe/Guernsey
+Link   Europe/London   Europe/Isle_of_Man
+Zone   Europe/Dublin   -0:25:00 -      LMT     1880 Aug  2
+                       -0:25:21 -      DMT     1916 May 21 2:00
+                       -0:25:21 1:00   IST     1916 Oct  1 2:00s
+                        0:00   GB-Eire %s      1921 Dec  6 # independence
+                        0:00   GB-Eire GMT/IST 1940 Feb 25 2:00
+                        0:00   1:00    IST     1946 Oct  6 2:00
+                        0:00   -       GMT     1947 Mar 16 2:00
+                        0:00   1:00    IST     1947 Nov  2 2:00
+                        0:00   -       GMT     1948 Apr 18 2:00
+                        0:00   GB-Eire GMT/IST 1968 Oct 27
+                        1:00   -       IST     1971 Oct 31 2:00u
+                        0:00   GB-Eire GMT/IST 1996
+                        0:00   EU      GMT/IST
+
+###############################################################################
+
+# Europe
+
+# EU rules are for the European Union, previously known as the EC, EEC,
+# Common Market, etc.
+
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   EU      1977    1980    -       Apr     Sun>=1   1:00u  1:00    S
+Rule   EU      1977    only    -       Sep     lastSun  1:00u  0       -
+Rule   EU      1978    only    -       Oct      1       1:00u  0       -
+Rule   EU      1979    1995    -       Sep     lastSun  1:00u  0       -
+Rule   EU      1981    max     -       Mar     lastSun  1:00u  1:00    S
+Rule   EU      1996    max     -       Oct     lastSun  1:00u  0       -
+# The most recent directive covers the years starting in 2002.  See:
+# <a href="http://europa.eu.int/eur-lex/en/lif/dat/2000/en_300L0084.html">
+# Directive 2000/84/EC of the European Parliament and of the Council
+# of 19 January 2001 on summer-time arrangements.
+# </a>
+
+# W-Eur differs from EU only in that W-Eur uses standard time.
+Rule   W-Eur   1977    1980    -       Apr     Sun>=1   1:00s  1:00    S
+Rule   W-Eur   1977    only    -       Sep     lastSun  1:00s  0       -
+Rule   W-Eur   1978    only    -       Oct      1       1:00s  0       -
+Rule   W-Eur   1979    1995    -       Sep     lastSun  1:00s  0       -
+Rule   W-Eur   1981    max     -       Mar     lastSun  1:00s  1:00    S
+Rule   W-Eur   1996    max     -       Oct     lastSun  1:00s  0       -
+
+# Older C-Eur rules are for convenience in the tables.
+# From 1977 on, C-Eur differs from EU only in that C-Eur uses standard time.
+Rule   C-Eur   1916    only    -       Apr     30      23:00   1:00    S
+Rule   C-Eur   1916    only    -       Oct      1       1:00   0       -
+Rule   C-Eur   1917    1918    -       Apr     Mon>=15  2:00s  1:00    S
+Rule   C-Eur   1917    1918    -       Sep     Mon>=15  2:00s  0       -
+Rule   C-Eur   1940    only    -       Apr      1       2:00s  1:00    S
+Rule   C-Eur   1942    only    -       Nov      2       2:00s  0       -
+Rule   C-Eur   1943    only    -       Mar     29       2:00s  1:00    S
+Rule   C-Eur   1943    only    -       Oct      4       2:00s  0       -
+Rule   C-Eur   1944    1945    -       Apr     Mon>=1   2:00s  1:00    S
+# Whitman gives 1944 Oct 7; go with Shanks & Pottenger.
+Rule   C-Eur   1944    only    -       Oct      2       2:00s  0       -
+# From Jesper Norgaard Welen (2008-07-13):
+#
+# I found what is probably a typo of 2:00 which should perhaps be 2:00s
+# in the C-Eur rule from tz database version 2008d (this part was
+# corrected in version 2008d). The circumstancial evidence is simply the
+# tz database itself, as seen below:
+#
+# Zone Europe/Paris 0:09:21 - LMT 1891 Mar 15  0:01
+#    0:00 France WE%sT 1945 Sep 16  3:00
+#
+# Zone Europe/Monaco 0:29:32 - LMT 1891 Mar 15
+#    0:00 France WE%sT 1945 Sep 16 3:00
+#
+# Zone Europe/Belgrade 1:22:00 - LMT 1884
+#    1:00 1:00 CEST 1945 Sep 16  2:00s
+#
+# Rule France 1945 only - Sep 16  3:00 0 -
+# Rule Belgium 1945 only - Sep 16  2:00s 0 -
+# Rule Neth 1945 only - Sep 16 2:00s 0 -
+#
+# The rule line to be changed is:
+#
+# Rule C-Eur 1945 only - Sep 16  2:00 0 -
+#
+# It seems that Paris, Monaco, Rule France, Rule Belgium all agree on
+# 2:00 standard time, e.g. 3:00 local time.  However there are no
+# countries that use C-Eur rules in September 1945, so the only items
+# affected are apparently these ficticious zones that translates acronyms
+# CET and MET:
+#
+# Zone CET  1:00 C-Eur CE%sT
+# Zone MET  1:00 C-Eur ME%sT
+#
+# It this is right then the corrected version would look like:
+#
+# Rule C-Eur 1945 only - Sep 16  2:00s 0 -
+#
+# A small step for mankind though 8-)
+Rule   C-Eur   1945    only    -       Sep     16       2:00s  0       -
+Rule   C-Eur   1977    1980    -       Apr     Sun>=1   2:00s  1:00    S
+Rule   C-Eur   1977    only    -       Sep     lastSun  2:00s  0       -
+Rule   C-Eur   1978    only    -       Oct      1       2:00s  0       -
+Rule   C-Eur   1979    1995    -       Sep     lastSun  2:00s  0       -
+Rule   C-Eur   1981    max     -       Mar     lastSun  2:00s  1:00    S
+Rule   C-Eur   1996    max     -       Oct     lastSun  2:00s  0       -
+
+# E-Eur differs from EU only in that E-Eur switches at midnight local time.
+Rule   E-Eur   1977    1980    -       Apr     Sun>=1   0:00   1:00    S
+Rule   E-Eur   1977    only    -       Sep     lastSun  0:00   0       -
+Rule   E-Eur   1978    only    -       Oct      1       0:00   0       -
+Rule   E-Eur   1979    1995    -       Sep     lastSun  0:00   0       -
+Rule   E-Eur   1981    max     -       Mar     lastSun  0:00   1:00    S
+Rule   E-Eur   1996    max     -       Oct     lastSun  0:00   0       -
+
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Russia  1917    only    -       Jul      1      23:00   1:00    MST     # Moscow Summer Time
+Rule   Russia  1917    only    -       Dec     28       0:00   0       MMT     # Moscow Mean Time
+Rule   Russia  1918    only    -       May     31      22:00   2:00    MDST    # Moscow Double Summer Time
+Rule   Russia  1918    only    -       Sep     16       1:00   1:00    MST
+Rule   Russia  1919    only    -       May     31      23:00   2:00    MDST
+Rule   Russia  1919    only    -       Jul      1       2:00   1:00    S
+Rule   Russia  1919    only    -       Aug     16       0:00   0       -
+Rule   Russia  1921    only    -       Feb     14      23:00   1:00    S
+Rule   Russia  1921    only    -       Mar     20      23:00   2:00    M # Midsummer
+Rule   Russia  1921    only    -       Sep      1       0:00   1:00    S
+Rule   Russia  1921    only    -       Oct      1       0:00   0       -
+# Act No.925 of the Council of Ministers of the USSR (1980-10-24):
+Rule   Russia  1981    1984    -       Apr      1       0:00   1:00    S
+Rule   Russia  1981    1983    -       Oct      1       0:00   0       -
+# Act No.967 of the Council of Ministers of the USSR (1984-09-13), repeated in
+# Act No.227 of the Council of Ministers of the USSR (1989-03-14):
+Rule   Russia  1984    1991    -       Sep     lastSun  2:00s  0       -
+Rule   Russia  1985    1991    -       Mar     lastSun  2:00s  1:00    S
+#
+Rule   Russia  1992    only    -       Mar     lastSat  23:00  1:00    S
+Rule   Russia  1992    only    -       Sep     lastSat  23:00  0       -
+Rule   Russia  1993    max     -       Mar     lastSun  2:00s  1:00    S
+Rule   Russia  1993    1995    -       Sep     lastSun  2:00s  0       -
+Rule   Russia  1996    max     -       Oct     lastSun  2:00s  0       -
+
+# These are for backward compatibility with older versions.
+
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   WET             0:00    EU      WE%sT
+Zone   CET             1:00    C-Eur   CE%sT
+Zone   MET             1:00    C-Eur   ME%sT
+Zone   EET             2:00    EU      EE%sT
+
+# Previous editions of this database used abbreviations like MET DST
+# for Central European Summer Time, but this didn't agree with common usage.
+
+# From Markus Kuhn (1996-07-12):
+# The official German names ... are
+#
+#      Mitteleuropaeische Zeit (MEZ)         = UTC+01:00
+#      Mitteleuropaeische Sommerzeit (MESZ)  = UTC+02:00
+#
+# as defined in the German Time Act (Gesetz ueber die Zeitbestimmung (ZeitG),
+# 1978-07-25, Bundesgesetzblatt, Jahrgang 1978, Teil I, S. 1110-1111)....
+# I wrote ... to the German Federal Physical-Technical Institution
+#
+#      Physikalisch-Technische Bundesanstalt (PTB)
+#      Laboratorium 4.41 "Zeiteinheit"
+#      Postfach 3345
+#      D-38023 Braunschweig
+#      phone: +49 531 592-0
+#
+# ... I received today an answer letter from Dr. Peter Hetzel, head of the PTB
+# department for time and frequency transmission.  He explained that the
+# PTB translates MEZ and MESZ into English as
+#
+#      Central European Time (CET)         = UTC+01:00
+#      Central European Summer Time (CEST) = UTC+02:00
+
+
+# Albania
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Albania 1940    only    -       Jun     16      0:00    1:00    S
+Rule   Albania 1942    only    -       Nov      2      3:00    0       -
+Rule   Albania 1943    only    -       Mar     29      2:00    1:00    S
+Rule   Albania 1943    only    -       Apr     10      3:00    0       -
+Rule   Albania 1974    only    -       May      4      0:00    1:00    S
+Rule   Albania 1974    only    -       Oct      2      0:00    0       -
+Rule   Albania 1975    only    -       May      1      0:00    1:00    S
+Rule   Albania 1975    only    -       Oct      2      0:00    0       -
+Rule   Albania 1976    only    -       May      2      0:00    1:00    S
+Rule   Albania 1976    only    -       Oct      3      0:00    0       -
+Rule   Albania 1977    only    -       May      8      0:00    1:00    S
+Rule   Albania 1977    only    -       Oct      2      0:00    0       -
+Rule   Albania 1978    only    -       May      6      0:00    1:00    S
+Rule   Albania 1978    only    -       Oct      1      0:00    0       -
+Rule   Albania 1979    only    -       May      5      0:00    1:00    S
+Rule   Albania 1979    only    -       Sep     30      0:00    0       -
+Rule   Albania 1980    only    -       May      3      0:00    1:00    S
+Rule   Albania 1980    only    -       Oct      4      0:00    0       -
+Rule   Albania 1981    only    -       Apr     26      0:00    1:00    S
+Rule   Albania 1981    only    -       Sep     27      0:00    0       -
+Rule   Albania 1982    only    -       May      2      0:00    1:00    S
+Rule   Albania 1982    only    -       Oct      3      0:00    0       -
+Rule   Albania 1983    only    -       Apr     18      0:00    1:00    S
+Rule   Albania 1983    only    -       Oct      1      0:00    0       -
+Rule   Albania 1984    only    -       Apr      1      0:00    1:00    S
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Europe/Tirane   1:19:20 -       LMT     1914
+                       1:00    -       CET     1940 Jun 16
+                       1:00    Albania CE%sT   1984 Jul
+                       1:00    EU      CE%sT
+
+# Andorra
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Europe/Andorra  0:06:04 -       LMT     1901
+                       0:00    -       WET     1946 Sep 30
+                       1:00    -       CET     1985 Mar 31 2:00
+                       1:00    EU      CE%sT
+
+# Austria
+
+# From Paul Eggert (2006-03-22): Shanks & Pottenger give 1918-06-16 and
+# 1945-11-18, but the Austrian Federal Office of Metrology and
+# Surveying (BEV) gives 1918-09-16 and for Vienna gives the "alleged"
+# date of 1945-04-12 with no time.  For the 1980-04-06 transition
+# Shanks & Pottenger give 02:00, the BEV 00:00.  Go with the BEV,
+# and guess 02:00 for 1945-04-12.
+
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Austria 1920    only    -       Apr      5      2:00s   1:00    S
+Rule   Austria 1920    only    -       Sep     13      2:00s   0       -
+Rule   Austria 1946    only    -       Apr     14      2:00s   1:00    S
+Rule   Austria 1946    1948    -       Oct     Sun>=1  2:00s   0       -
+Rule   Austria 1947    only    -       Apr      6      2:00s   1:00    S
+Rule   Austria 1948    only    -       Apr     18      2:00s   1:00    S
+Rule   Austria 1980    only    -       Apr      6      0:00    1:00    S
+Rule   Austria 1980    only    -       Sep     28      0:00    0       -
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Europe/Vienna   1:05:20 -       LMT     1893 Apr
+                       1:00    C-Eur   CE%sT   1920
+                       1:00    Austria CE%sT   1940 Apr  1 2:00s
+                       1:00    C-Eur   CE%sT   1945 Apr  2 2:00s
+                       1:00    1:00    CEST    1945 Apr 12 2:00s
+                       1:00    -       CET     1946
+                       1:00    Austria CE%sT   1981
+                       1:00    EU      CE%sT
+
+# Belarus
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Europe/Minsk    1:50:16 -       LMT     1880
+                       1:50    -       MMT     1924 May 2 # Minsk Mean Time
+                       2:00    -       EET     1930 Jun 21
+                       3:00    -       MSK     1941 Jun 28
+                       1:00    C-Eur   CE%sT   1944 Jul  3
+                       3:00    Russia  MSK/MSD 1990
+                       3:00    -       MSK     1991 Mar 31 2:00s
+                       2:00    1:00    EEST    1991 Sep 29 2:00s
+                       2:00    -       EET     1992 Mar 29 0:00s
+                       2:00    1:00    EEST    1992 Sep 27 0:00s
+                       2:00    Russia  EE%sT
+
+# Belgium
+#
+# From Paul Eggert (1997-07-02):
+# Entries from 1918 through 1991 are taken from:
+#      Annuaire de L'Observatoire Royal de Belgique,
+#      Avenue Circulaire, 3, B-1180 BRUXELLES, CLVIIe annee, 1991
+#      (Imprimerie HAYEZ, s.p.r.l., Rue Fin, 4, 1080 BRUXELLES, MCMXC),
+#      pp 8-9.
+# LMT before 1892 was 0:17:30, according to the official journal of Belgium:
+#      Moniteur Belge, Samedi 30 Avril 1892, N.121.
+# Thanks to Pascal Delmoitie for these references.
+# The 1918 rules are listed for completeness; they apply to unoccupied Belgium.
+# Assume Brussels switched to WET in 1918 when the armistice took effect.
+#
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Belgium 1918    only    -       Mar      9       0:00s  1:00    S
+Rule   Belgium 1918    1919    -       Oct     Sat>=1  23:00s  0       -
+Rule   Belgium 1919    only    -       Mar      1      23:00s  1:00    S
+Rule   Belgium 1920    only    -       Feb     14      23:00s  1:00    S
+Rule   Belgium 1920    only    -       Oct     23      23:00s  0       -
+Rule   Belgium 1921    only    -       Mar     14      23:00s  1:00    S
+Rule   Belgium 1921    only    -       Oct     25      23:00s  0       -
+Rule   Belgium 1922    only    -       Mar     25      23:00s  1:00    S
+Rule   Belgium 1922    1927    -       Oct     Sat>=1  23:00s  0       -
+Rule   Belgium 1923    only    -       Apr     21      23:00s  1:00    S
+Rule   Belgium 1924    only    -       Mar     29      23:00s  1:00    S
+Rule   Belgium 1925    only    -       Apr      4      23:00s  1:00    S
+# DSH writes that a royal decree of 1926-02-22 specified the Sun following 3rd
+# Sat in Apr (except if it's Easter, in which case it's one Sunday earlier),
+# to Sun following 1st Sat in Oct, and that a royal decree of 1928-09-15
+# changed the transition times to 02:00 GMT.
+Rule   Belgium 1926    only    -       Apr     17      23:00s  1:00    S
+Rule   Belgium 1927    only    -       Apr      9      23:00s  1:00    S
+Rule   Belgium 1928    only    -       Apr     14      23:00s  1:00    S
+Rule   Belgium 1928    1938    -       Oct     Sun>=2   2:00s  0       -
+Rule   Belgium 1929    only    -       Apr     21       2:00s  1:00    S
+Rule   Belgium 1930    only    -       Apr     13       2:00s  1:00    S
+Rule   Belgium 1931    only    -       Apr     19       2:00s  1:00    S
+Rule   Belgium 1932    only    -       Apr      3       2:00s  1:00    S
+Rule   Belgium 1933    only    -       Mar     26       2:00s  1:00    S
+Rule   Belgium 1934    only    -       Apr      8       2:00s  1:00    S
+Rule   Belgium 1935    only    -       Mar     31       2:00s  1:00    S
+Rule   Belgium 1936    only    -       Apr     19       2:00s  1:00    S
+Rule   Belgium 1937    only    -       Apr      4       2:00s  1:00    S
+Rule   Belgium 1938    only    -       Mar     27       2:00s  1:00    S
+Rule   Belgium 1939    only    -       Apr     16       2:00s  1:00    S
+Rule   Belgium 1939    only    -       Nov     19       2:00s  0       -
+Rule   Belgium 1940    only    -       Feb     25       2:00s  1:00    S
+Rule   Belgium 1944    only    -       Sep     17       2:00s  0       -
+Rule   Belgium 1945    only    -       Apr      2       2:00s  1:00    S
+Rule   Belgium 1945    only    -       Sep     16       2:00s  0       -
+Rule   Belgium 1946    only    -       May     19       2:00s  1:00    S
+Rule   Belgium 1946    only    -       Oct      7       2:00s  0       -
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Europe/Brussels 0:17:30 -       LMT     1880
+                       0:17:30 -       BMT     1892 May  1 12:00 # Brussels MT
+                       0:00    -       WET     1914 Nov  8
+                       1:00    -       CET     1916 May  1  0:00
+                       1:00    C-Eur   CE%sT   1918 Nov 11 11:00u
+                       0:00    Belgium WE%sT   1940 May 20  2:00s
+                       1:00    C-Eur   CE%sT   1944 Sep  3
+                       1:00    Belgium CE%sT   1977
+                       1:00    EU      CE%sT
+
+# Bosnia and Herzegovina
+# see Serbia
+
+# Bulgaria
+#
+# From Plamen Simenov via Steffen Thorsen (1999-09-09):
+# A document of Government of Bulgaria (No.94/1997) says:
+# EET --> EETDST is in 03:00 Local time in last Sunday of March ...
+# EETDST --> EET is in 04:00 Local time in last Sunday of October
+#
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Bulg    1979    only    -       Mar     31      23:00   1:00    S
+Rule   Bulg    1979    only    -       Oct      1       1:00   0       -
+Rule   Bulg    1980    1982    -       Apr     Sat>=1  23:00   1:00    S
+Rule   Bulg    1980    only    -       Sep     29       1:00   0       -
+Rule   Bulg    1981    only    -       Sep     27       2:00   0       -
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Europe/Sofia    1:33:16 -       LMT     1880
+                       1:56:56 -       IMT     1894 Nov 30 # Istanbul MT?
+                       2:00    -       EET     1942 Nov  2  3:00
+                       1:00    C-Eur   CE%sT   1945
+                       1:00    -       CET     1945 Apr 2 3:00
+                       2:00    -       EET     1979 Mar 31 23:00
+                       2:00    Bulg    EE%sT   1982 Sep 26  2:00
+                       2:00    C-Eur   EE%sT   1991
+                       2:00    E-Eur   EE%sT   1997
+                       2:00    EU      EE%sT
+
+# Croatia
+# see Serbia
+
+# Cyprus
+# Please see the `asia' file for Asia/Nicosia.
+
+# Czech Republic
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Czech   1945    only    -       Apr      8      2:00s   1:00    S
+Rule   Czech   1945    only    -       Nov     18      2:00s   0       -
+Rule   Czech   1946    only    -       May      6      2:00s   1:00    S
+Rule   Czech   1946    1949    -       Oct     Sun>=1  2:00s   0       -
+Rule   Czech   1947    only    -       Apr     20      2:00s   1:00    S
+Rule   Czech   1948    only    -       Apr     18      2:00s   1:00    S
+Rule   Czech   1949    only    -       Apr      9      2:00s   1:00    S
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Europe/Prague   0:57:44 -       LMT     1850
+                       0:57:44 -       PMT     1891 Oct     # Prague Mean Time
+                       1:00    C-Eur   CE%sT   1944 Sep 17 2:00s
+                       1:00    Czech   CE%sT   1979
+                       1:00    EU      CE%sT
+
+# Denmark, Faroe Islands, and Greenland
+
+# From Jesper Norgaard Welen (2005-04-26):
+# http://www.hum.aau.dk/~poe/tid/tine/DanskTid.htm says that the law
+# [introducing standard time] was in effect from 1894-01-01....
+# The page http://www.retsinfo.dk/_GETDOCI_/ACCN/A18930008330-REGL
+# confirms this, and states that the law was put forth 1893-03-29.
+#
+# The EU treaty with effect from 1973:
+# http://www.retsinfo.dk/_GETDOCI_/ACCN/A19722110030-REGL
+#
+# This provoked a new law from 1974 to make possible summer time changes
+# in subsequenet decrees with the law
+# http://www.retsinfo.dk/_GETDOCI_/ACCN/A19740022330-REGL
+#
+# It seems however that no decree was set forward until 1980.  I have
+# not found any decree, but in another related law, the effecting DST
+# changes are stated explicitly to be from 1980-04-06 at 02:00 to
+# 1980-09-28 at 02:00.  If this is true, this differs slightly from
+# the EU rule in that DST runs to 02:00, not 03:00.  We don't know
+# when Denmark began using the EU rule correctly, but we have only
+# confirmation of the 1980-time, so I presume it was correct in 1981:
+# The law is about the management of the extra hour, concerning
+# working hours reported and effect on obligatory-rest rules (which
+# was suspended on that night):
+# http://www.retsinfo.dk/_GETDOCI_/ACCN/C19801120554-REGL
+
+# From Jesper Norgaard Welen (2005-06-11):
+# The Herning Folkeblad (1980-09-26) reported that the night between
+# Saturday and Sunday the clock is set back from three to two.
+
+# From Paul Eggert (2005-06-11):
+# Hence the "02:00" of the 1980 law refers to standard time, not
+# wall-clock time, and so the EU rules were in effect in 1980.
+
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Denmark 1916    only    -       May     14      23:00   1:00    S
+Rule   Denmark 1916    only    -       Sep     30      23:00   0       -
+Rule   Denmark 1940    only    -       May     15       0:00   1:00    S
+Rule   Denmark 1945    only    -       Apr      2       2:00s  1:00    S
+Rule   Denmark 1945    only    -       Aug     15       2:00s  0       -
+Rule   Denmark 1946    only    -       May      1       2:00s  1:00    S
+Rule   Denmark 1946    only    -       Sep      1       2:00s  0       -
+Rule   Denmark 1947    only    -       May      4       2:00s  1:00    S
+Rule   Denmark 1947    only    -       Aug     10       2:00s  0       -
+Rule   Denmark 1948    only    -       May      9       2:00s  1:00    S
+Rule   Denmark 1948    only    -       Aug      8       2:00s  0       -
+#
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone Europe/Copenhagen  0:50:20 -      LMT     1890
+                        0:50:20 -      CMT     1894 Jan  1 # Copenhagen MT
+                        1:00   Denmark CE%sT   1942 Nov  2 2:00s
+                        1:00   C-Eur   CE%sT   1945 Apr  2 2:00
+                        1:00   Denmark CE%sT   1980
+                        1:00   EU      CE%sT
+Zone Atlantic/Faroe    -0:27:04 -      LMT     1908 Jan 11     # Torshavn
+                        0:00   -       WET     1981
+                        0:00   EU      WE%sT
+#
+# From Paul Eggert (2004-10-31):
+# During World War II, Germany maintained secret manned weather stations in
+# East Greenland and Franz Josef Land, but we don't know their time zones.
+# My source for this is Wilhelm Dege's book mentioned under Svalbard.
+#
+# From Paul Eggert (2006-03-22):
+# Greenland joined the EU as part of Denmark, obtained home rule on 1979-05-01,
+# and left the EU on 1985-02-01.  It therefore should have been using EU
+# rules at least through 1984.  Shanks & Pottenger say Scoresbysund and Godthab
+# used C-Eur rules after 1980, but IATA SSIM (1991/1996) says they use EU
+# rules since at least 1991.  Assume EU rules since 1980.
+
+# From Gwillin Law (2001-06-06), citing
+# <http://www.statkart.no/efs/efshefter/2001/efs5-2001.pdf> (2001-03-15),
+# and with translations corrected by Steffen Thorsen:
+#
+# Greenland has four local times, and the relation to UTC
+# is according to the following time line:
+#
+# The military zone near Thule UTC-4
+# Standard Greenland time      UTC-3
+# Scoresbysund                 UTC-1
+# Danmarkshavn                 UTC
+#
+# In the military area near Thule and in Danmarkshavn DST will not be
+# introduced.
+
+# From Rives McDow (2001-11-01):
+#
+# I correspond regularly with the Dansk Polarcenter, and wrote them at
+# the time to clarify the situation in Thule.  Unfortunately, I have
+# not heard back from them regarding my recent letter.  [But I have
+# info from earlier correspondence.]
+#
+# According to the center, a very small local time zone around Thule
+# Air Base keeps the time according to UTC-4, implementing daylight
+# savings using North America rules, changing the time at 02:00 local time....
+#
+# The east coast of Greenland north of the community of Scoresbysund
+# uses UTC in the same way as in Iceland, year round, with no dst.
+# There are just a few stations on this coast, including the
+# Danmarkshavn ICAO weather station mentioned in your September 29th
+# email.  The other stations are two sledge patrol stations in
+# Mestersvig and Daneborg, the air force base at Station Nord, and the
+# DPC research station at Zackenberg.
+#
+# Scoresbysund and two small villages nearby keep time UTC-1 and use
+# the same daylight savings time period as in West Greenland (Godthab).
+#
+# The rest of Greenland, including Godthab (this area, although it
+# includes central Greenland, is known as west Greenland), keeps time
+# UTC-3, with daylight savings methods according to European rules.
+#
+# It is common procedure to use UTC 0 in the wilderness of East and
+# North Greenland, because it is mainly Icelandic aircraft operators
+# maintaining traffic in these areas.  However, the official status of
+# this area is that it sticks with Godthab time.  This area might be
+# considered a dual time zone in some respects because of this.
+
+# From Rives McDow (2001-11-19):
+# I heard back from someone stationed at Thule; the time change took place
+# there at 2:00 AM.
+
+# From Paul Eggert (2006-03-22):
+# From 1997 on the CIA map shows Danmarkshavn on GMT;
+# the 1995 map as like Godthab.
+# For lack of better info, assume they were like Godthab before 1996.
+# startkart.no says Thule does not observe DST, but this is clearly an error,
+# so go with Shanks & Pottenger for Thule transitions until this year.
+# For 2007 on assume Thule will stay in sync with US DST rules.
+#
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Thule   1991    1992    -       Mar     lastSun 2:00    1:00    D
+Rule   Thule   1991    1992    -       Sep     lastSun 2:00    0       S
+Rule   Thule   1993    2006    -       Apr     Sun>=1  2:00    1:00    D
+Rule   Thule   1993    2006    -       Oct     lastSun 2:00    0       S
+Rule   Thule   2007    max     -       Mar     Sun>=8  2:00    1:00    D
+Rule   Thule   2007    max     -       Nov     Sun>=1  2:00    0       S
+#
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone America/Danmarkshavn -1:14:40 -   LMT     1916 Jul 28
+                       -3:00   -       WGT     1980 Apr  6 2:00
+                       -3:00   EU      WG%sT   1996
+                       0:00    -       GMT
+Zone America/Scoresbysund -1:27:52 -   LMT     1916 Jul 28 # Ittoqqortoormiit
+                       -2:00   -       CGT     1980 Apr  6 2:00
+                       -2:00   C-Eur   CG%sT   1981 Mar 29
+                       -1:00   EU      EG%sT
+Zone America/Godthab   -3:26:56 -      LMT     1916 Jul 28 # Nuuk
+                       -3:00   -       WGT     1980 Apr  6 2:00
+                       -3:00   EU      WG%sT
+Zone America/Thule     -4:35:08 -      LMT     1916 Jul 28 # Pituffik air base
+                       -4:00   Thule   A%sT
+
+# Estonia
+# From Peter Ilieve (1994-10-15):
+# A relative in Tallinn confirms the accuracy of the data for 1989 onwards
+# [through 1994] and gives the legal authority for it,
+# a regulation of the Government of Estonia, No. 111 of 1989....
+#
+# From Peter Ilieve (1996-10-28):
+# [IATA SSIM (1992/1996) claims that the Baltic republics switch at 01:00s,
+# but a relative confirms that Estonia still switches at 02:00s, writing:]
+# ``I do not [know] exactly but there are some little different
+# (confusing) rules for International Air and Railway Transport Schedules
+# conversion in Sunday connected with end of summer time in Estonia....
+# A discussion is running about the summer time efficiency and effect on
+# human physiology.  It seems that Estonia maybe will not change to
+# summer time next spring.''
+
+# From Peter Ilieve (1998-11-04), heavily edited:
+# <a href="http://trip.rk.ee/cgi-bin/thw?${BASE}=akt&${OOHTML}=rtd&TA=1998&TO=1&AN=1390">
+# The 1998-09-22 Estonian time law
+# </a>
+# refers to the Eighth Directive and cites the association agreement between
+# the EU and Estonia, ratified by the Estonian law (RT II 1995, 22--27, 120).
+#
+# I also asked [my relative] whether they use any standard abbreviation
+# for their standard and summer times. He says no, they use "suveaeg"
+# (summer time) and "talveaeg" (winter time).
+
+# From <a href="http://www.baltictimes.com/">The Baltic Times</a> (1999-09-09)
+# via Steffen Thorsen:
+# This year will mark the last time Estonia shifts to summer time,
+# a council of the ruling coalition announced Sept. 6....
+# But what this could mean for Estonia's chances of joining the European
+# Union are still unclear.  In 1994, the EU declared summer time compulsory
+# for all member states until 2001.  Brussels has yet to decide what to do
+# after that.
+
+# From Mart Oruaas (2000-01-29):
+# Regulation no. 301 (1999-10-12) obsoletes previous regulation
+# no. 206 (1998-09-22) and thus sticks Estonia to +02:00 GMT for all
+# the year round.  The regulation is effective 1999-11-01.
+
+# From Toomas Soome (2002-02-21):
+# The Estonian government has changed once again timezone politics.
+# Now we are using again EU rules.
+#
+# From Urmet Jaanes (2002-03-28):
+# The legislative reference is Government decree No. 84 on 2002-02-21.
+
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Europe/Tallinn  1:39:00 -       LMT     1880
+                       1:39:00 -       TMT     1918 Feb # Tallinn Mean Time
+                       1:00    C-Eur   CE%sT   1919 Jul
+                       1:39:00 -       TMT     1921 May
+                       2:00    -       EET     1940 Aug  6
+                       3:00    -       MSK     1941 Sep 15
+                       1:00    C-Eur   CE%sT   1944 Sep 22
+                       3:00    Russia  MSK/MSD 1989 Mar 26 2:00s
+                       2:00    1:00    EEST    1989 Sep 24 2:00s
+                       2:00    C-Eur   EE%sT   1998 Sep 22
+                       2:00    EU      EE%sT   1999 Nov  1
+                       2:00    -       EET     2002 Feb 21
+                       2:00    EU      EE%sT
+
+# Finland
+#
+# From Hannu Strang (1994-09-25 06:03:37 UTC):
+# Well, here in Helsinki we're just changing from summer time to regular one,
+# and it's supposed to change at 4am...
+#
+# From Paul Eggert (2006-03-22):
+# Shanks & Pottenger say Finland has switched at 02:00 standard time
+# since 1981.  Go with Strang instead.
+#
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Finland 1942    only    -       Apr     3       0:00    1:00    S
+Rule   Finland 1942    only    -       Oct     3       0:00    0       -
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Europe/Helsinki 1:39:52 -       LMT     1878 May 31
+                       1:39:52 -       HMT     1921 May    # Helsinki Mean Time
+                       2:00    Finland EE%sT   1981 Mar 29 2:00
+                       2:00    EU      EE%sT
+
+# Aaland Is
+Link   Europe/Helsinki Europe/Mariehamn
+
+
+# France
+
+# From Ciro Discepolo (2000-12-20):
+#
+# Henri Le Corre, Regimes Horaires pour le monde entier, Editions
+# Traditionnelles - Paris 2 books, 1993
+#
+# Gabriel, Traite de l'heure dans le monde, Guy Tredaniel editeur,
+# Paris, 1991
+#
+# Francoise Gauquelin, Problemes de l'heure resolus en astrologie,
+# Guy tredaniel, Paris 1987
+
+
+#
+# Shank & Pottenger seem to use `24:00' ambiguously; resolve it with Whitman.
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   France  1916    only    -       Jun     14      23:00s  1:00    S
+Rule   France  1916    1919    -       Oct     Sun>=1  23:00s  0       -
+Rule   France  1917    only    -       Mar     24      23:00s  1:00    S
+Rule   France  1918    only    -       Mar      9      23:00s  1:00    S
+Rule   France  1919    only    -       Mar      1      23:00s  1:00    S
+Rule   France  1920    only    -       Feb     14      23:00s  1:00    S
+Rule   France  1920    only    -       Oct     23      23:00s  0       -
+Rule   France  1921    only    -       Mar     14      23:00s  1:00    S
+Rule   France  1921    only    -       Oct     25      23:00s  0       -
+Rule   France  1922    only    -       Mar     25      23:00s  1:00    S
+# DSH writes that a law of 1923-05-24 specified 3rd Sat in Apr at 23:00 to 1st
+# Sat in Oct at 24:00; and that in 1930, because of Easter, the transitions
+# were Apr 12 and Oct 5.  Go with Shanks & Pottenger.
+Rule   France  1922    1938    -       Oct     Sat>=1  23:00s  0       -
+Rule   France  1923    only    -       May     26      23:00s  1:00    S
+Rule   France  1924    only    -       Mar     29      23:00s  1:00    S
+Rule   France  1925    only    -       Apr      4      23:00s  1:00    S
+Rule   France  1926    only    -       Apr     17      23:00s  1:00    S
+Rule   France  1927    only    -       Apr      9      23:00s  1:00    S
+Rule   France  1928    only    -       Apr     14      23:00s  1:00    S
+Rule   France  1929    only    -       Apr     20      23:00s  1:00    S
+Rule   France  1930    only    -       Apr     12      23:00s  1:00    S
+Rule   France  1931    only    -       Apr     18      23:00s  1:00    S
+Rule   France  1932    only    -       Apr      2      23:00s  1:00    S
+Rule   France  1933    only    -       Mar     25      23:00s  1:00    S
+Rule   France  1934    only    -       Apr      7      23:00s  1:00    S
+Rule   France  1935    only    -       Mar     30      23:00s  1:00    S
+Rule   France  1936    only    -       Apr     18      23:00s  1:00    S
+Rule   France  1937    only    -       Apr      3      23:00s  1:00    S
+Rule   France  1938    only    -       Mar     26      23:00s  1:00    S
+Rule   France  1939    only    -       Apr     15      23:00s  1:00    S
+Rule   France  1939    only    -       Nov     18      23:00s  0       -
+Rule   France  1940    only    -       Feb     25       2:00   1:00    S
+# The French rules for 1941-1944 were not used in Paris, but Shanks & Pottenger
+# write that they were used in Monaco and in many French locations.
+# Le Corre writes that the upper limit of the free zone was Arneguy, Orthez,
+# Mont-de-Marsan, Bazas, Langon, Lamotte-Montravel, Marouil, La
+# Rochefoucault, Champagne-Mouton, La Roche-Posay, La Haye-Decartes,
+# Loches, Montrichard, Vierzon, Bourges, Moulins, Digoin,
+# Paray-le-Monial, Montceau-les-Mines, Chalons-sur-Saone, Arbois,
+# Dole, Morez, St-Claude, and Collognes (Haute-Savioe).
+Rule   France  1941    only    -       May      5       0:00   2:00    M # Midsummer
+# Shanks & Pottenger say this transition occurred at Oct 6 1:00,
+# but go with Denis Excoffier (1997-12-12),
+# who quotes the Ephemerides Astronomiques for 1998 from Bureau des Longitudes
+# as saying 5/10/41 22hUT.
+Rule   France  1941    only    -       Oct      6       0:00   1:00    S
+Rule   France  1942    only    -       Mar      9       0:00   2:00    M
+Rule   France  1942    only    -       Nov      2       3:00   1:00    S
+Rule   France  1943    only    -       Mar     29       2:00   2:00    M
+Rule   France  1943    only    -       Oct      4       3:00   1:00    S
+Rule   France  1944    only    -       Apr      3       2:00   2:00    M
+Rule   France  1944    only    -       Oct      8       1:00   1:00    S
+Rule   France  1945    only    -       Apr      2       2:00   2:00    M
+Rule   France  1945    only    -       Sep     16       3:00   0       -
+# Shanks & Pottenger give Mar 28 2:00 and Sep 26 3:00;
+# go with Excoffier's 28/3/76 0hUT and 25/9/76 23hUT.
+Rule   France  1976    only    -       Mar     28       1:00   1:00    S
+Rule   France  1976    only    -       Sep     26       1:00   0       -
+# Shanks & Pottenger give 0:09:20 for Paris Mean Time, and Whitman 0:09:05,
+# but Howse quotes the actual French legislation as saying 0:09:21.
+# Go with Howse.  Howse writes that the time in France was officially based
+# on PMT-0:09:21 until 1978-08-09, when the time base finally switched to UTC.
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Europe/Paris    0:09:21 -       LMT     1891 Mar 15  0:01
+                       0:09:21 -       PMT     1911 Mar 11  0:01  # Paris MT
+# Shanks & Pottenger give 1940 Jun 14 0:00; go with Excoffier and Le Corre.
+                       0:00    France  WE%sT   1940 Jun 14 23:00
+# Le Corre says Paris stuck with occupied-France time after the liberation;
+# go with Shanks & Pottenger.
+                       1:00    C-Eur   CE%sT   1944 Aug 25
+                       0:00    France  WE%sT   1945 Sep 16  3:00
+                       1:00    France  CE%sT   1977
+                       1:00    EU      CE%sT
+
+# Germany
+
+# From Markus Kuhn (1998-09-29):
+# The German time zone web site by the Physikalisch-Technische
+# Bundesanstalt contains DST information back to 1916.
+# [See tz-link.htm for the URL.]
+
+# From Joerg Schilling (2002-10-23):
+# In 1945, Berlin was switched to Moscow Summer time (GMT+4) by
+# <a href="http://www.dhm.de/lemo/html/biografien/BersarinNikolai/">
+# General [Nikolai] Bersarin</a>.
+
+# From Paul Eggert (2003-03-08):
+# <a href="http://www.parlament-berlin.de/pds-fraktion.nsf/727459127c8b66ee8525662300459099/defc77cb784f180ac1256c2b0030274b/$FILE/bersarint.pdf">
+# http://www.parlament-berlin.de/pds-fraktion.nsf/727459127c8b66ee8525662300459099/defc77cb784f180ac1256c2b0030274b/$FILE/bersarint.pdf
+# </a>
+# says that Bersarin issued an order to use Moscow time on May 20.
+# However, Moscow did not observe daylight saving in 1945, so
+# this was equivalent to CEMT (GMT+3), not GMT+4.
+
+
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Germany 1946    only    -       Apr     14      2:00s   1:00    S
+Rule   Germany 1946    only    -       Oct      7      2:00s   0       -
+Rule   Germany 1947    1949    -       Oct     Sun>=1  2:00s   0       -
+# http://www.ptb.de/de/org/4/44/441/salt.htm says the following transition
+# occurred at 3:00 MEZ, not the 2:00 MEZ given in Shanks & Pottenger.
+# Go with the PTB.
+Rule   Germany 1947    only    -       Apr      6      3:00s   1:00    S
+Rule   Germany 1947    only    -       May     11      2:00s   2:00    M
+Rule   Germany 1947    only    -       Jun     29      3:00    1:00    S
+Rule   Germany 1948    only    -       Apr     18      2:00s   1:00    S
+Rule   Germany 1949    only    -       Apr     10      2:00s   1:00    S
+
+Rule SovietZone        1945    only    -       May     24      2:00    2:00    M # Midsummer
+Rule SovietZone        1945    only    -       Sep     24      3:00    1:00    S
+Rule SovietZone        1945    only    -       Nov     18      2:00s   0       -
+
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Europe/Berlin   0:53:28 -       LMT     1893 Apr
+                       1:00    C-Eur   CE%sT   1945 May 24 2:00
+                       1:00 SovietZone CE%sT   1946
+                       1:00    Germany CE%sT   1980
+                       1:00    EU      CE%sT
+
+# Georgia
+# Please see the "asia" file for Asia/Tbilisi.
+# Herodotus (Histories, IV.45) says Georgia north of the Phasis (now Rioni)
+# is in Europe.  Our reference location Tbilisi is in the Asian part.
+
+# Gibraltar
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone Europe/Gibraltar  -0:21:24 -      LMT     1880 Aug  2 0:00s
+                       0:00    GB-Eire %s      1957 Apr 14 2:00
+                       1:00    -       CET     1982
+                       1:00    EU      CE%sT
+
+# Greece
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+# Whitman gives 1932 Jul 5 - Nov 1; go with Shanks & Pottenger.
+Rule   Greece  1932    only    -       Jul      7      0:00    1:00    S
+Rule   Greece  1932    only    -       Sep      1      0:00    0       -
+# Whitman gives 1941 Apr 25 - ?; go with Shanks & Pottenger.
+Rule   Greece  1941    only    -       Apr      7      0:00    1:00    S
+# Whitman gives 1942 Feb 2 - ?; go with Shanks & Pottenger.
+Rule   Greece  1942    only    -       Nov      2      3:00    0       -
+Rule   Greece  1943    only    -       Mar     30      0:00    1:00    S
+Rule   Greece  1943    only    -       Oct      4      0:00    0       -
+# Whitman gives 1944 Oct 3 - Oct 31; go with Shanks & Pottenger.
+Rule   Greece  1952    only    -       Jul      1      0:00    1:00    S
+Rule   Greece  1952    only    -       Nov      2      0:00    0       -
+Rule   Greece  1975    only    -       Apr     12      0:00s   1:00    S
+Rule   Greece  1975    only    -       Nov     26      0:00s   0       -
+Rule   Greece  1976    only    -       Apr     11      2:00s   1:00    S
+Rule   Greece  1976    only    -       Oct     10      2:00s   0       -
+Rule   Greece  1977    1978    -       Apr     Sun>=1  2:00s   1:00    S
+Rule   Greece  1977    only    -       Sep     26      2:00s   0       -
+Rule   Greece  1978    only    -       Sep     24      4:00    0       -
+Rule   Greece  1979    only    -       Apr      1      9:00    1:00    S
+Rule   Greece  1979    only    -       Sep     29      2:00    0       -
+Rule   Greece  1980    only    -       Apr      1      0:00    1:00    S
+Rule   Greece  1980    only    -       Sep     28      0:00    0       -
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Europe/Athens   1:34:52 -       LMT     1895 Sep 14
+                       1:34:52 -       AMT     1916 Jul 28 0:01     # Athens MT
+                       2:00    Greece  EE%sT   1941 Apr 30
+                       1:00    Greece  CE%sT   1944 Apr  4
+                       2:00    Greece  EE%sT   1981
+                       # Shanks & Pottenger say it switched to C-Eur in 1981;
+                       # go with EU instead, since Greece joined it on Jan 1.
+                       2:00    EU      EE%sT
+
+# Hungary
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Hungary 1918    only    -       Apr      1       3:00   1:00    S
+Rule   Hungary 1918    only    -       Sep     29       3:00   0       -
+Rule   Hungary 1919    only    -       Apr     15       3:00   1:00    S
+Rule   Hungary 1919    only    -       Sep     15       3:00   0       -
+Rule   Hungary 1920    only    -       Apr      5       3:00   1:00    S
+Rule   Hungary 1920    only    -       Sep     30       3:00   0       -
+Rule   Hungary 1945    only    -       May      1      23:00   1:00    S
+Rule   Hungary 1945    only    -       Nov      3       0:00   0       -
+Rule   Hungary 1946    only    -       Mar     31       2:00s  1:00    S
+Rule   Hungary 1946    1949    -       Oct     Sun>=1   2:00s  0       -
+Rule   Hungary 1947    1949    -       Apr     Sun>=4   2:00s  1:00    S
+Rule   Hungary 1950    only    -       Apr     17       2:00s  1:00    S
+Rule   Hungary 1950    only    -       Oct     23       2:00s  0       -
+Rule   Hungary 1954    1955    -       May     23       0:00   1:00    S
+Rule   Hungary 1954    1955    -       Oct      3       0:00   0       -
+Rule   Hungary 1956    only    -       Jun     Sun>=1   0:00   1:00    S
+Rule   Hungary 1956    only    -       Sep     lastSun  0:00   0       -
+Rule   Hungary 1957    only    -       Jun     Sun>=1   1:00   1:00    S
+Rule   Hungary 1957    only    -       Sep     lastSun  3:00   0       -
+Rule   Hungary 1980    only    -       Apr      6       1:00   1:00    S
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Europe/Budapest 1:16:20 -       LMT     1890 Oct
+                       1:00    C-Eur   CE%sT   1918
+                       1:00    Hungary CE%sT   1941 Apr  6  2:00
+                       1:00    C-Eur   CE%sT   1945
+                       1:00    Hungary CE%sT   1980 Sep 28  2:00s
+                       1:00    EU      CE%sT
+
+# Iceland
+#
+# From Adam David (1993-11-06):
+# The name of the timezone in Iceland for system / mail / news purposes is GMT.
+#
+# (1993-12-05):
+# This material is paraphrased from the 1988 edition of the University of
+# Iceland Almanak.
+#
+# From January 1st, 1908 the whole of Iceland was standardised at 1 hour
+# behind GMT. Previously, local mean solar time was used in different parts
+# of Iceland, the almanak had been based on Reykjavik mean solar time which
+# was 1 hour and 28 minutes behind GMT.
+#
+# "first day of winter" referred to [below] means the first day of the 26 weeks
+# of winter, according to the old icelandic calendar that dates back to the
+# time the norsemen first settled Iceland.  The first day of winter is always
+# Saturday, but is not dependent on the Julian or Gregorian calendars.
+#
+# (1993-12-10):
+# I have a reference from the Oxford Icelandic-English dictionary for the
+# beginning of winter, which ties it to the ecclesiastical calendar (and thus
+# to the julian/gregorian calendar) over the period in question.
+#      the winter begins on the Saturday next before St. Luke's day
+#      (old style), or on St. Luke's day, if a Saturday.
+# St. Luke's day ought to be traceable from ecclesiastical sources. "old style"
+# might be a reference to the Julian calendar as opposed to Gregorian, or it
+# might mean something else (???).
+#
+# From Paul Eggert (2006-03-22):
+# The Iceland Almanak, Shanks & Pottenger, and Whitman disagree on many points.
+# We go with the Almanak, except for one claim from Shanks & Pottenger, namely
+# that Reykavik was 21W57 from 1837 to 1908, local mean time before that.
+#
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Iceland 1917    1918    -       Feb     19      23:00   1:00    S
+Rule   Iceland 1917    only    -       Oct     21       1:00   0       -
+Rule   Iceland 1918    only    -       Nov     16       1:00   0       -
+Rule   Iceland 1939    only    -       Apr     29      23:00   1:00    S
+Rule   Iceland 1939    only    -       Nov     29       2:00   0       -
+Rule   Iceland 1940    only    -       Feb     25       2:00   1:00    S
+Rule   Iceland 1940    only    -       Nov      3       2:00   0       -
+Rule   Iceland 1941    only    -       Mar      2       1:00s  1:00    S
+Rule   Iceland 1941    only    -       Nov      2       1:00s  0       -
+Rule   Iceland 1942    only    -       Mar      8       1:00s  1:00    S
+Rule   Iceland 1942    only    -       Oct     25       1:00s  0       -
+# 1943-1946 - first Sunday in March until first Sunday in winter
+Rule   Iceland 1943    1946    -       Mar     Sun>=1   1:00s  1:00    S
+Rule   Iceland 1943    1948    -       Oct     Sun>=22  1:00s  0       -
+# 1947-1967 - first Sunday in April until first Sunday in winter
+Rule   Iceland 1947    1967    -       Apr     Sun>=1   1:00s  1:00    S
+# 1949 Oct transition delayed by 1 week
+Rule   Iceland 1949    only    -       Oct     30       1:00s  0       -
+Rule   Iceland 1950    1966    -       Oct     Sun>=22  1:00s  0       -
+Rule   Iceland 1967    only    -       Oct     29       1:00s  0       -
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone Atlantic/Reykjavik        -1:27:24 -      LMT     1837
+                       -1:27:48 -      RMT     1908 # Reykjavik Mean Time?
+                       -1:00   Iceland IS%sT   1968 Apr 7 1:00s
+                        0:00   -       GMT
+
+# Italy
+#
+# From Paul Eggert (2001-03-06):
+# Sicily and Sardinia each had their own time zones from 1866 to 1893,
+# called Palermo Time (+00:53:28) and Cagliari Time (+00:36:32).
+# During World War II, German-controlled Italy used German time.
+# But these events all occurred before the 1970 cutoff,
+# so record only the time in Rome.
+#
+# From Paul Eggert (2006-03-22):
+# For Italian DST we have three sources: Shanks & Pottenger, Whitman, and
+# F. Pollastri
+# <a href="http://toi.iriti.cnr.it/uk/ienitlt.html">
+# Day-light Saving Time in Italy (2006-02-03)
+# </a>
+# (`FP' below), taken from an Italian National Electrotechnical Institute
+# publication. When the three sources disagree, guess who's right, as follows:
+#
+# year FP      Shanks&P. (S)   Whitman (W)     Go with:
+# 1916 06-03   06-03 24:00     06-03 00:00     FP & W
+#      09-30   09-30 24:00     09-30 01:00     FP; guess 24:00s
+# 1917 04-01   03-31 24:00     03-31 00:00     FP & S
+#      09-30   09-29 24:00     09-30 01:00     FP & W
+# 1918 03-09   03-09 24:00     03-09 00:00     FP & S
+#      10-06   10-05 24:00     10-06 01:00     FP & W
+# 1919 03-01   03-01 24:00     03-01 00:00     FP & S
+#      10-04   10-04 24:00     10-04 01:00     FP; guess 24:00s
+# 1920 03-20   03-20 24:00     03-20 00:00     FP & S
+#      09-18   09-18 24:00     10-01 01:00     FP; guess 24:00s
+# 1944 04-02   04-03 02:00                     S (see C-Eur)
+#      09-16   10-02 03:00                     FP; guess 24:00s
+# 1945 09-14   09-16 24:00                     FP; guess 24:00s
+# 1970 05-21   05-31 00:00                     S
+#      09-20   09-27 00:00                     S
+#
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Italy   1916    only    -       Jun      3      0:00s   1:00    S
+Rule   Italy   1916    only    -       Oct      1      0:00s   0       -
+Rule   Italy   1917    only    -       Apr      1      0:00s   1:00    S
+Rule   Italy   1917    only    -       Sep     30      0:00s   0       -
+Rule   Italy   1918    only    -       Mar     10      0:00s   1:00    S
+Rule   Italy   1918    1919    -       Oct     Sun>=1  0:00s   0       -
+Rule   Italy   1919    only    -       Mar      2      0:00s   1:00    S
+Rule   Italy   1920    only    -       Mar     21      0:00s   1:00    S
+Rule   Italy   1920    only    -       Sep     19      0:00s   0       -
+Rule   Italy   1940    only    -       Jun     15      0:00s   1:00    S
+Rule   Italy   1944    only    -       Sep     17      0:00s   0       -
+Rule   Italy   1945    only    -       Apr      2      2:00    1:00    S
+Rule   Italy   1945    only    -       Sep     15      0:00s   0       -
+Rule   Italy   1946    only    -       Mar     17      2:00s   1:00    S
+Rule   Italy   1946    only    -       Oct      6      2:00s   0       -
+Rule   Italy   1947    only    -       Mar     16      0:00s   1:00    S
+Rule   Italy   1947    only    -       Oct      5      0:00s   0       -
+Rule   Italy   1948    only    -       Feb     29      2:00s   1:00    S
+Rule   Italy   1948    only    -       Oct      3      2:00s   0       -
+Rule   Italy   1966    1968    -       May     Sun>=22 0:00    1:00    S
+Rule   Italy   1966    1969    -       Sep     Sun>=22 0:00    0       -
+Rule   Italy   1969    only    -       Jun      1      0:00    1:00    S
+Rule   Italy   1970    only    -       May     31      0:00    1:00    S
+Rule   Italy   1970    only    -       Sep     lastSun 0:00    0       -
+Rule   Italy   1971    1972    -       May     Sun>=22 0:00    1:00    S
+Rule   Italy   1971    only    -       Sep     lastSun 1:00    0       -
+Rule   Italy   1972    only    -       Oct      1      0:00    0       -
+Rule   Italy   1973    only    -       Jun      3      0:00    1:00    S
+Rule   Italy   1973    1974    -       Sep     lastSun 0:00    0       -
+Rule   Italy   1974    only    -       May     26      0:00    1:00    S
+Rule   Italy   1975    only    -       Jun      1      0:00s   1:00    S
+Rule   Italy   1975    1977    -       Sep     lastSun 0:00s   0       -
+Rule   Italy   1976    only    -       May     30      0:00s   1:00    S
+Rule   Italy   1977    1979    -       May     Sun>=22 0:00s   1:00    S
+Rule   Italy   1978    only    -       Oct      1      0:00s   0       -
+Rule   Italy   1979    only    -       Sep     30      0:00s   0       -
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Europe/Rome     0:49:56 -       LMT     1866 Sep 22
+                       0:49:56 -       RMT     1893 Nov  1 0:00s # Rome Mean
+                       1:00    Italy   CE%sT   1942 Nov  2 2:00s
+                       1:00    C-Eur   CE%sT   1944 Jul
+                       1:00    Italy   CE%sT   1980
+                       1:00    EU      CE%sT
+
+Link   Europe/Rome     Europe/Vatican
+Link   Europe/Rome     Europe/San_Marino
+
+# Latvia
+
+# From Liene Kanepe (1998-09-17):
+
+# I asked about this matter Scientific Secretary of the Institute of Astronomy
+# of The University of Latvia Dr. paed Mr. Ilgonis Vilks. I also searched the
+# correct data in juridical acts and I found some juridical documents about
+# changes in the counting of time in Latvia from 1981....
+#
+# Act No.35 of the Council of Ministers of Latvian SSR of 1981-01-22 ...
+# according to the Act No.925 of the Council of Ministers of USSR of 1980-10-24
+# ...: all year round the time of 2nd time zone + 1 hour, in addition turning
+# the hands of the clock 1 hour forward on 1 April at 00:00 (GMT 31 March 21:00)
+# and 1 hour backward on the 1 October at 00:00 (GMT 30 September 20:00).
+#
+# Act No.592 of the Council of Ministers of Latvian SSR of 1984-09-24 ...
+# according to the Act No.967 of the Council of Ministers of USSR of 1984-09-13
+# ...: all year round the time of 2nd time zone + 1 hour, in addition turning
+# the hands of the clock 1 hour forward on the last Sunday of March at 02:00
+# (GMT 23:00 on the previous day) and 1 hour backward on the last Sunday of
+# September at 03:00 (GMT 23:00 on the previous day).
+#
+# Act No.81 of the Council of Ministers of Latvian SSR of 1989-03-22 ...
+# according to the Act No.227 of the Council of Ministers of USSR of 1989-03-14
+# ...: since the last Sunday of March 1989 in Lithuanian SSR, Latvian SSR,
+# Estonian SSR and Kaliningrad region of Russian Federation all year round the
+# time of 2nd time zone (Moscow time minus one hour). On the territory of Latvia
+# transition to summer time is performed on the last Sunday of March at 02:00
+# (GMT 00:00), turning the hands of the clock 1 hour forward.  The end of
+# daylight saving time is performed on the last Sunday of September at 03:00
+# (GMT 00:00), turning the hands of the clock 1 hour backward. Exception is
+# 1989-03-26, when we must not turn the hands of the clock....
+#
+# The Regulations of the Cabinet of Ministers of the Republic of Latvia of
+# 1997-01-21 on transition to Summer time ... established the same order of
+# daylight savings time settings as in the States of the European Union.
+
+# From Andrei Ivanov (2000-03-06):
+# This year Latvia will not switch to Daylight Savings Time (as specified in
+# <a href="http://www.lv-laiks.lv/wwwraksti/2000/071072/vd4.htm">
+# The Regulations of the Cabinet of Ministers of the Rep. of Latvia of
+# 29-Feb-2000 (#79)</a>, in Latvian for subscribers only).
+
+# <a href="http://www.rferl.org/newsline/2001/01/3-CEE/cee-030101.html">
+# From RFE/RL Newsline (2001-01-03), noted after a heads-up by Rives McDow:
+# </a>
+# The Latvian government on 2 January decided that the country will
+# institute daylight-saving time this spring, LETA reported.
+# Last February the three Baltic states decided not to turn back their
+# clocks one hour in the spring....
+# Minister of Economy Aigars Kalvitis noted that Latvia had too few
+# daylight hours and thus decided to comply with a draft European
+# Commission directive that provides for instituting daylight-saving
+# time in EU countries between 2002 and 2006. The Latvian government
+# urged Lithuania and Estonia to adopt a similar time policy, but it
+# appears that they will not do so....
+
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Latvia  1989    1996    -       Mar     lastSun  2:00s  1:00    S
+Rule   Latvia  1989    1996    -       Sep     lastSun  2:00s  0       -
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Europe/Riga     1:36:24 -       LMT     1880
+                       1:36:24 -       RMT     1918 Apr 15 2:00 #Riga Mean Time
+                       1:36:24 1:00    LST     1918 Sep 16 3:00 #Latvian Summer
+                       1:36:24 -       RMT     1919 Apr  1 2:00
+                       1:36:24 1:00    LST     1919 May 22 3:00
+                       1:36:24 -       RMT     1926 May 11
+                       2:00    -       EET     1940 Aug  5
+                       3:00    -       MSK     1941 Jul
+                       1:00    C-Eur   CE%sT   1944 Oct 13
+                       3:00    Russia  MSK/MSD 1989 Mar lastSun 2:00s
+                       2:00    1:00    EEST    1989 Sep lastSun 2:00s
+                       2:00    Latvia  EE%sT   1997 Jan 21
+                       2:00    EU      EE%sT   2000 Feb 29
+                       2:00    -       EET     2001 Jan  2
+                       2:00    EU      EE%sT
+
+# Liechtenstein
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Europe/Vaduz    0:38:04 -       LMT     1894 Jun
+                       1:00    -       CET     1981
+                       1:00    EU      CE%sT
+
+# Lithuania
+
+# From Paul Eggert (1996-11-22):
+# IATA SSIM (1992/1996) says Lithuania uses W-Eur rules, but since it is
+# known to be wrong about Estonia and Latvia, assume it's wrong here too.
+
+# From Marius Gedminas (1998-08-07):
+# I would like to inform that in this year Lithuanian time zone
+# (Europe/Vilnius) was changed.
+
+# From <a href="http://www.elta.lt/">ELTA</a> No. 972 (2582) (1999-09-29),
+# via Steffen Thorsen:
+# Lithuania has shifted back to the second time zone (GMT plus two hours)
+# to be valid here starting from October 31,
+# as decided by the national government on Wednesday....
+# The Lithuanian government also announced plans to consider a
+# motion to give up shifting to summer time in spring, as it was
+# already done by Estonia.
+
+# From the <a href="http://www.tourism.lt/informa/ff.htm">
+# Fact File, Lithuanian State Department of Tourism
+# </a> (2000-03-27): Local time is GMT+2 hours ..., no daylight saving.
+
+# From a user via Klaus Marten (2003-02-07):
+# As a candidate for membership of the European Union, Lithuania will
+# observe Summer Time in 2003, changing its clocks at the times laid
+# down in EU Directive 2000/84 of 19.I.01 (i.e. at the same times as its
+# neighbour Latvia). The text of the Lithuanian government Order of
+# 7.XI.02 to this effect can be found at
+# http://www.lrvk.lt/nut/11/n1749.htm
+
+
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Europe/Vilnius  1:41:16 -       LMT     1880
+                       1:24:00 -       WMT     1917        # Warsaw Mean Time
+                       1:35:36 -       KMT     1919 Oct 10 # Kaunas Mean Time
+                       1:00    -       CET     1920 Jul 12
+                       2:00    -       EET     1920 Oct  9
+                       1:00    -       CET     1940 Aug  3
+                       3:00    -       MSK     1941 Jun 24
+                       1:00    C-Eur   CE%sT   1944 Aug
+                       3:00    Russia  MSK/MSD 1991 Mar 31 2:00s
+                       2:00    1:00    EEST    1991 Sep 29 2:00s
+                       2:00    C-Eur   EE%sT   1998
+                       2:00    -       EET     1998 Mar 29 1:00u
+                       1:00    EU      CE%sT   1999 Oct 31 1:00u
+                       2:00    -       EET     2003 Jan  1
+                       2:00    EU      EE%sT
+
+# Luxembourg
+# Whitman disagrees with most of these dates in minor ways;
+# go with Shanks & Pottenger.
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Lux     1916    only    -       May     14      23:00   1:00    S
+Rule   Lux     1916    only    -       Oct      1       1:00   0       -
+Rule   Lux     1917    only    -       Apr     28      23:00   1:00    S
+Rule   Lux     1917    only    -       Sep     17       1:00   0       -
+Rule   Lux     1918    only    -       Apr     Mon>=15  2:00s  1:00    S
+Rule   Lux     1918    only    -       Sep     Mon>=15  2:00s  0       -
+Rule   Lux     1919    only    -       Mar      1      23:00   1:00    S
+Rule   Lux     1919    only    -       Oct      5       3:00   0       -
+Rule   Lux     1920    only    -       Feb     14      23:00   1:00    S
+Rule   Lux     1920    only    -       Oct     24       2:00   0       -
+Rule   Lux     1921    only    -       Mar     14      23:00   1:00    S
+Rule   Lux     1921    only    -       Oct     26       2:00   0       -
+Rule   Lux     1922    only    -       Mar     25      23:00   1:00    S
+Rule   Lux     1922    only    -       Oct     Sun>=2   1:00   0       -
+Rule   Lux     1923    only    -       Apr     21      23:00   1:00    S
+Rule   Lux     1923    only    -       Oct     Sun>=2   2:00   0       -
+Rule   Lux     1924    only    -       Mar     29      23:00   1:00    S
+Rule   Lux     1924    1928    -       Oct     Sun>=2   1:00   0       -
+Rule   Lux     1925    only    -       Apr      5      23:00   1:00    S
+Rule   Lux     1926    only    -       Apr     17      23:00   1:00    S
+Rule   Lux     1927    only    -       Apr      9      23:00   1:00    S
+Rule   Lux     1928    only    -       Apr     14      23:00   1:00    S
+Rule   Lux     1929    only    -       Apr     20      23:00   1:00    S
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone Europe/Luxembourg 0:24:36 -       LMT     1904 Jun
+                       1:00    Lux     CE%sT   1918 Nov 25
+                       0:00    Lux     WE%sT   1929 Oct  6 2:00s
+                       0:00    Belgium WE%sT   1940 May 14 3:00
+                       1:00    C-Eur   WE%sT   1944 Sep 18 3:00
+                       1:00    Belgium CE%sT   1977
+                       1:00    EU      CE%sT
+
+# Macedonia
+# see Serbia
+
+# Malta
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Malta   1973    only    -       Mar     31      0:00s   1:00    S
+Rule   Malta   1973    only    -       Sep     29      0:00s   0       -
+Rule   Malta   1974    only    -       Apr     21      0:00s   1:00    S
+Rule   Malta   1974    only    -       Sep     16      0:00s   0       -
+Rule   Malta   1975    1979    -       Apr     Sun>=15 2:00    1:00    S
+Rule   Malta   1975    1980    -       Sep     Sun>=15 2:00    0       -
+Rule   Malta   1980    only    -       Mar     31      2:00    1:00    S
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Europe/Malta    0:58:04 -       LMT     1893 Nov  2 0:00s # Valletta
+                       1:00    Italy   CE%sT   1942 Nov  2 2:00s
+                       1:00    C-Eur   CE%sT   1945 Apr  2 2:00s
+                       1:00    Italy   CE%sT   1973 Mar 31
+                       1:00    Malta   CE%sT   1981
+                       1:00    EU      CE%sT
+
+# Moldova
+
+# From Paul Eggert (2006-03-22):
+# A previous version of this database followed Shanks & Pottenger, who write
+# that Tiraspol switched to Moscow time on 1992-01-19 at 02:00.
+# However, this is most likely an error, as Moldova declared independence
+# on 1991-08-27 (the 1992-01-19 date is that of a Russian decree).
+# In early 1992 there was large-scale interethnic violence in the area
+# and it's possible that some Russophones continued to observe Moscow time.
+# But [two people] separately reported via
+# Jesper Norgaard that as of 2001-01-24 Tiraspol was like Chisinau.
+# The Tiraspol entry has therefore been removed for now.
+
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Europe/Chisinau 1:55:20 -       LMT     1880
+                       1:55    -       CMT     1918 Feb 15 # Chisinau MT
+                       1:44:24 -       BMT     1931 Jul 24 # Bucharest MT
+                       2:00    Romania EE%sT   1940 Aug 15
+                       2:00    1:00    EEST    1941 Jul 17
+                       1:00    C-Eur   CE%sT   1944 Aug 24
+                       3:00    Russia  MSK/MSD 1990
+                       3:00    -       MSK     1990 May 6
+                       2:00    -       EET     1991
+                       2:00    Russia  EE%sT   1992
+                       2:00    E-Eur   EE%sT   1997
+# See Romania commentary for the guessed 1997 transition to EU rules.
+                       2:00    EU      EE%sT
+
+# Monaco
+# Shanks & Pottenger give 0:09:20 for Paris Mean Time; go with Howse's
+# more precise 0:09:21.
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Europe/Monaco   0:29:32 -       LMT     1891 Mar 15
+                       0:09:21 -       PMT     1911 Mar 11    # Paris Mean Time
+                       0:00    France  WE%sT   1945 Sep 16 3:00
+                       1:00    France  CE%sT   1977
+                       1:00    EU      CE%sT
+
+# Montenegro
+# see Serbia
+
+# Netherlands
+
+# Howse writes that the Netherlands' railways used GMT between 1892 and 1940,
+# but for other purposes the Netherlands used Amsterdam mean time.
+
+# However, Robert H. van Gent writes (2001-04-01):
+# Howse's statement is only correct up to 1909. From 1909-05-01 (00:00:00
+# Amsterdam mean time) onwards, the whole of the Netherlands (including
+# the Dutch railways) was required by law to observe Amsterdam mean time
+# (19 minutes 32.13 seconds ahead of GMT). This had already been the
+# common practice (except for the railways) for many decades but it was
+# not until 1909 when the Dutch government finally defined this by law.
+# On 1937-07-01 this was changed to 20 minutes (exactly) ahead of GMT and
+# was generally known as Dutch Time ("Nederlandse Tijd").
+#
+# (2001-04-08):
+# 1892-05-01 was the date when the Dutch railways were by law required to
+# observe GMT while the remainder of the Netherlands adhered to the common
+# practice of following Amsterdam mean time.
+#
+# (2001-04-09):
+# In 1835 the authorities of the province of North Holland requested the
+# municipal authorities of the towns and cities in the province to observe
+# Amsterdam mean time but I do not know in how many cases this request was
+# actually followed.
+#
+# From 1852 onwards the Dutch telegraph offices were by law required to
+# observe Amsterdam mean time. As the time signals from the observatory of
+# Leiden were also distributed by the telegraph system, I assume that most
+# places linked up with the telegraph (and railway) system automatically
+# adopted Amsterdam mean time.
+#
+# Although the early Dutch railway companies initially observed a variety
+# of times, most of them had adopted Amsterdam mean time by 1858 but it
+# was not until 1866 when they were all required by law to observe
+# Amsterdam mean time.
+
+# The data before 1945 are taken from
+# <http://www.phys.uu.nl/~vgent/wettijd/wettijd.htm>.
+
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Neth    1916    only    -       May      1      0:00    1:00    NST     # Netherlands Summer Time
+Rule   Neth    1916    only    -       Oct      1      0:00    0       AMT     # Amsterdam Mean Time
+Rule   Neth    1917    only    -       Apr     16      2:00s   1:00    NST
+Rule   Neth    1917    only    -       Sep     17      2:00s   0       AMT
+Rule   Neth    1918    1921    -       Apr     Mon>=1  2:00s   1:00    NST
+Rule   Neth    1918    1921    -       Sep     lastMon 2:00s   0       AMT
+Rule   Neth    1922    only    -       Mar     lastSun 2:00s   1:00    NST
+Rule   Neth    1922    1936    -       Oct     Sun>=2  2:00s   0       AMT
+Rule   Neth    1923    only    -       Jun     Fri>=1  2:00s   1:00    NST
+Rule   Neth    1924    only    -       Mar     lastSun 2:00s   1:00    NST
+Rule   Neth    1925    only    -       Jun     Fri>=1  2:00s   1:00    NST
+# From 1926 through 1939 DST began 05-15, except that it was delayed by a week
+# in years when 05-15 fell in the Pentecost weekend.
+Rule   Neth    1926    1931    -       May     15      2:00s   1:00    NST
+Rule   Neth    1932    only    -       May     22      2:00s   1:00    NST
+Rule   Neth    1933    1936    -       May     15      2:00s   1:00    NST
+Rule   Neth    1937    only    -       May     22      2:00s   1:00    NST
+Rule   Neth    1937    only    -       Jul      1      0:00    1:00    S
+Rule   Neth    1937    1939    -       Oct     Sun>=2  2:00s   0       -
+Rule   Neth    1938    1939    -       May     15      2:00s   1:00    S
+Rule   Neth    1945    only    -       Apr      2      2:00s   1:00    S
+Rule   Neth    1945    only    -       Sep     16      2:00s   0       -
+#
+# Amsterdam Mean Time was +00:19:32.13 exactly, but the .13 is omitted
+# below because the current format requires GMTOFF to be an integer.
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone Europe/Amsterdam  0:19:32 -       LMT     1835
+                       0:19:32 Neth    %s      1937 Jul  1
+                       0:20    Neth    NE%sT   1940 May 16 0:00 # Dutch Time
+                       1:00    C-Eur   CE%sT   1945 Apr  2 2:00
+                       1:00    Neth    CE%sT   1977
+                       1:00    EU      CE%sT
+
+# Norway
+# http://met.no/met/met_lex/q_u/sommertid.html (2004-01) agrees with Shanks &
+# Pottenger.
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Norway  1916    only    -       May     22      1:00    1:00    S
+Rule   Norway  1916    only    -       Sep     30      0:00    0       -
+Rule   Norway  1945    only    -       Apr      2      2:00s   1:00    S
+Rule   Norway  1945    only    -       Oct      1      2:00s   0       -
+Rule   Norway  1959    1964    -       Mar     Sun>=15 2:00s   1:00    S
+Rule   Norway  1959    1965    -       Sep     Sun>=15 2:00s   0       -
+Rule   Norway  1965    only    -       Apr     25      2:00s   1:00    S
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Europe/Oslo     0:43:00 -       LMT     1895 Jan  1
+                       1:00    Norway  CE%sT   1940 Aug 10 23:00
+                       1:00    C-Eur   CE%sT   1945 Apr  2  2:00
+                       1:00    Norway  CE%sT   1980
+                       1:00    EU      CE%sT
+
+# Svalbard & Jan Mayen
+
+# From Steffen Thorsen (2001-05-01):
+# Although I could not find it explicitly, it seems that Jan Mayen and
+# Svalbard have been using the same time as Norway at least since the
+# time they were declared as parts of Norway.  Svalbard was declared
+# as a part of Norway by law of 1925-07-17 no 11, section 4 and Jan
+# Mayen by law of 1930-02-27 no 2, section 2. (From
+# http://www.lovdata.no/all/nl-19250717-011.html and
+# http://www.lovdata.no/all/nl-19300227-002.html).  The law/regulation
+# for normal/standard time in Norway is from 1894-06-29 no 1 (came
+# into operation on 1895-01-01) and Svalbard/Jan Mayen seem to be a
+# part of this law since 1925/1930. (From
+# http://www.lovdata.no/all/nl-18940629-001.html ) I have not been
+# able to find if Jan Mayen used a different time zone (e.g. -0100)
+# before 1930. Jan Mayen has only been "inhabitated" since 1921 by
+# Norwegian meteorologists and maybe used the same time as Norway ever
+# since 1921.  Svalbard (Arctic/Longyearbyen) has been inhabited since
+# before 1895, and therefore probably changed the local time somewhere
+# between 1895 and 1925 (inclusive).
+
+# From Paul Eggert (2001-05-01):
+#
+# Actually, Jan Mayen was never occupied by Germany during World War II,
+# so it must have diverged from Oslo time during the war, as Oslo was
+# keeping Berlin time.
+#
+# <http://home.no.net/janmayen/history.htm> says that the meteorologists
+# burned down their station in 1940 and left the island, but returned in
+# 1941 with a small Norwegian garrison and continued operations despite
+# frequent air ttacks from Germans.  In 1943 the Americans established a
+# radiolocating station on the island, called "Atlantic City".  Possibly
+# the UTC offset changed during the war, but I think it unlikely that
+# Jan Mayen used German daylight-saving rules.
+#
+# Svalbard is more complicated, as it was raided in August 1941 by an
+# Allied party that evacuated the civilian population to England (says
+# <http://www.bartleby.com/65/sv/Svalbard.html>).  The Svalbard FAQ
+# <http://www.svalbard.com/SvalbardFAQ.html> says that the Germans were
+# expelled on 1942-05-14.  However, small parties of Germans did return,
+# and according to Wilhelm Dege's book "War North of 80" (1954)
+# <http://www.ucalgary.ca/UofC/departments/UP/1-55238/1-55238-110-2.html>
+# the German armed forces at the Svalbard weather station code-named
+# Haudegen did not surrender to the Allies until September 1945.
+#
+# All these events predate our cutoff date of 1970.  Unless we can
+# come up with more definitive info about the timekeeping during the
+# war years it's probably best just do do the following for now:
+Link   Europe/Oslo     Arctic/Longyearbyen
+
+# Poland
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Poland  1918    1919    -       Sep     16      2:00s   0       -
+Rule   Poland  1919    only    -       Apr     15      2:00s   1:00    S
+Rule   Poland  1944    only    -       Apr      3      2:00s   1:00    S
+# Whitman gives 1944 Nov 30; go with Shanks & Pottenger.
+Rule   Poland  1944    only    -       Oct      4      2:00    0       -
+# For 1944-1948 Whitman gives the previous day; go with Shanks & Pottenger.
+Rule   Poland  1945    only    -       Apr     29      0:00    1:00    S
+Rule   Poland  1945    only    -       Nov      1      0:00    0       -
+# For 1946 on the source is Kazimierz Borkowski,
+# Torun Center for Astronomy, Dept. of Radio Astronomy, Nicolaus Copernicus U.,
+# <http://www.astro.uni.torun.pl/~kb/Artykuly/U-PA/Czas2.htm#tth_tAb1>
+# Thanks to Przemyslaw Augustyniak (2005-05-28) for this reference.
+# He also gives these further references:
+# Mon Pol nr 13, poz 162 (1995) <http://www.abc.com.pl/serwis/mp/1995/0162.htm>
+# Druk nr 2180 (2003) <http://www.senat.gov.pl/k5/dok/sejm/053/2180.pdf>
+Rule   Poland  1946    only    -       Apr     14      0:00s   1:00    S
+Rule   Poland  1946    only    -       Oct      7      2:00s   0       -
+Rule   Poland  1947    only    -       May      4      2:00s   1:00    S
+Rule   Poland  1947    1949    -       Oct     Sun>=1  2:00s   0       -
+Rule   Poland  1948    only    -       Apr     18      2:00s   1:00    S
+Rule   Poland  1949    only    -       Apr     10      2:00s   1:00    S
+Rule   Poland  1957    only    -       Jun      2      1:00s   1:00    S
+Rule   Poland  1957    1958    -       Sep     lastSun 1:00s   0       -
+Rule   Poland  1958    only    -       Mar     30      1:00s   1:00    S
+Rule   Poland  1959    only    -       May     31      1:00s   1:00    S
+Rule   Poland  1959    1961    -       Oct     Sun>=1  1:00s   0       -
+Rule   Poland  1960    only    -       Apr      3      1:00s   1:00    S
+Rule   Poland  1961    1964    -       May     lastSun 1:00s   1:00    S
+Rule   Poland  1962    1964    -       Sep     lastSun 1:00s   0       -
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Europe/Warsaw   1:24:00 -       LMT     1880
+                       1:24:00 -       WMT     1915 Aug  5   # Warsaw Mean Time
+                       1:00    C-Eur   CE%sT   1918 Sep 16 3:00
+                       2:00    Poland  EE%sT   1922 Jun
+                       1:00    Poland  CE%sT   1940 Jun 23 2:00
+                       1:00    C-Eur   CE%sT   1944 Oct
+                       1:00    Poland  CE%sT   1977
+                       1:00    W-Eur   CE%sT   1988
+                       1:00    EU      CE%sT
+
+# Portugal
+#
+# From Rui Pedro Salgueiro (1992-11-12):
+# Portugal has recently (September, 27) changed timezone
+# (from WET to MET or CET) to harmonize with EEC.
+#
+# Martin Bruckmann (1996-02-29) reports via Peter Ilieve
+# that Portugal is reverting to 0:00 by not moving its clocks this spring.
+# The new Prime Minister was fed up with getting up in the dark in the winter.
+#
+# From Paul Eggert (1996-11-12):
+# IATA SSIM (1991-09) reports several 1991-09 and 1992-09 transitions
+# at 02:00u, not 01:00u.  Assume that these are typos.
+# IATA SSIM (1991/1992) reports that the Azores were at -1:00.
+# IATA SSIM (1993-02) says +0:00; later issues (through 1996-09) say -1:00.
+# Guess that the Azores changed to EU rules in 1992 (since that's when Portugal
+# harmonized with the EU), and that they stayed +0:00 that winter.
+#
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+# DSH writes that despite Decree 1,469 (1915), the change to the clocks was not
+# done every year, depending on what Spain did, because of railroad schedules.
+# Go with Shanks & Pottenger.
+Rule   Port    1916    only    -       Jun     17      23:00   1:00    S
+# Whitman gives 1916 Oct 31; go with Shanks & Pottenger.
+Rule   Port    1916    only    -       Nov      1       1:00   0       -
+Rule   Port    1917    only    -       Feb     28      23:00s  1:00    S
+Rule   Port    1917    1921    -       Oct     14      23:00s  0       -
+Rule   Port    1918    only    -       Mar      1      23:00s  1:00    S
+Rule   Port    1919    only    -       Feb     28      23:00s  1:00    S
+Rule   Port    1920    only    -       Feb     29      23:00s  1:00    S
+Rule   Port    1921    only    -       Feb     28      23:00s  1:00    S
+Rule   Port    1924    only    -       Apr     16      23:00s  1:00    S
+Rule   Port    1924    only    -       Oct     14      23:00s  0       -
+Rule   Port    1926    only    -       Apr     17      23:00s  1:00    S
+Rule   Port    1926    1929    -       Oct     Sat>=1  23:00s  0       -
+Rule   Port    1927    only    -       Apr      9      23:00s  1:00    S
+Rule   Port    1928    only    -       Apr     14      23:00s  1:00    S
+Rule   Port    1929    only    -       Apr     20      23:00s  1:00    S
+Rule   Port    1931    only    -       Apr     18      23:00s  1:00    S
+# Whitman gives 1931 Oct 8; go with Shanks & Pottenger.
+Rule   Port    1931    1932    -       Oct     Sat>=1  23:00s  0       -
+Rule   Port    1932    only    -       Apr      2      23:00s  1:00    S
+Rule   Port    1934    only    -       Apr      7      23:00s  1:00    S
+# Whitman gives 1934 Oct 5; go with Shanks & Pottenger.
+Rule   Port    1934    1938    -       Oct     Sat>=1  23:00s  0       -
+# Shanks & Pottenger give 1935 Apr 30; go with Whitman.
+Rule   Port    1935    only    -       Mar     30      23:00s  1:00    S
+Rule   Port    1936    only    -       Apr     18      23:00s  1:00    S
+# Whitman gives 1937 Apr 2; go with Shanks & Pottenger.
+Rule   Port    1937    only    -       Apr      3      23:00s  1:00    S
+Rule   Port    1938    only    -       Mar     26      23:00s  1:00    S
+Rule   Port    1939    only    -       Apr     15      23:00s  1:00    S
+# Whitman gives 1939 Oct 7; go with Shanks & Pottenger.
+Rule   Port    1939    only    -       Nov     18      23:00s  0       -
+Rule   Port    1940    only    -       Feb     24      23:00s  1:00    S
+# Shanks & Pottenger give 1940 Oct 7; go with Whitman.
+Rule   Port    1940    1941    -       Oct      5      23:00s  0       -
+Rule   Port    1941    only    -       Apr      5      23:00s  1:00    S
+Rule   Port    1942    1945    -       Mar     Sat>=8  23:00s  1:00    S
+Rule   Port    1942    only    -       Apr     25      22:00s  2:00    M # Midsummer
+Rule   Port    1942    only    -       Aug     15      22:00s  1:00    S
+Rule   Port    1942    1945    -       Oct     Sat>=24 23:00s  0       -
+Rule   Port    1943    only    -       Apr     17      22:00s  2:00    M
+Rule   Port    1943    1945    -       Aug     Sat>=25 22:00s  1:00    S
+Rule   Port    1944    1945    -       Apr     Sat>=21 22:00s  2:00    M
+Rule   Port    1946    only    -       Apr     Sat>=1  23:00s  1:00    S
+Rule   Port    1946    only    -       Oct     Sat>=1  23:00s  0       -
+Rule   Port    1947    1949    -       Apr     Sun>=1   2:00s  1:00    S
+Rule   Port    1947    1949    -       Oct     Sun>=1   2:00s  0       -
+# Shanks & Pottenger say DST was observed in 1950; go with Whitman.
+# Whitman gives Oct lastSun for 1952 on; go with Shanks & Pottenger.
+Rule   Port    1951    1965    -       Apr     Sun>=1   2:00s  1:00    S
+Rule   Port    1951    1965    -       Oct     Sun>=1   2:00s  0       -
+Rule   Port    1977    only    -       Mar     27       0:00s  1:00    S
+Rule   Port    1977    only    -       Sep     25       0:00s  0       -
+Rule   Port    1978    1979    -       Apr     Sun>=1   0:00s  1:00    S
+Rule   Port    1978    only    -       Oct      1       0:00s  0       -
+Rule   Port    1979    1982    -       Sep     lastSun  1:00s  0       -
+Rule   Port    1980    only    -       Mar     lastSun  0:00s  1:00    S
+Rule   Port    1981    1982    -       Mar     lastSun  1:00s  1:00    S
+Rule   Port    1983    only    -       Mar     lastSun  2:00s  1:00    S
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+# Shanks & Pottenger say the transition from LMT to WET occurred 1911-05-24;
+# Willett says 1912-01-01.  Go with Willett.
+Zone   Europe/Lisbon   -0:36:32 -      LMT     1884
+                       -0:36:32 -      LMT     1912 Jan  1  # Lisbon Mean Time
+                        0:00   Port    WE%sT   1966 Apr  3 2:00
+                        1:00   -       CET     1976 Sep 26 1:00
+                        0:00   Port    WE%sT   1983 Sep 25 1:00s
+                        0:00   W-Eur   WE%sT   1992 Sep 27 1:00s
+                        1:00   EU      CE%sT   1996 Mar 31 1:00u
+                        0:00   EU      WE%sT
+Zone Atlantic/Azores   -1:42:40 -      LMT     1884            # Ponta Delgada
+                       -1:54:32 -      HMT     1911 May 24  # Horta Mean Time
+                       -2:00   Port    AZO%sT  1966 Apr  3 2:00 # Azores Time
+                       -1:00   Port    AZO%sT  1983 Sep 25 1:00s
+                       -1:00   W-Eur   AZO%sT  1992 Sep 27 1:00s
+                        0:00   EU      WE%sT   1993 Mar 28 1:00u
+                       -1:00   EU      AZO%sT
+Zone Atlantic/Madeira  -1:07:36 -      LMT     1884            # Funchal
+                       -1:07:36 -      FMT     1911 May 24  # Funchal Mean Time
+                       -1:00   Port    MAD%sT  1966 Apr  3 2:00 # Madeira Time
+                        0:00   Port    WE%sT   1983 Sep 25 1:00s
+                        0:00   EU      WE%sT
+
+# Romania
+#
+# From Paul Eggert (1999-10-07):
+# <a href="http://www.nineoclock.ro/POL/1778pol.html">
+# Nine O'clock</a> (1998-10-23) reports that the switch occurred at
+# 04:00 local time in fall 1998.  For lack of better info,
+# assume that Romania and Moldova switched to EU rules in 1997,
+# the same year as Bulgaria.
+#
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Romania 1932    only    -       May     21       0:00s  1:00    S
+Rule   Romania 1932    1939    -       Oct     Sun>=1   0:00s  0       -
+Rule   Romania 1933    1939    -       Apr     Sun>=2   0:00s  1:00    S
+Rule   Romania 1979    only    -       May     27       0:00   1:00    S
+Rule   Romania 1979    only    -       Sep     lastSun  0:00   0       -
+Rule   Romania 1980    only    -       Apr      5      23:00   1:00    S
+Rule   Romania 1980    only    -       Sep     lastSun  1:00   0       -
+Rule   Romania 1991    1993    -       Mar     lastSun  0:00s  1:00    S
+Rule   Romania 1991    1993    -       Sep     lastSun  0:00s  0       -
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone Europe/Bucharest  1:44:24 -       LMT     1891 Oct
+                       1:44:24 -       BMT     1931 Jul 24     # Bucharest MT
+                       2:00    Romania EE%sT   1981 Mar 29 2:00s
+                       2:00    C-Eur   EE%sT   1991
+                       2:00    Romania EE%sT   1994
+                       2:00    E-Eur   EE%sT   1997
+                       2:00    EU      EE%sT
+
+# Russia
+
+# From Paul Eggert (2006-03-22):
+# Except for Moscow after 1919-07-01, I invented the time zone abbreviations.
+# Moscow time zone abbreviations after 1919-07-01, and Moscow rules after 1991,
+# are from Andrey A. Chernov.  The rest is from Shanks & Pottenger,
+# except we follow Chernov's report that 1992 DST transitions were Sat
+# 23:00, not Sun 02:00s.
+#
+# From Stanislaw A. Kuzikowski (1994-06-29):
+# But now it is some months since Novosibirsk is 3 hours ahead of Moscow!
+# I do not know why they have decided to make this change;
+# as far as I remember it was done exactly during winter->summer switching
+# so we (Novosibirsk) simply did not switch.
+#
+# From Andrey A. Chernov (1996-10-04):
+# `MSK' and `MSD' were born and used initially on Moscow computers with
+# UNIX-like OSes by several developer groups (e.g. Demos group, Kiae group)....
+# The next step was the UUCP network, the Relcom predecessor
+# (used mainly for mail), and MSK/MSD was actively used there.
+#
+# From Chris Carrier (1996-10-30):
+# According to a friend of mine who rode the Trans-Siberian Railroad from
+# Moscow to Irkutsk in 1995, public air and rail transport in Russia ...
+# still follows Moscow time, no matter where in Russia it is located.
+#
+# For Grozny, Chechnya, we have the following story from
+# John Daniszewski, "Scavengers in the Rubble", Los Angeles Times (2001-02-07):
+# News--often false--is spread by word of mouth.  A rumor that it was
+# time to move the clocks back put this whole city out of sync with
+# the rest of Russia for two weeks--even soldiers stationed here began
+# enforcing curfew at the wrong time.
+#
+# From Gwillim Law (2001-06-05):
+# There's considerable evidence that Sakhalin Island used to be in
+# UTC+11, and has changed to UTC+10, in this decade.  I start with the
+# SSIM, which listed Yuzhno-Sakhalinsk in zone RU10 along with Magadan
+# until February 1997, and then in RU9 with Khabarovsk and Vladivostok
+# since September 1997....  Although the Kuril Islands are
+# administratively part of Sakhalin oblast', they appear to have
+# remained on UTC+11 along with Magadan.
+#
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+#
+# Kaliningradskaya oblast'.
+Zone Europe/Kaliningrad         1:22:00 -      LMT     1893 Apr
+                        1:00   C-Eur   CE%sT   1945
+                        2:00   Poland  CE%sT   1946
+                        3:00   Russia  MSK/MSD 1991 Mar 31 2:00s
+                        2:00   Russia  EE%sT
+#
+# From Oscar van Vlijmen (2001-08-25): [This region consists of]
+# Respublika Adygeya, Arkhangel'skaya oblast',
+# Belgorodskaya oblast', Bryanskaya oblast', Vladimirskaya oblast',
+# Vologodskaya oblast', Voronezhskaya oblast',
+# Respublika Dagestan, Ivanovskaya oblast', Respublika Ingushetiya,
+# Kabarbino-Balkarskaya Respublika, Respublika Kalmykiya,
+# Kalyzhskaya oblast', Respublika Karachaevo-Cherkessiya,
+# Respublika Kareliya, Respublika Komi,
+# Kostromskaya oblast', Krasnodarskij kraj, Kurskaya oblast',
+# Leningradskaya oblast', Lipetskaya oblast', Respublika Marij El,
+# Respublika Mordoviya, Moskva, Moskovskaya oblast',
+# Murmanskaya oblast', Nenetskij avtonomnyj okrug,
+# Nizhegorodskaya oblast', Novgorodskaya oblast', Orlovskaya oblast',
+# Penzenskaya oblast', Pskovskaya oblast', Rostovskaya oblast',
+# Ryazanskaya oblast', Sankt-Peterburg,
+# Respublika Severnaya Osetiya, Smolenskaya oblast',
+# Stavropol'skij kraj, Tambovskaya oblast', Respublika Tatarstan,
+# Tverskaya oblast', Tyl'skaya oblast', Ul'yanovskaya oblast',
+# Chechenskaya Respublika, Chuvashskaya oblast',
+# Yaroslavskaya oblast'
+Zone Europe/Moscow      2:30:20 -      LMT     1880
+                        2:30   -       MMT     1916 Jul  3 # Moscow Mean Time
+                        2:30:48 Russia %s      1919 Jul  1 2:00
+                        3:00   Russia  MSK/MSD 1922 Oct
+                        2:00   -       EET     1930 Jun 21
+                        3:00   Russia  MSK/MSD 1991 Mar 31 2:00s
+                        2:00   Russia  EE%sT   1992 Jan 19 2:00s
+                        3:00   Russia  MSK/MSD
+#
+# Astrakhanskaya oblast', Kirovskaya oblast', Saratovskaya oblast',
+# Volgogradskaya oblast'.  Shanks & Pottenger say Kirov is still at +0400
+# but Wikipedia (2006-05-09) says +0300.  Perhaps it switched after the
+# others?  But we have no data.
+Zone Europe/Volgograd   2:57:40 -      LMT     1920 Jan  3
+                        3:00   -       TSAT    1925 Apr  6 # Tsaritsyn Time
+                        3:00   -       STAT    1930 Jun 21 # Stalingrad Time
+                        4:00   -       STAT    1961 Nov 11
+                        4:00   Russia  VOL%sT  1989 Mar 26 2:00s # Volgograd T
+                        3:00   Russia  VOL%sT  1991 Mar 31 2:00s
+                        4:00   -       VOLT    1992 Mar 29 2:00s
+                        3:00   Russia  VOL%sT
+#
+# From Oscar van Vlijmen (2001-08-25): [This region consists of]
+# Samarskaya oblast', Udmyrtskaya respublika
+Zone Europe/Samara      3:20:36 -      LMT     1919 Jul  1 2:00
+                        3:00   -       SAMT    1930 Jun 21
+                        4:00   -       SAMT    1935 Jan 27
+                        4:00   Russia  KUY%sT  1989 Mar 26 2:00s # Kuybyshev
+                        3:00   Russia  KUY%sT  1991 Mar 31 2:00s
+                        2:00   Russia  KUY%sT  1991 Sep 29 2:00s
+                        3:00   -       KUYT    1991 Oct 20 3:00
+                        4:00   Russia  SAM%sT  # Samara Time
+#
+# From Oscar van Vlijmen (2001-08-25): [This region consists of]
+# Respublika Bashkortostan, Komi-Permyatskij avtonomnyj okrug,
+# Kurganskaya oblast', Orenburgskaya oblast', Permskaya oblast',
+# Sverdlovskaya oblast', Tyumenskaya oblast',
+# Khanty-Manskijskij avtonomnyj okrug, Chelyabinskaya oblast',
+# Yamalo-Nenetskij avtonomnyj okrug.
+Zone Asia/Yekaterinburg         4:02:24 -      LMT     1919 Jul 15 4:00
+                        4:00   -       SVET    1930 Jun 21 # Sverdlovsk Time
+                        5:00   Russia  SVE%sT  1991 Mar 31 2:00s
+                        4:00   Russia  SVE%sT  1992 Jan 19 2:00s
+                        5:00   Russia  YEK%sT  # Yekaterinburg Time
+#
+# From Oscar van Vlijmen (2001-08-25): [This region consists of]
+# Respublika Altaj, Altajskij kraj, Omskaya oblast'.
+Zone Asia/Omsk          4:53:36 -      LMT     1919 Nov 14
+                        5:00   -       OMST    1930 Jun 21 # Omsk TIme
+                        6:00   Russia  OMS%sT  1991 Mar 31 2:00s
+                        5:00   Russia  OMS%sT  1992 Jan 19 2:00s
+                        6:00   Russia  OMS%sT
+#
+# From Paul Eggert (2006-08-19): I'm guessing about Tomsk here; it's
+# not clear when it switched from +7 to +6.
+# Novosibirskaya oblast', Tomskaya oblast'.
+Zone Asia/Novosibirsk   5:31:40 -      LMT     1919 Dec 14 6:00
+                        6:00   -       NOVT    1930 Jun 21 # Novosibirsk Time
+                        7:00   Russia  NOV%sT  1991 Mar 31 2:00s
+                        6:00   Russia  NOV%sT  1992 Jan 19 2:00s
+                        7:00   Russia  NOV%sT  1993 May 23 # say Shanks & P.
+                        6:00   Russia  NOV%sT
+#
+# From Oscar van Vlijmen (2001-08-25): [This region consists of]
+# Kemerovskaya oblast', Krasnoyarskij kraj,
+# Tajmyrskij (Dolgano-Nenetskij) avtonomnyj okrug,
+# Respublika Tuva, Respublika Khakasiya, Evenkijskij avtonomnyj okrug.
+Zone Asia/Krasnoyarsk   6:11:20 -      LMT     1920 Jan  6
+                        6:00   -       KRAT    1930 Jun 21 # Krasnoyarsk Time
+                        7:00   Russia  KRA%sT  1991 Mar 31 2:00s
+                        6:00   Russia  KRA%sT  1992 Jan 19 2:00s
+                        7:00   Russia  KRA%sT
+#
+# From Oscar van Vlijmen (2001-08-25): [This region consists of]
+# Respublika Buryatiya, Irkutskaya oblast',
+# Ust'-Ordynskij Buryatskij avtonomnyj okrug.
+Zone Asia/Irkutsk       6:57:20 -      LMT     1880
+                        6:57:20 -      IMT     1920 Jan 25 # Irkutsk Mean Time
+                        7:00   -       IRKT    1930 Jun 21 # Irkutsk Time
+                        8:00   Russia  IRK%sT  1991 Mar 31 2:00s
+                        7:00   Russia  IRK%sT  1992 Jan 19 2:00s
+                        8:00   Russia  IRK%sT
+#
+# From Oscar van Vlijmen (2003-10-18): [This region consists of]
+# Aginskij Buryatskij avtonomnyj okrug, Amurskaya oblast',
+# [parts of] Respublika Sakha (Yakutiya), Chitinskaya oblast'.
+# The Sakha districts are: Aldanskij, Amginskij, Anabarskij,
+# Bulunskij, Verkhnekolymskij, Verkhnevilyujskij, Vilyujskij, Gornyj,
+# Zhiganskij, Kobyajskij, Lenskij, Megino-Kangalasskij, Mirninskij,
+# Namskij, Nyurbinskij, Olenekskij, Olekminskij, Srednekolymskij,
+# Suntarskij, Tattinskij, Ust'-Aldanskij, Khangalasskij,
+# Churapchinskij, Eveno-Bytantajskij.
+Zone Asia/Yakutsk       8:38:40 -      LMT     1919 Dec 15
+                        8:00   -       YAKT    1930 Jun 21 # Yakutsk Time
+                        9:00   Russia  YAK%sT  1991 Mar 31 2:00s
+                        8:00   Russia  YAK%sT  1992 Jan 19 2:00s
+                        9:00   Russia  YAK%sT
+#
+# From Oscar van Vlijmen (2003-10-18): [This region consists of]
+# Evrejskaya avtonomnaya oblast', Khabarovskij kraj, Primorskij kraj,
+# [parts of] Respublika Sakha (Yakutiya).
+# The Sakha districts are: Verkhoyanskij, Tomponskij, Ust'-Majskij,
+# Ust'-Yanskij.
+Zone Asia/Vladivostok   8:47:44 -      LMT     1922 Nov 15
+                        9:00   -       VLAT    1930 Jun 21 # Vladivostok Time
+                       10:00   Russia  VLA%sT  1991 Mar 31 2:00s
+                        9:00   Russia  VLA%sST 1992 Jan 19 2:00s
+                       10:00   Russia  VLA%sT
+#
+# Sakhalinskaya oblast'.
+# The Zone name should be Yuzhno-Sakhalinsk, but that's too long.
+Zone Asia/Sakhalin      9:30:48 -      LMT     1905 Aug 23
+                        9:00   -       CJT     1938
+                        9:00   -       JST     1945 Aug 25
+                       11:00   Russia  SAK%sT  1991 Mar 31 2:00s # Sakhalin T.
+                       10:00   Russia  SAK%sT  1992 Jan 19 2:00s
+                       11:00   Russia  SAK%sT  1997 Mar lastSun 2:00s
+                       10:00   Russia  SAK%sT
+#
+# From Oscar van Vlijmen (2003-10-18): [This region consists of]
+# Magadanskaya oblast', Respublika Sakha (Yakutiya).
+# Probably also: Kuril Islands.
+# The Sakha districts are: Abyjskij, Allaikhovskij, Momskij,
+# Nizhnekolymskij, Ojmyakonskij.
+Zone Asia/Magadan      10:03:12 -      LMT     1924 May  2
+                       10:00   -       MAGT    1930 Jun 21 # Magadan Time
+                       11:00   Russia  MAG%sT  1991 Mar 31 2:00s
+                       10:00   Russia  MAG%sT  1992 Jan 19 2:00s
+                       11:00   Russia  MAG%sT
+#
+# From Oscar van Vlijmen (2001-08-25): [This region consists of]
+# Kamchatskaya oblast', Koryakskij avtonomnyj okrug.
+#
+# The Zone name should be Asia/Petropavlovsk-Kamchatski, but that's too long.
+Zone Asia/Kamchatka    10:34:36 -      LMT     1922 Nov 10
+                       11:00   -       PETT    1930 Jun 21 # P-K Time
+                       12:00   Russia  PET%sT  1991 Mar 31 2:00s
+                       11:00   Russia  PET%sT  1992 Jan 19 2:00s
+                       12:00   Russia  PET%sT
+#
+# Chukotskij avtonomnyj okrug
+Zone Asia/Anadyr       11:49:56 -      LMT     1924 May  2
+                       12:00   -       ANAT    1930 Jun 21 # Anadyr Time
+                       13:00   Russia  ANA%sT  1982 Apr  1 0:00s
+                       12:00   Russia  ANA%sT  1991 Mar 31 2:00s
+                       11:00   Russia  ANA%sT  1992 Jan 19 2:00s
+                       12:00   Russia  ANA%sT
+
+# Serbia
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Europe/Belgrade 1:22:00 -       LMT     1884
+                       1:00    -       CET     1941 Apr 18 23:00
+                       1:00    C-Eur   CE%sT   1945
+                       1:00    -       CET     1945 May 8 2:00s
+                       1:00    1:00    CEST    1945 Sep 16  2:00s
+# Metod Kozelj reports that the legal date of
+# transition to EU rules was 1982-11-27, for all of Yugoslavia at the time.
+# Shanks & Pottenger don't give as much detail, so go with Kozelj.
+                       1:00    -       CET     1982 Nov 27
+                       1:00    EU      CE%sT
+Link Europe/Belgrade Europe/Ljubljana  # Slovenia
+Link Europe/Belgrade Europe/Podgorica  # Montenegro
+Link Europe/Belgrade Europe/Sarajevo   # Bosnia and Herzegovina
+Link Europe/Belgrade Europe/Skopje     # Macedonia
+Link Europe/Belgrade Europe/Zagreb     # Croatia
+
+# Slovakia
+Link Europe/Prague Europe/Bratislava
+
+# Slovenia
+# see Serbia
+
+# Spain
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+# For 1917-1919 Whitman gives Apr Sat>=1 - Oct Sat>=1;
+# go with Shanks & Pottenger.
+Rule   Spain   1917    only    -       May      5      23:00s  1:00    S
+Rule   Spain   1917    1919    -       Oct      6      23:00s  0       -
+Rule   Spain   1918    only    -       Apr     15      23:00s  1:00    S
+Rule   Spain   1919    only    -       Apr      5      23:00s  1:00    S
+# Whitman gives 1921 Feb 28 - Oct 14; go with Shanks & Pottenger.
+Rule   Spain   1924    only    -       Apr     16      23:00s  1:00    S
+# Whitman gives 1924 Oct 14; go with Shanks & Pottenger.
+Rule   Spain   1924    only    -       Oct      4      23:00s  0       -
+Rule   Spain   1926    only    -       Apr     17      23:00s  1:00    S
+# Whitman says no DST in 1929; go with Shanks & Pottenger.
+Rule   Spain   1926    1929    -       Oct     Sat>=1  23:00s  0       -
+Rule   Spain   1927    only    -       Apr      9      23:00s  1:00    S
+Rule   Spain   1928    only    -       Apr     14      23:00s  1:00    S
+Rule   Spain   1929    only    -       Apr     20      23:00s  1:00    S
+# Whitman gives 1937 Jun 16, 1938 Apr 16, 1940 Apr 13;
+# go with Shanks & Pottenger.
+Rule   Spain   1937    only    -       May     22      23:00s  1:00    S
+Rule   Spain   1937    1939    -       Oct     Sat>=1  23:00s  0       -
+Rule   Spain   1938    only    -       Mar     22      23:00s  1:00    S
+Rule   Spain   1939    only    -       Apr     15      23:00s  1:00    S
+Rule   Spain   1940    only    -       Mar     16      23:00s  1:00    S
+# Whitman says no DST 1942-1945; go with Shanks & Pottenger.
+Rule   Spain   1942    only    -       May      2      22:00s  2:00    M # Midsummer
+Rule   Spain   1942    only    -       Sep      1      22:00s  1:00    S
+Rule   Spain   1943    1946    -       Apr     Sat>=13 22:00s  2:00    M
+Rule   Spain   1943    only    -       Oct      3      22:00s  1:00    S
+Rule   Spain   1944    only    -       Oct     10      22:00s  1:00    S
+Rule   Spain   1945    only    -       Sep     30       1:00   1:00    S
+Rule   Spain   1946    only    -       Sep     30       0:00   0       -
+Rule   Spain   1949    only    -       Apr     30      23:00   1:00    S
+Rule   Spain   1949    only    -       Sep     30       1:00   0       -
+Rule   Spain   1974    1975    -       Apr     Sat>=13 23:00   1:00    S
+Rule   Spain   1974    1975    -       Oct     Sun>=1   1:00   0       -
+Rule   Spain   1976    only    -       Mar     27      23:00   1:00    S
+Rule   Spain   1976    1977    -       Sep     lastSun  1:00   0       -
+Rule   Spain   1977    1978    -       Apr      2      23:00   1:00    S
+Rule   Spain   1978    only    -       Oct      1       1:00   0       -
+# The following rules are copied from Morocco from 1967 through 1978.
+Rule SpainAfrica 1967  only    -       Jun      3      12:00   1:00    S
+Rule SpainAfrica 1967  only    -       Oct      1       0:00   0       -
+Rule SpainAfrica 1974  only    -       Jun     24       0:00   1:00    S
+Rule SpainAfrica 1974  only    -       Sep      1       0:00   0       -
+Rule SpainAfrica 1976  1977    -       May      1       0:00   1:00    S
+Rule SpainAfrica 1976  only    -       Aug      1       0:00   0       -
+Rule SpainAfrica 1977  only    -       Sep     28       0:00   0       -
+Rule SpainAfrica 1978  only    -       Jun      1       0:00   1:00    S
+Rule SpainAfrica 1978  only    -       Aug      4       0:00   0       -
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Europe/Madrid   -0:14:44 -      LMT     1901 Jan  1  0:00s
+                        0:00   Spain   WE%sT   1946 Sep 30
+                        1:00   Spain   CE%sT   1979
+                        1:00   EU      CE%sT
+Zone   Africa/Ceuta    -0:21:16 -      LMT     1901
+                        0:00   -       WET     1918 May  6 23:00
+                        0:00   1:00    WEST    1918 Oct  7 23:00
+                        0:00   -       WET     1924
+                        0:00   Spain   WE%sT   1929
+                        0:00 SpainAfrica WE%sT 1984 Mar 16
+                        1:00   -       CET     1986
+                        1:00   EU      CE%sT
+Zone   Atlantic/Canary -1:01:36 -      LMT     1922 Mar # Las Palmas de Gran C.
+                       -1:00   -       CANT    1946 Sep 30 1:00 # Canaries Time
+                        0:00   -       WET     1980 Apr  6 0:00s
+                        0:00   1:00    WEST    1980 Sep 28 0:00s
+                        0:00   EU      WE%sT
+# IATA SSIM (1996-09) says the Canaries switch at 2:00u, not 1:00u.
+# Ignore this for now, as the Canaries are part of the EU.
+
+# Sweden
+
+# From Ivan Nilsson (2001-04-13), superseding Shanks & Pottenger:
+#
+# The law "Svensk forfattningssamling 1878, no 14" about standard time in 1879:
+# From the beginning of 1879 (that is 01-01 00:00) the time for all
+# places in the country is "the mean solar time for the meridian at
+# three degrees, or twelve minutes of time, to the west of the
+# meridian of the Observatory of Stockholm".  The law is dated 1878-05-31.
+#
+# The observatory at that time had the meridian 18 degrees 03' 30"
+# eastern longitude = 01:12:14 in time.  Less 12 minutes gives the
+# national standard time as 01:00:14 ahead of GMT....
+#
+# About the beginning of CET in Sweden. The lawtext ("Svensk
+# forfattningssamling 1899, no 44") states, that "from the beginning
+# of 1900... ... the same as the mean solar time for the meridian at
+# the distance of one hour of time from the meridian of the English
+# observatory at Greenwich, or at 12 minutes 14 seconds to the west
+# from the meridian of the Observatory of Stockholm". The law is dated
+# 1899-06-16.  In short: At 1900-01-01 00:00:00 the new standard time
+# in Sweden is 01:00:00 ahead of GMT.
+#
+# 1916: The lawtext ("Svensk forfattningssamling 1916, no 124") states
+# that "1916-05-15 is considered to begin one hour earlier". It is
+# pretty obvious that at 05-14 23:00 the clocks are set to 05-15 00:00....
+# Further the law says, that "1916-09-30 is considered to end one hour later".
+#
+# The laws regulating [DST] are available on the site of the Swedish
+# Parliament beginning with 1985 - the laws regulating 1980/1984 are
+# not available on the site (to my knowledge they are only available
+# in Swedish): <http://www.riksdagen.se/english/work/sfst.asp> (type
+# "sommartid" without the quotes in the field "Fritext" and then click
+# the Sok-button).
+#
+# (2001-05-13):
+#
+# I have now found a newspaper stating that at 1916-10-01 01:00
+# summertime the church-clocks etc were set back one hour to show
+# 1916-10-01 00:00 standard time.  The article also reports that some
+# people thought the switch to standard time would take place already
+# at 1916-10-01 00:00 summer time, but they had to wait for another
+# hour before the event took place.
+#
+# Source: The newspaper "Dagens Nyheter", 1916-10-01, page 7 upper left.
+
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone Europe/Stockholm  1:12:12 -       LMT     1879 Jan  1
+                       1:00:14 -       SET     1900 Jan  1     # Swedish Time
+                       1:00    -       CET     1916 May 14 23:00
+                       1:00    1:00    CEST    1916 Oct  1 01:00
+                       1:00    -       CET     1980
+                       1:00    EU      CE%sT
+
+# Switzerland
+# From Howse:
+# By the end of the 18th century clocks and watches became commonplace
+# and their performance improved enormously.  Communities began to keep
+# mean time in preference to apparent time -- Geneva from 1780 ....
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+# From Whitman (who writes ``Midnight?''):
+# Rule Swiss   1940    only    -       Nov      2      0:00    1:00    S
+# Rule Swiss   1940    only    -       Dec     31      0:00    0       -
+# From Shanks & Pottenger:
+# Rule Swiss   1941    1942    -       May     Sun>=1  2:00    1:00    S
+# Rule Swiss   1941    1942    -       Oct     Sun>=1  0:00    0       -
+
+# From Alois Treindl (2008-12-17):
+# I have researched the DST usage in Switzerland during the 1940ies.
+#
+# As I wrote in an earlier message, I suspected the current tzdata values
+# to be wrong. This is now verified.
+#
+# I have found copies of the original ruling by the Swiss Federal
+# government, in 'Eidgen[o]ssische Gesetzessammlung 1941 and 1942' (Swiss
+# federal law collection)...
+#
+# DST began on Monday 5 May 1941, 1:00 am by shifting the clocks to 2:00 am
+# DST ended on Monday 6 Oct 1941, 2:00 am by shifting the clocks to 1:00 am.
+#
+# DST began on Monday, 4 May 1942 at 01:00 am
+# DST ended on Monday, 5 Oct 1942 at 02:00 am
+#
+# There was no DST in 1940, I have checked the law collection carefully.
+# It is also indicated by the fact that the 1942 entry in the law
+# collection points back to 1941 as a reference, but no reference to any
+# other years are made.
+#
+# Newspaper articles I have read in the archives on 6 May 1941 reported
+# about the introduction of DST (Sommerzeit in German) during the previous
+# night as an absolute novelty, because this was the first time that such
+# a thing had happened in Switzerland.
+#
+# I have also checked 1916, because one book source (Gabriel, Traite de
+# l'heure dans le monde) claims that Switzerland had DST in 1916. This is
+# false, no official document could be found. Probably Gabriel got misled
+# by references to Germany, which introduced DST in 1916 for the first time.
+#
+# The tzdata rules for Switzerland must be changed to:
+# Rule  Swiss   1941    1942    -       May     Mon>=1  1:00    1:00    S
+# Rule  Swiss   1941    1942    -       Oct     Mon>=1  2:00    0       -
+#
+# The 1940 rules must be deleted.
+#
+# One further detail for Switzerland, which is probably out of scope for
+# most users of tzdata:
+# The zone file
+# Zone    Europe/Zurich   0:34:08 -       LMT     1848 Sep 12
+#                          0:29:44 -       BMT     1894 Jun #Bern Mean Time
+#                          1:00    Swiss   CE%sT   1981
+#                          1:00    EU      CE%sT
+# describes all of Switzerland correctly, with the exception of
+# the Cantone Geneve (Geneva, Genf). Between 1848 and 1894 Geneve did not
+# follow Bern Mean Time but kept its own local mean time.
+# To represent this, an extra zone would be needed.
+
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Swiss   1941    1942    -       May     Mon>=1  1:00    1:00    S
+Rule   Swiss   1941    1942    -       Oct     Mon>=1  2:00    0       -
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Europe/Zurich   0:34:08 -       LMT     1848 Sep 12
+                       0:29:44 -       BMT     1894 Jun # Bern Mean Time
+                       1:00    Swiss   CE%sT   1981
+                       1:00    EU      CE%sT
+
+# Turkey
+
+# From Amar Devegowda (2007-01-03):
+# The time zone rules for Istanbul, Turkey have not been changed for years now.
+# ... The latest rules are available at -
+# http://www.timeanddate.com/worldclock/timezone.html?n=107
+# From Steffen Thorsen (2007-01-03):
+# I have been able to find press records back to 1996 which all say that
+# DST started 01:00 local time and end at 02:00 local time.  I am not sure
+# what happened before that.  One example for each year from 1996 to 2001:
+# http://newspot.byegm.gov.tr/arsiv/1996/21/N4.htm
+# http://www.byegm.gov.tr/YAYINLARIMIZ/CHR/ING97/03/97X03X25.TXT
+# http://www.byegm.gov.tr/YAYINLARIMIZ/CHR/ING98/03/98X03X02.HTM
+# http://www.byegm.gov.tr/YAYINLARIMIZ/CHR/ING99/10/99X10X26.HTM#%2016
+# http://www.byegm.gov.tr/YAYINLARIMIZ/CHR/ING2000/03/00X03X06.HTM#%2021
+# http://www.byegm.gov.tr/YAYINLARIMIZ/CHR/ING2001/03/23x03x01.HTM#%2027
+# From Paul Eggert (2007-01-03):
+# Prefer the above source to Shanks & Pottenger for time stamps after 1990.
+
+# From Steffen Thorsen (2007-03-09):
+# Starting 2007 though, it seems that they are adopting EU's 1:00 UTC
+# start/end time, according to the following page (2007-03-07):
+# http://www.ntvmsnbc.com/news/402029.asp
+# The official document is located here - it is in Turkish...:
+# http://rega.basbakanlik.gov.tr/eskiler/2007/03/20070307-7.htm
+# I was able to locate the following seemingly official document
+# (on a non-government server though) describing dates between 2002 and 2006:
+# http://www.alomaliye.com/bkk_2002_3769.htm
+
+# From Sue Williams (2008-08-11):
+# I spotted this news article about a potential change in Turkey.
+#
+# <a href="http://www.hurriyet.com.tr/english/domestic/9626174.asp?scr=1">
+# http://www.hurriyet.com.tr/english/domestic/9626174.asp?scr=1
+# </a>
+
+# From Sue Williams (2008-08-20):
+# This article says that around the end of March 2011, Turkey wants to
+# adjust the clocks forward by 1/2 hour and stay that way permanently.
+# The article indicates that this is a change in timezone offset in addition
+# to stopping observance of DST.
+# This proposal has not yet been approved.
+#
+# Read more here...
+#
+# Turkey to abandon daylight saving time in 2011
+# <a href="http://www.turkishdailynews.com.tr/article.php?enewsid=112989">
+# http://www.turkishdailynews.com.tr/article.php?enewsid=112989
+# </a>
+
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Turkey  1916    only    -       May      1      0:00    1:00    S
+Rule   Turkey  1916    only    -       Oct      1      0:00    0       -
+Rule   Turkey  1920    only    -       Mar     28      0:00    1:00    S
+Rule   Turkey  1920    only    -       Oct     25      0:00    0       -
+Rule   Turkey  1921    only    -       Apr      3      0:00    1:00    S
+Rule   Turkey  1921    only    -       Oct      3      0:00    0       -
+Rule   Turkey  1922    only    -       Mar     26      0:00    1:00    S
+Rule   Turkey  1922    only    -       Oct      8      0:00    0       -
+# Whitman gives 1923 Apr 28 - Sep 16 and no DST in 1924-1925;
+# go with Shanks & Pottenger.
+Rule   Turkey  1924    only    -       May     13      0:00    1:00    S
+Rule   Turkey  1924    1925    -       Oct      1      0:00    0       -
+Rule   Turkey  1925    only    -       May      1      0:00    1:00    S
+Rule   Turkey  1940    only    -       Jun     30      0:00    1:00    S
+Rule   Turkey  1940    only    -       Oct      5      0:00    0       -
+Rule   Turkey  1940    only    -       Dec      1      0:00    1:00    S
+Rule   Turkey  1941    only    -       Sep     21      0:00    0       -
+Rule   Turkey  1942    only    -       Apr      1      0:00    1:00    S
+# Whitman omits the next two transition and gives 1945 Oct 1;
+# go with Shanks & Pottenger.
+Rule   Turkey  1942    only    -       Nov      1      0:00    0       -
+Rule   Turkey  1945    only    -       Apr      2      0:00    1:00    S
+Rule   Turkey  1945    only    -       Oct      8      0:00    0       -
+Rule   Turkey  1946    only    -       Jun      1      0:00    1:00    S
+Rule   Turkey  1946    only    -       Oct      1      0:00    0       -
+Rule   Turkey  1947    1948    -       Apr     Sun>=16 0:00    1:00    S
+Rule   Turkey  1947    1950    -       Oct     Sun>=2  0:00    0       -
+Rule   Turkey  1949    only    -       Apr     10      0:00    1:00    S
+Rule   Turkey  1950    only    -       Apr     19      0:00    1:00    S
+Rule   Turkey  1951    only    -       Apr     22      0:00    1:00    S
+Rule   Turkey  1951    only    -       Oct      8      0:00    0       -
+Rule   Turkey  1962    only    -       Jul     15      0:00    1:00    S
+Rule   Turkey  1962    only    -       Oct      8      0:00    0       -
+Rule   Turkey  1964    only    -       May     15      0:00    1:00    S
+Rule   Turkey  1964    only    -       Oct      1      0:00    0       -
+Rule   Turkey  1970    1972    -       May     Sun>=2  0:00    1:00    S
+Rule   Turkey  1970    1972    -       Oct     Sun>=2  0:00    0       -
+Rule   Turkey  1973    only    -       Jun      3      1:00    1:00    S
+Rule   Turkey  1973    only    -       Nov      4      3:00    0       -
+Rule   Turkey  1974    only    -       Mar     31      2:00    1:00    S
+Rule   Turkey  1974    only    -       Nov      3      5:00    0       -
+Rule   Turkey  1975    only    -       Mar     30      0:00    1:00    S
+Rule   Turkey  1975    1976    -       Oct     lastSun 0:00    0       -
+Rule   Turkey  1976    only    -       Jun      1      0:00    1:00    S
+Rule   Turkey  1977    1978    -       Apr     Sun>=1  0:00    1:00    S
+Rule   Turkey  1977    only    -       Oct     16      0:00    0       -
+Rule   Turkey  1979    1980    -       Apr     Sun>=1  3:00    1:00    S
+Rule   Turkey  1979    1982    -       Oct     Mon>=11 0:00    0       -
+Rule   Turkey  1981    1982    -       Mar     lastSun 3:00    1:00    S
+Rule   Turkey  1983    only    -       Jul     31      0:00    1:00    S
+Rule   Turkey  1983    only    -       Oct      2      0:00    0       -
+Rule   Turkey  1985    only    -       Apr     20      0:00    1:00    S
+Rule   Turkey  1985    only    -       Sep     28      0:00    0       -
+Rule   Turkey  1986    1990    -       Mar     lastSun 2:00s   1:00    S
+Rule   Turkey  1986    1990    -       Sep     lastSun 2:00s   0       -
+Rule   Turkey  1991    2006    -       Mar     lastSun 1:00s   1:00    S
+Rule   Turkey  1991    1995    -       Sep     lastSun 1:00s   0       -
+Rule   Turkey  1996    2006    -       Oct     lastSun 1:00s   0       -
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   Europe/Istanbul 1:55:52 -       LMT     1880
+                       1:56:56 -       IMT     1910 Oct # Istanbul Mean Time?
+                       2:00    Turkey  EE%sT   1978 Oct 15
+                       3:00    Turkey  TR%sT   1985 Apr 20 # Turkey Time
+                       2:00    Turkey  EE%sT   2007
+                       2:00    EU      EE%sT
+Link   Europe/Istanbul Asia/Istanbul   # Istanbul is in both continents.
+
+# Ukraine
+#
+# From Igor Karpov, who works for the Ukranian Ministry of Justice,
+# via Garrett Wollman (2003-01-27):
+# BTW, I've found the official document on this matter. It's goverment
+# regulations number 509, May 13, 1996. In my poor translation it says:
+# "Time in Ukraine is set to second timezone (Kiev time). Each last Sunday
+# of March at 3am the time is changing to 4am and each last Sunday of
+# October the time at 4am is changing to 3am"
+
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+# Most of Ukraine since 1970 has been like Kiev.
+# "Kyiv" is the transliteration of the Ukrainian name, but
+# "Kiev" is more common in English.
+Zone Europe/Kiev       2:02:04 -       LMT     1880
+                       2:02:04 -       KMT     1924 May  2 # Kiev Mean Time
+                       2:00    -       EET     1930 Jun 21
+                       3:00    -       MSK     1941 Sep 20
+                       1:00    C-Eur   CE%sT   1943 Nov  6
+                       3:00    Russia  MSK/MSD 1990
+                       3:00    -       MSK     1990 Jul  1 2:00
+                       2:00    -       EET     1992
+                       2:00    E-Eur   EE%sT   1995
+                       2:00    EU      EE%sT
+# Ruthenia used CET 1990/1991.
+# "Uzhhorod" is the transliteration of the Ukrainian name, but
+# "Uzhgorod" is more common in English.
+Zone Europe/Uzhgorod   1:29:12 -       LMT     1890 Oct
+                       1:00    -       CET     1940
+                       1:00    C-Eur   CE%sT   1944 Oct
+                       1:00    1:00    CEST    1944 Oct 26
+                       1:00    -       CET     1945 Jun 29
+                       3:00    Russia  MSK/MSD 1990
+                       3:00    -       MSK     1990 Jul  1 2:00
+                       1:00    -       CET     1991 Mar 31 3:00
+                       2:00    -       EET     1992
+                       2:00    E-Eur   EE%sT   1995
+                       2:00    EU      EE%sT
+# Zaporozh'ye and eastern Lugansk oblasts observed DST 1990/1991.
+# "Zaporizhia" is the transliteration of the Ukrainian name, but
+# "Zaporozh'ye" is more common in English.  Use the common English
+# spelling, except omit the apostrophe as it is not allowed in
+# portable Posix file names.
+Zone Europe/Zaporozhye 2:20:40 -       LMT     1880
+                       2:20    -       CUT     1924 May  2 # Central Ukraine T
+                       2:00    -       EET     1930 Jun 21
+                       3:00    -       MSK     1941 Aug 25
+                       1:00    C-Eur   CE%sT   1943 Oct 25
+                       3:00    Russia  MSK/MSD 1991 Mar 31 2:00
+                       2:00    E-Eur   EE%sT   1995
+                       2:00    EU      EE%sT
+# Central Crimea used Moscow time 1994/1997.
+Zone Europe/Simferopol 2:16:24 -       LMT     1880
+                       2:16    -       SMT     1924 May  2 # Simferopol Mean T
+                       2:00    -       EET     1930 Jun 21
+                       3:00    -       MSK     1941 Nov
+                       1:00    C-Eur   CE%sT   1944 Apr 13
+                       3:00    Russia  MSK/MSD 1990
+                       3:00    -       MSK     1990 Jul  1 2:00
+                       2:00    -       EET     1992
+# From Paul Eggert (2006-03-22):
+# The _Economist_ (1994-05-28, p 45) reports that central Crimea switched
+# from Kiev to Moscow time sometime after the January 1994 elections.
+# Shanks (1999) says ``date of change uncertain'', but implies that it happened
+# sometime between the 1994 DST switches.  Shanks & Pottenger simply say
+# 1994-09-25 03:00, but that can't be right.  For now, guess it
+# changed in May.
+                       2:00    E-Eur   EE%sT   1994 May
+# From IATA SSIM (1994/1997), which also says that Kerch is still like Kiev.
+                       3:00    E-Eur   MSK/MSD 1996 Mar 31 3:00s
+                       3:00    1:00    MSD     1996 Oct 27 3:00s
+# IATA SSIM (1997-09) says Crimea switched to EET/EEST.
+# Assume it happened in March by not changing the clocks.
+                       3:00    Russia  MSK/MSD 1997
+                       3:00    -       MSK     1997 Mar lastSun 1:00u
+                       2:00    EU      EE%sT
+
+###############################################################################
+
+# One source shows that Bulgaria, Cyprus, Finland, and Greece observe DST from
+# the last Sunday in March to the last Sunday in September in 1986.
+# The source shows Romania changing a day later than everybody else.
+#
+# According to Bernard Sieloff's source, Poland is in the MET time zone but
+# uses the WE DST rules.  The Western USSR uses EET+1 and ME DST rules.
+# Bernard Sieloff's source claims Romania switches on the same day, but at
+# 00:00 standard time (i.e., 01:00 DST).  It also claims that Turkey
+# switches on the same day, but switches on at 01:00 standard time
+# and off at 00:00 standard time (i.e., 01:00 DST)
+
+# ...
+# Date: Wed, 28 Jan 87 16:56:27 -0100
+# From: Tom Hofmann
+# ...
+#
+# ...the European time rules are...standardized since 1981, when
+# most European coun[tr]ies started DST.  Before that year, only
+# a few countries (UK, France, Italy) had DST, each according
+# to own national rules.  In 1981, however, DST started on
+# 'Apr firstSun', and not on 'Mar lastSun' as in the following
+# years...
+# But also since 1981 there are some more national exceptions
+# than listed in 'europe': Switzerland, for example, joined DST
+# one year later, Denmark ended DST on 'Oct 1' instead of 'Sep
+# lastSun' in 1981---I don't know how they handle now.
+#
+# Finally, DST ist always from 'Apr 1' to 'Oct 1' in the
+# Soviet Union (as far as I know).
+#
+# Tom Hofmann, Scientific Computer Center, CIBA-GEIGY AG,
+# 4002 Basle, Switzerland
+# ...
+
+# ...
+# Date: Wed, 4 Feb 87 22:35:22 +0100
+# From: Dik T. Winter
+# ...
+#
+# The information from Tom Hofmann is (as far as I know) not entirely correct.
+# After a request from chongo at amdahl I tried to retrieve all information
+# about DST in Europe.  I was able to find all from about 1969.
+#
+# ...standardization on DST in Europe started in about 1977 with switches on
+# first Sunday in April and last Sunday in September...
+# In 1981 UK joined Europe insofar that
+# the starting day for both shifted to last Sunday in March.  And from 1982
+# the whole of Europe used DST, with switch dates April 1 and October 1 in
+# the Sov[i]et Union.  In 1985 the SU reverted to standard Europe[a]n switch
+# dates...
+#
+# It should also be remembered that time-zones are not constants; e.g.
+# Portugal switched in 1976 from MET (or CET) to WET with DST...
+# Note also that though there were rules for switch dates not
+# all countries abided to these dates, and many individual deviations
+# occurred, though not since 1982 I believe.  Another note: it is always
+# assumed that DST is 1 hour ahead of normal time, this need not be the
+# case; at least in the Netherlands there have been times when DST was 2 hours
+# in advance of normal time.
+#
+# ...
+# dik t. winter, cwi, amsterdam, nederland
+# ...
+
+# From Bob Devine (1988-01-28):
+# ...
+# Greece: Last Sunday in April to last Sunday in September (iffy on dates).
+# Since 1978.  Change at midnight.
+# ...
+# Monaco: has same DST as France.
+# ...
diff --git a/extra/zoneinfo/leapseconds b/extra/zoneinfo/leapseconds
new file mode 100644 (file)
index 0000000..aa8cceb
--- /dev/null
@@ -0,0 +1,84 @@
+# @(#)leapseconds      8.7
+
+# Allowance for leapseconds added to each timezone file.
+
+# The International Earth Rotation Service periodically uses leap seconds
+# to keep UTC to within 0.9 s of UT1
+# (which measures the true angular orientation of the earth in space); see
+# Terry J Quinn, The BIPM and the accurate measure of time,
+# Proc IEEE 79, 7 (July 1991), 894-905.
+# There were no leap seconds before 1972, because the official mechanism
+# accounting for the discrepancy between atomic time and the earth's rotation
+# did not exist until the early 1970s.
+
+# The correction (+ or -) is made at the given time, so lines
+# will typically look like:
+#      Leap    YEAR    MON     DAY     23:59:60        +       R/S
+# or
+#      Leap    YEAR    MON     DAY     23:59:59        -       R/S
+
+# If the leapsecond is Rolling (R) the given time is local time
+# If the leapsecond is Stationary (S) the given time is UTC
+
+# Leap YEAR    MONTH   DAY     HH:MM:SS        CORR    R/S
+Leap   1972    Jun     30      23:59:60        +       S
+Leap   1972    Dec     31      23:59:60        +       S
+Leap   1973    Dec     31      23:59:60        +       S
+Leap   1974    Dec     31      23:59:60        +       S
+Leap   1975    Dec     31      23:59:60        +       S
+Leap   1976    Dec     31      23:59:60        +       S
+Leap   1977    Dec     31      23:59:60        +       S
+Leap   1978    Dec     31      23:59:60        +       S
+Leap   1979    Dec     31      23:59:60        +       S
+Leap   1981    Jun     30      23:59:60        +       S
+Leap   1982    Jun     30      23:59:60        +       S
+Leap   1983    Jun     30      23:59:60        +       S
+Leap   1985    Jun     30      23:59:60        +       S
+Leap   1987    Dec     31      23:59:60        +       S
+Leap   1989    Dec     31      23:59:60        +       S
+Leap   1990    Dec     31      23:59:60        +       S
+Leap   1992    Jun     30      23:59:60        +       S
+Leap   1993    Jun     30      23:59:60        +       S
+Leap   1994    Jun     30      23:59:60        +       S
+Leap   1995    Dec     31      23:59:60        +       S
+Leap   1997    Jun     30      23:59:60        +       S
+Leap   1998    Dec     31      23:59:60        +       S
+Leap   2005    Dec     31      23:59:60        +       S
+Leap   2008    Dec     31      23:59:60        +       S
+
+# INTERNATIONAL EARTH ROTATION AND REFERENCE SYSTEMS SERVICE (IERS)
+#
+# SERVICE INTERNATIONAL DE LA ROTATION TERRESTRE ET DES SYSTEMES DE REFERENCE
+#
+# SERVICE DE LA ROTATION TERRESTRE
+# OBSERVATOIRE DE PARIS
+# 61, Av. de l'Observatoire 75014 PARIS (France)
+# Tel.      : 33 (0) 1 40 51 22 29
+# FAX       : 33 (0) 1 40 51 22 91
+# Internet  : services.iers@obspm.fr
+#
+# Paris, 15 January 2009
+#
+# Bulletin C 37
+#
+# To authorities responsible
+# for the measurement and
+# distribution of time
+#
+# INFORMATION ON UTC - TAI
+#
+# NO positive leap second will be introduced at the end of June 2009.
+# The difference between Coordinated Universal Time UTC and the
+# International Atomic Time TAI is :           
+#
+# from 2009 January 1, 0h UTC, until further notice : UTC-TAI = -34 s
+#
+# Leap seconds can be introduced in UTC at the end of the months of December
+# or June,  depending on the evolution of UT1-TAI. Bulletin C is mailed every
+# six months, either to announce a time step in UTC, or to confirm that there
+# will be no time step at the next possible date.
+#
+# Daniel GAMBIS
+# Head                 
+# Earth Orientation Center of the IERS
+# Observatoire de Paris, France
diff --git a/extra/zoneinfo/northamerica b/extra/zoneinfo/northamerica
new file mode 100644 (file)
index 0000000..7fd6ea6
--- /dev/null
@@ -0,0 +1,2678 @@
+# @(#)northamerica     8.27
+# <pre>
+
+# also includes Central America and the Caribbean
+
+# This data is by no means authoritative; if you think you know better,
+# go ahead and edit the file (and please send any changes to
+# tz@elsie.nci.nih.gov for general use in the future).
+
+# From Paul Eggert (1999-03-22):
+# A reliable and entertaining source about time zones is
+# Derek Howse, Greenwich time and longitude, Philip Wilson Publishers (1997).
+
+###############################################################################
+
+# United States
+
+# From Paul Eggert (1999-03-31):
+# Howse writes (pp 121-125) that time zones were invented by
+# Professor Charles Ferdinand Dowd (1825-1904),
+# Principal of Temple Grove Ladies' Seminary (Saratoga Springs, NY).
+# His pamphlet ``A System of National Time for Railroads'' (1870)
+# was the result of his proposals at the Convention of Railroad Trunk Lines
+# in New York City (1869-10).  His 1870 proposal was based on Washington, DC,
+# but in 1872-05 he moved the proposed origin to Greenwich.
+# His proposal was adopted by the railroads on 1883-11-18 at 12:00,
+# and the most of the country soon followed suit.
+
+# From Paul Eggert (2005-04-16):
+# That 1883 transition occurred at 12:00 new time, not at 12:00 old time.
+# See p 46 of David Prerau, Seize the daylight, Thunder's Mouth Press (2005).
+
+# From Paul Eggert (2006-03-22):
+# A good source for time zone historical data in the US is
+# Thomas G. Shanks, The American Atlas (5th edition),
+# San Diego: ACS Publications, Inc. (1991).
+# Make sure you have the errata sheet; the book is somewhat useless without it.
+# It is the source for most of the pre-1991 US entries below.
+
+# From Paul Eggert (2001-03-06):
+# Daylight Saving Time was first suggested as a joke by Benjamin Franklin
+# in his whimsical essay ``An Economical Project for Diminishing the Cost
+# of Light'' published in the Journal de Paris (1784-04-26).
+# Not everyone is happy with the results:
+#
+#      I don't really care how time is reckoned so long as there is some
+#      agreement about it, but I object to being told that I am saving
+#      daylight when my reason tells me that I am doing nothing of the kind.
+#      I even object to the implication that I am wasting something
+#      valuable if I stay in bed after the sun has risen.  As an admirer
+#      of moonlight I resent the bossy insistence of those who want to
+#      reduce my time for enjoying it.  At the back of the Daylight Saving
+#      scheme I detect the bony, blue-fingered hand of Puritanism, eager
+#      to push people into bed earlier, and get them up earlier, to make
+#      them healthy, wealthy and wise in spite of themselves.
+#
+#      -- Robertson Davies, The diary of Samuel Marchbanks,
+#         Clarke, Irwin (1947), XIX, Sunday
+#
+# For more about the first ten years of DST in the United States, see
+# Robert Garland's <a href="http://www.clpgh.org/exhibit/dst.html">
+# Ten years of daylight saving from the Pittsburgh standpoint
+# (Carnegie Library of Pittsburgh, 1927)</a>.
+#
+# Shanks says that DST was called "War Time" in the US in 1918 and 1919.
+# However, DST was imposed by the Standard Time Act of 1918, which
+# was the first nationwide legal time standard, and apparently
+# time was just called "Standard Time" or "Daylight Saving Time".
+
+# From Arthur David Olson:
+# US Daylight Saving Time ended on the last Sunday of *October* in 1974.
+# See, for example, the front page of the Saturday, 1974-10-26
+# and Sunday, 1974-10-27 editions of the Washington Post.
+
+# From Arthur David Olson:
+# Before the Uniform Time Act of 1966 took effect in 1967, observance of
+# Daylight Saving Time in the US was by local option, except during wartime.
+
+# From Arthur David Olson (2000-09-25):
+# Last night I heard part of a rebroadcast of a 1945 Arch Oboler radio drama.
+# In the introduction, Oboler spoke of "Eastern Peace Time."
+# An AltaVista search turned up
+# <a href="http://rowayton.org/rhs/hstaug45.html">:
+# "When the time is announced over the radio now, it is 'Eastern Peace
+# Time' instead of the old familiar 'Eastern War Time.'  Peace is wonderful."
+# </a> (August 1945) by way of confirmation.
+
+# From Joseph Gallant citing
+# George H. Douglas, _The Early Days of Radio Broadcasting_ (1987):
+# At 7 P.M. (Eastern War Time) [on 1945-08-14], the networks were set
+# to switch to London for Attlee's address, but the American people
+# never got to hear his speech live. According to one press account,
+# CBS' Bob Trout was first to announce the word of Japan's surrender,
+# but a few seconds later, NBC, ABC and Mutual also flashed the word
+# of surrender, all of whom interrupting the bells of Big Ben in
+# London which were to precede Mr. Attlee's speech.
+
+# From Paul Eggert (2003-02-09): It was Robert St John, not Bob Trout.  From
+# Myrna Oliver's obituary of St John on page B16 of today's Los Angeles Times:
+#
+# ... a war-weary U.S. clung to radios, awaiting word of Japan's surrender.
+# Any announcement from Asia would reach St. John's New York newsroom on a
+# wire service teletype machine, which had prescribed signals for major news.
+# Associated Press, for example, would ring five bells before spewing out
+# typed copy of an important story, and 10 bells for news "of transcendental
+# importance."
+#
+# On Aug. 14, stalling while talking steadily into the NBC networks' open
+# microphone, St. John heard five bells and waited only to hear a sixth bell,
+# before announcing confidently: "Ladies and gentlemen, World War II is over.
+# The Japanese have agreed to our surrender terms."
+#
+# He had scored a 20-second scoop on other broadcasters.
+
+# From Arthur David Olson (2005-08-22):
+# Paul has been careful to use the "US" rules only in those locations
+# that are part of the United States; this reflects the real scope of
+# U.S. government action.  So even though the "US" rules have changed
+# in the latest release, other countries won't be affected.
+
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   US      1918    1919    -       Mar     lastSun 2:00    1:00    D
+Rule   US      1918    1919    -       Oct     lastSun 2:00    0       S
+Rule   US      1942    only    -       Feb     9       2:00    1:00    W # War
+Rule   US      1945    only    -       Aug     14      23:00u  1:00    P # Peace
+Rule   US      1945    only    -       Sep     30      2:00    0       S
+Rule   US      1967    2006    -       Oct     lastSun 2:00    0       S
+Rule   US      1967    1973    -       Apr     lastSun 2:00    1:00    D
+Rule   US      1974    only    -       Jan     6       2:00    1:00    D
+Rule   US      1975    only    -       Feb     23      2:00    1:00    D
+Rule   US      1976    1986    -       Apr     lastSun 2:00    1:00    D
+Rule   US      1987    2006    -       Apr     Sun>=1  2:00    1:00    D
+Rule   US      2007    max     -       Mar     Sun>=8  2:00    1:00    D
+Rule   US      2007    max     -       Nov     Sun>=1  2:00    0       S
+
+# From Arthur David Olson, 2005-12-19
+# We generate the files specified below to guard against old files with
+# obsolete information being left in the time zone binary directory.
+# We limit the list to names that have appeared in previous versions of
+# this time zone package.
+# We do these as separate Zones rather than as Links to avoid problems if
+# a particular place changes whether it observes DST.
+# We put these specifications here in the northamerica file both to
+# increase the chances that they'll actually get compiled and to
+# avoid the need to duplicate the US rules in another file.
+
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   EST              -5:00  -       EST
+Zone   MST              -7:00  -       MST
+Zone   HST             -10:00  -       HST
+Zone   EST5EDT          -5:00  US      E%sT
+Zone   CST6CDT          -6:00  US      C%sT
+Zone   MST7MDT          -7:00  US      M%sT
+Zone   PST8PDT          -8:00  US      P%sT
+
+# From Bob Devine (1988-01-28):
+# ...Alaska (and Hawaii) had the timezone names changed in 1967.
+#    old                        new
+#    Pacific Standard Time(PST)  -same-
+#    Yukon Standard Time(YST)    -same-
+#    Central Alaska S.T. (CAT)   Alaska-Hawaii St[an]dard Time (AHST)
+#    Nome Standard Time (NT)     Bering Standard Time (BST)
+#
+# ...Alaska's timezone lines were redrawn in 1983 to give only 2 tz.
+#    The YST zone now covers nearly all of the state, AHST just part
+#    of the Aleutian islands.   No DST.
+
+# From Paul Eggert (1995-12-19):
+# The tables below use `NST', not `NT', for Nome Standard Time.
+# I invented `CAWT' for Central Alaska War Time.
+
+# From U. S. Naval Observatory (1989-01-19):
+# USA  EASTERN       5 H  BEHIND UTC    NEW YORK, WASHINGTON
+# USA  EASTERN       4 H  BEHIND UTC    APR 3 - OCT 30
+# USA  CENTRAL       6 H  BEHIND UTC    CHICAGO, HOUSTON
+# USA  CENTRAL       5 H  BEHIND UTC    APR 3 - OCT 30
+# USA  MOUNTAIN      7 H  BEHIND UTC    DENVER
+# USA  MOUNTAIN      6 H  BEHIND UTC    APR 3 - OCT 30
+# USA  PACIFIC       8 H  BEHIND UTC    L.A., SAN FRANCISCO
+# USA  PACIFIC       7 H  BEHIND UTC    APR 3 - OCT 30
+# USA  ALASKA STD    9 H  BEHIND UTC    MOST OF ALASKA     (AKST)
+# USA  ALASKA STD    8 H  BEHIND UTC    APR 3 - OCT 30 (AKDT)
+# USA  ALEUTIAN     10 H  BEHIND UTC    ISLANDS WEST OF 170W
+# USA  - " -         9 H  BEHIND UTC    APR 3 - OCT 30
+# USA  HAWAII       10 H  BEHIND UTC
+# USA  BERING       11 H  BEHIND UTC    SAMOA, MIDWAY
+
+# From Arthur David Olson (1989-01-21):
+# The above dates are for 1988.
+# Note the "AKST" and "AKDT" abbreviations, the claim that there's
+# no DST in Samoa, and the claim that there is DST in Alaska and the
+# Aleutians.
+
+# From Arthur David Olson (1988-02-13):
+# Legal standard time zone names, from United States Code (1982 Edition and
+# Supplement III), Title 15, Chapter 6, Section 260 and forward.  First, names
+# up to 1967-04-01 (when most provisions of the Uniform Time Act of 1966
+# took effect), as explained in sections 263 and 261:
+#      (none)
+#      United States standard eastern time
+#      United States standard mountain time
+#      United States standard central time
+#      United States standard Pacific time
+#      (none)
+#      United States standard Alaska time
+#      (none)
+# Next, names from 1967-04-01 until 1983-11-30 (the date for
+# public law 98-181):
+#      Atlantic standard time
+#      eastern standard time
+#      central standard time
+#      mountain standard time
+#      Pacific standard time
+#      Yukon standard time
+#      Alaska-Hawaii standard time
+#      Bering standard time
+# And after 1983-11-30:
+#      Atlantic standard time
+#      eastern standard time
+#      central standard time
+#      mountain standard time
+#      Pacific standard time
+#      Alaska standard time
+#      Hawaii-Aleutian standard time
+#      Samoa standard time
+# The law doesn't give abbreviations.
+#
+# From Paul Eggert (2000-01-08), following a heads-up from Rives McDow:
+# Public law 106-564 (2000-12-23) introduced the abbreviation
+# "Chamorro Standard Time" for time in Guam and the Northern Marianas.
+# See the file "australasia".
+
+# From Arthur David Olson, 2005-08-09
+# The following was signed into law on 2005-08-08.
+#
+# H.R. 6, Energy Policy Act of 2005, SEC. 110. DAYLIGHT SAVINGS.
+#   (a) Amendment- Section 3(a) of the Uniform Time Act of 1966 (15
+#   U.S.C. 260a(a)) is amended--
+#     (1) by striking `first Sunday of April' and inserting `second
+#     Sunday of March'; and
+#     (2) by striking `last Sunday of October' and inserting `first
+#     Sunday of November'.
+#   (b) Effective Date- Subsection (a) shall take effect 1 year after the
+#   date of enactment of this Act or March 1, 2007, whichever is later.
+#   (c) Report to Congress- Not later than 9 months after the effective
+#   date stated in subsection (b), the Secretary shall report to Congress
+#   on the impact of this section on energy consumption in the United
+#   States.
+#   (d) Right to Revert- Congress retains the right to revert the
+#   Daylight Saving Time back to the 2005 time schedules once the
+#   Department study is complete.
+
+# US eastern time, represented by New York
+
+# Connecticut, Delaware, District of Columbia, most of Florida,
+# Georgia, southeast Indiana (Dearborn and Ohio counties), eastern Kentucky
+# (except America/Kentucky/Louisville below), Maine, Maryland, Massachusetts,
+# New Hampshire, New Jersey, New York, North Carolina, Ohio,
+# Pennsylvania, Rhode Island, South Carolina, eastern Tennessee,
+# Vermont, Virginia, West Virginia
+
+# From Dave Cantor (2004-11-02):
+# Early this summer I had the occasion to visit the Mount Washington
+# Observatory weather station atop (of course!) Mount Washington [, NH]....
+# One of the staff members said that the station was on Eastern Standard Time
+# and didn't change their clocks for Daylight Saving ... so that their
+# reports will always have times which are 5 hours behind UTC.
+
+# From Paul Eggert (2005-08-26):
+# According to today's Huntsville Times
+# <http://www.al.com/news/huntsvilletimes/index.ssf?/base/news/1125047783228320.xml&coll=1>
+# a few towns on Alabama's "eastern border with Georgia, such as Phenix City
+# in Russell County, Lanett in Chambers County and some towns in Lee County,
+# set their watches and clocks on Eastern time."  It quotes H.H. "Bubba"
+# Roberts, city administrator in Phenix City. as saying "We are in the Central
+# time zone, but we do go by the Eastern time zone because so many people work
+# in Columbus."
+
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER
+Rule   NYC     1920    only    -       Mar     lastSun 2:00    1:00    D
+Rule   NYC     1920    only    -       Oct     lastSun 2:00    0       S
+Rule   NYC     1921    1966    -       Apr     lastSun 2:00    1:00    D
+Rule   NYC     1921    1954    -       Sep     lastSun 2:00    0       S
+Rule   NYC     1955    1966    -       Oct     lastSun 2:00    0       S
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone America/New_York  -4:56:02 -      LMT     1883 Nov 18 12:03:58
+                       -5:00   US      E%sT    1920
+                       -5:00   NYC     E%sT    1942
+                       -5:00   US      E%sT    1946
+                       -5:00   NYC     E%sT    1967
+                       -5:00   US      E%sT
+
+# US central time, represented by Chicago
+
+# Alabama, Arkansas, Florida panhandle (Bay, Calhoun, Escambia,
+# Gulf, Holmes, Jackson, Okaloosa, Santa Rosa, Walton, and
+# Washington counties), Illinois, western Indiana
+# (Gibson, Jasper, Lake, LaPorte, Newton, Porter, Posey, Spencer,
+# Vanderburgh, and Warrick counties), Iowa, most of Kansas, western
+# Kentucky, Louisiana, Minnesota, Mississippi, Missouri, eastern
+# Nebraska, eastern North Dakota, Oklahoma, eastern South Dakota,
+# western Tennessee, most of Texas, Wisconsin
+
+# From Larry M. Smith (2006-04-26) re Wisconsin:
+# http://www.legis.state.wi.us/statutes/Stat0175.pdf ...
+# is currently enforced at the 01:00 time of change.  Because the local
+# "bar time" in the state corresponds to 02:00, a number of citations
+# are issued for the "sale of class 'B' alcohol after prohibited
+# hours" within the deviated hour of this change every year....
+#
+# From Douglas R. Bomberg (2007-03-12):
+# Wisconsin has enacted (nearly eleventh-hour) legislation to get WI
+# Statue 175 closer in synch with the US Congress' intent....
+# http://www.legis.state.wi.us/2007/data/acts/07Act3.pdf
+
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER
+Rule   Chicago 1920    only    -       Jun     13      2:00    1:00    D
+Rule   Chicago 1920    1921    -       Oct     lastSun 2:00    0       S
+Rule   Chicago 1921    only    -       Mar     lastSun 2:00    1:00    D
+Rule   Chicago 1922    1966    -       Apr     lastSun 2:00    1:00    D
+Rule   Chicago 1922    1954    -       Sep     lastSun 2:00    0       S
+Rule   Chicago 1955    1966    -       Oct     lastSun 2:00    0       S
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone America/Chicago   -5:50:36 -      LMT     1883 Nov 18 12:09:24
+                       -6:00   US      C%sT    1920
+                       -6:00   Chicago C%sT    1936 Mar  1 2:00
+                       -5:00   -       EST     1936 Nov 15 2:00
+                       -6:00   Chicago C%sT    1942
+                       -6:00   US      C%sT    1946
+                       -6:00   Chicago C%sT    1967
+                       -6:00   US      C%sT
+# Oliver County, ND switched from mountain to central time on 1992-10-25.
+Zone America/North_Dakota/Center -6:45:12 - LMT        1883 Nov 18 12:14:48
+                       -7:00   US      M%sT    1992 Oct 25 02:00
+                       -6:00   US      C%sT
+# Morton County, ND, switched from mountain to central time on
+# 2003-10-26, except for the area around Mandan which was already central time.
+# See <http://dmses.dot.gov/docimages/p63/135818.pdf>.
+# Officially this switch also included part of Sioux County, and
+# Jones, Mellette, and Todd Counties in South Dakota;
+# but in practice these other counties were already observing central time.
+# See <http://www.epa.gov/fedrgstr/EPA-IMPACT/2003/October/Day-28/i27056.htm>.
+Zone America/North_Dakota/New_Salem -6:45:39 - LMT 1883 Nov 18 12:14:21
+                       -7:00   US      M%sT    2003 Oct 26 02:00
+                       -6:00   US      C%sT
+
+# US mountain time, represented by Denver
+#
+# Colorado, far western Kansas, Montana, western
+# Nebraska, Nevada border (Jackpot, Owyhee, and Mountain City),
+# New Mexico, southwestern North Dakota,
+# western South Dakota, far western Texas (El Paso County, Hudspeth County,
+# and Pine Springs and Nickel Creek in Culberson County), Utah, Wyoming
+#
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER
+Rule   Denver  1920    1921    -       Mar     lastSun 2:00    1:00    D
+Rule   Denver  1920    only    -       Oct     lastSun 2:00    0       S
+Rule   Denver  1921    only    -       May     22      2:00    0       S
+Rule   Denver  1965    1966    -       Apr     lastSun 2:00    1:00    D
+Rule   Denver  1965    1966    -       Oct     lastSun 2:00    0       S
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone America/Denver    -6:59:56 -      LMT     1883 Nov 18 12:00:04
+                       -7:00   US      M%sT    1920
+                       -7:00   Denver  M%sT    1942
+                       -7:00   US      M%sT    1946
+                       -7:00   Denver  M%sT    1967
+                       -7:00   US      M%sT
+
+# US Pacific time, represented by Los Angeles
+#
+# California, northern Idaho (Benewah, Bonner, Boundary, Clearwater,
+# Idaho, Kootenai, Latah, Lewis, Nez Perce, and Shoshone counties,
+# and the northern three-quarters of Idaho county),
+# most of Nevada, most of Oregon, and Washington
+#
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER
+Rule   CA      1948    only    -       Mar     14      2:00    1:00    D
+Rule   CA      1949    only    -       Jan      1      2:00    0       S
+Rule   CA      1950    1966    -       Apr     lastSun 2:00    1:00    D
+Rule   CA      1950    1961    -       Sep     lastSun 2:00    0       S
+Rule   CA      1962    1966    -       Oct     lastSun 2:00    0       S
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone America/Los_Angeles -7:52:58 -    LMT     1883 Nov 18 12:07:02
+                       -8:00   US      P%sT    1946
+                       -8:00   CA      P%sT    1967
+                       -8:00   US      P%sT
+
+# Alaska
+# AK%sT is the modern abbreviation for -9:00 per USNO.
+#
+# From Paul Eggert (2001-05-30):
+# Howse writes that Alaska switched from the Julian to the Gregorian calendar,
+# and from east-of-GMT to west-of-GMT days, when the US bought it from Russia.
+# This was on 1867-10-18, a Friday; the previous day was 1867-10-06 Julian,
+# also a Friday.  Include only the time zone part of this transition,
+# ignoring the switch from Julian to Gregorian, since we can't represent
+# the Julian calendar.
+#
+# As far as we know, none of the exact locations mentioned below were
+# permanently inhabited in 1867 by anyone using either calendar.
+# (Yakutat was colonized by the Russians in 1799, but the settlement
+# was destroyed in 1805 by a Yakutat-kon war party.)  However, there
+# were nearby inhabitants in some cases and for our purposes perhaps
+# it's best to simply use the official transition.
+#
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone America/Juneau     15:02:19 -     LMT     1867 Oct 18
+                        -8:57:41 -     LMT     1900 Aug 20 12:00
+                        -8:00  -       PST     1942
+                        -8:00  US      P%sT    1946
+                        -8:00  -       PST     1969
+                        -8:00  US      P%sT    1983 Oct 30 2:00
+                        -9:00  US      Y%sT    1983 Nov 30
+                        -9:00  US      AK%sT
+Zone America/Yakutat    14:41:05 -     LMT     1867 Oct 18
+                        -9:18:55 -     LMT     1900 Aug 20 12:00
+                        -9:00  -       YST     1942
+                        -9:00  US      Y%sT    1946
+                        -9:00  -       YST     1969
+                        -9:00  US      Y%sT    1983 Nov 30
+                        -9:00  US      AK%sT
+Zone America/Anchorage  14:00:24 -     LMT     1867 Oct 18
+                        -9:59:36 -     LMT     1900 Aug 20 12:00
+                       -10:00  -       CAT     1942
+                       -10:00  US      CAT/CAWT 1945 Aug 14 23:00u
+                       -10:00  US      CAT/CAPT 1946 # Peace
+                       -10:00  -       CAT     1967 Apr
+                       -10:00  -       AHST    1969
+                       -10:00  US      AH%sT   1983 Oct 30 2:00
+                        -9:00  US      Y%sT    1983 Nov 30
+                        -9:00  US      AK%sT
+Zone America/Nome       12:58:21 -     LMT     1867 Oct 18
+                       -11:01:38 -     LMT     1900 Aug 20 12:00
+                       -11:00  -       NST     1942
+                       -11:00  US      N%sT    1946
+                       -11:00  -       NST     1967 Apr
+                       -11:00  -       BST     1969
+                       -11:00  US      B%sT    1983 Oct 30 2:00
+                        -9:00  US      Y%sT    1983 Nov 30
+                        -9:00  US      AK%sT
+Zone America/Adak       12:13:21 -     LMT     1867 Oct 18
+                       -11:46:38 -     LMT     1900 Aug 20 12:00
+                       -11:00  -       NST     1942
+                       -11:00  US      N%sT    1946
+                       -11:00  -       NST     1967 Apr
+                       -11:00  -       BST     1969
+                       -11:00  US      B%sT    1983 Oct 30 2:00
+                       -10:00  US      AH%sT   1983 Nov 30
+                       -10:00  US      HA%sT
+# The following switches don't quite make our 1970 cutoff.
+#
+# Shanks writes that part of southwest Alaska (e.g. Aniak)
+# switched from -11:00 to -10:00 on 1968-09-22 at 02:00,
+# and another part (e.g. Akiak) made the same switch five weeks later.
+#
+# From David Flater (2004-11-09):
+# In e-mail, 2004-11-02, Ray Hudson, historian/liaison to the Unalaska
+# Historic Preservation Commission, provided this information, which
+# suggests that Unalaska deviated from statutory time from early 1967
+# possibly until 1983:
+#
+#  Minutes of the Unalaska City Council Meeting, January 10, 1967:
+#  "Except for St. Paul and Akutan, Unalaska is the only important
+#  location not on Alaska Standard Time.  The following resolution was
+#  made by William Robinson and seconded by Henry Swanson:  Be it
+#  resolved that the City of Unalaska hereby goes to Alaska Standard
+#  Time as of midnight Friday, January 13, 1967 (1 A.M. Saturday,
+#  January 14, Alaska Standard Time.)  This resolution was passed with
+#  three votes for and one against."
+
+# Hawaii
+#
+# From Arthur David Olson:
+# And then there's Hawaii.
+# DST was observed for one day in 1933;
+# standard time was changed by half an hour in 1947;
+# it's always standard as of 1986.
+#
+# From Paul Eggert:
+# Shanks says the 1933 experiment lasted for three weeks.  Go with Shanks.
+#
+Zone Pacific/Honolulu  -10:31:26 -     LMT     1900 Jan  1 12:00
+                       -10:30  -       HST     1933 Apr 30 2:00
+                       -10:30  1:00    HDT     1933 May 21 2:00
+                       -10:30  US      H%sT    1947 Jun  8 2:00
+                       -10:00  -       HST
+
+# Now we turn to US areas that have diverged from the consensus since 1970.
+
+# Arizona mostly uses MST.
+
+# From Paul Eggert (2002-10-20):
+#
+# The information in the rest of this paragraph is derived from the
+# <a href="http://www.dlapr.lib.az.us/links/daylight.htm">
+# Daylight Saving Time web page (2002-01-23)</a> maintained by the
+# Arizona State Library, Archives and Public Records.
+# Between 1944-01-01 and 1944-04-01 the State of Arizona used standard
+# time, but by federal law railroads, airlines, bus lines, military
+# personnel, and some engaged in interstate commerce continued to
+# observe war (i.e., daylight saving) time.  The 1944-03-17 Phoenix
+# Gazette says that was the date the law changed, and that 04-01 was
+# the date the state's clocks would change.  In 1945 the State of
+# Arizona used standard time all year, again with exceptions only as
+# mandated by federal law.  Arizona observed DST in 1967, but Arizona
+# Laws 1968, ch. 183 (effective 1968-03-21) repealed DST.
+#
+# Shanks says the 1944 experiment came to an end on 1944-03-17.
+# Go with the Arizona State Library instead.
+
+Zone America/Phoenix   -7:28:18 -      LMT     1883 Nov 18 11:31:42
+                       -7:00   US      M%sT    1944 Jan  1 00:01
+                       -7:00   -       MST     1944 Apr  1 00:01
+                       -7:00   US      M%sT    1944 Oct  1 00:01
+                       -7:00   -       MST     1967
+                       -7:00   US      M%sT    1968 Mar 21
+                       -7:00   -       MST
+# From Arthur David Olson (1988-02-13):
+# A writer from the Inter Tribal Council of Arizona, Inc.,
+# notes in private correspondence dated 1987-12-28 that "Presently, only the
+# Navajo Nation participates in the Daylight Saving Time policy, due to its
+# large size and location in three states."  (The "only" means that other
+# tribal nations don't use DST.)
+
+Link America/Denver America/Shiprock
+
+# Southern Idaho (Ada, Adams, Bannock, Bear Lake, Bingham, Blaine,
+# Boise, Bonneville, Butte, Camas, Canyon, Caribou, Cassia, Clark,
+# Custer, Elmore, Franklin, Fremont, Gem, Gooding, Jefferson, Jerome,
+# Lemhi, Lincoln, Madison, Minidoka, Oneida, Owyhee, Payette, Power,
+# Teton, Twin Falls, Valley, Washington counties, and the southern
+# quarter of Idaho county) and eastern Oregon (most of Malheur County)
+# switched four weeks late in 1974.
+#
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone America/Boise     -7:44:49 -      LMT     1883 Nov 18 12:15:11
+                       -8:00   US      P%sT    1923 May 13 2:00
+                       -7:00   US      M%sT    1974
+                       -7:00   -       MST     1974 Feb  3 2:00
+                       -7:00   US      M%sT
+
+# Indiana
+#
+# For a map of Indiana's time zone regions, see:
+# <a href="http://www.mccsc.edu/time.html">
+# What time is it in Indiana?
+# </a> (2006-03-01)
+#
+# From Paul Eggert (2007-08-17):
+# Since 1970, most of Indiana has been like America/Indiana/Indianapolis,
+# with the following exceptions:
+#
+# - Gibson, Jasper, Lake, LaPorte, Newton, Porter, Posey, Spencer,
+#   Vandenburgh, and Warrick counties have been like America/Chicago.
+#
+# - Dearborn and Ohio counties have been like America/New_York.
+#
+# - Clark, Floyd, and Harrison counties have been like
+#   America/Kentucky/Louisville.
+#
+# - Crawford, Daviess, Dubois, Knox, Martin, Perry, Pike, Pulaski, Starke,
+#   and Switzerland counties have their own time zone histories as noted below.
+#
+# Shanks partitioned Indiana into 345 regions, each with its own time history,
+# and wrote ``Even newspaper reports present contradictory information.''
+# Those Hoosiers!  Such a flighty and changeable people!
+# Fortunately, most of the complexity occurred before our cutoff date of 1970.
+#
+# Other than Indianapolis, the Indiana place names are so nondescript
+# that they would be ambiguous if we left them at the `America' level.
+# So we reluctantly put them all in a subdirectory `America/Indiana'.
+
+# From Paul Eggert (2005-08-16):
+# http://www.mccsc.edu/time.html says that Indiana will use DST starting 2006.
+
+# From Nathan Stratton Treadway (2006-03-30):
+# http://www.dot.gov/affairs/dot0406.htm [3705 B]
+# From Deborah Goldsmith (2006-01-18):
+# http://dmses.dot.gov/docimages/pdf95/382329_web.pdf [2.9 MB]
+# From Paul Eggert (2006-01-20):
+# It says "DOT is relocating the time zone boundary in Indiana to move Starke,
+# Pulaski, Knox, Daviess, Martin, Pike, Dubois, and Perry Counties from the
+# Eastern Time Zone to the Central Time Zone.... The effective date of
+# this rule is 2:OO a.m. EST Sunday, April 2, 2006, which is the
+# changeover date from standard time to Daylight Saving Time."
+# Strictly speaking, this means the affected counties will change their
+# clocks twice that night, but this obviously is in error.  The intent
+# is that 01:59:59 EST be followed by 02:00:00 CDT.
+
+# From Gwillim Law (2007-02-10):
+# The Associated Press has been reporting that Pulaski County, Indiana is
+# going to switch from Central to Eastern Time on March 11, 2007....
+# http://www.indystar.com/apps/pbcs.dll/article?AID=/20070207/LOCAL190108/702070524/0/LOCAL
+
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER
+Rule Indianapolis 1941 only    -       Jun     22      2:00    1:00    D
+Rule Indianapolis 1941 1954    -       Sep     lastSun 2:00    0       S
+Rule Indianapolis 1946 1954    -       Apr     lastSun 2:00    1:00    D
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone America/Indiana/Indianapolis -5:44:38 - LMT 1883 Nov 18 12:15:22
+                       -6:00   US      C%sT    1920
+                       -6:00 Indianapolis C%sT 1942
+                       -6:00   US      C%sT    1946
+                       -6:00 Indianapolis C%sT 1955 Apr 24 2:00
+                       -5:00   -       EST     1957 Sep 29 2:00
+                       -6:00   -       CST     1958 Apr 27 2:00
+                       -5:00   -       EST     1969
+                       -5:00   US      E%sT    1971
+                       -5:00   -       EST     2006
+                       -5:00   US      E%sT
+#
+# Eastern Crawford County, Indiana, left its clocks alone in 1974,
+# as well as from 1976 through 2005.
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER
+Rule   Marengo 1951    only    -       Apr     lastSun 2:00    1:00    D
+Rule   Marengo 1951    only    -       Sep     lastSun 2:00    0       S
+Rule   Marengo 1954    1960    -       Apr     lastSun 2:00    1:00    D
+Rule   Marengo 1954    1960    -       Sep     lastSun 2:00    0       S
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone America/Indiana/Marengo -5:45:23 -        LMT     1883 Nov 18 12:14:37
+                       -6:00   US      C%sT    1951
+                       -6:00   Marengo C%sT    1961 Apr 30 2:00
+                       -5:00   -       EST     1969
+                       -5:00   US      E%sT    1974 Jan  6 2:00
+                       -6:00   1:00    CDT     1974 Oct 27 2:00
+                       -5:00   US      E%sT    1976
+                       -5:00   -       EST     2006
+                       -5:00   US      E%sT
+#
+# Daviess, Dubois, Knox, and Martin Counties, Indiana,
+# switched from eastern to central time in April 2006, then switched back
+# in November 2007.
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER
+Rule Vincennes 1946    only    -       Apr     lastSun 2:00    1:00    D
+Rule Vincennes 1946    only    -       Sep     lastSun 2:00    0       S
+Rule Vincennes 1953    1954    -       Apr     lastSun 2:00    1:00    D
+Rule Vincennes 1953    1959    -       Sep     lastSun 2:00    0       S
+Rule Vincennes 1955    only    -       May      1      0:00    1:00    D
+Rule Vincennes 1956    1963    -       Apr     lastSun 2:00    1:00    D
+Rule Vincennes 1960    only    -       Oct     lastSun 2:00    0       S
+Rule Vincennes 1961    only    -       Sep     lastSun 2:00    0       S
+Rule Vincennes 1962    1963    -       Oct     lastSun 2:00    0       S
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone America/Indiana/Vincennes -5:50:07 - LMT  1883 Nov 18 12:09:53
+                       -6:00   US      C%sT    1946
+                       -6:00 Vincennes C%sT    1964 Apr 26 2:00
+                       -5:00   -       EST     1969
+                       -5:00   US      E%sT    1971
+                       -5:00   -       EST     2006 Apr  2 2:00
+                       -6:00   US      C%sT    2007 Nov  4 2:00
+                       -5:00   US      E%sT
+#
+# Perry County, Indiana, switched from eastern to central time in April 2006.
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER
+Rule Perry     1946    only    -       Apr     lastSun 2:00    1:00    D
+Rule Perry     1946    only    -       Sep     lastSun 2:00    0       S
+Rule Perry     1953    1954    -       Apr     lastSun 2:00    1:00    D
+Rule Perry     1953    1959    -       Sep     lastSun 2:00    0       S
+Rule Perry     1955    only    -       May      1      0:00    1:00    D
+Rule Perry     1956    1963    -       Apr     lastSun 2:00    1:00    D
+Rule Perry     1960    only    -       Oct     lastSun 2:00    0       S
+Rule Perry     1961    only    -       Sep     lastSun 2:00    0       S
+Rule Perry     1962    1963    -       Oct     lastSun 2:00    0       S
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone America/Indiana/Tell_City -5:47:03 - LMT  1883 Nov 18 12:12:57
+                       -6:00   US      C%sT    1946
+                       -6:00 Perry     C%sT    1964 Apr 26 2:00
+                       -5:00   -       EST     1969
+                       -5:00   US      E%sT    1971
+                       -5:00   -       EST     2006 Apr  2 2:00
+                       -6:00   US      C%sT
+#
+# Pike County, Indiana moved from central to eastern time in 1977,
+# then switched back in 2006, then switched back again in 2007.
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER
+Rule   Pike    1955    only    -       May      1      0:00    1:00    D
+Rule   Pike    1955    1960    -       Sep     lastSun 2:00    0       S
+Rule   Pike    1956    1964    -       Apr     lastSun 2:00    1:00    D
+Rule   Pike    1961    1964    -       Oct     lastSun 2:00    0       S
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone America/Indiana/Petersburg -5:49:07 - LMT 1883 Nov 18 12:10:53
+                       -6:00   US      C%sT    1955
+                       -6:00   Pike    C%sT    1965 Apr 25 2:00
+                       -5:00   -       EST     1966 Oct 30 2:00
+                       -6:00   US      C%sT    1977 Oct 30 2:00
+                       -5:00   -       EST     2006 Apr  2 2:00
+                       -6:00   US      C%sT    2007 Nov  4 2:00
+                       -5:00   US      E%sT
+#
+# Starke County, Indiana moved from central to eastern time in 1991,
+# then switched back in 2006.
+# From Arthur David Olson (1991-10-28):
+# An article on page A3 of the Sunday, 1991-10-27 Washington Post
+# notes that Starke County switched from Central time to Eastern time as of
+# 1991-10-27.
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER
+Rule   Starke  1947    1961    -       Apr     lastSun 2:00    1:00    D
+Rule   Starke  1947    1954    -       Sep     lastSun 2:00    0       S
+Rule   Starke  1955    1956    -       Oct     lastSun 2:00    0       S
+Rule   Starke  1957    1958    -       Sep     lastSun 2:00    0       S
+Rule   Starke  1959    1961    -       Oct     lastSun 2:00    0       S
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone America/Indiana/Knox -5:46:30 -   LMT     1883 Nov 18 12:13:30
+                       -6:00   US      C%sT    1947
+                       -6:00   Starke  C%sT    1962 Apr 29 2:00
+                       -5:00   -       EST     1963 Oct 27 2:00
+                       -6:00   US      C%sT    1991 Oct 27 2:00
+                       -5:00   -       EST     2006 Apr  2 2:00
+                       -6:00   US      C%sT
+#
+# Pulaski County, Indiana, switched from eastern to central time in
+# April 2006 and then switched back in March 2007.
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER
+Rule   Pulaski 1946    1960    -       Apr     lastSun 2:00    1:00    D
+Rule   Pulaski 1946    1954    -       Sep     lastSun 2:00    0       S
+Rule   Pulaski 1955    1956    -       Oct     lastSun 2:00    0       S
+Rule   Pulaski 1957    1960    -       Sep     lastSun 2:00    0       S
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone America/Indiana/Winamac -5:46:25 - LMT    1883 Nov 18 12:13:35
+                       -6:00   US      C%sT    1946
+                       -6:00   Pulaski C%sT    1961 Apr 30 2:00
+                       -5:00   -       EST     1969
+                       -5:00   US      E%sT    1971
+                       -5:00   -       EST     2006 Apr  2 2:00
+                       -6:00   US      C%sT    2007 Mar 11 2:00
+                       -5:00   US      E%sT
+#
+# Switzerland County, Indiana, did not observe DST from 1973 through 2005.
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone America/Indiana/Vevay -5:40:16 -  LMT     1883 Nov 18 12:19:44
+                       -6:00   US      C%sT    1954 Apr 25 2:00
+                       -5:00   -       EST     1969
+                       -5:00   US      E%sT    1973
+                       -5:00   -       EST     2006
+                       -5:00   US      E%sT
+
+# Part of Kentucky left its clocks alone in 1974.
+# This also includes Clark, Floyd, and Harrison counties in Indiana.
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER
+Rule Louisville        1921    only    -       May     1       2:00    1:00    D
+Rule Louisville        1921    only    -       Sep     1       2:00    0       S
+Rule Louisville        1941    1961    -       Apr     lastSun 2:00    1:00    D
+Rule Louisville        1941    only    -       Sep     lastSun 2:00    0       S
+Rule Louisville        1946    only    -       Jun     2       2:00    0       S
+Rule Louisville        1950    1955    -       Sep     lastSun 2:00    0       S
+Rule Louisville        1956    1960    -       Oct     lastSun 2:00    0       S
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone America/Kentucky/Louisville -5:43:02 -    LMT     1883 Nov 18 12:16:58
+                       -6:00   US      C%sT    1921
+                       -6:00 Louisville C%sT   1942
+                       -6:00   US      C%sT    1946
+                       -6:00 Louisville C%sT   1961 Jul 23 2:00
+                       -5:00   -       EST     1968
+                       -5:00   US      E%sT    1974 Jan  6 2:00
+                       -6:00   1:00    CDT     1974 Oct 27 2:00
+                       -5:00   US      E%sT
+#
+# Wayne County, Kentucky
+#
+# From
+# <a href="http://www.lake-cumberland.com/life/archive/news990129time.shtml">
+# Lake Cumberland LIFE
+# </a> (1999-01-29) via WKYM-101.7:
+# Clinton County has joined Wayne County in asking the DoT to change from
+# the Central to the Eastern time zone....  The Wayne County government made
+# the same request in December.  And while Russell County officials have not
+# taken action, the majority of respondents to a poll conducted there in
+# August indicated they would like to change to "fast time" also.
+# The three Lake Cumberland counties are the farthest east of any U.S.
+# location in the Central time zone.
+#
+# From Rich Wales (2000-08-29):
+# After prolonged debate, and despite continuing deep differences of opinion,
+# Wayne County (central Kentucky) is switching from Central (-0600) to Eastern
+# (-0500) time.  They won't "fall back" this year.  See Sara Shipley,
+# The difference an hour makes, Nando Times (2000-08-29 15:33 -0400).
+#
+# From Paul Eggert (2001-07-16):
+# The final rule was published in the
+# <a href="http://frwebgate.access.gpo.gov/cgi-bin/getdoc.cgi?dbname=2000_register&docid=fr17au00-22">
+# Federal Register 65, 160 (2000-08-17), page 50154-50158.
+# </a>
+#
+Zone America/Kentucky/Monticello -5:39:24 - LMT        1883 Nov 18 12:20:36
+                       -6:00   US      C%sT    1946
+                       -6:00   -       CST     1968
+                       -6:00   US      C%sT    2000 Oct 29  2:00
+                       -5:00   US      E%sT
+
+
+# From Rives McDow (2000-08-30):
+# Here ... are all the changes in the US since 1985.
+# Kearny County, KS (put all of county on central;
+#      previously split between MST and CST) ... 1990-10
+# Starke County, IN (from CST to EST) ... 1991-10
+# Oliver County, ND (from MST to CST) ... 1992-10
+# West Wendover, NV (from PST TO MST) ... 1999-10
+# Wayne County, KY (from CST to EST) ... 2000-10
+#
+# From Paul Eggert (2001-07-17):
+# We don't know where the line used to be within Kearny County, KS,
+# so omit that change for now.
+# See America/Indiana/Knox for the Starke County, IN change.
+# See America/North_Dakota/Center for the Oliver County, ND change.
+# West Wendover, NV officially switched from Pacific to mountain time on
+# 1999-10-31.  See the
+# <a href="http://frwebgate.access.gpo.gov/cgi-bin/getdoc.cgi?dbname=1999_register&docid=fr21oc99-15">
+# Federal Register 64, 203 (1999-10-21), page 56705-56707.
+# </a>
+# However, the Federal Register says that West Wendover already operated
+# on mountain time, and the rule merely made this official;
+# hence a separate tz entry is not needed.
+
+# Michigan
+#
+# From Bob Devine (1988-01-28):
+# Michigan didn't observe DST from 1968 to 1973.
+#
+# From Paul Eggert (1999-03-31):
+# Shanks writes that Michigan started using standard time on 1885-09-18,
+# but Howse writes (pp 124-125, referring to Popular Astronomy, 1901-01)
+# that Detroit kept
+#
+#      local time until 1900 when the City Council decreed that clocks should
+#      be put back twenty-eight minutes to Central Standard Time.  Half the
+#      city obeyed, half refused.  After considerable debate, the decision
+#      was rescinded and the city reverted to Sun time.  A derisive offer to
+#      erect a sundial in front of the city hall was referred to the
+#      Committee on Sewers.  Then, in 1905, Central time was adopted
+#      by city vote.
+#
+# This story is too entertaining to be false, so go with Howse over Shanks.
+#
+# From Paul Eggert (2001-03-06):
+# Garland (1927) writes ``Cleveland and Detroit advanced their clocks
+# one hour in 1914.''  This change is not in Shanks.  We have no more
+# info, so omit this for now.
+#
+# Most of Michigan observed DST from 1973 on, but was a bit late in 1975.
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER
+Rule   Detroit 1948    only    -       Apr     lastSun 2:00    1:00    D
+Rule   Detroit 1948    only    -       Sep     lastSun 2:00    0       S
+Rule   Detroit 1967    only    -       Jun     14      2:00    1:00    D
+Rule   Detroit 1967    only    -       Oct     lastSun 2:00    0       S
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone America/Detroit   -5:32:11 -      LMT     1905
+                       -6:00   -       CST     1915 May 15 2:00
+                       -5:00   -       EST     1942
+                       -5:00   US      E%sT    1946
+                       -5:00   Detroit E%sT    1973
+                       -5:00   US      E%sT    1975
+                       -5:00   -       EST     1975 Apr 27 2:00
+                       -5:00   US      E%sT
+#
+# Dickinson, Gogebic, Iron, and Menominee Counties, Michigan,
+# switched from EST to CST/CDT in 1973.
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER
+Rule Menominee 1946    only    -       Apr     lastSun 2:00    1:00    D
+Rule Menominee 1946    only    -       Sep     lastSun 2:00    0       S
+Rule Menominee 1966    only    -       Apr     lastSun 2:00    1:00    D
+Rule Menominee 1966    only    -       Oct     lastSun 2:00    0       S
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone America/Menominee -5:50:27 -      LMT     1885 Sep 18 12:00
+                       -6:00   US      C%sT    1946
+                       -6:00 Menominee C%sT    1969 Apr 27 2:00
+                       -5:00   -       EST     1973 Apr 29 2:00
+                       -6:00   US      C%sT
+
+# Navassa
+# administered by the US Fish and Wildlife Service
+# claimed by US under the provisions of the 1856 Guano Islands Act
+# also claimed by Haiti
+# occupied 1857/1900 by the Navassa Phosphate Co
+# US lighthouse 1917/1996-09
+# currently uninhabited
+# see Mark Fineman, ``An Isle Rich in Guano and Discord'',
+# _Los Angeles Times_ (1998-11-10), A1, A10; it cites
+# Jimmy Skaggs, _The Great Guano Rush_ (1994).
+
+################################################################################
+
+
+# From Paul Eggert (2006-03-22):
+# A good source for time zone historical data outside the U.S. is
+# Thomas G. Shanks and Rique Pottenger, The International Atlas (6th edition),
+# San Diego: ACS Publications, Inc. (2003).
+#
+# Gwillim Law writes that a good source
+# for recent time zone data is the International Air Transport
+# Association's Standard Schedules Information Manual (IATA SSIM),
+# published semiannually.  Law sent in several helpful summaries
+# of the IATA's data after 1990.
+#
+# Except where otherwise noted, Shanks & Pottenger is the source for
+# entries through 1990, and IATA SSIM is the source for entries afterwards.
+#
+# Other sources occasionally used include:
+#
+#      Edward W. Whitman, World Time Differences,
+#      Whitman Publishing Co, 2 Niagara Av, Ealing, London (undated),
+#      which I found in the UCLA library.
+#
+#      <a href="http://www.pettswoodvillage.co.uk/Daylight_Savings_William_Willett.pdf">
+#      William Willett, The Waste of Daylight, 19th edition
+#      </a> (1914-03)
+#
+# See the `europe' file for Greenland.
+
+# Canada
+
+# From Alain LaBont<e'> (1994-11-14):
+# I post here the time zone abbreviations standardized in Canada
+# for both English and French in the CAN/CSA-Z234.4-89 standard....
+#
+#      UTC     Standard time   Daylight savings time
+#      offset  French  English French  English
+#      -2:30   -       -       HAT     NDT
+#      -3      -       -       HAA     ADT
+#      -3:30   HNT     NST     -       -
+#      -4      HNA     AST     HAE     EDT
+#      -5      HNE     EST     HAC     CDT
+#      -6      HNC     CST     HAR     MDT
+#      -7      HNR     MST     HAP     PDT
+#      -8      HNP     PST     HAY     YDT
+#      -9      HNY     YST     -       -
+#
+#      HN: Heure Normale       ST: Standard Time
+#      HA: Heure Avanc<e'>e    DT: Daylight saving Time
+#
+#      A: de l'Atlantique      Atlantic
+#      C: du Centre            Central
+#      E: de l'Est             Eastern
+#      M:                      Mountain
+#      N:                      Newfoundland
+#      P: du Pacifique         Pacific
+#      R: des Rocheuses
+#      T: de Terre-Neuve
+#      Y: du Yukon             Yukon
+#
+# From Paul Eggert (1994-11-22):
+# Alas, this sort of thing must be handled by localization software.
+
+# Unless otherwise specified, the data for Canada are all from Shanks
+# & Pottenger.
+
+# From Chris Walton (2006-04-01, 2006-04-25, 2006-06-26, 2007-01-31,
+# 2007-03-01):
+# The British Columbia government announced yesterday that it will
+# adjust daylight savings next year to align with changes in the
+# U.S. and the rest of Canada....
+# http://www2.news.gov.bc.ca/news_releases_2005-2009/2006AG0014-000330.htm
+# ...
+# Nova Scotia
+# Daylight saving time will be extended by four weeks starting in 2007....
+# http://www.gov.ns.ca/just/regulations/rg2/2006/ma1206.pdf
+#
+# [For New Brunswick] the new legislation dictates that the time change is to
+# be done at 02:00 instead of 00:01.
+# http://www.gnb.ca/0062/acts/BBA-2006/Chap-19.pdf
+# ...
+# Manitoba has traditionally changed the clock every fall at 03:00.
+# As of 2006, the transition is to take place one hour earlier at 02:00.
+# http://web2.gov.mb.ca/laws/statutes/ccsm/o030e.php
+# ...
+# [Alberta, Ontario, Quebec] will follow US rules.
+# http://www.qp.gov.ab.ca/documents/spring/CH03_06.CFM
+# http://www.e-laws.gov.on.ca/DBLaws/Source/Regs/English/2006/R06111_e.htm
+# http://www2.publicationsduquebec.gouv.qc.ca/dynamicSearch/telecharge.php?type=5&file=2006C39A.PDF
+# ...
+# P.E.I. will follow US rules....
+# http://www.assembly.pe.ca/bills/pdf_chapter/62/3/chapter-41.pdf
+# ...
+# Province of Newfoundland and Labrador....
+# http://www.hoa.gov.nl.ca/hoa/bills/Bill0634.htm
+# ...
+# Yukon
+# http://www.gov.yk.ca/legislation/regs/oic2006_127.pdf
+# ...
+# N.W.T. will follow US rules.  Whoever maintains the government web site
+# does not seem to believe in bookmarks.  To see the news release, click the
+# following link and search for "Daylight Savings Time Change".  Press the
+# "Daylight Savings Time Change" link; it will fire off a popup using
+# JavaScript.
+# http://www.exec.gov.nt.ca/currentnews/currentPR.asp?mode=archive
+# ...
+# Nunavut
+# An amendment to the Interpretation Act was registered on February 19/2007....
+# http://action.attavik.ca/home/justice-gn/attach/2007/gaz02part2.pdf
+
+# From Paul Eggert (2006-04-25):
+# H. David Matthews and Mary Vincent's map
+# <a href="http://www.canadiangeographic.ca/Magazine/SO98/geomap.asp">
+# "It's about TIME", _Canadian Geographic_ (September-October 1998)
+# </a> contains detailed boundaries for regions observing nonstandard
+# time and daylight saving time arrangements in Canada circa 1998.
+#
+# INMS, the Institute for National Measurement Standards in Ottawa, has <a
+# href="http://inms-ienm.nrc-cnrc.gc.ca/en/time_services/daylight_saving_e.php">
+# information about standard and daylight saving time zones in Canada.
+# </a> (updated periodically).
+# Its unofficial information is often taken from Matthews and Vincent.
+
+# From Paul Eggert (2006-06-27):
+# For now, assume all of DST-observing Canada will fall into line with the
+# new US DST rules,
+
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Canada  1918    only    -       Apr     14      2:00    1:00    D
+Rule   Canada  1918    only    -       Oct     31      2:00    0       S
+Rule   Canada  1942    only    -       Feb      9      2:00    1:00    W # War
+Rule   Canada  1945    only    -       Aug     14      23:00u  1:00    P # Peace
+Rule   Canada  1945    only    -       Sep     30      2:00    0       S
+Rule   Canada  1974    1986    -       Apr     lastSun 2:00    1:00    D
+Rule   Canada  1974    2006    -       Oct     lastSun 2:00    0       S
+Rule   Canada  1987    2006    -       Apr     Sun>=1  2:00    1:00    D
+Rule   Canada  2007    max     -       Mar     Sun>=8  2:00    1:00    D
+Rule   Canada  2007    max     -       Nov     Sun>=1  2:00    0       S
+
+
+# Newfoundland and Labrador
+
+# From Paul Eggert (2000-10-02):
+# Matthews and Vincent (1998) write that Labrador should use NST/NDT,
+# but the only part of Labrador that follows the rules is the
+# southeast corner, including Port Hope Simpson and Mary's Harbour,
+# but excluding, say, Black Tickle.
+
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   StJohns 1917    only    -       Apr      8      2:00    1:00    D
+Rule   StJohns 1917    only    -       Sep     17      2:00    0       S
+# Whitman gives 1919 Apr 5 and 1920 Apr 5; go with Shanks & Pottenger.
+Rule   StJohns 1919    only    -       May      5      23:00   1:00    D
+Rule   StJohns 1919    only    -       Aug     12      23:00   0       S
+# For 1931-1935 Whitman gives Apr same date; go with Shanks & Pottenger.
+Rule   StJohns 1920    1935    -       May     Sun>=1  23:00   1:00    D
+Rule   StJohns 1920    1935    -       Oct     lastSun 23:00   0       S
+# For 1936-1941 Whitman gives May Sun>=8 and Oct Sun>=1; go with Shanks &
+# Pottenger.
+Rule   StJohns 1936    1941    -       May     Mon>=9  0:00    1:00    D
+Rule   StJohns 1936    1941    -       Oct     Mon>=2  0:00    0       S
+# Whitman gives the following transitions:
+# 1942 03-01/12-31, 1943 05-30/09-05, 1944 07-10/09-02, 1945 01-01/10-07
+# but go with Shanks & Pottenger and assume they used Canadian rules.
+# For 1946-9 Whitman gives May 5,4,9,1 - Oct 1,5,3,2, and for 1950 he gives
+# Apr 30 - Sep 24; go with Shanks & Pottenger.
+Rule   StJohns 1946    1950    -       May     Sun>=8  2:00    1:00    D
+Rule   StJohns 1946    1950    -       Oct     Sun>=2  2:00    0       S
+Rule   StJohns 1951    1986    -       Apr     lastSun 2:00    1:00    D
+Rule   StJohns 1951    1959    -       Sep     lastSun 2:00    0       S
+Rule   StJohns 1960    1986    -       Oct     lastSun 2:00    0       S
+# From Paul Eggert (2000-10-02):
+# INMS (2000-09-12) says that, since 1988 at least, Newfoundland switches
+# at 00:01 local time.  For now, assume it started in 1987.
+Rule   StJohns 1987    only    -       Apr     Sun>=1  0:01    1:00    D
+Rule   StJohns 1987    2006    -       Oct     lastSun 0:01    0       S
+Rule   StJohns 1988    only    -       Apr     Sun>=1  0:01    2:00    DD
+Rule   StJohns 1989    2006    -       Apr     Sun>=1  0:01    1:00    D
+Rule   StJohns 2007    max     -       Mar     Sun>=8  0:01    1:00    D
+Rule   StJohns 2007    max     -       Nov     Sun>=1  0:01    0       S
+#
+# St John's has an apostrophe, but Posix file names can't have apostrophes.
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone America/St_Johns  -3:30:52 -      LMT     1884
+                       -3:30:52 StJohns N%sT   1918
+                       -3:30:52 Canada N%sT    1919
+                       -3:30:52 StJohns N%sT   1935 Mar 30
+                       -3:30   StJohns N%sT    1942 May 11
+                       -3:30   Canada  N%sT    1946
+                       -3:30   StJohns N%sT
+
+# most of east Labrador
+
+# The name `Happy Valley-Goose Bay' is too long; use `Goose Bay'.
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone America/Goose_Bay -4:01:40 -      LMT     1884 # Happy Valley-Goose Bay
+                       -3:30:52 -      NST     1918
+                       -3:30:52 Canada N%sT    1919
+                       -3:30:52 -      NST     1935 Mar 30
+                       -3:30   -       NST     1936
+                       -3:30   StJohns N%sT    1942 May 11
+                       -3:30   Canada  N%sT    1946
+                       -3:30   StJohns N%sT    1966 Mar 15 2:00
+                       -4:00   StJohns A%sT
+
+
+# west Labrador, Nova Scotia, Prince Edward I
+
+# From Paul Eggert (2006-03-22):
+# Shanks & Pottenger write that since 1970 most of this region has been like
+# Halifax.  Many locales did not observe peacetime DST until 1972;
+# Glace Bay, NS is the largest that we know of.
+# Shanks & Pottenger also write that Liverpool, NS was the only town
+# in Canada to observe DST in 1971 but not 1970; for now we'll assume
+# this is a typo.
+
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Halifax 1916    only    -       Apr      1      0:00    1:00    D
+Rule   Halifax 1916    only    -       Oct      1      0:00    0       S
+Rule   Halifax 1920    only    -       May      9      0:00    1:00    D
+Rule   Halifax 1920    only    -       Aug     29      0:00    0       S
+Rule   Halifax 1921    only    -       May      6      0:00    1:00    D
+Rule   Halifax 1921    1922    -       Sep      5      0:00    0       S
+Rule   Halifax 1922    only    -       Apr     30      0:00    1:00    D
+Rule   Halifax 1923    1925    -       May     Sun>=1  0:00    1:00    D
+Rule   Halifax 1923    only    -       Sep      4      0:00    0       S
+Rule   Halifax 1924    only    -       Sep     15      0:00    0       S
+Rule   Halifax 1925    only    -       Sep     28      0:00    0       S
+Rule   Halifax 1926    only    -       May     16      0:00    1:00    D
+Rule   Halifax 1926    only    -       Sep     13      0:00    0       S
+Rule   Halifax 1927    only    -       May      1      0:00    1:00    D
+Rule   Halifax 1927    only    -       Sep     26      0:00    0       S
+Rule   Halifax 1928    1931    -       May     Sun>=8  0:00    1:00    D
+Rule   Halifax 1928    only    -       Sep      9      0:00    0       S
+Rule   Halifax 1929    only    -       Sep      3      0:00    0       S
+Rule   Halifax 1930    only    -       Sep     15      0:00    0       S
+Rule   Halifax 1931    1932    -       Sep     Mon>=24 0:00    0       S
+Rule   Halifax 1932    only    -       May      1      0:00    1:00    D
+Rule   Halifax 1933    only    -       Apr     30      0:00    1:00    D
+Rule   Halifax 1933    only    -       Oct      2      0:00    0       S
+Rule   Halifax 1934    only    -       May     20      0:00    1:00    D
+Rule   Halifax 1934    only    -       Sep     16      0:00    0       S
+Rule   Halifax 1935    only    -       Jun      2      0:00    1:00    D
+Rule   Halifax 1935    only    -       Sep     30      0:00    0       S
+Rule   Halifax 1936    only    -       Jun      1      0:00    1:00    D
+Rule   Halifax 1936    only    -       Sep     14      0:00    0       S
+Rule   Halifax 1937    1938    -       May     Sun>=1  0:00    1:00    D
+Rule   Halifax 1937    1941    -       Sep     Mon>=24 0:00    0       S
+Rule   Halifax 1939    only    -       May     28      0:00    1:00    D
+Rule   Halifax 1940    1941    -       May     Sun>=1  0:00    1:00    D
+Rule   Halifax 1946    1949    -       Apr     lastSun 2:00    1:00    D
+Rule   Halifax 1946    1949    -       Sep     lastSun 2:00    0       S
+Rule   Halifax 1951    1954    -       Apr     lastSun 2:00    1:00    D
+Rule   Halifax 1951    1954    -       Sep     lastSun 2:00    0       S
+Rule   Halifax 1956    1959    -       Apr     lastSun 2:00    1:00    D
+Rule   Halifax 1956    1959    -       Sep     lastSun 2:00    0       S
+Rule   Halifax 1962    1973    -       Apr     lastSun 2:00    1:00    D
+Rule   Halifax 1962    1973    -       Oct     lastSun 2:00    0       S
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone America/Halifax   -4:14:24 -      LMT     1902 Jun 15
+                       -4:00   Halifax A%sT    1918
+                       -4:00   Canada  A%sT    1919
+                       -4:00   Halifax A%sT    1942 Feb  9 2:00s
+                       -4:00   Canada  A%sT    1946
+                       -4:00   Halifax A%sT    1974
+                       -4:00   Canada  A%sT
+Zone America/Glace_Bay -3:59:48 -      LMT     1902 Jun 15
+                       -4:00   Canada  A%sT    1953
+                       -4:00   Halifax A%sT    1954
+                       -4:00   -       AST     1972
+                       -4:00   Halifax A%sT    1974
+                       -4:00   Canada  A%sT
+
+# New Brunswick
+
+# From Paul Eggert (2007-01-31):
+# The Time Definition Act <http://www.gnb.ca/0062/PDF-acts/t-06.pdf>
+# says they changed at 00:01 through 2006, and
+# <http://www.canlii.org/nb/laws/sta/t-6/20030127/whole.html> makes it
+# clear that this was the case since at least 1993.
+# For now, assume it started in 1993.
+
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Moncton 1933    1935    -       Jun     Sun>=8  1:00    1:00    D
+Rule   Moncton 1933    1935    -       Sep     Sun>=8  1:00    0       S
+Rule   Moncton 1936    1938    -       Jun     Sun>=1  1:00    1:00    D
+Rule   Moncton 1936    1938    -       Sep     Sun>=1  1:00    0       S
+Rule   Moncton 1939    only    -       May     27      1:00    1:00    D
+Rule   Moncton 1939    1941    -       Sep     Sat>=21 1:00    0       S
+Rule   Moncton 1940    only    -       May     19      1:00    1:00    D
+Rule   Moncton 1941    only    -       May      4      1:00    1:00    D
+Rule   Moncton 1946    1972    -       Apr     lastSun 2:00    1:00    D
+Rule   Moncton 1946    1956    -       Sep     lastSun 2:00    0       S
+Rule   Moncton 1957    1972    -       Oct     lastSun 2:00    0       S
+Rule   Moncton 1993    2006    -       Apr     Sun>=1  0:01    1:00    D
+Rule   Moncton 1993    2006    -       Oct     lastSun 0:01    0       S
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone America/Moncton   -4:19:08 -      LMT     1883 Dec  9
+                       -5:00   -       EST     1902 Jun 15
+                       -4:00   Canada  A%sT    1933
+                       -4:00   Moncton A%sT    1942
+                       -4:00   Canada  A%sT    1946
+                       -4:00   Moncton A%sT    1973
+                       -4:00   Canada  A%sT    1993
+                       -4:00   Moncton A%sT    2007
+                       -4:00   Canada  A%sT
+
+# Quebec
+
+# From Paul Eggert (2006-07-09):
+# Shanks & Pottenger write that since 1970 most of Quebec has been
+# like Montreal.
+
+# From Paul Eggert (2006-06-27):
+# Matthews and Vincent (1998) also write that Quebec east of the -63
+# meridian is supposed to observe AST, but residents as far east as
+# Natashquan use EST/EDT, and residents east of Natashquan use AST.
+# In "Official time in Quebec" the Quebec department of justice writes in
+# http://www.justice.gouv.qc.ca/english/publications/generale/temps-regl-1-a.htm
+# that "The residents of the Municipality of the
+# Cote-Nord-du-Golfe-Saint-Laurent and the municipalities of Saint-Augustin,
+# Bonne-Esperance and Blanc-Sablon apply the Official Time Act as it is
+# written and use Atlantic standard time all year round. The same applies to
+# the residents of the Native facilities along the lower North Shore."
+# <http://www.assnat.qc.ca/eng/37legislature2/Projets-loi/Publics/06-a002.htm>
+# says this common practice was codified into law as of 2007.
+# For lack of better info, guess this practice began around 1970, contra to
+# Shanks & Pottenger who have this region observing AST/ADT.
+
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Mont    1917    only    -       Mar     25      2:00    1:00    D
+Rule   Mont    1917    only    -       Apr     24      0:00    0       S
+Rule   Mont    1919    only    -       Mar     31      2:30    1:00    D
+Rule   Mont    1919    only    -       Oct     25      2:30    0       S
+Rule   Mont    1920    only    -       May      2      2:30    1:00    D
+Rule   Mont    1920    1922    -       Oct     Sun>=1  2:30    0       S
+Rule   Mont    1921    only    -       May      1      2:00    1:00    D
+Rule   Mont    1922    only    -       Apr     30      2:00    1:00    D
+Rule   Mont    1924    only    -       May     17      2:00    1:00    D
+Rule   Mont    1924    1926    -       Sep     lastSun 2:30    0       S
+Rule   Mont    1925    1926    -       May     Sun>=1  2:00    1:00    D
+# The 1927-to-1937 rules can be expressed more simply as
+# Rule Mont    1927    1937    -       Apr     lastSat 24:00   1:00    D
+# Rule Mont    1927    1937    -       Sep     lastSat 24:00   0       S
+# The rules below avoid use of 24:00
+# (which pre-1998 versions of zic cannot handle).
+Rule   Mont    1927    only    -       May     1       0:00    1:00    D
+Rule   Mont    1927    1932    -       Sep     lastSun 0:00    0       S
+Rule   Mont    1928    1931    -       Apr     lastSun 0:00    1:00    D
+Rule   Mont    1932    only    -       May     1       0:00    1:00    D
+Rule   Mont    1933    1940    -       Apr     lastSun 0:00    1:00    D
+Rule   Mont    1933    only    -       Oct     1       0:00    0       S
+Rule   Mont    1934    1939    -       Sep     lastSun 0:00    0       S
+Rule   Mont    1946    1973    -       Apr     lastSun 2:00    1:00    D
+Rule   Mont    1945    1948    -       Sep     lastSun 2:00    0       S
+Rule   Mont    1949    1950    -       Oct     lastSun 2:00    0       S
+Rule   Mont    1951    1956    -       Sep     lastSun 2:00    0       S
+Rule   Mont    1957    1973    -       Oct     lastSun 2:00    0       S
+
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone America/Blanc-Sablon -3:48:28 -   LMT     1884
+                       -4:00   Canada  A%sT    1970
+                       -4:00   -       AST
+Zone America/Montreal  -4:54:16 -      LMT     1884
+                       -5:00   Mont    E%sT    1918
+                       -5:00   Canada  E%sT    1919
+                       -5:00   Mont    E%sT    1942 Feb  9 2:00s
+                       -5:00   Canada  E%sT    1946
+                       -5:00   Mont    E%sT    1974
+                       -5:00   Canada  E%sT
+
+
+# Ontario
+
+# From Paul Eggert (2006-07-09):
+# Shanks & Pottenger write that since 1970 most of Ontario has been like
+# Toronto.
+# Thunder Bay skipped DST in 1973.
+# Many smaller locales did not observe peacetime DST until 1974;
+# Nipigon (EST) and Rainy River (CST) are the largest that we know of.
+# Far west Ontario is like Winnipeg; far east Quebec is like Halifax.
+
+# From Mark Brader (2003-07-26):
+# [According to the Toronto Star] Orillia, Ontario, adopted DST
+# effective Saturday, 1912-06-22, 22:00; the article mentions that
+# Port Arthur (now part of Thunder Bay, Ontario) as well as Moose Jaw
+# have already done so.  In Orillia DST was to run until Saturday,
+# 1912-08-31 (no time mentioned), but it was met with considerable
+# hostility from certain segments of the public, and was revoked after
+# only two weeks -- I copied it as Saturday, 1912-07-07, 22:00, but
+# presumably that should be -07-06.  (1912-06-19, -07-12; also letters
+# earlier in June).
+#
+# Kenora, Ontario, was to abandon DST on 1914-06-01 (-05-21).
+
+# From Paul Eggert (1997-10-17):
+# Mark Brader writes that an article in the 1997-10-14 Toronto Star
+# says that Atikokan, Ontario currently does not observe DST,
+# but will vote on 11-10 whether to use EST/EDT.
+# He also writes that the
+# <a href="http://www.gov.on.ca/MBS/english/publications/statregs/conttext.html">
+# Ontario Time Act (1990, Chapter T.9)
+# </a>
+# says that Ontario east of 90W uses EST/EDT, and west of 90W uses CST/CDT.
+# Officially Atikokan is therefore on CST/CDT, and most likely this report
+# concerns a non-official time observed as a matter of local practice.
+#
+# From Paul Eggert (2000-10-02):
+# Matthews and Vincent (1998) write that Atikokan, Pickle Lake, and
+# New Osnaburgh observe CST all year, that Big Trout Lake observes
+# CST/CDT, and that Upsala and Shebandowan observe EST/EDT, all in
+# violation of the official Ontario rules.
+#
+# From Paul Eggert (2006-07-09):
+# Chris Walton (2006-07-06) mentioned an article by Stephanie MacLellan in the
+# 2005-07-21 Chronicle-Journal, which said:
+#
+#      The clocks in Atikokan stay set on standard time year-round.
+#      This means they spend about half the time on central time and
+#      the other half on eastern time.
+#
+#      For the most part, the system works, Mayor Dennis Brown said.
+#
+#      "The majority of businesses in Atikokan deal more with Eastern
+#      Canada, but there are some that deal with Western Canada," he
+#      said.  "I don't see any changes happening here."
+#
+# Walton also writes "Supposedly Pickle Lake and Mishkeegogamang
+# [New Osnaburgh] follow the same practice."
+
+# From Garry McKinnon (2006-07-14) via Chris Walton:
+# I chatted with a member of my board who has an outstanding memory
+# and a long history in Atikokan (and in the telecom industry) and he
+# can say for certain that Atikokan has been practicing the current
+# time keeping since 1952, at least.
+
+# From Paul Eggert (2006-07-17):
+# Shanks & Pottenger say that Atikokan has agreed with Rainy River
+# ever since standard time was introduced, but the information from
+# McKinnon sounds more authoritative.  For now, assume that Atikokan
+# switched to EST immediately after WWII era daylight saving time
+# ended.  This matches the old (less-populous) America/Coral_Harbour
+# entry since our cutoff date of 1970, so we can move
+# America/Coral_Harbour to the 'backward' file.
+
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Toronto 1919    only    -       Mar     30      23:30   1:00    D
+Rule   Toronto 1919    only    -       Oct     26      0:00    0       S
+Rule   Toronto 1920    only    -       May      2      2:00    1:00    D
+Rule   Toronto 1920    only    -       Sep     26      0:00    0       S
+Rule   Toronto 1921    only    -       May     15      2:00    1:00    D
+Rule   Toronto 1921    only    -       Sep     15      2:00    0       S
+Rule   Toronto 1922    1923    -       May     Sun>=8  2:00    1:00    D
+# Shanks & Pottenger say 1923-09-19; assume it's a typo and that "-16"
+# was meant.
+Rule   Toronto 1922    1926    -       Sep     Sun>=15 2:00    0       S
+Rule   Toronto 1924    1927    -       May     Sun>=1  2:00    1:00    D
+# The 1927-to-1939 rules can be expressed more simply as
+# Rule Toronto 1927    1937    -       Sep     Sun>=25 2:00    0       S
+# Rule Toronto 1928    1937    -       Apr     Sun>=25 2:00    1:00    D
+# Rule Toronto 1938    1940    -       Apr     lastSun 2:00    1:00    D
+# Rule Toronto 1938    1939    -       Sep     lastSun 2:00    0       S
+# The rules below avoid use of Sun>=25
+# (which pre-2004 versions of zic cannot handle).
+Rule   Toronto 1927    1932    -       Sep     lastSun 2:00    0       S
+Rule   Toronto 1928    1931    -       Apr     lastSun 2:00    1:00    D
+Rule   Toronto 1932    only    -       May     1       2:00    1:00    D
+Rule   Toronto 1933    1940    -       Apr     lastSun 2:00    1:00    D
+Rule   Toronto 1933    only    -       Oct     1       2:00    0       S
+Rule   Toronto 1934    1939    -       Sep     lastSun 2:00    0       S
+Rule   Toronto 1945    1946    -       Sep     lastSun 2:00    0       S
+Rule   Toronto 1946    only    -       Apr     lastSun 2:00    1:00    D
+Rule   Toronto 1947    1949    -       Apr     lastSun 0:00    1:00    D
+Rule   Toronto 1947    1948    -       Sep     lastSun 0:00    0       S
+Rule   Toronto 1949    only    -       Nov     lastSun 0:00    0       S
+Rule   Toronto 1950    1973    -       Apr     lastSun 2:00    1:00    D
+Rule   Toronto 1950    only    -       Nov     lastSun 2:00    0       S
+Rule   Toronto 1951    1956    -       Sep     lastSun 2:00    0       S
+# Shanks & Pottenger say Toronto ended DST a week early in 1971,
+# namely on 1971-10-24, but Mark Brader wrote (2003-05-31) that this
+# is wrong, and that he had confirmed it by checking the 1971-10-30
+# Toronto Star, which said that DST was ending 1971-10-31 as usual.
+Rule   Toronto 1957    1973    -       Oct     lastSun 2:00    0       S
+
+# From Paul Eggert (2003-07-27):
+# Willett (1914-03) writes (p. 17) "In the Cities of Fort William, and
+# Port Arthur, Ontario, the principle of the Bill has been in
+# operation for the past three years, and in the City of Moose Jaw,
+# Saskatchewan, for one year."
+
+# From David Bryan via Tory Tronrud, Director/Curator,
+# Thunder Bay Museum (2003-11-12):
+# There is some suggestion, however, that, by-law or not, daylight
+# savings time was being practiced in Fort William and Port Arthur
+# before 1909.... [I]n 1910, the line between the Eastern and Central
+# Time Zones was permanently moved about two hundred miles west to
+# include the Thunder Bay area....  When Canada adopted daylight
+# savings time in 1916, Fort William and Port Arthur, having done so
+# already, did not change their clocks....  During the Second World
+# War,... [t]he cities agreed to implement DST during the summer
+# months for the remainder of the war years.
+
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone America/Toronto   -5:17:32 -      LMT     1895
+                       -5:00   Canada  E%sT    1919
+                       -5:00   Toronto E%sT    1942 Feb  9 2:00s
+                       -5:00   Canada  E%sT    1946
+                       -5:00   Toronto E%sT    1974
+                       -5:00   Canada  E%sT
+Zone America/Thunder_Bay -5:57:00 -    LMT     1895
+                       -6:00   -       CST     1910
+                       -5:00   -       EST     1942
+                       -5:00   Canada  E%sT    1970
+                       -5:00   Mont    E%sT    1973
+                       -5:00   -       EST     1974
+                       -5:00   Canada  E%sT
+Zone America/Nipigon   -5:53:04 -      LMT     1895
+                       -5:00   Canada  E%sT    1940 Sep 29
+                       -5:00   1:00    EDT     1942 Feb  9 2:00s
+                       -5:00   Canada  E%sT
+Zone America/Rainy_River -6:18:16 -    LMT     1895
+                       -6:00   Canada  C%sT    1940 Sep 29
+                       -6:00   1:00    CDT     1942 Feb  9 2:00s
+                       -6:00   Canada  C%sT
+Zone America/Atikokan  -6:06:28 -      LMT     1895
+                       -6:00   Canada  C%sT    1940 Sep 29
+                       -6:00   1:00    CDT     1942 Feb  9 2:00s
+                       -6:00   Canada  C%sT    1945 Sep 30 2:00
+                       -5:00   -       EST
+
+
+# Manitoba
+
+# From Rob Douglas (2006-04-06):
+# the old Manitoba Time Act - as amended by Bill 2, assented to
+# March 27, 1987 ... said ...
+# "between two o'clock Central Standard Time in the morning of
+# the first Sunday of April of each year and two o'clock Central
+# Standard Time in the morning of the last Sunday of October next
+# following, one hour in advance of Central Standard Time."...
+# I believe that the English legislation [of the old time act] had =
+# been assented to (March 22, 1967)....
+# Also, as far as I can tell, there was no order-in-council varying
+# the time of Daylight Saving Time for 2005 and so the provisions of
+# the 1987 version would apply - the changeover was at 2:00 Central
+# Standard Time (i.e. not until 3:00 Central Daylight Time).
+
+# From Paul Eggert (2006-04-10):
+# Shanks & Pottenger say Manitoba switched at 02:00 (not 02:00s)
+# starting 1966.  Since 02:00s is clearly correct for 1967 on, assume
+# it was also 02:00s in 1966.
+
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Winn    1916    only    -       Apr     23      0:00    1:00    D
+Rule   Winn    1916    only    -       Sep     17      0:00    0       S
+Rule   Winn    1918    only    -       Apr     14      2:00    1:00    D
+Rule   Winn    1918    only    -       Oct     31      2:00    0       S
+Rule   Winn    1937    only    -       May     16      2:00    1:00    D
+Rule   Winn    1937    only    -       Sep     26      2:00    0       S
+Rule   Winn    1942    only    -       Feb      9      2:00    1:00    W # War
+Rule   Winn    1945    only    -       Aug     14      23:00u  1:00    P # Peace
+Rule   Winn    1945    only    -       Sep     lastSun 2:00    0       S
+Rule   Winn    1946    only    -       May     12      2:00    1:00    D
+Rule   Winn    1946    only    -       Oct     13      2:00    0       S
+Rule   Winn    1947    1949    -       Apr     lastSun 2:00    1:00    D
+Rule   Winn    1947    1949    -       Sep     lastSun 2:00    0       S
+Rule   Winn    1950    only    -       May      1      2:00    1:00    D
+Rule   Winn    1950    only    -       Sep     30      2:00    0       S
+Rule   Winn    1951    1960    -       Apr     lastSun 2:00    1:00    D
+Rule   Winn    1951    1958    -       Sep     lastSun 2:00    0       S
+Rule   Winn    1959    only    -       Oct     lastSun 2:00    0       S
+Rule   Winn    1960    only    -       Sep     lastSun 2:00    0       S
+Rule   Winn    1963    only    -       Apr     lastSun 2:00    1:00    D
+Rule   Winn    1963    only    -       Sep     22      2:00    0       S
+Rule   Winn    1966    1986    -       Apr     lastSun 2:00s   1:00    D
+Rule   Winn    1966    2005    -       Oct     lastSun 2:00s   0       S
+Rule   Winn    1987    2005    -       Apr     Sun>=1  2:00s   1:00    D
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone America/Winnipeg  -6:28:36 -      LMT     1887 Jul 16
+                       -6:00   Winn    C%sT    2006
+                       -6:00   Canada  C%sT
+
+
+# Saskatchewan
+
+# From Mark Brader (2003-07-26):
+# The first actual adoption of DST in Canada was at the municipal
+# level.  As the [Toronto] Star put it (1912-06-07), "While people
+# elsewhere have long been talking of legislation to save daylight,
+# the city of Moose Jaw [Saskatchewan] has acted on its own hook."
+# DST in Moose Jaw began on Saturday, 1912-06-01 (no time mentioned:
+# presumably late evening, as below), and would run until "the end of
+# the summer".  The discrepancy between municipal time and railroad
+# time was noted.
+
+# From Paul Eggert (2003-07-27):
+# Willett (1914-03) notes that DST "has been in operation ... in the
+# City of Moose Jaw, Saskatchewan, for one year."
+
+# From Paul Eggert (2006-03-22):
+# Shanks & Pottenger say that since 1970 this region has mostly been as Regina.
+# Some western towns (e.g. Swift Current) switched from MST/MDT to CST in 1972.
+# Other western towns (e.g. Lloydminster) are like Edmonton.
+# Matthews and Vincent (1998) write that Denare Beach and Creighton
+# are like Winnipeg, in violation of Saskatchewan law.
+
+# From W. Jones (1992-11-06):
+# The. . .below is based on information I got from our law library, the
+# provincial archives, and the provincial Community Services department.
+# A precise history would require digging through newspaper archives, and
+# since you didn't say what you wanted, I didn't bother.
+#
+# Saskatchewan is split by a time zone meridian (105W) and over the years
+# the boundary became pretty ragged as communities near it reevaluated
+# their affiliations in one direction or the other.  In 1965 a provincial
+# referendum favoured legislating common time practices.
+#
+# On 15 April 1966 the Time Act (c. T-14, Revised Statutes of
+# Saskatchewan 1978) was proclaimed, and established that the eastern
+# part of Saskatchewan would use CST year round, that districts in
+# northwest Saskatchewan would by default follow CST but could opt to
+# follow Mountain Time rules (thus 1 hour difference in the winter and
+# zero in the summer), and that districts in southwest Saskatchewan would
+# by default follow MT but could opt to follow CST.
+#
+# It took a few years for the dust to settle (I know one story of a town
+# on one time zone having its school in another, such that a mom had to
+# serve her family lunch in two shifts), but presently it seems that only
+# a few towns on the border with Alberta (e.g. Lloydminster) follow MT
+# rules any more; all other districts appear to have used CST year round
+# since sometime in the 1960s.
+
+# From Chris Walton (2006-06-26):
+# The Saskatchewan time act which was last updated in 1996 is about 30 pages
+# long and rather painful to read.
+# http://www.qp.gov.sk.ca/documents/English/Statutes/Statutes/T14.pdf
+
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Regina  1918    only    -       Apr     14      2:00    1:00    D
+Rule   Regina  1918    only    -       Oct     31      2:00    0       S
+Rule   Regina  1930    1934    -       May     Sun>=1  0:00    1:00    D
+Rule   Regina  1930    1934    -       Oct     Sun>=1  0:00    0       S
+Rule   Regina  1937    1941    -       Apr     Sun>=8  0:00    1:00    D
+Rule   Regina  1937    only    -       Oct     Sun>=8  0:00    0       S
+Rule   Regina  1938    only    -       Oct     Sun>=1  0:00    0       S
+Rule   Regina  1939    1941    -       Oct     Sun>=8  0:00    0       S
+Rule   Regina  1942    only    -       Feb      9      2:00    1:00    W # War
+Rule   Regina  1945    only    -       Aug     14      23:00u  1:00    P # Peace
+Rule   Regina  1945    only    -       Sep     lastSun 2:00    0       S
+Rule   Regina  1946    only    -       Apr     Sun>=8  2:00    1:00    D
+Rule   Regina  1946    only    -       Oct     Sun>=8  2:00    0       S
+Rule   Regina  1947    1957    -       Apr     lastSun 2:00    1:00    D
+Rule   Regina  1947    1957    -       Sep     lastSun 2:00    0       S
+Rule   Regina  1959    only    -       Apr     lastSun 2:00    1:00    D
+Rule   Regina  1959    only    -       Oct     lastSun 2:00    0       S
+#
+Rule   Swift   1957    only    -       Apr     lastSun 2:00    1:00    D
+Rule   Swift   1957    only    -       Oct     lastSun 2:00    0       S
+Rule   Swift   1959    1961    -       Apr     lastSun 2:00    1:00    D
+Rule   Swift   1959    only    -       Oct     lastSun 2:00    0       S
+Rule   Swift   1960    1961    -       Sep     lastSun 2:00    0       S
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone America/Regina    -6:58:36 -      LMT     1905 Sep
+                       -7:00   Regina  M%sT    1960 Apr lastSun 2:00
+                       -6:00   -       CST
+Zone America/Swift_Current -7:11:20 -  LMT     1905 Sep
+                       -7:00   Canada  M%sT    1946 Apr lastSun 2:00
+                       -7:00   Regina  M%sT    1950
+                       -7:00   Swift   M%sT    1972 Apr lastSun 2:00
+                       -6:00   -       CST
+
+
+# Alberta
+
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Edm     1918    1919    -       Apr     Sun>=8  2:00    1:00    D
+Rule   Edm     1918    only    -       Oct     31      2:00    0       S
+Rule   Edm     1919    only    -       May     27      2:00    0       S
+Rule   Edm     1920    1923    -       Apr     lastSun 2:00    1:00    D
+Rule   Edm     1920    only    -       Oct     lastSun 2:00    0       S
+Rule   Edm     1921    1923    -       Sep     lastSun 2:00    0       S
+Rule   Edm     1942    only    -       Feb      9      2:00    1:00    W # War
+Rule   Edm     1945    only    -       Aug     14      23:00u  1:00    P # Peace
+Rule   Edm     1945    only    -       Sep     lastSun 2:00    0       S
+Rule   Edm     1947    only    -       Apr     lastSun 2:00    1:00    D
+Rule   Edm     1947    only    -       Sep     lastSun 2:00    0       S
+Rule   Edm     1967    only    -       Apr     lastSun 2:00    1:00    D
+Rule   Edm     1967    only    -       Oct     lastSun 2:00    0       S
+Rule   Edm     1969    only    -       Apr     lastSun 2:00    1:00    D
+Rule   Edm     1969    only    -       Oct     lastSun 2:00    0       S
+Rule   Edm     1972    1986    -       Apr     lastSun 2:00    1:00    D
+Rule   Edm     1972    2006    -       Oct     lastSun 2:00    0       S
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone America/Edmonton  -7:33:52 -      LMT     1906 Sep
+                       -7:00   Edm     M%sT    1987
+                       -7:00   Canada  M%sT
+
+
+# British Columbia
+
+# From Paul Eggert (2006-03-22):
+# Shanks & Pottenger write that since 1970 most of this region has
+# been like Vancouver.
+# Dawson Creek uses MST.  Much of east BC is like Edmonton.
+# Matthews and Vincent (1998) write that Creston is like Dawson Creek.
+
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Vanc    1918    only    -       Apr     14      2:00    1:00    D
+Rule   Vanc    1918    only    -       Oct     31      2:00    0       S
+Rule   Vanc    1942    only    -       Feb      9      2:00    1:00    W # War
+Rule   Vanc    1945    only    -       Aug     14      23:00u  1:00    P # Peace
+Rule   Vanc    1945    only    -       Sep     30      2:00    0       S
+Rule   Vanc    1946    1986    -       Apr     lastSun 2:00    1:00    D
+Rule   Vanc    1946    only    -       Oct     13      2:00    0       S
+Rule   Vanc    1947    1961    -       Sep     lastSun 2:00    0       S
+Rule   Vanc    1962    2006    -       Oct     lastSun 2:00    0       S
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone America/Vancouver -8:12:28 -      LMT     1884
+                       -8:00   Vanc    P%sT    1987
+                       -8:00   Canada  P%sT
+Zone America/Dawson_Creek -8:00:56 -   LMT     1884
+                       -8:00   Canada  P%sT    1947
+                       -8:00   Vanc    P%sT    1972 Aug 30 2:00
+                       -7:00   -       MST
+
+
+# Northwest Territories, Nunavut, Yukon
+
+# From Paul Eggert (2006-03-22):
+# Dawson switched to PST in 1973.  Inuvik switched to MST in 1979.
+# Mathew Englander (1996-10-07) gives the following refs:
+#      * 1967. Paragraph 28(34)(g) of the Interpretation Act, S.C. 1967-68,
+#      c. 7 defines Yukon standard time as UTC-9.  This is still valid;
+#      see Interpretation Act, R.S.C. 1985, c. I-21, s. 35(1).
+#      * C.O. 1973/214 switched Yukon to PST on 1973-10-28 00:00.
+#      * O.I.C. 1980/02 established DST.
+#      * O.I.C. 1987/056 changed DST to Apr firstSun 2:00 to Oct lastSun 2:00.
+# Shanks & Pottenger say Yukon's 1973-10-28 switch was at 2:00; go
+# with Englander.
+# From Chris Walton (2006-06-26):
+# Here is a link to the old daylight saving portion of the interpretation
+# act which was last updated in 1987:
+# http://www.gov.yk.ca/legislation/regs/oic1987_056.pdf
+
+# From Rives McDow (1999-09-04):
+# Nunavut ... moved ... to incorporate the whole territory into one time zone.
+# <a href="http://www.nunatsiaq.com/nunavut/nvt90903_13.html">
+# Nunavut moves to single time zone Oct. 31
+# </a>
+#
+# From Antoine Leca (1999-09-06):
+# We then need to create a new timezone for the Kitikmeot region of Nunavut
+# to differentiate it from the Yellowknife region.
+
+# From Paul Eggert (1999-09-20):
+# <a href="http://www.nunavut.com/basicfacts/english/basicfacts_1territory.html">
+# Basic Facts: The New Territory
+# </a> (1999) reports that Pangnirtung operates on eastern time,
+# and that Coral Harbour does not observe DST.  We don't know when
+# Pangnirtung switched to eastern time; we'll guess 1995.
+
+# From Rives McDow (1999-11-08):
+# On October 31, when the rest of Nunavut went to Central time,
+# Pangnirtung wobbled.  Here is the result of their wobble:
+#
+# The following businesses and organizations in Pangnirtung use Central Time:
+#
+#      First Air, Power Corp, Nunavut Construction, Health Center, RCMP,
+#      Eastern Arctic National Parks, A & D Specialist
+#
+# The following businesses and organizations in Pangnirtung use Eastern Time:
+#
+#      Hamlet office, All other businesses, Both schools, Airport operator
+#
+# This has made for an interesting situation there, which warranted the news.
+# No one there that I spoke with seems concerned, or has plans to
+# change the local methods of keeping time, as it evidently does not
+# really interfere with any activities or make things difficult locally.
+# They plan to celebrate New Year's turn-over twice, one hour apart,
+# so it appears that the situation will last at least that long.
+# The Nunavut Intergovernmental Affairs hopes that they will "come to
+# their senses", but the locals evidently don't see any problem with
+# the current state of affairs.
+
+# From Michaela Rodrigue, writing in the
+# <a href="http://www.nunatsiaq.com/archives/nunavut991130/nvt91119_17.html">
+# Nunatsiaq News (1999-11-19)</a>:
+# Clyde River, Pangnirtung and Sanikiluaq now operate with two time zones,
+# central - or Nunavut time - for government offices, and eastern time
+# for municipal offices and schools....  Igloolik [was similar but then]
+# made the switch to central time on Saturday, Nov. 6.
+
+# From Paul Eggert (2000-10-02):
+# Matthews and Vincent (1998) say the following, but we lack histories
+# for these potential new Zones.
+#
+# The Canadian Forces station at Alert uses Eastern Time while the
+# handful of residents at the Eureka weather station [in the Central
+# zone] skip daylight savings.  Baffin Island, which is crossed by the
+# Central, Eastern and Atlantic Time zones only uses Eastern Time.
+# Gjoa Haven, Taloyoak and Pelly Bay all use Mountain instead of
+# Central Time and Southampton Island [in the Central zone] is not
+# required to use daylight savings.
+
+# From
+# <a href="http://www.nunatsiaq.com/archives/nunavut001130/nvt21110_02.html">
+# Nunavut now has two time zones
+# </a> (2000-11-10):
+# The Nunavut government would allow its employees in Kugluktuk and
+# Cambridge Bay to operate on central time year-round, putting them
+# one hour behind the rest of Nunavut for six months during the winter.
+# At the end of October the two communities had rebelled against
+# Nunavut's unified time zone, refusing to shift to eastern time with
+# the rest of the territory for the winter.  Cambridge Bay remained on
+# central time, while Kugluktuk, even farther west, reverted to
+# mountain time, which they had used before the advent of Nunavut's
+# unified time zone in 1999.
+#
+# From Rives McDow (2001-01-20), quoting the Nunavut government:
+# The preceding decision came into effect at midnight, Saturday Nov 4, 2000.
+
+# From Paul Eggert (2000-12-04):
+# Let's just keep track of the official times for now.
+
+# From Rives McDow (2001-03-07):
+# The premier of Nunavut has issued a ministerial statement advising
+# that effective 2001-04-01, the territory of Nunavut will revert
+# back to three time zones (mountain, central, and eastern).  Of the
+# cities in Nunavut, Coral Harbor is the only one that I know of that
+# has said it will not observe dst, staying on EST year round.  I'm
+# checking for more info, and will get back to you if I come up with
+# more.
+# [Also see <http://www.nunatsiaq.com/nunavut/nvt10309_06.html> (2001-03-09).]
+
+# From Gwillim Law (2005-05-21):
+# According to maps at
+# http://inms-ienm.nrc-cnrc.gc.ca/images/time_services/TZ01SWE.jpg
+# http://inms-ienm.nrc-cnrc.gc.ca/images/time_services/TZ01SSE.jpg
+# (both dated 2003), and
+# http://www.canadiangeographic.ca/Magazine/SO98/geomap.asp
+# (from a 1998 Canadian Geographic article), the de facto and de jure time
+# for Southampton Island (at the north end of Hudson Bay) is UTC-5 all year
+# round.  Using Google, it's easy to find other websites that confirm this.
+# I wasn't able to find how far back this time regimen goes, but since it
+# predates the creation of Nunavut, it probably goes back many years....
+# The Inuktitut name of Coral Harbour is Sallit, but it's rarely used.
+#
+# From Paul Eggert (2005-07-26):
+# For lack of better information, assume that Southampton Island observed
+# daylight saving only during wartime.
+
+# From Chris Walton (2007-03-01):
+# ... the community of Resolute (located on Cornwallis Island in
+# Nunavut) moved from Central Time to Eastern Time last November.
+# Basically the community did not change its clocks at the end of
+# daylight saving....
+# http://www.nnsl.com/frames/newspapers/2006-11/nov13_06none.html
+
+# From Chris Walton (2007-03-14):
+# Today I phoned the "hamlet office" to find out what Resolute was doing with
+# its clocks.
+#
+# The individual that answered the phone confirmed that the clocks did not
+# move at the end of daylight saving on October 29/2006.  He also told me that
+# the clocks did not move this past weekend (March 11/2007)....
+
+# From Chris Walton (2008-11-13):
+# ...the residents of Resolute believe that they are changing "time zones"
+# twice a year.  In winter months, local time is qualified with "Eastern
+# Time" which is really "Eastern Standard Time (UTC-5)".  In summer
+# months, local time is qualified with "Central Time" which is really
+# "Central Daylight Time (UTC-5)"...
+
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   NT_YK   1918    only    -       Apr     14      2:00    1:00    D
+Rule   NT_YK   1918    only    -       Oct     27      2:00    0       S
+Rule   NT_YK   1919    only    -       May     25      2:00    1:00    D
+Rule   NT_YK   1919    only    -       Nov      1      0:00    0       S
+Rule   NT_YK   1942    only    -       Feb      9      2:00    1:00    W # War
+Rule   NT_YK   1945    only    -       Aug     14      23:00u  1:00    P # Peace
+Rule   NT_YK   1945    only    -       Sep     30      2:00    0       S
+Rule   NT_YK   1965    only    -       Apr     lastSun 0:00    2:00    DD
+Rule   NT_YK   1965    only    -       Oct     lastSun 2:00    0       S
+Rule   NT_YK   1980    1986    -       Apr     lastSun 2:00    1:00    D
+Rule   NT_YK   1980    2006    -       Oct     lastSun 2:00    0       S
+Rule   NT_YK   1987    2006    -       Apr     Sun>=1  2:00    1:00    D
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+# aka Panniqtuuq
+Zone America/Pangnirtung 0     -       zzz     1921 # trading post est.
+                       -4:00   NT_YK   A%sT    1995 Apr Sun>=1 2:00
+                       -5:00   Canada  E%sT    1999 Oct 31 2:00
+                       -6:00   Canada  C%sT    2000 Oct 29 2:00
+                       -5:00   Canada  E%sT
+# formerly Frobisher Bay
+Zone America/Iqaluit   0       -       zzz     1942 Aug # Frobisher Bay est.
+                       -5:00   NT_YK   E%sT    1999 Oct 31 2:00
+                       -6:00   Canada  C%sT    2000 Oct 29 2:00
+                       -5:00   Canada  E%sT
+# aka Qausuittuq
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Resolute 2006   max     -       Nov     Sun>=1  2:00    0       ES
+Rule   Resolute 2007   max     -       Mar     Sun>=8  2:00    0       CD
+Zone America/Resolute  0       -       zzz     1947 Aug 31 # Resolute founded
+                       -6:00   NT_YK   C%sT    2000 Oct 29 2:00
+                       -5:00   -       EST     2001 Apr  1 3:00
+                       -6:00   Canada  C%sT    2006 Oct 29 2:00
+                       -5:00   Resolute        %sT
+# aka Kangiqiniq
+Zone America/Rankin_Inlet 0    -       zzz     1957 # Rankin Inlet founded
+                       -6:00   NT_YK   C%sT    2000 Oct 29 2:00
+                       -5:00   -       EST     2001 Apr  1 3:00
+                       -6:00   Canada  C%sT
+# aka Iqaluktuuttiaq
+Zone America/Cambridge_Bay 0   -       zzz     1920 # trading post est.?
+                       -7:00   NT_YK   M%sT    1999 Oct 31 2:00
+                       -6:00   Canada  C%sT    2000 Oct 29 2:00
+                       -5:00   -       EST     2000 Nov  5 0:00
+                       -6:00   -       CST     2001 Apr  1 3:00
+                       -7:00   Canada  M%sT
+Zone America/Yellowknife 0     -       zzz     1935 # Yellowknife founded?
+                       -7:00   NT_YK   M%sT    1980
+                       -7:00   Canada  M%sT
+Zone America/Inuvik    0       -       zzz     1953 # Inuvik founded
+                       -8:00   NT_YK   P%sT    1979 Apr lastSun 2:00
+                       -7:00   NT_YK   M%sT    1980
+                       -7:00   Canada  M%sT
+Zone America/Whitehorse        -9:00:12 -      LMT     1900 Aug 20
+                       -9:00   NT_YK   Y%sT    1966 Jul 1 2:00
+                       -8:00   NT_YK   P%sT    1980
+                       -8:00   Canada  P%sT
+Zone America/Dawson    -9:17:40 -      LMT     1900 Aug 20
+                       -9:00   NT_YK   Y%sT    1973 Oct 28 0:00
+                       -8:00   NT_YK   P%sT    1980
+                       -8:00   Canada  P%sT
+
+
+###############################################################################
+
+# Mexico
+
+# From Paul Eggert (2001-03-05):
+# The Investigation and Analysis Service of the
+# Mexican Library of Congress (MLoC) has published a
+# <a href="http://www.cddhcu.gob.mx/bibliot/publica/inveyana/polisoc/horver/">
+# history of Mexican local time (in Spanish)
+# </a>.
+#
+# Here are the discrepancies between Shanks & Pottenger (S&P) and the MLoC.
+# (In all cases we go with the MLoC.)
+# S&P report that Baja was at -8:00 in 1922/1923.
+# S&P say the 1930 transition in Baja was 1930-11-16.
+# S&P report no DST during summer 1931.
+# S&P report a transition at 1932-03-30 23:00, not 1932-04-01.
+
+# From Gwillim Law (2001-02-20):
+# There are some other discrepancies between the Decrees page and the
+# tz database.  I think they can best be explained by supposing that
+# the researchers who prepared the Decrees page failed to find some of
+# the relevant documents.
+
+# From Alan Perry (1996-02-15):
+# A guy from our Mexico subsidiary finally found the Presidential Decree
+# outlining the timezone changes in Mexico.
+#
+# ------------- Begin Forwarded Message -------------
+#
+# I finally got my hands on the Official Presidential Decree that sets up the
+# rules for the DST changes. The rules are:
+#
+# 1. The country is divided in 3 timezones:
+#    - Baja California Norte (the Mexico/BajaNorte TZ)
+#    - Baja California Sur, Nayarit, Sinaloa and Sonora (the Mexico/BajaSur TZ)
+#    - The rest of the country (the Mexico/General TZ)
+#
+# 2. From the first Sunday in April at 2:00 AM to the last Sunday in October
+#    at 2:00 AM, the times in each zone are as follows:
+#    BajaNorte: GMT+7
+#    BajaSur:   GMT+6
+#    General:   GMT+5
+#
+# 3. The rest of the year, the times are as follows:
+#    BajaNorte: GMT+8
+#    BajaSur:   GMT+7
+#    General:   GMT+6
+#
+# The Decree was published in Mexico's Official Newspaper on January 4th.
+#
+# -------------- End Forwarded Message --------------
+# From Paul Eggert (1996-06-12):
+# For an English translation of the decree, see
+# <a href="http://mexico-travel.com/extra/timezone_eng.html">
+# ``Diario Oficial: Time Zone Changeover'' (1996-01-04).
+# </a>
+
+# From Rives McDow (1998-10-08):
+# The State of Quintana Roo has reverted back to central STD and DST times
+# (i.e. UTC -0600 and -0500 as of 1998-08-02).
+
+# From Rives McDow (2000-01-10):
+# Effective April 4, 1999 at 2:00 AM local time, Sonora changed to the time
+# zone 5 hours from the International Date Line, and will not observe daylight
+# savings time so as to stay on the same time zone as the southern part of
+# Arizona year round.
+
+# From Jesper Norgaard, translating
+# <http://www.reforma.com/nacional/articulo/064327/> (2001-01-17):
+# In Oaxaca, the 55.000 teachers from the Section 22 of the National
+# Syndicate of Education Workers, refuse to apply daylight saving each
+# year, so that the more than 10,000 schools work at normal hour the
+# whole year.
+
+# From Gwillim Law (2001-01-19):
+# <http://www.reforma.com/negocios_y_dinero/articulo/064481/> ... says
+# (translated):...
+# January 17, 2000 - The Energy Secretary, Ernesto Martens, announced
+# that Summer Time will be reduced from seven to five months, starting
+# this year....
+# <http://www.publico.com.mx/scripts/texto3.asp?action=pagina&pag=21&pos=p&secc=naci&date=01/17/2001>
+# [translated], says "summer time will ... take effect on the first Sunday
+# in May, and end on the last Sunday of September.
+
+# From Arthur David Olson (2001-01-25):
+# The 2001-01-24 traditional Washington Post contained the page one
+# story "Timely Issue Divides Mexicans."...
+# http://www.washingtonpost.com/wp-dyn/articles/A37383-2001Jan23.html
+# ... Mexico City Mayor Lopez Obrador "...is threatening to keep
+# Mexico City and its 20 million residents on a different time than
+# the rest of the country..." In particular, Lopez Obrador would abolish
+# observation of Daylight Saving Time.
+
+# <a href="http://www.conae.gob.mx/ahorro/decretohorver2001.html#decre">
+# Official statute published by the Energy Department
+# </a> (2001-02-01) shows Baja and Chihauhua as still using US DST rules,
+# and Sonora with no DST.  This was reported by Jesper Norgaard (2001-02-03).
+
+# From Paul Eggert (2001-03-03):
+#
+# <a href="http://www.latimes.com/news/nation/20010303/t000018766.html">
+# James F. Smith writes in today's LA Times
+# </a>
+# * Sonora will continue to observe standard time.
+# * Last week Mexico City's mayor Andres Manuel Lopez Obrador decreed that
+#   the Federal District will not adopt DST.
+# * 4 of 16 district leaders announced they'll ignore the decree.
+# * The decree does not affect federal-controlled facilities including
+#   the airport, banks, hospitals, and schools.
+#
+# For now we'll assume that the Federal District will bow to federal rules.
+
+# From Jesper Norgaard (2001-04-01):
+# I found some references to the Mexican application of daylight
+# saving, which modifies what I had already sent you, stating earlier
+# that a number of northern Mexican states would go on daylight
+# saving. The modification reverts this to only cover Baja California
+# (Norte), while all other states (except Sonora, who has no daylight
+# saving all year) will follow the original decree of president
+# Vicente Fox, starting daylight saving May 6, 2001 and ending
+# September 30, 2001.
+# References: "Diario de Monterrey" <www.diariodemonterrey.com/index.asp>
+# Palabra <http://palabra.infosel.com/010331/primera/ppri3101.pdf> (2001-03-31)
+
+# From Reuters (2001-09-04):
+# Mexico's Supreme Court on Tuesday declared that daylight savings was
+# unconstitutional in Mexico City, creating the possibility the
+# capital will be in a different time zone from the rest of the nation
+# next year....  The Supreme Court's ruling takes effect at 2:00
+# a.m. (0800 GMT) on Sept. 30, when Mexico is scheduled to revert to
+# standard time. "This is so residents of the Federal District are not
+# subject to unexpected time changes," a statement from the court said.
+
+# From Jesper Norgaard Welen (2002-03-12):
+# ... consulting my local grocery store(!) and my coworkers, they all insisted
+# that a new decision had been made to reinstate US style DST in Mexico....
+# http://www.conae.gob.mx/ahorro/horaver2001_m1_2002.html (2002-02-20)
+# confirms this.  Sonora as usual is the only state where DST is not applied.
+
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Mexico  1939    only    -       Feb     5       0:00    1:00    D
+Rule   Mexico  1939    only    -       Jun     25      0:00    0       S
+Rule   Mexico  1940    only    -       Dec     9       0:00    1:00    D
+Rule   Mexico  1941    only    -       Apr     1       0:00    0       S
+Rule   Mexico  1943    only    -       Dec     16      0:00    1:00    W # War
+Rule   Mexico  1944    only    -       May     1       0:00    0       S
+Rule   Mexico  1950    only    -       Feb     12      0:00    1:00    D
+Rule   Mexico  1950    only    -       Jul     30      0:00    0       S
+Rule   Mexico  1996    2000    -       Apr     Sun>=1  2:00    1:00    D
+Rule   Mexico  1996    2000    -       Oct     lastSun 2:00    0       S
+Rule   Mexico  2001    only    -       May     Sun>=1  2:00    1:00    D
+Rule   Mexico  2001    only    -       Sep     lastSun 2:00    0       S
+Rule   Mexico  2002    max     -       Apr     Sun>=1  2:00    1:00    D
+Rule   Mexico  2002    max     -       Oct     lastSun 2:00    0       S
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+# Quintana Roo
+Zone America/Cancun    -5:47:04 -      LMT     1922 Jan  1  0:12:56
+                       -6:00   -       CST     1981 Dec 23
+                       -5:00   Mexico  E%sT    1998 Aug  2  2:00
+                       -6:00   Mexico  C%sT
+# Campeche, Yucatan
+Zone America/Merida    -5:58:28 -      LMT     1922 Jan  1  0:01:32
+                       -6:00   -       CST     1981 Dec 23
+                       -5:00   -       EST     1982 Dec  2
+                       -6:00   Mexico  C%sT
+# Coahuila, Durango, Nuevo Leon, Tamaulipas
+Zone America/Monterrey -6:41:16 -      LMT     1921 Dec 31 23:18:44
+                       -6:00   -       CST     1988
+                       -6:00   US      C%sT    1989
+                       -6:00   Mexico  C%sT
+# Central Mexico
+Zone America/Mexico_City -6:36:36 -    LMT     1922 Jan  1  0:23:24
+                       -7:00   -       MST     1927 Jun 10 23:00
+                       -6:00   -       CST     1930 Nov 15
+                       -7:00   -       MST     1931 May  1 23:00
+                       -6:00   -       CST     1931 Oct
+                       -7:00   -       MST     1932 Apr  1
+                       -6:00   Mexico  C%sT    2001 Sep 30 02:00
+                       -6:00   -       CST     2002 Feb 20
+                       -6:00   Mexico  C%sT
+# Chihuahua
+Zone America/Chihuahua -7:04:20 -      LMT     1921 Dec 31 23:55:40
+                       -7:00   -       MST     1927 Jun 10 23:00
+                       -6:00   -       CST     1930 Nov 15
+                       -7:00   -       MST     1931 May  1 23:00
+                       -6:00   -       CST     1931 Oct
+                       -7:00   -       MST     1932 Apr  1
+                       -6:00   -       CST     1996
+                       -6:00   Mexico  C%sT    1998
+                       -6:00   -       CST     1998 Apr Sun>=1 3:00
+                       -7:00   Mexico  M%sT
+# Sonora
+Zone America/Hermosillo        -7:23:52 -      LMT     1921 Dec 31 23:36:08
+                       -7:00   -       MST     1927 Jun 10 23:00
+                       -6:00   -       CST     1930 Nov 15
+                       -7:00   -       MST     1931 May  1 23:00
+                       -6:00   -       CST     1931 Oct
+                       -7:00   -       MST     1932 Apr  1
+                       -6:00   -       CST     1942 Apr 24
+                       -7:00   -       MST     1949 Jan 14
+                       -8:00   -       PST     1970
+                       -7:00   Mexico  M%sT    1999
+                       -7:00   -       MST
+# Baja California Sur, Nayarit, Sinaloa
+Zone America/Mazatlan  -7:05:40 -      LMT     1921 Dec 31 23:54:20
+                       -7:00   -       MST     1927 Jun 10 23:00
+                       -6:00   -       CST     1930 Nov 15
+                       -7:00   -       MST     1931 May  1 23:00
+                       -6:00   -       CST     1931 Oct
+                       -7:00   -       MST     1932 Apr  1
+                       -6:00   -       CST     1942 Apr 24
+                       -7:00   -       MST     1949 Jan 14
+                       -8:00   -       PST     1970
+                       -7:00   Mexico  M%sT
+# Baja California
+Zone America/Tijuana   -7:48:04 -      LMT     1922 Jan  1  0:11:56
+                       -7:00   -       MST     1924
+                       -8:00   -       PST     1927 Jun 10 23:00
+                       -7:00   -       MST     1930 Nov 15
+                       -8:00   -       PST     1931 Apr  1
+                       -8:00   1:00    PDT     1931 Sep 30
+                       -8:00   -       PST     1942 Apr 24
+                       -8:00   1:00    PWT     1945 Aug 14 23:00u
+                       -8:00   1:00    PPT     1945 Nov 12 # Peace
+                       -8:00   -       PST     1948 Apr  5
+                       -8:00   1:00    PDT     1949 Jan 14
+                       -8:00   -       PST     1954
+                       -8:00   CA      P%sT    1961
+                       -8:00   -       PST     1976
+                       -8:00   US      P%sT    1996
+                       -8:00   Mexico  P%sT    2001
+                       -8:00   US      P%sT    2002 Feb 20
+                       -8:00   Mexico  P%sT
+# From Paul Eggert (2006-03-22):
+# Formerly there was an America/Ensenada zone, which differed from
+# America/Tijuana only in that it did not observe DST from 1976
+# through 1995.  This was as per Shanks (1999).  But Shanks & Pottenger say
+# Ensenada did not observe DST from 1948 through 1975.  Guy Harris reports
+# that the 1987 OAG says "Only Ensenada, Mexicale, San Felipe and
+# Tijuana observe DST," which agrees with Shanks & Pottenger but implies that
+# DST-observance was a town-by-town matter back then.  This concerns
+# data after 1970 so most likely there should be at least one Zone
+# other than America/Tijuana for Baja, but it's not clear yet what its
+# name or contents should be.
+#
+# Revillagigedo Is
+# no information
+
+###############################################################################
+
+# Anguilla
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone America/Anguilla  -4:12:16 -      LMT     1912 Mar 2
+                       -4:00   -       AST
+
+# Antigua and Barbuda
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   America/Antigua -4:07:12 -      LMT     1912 Mar 2
+                       -5:00   -       EST     1951
+                       -4:00   -       AST
+
+# Bahamas
+#
+# From Sue Williams (2006-12-07):
+# The Bahamas announced about a month ago that they plan to change their DST
+# rules to sync with the U.S. starting in 2007....
+# http://www.jonesbahamas.com/?c=45&a=10412
+
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Bahamas 1964    1975    -       Oct     lastSun 2:00    0       S
+Rule   Bahamas 1964    1975    -       Apr     lastSun 2:00    1:00    D
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   America/Nassau  -5:09:24 -      LMT     1912 Mar 2
+                       -5:00   Bahamas E%sT    1976
+                       -5:00   US      E%sT
+
+# Barbados
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Barb    1977    only    -       Jun     12      2:00    1:00    D
+Rule   Barb    1977    1978    -       Oct     Sun>=1  2:00    0       S
+Rule   Barb    1978    1980    -       Apr     Sun>=15 2:00    1:00    D
+Rule   Barb    1979    only    -       Sep     30      2:00    0       S
+Rule   Barb    1980    only    -       Sep     25      2:00    0       S
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone America/Barbados  -3:58:28 -      LMT     1924            # Bridgetown
+                       -3:58:28 -      BMT     1932      # Bridgetown Mean Time
+                       -4:00   Barb    A%sT
+
+# Belize
+# Whitman entirely disagrees with Shanks; go with Shanks & Pottenger.
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Belize  1918    1942    -       Oct     Sun>=2  0:00    0:30    HD
+Rule   Belize  1919    1943    -       Feb     Sun>=9  0:00    0       S
+Rule   Belize  1973    only    -       Dec      5      0:00    1:00    D
+Rule   Belize  1974    only    -       Feb      9      0:00    0       S
+Rule   Belize  1982    only    -       Dec     18      0:00    1:00    D
+Rule   Belize  1983    only    -       Feb     12      0:00    0       S
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   America/Belize  -5:52:48 -      LMT     1912 Apr
+                       -6:00   Belize  C%sT
+
+# Bermuda
+
+# From Dan Jones, reporting in The Royal Gazette (2006-06-26):
+
+# Next year, however, clocks in the US will go forward on the second Sunday
+# in March, until the first Sunday in November.  And, after the Time Zone
+# (Seasonal Variation) Bill 2006 was passed in the House of Assembly on
+# Friday, the same thing will happen in Bermuda.
+# http://www.theroyalgazette.com/apps/pbcs.dll/article?AID=/20060529/NEWS/105290135
+
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone Atlantic/Bermuda  -4:19:04 -      LMT     1930 Jan  1 2:00    # Hamilton
+                       -4:00   -       AST     1974 Apr 28 2:00
+                       -4:00   Bahamas A%sT    1976
+                       -4:00   US      A%sT
+
+# Cayman Is
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   America/Cayman  -5:25:32 -      LMT     1890            # Georgetown
+                       -5:07:12 -      KMT     1912 Feb    # Kingston Mean Time
+                       -5:00   -       EST
+
+# Costa Rica
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   CR      1979    1980    -       Feb     lastSun 0:00    1:00    D
+Rule   CR      1979    1980    -       Jun     Sun>=1  0:00    0       S
+Rule   CR      1991    1992    -       Jan     Sat>=15 0:00    1:00    D
+# IATA SSIM (1991-09) says the following was at 1:00;
+# go with Shanks & Pottenger.
+Rule   CR      1991    only    -       Jul      1      0:00    0       S
+Rule   CR      1992    only    -       Mar     15      0:00    0       S
+# There are too many San Joses elsewhere, so we'll use `Costa Rica'.
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone America/Costa_Rica        -5:36:20 -      LMT     1890            # San Jose
+                       -5:36:20 -      SJMT    1921 Jan 15 # San Jose Mean Time
+                       -6:00   CR      C%sT
+# Coco
+# no information; probably like America/Costa_Rica
+
+# Cuba
+
+# From Arthur David Olson (1999-03-29):
+# The 1999-03-28 exhibition baseball game held in Havana, Cuba, between
+# the Cuban National Team and the Baltimore Orioles was carried live on
+# the Orioles Radio Network, including affiliate WTOP in Washington, DC.
+# During the game, play-by-play announcer Jim Hunter noted that
+# "We'll be losing two hours of sleep...Cuba switched to Daylight Saving
+# Time today."  (The "two hour" remark referred to losing one hour of
+# sleep on 1999-03-28--when the announcers were in Cuba as it switched
+# to DST--and one more hour on 1999-04-04--when the announcers will have
+# returned to Baltimore, which switches on that date.)
+
+# From Evert van der Veer via Steffen Thorsen (2004-10-28):
+# Cuba is not going back to standard time this year.
+# From Paul Eggert (2006-03-22):
+# http://www.granma.cu/ingles/2004/septiembre/juev30/41medid-i.html
+# says that it's due to a problem at the Antonio Guiteras
+# thermoelectric plant, and says "This October there will be no return
+# to normal hours (after daylight saving time)".
+# For now, let's assume that it's a temporary measure.
+
+# From Carlos A. Carnero Delgado (2005-11-12):
+# This year (just like in 2004-2005) there's no change in time zone
+# adjustment in Cuba.  We will stay in daylight saving time:
+# http://www.granma.cu/espanol/2005/noviembre/mier9/horario.html
+
+# From Jesper Norgaard Welen (2006-10-21):
+# An article in GRANMA INTERNACIONAL claims that Cuba will end
+# the 3 years of permanent DST next weekend, see
+# http://www.granma.cu/ingles/2006/octubre/lun16/43horario.html
+# "On Saturday night, October 28 going into Sunday, October 29, at 01:00,
+# watches should be set back one hour -- going back to 00:00 hours -- returning
+# to the normal schedule....
+
+# From Paul Eggert (2007-03-02):
+# http://www.granma.cubaweb.cu/english/news/art89.html, dated yesterday,
+# says Cuban clocks will advance at midnight on March 10.
+# For lack of better information, assume Cuba will use US rules,
+# except that it switches at midnight standard time as usual.
+#
+# From Steffen Thorsen (2007-10-25):
+# Carlos Alberto Fonseca Arauz informed me that Cuba will end DST one week 
+# earlier - on the last Sunday of October, just like in 2006.
+# 
+# He supplied these references:
+# 
+# http://www.prensalatina.com.mx/article.asp?ID=%7B4CC32C1B-A9F7-42FB-8A07-8631AFC923AF%7D&language=ES
+# http://actualidad.terra.es/sociedad/articulo/cuba_llama_ahorrar_energia_cambio_1957044.htm
+# 
+# From Alex Kryvenishev (2007-10-25):
+# Here is also article from Granma (Cuba):
+# 
+# [Regira] el Horario Normal desde el [proximo] domingo 28 de octubre
+# http://www.granma.cubaweb.cu/2007/10/24/nacional/artic07.html
+# 
+# http://www.worldtimezone.com/dst_news/dst_news_cuba03.html
+
+# From Arthur David Olson (2008-03-09):
+# I'm in Maryland which is now observing United States Eastern Daylight
+# Time. At 9:44 local time I used RealPlayer to listen to
+# <a href="http://media.enet.cu/radioreloj">
+# http://media.enet.cu/radioreloj
+# </a>, a Cuban information station, and heard
+# the time announced as "ocho cuarenta y cuatro" ("eight forty-four"),
+# indicating that Cuba is still on standard time.
+
+# From Steffen Thorsen (2008-03-12):
+# It seems that Cuba will start DST on Sunday, 2007-03-16...
+# It was announced yesterday, according to this source (in Spanish):
+# <a href="http://www.nnc.cubaweb.cu/marzo-2008/cien-1-11-3-08.htm">
+# http://www.nnc.cubaweb.cu/marzo-2008/cien-1-11-3-08.htm
+# </a>
+#
+# Some more background information is posted here:
+# <a href="http://www.timeanddate.com/news/time/cuba-starts-dst-march-16.html">
+# http://www.timeanddate.com/news/time/cuba-starts-dst-march-16.html
+# </a>
+#
+# The article also says that Cuba has been observing DST since 1963,
+# while Shanks (and tzdata) has 1965 as the first date (except in the
+# 1940's). Many other web pages in Cuba also claim that it has been
+# observed since 1963, but with the exception of 1970 - an exception
+# which is not present in tzdata/Shanks. So there is a chance we need to
+# change some historic records as well.
+#
+# One example:
+# <a href="http://www.radiohc.cu/espanol/noticias/mar07/11mar/hor.htm">
+# http://www.radiohc.cu/espanol/noticias/mar07/11mar/hor.htm
+# </a>
+
+# From Jesper Norgaard Welen (2008-03-13):
+# The Cuban time change has just been confirmed on the most authoritative
+# web site, the Granma.  Please check out
+# <a href="http://www.granma.cubaweb.cu/2008/03/13/nacional/artic10.html">
+# http://www.granma.cubaweb.cu/2008/03/13/nacional/artic10.html
+# </a>
+#
+# Basically as expected after Steffen Thorsens information, the change
+# will take place midnight between Saturday and Sunday.
+
+# From Arthur David Olson (2008-03-12):
+# Assume Sun>=15 (third Sunday) going forward.
+
+# From Alexander Krivenyshev (2009-03-04)
+# According to the Radio Reloj - Cuba will start Daylight Saving Time on
+# midnight between Saturday, March 07, 2009 and Sunday, March 08, 2009-
+# not on midnight March 14 / March 15 as previously thought.
+#
+# <a href="http://www.worldtimezone.com/dst_news/dst_news_cuba05.html">
+# http://www.worldtimezone.com/dst_news/dst_news_cuba05.html
+# (in Spanish)
+# </a>
+
+# From Arthur David Olson (2009-03-09)
+# I listened over the Internet to
+# <a href="http://media.enet.cu/readioreloj">
+# http://media.enet.cu/readioreloj
+# </a>
+# this morning; when it was 10:05 a. m. here in Bethesda, Maryland the
+# the time was announced as "diez cinco"--the same time as here, indicating
+# that has indeed switched to DST. Assume second Sunday from 2009 forward.
+
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Cuba    1928    only    -       Jun     10      0:00    1:00    D
+Rule   Cuba    1928    only    -       Oct     10      0:00    0       S
+Rule   Cuba    1940    1942    -       Jun     Sun>=1  0:00    1:00    D
+Rule   Cuba    1940    1942    -       Sep     Sun>=1  0:00    0       S
+Rule   Cuba    1945    1946    -       Jun     Sun>=1  0:00    1:00    D
+Rule   Cuba    1945    1946    -       Sep     Sun>=1  0:00    0       S
+Rule   Cuba    1965    only    -       Jun     1       0:00    1:00    D
+Rule   Cuba    1965    only    -       Sep     30      0:00    0       S
+Rule   Cuba    1966    only    -       May     29      0:00    1:00    D
+Rule   Cuba    1966    only    -       Oct     2       0:00    0       S
+Rule   Cuba    1967    only    -       Apr     8       0:00    1:00    D
+Rule   Cuba    1967    1968    -       Sep     Sun>=8  0:00    0       S
+Rule   Cuba    1968    only    -       Apr     14      0:00    1:00    D
+Rule   Cuba    1969    1977    -       Apr     lastSun 0:00    1:00    D
+Rule   Cuba    1969    1971    -       Oct     lastSun 0:00    0       S
+Rule   Cuba    1972    1974    -       Oct     8       0:00    0       S
+Rule   Cuba    1975    1977    -       Oct     lastSun 0:00    0       S
+Rule   Cuba    1978    only    -       May     7       0:00    1:00    D
+Rule   Cuba    1978    1990    -       Oct     Sun>=8  0:00    0       S
+Rule   Cuba    1979    1980    -       Mar     Sun>=15 0:00    1:00    D
+Rule   Cuba    1981    1985    -       May     Sun>=5  0:00    1:00    D
+Rule   Cuba    1986    1989    -       Mar     Sun>=14 0:00    1:00    D
+Rule   Cuba    1990    1997    -       Apr     Sun>=1  0:00    1:00    D
+Rule   Cuba    1991    1995    -       Oct     Sun>=8  0:00s   0       S
+Rule   Cuba    1996    only    -       Oct      6      0:00s   0       S
+Rule   Cuba    1997    only    -       Oct     12      0:00s   0       S
+Rule   Cuba    1998    1999    -       Mar     lastSun 0:00s   1:00    D
+Rule   Cuba    1998    2003    -       Oct     lastSun 0:00s   0       S
+Rule   Cuba    2000    2004    -       Apr     Sun>=1  0:00s   1:00    D
+Rule   Cuba    2006    max     -       Oct     lastSun 0:00s   0       S
+Rule   Cuba    2007    only    -       Mar     Sun>=8  0:00s   1:00    D
+Rule   Cuba    2008    only    -       Mar     Sun>=15 0:00s   1:00    D
+Rule   Cuba    2009    max     -       Mar     Sun>=8  0:00s   1:00    D
+
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   America/Havana  -5:29:28 -      LMT     1890
+                       -5:29:36 -      HMT     1925 Jul 19 12:00 # Havana MT
+                       -5:00   Cuba    C%sT
+
+# Dominica
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone America/Dominica  -4:05:36 -      LMT     1911 Jul 1 0:01         # Roseau
+                       -4:00   -       AST
+
+# Dominican Republic
+
+# From Steffen Thorsen (2000-10-30):
+# Enrique Morales reported to me that the Dominican Republic has changed the
+# time zone to Eastern Standard Time as of Sunday 29 at 2 am....
+# http://www.listin.com.do/antes/261000/republica/princi.html
+
+# From Paul Eggert (2000-12-04):
+# That URL (2000-10-26, in Spanish) says they planned to use US-style DST.
+
+# From Rives McDow (2000-12-01):
+# Dominican Republic changed its mind and presidential decree on Tuesday,
+# November 28, 2000, with a new decree.  On Sunday, December 3 at 1:00 AM the
+# Dominican Republic will be reverting to 8 hours from the International Date
+# Line, and will not be using DST in the foreseeable future.  The reason they
+# decided to use DST was to be in synch with Puerto Rico, who was also going
+# to implement DST.  When Puerto Rico didn't implement DST, the president
+# decided to revert.
+
+
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   DR      1966    only    -       Oct     30      0:00    1:00    D
+Rule   DR      1967    only    -       Feb     28      0:00    0       S
+Rule   DR      1969    1973    -       Oct     lastSun 0:00    0:30    HD
+Rule   DR      1970    only    -       Feb     21      0:00    0       S
+Rule   DR      1971    only    -       Jan     20      0:00    0       S
+Rule   DR      1972    1974    -       Jan     21      0:00    0       S
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone America/Santo_Domingo -4:39:36 -  LMT     1890
+                       -4:40   -       SDMT    1933 Apr  1 12:00 # S. Dom. MT
+                       -5:00   DR      E%sT    1974 Oct 27
+                       -4:00   -       AST     2000 Oct 29 02:00
+                       -5:00   US      E%sT    2000 Dec  3 01:00
+                       -4:00   -       AST
+
+# El Salvador
+
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Salv    1987    1988    -       May     Sun>=1  0:00    1:00    D
+Rule   Salv    1987    1988    -       Sep     lastSun 0:00    0       S
+# There are too many San Salvadors elsewhere, so use America/El_Salvador
+# instead of America/San_Salvador.
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone America/El_Salvador -5:56:48 -    LMT     1921            # San Salvador
+                       -6:00   Salv    C%sT
+
+# Grenada
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   America/Grenada -4:07:00 -      LMT     1911 Jul        # St George's
+                       -4:00   -       AST
+
+# Guadeloupe
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone America/Guadeloupe        -4:06:08 -      LMT     1911 Jun 8      # Pointe a Pitre
+                       -4:00   -       AST
+# St Barthelemy
+Link America/Guadeloupe        America/St_Barthelemy
+# St Martin (French part)
+Link America/Guadeloupe        America/Marigot
+
+# Guatemala
+#
+# From Gwillim Law (2006-04-22), after a heads-up from Oscar van Vlijmen:
+# Diario Co Latino, at
+# http://www.diariocolatino.com/internacionales/detalles.asp?NewsID=8079,
+# says in an article dated 2006-04-19 that the Guatemalan government had
+# decided on that date to advance official time by 60 minutes, to lessen the
+# impact of the elevated cost of oil....  Daylight saving time will last from
+# 2006-04-29 24:00 (Guatemalan standard time) to 2006-09-30 (time unspecified).
+# From Paul Eggert (2006-06-22):
+# The Ministry of Energy and Mines, press release CP-15/2006
+# (2006-04-19), says DST ends at 24:00.  See
+# <http://www.sieca.org.gt/Sitio_publico/Energeticos/Doc/Medidas/Cambio_Horario_Nac_190406.pdf>.
+
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Guat    1973    only    -       Nov     25      0:00    1:00    D
+Rule   Guat    1974    only    -       Feb     24      0:00    0       S
+Rule   Guat    1983    only    -       May     21      0:00    1:00    D
+Rule   Guat    1983    only    -       Sep     22      0:00    0       S
+Rule   Guat    1991    only    -       Mar     23      0:00    1:00    D
+Rule   Guat    1991    only    -       Sep      7      0:00    0       S
+Rule   Guat    2006    only    -       Apr     30      0:00    1:00    D
+Rule   Guat    2006    only    -       Oct      1      0:00    0       S
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone America/Guatemala -6:02:04 -      LMT     1918 Oct 5
+                       -6:00   Guat    C%sT
+
+# Haiti
+# From Gwillim Law (2005-04-15):
+# Risto O. Nykanen wrote me that Haiti is now on DST.
+# I searched for confirmation, and I found a
+# <a href="http://www.haitianconsulate.org/time.doc"> press release
+# on the Web page of the Haitian Consulate in Chicago (2005-03-31),
+# </a>.  Translated from French, it says:
+#
+#  "The Prime Minister's Communication Office notifies the public in general
+#   and the press in particular that, following a decision of the Interior
+#   Ministry and the Territorial Collectivities [I suppose that means the
+#   provinces], Haiti will move to Eastern Daylight Time in the night from next
+#   Saturday the 2nd to Sunday the 3rd.
+#
+#  "Consequently, the Prime Minister's Communication Office wishes to inform
+#   the population that the country's clocks will be set forward one hour
+#   starting at midnight.  This provision will hold until the last Saturday in
+#   October 2005.
+#
+#  "Port-au-Prince, March 31, 2005"
+#
+# From Steffen Thorsen (2006-04-04):
+# I have been informed by users that Haiti observes DST this year like
+# last year, so the current "only" rule for 2005 might be changed to a
+# "max" rule or to last until 2006. (Who knows if they will observe DST
+# next year or if they will extend their DST like US/Canada next year).
+#
+# I have found this article about it (in French):
+# http://www.haitipressnetwork.com/news.cfm?articleID=7612
+#
+# The reason seems to be an energy crisis.
+
+# From Stephen Colebourne (2007-02-22):
+# Some IATA info: Haiti won't be having DST in 2007.
+
+
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Haiti   1983    only    -       May     8       0:00    1:00    D
+Rule   Haiti   1984    1987    -       Apr     lastSun 0:00    1:00    D
+Rule   Haiti   1983    1987    -       Oct     lastSun 0:00    0       S
+# Shanks & Pottenger say AT is 2:00, but IATA SSIM (1991/1997) says 1:00s.
+# Go with IATA.
+Rule   Haiti   1988    1997    -       Apr     Sun>=1  1:00s   1:00    D
+Rule   Haiti   1988    1997    -       Oct     lastSun 1:00s   0       S
+Rule   Haiti   2005    2006    -       Apr     Sun>=1  0:00    1:00    D
+Rule   Haiti   2005    2006    -       Oct     lastSun 0:00    0       S
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone America/Port-au-Prince -4:49:20 - LMT     1890
+                       -4:49   -       PPMT    1917 Jan 24 12:00 # P-a-P MT
+                       -5:00   Haiti   E%sT
+
+# Honduras
+# Shanks & Pottenger say 1921 Jan 1; go with Whitman's more precise Apr 1.
+
+# From Paul Eggert (2006-05-05):
+# worldtimezone.com reports a 2006-05-02 Spanish-language AP article
+# saying Honduras will start using DST midnight Saturday, effective 4
+# months until September.  La Tribuna reported today
+# <http://www.latribuna.hn/99299.html> that Manuel Zelaya, the president
+# of Honduras, refused to back down on this.
+
+# From Jesper Norgaard Welen (2006-08-08):
+# It seems that Honduras has returned from DST to standard time this Monday at
+# 00:00 hours (prolonging Sunday to 25 hours duration).
+# http://www.worldtimezone.com/dst_news/dst_news_honduras04.html
+
+# From Paul Eggert (2006-08-08):
+# Also see Diario El Heraldo, The country returns to standard time (2006-08-08)
+# <http://www.elheraldo.hn/nota.php?nid=54941&sec=12>.
+# It mentions executive decree 18-2006.
+
+# From Steffen Thorsen (2006-08-17):
+# Honduras will observe DST from 2007 to 2009, exact dates are not
+# published, I have located this authoritative source:
+# http://www.presidencia.gob.hn/noticia.aspx?nId=47
+
+# From Steffen Thorsen (2007-03-30):
+# http://www.laprensahn.com/pais_nota.php?id04962=7386
+# So it seems that Honduras will not enter DST this year....
+
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Hond    1987    1988    -       May     Sun>=1  0:00    1:00    D
+Rule   Hond    1987    1988    -       Sep     lastSun 0:00    0       S
+Rule   Hond    2006    only    -       May     Sun>=1  0:00    1:00    D
+Rule   Hond    2006    only    -       Aug     Mon>=1  0:00    0       S
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone America/Tegucigalpa -5:48:52 -    LMT     1921 Apr
+                       -6:00   Hond    C%sT
+#
+# Great Swan I ceded by US to Honduras in 1972
+
+# Jamaica
+
+# From Bob Devine (1988-01-28):
+# Follows US rules.
+
+# From U. S. Naval Observatory (1989-01-19):
+# JAMAICA             5 H  BEHIND UTC
+
+# From Shanks & Pottenger:
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   America/Jamaica -5:07:12 -      LMT     1890            # Kingston
+                       -5:07:12 -      KMT     1912 Feb    # Kingston Mean Time
+                       -5:00   -       EST     1974 Apr 28 2:00
+                       -5:00   US      E%sT    1984
+                       -5:00   -       EST
+
+# Martinique
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone America/Martinique        -4:04:20 -      LMT     1890            # Fort-de-France
+                       -4:04:20 -      FFMT    1911 May     # Fort-de-France MT
+                       -4:00   -       AST     1980 Apr  6
+                       -4:00   1:00    ADT     1980 Sep 28
+                       -4:00   -       AST
+
+# Montserrat
+# From Paul Eggert (2006-03-22):
+# In 1995 volcanic eruptions forced evacuation of Plymouth, the capital.
+# world.gazetteer.com says Cork Hill is the most populous location now.
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone America/Montserrat        -4:08:52 -      LMT     1911 Jul 1 0:01   # Cork Hill
+                       -4:00   -       AST
+
+# Nicaragua
+#
+# This uses Shanks & Pottenger for times before 2005.
+#
+# From Steffen Thorsen (2005-04-12):
+# I've got reports from 8 different people that Nicaragua just started
+# DST on Sunday 2005-04-10, in order to save energy because of
+# expensive petroleum.  The exact end date for DST is not yet
+# announced, only "September" but some sites also say "mid-September".
+# Some background information is available on the President's official site:
+# http://www.presidencia.gob.ni/Presidencia/Files_index/Secretaria/Notas%20de%20Prensa/Presidente/2005/ABRIL/Gobierno-de-nicaragua-adelanta-hora-oficial-06abril.htm
+# The Decree, no 23-2005 is available here:
+# http://www.presidencia.gob.ni/buscador_gaceta/BD/DECRETOS/2005/Decreto%2023-2005%20Se%20adelanta%20en%20una%20hora%20en%20todo%20el%20territorio%20nacional%20apartir%20de%20las%2024horas%20del%2009%20de%20Abril.pdf
+#
+# From Paul Eggert (2005-05-01):
+# The decree doesn't say anything about daylight saving, but for now let's
+# assume that it is daylight saving....
+#
+# From Gwillim Law (2005-04-21):
+# The Associated Press story on the time change, which can be found at
+# http://www.lapalmainteractivo.com/guias/content/gen/ap/America_Latina/AMC_GEN_NICARAGUA_HORA.html
+# and elsewhere, says (fifth paragraph, translated from Spanish):  "The last
+# time that a change of clocks was applied to save energy was in the year 2000
+# during the Arnoldo Aleman administration."...
+# The northamerica file says that Nicaragua has been on UTC-6 continuously
+# since December 1998.  I wasn't able to find any details of Nicaraguan time
+# changes in 2000.  Perhaps a note could be added to the northamerica file, to
+# the effect that we have indirect evidence that DST was observed in 2000.
+#
+# From Jesper Norgaard Welen (2005-11-02):
+# Nicaragua left DST the 2005-10-02 at 00:00 (local time).
+# http://www.presidencia.gob.ni/presidencia/files_index/secretaria/comunicados/2005/septiembre/26septiembre-cambio-hora.htm
+# (2005-09-26)
+#
+# From Jesper Norgaard Welen (2006-05-05):
+# http://www.elnuevodiario.com.ni/2006/05/01/nacionales/18410
+# (my informal translation)
+# By order of the president of the republic, Enrique Bolanos, Nicaragua
+# advanced by sixty minutes their official time, yesterday at 2 in the
+# morning, and will stay that way until 30.th. of september.
+#
+# From Jesper Norgaard Welen (2006-09-30):
+# http://www.presidencia.gob.ni/buscador_gaceta/BD/DECRETOS/2006/D-063-2006P-PRN-Cambio-Hora.pdf
+# My informal translation runs:
+# The natural sun time is restored in all the national territory, in that the
+# time is returned one hour at 01:00 am of October 1 of 2006.
+#
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Nic     1979    1980    -       Mar     Sun>=16 0:00    1:00    D
+Rule   Nic     1979    1980    -       Jun     Mon>=23 0:00    0       S
+Rule   Nic     2005    only    -       Apr     10      0:00    1:00    D
+Rule   Nic     2005    only    -       Oct     Sun>=1  0:00    0       S
+Rule   Nic     2006    only    -       Apr     30      2:00    1:00    D
+Rule   Nic     2006    only    -       Oct     Sun>=1  1:00    0       S
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   America/Managua -5:45:08 -      LMT     1890
+                       -5:45:12 -      MMT     1934 Jun 23 # Managua Mean Time?
+                       -6:00   -       CST     1973 May
+                       -5:00   -       EST     1975 Feb 16
+                       -6:00   Nic     C%sT    1992 Jan  1 4:00
+                       -5:00   -       EST     1992 Sep 24
+                       -6:00   -       CST     1993
+                       -5:00   -       EST     1997
+                       -6:00   Nic     C%sT
+
+# Panama
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   America/Panama  -5:18:08 -      LMT     1890
+                       -5:19:36 -      CMT     1908 Apr 22   # Colon Mean Time
+                       -5:00   -       EST
+
+# Puerto Rico
+# There are too many San Juans elsewhere, so we'll use `Puerto_Rico'.
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone America/Puerto_Rico -4:24:25 -    LMT     1899 Mar 28 12:00    # San Juan
+                       -4:00   -       AST     1942 May  3
+                       -4:00   US      A%sT    1946
+                       -4:00   -       AST
+
+# St Kitts-Nevis
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone America/St_Kitts  -4:10:52 -      LMT     1912 Mar 2      # Basseterre
+                       -4:00   -       AST
+
+# St Lucia
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone America/St_Lucia  -4:04:00 -      LMT     1890            # Castries
+                       -4:04:00 -      CMT     1912        # Castries Mean Time
+                       -4:00   -       AST
+
+# St Pierre and Miquelon
+# There are too many St Pierres elsewhere, so we'll use `Miquelon'.
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone America/Miquelon  -3:44:40 -      LMT     1911 May 15     # St Pierre
+                       -4:00   -       AST     1980 May
+                       -3:00   -       PMST    1987 # Pierre & Miquelon Time
+                       -3:00   Canada  PM%sT
+
+# St Vincent and the Grenadines
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone America/St_Vincent        -4:04:56 -      LMT     1890            # Kingstown
+                       -4:04:56 -      KMT     1912       # Kingstown Mean Time
+                       -4:00   -       AST
+
+# Turks and Caicos
+#
+# From Chris Dunn in
+# <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=415007>
+# (2007-03-15): In the Turks & Caicos Islands (America/Grand_Turk) the
+# daylight saving dates for time changes have been adjusted to match
+# the recent U.S. change of dates.
+#
+# From Brian Inglis (2007-04-28):
+# http://www.turksandcaicos.tc/calendar/index.htm [2007-04-26]
+# there is an entry for Nov 4 "Daylight Savings Time Ends 2007" and three
+# rows before that there is an out of date entry for Oct:
+# "Eastern Standard Times Begins 2007
+# Clocks are set back one hour at 2:00 a.m. local Daylight Saving Time"
+# indicating that the normal ET rules are followed.
+#
+# From Paul Eggert (2006-05-01):
+# Shanks & Pottenger say they use US DST rules, but IATA SSIM (1991/1998)
+# says they switch at midnight.  Go with Shanks & Pottenger.
+#
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   TC      1979    1986    -       Apr     lastSun 2:00    1:00    D
+Rule   TC      1979    2006    -       Oct     lastSun 2:00    0       S
+Rule   TC      1987    2006    -       Apr     Sun>=1  2:00    1:00    D
+Rule   TC      2007    max     -       Mar     Sun>=8  2:00    1:00    D
+Rule   TC      2007    max     -       Nov     Sun>=1  2:00    0       S
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone America/Grand_Turk        -4:44:32 -      LMT     1890
+                       -5:07:12 -      KMT     1912 Feb    # Kingston Mean Time
+                       -5:00   TC      E%sT
+
+# British Virgin Is
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone America/Tortola   -4:18:28 -      LMT     1911 Jul    # Road Town
+                       -4:00   -       AST
+
+# Virgin Is
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone America/St_Thomas -4:19:44 -      LMT     1911 Jul    # Charlotte Amalie
+                       -4:00   -       AST
diff --git a/extra/zoneinfo/pacificnew b/extra/zoneinfo/pacificnew
new file mode 100644 (file)
index 0000000..667940b
--- /dev/null
@@ -0,0 +1,26 @@
+# @(#)pacificnew       8.1
+
+# From Arthur David Olson (1989-04-05):
+# On 1989-04-05, the U. S. House of Representatives passed (238-154) a bill
+# establishing "Pacific Presidential Election Time"; it was not acted on
+# by the Senate or signed into law by the President.
+# You might want to change the "PE" (Presidential Election) below to
+# "Q" (Quadrennial) to maintain three-character zone abbreviations.
+# If you're really conservative, you might want to change it to "D".
+# Avoid "L" (Leap Year), which won't be true in 2100.
+
+# If Presidential Election Time is ever established, replace "XXXX" below
+# with the year the law takes effect and uncomment the "##" lines.
+
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+## Rule        Twilite XXXX    max     -       Apr     Sun>=1  2:00    1:00    D
+## Rule        Twilite XXXX    max     uspres  Oct     lastSun 2:00    1:00    PE
+## Rule        Twilite XXXX    max     uspres  Nov     Sun>=7  2:00    0       S
+## Rule        Twilite XXXX    max     nonpres Oct     lastSun 2:00    0       S
+
+# Zone NAME                    GMTOFF  RULES/SAVE      FORMAT  [UNTIL]
+## Zone        America/Los_Angeles-PET -8:00   US              P%sT    XXXX
+##                             -8:00   Twilite         P%sT
+
+# For now...
+Link   America/Los_Angeles     US/Pacific-New  ##
diff --git a/extra/zoneinfo/solar87 b/extra/zoneinfo/solar87
new file mode 100644 (file)
index 0000000..7183932
--- /dev/null
@@ -0,0 +1,388 @@
+# @(#)solar87  8.1
+
+# So much for footnotes about Saudi Arabia.
+# Apparent noon times below are for Riyadh; your mileage will vary.
+# Times were computed using formulas in the U.S. Naval Observatory's
+# Almanac for Computers 1987; the formulas "will give EqT to an accuracy of
+# [plus or minus two] seconds during the current year."
+#
+# Rounding to the nearest five seconds results in fewer than
+# 256 different "time types"--a limit that's faced because time types are
+# stored on disk as unsigned chars.
+
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   sol87   1987    only    -       Jan     1       12:03:20s -0:03:20 -
+Rule   sol87   1987    only    -       Jan     2       12:03:50s -0:03:50 -
+Rule   sol87   1987    only    -       Jan     3       12:04:15s -0:04:15 -
+Rule   sol87   1987    only    -       Jan     4       12:04:45s -0:04:45 -
+Rule   sol87   1987    only    -       Jan     5       12:05:10s -0:05:10 -
+Rule   sol87   1987    only    -       Jan     6       12:05:40s -0:05:40 -
+Rule   sol87   1987    only    -       Jan     7       12:06:05s -0:06:05 -
+Rule   sol87   1987    only    -       Jan     8       12:06:30s -0:06:30 -
+Rule   sol87   1987    only    -       Jan     9       12:06:55s -0:06:55 -
+Rule   sol87   1987    only    -       Jan     10      12:07:20s -0:07:20 -
+Rule   sol87   1987    only    -       Jan     11      12:07:45s -0:07:45 -
+Rule   sol87   1987    only    -       Jan     12      12:08:10s -0:08:10 -
+Rule   sol87   1987    only    -       Jan     13      12:08:30s -0:08:30 -
+Rule   sol87   1987    only    -       Jan     14      12:08:55s -0:08:55 -
+Rule   sol87   1987    only    -       Jan     15      12:09:15s -0:09:15 -
+Rule   sol87   1987    only    -       Jan     16      12:09:35s -0:09:35 -
+Rule   sol87   1987    only    -       Jan     17      12:09:55s -0:09:55 -
+Rule   sol87   1987    only    -       Jan     18      12:10:15s -0:10:15 -
+Rule   sol87   1987    only    -       Jan     19      12:10:35s -0:10:35 -
+Rule   sol87   1987    only    -       Jan     20      12:10:55s -0:10:55 -
+Rule   sol87   1987    only    -       Jan     21      12:11:10s -0:11:10 -
+Rule   sol87   1987    only    -       Jan     22      12:11:30s -0:11:30 -
+Rule   sol87   1987    only    -       Jan     23      12:11:45s -0:11:45 -
+Rule   sol87   1987    only    -       Jan     24      12:12:00s -0:12:00 -
+Rule   sol87   1987    only    -       Jan     25      12:12:15s -0:12:15 -
+Rule   sol87   1987    only    -       Jan     26      12:12:30s -0:12:30 -
+Rule   sol87   1987    only    -       Jan     27      12:12:40s -0:12:40 -
+Rule   sol87   1987    only    -       Jan     28      12:12:55s -0:12:55 -
+Rule   sol87   1987    only    -       Jan     29      12:13:05s -0:13:05 -
+Rule   sol87   1987    only    -       Jan     30      12:13:15s -0:13:15 -
+Rule   sol87   1987    only    -       Jan     31      12:13:25s -0:13:25 -
+Rule   sol87   1987    only    -       Feb     1       12:13:35s -0:13:35 -
+Rule   sol87   1987    only    -       Feb     2       12:13:40s -0:13:40 -
+Rule   sol87   1987    only    -       Feb     3       12:13:50s -0:13:50 -
+Rule   sol87   1987    only    -       Feb     4       12:13:55s -0:13:55 -
+Rule   sol87   1987    only    -       Feb     5       12:14:00s -0:14:00 -
+Rule   sol87   1987    only    -       Feb     6       12:14:05s -0:14:05 -
+Rule   sol87   1987    only    -       Feb     7       12:14:10s -0:14:10 -
+Rule   sol87   1987    only    -       Feb     8       12:14:10s -0:14:10 -
+Rule   sol87   1987    only    -       Feb     9       12:14:15s -0:14:15 -
+Rule   sol87   1987    only    -       Feb     10      12:14:15s -0:14:15 -
+Rule   sol87   1987    only    -       Feb     11      12:14:15s -0:14:15 -
+Rule   sol87   1987    only    -       Feb     12      12:14:15s -0:14:15 -
+Rule   sol87   1987    only    -       Feb     13      12:14:15s -0:14:15 -
+Rule   sol87   1987    only    -       Feb     14      12:14:15s -0:14:15 -
+Rule   sol87   1987    only    -       Feb     15      12:14:10s -0:14:10 -
+Rule   sol87   1987    only    -       Feb     16      12:14:10s -0:14:10 -
+Rule   sol87   1987    only    -       Feb     17      12:14:05s -0:14:05 -
+Rule   sol87   1987    only    -       Feb     18      12:14:00s -0:14:00 -
+Rule   sol87   1987    only    -       Feb     19      12:13:55s -0:13:55 -
+Rule   sol87   1987    only    -       Feb     20      12:13:50s -0:13:50 -
+Rule   sol87   1987    only    -       Feb     21      12:13:45s -0:13:45 -
+Rule   sol87   1987    only    -       Feb     22      12:13:35s -0:13:35 -
+Rule   sol87   1987    only    -       Feb     23      12:13:30s -0:13:30 -
+Rule   sol87   1987    only    -       Feb     24      12:13:20s -0:13:20 -
+Rule   sol87   1987    only    -       Feb     25      12:13:10s -0:13:10 -
+Rule   sol87   1987    only    -       Feb     26      12:13:00s -0:13:00 -
+Rule   sol87   1987    only    -       Feb     27      12:12:50s -0:12:50 -
+Rule   sol87   1987    only    -       Feb     28      12:12:40s -0:12:40 -
+Rule   sol87   1987    only    -       Mar     1       12:12:30s -0:12:30 -
+Rule   sol87   1987    only    -       Mar     2       12:12:20s -0:12:20 -
+Rule   sol87   1987    only    -       Mar     3       12:12:05s -0:12:05 -
+Rule   sol87   1987    only    -       Mar     4       12:11:55s -0:11:55 -
+Rule   sol87   1987    only    -       Mar     5       12:11:40s -0:11:40 -
+Rule   sol87   1987    only    -       Mar     6       12:11:25s -0:11:25 -
+Rule   sol87   1987    only    -       Mar     7       12:11:15s -0:11:15 -
+Rule   sol87   1987    only    -       Mar     8       12:11:00s -0:11:00 -
+Rule   sol87   1987    only    -       Mar     9       12:10:45s -0:10:45 -
+Rule   sol87   1987    only    -       Mar     10      12:10:30s -0:10:30 -
+Rule   sol87   1987    only    -       Mar     11      12:10:15s -0:10:15 -
+Rule   sol87   1987    only    -       Mar     12      12:09:55s -0:09:55 -
+Rule   sol87   1987    only    -       Mar     13      12:09:40s -0:09:40 -
+Rule   sol87   1987    only    -       Mar     14      12:09:25s -0:09:25 -
+Rule   sol87   1987    only    -       Mar     15      12:09:10s -0:09:10 -
+Rule   sol87   1987    only    -       Mar     16      12:08:50s -0:08:50 -
+Rule   sol87   1987    only    -       Mar     17      12:08:35s -0:08:35 -
+Rule   sol87   1987    only    -       Mar     18      12:08:15s -0:08:15 -
+Rule   sol87   1987    only    -       Mar     19      12:08:00s -0:08:00 -
+Rule   sol87   1987    only    -       Mar     20      12:07:40s -0:07:40 -
+Rule   sol87   1987    only    -       Mar     21      12:07:25s -0:07:25 -
+Rule   sol87   1987    only    -       Mar     22      12:07:05s -0:07:05 -
+Rule   sol87   1987    only    -       Mar     23      12:06:50s -0:06:50 -
+Rule   sol87   1987    only    -       Mar     24      12:06:30s -0:06:30 -
+Rule   sol87   1987    only    -       Mar     25      12:06:10s -0:06:10 -
+Rule   sol87   1987    only    -       Mar     26      12:05:55s -0:05:55 -
+Rule   sol87   1987    only    -       Mar     27      12:05:35s -0:05:35 -
+Rule   sol87   1987    only    -       Mar     28      12:05:15s -0:05:15 -
+Rule   sol87   1987    only    -       Mar     29      12:05:00s -0:05:00 -
+Rule   sol87   1987    only    -       Mar     30      12:04:40s -0:04:40 -
+Rule   sol87   1987    only    -       Mar     31      12:04:25s -0:04:25 -
+Rule   sol87   1987    only    -       Apr     1       12:04:05s -0:04:05 -
+Rule   sol87   1987    only    -       Apr     2       12:03:45s -0:03:45 -
+Rule   sol87   1987    only    -       Apr     3       12:03:30s -0:03:30 -
+Rule   sol87   1987    only    -       Apr     4       12:03:10s -0:03:10 -
+Rule   sol87   1987    only    -       Apr     5       12:02:55s -0:02:55 -
+Rule   sol87   1987    only    -       Apr     6       12:02:35s -0:02:35 -
+Rule   sol87   1987    only    -       Apr     7       12:02:20s -0:02:20 -
+Rule   sol87   1987    only    -       Apr     8       12:02:05s -0:02:05 -
+Rule   sol87   1987    only    -       Apr     9       12:01:45s -0:01:45 -
+Rule   sol87   1987    only    -       Apr     10      12:01:30s -0:01:30 -
+Rule   sol87   1987    only    -       Apr     11      12:01:15s -0:01:15 -
+Rule   sol87   1987    only    -       Apr     12      12:00:55s -0:00:55 -
+Rule   sol87   1987    only    -       Apr     13      12:00:40s -0:00:40 -
+Rule   sol87   1987    only    -       Apr     14      12:00:25s -0:00:25 -
+Rule   sol87   1987    only    -       Apr     15      12:00:10s -0:00:10 -
+Rule   sol87   1987    only    -       Apr     16      11:59:55s 0:00:05 -
+Rule   sol87   1987    only    -       Apr     17      11:59:45s 0:00:15 -
+Rule   sol87   1987    only    -       Apr     18      11:59:30s 0:00:30 -
+Rule   sol87   1987    only    -       Apr     19      11:59:15s 0:00:45 -
+Rule   sol87   1987    only    -       Apr     20      11:59:05s 0:00:55 -
+Rule   sol87   1987    only    -       Apr     21      11:58:50s 0:01:10 -
+Rule   sol87   1987    only    -       Apr     22      11:58:40s 0:01:20 -
+Rule   sol87   1987    only    -       Apr     23      11:58:25s 0:01:35 -
+Rule   sol87   1987    only    -       Apr     24      11:58:15s 0:01:45 -
+Rule   sol87   1987    only    -       Apr     25      11:58:05s 0:01:55 -
+Rule   sol87   1987    only    -       Apr     26      11:57:55s 0:02:05 -
+Rule   sol87   1987    only    -       Apr     27      11:57:45s 0:02:15 -
+Rule   sol87   1987    only    -       Apr     28      11:57:35s 0:02:25 -
+Rule   sol87   1987    only    -       Apr     29      11:57:25s 0:02:35 -
+Rule   sol87   1987    only    -       Apr     30      11:57:15s 0:02:45 -
+Rule   sol87   1987    only    -       May     1       11:57:10s 0:02:50 -
+Rule   sol87   1987    only    -       May     2       11:57:00s 0:03:00 -
+Rule   sol87   1987    only    -       May     3       11:56:55s 0:03:05 -
+Rule   sol87   1987    only    -       May     4       11:56:50s 0:03:10 -
+Rule   sol87   1987    only    -       May     5       11:56:45s 0:03:15 -
+Rule   sol87   1987    only    -       May     6       11:56:40s 0:03:20 -
+Rule   sol87   1987    only    -       May     7       11:56:35s 0:03:25 -
+Rule   sol87   1987    only    -       May     8       11:56:30s 0:03:30 -
+Rule   sol87   1987    only    -       May     9       11:56:25s 0:03:35 -
+Rule   sol87   1987    only    -       May     10      11:56:25s 0:03:35 -
+Rule   sol87   1987    only    -       May     11      11:56:20s 0:03:40 -
+Rule   sol87   1987    only    -       May     12      11:56:20s 0:03:40 -
+Rule   sol87   1987    only    -       May     13      11:56:20s 0:03:40 -
+Rule   sol87   1987    only    -       May     14      11:56:20s 0:03:40 -
+Rule   sol87   1987    only    -       May     15      11:56:20s 0:03:40 -
+Rule   sol87   1987    only    -       May     16      11:56:20s 0:03:40 -
+Rule   sol87   1987    only    -       May     17      11:56:20s 0:03:40 -
+Rule   sol87   1987    only    -       May     18      11:56:20s 0:03:40 -
+Rule   sol87   1987    only    -       May     19      11:56:25s 0:03:35 -
+Rule   sol87   1987    only    -       May     20      11:56:25s 0:03:35 -
+Rule   sol87   1987    only    -       May     21      11:56:30s 0:03:30 -
+Rule   sol87   1987    only    -       May     22      11:56:35s 0:03:25 -
+Rule   sol87   1987    only    -       May     23      11:56:40s 0:03:20 -
+Rule   sol87   1987    only    -       May     24      11:56:45s 0:03:15 -
+Rule   sol87   1987    only    -       May     25      11:56:50s 0:03:10 -
+Rule   sol87   1987    only    -       May     26      11:56:55s 0:03:05 -
+Rule   sol87   1987    only    -       May     27      11:57:00s 0:03:00 -
+Rule   sol87   1987    only    -       May     28      11:57:10s 0:02:50 -
+Rule   sol87   1987    only    -       May     29      11:57:15s 0:02:45 -
+Rule   sol87   1987    only    -       May     30      11:57:25s 0:02:35 -
+Rule   sol87   1987    only    -       May     31      11:57:30s 0:02:30 -
+Rule   sol87   1987    only    -       Jun     1       11:57:40s 0:02:20 -
+Rule   sol87   1987    only    -       Jun     2       11:57:50s 0:02:10 -
+Rule   sol87   1987    only    -       Jun     3       11:58:00s 0:02:00 -
+Rule   sol87   1987    only    -       Jun     4       11:58:10s 0:01:50 -
+Rule   sol87   1987    only    -       Jun     5       11:58:20s 0:01:40 -
+Rule   sol87   1987    only    -       Jun     6       11:58:30s 0:01:30 -
+Rule   sol87   1987    only    -       Jun     7       11:58:40s 0:01:20 -
+Rule   sol87   1987    only    -       Jun     8       11:58:50s 0:01:10 -
+Rule   sol87   1987    only    -       Jun     9       11:59:05s 0:00:55 -
+Rule   sol87   1987    only    -       Jun     10      11:59:15s 0:00:45 -
+Rule   sol87   1987    only    -       Jun     11      11:59:30s 0:00:30 -
+Rule   sol87   1987    only    -       Jun     12      11:59:40s 0:00:20 -
+Rule   sol87   1987    only    -       Jun     13      11:59:50s 0:00:10 -
+Rule   sol87   1987    only    -       Jun     14      12:00:05s -0:00:05 -
+Rule   sol87   1987    only    -       Jun     15      12:00:15s -0:00:15 -
+Rule   sol87   1987    only    -       Jun     16      12:00:30s -0:00:30 -
+Rule   sol87   1987    only    -       Jun     17      12:00:45s -0:00:45 -
+Rule   sol87   1987    only    -       Jun     18      12:00:55s -0:00:55 -
+Rule   sol87   1987    only    -       Jun     19      12:01:10s -0:01:10 -
+Rule   sol87   1987    only    -       Jun     20      12:01:20s -0:01:20 -
+Rule   sol87   1987    only    -       Jun     21      12:01:35s -0:01:35 -
+Rule   sol87   1987    only    -       Jun     22      12:01:50s -0:01:50 -
+Rule   sol87   1987    only    -       Jun     23      12:02:00s -0:02:00 -
+Rule   sol87   1987    only    -       Jun     24      12:02:15s -0:02:15 -
+Rule   sol87   1987    only    -       Jun     25      12:02:25s -0:02:25 -
+Rule   sol87   1987    only    -       Jun     26      12:02:40s -0:02:40 -
+Rule   sol87   1987    only    -       Jun     27      12:02:50s -0:02:50 -
+Rule   sol87   1987    only    -       Jun     28      12:03:05s -0:03:05 -
+Rule   sol87   1987    only    -       Jun     29      12:03:15s -0:03:15 -
+Rule   sol87   1987    only    -       Jun     30      12:03:30s -0:03:30 -
+Rule   sol87   1987    only    -       Jul     1       12:03:40s -0:03:40 -
+Rule   sol87   1987    only    -       Jul     2       12:03:50s -0:03:50 -
+Rule   sol87   1987    only    -       Jul     3       12:04:05s -0:04:05 -
+Rule   sol87   1987    only    -       Jul     4       12:04:15s -0:04:15 -
+Rule   sol87   1987    only    -       Jul     5       12:04:25s -0:04:25 -
+Rule   sol87   1987    only    -       Jul     6       12:04:35s -0:04:35 -
+Rule   sol87   1987    only    -       Jul     7       12:04:45s -0:04:45 -
+Rule   sol87   1987    only    -       Jul     8       12:04:55s -0:04:55 -
+Rule   sol87   1987    only    -       Jul     9       12:05:05s -0:05:05 -
+Rule   sol87   1987    only    -       Jul     10      12:05:15s -0:05:15 -
+Rule   sol87   1987    only    -       Jul     11      12:05:20s -0:05:20 -
+Rule   sol87   1987    only    -       Jul     12      12:05:30s -0:05:30 -
+Rule   sol87   1987    only    -       Jul     13      12:05:40s -0:05:40 -
+Rule   sol87   1987    only    -       Jul     14      12:05:45s -0:05:45 -
+Rule   sol87   1987    only    -       Jul     15      12:05:50s -0:05:50 -
+Rule   sol87   1987    only    -       Jul     16      12:06:00s -0:06:00 -
+Rule   sol87   1987    only    -       Jul     17      12:06:05s -0:06:05 -
+Rule   sol87   1987    only    -       Jul     18      12:06:10s -0:06:10 -
+Rule   sol87   1987    only    -       Jul     19      12:06:15s -0:06:15 -
+Rule   sol87   1987    only    -       Jul     20      12:06:15s -0:06:15 -
+Rule   sol87   1987    only    -       Jul     21      12:06:20s -0:06:20 -
+Rule   sol87   1987    only    -       Jul     22      12:06:25s -0:06:25 -
+Rule   sol87   1987    only    -       Jul     23      12:06:25s -0:06:25 -
+Rule   sol87   1987    only    -       Jul     24      12:06:25s -0:06:25 -
+Rule   sol87   1987    only    -       Jul     25      12:06:30s -0:06:30 -
+Rule   sol87   1987    only    -       Jul     26      12:06:30s -0:06:30 -
+Rule   sol87   1987    only    -       Jul     27      12:06:30s -0:06:30 -
+Rule   sol87   1987    only    -       Jul     28      12:06:30s -0:06:30 -
+Rule   sol87   1987    only    -       Jul     29      12:06:25s -0:06:25 -
+Rule   sol87   1987    only    -       Jul     30      12:06:25s -0:06:25 -
+Rule   sol87   1987    only    -       Jul     31      12:06:25s -0:06:25 -
+Rule   sol87   1987    only    -       Aug     1       12:06:20s -0:06:20 -
+Rule   sol87   1987    only    -       Aug     2       12:06:15s -0:06:15 -
+Rule   sol87   1987    only    -       Aug     3       12:06:10s -0:06:10 -
+Rule   sol87   1987    only    -       Aug     4       12:06:05s -0:06:05 -
+Rule   sol87   1987    only    -       Aug     5       12:06:00s -0:06:00 -
+Rule   sol87   1987    only    -       Aug     6       12:05:55s -0:05:55 -
+Rule   sol87   1987    only    -       Aug     7       12:05:50s -0:05:50 -
+Rule   sol87   1987    only    -       Aug     8       12:05:40s -0:05:40 -
+Rule   sol87   1987    only    -       Aug     9       12:05:35s -0:05:35 -
+Rule   sol87   1987    only    -       Aug     10      12:05:25s -0:05:25 -
+Rule   sol87   1987    only    -       Aug     11      12:05:15s -0:05:15 -
+Rule   sol87   1987    only    -       Aug     12      12:05:05s -0:05:05 -
+Rule   sol87   1987    only    -       Aug     13      12:04:55s -0:04:55 -
+Rule   sol87   1987    only    -       Aug     14      12:04:45s -0:04:45 -
+Rule   sol87   1987    only    -       Aug     15      12:04:35s -0:04:35 -
+Rule   sol87   1987    only    -       Aug     16      12:04:25s -0:04:25 -
+Rule   sol87   1987    only    -       Aug     17      12:04:10s -0:04:10 -
+Rule   sol87   1987    only    -       Aug     18      12:04:00s -0:04:00 -
+Rule   sol87   1987    only    -       Aug     19      12:03:45s -0:03:45 -
+Rule   sol87   1987    only    -       Aug     20      12:03:30s -0:03:30 -
+Rule   sol87   1987    only    -       Aug     21      12:03:15s -0:03:15 -
+Rule   sol87   1987    only    -       Aug     22      12:03:00s -0:03:00 -
+Rule   sol87   1987    only    -       Aug     23      12:02:45s -0:02:45 -
+Rule   sol87   1987    only    -       Aug     24      12:02:30s -0:02:30 -
+Rule   sol87   1987    only    -       Aug     25      12:02:15s -0:02:15 -
+Rule   sol87   1987    only    -       Aug     26      12:02:00s -0:02:00 -
+Rule   sol87   1987    only    -       Aug     27      12:01:40s -0:01:40 -
+Rule   sol87   1987    only    -       Aug     28      12:01:25s -0:01:25 -
+Rule   sol87   1987    only    -       Aug     29      12:01:05s -0:01:05 -
+Rule   sol87   1987    only    -       Aug     30      12:00:50s -0:00:50 -
+Rule   sol87   1987    only    -       Aug     31      12:00:30s -0:00:30 -
+Rule   sol87   1987    only    -       Sep     1       12:00:10s -0:00:10 -
+Rule   sol87   1987    only    -       Sep     2       11:59:50s 0:00:10 -
+Rule   sol87   1987    only    -       Sep     3       11:59:35s 0:00:25 -
+Rule   sol87   1987    only    -       Sep     4       11:59:15s 0:00:45 -
+Rule   sol87   1987    only    -       Sep     5       11:58:55s 0:01:05 -
+Rule   sol87   1987    only    -       Sep     6       11:58:35s 0:01:25 -
+Rule   sol87   1987    only    -       Sep     7       11:58:15s 0:01:45 -
+Rule   sol87   1987    only    -       Sep     8       11:57:55s 0:02:05 -
+Rule   sol87   1987    only    -       Sep     9       11:57:30s 0:02:30 -
+Rule   sol87   1987    only    -       Sep     10      11:57:10s 0:02:50 -
+Rule   sol87   1987    only    -       Sep     11      11:56:50s 0:03:10 -
+Rule   sol87   1987    only    -       Sep     12      11:56:30s 0:03:30 -
+Rule   sol87   1987    only    -       Sep     13      11:56:10s 0:03:50 -
+Rule   sol87   1987    only    -       Sep     14      11:55:45s 0:04:15 -
+Rule   sol87   1987    only    -       Sep     15      11:55:25s 0:04:35 -
+Rule   sol87   1987    only    -       Sep     16      11:55:05s 0:04:55 -
+Rule   sol87   1987    only    -       Sep     17      11:54:45s 0:05:15 -
+Rule   sol87   1987    only    -       Sep     18      11:54:20s 0:05:40 -
+Rule   sol87   1987    only    -       Sep     19      11:54:00s 0:06:00 -
+Rule   sol87   1987    only    -       Sep     20      11:53:40s 0:06:20 -
+Rule   sol87   1987    only    -       Sep     21      11:53:15s 0:06:45 -
+Rule   sol87   1987    only    -       Sep     22      11:52:55s 0:07:05 -
+Rule   sol87   1987    only    -       Sep     23      11:52:35s 0:07:25 -
+Rule   sol87   1987    only    -       Sep     24      11:52:15s 0:07:45 -
+Rule   sol87   1987    only    -       Sep     25      11:51:55s 0:08:05 -
+Rule   sol87   1987    only    -       Sep     26      11:51:35s 0:08:25 -
+Rule   sol87   1987    only    -       Sep     27      11:51:10s 0:08:50 -
+Rule   sol87   1987    only    -       Sep     28      11:50:50s 0:09:10 -
+Rule   sol87   1987    only    -       Sep     29      11:50:30s 0:09:30 -
+Rule   sol87   1987    only    -       Sep     30      11:50:10s 0:09:50 -
+Rule   sol87   1987    only    -       Oct     1       11:49:50s 0:10:10 -
+Rule   sol87   1987    only    -       Oct     2       11:49:35s 0:10:25 -
+Rule   sol87   1987    only    -       Oct     3       11:49:15s 0:10:45 -
+Rule   sol87   1987    only    -       Oct     4       11:48:55s 0:11:05 -
+Rule   sol87   1987    only    -       Oct     5       11:48:35s 0:11:25 -
+Rule   sol87   1987    only    -       Oct     6       11:48:20s 0:11:40 -
+Rule   sol87   1987    only    -       Oct     7       11:48:00s 0:12:00 -
+Rule   sol87   1987    only    -       Oct     8       11:47:45s 0:12:15 -
+Rule   sol87   1987    only    -       Oct     9       11:47:25s 0:12:35 -
+Rule   sol87   1987    only    -       Oct     10      11:47:10s 0:12:50 -
+Rule   sol87   1987    only    -       Oct     11      11:46:55s 0:13:05 -
+Rule   sol87   1987    only    -       Oct     12      11:46:40s 0:13:20 -
+Rule   sol87   1987    only    -       Oct     13      11:46:25s 0:13:35 -
+Rule   sol87   1987    only    -       Oct     14      11:46:10s 0:13:50 -
+Rule   sol87   1987    only    -       Oct     15      11:45:55s 0:14:05 -
+Rule   sol87   1987    only    -       Oct     16      11:45:45s 0:14:15 -
+Rule   sol87   1987    only    -       Oct     17      11:45:30s 0:14:30 -
+Rule   sol87   1987    only    -       Oct     18      11:45:20s 0:14:40 -
+Rule   sol87   1987    only    -       Oct     19      11:45:05s 0:14:55 -
+Rule   sol87   1987    only    -       Oct     20      11:44:55s 0:15:05 -
+Rule   sol87   1987    only    -       Oct     21      11:44:45s 0:15:15 -
+Rule   sol87   1987    only    -       Oct     22      11:44:35s 0:15:25 -
+Rule   sol87   1987    only    -       Oct     23      11:44:25s 0:15:35 -
+Rule   sol87   1987    only    -       Oct     24      11:44:20s 0:15:40 -
+Rule   sol87   1987    only    -       Oct     25      11:44:10s 0:15:50 -
+Rule   sol87   1987    only    -       Oct     26      11:44:05s 0:15:55 -
+Rule   sol87   1987    only    -       Oct     27      11:43:55s 0:16:05 -
+Rule   sol87   1987    only    -       Oct     28      11:43:50s 0:16:10 -
+Rule   sol87   1987    only    -       Oct     29      11:43:45s 0:16:15 -
+Rule   sol87   1987    only    -       Oct     30      11:43:45s 0:16:15 -
+Rule   sol87   1987    only    -       Oct     31      11:43:40s 0:16:20 -
+Rule   sol87   1987    only    -       Nov     1       11:43:40s 0:16:20 -
+Rule   sol87   1987    only    -       Nov     2       11:43:35s 0:16:25 -
+Rule   sol87   1987    only    -       Nov     3       11:43:35s 0:16:25 -
+Rule   sol87   1987    only    -       Nov     4       11:43:35s 0:16:25 -
+Rule   sol87   1987    only    -       Nov     5       11:43:35s 0:16:25 -
+Rule   sol87   1987    only    -       Nov     6       11:43:40s 0:16:20 -
+Rule   sol87   1987    only    -       Nov     7       11:43:40s 0:16:20 -
+Rule   sol87   1987    only    -       Nov     8       11:43:45s 0:16:15 -
+Rule   sol87   1987    only    -       Nov     9       11:43:50s 0:16:10 -
+Rule   sol87   1987    only    -       Nov     10      11:43:55s 0:16:05 -
+Rule   sol87   1987    only    -       Nov     11      11:44:00s 0:16:00 -
+Rule   sol87   1987    only    -       Nov     12      11:44:05s 0:15:55 -
+Rule   sol87   1987    only    -       Nov     13      11:44:15s 0:15:45 -
+Rule   sol87   1987    only    -       Nov     14      11:44:20s 0:15:40 -
+Rule   sol87   1987    only    -       Nov     15      11:44:30s 0:15:30 -
+Rule   sol87   1987    only    -       Nov     16      11:44:40s 0:15:20 -
+Rule   sol87   1987    only    -       Nov     17      11:44:50s 0:15:10 -
+Rule   sol87   1987    only    -       Nov     18      11:45:05s 0:14:55 -
+Rule   sol87   1987    only    -       Nov     19      11:45:15s 0:14:45 -
+Rule   sol87   1987    only    -       Nov     20      11:45:30s 0:14:30 -
+Rule   sol87   1987    only    -       Nov     21      11:45:45s 0:14:15 -
+Rule   sol87   1987    only    -       Nov     22      11:46:00s 0:14:00 -
+Rule   sol87   1987    only    -       Nov     23      11:46:15s 0:13:45 -
+Rule   sol87   1987    only    -       Nov     24      11:46:30s 0:13:30 -
+Rule   sol87   1987    only    -       Nov     25      11:46:50s 0:13:10 -
+Rule   sol87   1987    only    -       Nov     26      11:47:10s 0:12:50 -
+Rule   sol87   1987    only    -       Nov     27      11:47:25s 0:12:35 -
+Rule   sol87   1987    only    -       Nov     28      11:47:45s 0:12:15 -
+Rule   sol87   1987    only    -       Nov     29      11:48:05s 0:11:55 -
+Rule   sol87   1987    only    -       Nov     30      11:48:30s 0:11:30 -
+Rule   sol87   1987    only    -       Dec     1       11:48:50s 0:11:10 -
+Rule   sol87   1987    only    -       Dec     2       11:49:10s 0:10:50 -
+Rule   sol87   1987    only    -       Dec     3       11:49:35s 0:10:25 -
+Rule   sol87   1987    only    -       Dec     4       11:50:00s 0:10:00 -
+Rule   sol87   1987    only    -       Dec     5       11:50:25s 0:09:35 -
+Rule   sol87   1987    only    -       Dec     6       11:50:50s 0:09:10 -
+Rule   sol87   1987    only    -       Dec     7       11:51:15s 0:08:45 -
+Rule   sol87   1987    only    -       Dec     8       11:51:40s 0:08:20 -
+Rule   sol87   1987    only    -       Dec     9       11:52:05s 0:07:55 -
+Rule   sol87   1987    only    -       Dec     10      11:52:30s 0:07:30 -
+Rule   sol87   1987    only    -       Dec     11      11:53:00s 0:07:00 -
+Rule   sol87   1987    only    -       Dec     12      11:53:25s 0:06:35 -
+Rule   sol87   1987    only    -       Dec     13      11:53:55s 0:06:05 -
+Rule   sol87   1987    only    -       Dec     14      11:54:25s 0:05:35 -
+Rule   sol87   1987    only    -       Dec     15      11:54:50s 0:05:10 -
+Rule   sol87   1987    only    -       Dec     16      11:55:20s 0:04:40 -
+Rule   sol87   1987    only    -       Dec     17      11:55:50s 0:04:10 -
+Rule   sol87   1987    only    -       Dec     18      11:56:20s 0:03:40 -
+Rule   sol87   1987    only    -       Dec     19      11:56:50s 0:03:10 -
+Rule   sol87   1987    only    -       Dec     20      11:57:20s 0:02:40 -
+Rule   sol87   1987    only    -       Dec     21      11:57:50s 0:02:10 -
+Rule   sol87   1987    only    -       Dec     22      11:58:20s 0:01:40 -
+Rule   sol87   1987    only    -       Dec     23      11:58:50s 0:01:10 -
+Rule   sol87   1987    only    -       Dec     24      11:59:20s 0:00:40 -
+Rule   sol87   1987    only    -       Dec     25      11:59:50s 0:00:10 -
+Rule   sol87   1987    only    -       Dec     26      12:00:20s -0:00:20 -
+Rule   sol87   1987    only    -       Dec     27      12:00:45s -0:00:45 -
+Rule   sol87   1987    only    -       Dec     28      12:01:15s -0:01:15 -
+Rule   sol87   1987    only    -       Dec     29      12:01:45s -0:01:45 -
+Rule   sol87   1987    only    -       Dec     30      12:02:15s -0:02:15 -
+Rule   sol87   1987    only    -       Dec     31      12:02:45s -0:02:45 -
+
+# Riyadh is at about 46 degrees 46 minutes East:  3 hrs, 7 mins, 4 secs
+# Before and after 1987, we'll operate on local mean solar time.
+
+# Zone NAME            GMTOFF  RULES/SAVE      FORMAT  [UNTIL]
+Zone   Asia/Riyadh87   3:07:04 -               zzz     1987
+                       3:07:04 sol87           zzz     1988
+                       3:07:04 -               zzz
+# For backward compatibility...
+Link   Asia/Riyadh87   Mideast/Riyadh87
diff --git a/extra/zoneinfo/solar88 b/extra/zoneinfo/solar88
new file mode 100644 (file)
index 0000000..b4cfe8e
--- /dev/null
@@ -0,0 +1,388 @@
+# @(#)solar88  8.1
+
+# Apparent noon times below are for Riyadh; they're a bit off for other places.
+# Times were computed using formulas in the U.S. Naval Observatory's
+# Almanac for Computers 1988; the formulas "will give EqT to an accuracy of
+# [plus or minus two] seconds during the current year."
+#
+# Rounding to the nearest five seconds results in fewer than
+# 256 different "time types"--a limit that's faced because time types are
+# stored on disk as unsigned chars.
+
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   sol88   1988    only    -       Jan     1       12:03:15s -0:03:15 -
+Rule   sol88   1988    only    -       Jan     2       12:03:40s -0:03:40 -
+Rule   sol88   1988    only    -       Jan     3       12:04:10s -0:04:10 -
+Rule   sol88   1988    only    -       Jan     4       12:04:40s -0:04:40 -
+Rule   sol88   1988    only    -       Jan     5       12:05:05s -0:05:05 -
+Rule   sol88   1988    only    -       Jan     6       12:05:30s -0:05:30 -
+Rule   sol88   1988    only    -       Jan     7       12:06:00s -0:06:00 -
+Rule   sol88   1988    only    -       Jan     8       12:06:25s -0:06:25 -
+Rule   sol88   1988    only    -       Jan     9       12:06:50s -0:06:50 -
+Rule   sol88   1988    only    -       Jan     10      12:07:15s -0:07:15 -
+Rule   sol88   1988    only    -       Jan     11      12:07:40s -0:07:40 -
+Rule   sol88   1988    only    -       Jan     12      12:08:05s -0:08:05 -
+Rule   sol88   1988    only    -       Jan     13      12:08:25s -0:08:25 -
+Rule   sol88   1988    only    -       Jan     14      12:08:50s -0:08:50 -
+Rule   sol88   1988    only    -       Jan     15      12:09:10s -0:09:10 -
+Rule   sol88   1988    only    -       Jan     16      12:09:30s -0:09:30 -
+Rule   sol88   1988    only    -       Jan     17      12:09:50s -0:09:50 -
+Rule   sol88   1988    only    -       Jan     18      12:10:10s -0:10:10 -
+Rule   sol88   1988    only    -       Jan     19      12:10:30s -0:10:30 -
+Rule   sol88   1988    only    -       Jan     20      12:10:50s -0:10:50 -
+Rule   sol88   1988    only    -       Jan     21      12:11:05s -0:11:05 -
+Rule   sol88   1988    only    -       Jan     22      12:11:25s -0:11:25 -
+Rule   sol88   1988    only    -       Jan     23      12:11:40s -0:11:40 -
+Rule   sol88   1988    only    -       Jan     24      12:11:55s -0:11:55 -
+Rule   sol88   1988    only    -       Jan     25      12:12:10s -0:12:10 -
+Rule   sol88   1988    only    -       Jan     26      12:12:25s -0:12:25 -
+Rule   sol88   1988    only    -       Jan     27      12:12:40s -0:12:40 -
+Rule   sol88   1988    only    -       Jan     28      12:12:50s -0:12:50 -
+Rule   sol88   1988    only    -       Jan     29      12:13:00s -0:13:00 -
+Rule   sol88   1988    only    -       Jan     30      12:13:10s -0:13:10 -
+Rule   sol88   1988    only    -       Jan     31      12:13:20s -0:13:20 -
+Rule   sol88   1988    only    -       Feb     1       12:13:30s -0:13:30 -
+Rule   sol88   1988    only    -       Feb     2       12:13:40s -0:13:40 -
+Rule   sol88   1988    only    -       Feb     3       12:13:45s -0:13:45 -
+Rule   sol88   1988    only    -       Feb     4       12:13:55s -0:13:55 -
+Rule   sol88   1988    only    -       Feb     5       12:14:00s -0:14:00 -
+Rule   sol88   1988    only    -       Feb     6       12:14:05s -0:14:05 -
+Rule   sol88   1988    only    -       Feb     7       12:14:10s -0:14:10 -
+Rule   sol88   1988    only    -       Feb     8       12:14:10s -0:14:10 -
+Rule   sol88   1988    only    -       Feb     9       12:14:15s -0:14:15 -
+Rule   sol88   1988    only    -       Feb     10      12:14:15s -0:14:15 -
+Rule   sol88   1988    only    -       Feb     11      12:14:15s -0:14:15 -
+Rule   sol88   1988    only    -       Feb     12      12:14:15s -0:14:15 -
+Rule   sol88   1988    only    -       Feb     13      12:14:15s -0:14:15 -
+Rule   sol88   1988    only    -       Feb     14      12:14:15s -0:14:15 -
+Rule   sol88   1988    only    -       Feb     15      12:14:10s -0:14:10 -
+Rule   sol88   1988    only    -       Feb     16      12:14:10s -0:14:10 -
+Rule   sol88   1988    only    -       Feb     17      12:14:05s -0:14:05 -
+Rule   sol88   1988    only    -       Feb     18      12:14:00s -0:14:00 -
+Rule   sol88   1988    only    -       Feb     19      12:13:55s -0:13:55 -
+Rule   sol88   1988    only    -       Feb     20      12:13:50s -0:13:50 -
+Rule   sol88   1988    only    -       Feb     21      12:13:45s -0:13:45 -
+Rule   sol88   1988    only    -       Feb     22      12:13:40s -0:13:40 -
+Rule   sol88   1988    only    -       Feb     23      12:13:30s -0:13:30 -
+Rule   sol88   1988    only    -       Feb     24      12:13:20s -0:13:20 -
+Rule   sol88   1988    only    -       Feb     25      12:13:15s -0:13:15 -
+Rule   sol88   1988    only    -       Feb     26      12:13:05s -0:13:05 -
+Rule   sol88   1988    only    -       Feb     27      12:12:55s -0:12:55 -
+Rule   sol88   1988    only    -       Feb     28      12:12:45s -0:12:45 -
+Rule   sol88   1988    only    -       Feb     29      12:12:30s -0:12:30 -
+Rule   sol88   1988    only    -       Mar     1       12:12:20s -0:12:20 -
+Rule   sol88   1988    only    -       Mar     2       12:12:10s -0:12:10 -
+Rule   sol88   1988    only    -       Mar     3       12:11:55s -0:11:55 -
+Rule   sol88   1988    only    -       Mar     4       12:11:45s -0:11:45 -
+Rule   sol88   1988    only    -       Mar     5       12:11:30s -0:11:30 -
+Rule   sol88   1988    only    -       Mar     6       12:11:15s -0:11:15 -
+Rule   sol88   1988    only    -       Mar     7       12:11:00s -0:11:00 -
+Rule   sol88   1988    only    -       Mar     8       12:10:45s -0:10:45 -
+Rule   sol88   1988    only    -       Mar     9       12:10:30s -0:10:30 -
+Rule   sol88   1988    only    -       Mar     10      12:10:15s -0:10:15 -
+Rule   sol88   1988    only    -       Mar     11      12:10:00s -0:10:00 -
+Rule   sol88   1988    only    -       Mar     12      12:09:45s -0:09:45 -
+Rule   sol88   1988    only    -       Mar     13      12:09:30s -0:09:30 -
+Rule   sol88   1988    only    -       Mar     14      12:09:10s -0:09:10 -
+Rule   sol88   1988    only    -       Mar     15      12:08:55s -0:08:55 -
+Rule   sol88   1988    only    -       Mar     16      12:08:40s -0:08:40 -
+Rule   sol88   1988    only    -       Mar     17      12:08:20s -0:08:20 -
+Rule   sol88   1988    only    -       Mar     18      12:08:05s -0:08:05 -
+Rule   sol88   1988    only    -       Mar     19      12:07:45s -0:07:45 -
+Rule   sol88   1988    only    -       Mar     20      12:07:30s -0:07:30 -
+Rule   sol88   1988    only    -       Mar     21      12:07:10s -0:07:10 -
+Rule   sol88   1988    only    -       Mar     22      12:06:50s -0:06:50 -
+Rule   sol88   1988    only    -       Mar     23      12:06:35s -0:06:35 -
+Rule   sol88   1988    only    -       Mar     24      12:06:15s -0:06:15 -
+Rule   sol88   1988    only    -       Mar     25      12:06:00s -0:06:00 -
+Rule   sol88   1988    only    -       Mar     26      12:05:40s -0:05:40 -
+Rule   sol88   1988    only    -       Mar     27      12:05:20s -0:05:20 -
+Rule   sol88   1988    only    -       Mar     28      12:05:05s -0:05:05 -
+Rule   sol88   1988    only    -       Mar     29      12:04:45s -0:04:45 -
+Rule   sol88   1988    only    -       Mar     30      12:04:25s -0:04:25 -
+Rule   sol88   1988    only    -       Mar     31      12:04:10s -0:04:10 -
+Rule   sol88   1988    only    -       Apr     1       12:03:50s -0:03:50 -
+Rule   sol88   1988    only    -       Apr     2       12:03:35s -0:03:35 -
+Rule   sol88   1988    only    -       Apr     3       12:03:15s -0:03:15 -
+Rule   sol88   1988    only    -       Apr     4       12:03:00s -0:03:00 -
+Rule   sol88   1988    only    -       Apr     5       12:02:40s -0:02:40 -
+Rule   sol88   1988    only    -       Apr     6       12:02:25s -0:02:25 -
+Rule   sol88   1988    only    -       Apr     7       12:02:05s -0:02:05 -
+Rule   sol88   1988    only    -       Apr     8       12:01:50s -0:01:50 -
+Rule   sol88   1988    only    -       Apr     9       12:01:35s -0:01:35 -
+Rule   sol88   1988    only    -       Apr     10      12:01:15s -0:01:15 -
+Rule   sol88   1988    only    -       Apr     11      12:01:00s -0:01:00 -
+Rule   sol88   1988    only    -       Apr     12      12:00:45s -0:00:45 -
+Rule   sol88   1988    only    -       Apr     13      12:00:30s -0:00:30 -
+Rule   sol88   1988    only    -       Apr     14      12:00:15s -0:00:15 -
+Rule   sol88   1988    only    -       Apr     15      12:00:00s 0:00:00 -
+Rule   sol88   1988    only    -       Apr     16      11:59:45s 0:00:15 -
+Rule   sol88   1988    only    -       Apr     17      11:59:30s 0:00:30 -
+Rule   sol88   1988    only    -       Apr     18      11:59:20s 0:00:40 -
+Rule   sol88   1988    only    -       Apr     19      11:59:05s 0:00:55 -
+Rule   sol88   1988    only    -       Apr     20      11:58:55s 0:01:05 -
+Rule   sol88   1988    only    -       Apr     21      11:58:40s 0:01:20 -
+Rule   sol88   1988    only    -       Apr     22      11:58:30s 0:01:30 -
+Rule   sol88   1988    only    -       Apr     23      11:58:15s 0:01:45 -
+Rule   sol88   1988    only    -       Apr     24      11:58:05s 0:01:55 -
+Rule   sol88   1988    only    -       Apr     25      11:57:55s 0:02:05 -
+Rule   sol88   1988    only    -       Apr     26      11:57:45s 0:02:15 -
+Rule   sol88   1988    only    -       Apr     27      11:57:35s 0:02:25 -
+Rule   sol88   1988    only    -       Apr     28      11:57:30s 0:02:30 -
+Rule   sol88   1988    only    -       Apr     29      11:57:20s 0:02:40 -
+Rule   sol88   1988    only    -       Apr     30      11:57:10s 0:02:50 -
+Rule   sol88   1988    only    -       May     1       11:57:05s 0:02:55 -
+Rule   sol88   1988    only    -       May     2       11:56:55s 0:03:05 -
+Rule   sol88   1988    only    -       May     3       11:56:50s 0:03:10 -
+Rule   sol88   1988    only    -       May     4       11:56:45s 0:03:15 -
+Rule   sol88   1988    only    -       May     5       11:56:40s 0:03:20 -
+Rule   sol88   1988    only    -       May     6       11:56:35s 0:03:25 -
+Rule   sol88   1988    only    -       May     7       11:56:30s 0:03:30 -
+Rule   sol88   1988    only    -       May     8       11:56:25s 0:03:35 -
+Rule   sol88   1988    only    -       May     9       11:56:25s 0:03:35 -
+Rule   sol88   1988    only    -       May     10      11:56:20s 0:03:40 -
+Rule   sol88   1988    only    -       May     11      11:56:20s 0:03:40 -
+Rule   sol88   1988    only    -       May     12      11:56:20s 0:03:40 -
+Rule   sol88   1988    only    -       May     13      11:56:20s 0:03:40 -
+Rule   sol88   1988    only    -       May     14      11:56:20s 0:03:40 -
+Rule   sol88   1988    only    -       May     15      11:56:20s 0:03:40 -
+Rule   sol88   1988    only    -       May     16      11:56:20s 0:03:40 -
+Rule   sol88   1988    only    -       May     17      11:56:20s 0:03:40 -
+Rule   sol88   1988    only    -       May     18      11:56:25s 0:03:35 -
+Rule   sol88   1988    only    -       May     19      11:56:25s 0:03:35 -
+Rule   sol88   1988    only    -       May     20      11:56:30s 0:03:30 -
+Rule   sol88   1988    only    -       May     21      11:56:35s 0:03:25 -
+Rule   sol88   1988    only    -       May     22      11:56:40s 0:03:20 -
+Rule   sol88   1988    only    -       May     23      11:56:45s 0:03:15 -
+Rule   sol88   1988    only    -       May     24      11:56:50s 0:03:10 -
+Rule   sol88   1988    only    -       May     25      11:56:55s 0:03:05 -
+Rule   sol88   1988    only    -       May     26      11:57:00s 0:03:00 -
+Rule   sol88   1988    only    -       May     27      11:57:05s 0:02:55 -
+Rule   sol88   1988    only    -       May     28      11:57:15s 0:02:45 -
+Rule   sol88   1988    only    -       May     29      11:57:20s 0:02:40 -
+Rule   sol88   1988    only    -       May     30      11:57:30s 0:02:30 -
+Rule   sol88   1988    only    -       May     31      11:57:40s 0:02:20 -
+Rule   sol88   1988    only    -       Jun     1       11:57:50s 0:02:10 -
+Rule   sol88   1988    only    -       Jun     2       11:57:55s 0:02:05 -
+Rule   sol88   1988    only    -       Jun     3       11:58:05s 0:01:55 -
+Rule   sol88   1988    only    -       Jun     4       11:58:15s 0:01:45 -
+Rule   sol88   1988    only    -       Jun     5       11:58:30s 0:01:30 -
+Rule   sol88   1988    only    -       Jun     6       11:58:40s 0:01:20 -
+Rule   sol88   1988    only    -       Jun     7       11:58:50s 0:01:10 -
+Rule   sol88   1988    only    -       Jun     8       11:59:00s 0:01:00 -
+Rule   sol88   1988    only    -       Jun     9       11:59:15s 0:00:45 -
+Rule   sol88   1988    only    -       Jun     10      11:59:25s 0:00:35 -
+Rule   sol88   1988    only    -       Jun     11      11:59:35s 0:00:25 -
+Rule   sol88   1988    only    -       Jun     12      11:59:50s 0:00:10 -
+Rule   sol88   1988    only    -       Jun     13      12:00:00s 0:00:00 -
+Rule   sol88   1988    only    -       Jun     14      12:00:15s -0:00:15 -
+Rule   sol88   1988    only    -       Jun     15      12:00:25s -0:00:25 -
+Rule   sol88   1988    only    -       Jun     16      12:00:40s -0:00:40 -
+Rule   sol88   1988    only    -       Jun     17      12:00:55s -0:00:55 -
+Rule   sol88   1988    only    -       Jun     18      12:01:05s -0:01:05 -
+Rule   sol88   1988    only    -       Jun     19      12:01:20s -0:01:20 -
+Rule   sol88   1988    only    -       Jun     20      12:01:30s -0:01:30 -
+Rule   sol88   1988    only    -       Jun     21      12:01:45s -0:01:45 -
+Rule   sol88   1988    only    -       Jun     22      12:02:00s -0:02:00 -
+Rule   sol88   1988    only    -       Jun     23      12:02:10s -0:02:10 -
+Rule   sol88   1988    only    -       Jun     24      12:02:25s -0:02:25 -
+Rule   sol88   1988    only    -       Jun     25      12:02:35s -0:02:35 -
+Rule   sol88   1988    only    -       Jun     26      12:02:50s -0:02:50 -
+Rule   sol88   1988    only    -       Jun     27      12:03:00s -0:03:00 -
+Rule   sol88   1988    only    -       Jun     28      12:03:15s -0:03:15 -
+Rule   sol88   1988    only    -       Jun     29      12:03:25s -0:03:25 -
+Rule   sol88   1988    only    -       Jun     30      12:03:40s -0:03:40 -
+Rule   sol88   1988    only    -       Jul     1       12:03:50s -0:03:50 -
+Rule   sol88   1988    only    -       Jul     2       12:04:00s -0:04:00 -
+Rule   sol88   1988    only    -       Jul     3       12:04:10s -0:04:10 -
+Rule   sol88   1988    only    -       Jul     4       12:04:25s -0:04:25 -
+Rule   sol88   1988    only    -       Jul     5       12:04:35s -0:04:35 -
+Rule   sol88   1988    only    -       Jul     6       12:04:45s -0:04:45 -
+Rule   sol88   1988    only    -       Jul     7       12:04:55s -0:04:55 -
+Rule   sol88   1988    only    -       Jul     8       12:05:05s -0:05:05 -
+Rule   sol88   1988    only    -       Jul     9       12:05:10s -0:05:10 -
+Rule   sol88   1988    only    -       Jul     10      12:05:20s -0:05:20 -
+Rule   sol88   1988    only    -       Jul     11      12:05:30s -0:05:30 -
+Rule   sol88   1988    only    -       Jul     12      12:05:35s -0:05:35 -
+Rule   sol88   1988    only    -       Jul     13      12:05:45s -0:05:45 -
+Rule   sol88   1988    only    -       Jul     14      12:05:50s -0:05:50 -
+Rule   sol88   1988    only    -       Jul     15      12:05:55s -0:05:55 -
+Rule   sol88   1988    only    -       Jul     16      12:06:00s -0:06:00 -
+Rule   sol88   1988    only    -       Jul     17      12:06:05s -0:06:05 -
+Rule   sol88   1988    only    -       Jul     18      12:06:10s -0:06:10 -
+Rule   sol88   1988    only    -       Jul     19      12:06:15s -0:06:15 -
+Rule   sol88   1988    only    -       Jul     20      12:06:20s -0:06:20 -
+Rule   sol88   1988    only    -       Jul     21      12:06:25s -0:06:25 -
+Rule   sol88   1988    only    -       Jul     22      12:06:25s -0:06:25 -
+Rule   sol88   1988    only    -       Jul     23      12:06:25s -0:06:25 -
+Rule   sol88   1988    only    -       Jul     24      12:06:30s -0:06:30 -
+Rule   sol88   1988    only    -       Jul     25      12:06:30s -0:06:30 -
+Rule   sol88   1988    only    -       Jul     26      12:06:30s -0:06:30 -
+Rule   sol88   1988    only    -       Jul     27      12:06:30s -0:06:30 -
+Rule   sol88   1988    only    -       Jul     28      12:06:30s -0:06:30 -
+Rule   sol88   1988    only    -       Jul     29      12:06:25s -0:06:25 -
+Rule   sol88   1988    only    -       Jul     30      12:06:25s -0:06:25 -
+Rule   sol88   1988    only    -       Jul     31      12:06:20s -0:06:20 -
+Rule   sol88   1988    only    -       Aug     1       12:06:15s -0:06:15 -
+Rule   sol88   1988    only    -       Aug     2       12:06:15s -0:06:15 -
+Rule   sol88   1988    only    -       Aug     3       12:06:10s -0:06:10 -
+Rule   sol88   1988    only    -       Aug     4       12:06:05s -0:06:05 -
+Rule   sol88   1988    only    -       Aug     5       12:05:55s -0:05:55 -
+Rule   sol88   1988    only    -       Aug     6       12:05:50s -0:05:50 -
+Rule   sol88   1988    only    -       Aug     7       12:05:45s -0:05:45 -
+Rule   sol88   1988    only    -       Aug     8       12:05:35s -0:05:35 -
+Rule   sol88   1988    only    -       Aug     9       12:05:25s -0:05:25 -
+Rule   sol88   1988    only    -       Aug     10      12:05:20s -0:05:20 -
+Rule   sol88   1988    only    -       Aug     11      12:05:10s -0:05:10 -
+Rule   sol88   1988    only    -       Aug     12      12:05:00s -0:05:00 -
+Rule   sol88   1988    only    -       Aug     13      12:04:50s -0:04:50 -
+Rule   sol88   1988    only    -       Aug     14      12:04:35s -0:04:35 -
+Rule   sol88   1988    only    -       Aug     15      12:04:25s -0:04:25 -
+Rule   sol88   1988    only    -       Aug     16      12:04:15s -0:04:15 -
+Rule   sol88   1988    only    -       Aug     17      12:04:00s -0:04:00 -
+Rule   sol88   1988    only    -       Aug     18      12:03:50s -0:03:50 -
+Rule   sol88   1988    only    -       Aug     19      12:03:35s -0:03:35 -
+Rule   sol88   1988    only    -       Aug     20      12:03:20s -0:03:20 -
+Rule   sol88   1988    only    -       Aug     21      12:03:05s -0:03:05 -
+Rule   sol88   1988    only    -       Aug     22      12:02:50s -0:02:50 -
+Rule   sol88   1988    only    -       Aug     23      12:02:35s -0:02:35 -
+Rule   sol88   1988    only    -       Aug     24      12:02:20s -0:02:20 -
+Rule   sol88   1988    only    -       Aug     25      12:02:00s -0:02:00 -
+Rule   sol88   1988    only    -       Aug     26      12:01:45s -0:01:45 -
+Rule   sol88   1988    only    -       Aug     27      12:01:30s -0:01:30 -
+Rule   sol88   1988    only    -       Aug     28      12:01:10s -0:01:10 -
+Rule   sol88   1988    only    -       Aug     29      12:00:50s -0:00:50 -
+Rule   sol88   1988    only    -       Aug     30      12:00:35s -0:00:35 -
+Rule   sol88   1988    only    -       Aug     31      12:00:15s -0:00:15 -
+Rule   sol88   1988    only    -       Sep     1       11:59:55s 0:00:05 -
+Rule   sol88   1988    only    -       Sep     2       11:59:35s 0:00:25 -
+Rule   sol88   1988    only    -       Sep     3       11:59:20s 0:00:40 -
+Rule   sol88   1988    only    -       Sep     4       11:59:00s 0:01:00 -
+Rule   sol88   1988    only    -       Sep     5       11:58:40s 0:01:20 -
+Rule   sol88   1988    only    -       Sep     6       11:58:20s 0:01:40 -
+Rule   sol88   1988    only    -       Sep     7       11:58:00s 0:02:00 -
+Rule   sol88   1988    only    -       Sep     8       11:57:35s 0:02:25 -
+Rule   sol88   1988    only    -       Sep     9       11:57:15s 0:02:45 -
+Rule   sol88   1988    only    -       Sep     10      11:56:55s 0:03:05 -
+Rule   sol88   1988    only    -       Sep     11      11:56:35s 0:03:25 -
+Rule   sol88   1988    only    -       Sep     12      11:56:15s 0:03:45 -
+Rule   sol88   1988    only    -       Sep     13      11:55:50s 0:04:10 -
+Rule   sol88   1988    only    -       Sep     14      11:55:30s 0:04:30 -
+Rule   sol88   1988    only    -       Sep     15      11:55:10s 0:04:50 -
+Rule   sol88   1988    only    -       Sep     16      11:54:50s 0:05:10 -
+Rule   sol88   1988    only    -       Sep     17      11:54:25s 0:05:35 -
+Rule   sol88   1988    only    -       Sep     18      11:54:05s 0:05:55 -
+Rule   sol88   1988    only    -       Sep     19      11:53:45s 0:06:15 -
+Rule   sol88   1988    only    -       Sep     20      11:53:25s 0:06:35 -
+Rule   sol88   1988    only    -       Sep     21      11:53:00s 0:07:00 -
+Rule   sol88   1988    only    -       Sep     22      11:52:40s 0:07:20 -
+Rule   sol88   1988    only    -       Sep     23      11:52:20s 0:07:40 -
+Rule   sol88   1988    only    -       Sep     24      11:52:00s 0:08:00 -
+Rule   sol88   1988    only    -       Sep     25      11:51:40s 0:08:20 -
+Rule   sol88   1988    only    -       Sep     26      11:51:15s 0:08:45 -
+Rule   sol88   1988    only    -       Sep     27      11:50:55s 0:09:05 -
+Rule   sol88   1988    only    -       Sep     28      11:50:35s 0:09:25 -
+Rule   sol88   1988    only    -       Sep     29      11:50:15s 0:09:45 -
+Rule   sol88   1988    only    -       Sep     30      11:49:55s 0:10:05 -
+Rule   sol88   1988    only    -       Oct     1       11:49:35s 0:10:25 -
+Rule   sol88   1988    only    -       Oct     2       11:49:20s 0:10:40 -
+Rule   sol88   1988    only    -       Oct     3       11:49:00s 0:11:00 -
+Rule   sol88   1988    only    -       Oct     4       11:48:40s 0:11:20 -
+Rule   sol88   1988    only    -       Oct     5       11:48:25s 0:11:35 -
+Rule   sol88   1988    only    -       Oct     6       11:48:05s 0:11:55 -
+Rule   sol88   1988    only    -       Oct     7       11:47:50s 0:12:10 -
+Rule   sol88   1988    only    -       Oct     8       11:47:30s 0:12:30 -
+Rule   sol88   1988    only    -       Oct     9       11:47:15s 0:12:45 -
+Rule   sol88   1988    only    -       Oct     10      11:47:00s 0:13:00 -
+Rule   sol88   1988    only    -       Oct     11      11:46:45s 0:13:15 -
+Rule   sol88   1988    only    -       Oct     12      11:46:30s 0:13:30 -
+Rule   sol88   1988    only    -       Oct     13      11:46:15s 0:13:45 -
+Rule   sol88   1988    only    -       Oct     14      11:46:00s 0:14:00 -
+Rule   sol88   1988    only    -       Oct     15      11:45:45s 0:14:15 -
+Rule   sol88   1988    only    -       Oct     16      11:45:35s 0:14:25 -
+Rule   sol88   1988    only    -       Oct     17      11:45:20s 0:14:40 -
+Rule   sol88   1988    only    -       Oct     18      11:45:10s 0:14:50 -
+Rule   sol88   1988    only    -       Oct     19      11:45:00s 0:15:00 -
+Rule   sol88   1988    only    -       Oct     20      11:44:45s 0:15:15 -
+Rule   sol88   1988    only    -       Oct     21      11:44:40s 0:15:20 -
+Rule   sol88   1988    only    -       Oct     22      11:44:30s 0:15:30 -
+Rule   sol88   1988    only    -       Oct     23      11:44:20s 0:15:40 -
+Rule   sol88   1988    only    -       Oct     24      11:44:10s 0:15:50 -
+Rule   sol88   1988    only    -       Oct     25      11:44:05s 0:15:55 -
+Rule   sol88   1988    only    -       Oct     26      11:44:00s 0:16:00 -
+Rule   sol88   1988    only    -       Oct     27      11:43:55s 0:16:05 -
+Rule   sol88   1988    only    -       Oct     28      11:43:50s 0:16:10 -
+Rule   sol88   1988    only    -       Oct     29      11:43:45s 0:16:15 -
+Rule   sol88   1988    only    -       Oct     30      11:43:40s 0:16:20 -
+Rule   sol88   1988    only    -       Oct     31      11:43:40s 0:16:20 -
+Rule   sol88   1988    only    -       Nov     1       11:43:35s 0:16:25 -
+Rule   sol88   1988    only    -       Nov     2       11:43:35s 0:16:25 -
+Rule   sol88   1988    only    -       Nov     3       11:43:35s 0:16:25 -
+Rule   sol88   1988    only    -       Nov     4       11:43:35s 0:16:25 -
+Rule   sol88   1988    only    -       Nov     5       11:43:40s 0:16:20 -
+Rule   sol88   1988    only    -       Nov     6       11:43:40s 0:16:20 -
+Rule   sol88   1988    only    -       Nov     7       11:43:45s 0:16:15 -
+Rule   sol88   1988    only    -       Nov     8       11:43:45s 0:16:15 -
+Rule   sol88   1988    only    -       Nov     9       11:43:50s 0:16:10 -
+Rule   sol88   1988    only    -       Nov     10      11:44:00s 0:16:00 -
+Rule   sol88   1988    only    -       Nov     11      11:44:05s 0:15:55 -
+Rule   sol88   1988    only    -       Nov     12      11:44:10s 0:15:50 -
+Rule   sol88   1988    only    -       Nov     13      11:44:20s 0:15:40 -
+Rule   sol88   1988    only    -       Nov     14      11:44:30s 0:15:30 -
+Rule   sol88   1988    only    -       Nov     15      11:44:40s 0:15:20 -
+Rule   sol88   1988    only    -       Nov     16      11:44:50s 0:15:10 -
+Rule   sol88   1988    only    -       Nov     17      11:45:00s 0:15:00 -
+Rule   sol88   1988    only    -       Nov     18      11:45:15s 0:14:45 -
+Rule   sol88   1988    only    -       Nov     19      11:45:25s 0:14:35 -
+Rule   sol88   1988    only    -       Nov     20      11:45:40s 0:14:20 -
+Rule   sol88   1988    only    -       Nov     21      11:45:55s 0:14:05 -
+Rule   sol88   1988    only    -       Nov     22      11:46:10s 0:13:50 -
+Rule   sol88   1988    only    -       Nov     23      11:46:30s 0:13:30 -
+Rule   sol88   1988    only    -       Nov     24      11:46:45s 0:13:15 -
+Rule   sol88   1988    only    -       Nov     25      11:47:05s 0:12:55 -
+Rule   sol88   1988    only    -       Nov     26      11:47:20s 0:12:40 -
+Rule   sol88   1988    only    -       Nov     27      11:47:40s 0:12:20 -
+Rule   sol88   1988    only    -       Nov     28      11:48:00s 0:12:00 -
+Rule   sol88   1988    only    -       Nov     29      11:48:25s 0:11:35 -
+Rule   sol88   1988    only    -       Nov     30      11:48:45s 0:11:15 -
+Rule   sol88   1988    only    -       Dec     1       11:49:05s 0:10:55 -
+Rule   sol88   1988    only    -       Dec     2       11:49:30s 0:10:30 -
+Rule   sol88   1988    only    -       Dec     3       11:49:55s 0:10:05 -
+Rule   sol88   1988    only    -       Dec     4       11:50:15s 0:09:45 -
+Rule   sol88   1988    only    -       Dec     5       11:50:40s 0:09:20 -
+Rule   sol88   1988    only    -       Dec     6       11:51:05s 0:08:55 -
+Rule   sol88   1988    only    -       Dec     7       11:51:35s 0:08:25 -
+Rule   sol88   1988    only    -       Dec     8       11:52:00s 0:08:00 -
+Rule   sol88   1988    only    -       Dec     9       11:52:25s 0:07:35 -
+Rule   sol88   1988    only    -       Dec     10      11:52:55s 0:07:05 -
+Rule   sol88   1988    only    -       Dec     11      11:53:20s 0:06:40 -
+Rule   sol88   1988    only    -       Dec     12      11:53:50s 0:06:10 -
+Rule   sol88   1988    only    -       Dec     13      11:54:15s 0:05:45 -
+Rule   sol88   1988    only    -       Dec     14      11:54:45s 0:05:15 -
+Rule   sol88   1988    only    -       Dec     15      11:55:15s 0:04:45 -
+Rule   sol88   1988    only    -       Dec     16      11:55:45s 0:04:15 -
+Rule   sol88   1988    only    -       Dec     17      11:56:15s 0:03:45 -
+Rule   sol88   1988    only    -       Dec     18      11:56:40s 0:03:20 -
+Rule   sol88   1988    only    -       Dec     19      11:57:10s 0:02:50 -
+Rule   sol88   1988    only    -       Dec     20      11:57:40s 0:02:20 -
+Rule   sol88   1988    only    -       Dec     21      11:58:10s 0:01:50 -
+Rule   sol88   1988    only    -       Dec     22      11:58:40s 0:01:20 -
+Rule   sol88   1988    only    -       Dec     23      11:59:10s 0:00:50 -
+Rule   sol88   1988    only    -       Dec     24      11:59:40s 0:00:20 -
+Rule   sol88   1988    only    -       Dec     25      12:00:10s -0:00:10 -
+Rule   sol88   1988    only    -       Dec     26      12:00:40s -0:00:40 -
+Rule   sol88   1988    only    -       Dec     27      12:01:10s -0:01:10 -
+Rule   sol88   1988    only    -       Dec     28      12:01:40s -0:01:40 -
+Rule   sol88   1988    only    -       Dec     29      12:02:10s -0:02:10 -
+Rule   sol88   1988    only    -       Dec     30      12:02:35s -0:02:35 -
+Rule   sol88   1988    only    -       Dec     31      12:03:05s -0:03:05 -
+
+# Riyadh is at about 46 degrees 46 minutes East:  3 hrs, 7 mins, 4 secs
+# Before and after 1988, we'll operate on local mean solar time.
+
+# Zone NAME            GMTOFF  RULES/SAVE      FORMAT  [UNTIL]
+Zone   Asia/Riyadh88   3:07:04 -               zzz     1988
+                       3:07:04 sol88           zzz     1989
+                       3:07:04 -               zzz
+# For backward compatibility...
+Link   Asia/Riyadh88   Mideast/Riyadh88
diff --git a/extra/zoneinfo/solar89 b/extra/zoneinfo/solar89
new file mode 100644 (file)
index 0000000..8c48531
--- /dev/null
@@ -0,0 +1,393 @@
+# @(#)solar89  8.1
+
+# Apparent noon times below are for Riyadh; they're a bit off for other places.
+# Times were computed using a formula provided by the U. S. Naval Observatory:
+#      eqt = -105.8 * sin(l) + 596.2 * sin(2 * l) + 4.4 * sin(3 * l)
+#              -12.7 * sin(4 * l) - 429.0 * cos(l) - 2.1 * cos (2 * l)
+#              + 19.3 * cos(3 * l);
+# where l is the "mean longitude of the Sun" given by
+#      l = 279.642 degrees + 0.985647 * d
+# and d is the interval in days from January 0, 0 hours Universal Time
+# (equaling the day of the year plus the fraction of a day from zero hours).
+# The accuracy of the formula is plus or minus three seconds.
+#
+# Rounding to the nearest five seconds results in fewer than
+# 256 different "time types"--a limit that's faced because time types are
+# stored on disk as unsigned chars.
+
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   sol89   1989    only    -       Jan     1       12:03:35s -0:03:35 -
+Rule   sol89   1989    only    -       Jan     2       12:04:05s -0:04:05 -
+Rule   sol89   1989    only    -       Jan     3       12:04:30s -0:04:30 -
+Rule   sol89   1989    only    -       Jan     4       12:05:00s -0:05:00 -
+Rule   sol89   1989    only    -       Jan     5       12:05:25s -0:05:25 -
+Rule   sol89   1989    only    -       Jan     6       12:05:50s -0:05:50 -
+Rule   sol89   1989    only    -       Jan     7       12:06:15s -0:06:15 -
+Rule   sol89   1989    only    -       Jan     8       12:06:45s -0:06:45 -
+Rule   sol89   1989    only    -       Jan     9       12:07:10s -0:07:10 -
+Rule   sol89   1989    only    -       Jan     10      12:07:35s -0:07:35 -
+Rule   sol89   1989    only    -       Jan     11      12:07:55s -0:07:55 -
+Rule   sol89   1989    only    -       Jan     12      12:08:20s -0:08:20 -
+Rule   sol89   1989    only    -       Jan     13      12:08:45s -0:08:45 -
+Rule   sol89   1989    only    -       Jan     14      12:09:05s -0:09:05 -
+Rule   sol89   1989    only    -       Jan     15      12:09:25s -0:09:25 -
+Rule   sol89   1989    only    -       Jan     16      12:09:45s -0:09:45 -
+Rule   sol89   1989    only    -       Jan     17      12:10:05s -0:10:05 -
+Rule   sol89   1989    only    -       Jan     18      12:10:25s -0:10:25 -
+Rule   sol89   1989    only    -       Jan     19      12:10:45s -0:10:45 -
+Rule   sol89   1989    only    -       Jan     20      12:11:05s -0:11:05 -
+Rule   sol89   1989    only    -       Jan     21      12:11:20s -0:11:20 -
+Rule   sol89   1989    only    -       Jan     22      12:11:35s -0:11:35 -
+Rule   sol89   1989    only    -       Jan     23      12:11:55s -0:11:55 -
+Rule   sol89   1989    only    -       Jan     24      12:12:10s -0:12:10 -
+Rule   sol89   1989    only    -       Jan     25      12:12:20s -0:12:20 -
+Rule   sol89   1989    only    -       Jan     26      12:12:35s -0:12:35 -
+Rule   sol89   1989    only    -       Jan     27      12:12:50s -0:12:50 -
+Rule   sol89   1989    only    -       Jan     28      12:13:00s -0:13:00 -
+Rule   sol89   1989    only    -       Jan     29      12:13:10s -0:13:10 -
+Rule   sol89   1989    only    -       Jan     30      12:13:20s -0:13:20 -
+Rule   sol89   1989    only    -       Jan     31      12:13:30s -0:13:30 -
+Rule   sol89   1989    only    -       Feb     1       12:13:40s -0:13:40 -
+Rule   sol89   1989    only    -       Feb     2       12:13:45s -0:13:45 -
+Rule   sol89   1989    only    -       Feb     3       12:13:55s -0:13:55 -
+Rule   sol89   1989    only    -       Feb     4       12:14:00s -0:14:00 -
+Rule   sol89   1989    only    -       Feb     5       12:14:05s -0:14:05 -
+Rule   sol89   1989    only    -       Feb     6       12:14:10s -0:14:10 -
+Rule   sol89   1989    only    -       Feb     7       12:14:10s -0:14:10 -
+Rule   sol89   1989    only    -       Feb     8       12:14:15s -0:14:15 -
+Rule   sol89   1989    only    -       Feb     9       12:14:15s -0:14:15 -
+Rule   sol89   1989    only    -       Feb     10      12:14:20s -0:14:20 -
+Rule   sol89   1989    only    -       Feb     11      12:14:20s -0:14:20 -
+Rule   sol89   1989    only    -       Feb     12      12:14:20s -0:14:20 -
+Rule   sol89   1989    only    -       Feb     13      12:14:15s -0:14:15 -
+Rule   sol89   1989    only    -       Feb     14      12:14:15s -0:14:15 -
+Rule   sol89   1989    only    -       Feb     15      12:14:10s -0:14:10 -
+Rule   sol89   1989    only    -       Feb     16      12:14:10s -0:14:10 -
+Rule   sol89   1989    only    -       Feb     17      12:14:05s -0:14:05 -
+Rule   sol89   1989    only    -       Feb     18      12:14:00s -0:14:00 -
+Rule   sol89   1989    only    -       Feb     19      12:13:55s -0:13:55 -
+Rule   sol89   1989    only    -       Feb     20      12:13:50s -0:13:50 -
+Rule   sol89   1989    only    -       Feb     21      12:13:40s -0:13:40 -
+Rule   sol89   1989    only    -       Feb     22      12:13:35s -0:13:35 -
+Rule   sol89   1989    only    -       Feb     23      12:13:25s -0:13:25 -
+Rule   sol89   1989    only    -       Feb     24      12:13:15s -0:13:15 -
+Rule   sol89   1989    only    -       Feb     25      12:13:05s -0:13:05 -
+Rule   sol89   1989    only    -       Feb     26      12:12:55s -0:12:55 -
+Rule   sol89   1989    only    -       Feb     27      12:12:45s -0:12:45 -
+Rule   sol89   1989    only    -       Feb     28      12:12:35s -0:12:35 -
+Rule   sol89   1989    only    -       Mar     1       12:12:25s -0:12:25 -
+Rule   sol89   1989    only    -       Mar     2       12:12:10s -0:12:10 -
+Rule   sol89   1989    only    -       Mar     3       12:12:00s -0:12:00 -
+Rule   sol89   1989    only    -       Mar     4       12:11:45s -0:11:45 -
+Rule   sol89   1989    only    -       Mar     5       12:11:35s -0:11:35 -
+Rule   sol89   1989    only    -       Mar     6       12:11:20s -0:11:20 -
+Rule   sol89   1989    only    -       Mar     7       12:11:05s -0:11:05 -
+Rule   sol89   1989    only    -       Mar     8       12:10:50s -0:10:50 -
+Rule   sol89   1989    only    -       Mar     9       12:10:35s -0:10:35 -
+Rule   sol89   1989    only    -       Mar     10      12:10:20s -0:10:20 -
+Rule   sol89   1989    only    -       Mar     11      12:10:05s -0:10:05 -
+Rule   sol89   1989    only    -       Mar     12      12:09:50s -0:09:50 -
+Rule   sol89   1989    only    -       Mar     13      12:09:30s -0:09:30 -
+Rule   sol89   1989    only    -       Mar     14      12:09:15s -0:09:15 -
+Rule   sol89   1989    only    -       Mar     15      12:09:00s -0:09:00 -
+Rule   sol89   1989    only    -       Mar     16      12:08:40s -0:08:40 -
+Rule   sol89   1989    only    -       Mar     17      12:08:25s -0:08:25 -
+Rule   sol89   1989    only    -       Mar     18      12:08:05s -0:08:05 -
+Rule   sol89   1989    only    -       Mar     19      12:07:50s -0:07:50 -
+Rule   sol89   1989    only    -       Mar     20      12:07:30s -0:07:30 -
+Rule   sol89   1989    only    -       Mar     21      12:07:15s -0:07:15 -
+Rule   sol89   1989    only    -       Mar     22      12:06:55s -0:06:55 -
+Rule   sol89   1989    only    -       Mar     23      12:06:35s -0:06:35 -
+Rule   sol89   1989    only    -       Mar     24      12:06:20s -0:06:20 -
+Rule   sol89   1989    only    -       Mar     25      12:06:00s -0:06:00 -
+Rule   sol89   1989    only    -       Mar     26      12:05:40s -0:05:40 -
+Rule   sol89   1989    only    -       Mar     27      12:05:25s -0:05:25 -
+Rule   sol89   1989    only    -       Mar     28      12:05:05s -0:05:05 -
+Rule   sol89   1989    only    -       Mar     29      12:04:50s -0:04:50 -
+Rule   sol89   1989    only    -       Mar     30      12:04:30s -0:04:30 -
+Rule   sol89   1989    only    -       Mar     31      12:04:10s -0:04:10 -
+Rule   sol89   1989    only    -       Apr     1       12:03:55s -0:03:55 -
+Rule   sol89   1989    only    -       Apr     2       12:03:35s -0:03:35 -
+Rule   sol89   1989    only    -       Apr     3       12:03:20s -0:03:20 -
+Rule   sol89   1989    only    -       Apr     4       12:03:00s -0:03:00 -
+Rule   sol89   1989    only    -       Apr     5       12:02:45s -0:02:45 -
+Rule   sol89   1989    only    -       Apr     6       12:02:25s -0:02:25 -
+Rule   sol89   1989    only    -       Apr     7       12:02:10s -0:02:10 -
+Rule   sol89   1989    only    -       Apr     8       12:01:50s -0:01:50 -
+Rule   sol89   1989    only    -       Apr     9       12:01:35s -0:01:35 -
+Rule   sol89   1989    only    -       Apr     10      12:01:20s -0:01:20 -
+Rule   sol89   1989    only    -       Apr     11      12:01:05s -0:01:05 -
+Rule   sol89   1989    only    -       Apr     12      12:00:50s -0:00:50 -
+Rule   sol89   1989    only    -       Apr     13      12:00:35s -0:00:35 -
+Rule   sol89   1989    only    -       Apr     14      12:00:20s -0:00:20 -
+Rule   sol89   1989    only    -       Apr     15      12:00:05s -0:00:05 -
+Rule   sol89   1989    only    -       Apr     16      11:59:50s 0:00:10 -
+Rule   sol89   1989    only    -       Apr     17      11:59:35s 0:00:25 -
+Rule   sol89   1989    only    -       Apr     18      11:59:20s 0:00:40 -
+Rule   sol89   1989    only    -       Apr     19      11:59:10s 0:00:50 -
+Rule   sol89   1989    only    -       Apr     20      11:58:55s 0:01:05 -
+Rule   sol89   1989    only    -       Apr     21      11:58:45s 0:01:15 -
+Rule   sol89   1989    only    -       Apr     22      11:58:30s 0:01:30 -
+Rule   sol89   1989    only    -       Apr     23      11:58:20s 0:01:40 -
+Rule   sol89   1989    only    -       Apr     24      11:58:10s 0:01:50 -
+Rule   sol89   1989    only    -       Apr     25      11:58:00s 0:02:00 -
+Rule   sol89   1989    only    -       Apr     26      11:57:50s 0:02:10 -
+Rule   sol89   1989    only    -       Apr     27      11:57:40s 0:02:20 -
+Rule   sol89   1989    only    -       Apr     28      11:57:30s 0:02:30 -
+Rule   sol89   1989    only    -       Apr     29      11:57:20s 0:02:40 -
+Rule   sol89   1989    only    -       Apr     30      11:57:15s 0:02:45 -
+Rule   sol89   1989    only    -       May     1       11:57:05s 0:02:55 -
+Rule   sol89   1989    only    -       May     2       11:57:00s 0:03:00 -
+Rule   sol89   1989    only    -       May     3       11:56:50s 0:03:10 -
+Rule   sol89   1989    only    -       May     4       11:56:45s 0:03:15 -
+Rule   sol89   1989    only    -       May     5       11:56:40s 0:03:20 -
+Rule   sol89   1989    only    -       May     6       11:56:35s 0:03:25 -
+Rule   sol89   1989    only    -       May     7       11:56:30s 0:03:30 -
+Rule   sol89   1989    only    -       May     8       11:56:30s 0:03:30 -
+Rule   sol89   1989    only    -       May     9       11:56:25s 0:03:35 -
+Rule   sol89   1989    only    -       May     10      11:56:25s 0:03:35 -
+Rule   sol89   1989    only    -       May     11      11:56:20s 0:03:40 -
+Rule   sol89   1989    only    -       May     12      11:56:20s 0:03:40 -
+Rule   sol89   1989    only    -       May     13      11:56:20s 0:03:40 -
+Rule   sol89   1989    only    -       May     14      11:56:20s 0:03:40 -
+Rule   sol89   1989    only    -       May     15      11:56:20s 0:03:40 -
+Rule   sol89   1989    only    -       May     16      11:56:20s 0:03:40 -
+Rule   sol89   1989    only    -       May     17      11:56:20s 0:03:40 -
+Rule   sol89   1989    only    -       May     18      11:56:25s 0:03:35 -
+Rule   sol89   1989    only    -       May     19      11:56:25s 0:03:35 -
+Rule   sol89   1989    only    -       May     20      11:56:30s 0:03:30 -
+Rule   sol89   1989    only    -       May     21      11:56:35s 0:03:25 -
+Rule   sol89   1989    only    -       May     22      11:56:35s 0:03:25 -
+Rule   sol89   1989    only    -       May     23      11:56:40s 0:03:20 -
+Rule   sol89   1989    only    -       May     24      11:56:45s 0:03:15 -
+Rule   sol89   1989    only    -       May     25      11:56:55s 0:03:05 -
+Rule   sol89   1989    only    -       May     26      11:57:00s 0:03:00 -
+Rule   sol89   1989    only    -       May     27      11:57:05s 0:02:55 -
+Rule   sol89   1989    only    -       May     28      11:57:15s 0:02:45 -
+Rule   sol89   1989    only    -       May     29      11:57:20s 0:02:40 -
+Rule   sol89   1989    only    -       May     30      11:57:30s 0:02:30 -
+Rule   sol89   1989    only    -       May     31      11:57:35s 0:02:25 -
+Rule   sol89   1989    only    -       Jun     1       11:57:45s 0:02:15 -
+Rule   sol89   1989    only    -       Jun     2       11:57:55s 0:02:05 -
+Rule   sol89   1989    only    -       Jun     3       11:58:05s 0:01:55 -
+Rule   sol89   1989    only    -       Jun     4       11:58:15s 0:01:45 -
+Rule   sol89   1989    only    -       Jun     5       11:58:25s 0:01:35 -
+Rule   sol89   1989    only    -       Jun     6       11:58:35s 0:01:25 -
+Rule   sol89   1989    only    -       Jun     7       11:58:45s 0:01:15 -
+Rule   sol89   1989    only    -       Jun     8       11:59:00s 0:01:00 -
+Rule   sol89   1989    only    -       Jun     9       11:59:10s 0:00:50 -
+Rule   sol89   1989    only    -       Jun     10      11:59:20s 0:00:40 -
+Rule   sol89   1989    only    -       Jun     11      11:59:35s 0:00:25 -
+Rule   sol89   1989    only    -       Jun     12      11:59:45s 0:00:15 -
+Rule   sol89   1989    only    -       Jun     13      12:00:00s 0:00:00 -
+Rule   sol89   1989    only    -       Jun     14      12:00:10s -0:00:10 -
+Rule   sol89   1989    only    -       Jun     15      12:00:25s -0:00:25 -
+Rule   sol89   1989    only    -       Jun     16      12:00:35s -0:00:35 -
+Rule   sol89   1989    only    -       Jun     17      12:00:50s -0:00:50 -
+Rule   sol89   1989    only    -       Jun     18      12:01:05s -0:01:05 -
+Rule   sol89   1989    only    -       Jun     19      12:01:15s -0:01:15 -
+Rule   sol89   1989    only    -       Jun     20      12:01:30s -0:01:30 -
+Rule   sol89   1989    only    -       Jun     21      12:01:40s -0:01:40 -
+Rule   sol89   1989    only    -       Jun     22      12:01:55s -0:01:55 -
+Rule   sol89   1989    only    -       Jun     23      12:02:10s -0:02:10 -
+Rule   sol89   1989    only    -       Jun     24      12:02:20s -0:02:20 -
+Rule   sol89   1989    only    -       Jun     25      12:02:35s -0:02:35 -
+Rule   sol89   1989    only    -       Jun     26      12:02:45s -0:02:45 -
+Rule   sol89   1989    only    -       Jun     27      12:03:00s -0:03:00 -
+Rule   sol89   1989    only    -       Jun     28      12:03:10s -0:03:10 -
+Rule   sol89   1989    only    -       Jun     29      12:03:25s -0:03:25 -
+Rule   sol89   1989    only    -       Jun     30      12:03:35s -0:03:35 -
+Rule   sol89   1989    only    -       Jul     1       12:03:45s -0:03:45 -
+Rule   sol89   1989    only    -       Jul     2       12:04:00s -0:04:00 -
+Rule   sol89   1989    only    -       Jul     3       12:04:10s -0:04:10 -
+Rule   sol89   1989    only    -       Jul     4       12:04:20s -0:04:20 -
+Rule   sol89   1989    only    -       Jul     5       12:04:30s -0:04:30 -
+Rule   sol89   1989    only    -       Jul     6       12:04:40s -0:04:40 -
+Rule   sol89   1989    only    -       Jul     7       12:04:50s -0:04:50 -
+Rule   sol89   1989    only    -       Jul     8       12:05:00s -0:05:00 -
+Rule   sol89   1989    only    -       Jul     9       12:05:10s -0:05:10 -
+Rule   sol89   1989    only    -       Jul     10      12:05:20s -0:05:20 -
+Rule   sol89   1989    only    -       Jul     11      12:05:25s -0:05:25 -
+Rule   sol89   1989    only    -       Jul     12      12:05:35s -0:05:35 -
+Rule   sol89   1989    only    -       Jul     13      12:05:40s -0:05:40 -
+Rule   sol89   1989    only    -       Jul     14      12:05:50s -0:05:50 -
+Rule   sol89   1989    only    -       Jul     15      12:05:55s -0:05:55 -
+Rule   sol89   1989    only    -       Jul     16      12:06:00s -0:06:00 -
+Rule   sol89   1989    only    -       Jul     17      12:06:05s -0:06:05 -
+Rule   sol89   1989    only    -       Jul     18      12:06:10s -0:06:10 -
+Rule   sol89   1989    only    -       Jul     19      12:06:15s -0:06:15 -
+Rule   sol89   1989    only    -       Jul     20      12:06:20s -0:06:20 -
+Rule   sol89   1989    only    -       Jul     21      12:06:20s -0:06:20 -
+Rule   sol89   1989    only    -       Jul     22      12:06:25s -0:06:25 -
+Rule   sol89   1989    only    -       Jul     23      12:06:25s -0:06:25 -
+Rule   sol89   1989    only    -       Jul     24      12:06:30s -0:06:30 -
+Rule   sol89   1989    only    -       Jul     25      12:06:30s -0:06:30 -
+Rule   sol89   1989    only    -       Jul     26      12:06:30s -0:06:30 -
+Rule   sol89   1989    only    -       Jul     27      12:06:30s -0:06:30 -
+Rule   sol89   1989    only    -       Jul     28      12:06:30s -0:06:30 -
+Rule   sol89   1989    only    -       Jul     29      12:06:25s -0:06:25 -
+Rule   sol89   1989    only    -       Jul     30      12:06:25s -0:06:25 -
+Rule   sol89   1989    only    -       Jul     31      12:06:20s -0:06:20 -
+Rule   sol89   1989    only    -       Aug     1       12:06:20s -0:06:20 -
+Rule   sol89   1989    only    -       Aug     2       12:06:15s -0:06:15 -
+Rule   sol89   1989    only    -       Aug     3       12:06:10s -0:06:10 -
+Rule   sol89   1989    only    -       Aug     4       12:06:05s -0:06:05 -
+Rule   sol89   1989    only    -       Aug     5       12:06:00s -0:06:00 -
+Rule   sol89   1989    only    -       Aug     6       12:05:50s -0:05:50 -
+Rule   sol89   1989    only    -       Aug     7       12:05:45s -0:05:45 -
+Rule   sol89   1989    only    -       Aug     8       12:05:35s -0:05:35 -
+Rule   sol89   1989    only    -       Aug     9       12:05:30s -0:05:30 -
+Rule   sol89   1989    only    -       Aug     10      12:05:20s -0:05:20 -
+Rule   sol89   1989    only    -       Aug     11      12:05:10s -0:05:10 -
+Rule   sol89   1989    only    -       Aug     12      12:05:00s -0:05:00 -
+Rule   sol89   1989    only    -       Aug     13      12:04:50s -0:04:50 -
+Rule   sol89   1989    only    -       Aug     14      12:04:40s -0:04:40 -
+Rule   sol89   1989    only    -       Aug     15      12:04:30s -0:04:30 -
+Rule   sol89   1989    only    -       Aug     16      12:04:15s -0:04:15 -
+Rule   sol89   1989    only    -       Aug     17      12:04:05s -0:04:05 -
+Rule   sol89   1989    only    -       Aug     18      12:03:50s -0:03:50 -
+Rule   sol89   1989    only    -       Aug     19      12:03:35s -0:03:35 -
+Rule   sol89   1989    only    -       Aug     20      12:03:25s -0:03:25 -
+Rule   sol89   1989    only    -       Aug     21      12:03:10s -0:03:10 -
+Rule   sol89   1989    only    -       Aug     22      12:02:55s -0:02:55 -
+Rule   sol89   1989    only    -       Aug     23      12:02:40s -0:02:40 -
+Rule   sol89   1989    only    -       Aug     24      12:02:20s -0:02:20 -
+Rule   sol89   1989    only    -       Aug     25      12:02:05s -0:02:05 -
+Rule   sol89   1989    only    -       Aug     26      12:01:50s -0:01:50 -
+Rule   sol89   1989    only    -       Aug     27      12:01:30s -0:01:30 -
+Rule   sol89   1989    only    -       Aug     28      12:01:15s -0:01:15 -
+Rule   sol89   1989    only    -       Aug     29      12:00:55s -0:00:55 -
+Rule   sol89   1989    only    -       Aug     30      12:00:40s -0:00:40 -
+Rule   sol89   1989    only    -       Aug     31      12:00:20s -0:00:20 -
+Rule   sol89   1989    only    -       Sep     1       12:00:00s 0:00:00 -
+Rule   sol89   1989    only    -       Sep     2       11:59:45s 0:00:15 -
+Rule   sol89   1989    only    -       Sep     3       11:59:25s 0:00:35 -
+Rule   sol89   1989    only    -       Sep     4       11:59:05s 0:00:55 -
+Rule   sol89   1989    only    -       Sep     5       11:58:45s 0:01:15 -
+Rule   sol89   1989    only    -       Sep     6       11:58:25s 0:01:35 -
+Rule   sol89   1989    only    -       Sep     7       11:58:05s 0:01:55 -
+Rule   sol89   1989    only    -       Sep     8       11:57:45s 0:02:15 -
+Rule   sol89   1989    only    -       Sep     9       11:57:20s 0:02:40 -
+Rule   sol89   1989    only    -       Sep     10      11:57:00s 0:03:00 -
+Rule   sol89   1989    only    -       Sep     11      11:56:40s 0:03:20 -
+Rule   sol89   1989    only    -       Sep     12      11:56:20s 0:03:40 -
+Rule   sol89   1989    only    -       Sep     13      11:56:00s 0:04:00 -
+Rule   sol89   1989    only    -       Sep     14      11:55:35s 0:04:25 -
+Rule   sol89   1989    only    -       Sep     15      11:55:15s 0:04:45 -
+Rule   sol89   1989    only    -       Sep     16      11:54:55s 0:05:05 -
+Rule   sol89   1989    only    -       Sep     17      11:54:35s 0:05:25 -
+Rule   sol89   1989    only    -       Sep     18      11:54:10s 0:05:50 -
+Rule   sol89   1989    only    -       Sep     19      11:53:50s 0:06:10 -
+Rule   sol89   1989    only    -       Sep     20      11:53:30s 0:06:30 -
+Rule   sol89   1989    only    -       Sep     21      11:53:10s 0:06:50 -
+Rule   sol89   1989    only    -       Sep     22      11:52:45s 0:07:15 -
+Rule   sol89   1989    only    -       Sep     23      11:52:25s 0:07:35 -
+Rule   sol89   1989    only    -       Sep     24      11:52:05s 0:07:55 -
+Rule   sol89   1989    only    -       Sep     25      11:51:45s 0:08:15 -
+Rule   sol89   1989    only    -       Sep     26      11:51:25s 0:08:35 -
+Rule   sol89   1989    only    -       Sep     27      11:51:05s 0:08:55 -
+Rule   sol89   1989    only    -       Sep     28      11:50:40s 0:09:20 -
+Rule   sol89   1989    only    -       Sep     29      11:50:20s 0:09:40 -
+Rule   sol89   1989    only    -       Sep     30      11:50:00s 0:10:00 -
+Rule   sol89   1989    only    -       Oct     1       11:49:45s 0:10:15 -
+Rule   sol89   1989    only    -       Oct     2       11:49:25s 0:10:35 -
+Rule   sol89   1989    only    -       Oct     3       11:49:05s 0:10:55 -
+Rule   sol89   1989    only    -       Oct     4       11:48:45s 0:11:15 -
+Rule   sol89   1989    only    -       Oct     5       11:48:30s 0:11:30 -
+Rule   sol89   1989    only    -       Oct     6       11:48:10s 0:11:50 -
+Rule   sol89   1989    only    -       Oct     7       11:47:50s 0:12:10 -
+Rule   sol89   1989    only    -       Oct     8       11:47:35s 0:12:25 -
+Rule   sol89   1989    only    -       Oct     9       11:47:20s 0:12:40 -
+Rule   sol89   1989    only    -       Oct     10      11:47:00s 0:13:00 -
+Rule   sol89   1989    only    -       Oct     11      11:46:45s 0:13:15 -
+Rule   sol89   1989    only    -       Oct     12      11:46:30s 0:13:30 -
+Rule   sol89   1989    only    -       Oct     13      11:46:15s 0:13:45 -
+Rule   sol89   1989    only    -       Oct     14      11:46:00s 0:14:00 -
+Rule   sol89   1989    only    -       Oct     15      11:45:50s 0:14:10 -
+Rule   sol89   1989    only    -       Oct     16      11:45:35s 0:14:25 -
+Rule   sol89   1989    only    -       Oct     17      11:45:20s 0:14:40 -
+Rule   sol89   1989    only    -       Oct     18      11:45:10s 0:14:50 -
+Rule   sol89   1989    only    -       Oct     19      11:45:00s 0:15:00 -
+Rule   sol89   1989    only    -       Oct     20      11:44:50s 0:15:10 -
+Rule   sol89   1989    only    -       Oct     21      11:44:40s 0:15:20 -
+Rule   sol89   1989    only    -       Oct     22      11:44:30s 0:15:30 -
+Rule   sol89   1989    only    -       Oct     23      11:44:20s 0:15:40 -
+Rule   sol89   1989    only    -       Oct     24      11:44:10s 0:15:50 -
+Rule   sol89   1989    only    -       Oct     25      11:44:05s 0:15:55 -
+Rule   sol89   1989    only    -       Oct     26      11:44:00s 0:16:00 -
+Rule   sol89   1989    only    -       Oct     27      11:43:50s 0:16:10 -
+Rule   sol89   1989    only    -       Oct     28      11:43:45s 0:16:15 -
+Rule   sol89   1989    only    -       Oct     29      11:43:40s 0:16:20 -
+Rule   sol89   1989    only    -       Oct     30      11:43:40s 0:16:20 -
+Rule   sol89   1989    only    -       Oct     31      11:43:35s 0:16:25 -
+Rule   sol89   1989    only    -       Nov     1       11:43:35s 0:16:25 -
+Rule   sol89   1989    only    -       Nov     2       11:43:35s 0:16:25 -
+Rule   sol89   1989    only    -       Nov     3       11:43:30s 0:16:30 -
+Rule   sol89   1989    only    -       Nov     4       11:43:35s 0:16:25 -
+Rule   sol89   1989    only    -       Nov     5       11:43:35s 0:16:25 -
+Rule   sol89   1989    only    -       Nov     6       11:43:35s 0:16:25 -
+Rule   sol89   1989    only    -       Nov     7       11:43:40s 0:16:20 -
+Rule   sol89   1989    only    -       Nov     8       11:43:45s 0:16:15 -
+Rule   sol89   1989    only    -       Nov     9       11:43:50s 0:16:10 -
+Rule   sol89   1989    only    -       Nov     10      11:43:55s 0:16:05 -
+Rule   sol89   1989    only    -       Nov     11      11:44:00s 0:16:00 -
+Rule   sol89   1989    only    -       Nov     12      11:44:05s 0:15:55 -
+Rule   sol89   1989    only    -       Nov     13      11:44:15s 0:15:45 -
+Rule   sol89   1989    only    -       Nov     14      11:44:25s 0:15:35 -
+Rule   sol89   1989    only    -       Nov     15      11:44:35s 0:15:25 -
+Rule   sol89   1989    only    -       Nov     16      11:44:45s 0:15:15 -
+Rule   sol89   1989    only    -       Nov     17      11:44:55s 0:15:05 -
+Rule   sol89   1989    only    -       Nov     18      11:45:10s 0:14:50 -
+Rule   sol89   1989    only    -       Nov     19      11:45:20s 0:14:40 -
+Rule   sol89   1989    only    -       Nov     20      11:45:35s 0:14:25 -
+Rule   sol89   1989    only    -       Nov     21      11:45:50s 0:14:10 -
+Rule   sol89   1989    only    -       Nov     22      11:46:05s 0:13:55 -
+Rule   sol89   1989    only    -       Nov     23      11:46:25s 0:13:35 -
+Rule   sol89   1989    only    -       Nov     24      11:46:40s 0:13:20 -
+Rule   sol89   1989    only    -       Nov     25      11:47:00s 0:13:00 -
+Rule   sol89   1989    only    -       Nov     26      11:47:20s 0:12:40 -
+Rule   sol89   1989    only    -       Nov     27      11:47:35s 0:12:25 -
+Rule   sol89   1989    only    -       Nov     28      11:47:55s 0:12:05 -
+Rule   sol89   1989    only    -       Nov     29      11:48:20s 0:11:40 -
+Rule   sol89   1989    only    -       Nov     30      11:48:40s 0:11:20 -
+Rule   sol89   1989    only    -       Dec     1       11:49:00s 0:11:00 -
+Rule   sol89   1989    only    -       Dec     2       11:49:25s 0:10:35 -
+Rule   sol89   1989    only    -       Dec     3       11:49:50s 0:10:10 -
+Rule   sol89   1989    only    -       Dec     4       11:50:15s 0:09:45 -
+Rule   sol89   1989    only    -       Dec     5       11:50:35s 0:09:25 -
+Rule   sol89   1989    only    -       Dec     6       11:51:00s 0:09:00 -
+Rule   sol89   1989    only    -       Dec     7       11:51:30s 0:08:30 -
+Rule   sol89   1989    only    -       Dec     8       11:51:55s 0:08:05 -
+Rule   sol89   1989    only    -       Dec     9       11:52:20s 0:07:40 -
+Rule   sol89   1989    only    -       Dec     10      11:52:50s 0:07:10 -
+Rule   sol89   1989    only    -       Dec     11      11:53:15s 0:06:45 -
+Rule   sol89   1989    only    -       Dec     12      11:53:45s 0:06:15 -
+Rule   sol89   1989    only    -       Dec     13      11:54:10s 0:05:50 -
+Rule   sol89   1989    only    -       Dec     14      11:54:40s 0:05:20 -
+Rule   sol89   1989    only    -       Dec     15      11:55:10s 0:04:50 -
+Rule   sol89   1989    only    -       Dec     16      11:55:40s 0:04:20 -
+Rule   sol89   1989    only    -       Dec     17      11:56:05s 0:03:55 -
+Rule   sol89   1989    only    -       Dec     18      11:56:35s 0:03:25 -
+Rule   sol89   1989    only    -       Dec     19      11:57:05s 0:02:55 -
+Rule   sol89   1989    only    -       Dec     20      11:57:35s 0:02:25 -
+Rule   sol89   1989    only    -       Dec     21      11:58:05s 0:01:55 -
+Rule   sol89   1989    only    -       Dec     22      11:58:35s 0:01:25 -
+Rule   sol89   1989    only    -       Dec     23      11:59:05s 0:00:55 -
+Rule   sol89   1989    only    -       Dec     24      11:59:35s 0:00:25 -
+Rule   sol89   1989    only    -       Dec     25      12:00:05s -0:00:05 -
+Rule   sol89   1989    only    -       Dec     26      12:00:35s -0:00:35 -
+Rule   sol89   1989    only    -       Dec     27      12:01:05s -0:01:05 -
+Rule   sol89   1989    only    -       Dec     28      12:01:35s -0:01:35 -
+Rule   sol89   1989    only    -       Dec     29      12:02:00s -0:02:00 -
+Rule   sol89   1989    only    -       Dec     30      12:02:30s -0:02:30 -
+Rule   sol89   1989    only    -       Dec     31      12:03:00s -0:03:00 -
+
+# Riyadh is at about 46 degrees 46 minutes East:  3 hrs, 7 mins, 4 secs
+# Before and after 1989, we'll operate on local mean solar time.
+
+# Zone NAME            GMTOFF  RULES/SAVE      FORMAT  [UNTIL]
+Zone   Asia/Riyadh89   3:07:04 -               zzz     1989
+                       3:07:04 sol89           zzz     1990
+                       3:07:04 -               zzz
+# For backward compatibility...
+Link   Asia/Riyadh89   Mideast/Riyadh89
diff --git a/extra/zoneinfo/southamerica b/extra/zoneinfo/southamerica
new file mode 100644 (file)
index 0000000..5824b7f
--- /dev/null
@@ -0,0 +1,1473 @@
+# @(#)southamerica     8.34
+# <pre>
+
+# This data is by no means authoritative; if you think you know better,
+# go ahead and edit the file (and please send any changes to
+# tz@elsie.nci.nih.gov for general use in the future).
+
+# From Paul Eggert (2006-03-22):
+# A good source for time zone historical data outside the U.S. is
+# Thomas G. Shanks and Rique Pottenger, The International Atlas (6th edition),
+# San Diego: ACS Publications, Inc. (2003).
+#
+# Gwillim Law writes that a good source
+# for recent time zone data is the International Air Transport
+# Association's Standard Schedules Information Manual (IATA SSIM),
+# published semiannually.  Law sent in several helpful summaries
+# of the IATA's data after 1990.
+#
+# Except where otherwise noted, Shanks & Pottenger is the source for
+# entries through 1990, and IATA SSIM is the source for entries afterwards.
+#
+# Earlier editions of these tables used the North American style (e.g. ARST and
+# ARDT for Argentine Standard and Daylight Time), but the following quote
+# suggests that it's better to use European style (e.g. ART and ARST).
+#      I suggest the use of _Summer time_ instead of the more cumbersome
+#      _daylight-saving time_.  _Summer time_ seems to be in general use
+#      in Europe and South America.
+#      -- E O Cutler, _New York Times_ (1937-02-14), quoted in
+#      H L Mencken, _The American Language: Supplement I_ (1960), p 466
+#
+# Earlier editions of these tables also used the North American style
+# for time zones in Brazil, but this was incorrect, as Brazilians say
+# "summer time".  Reinaldo Goulart, a Sao Paulo businessman active in
+# the railroad sector, writes (1999-07-06):
+#      The subject of time zones is currently a matter of discussion/debate in
+#      Brazil.  Let's say that "the Brasilia time" is considered the
+#      "official time" because Brasilia is the capital city.
+#      The other three time zones are called "Brasilia time "minus one" or
+#      "plus one" or "plus two".  As far as I know there is no such
+#      name/designation as "Eastern Time" or "Central Time".
+# So I invented the following (English-language) abbreviations for now.
+# Corrections are welcome!
+#              std     dst
+#      -2:00   FNT     FNST    Fernando de Noronha
+#      -3:00   BRT     BRST    Brasilia
+#      -4:00   AMT     AMST    Amazon
+#      -5:00   ACT     ACST    Acre
+
+###############################################################################
+
+###############################################################################
+
+# Argentina
+
+# From Bob Devine (1988-01-28):
+# Argentina: first Sunday in October to first Sunday in April since 1976.
+# Double Summer time from 1969 to 1974.  Switches at midnight.
+
+# From U. S. Naval Observatory (1988-01-199):
+# ARGENTINA           3 H BEHIND   UTC
+
+# From Hernan G. Otero (1995-06-26):
+# I am sending modifications to the Argentine time zone table...
+# AR was chosen because they are the ISO letters that represent Argentina.
+
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Arg     1930    only    -       Dec      1      0:00    1:00    S
+Rule   Arg     1931    only    -       Apr      1      0:00    0       -
+Rule   Arg     1931    only    -       Oct     15      0:00    1:00    S
+Rule   Arg     1932    1940    -       Mar      1      0:00    0       -
+Rule   Arg     1932    1939    -       Nov      1      0:00    1:00    S
+Rule   Arg     1940    only    -       Jul      1      0:00    1:00    S
+Rule   Arg     1941    only    -       Jun     15      0:00    0       -
+Rule   Arg     1941    only    -       Oct     15      0:00    1:00    S
+Rule   Arg     1943    only    -       Aug      1      0:00    0       -
+Rule   Arg     1943    only    -       Oct     15      0:00    1:00    S
+Rule   Arg     1946    only    -       Mar      1      0:00    0       -
+Rule   Arg     1946    only    -       Oct      1      0:00    1:00    S
+Rule   Arg     1963    only    -       Oct      1      0:00    0       -
+Rule   Arg     1963    only    -       Dec     15      0:00    1:00    S
+Rule   Arg     1964    1966    -       Mar      1      0:00    0       -
+Rule   Arg     1964    1966    -       Oct     15      0:00    1:00    S
+Rule   Arg     1967    only    -       Apr      2      0:00    0       -
+Rule   Arg     1967    1968    -       Oct     Sun>=1  0:00    1:00    S
+Rule   Arg     1968    1969    -       Apr     Sun>=1  0:00    0       -
+Rule   Arg     1974    only    -       Jan     23      0:00    1:00    S
+Rule   Arg     1974    only    -       May      1      0:00    0       -
+Rule   Arg     1988    only    -       Dec      1      0:00    1:00    S
+#
+# From Hernan G. Otero (1995-06-26):
+# These corrections were contributed by InterSoft Argentina S.A.,
+# obtaining the data from the:
+# Talleres de Hidrografia Naval Argentina
+# (Argentine Naval Hydrography Institute)
+Rule   Arg     1989    1993    -       Mar     Sun>=1  0:00    0       -
+Rule   Arg     1989    1992    -       Oct     Sun>=15 0:00    1:00    S
+#
+# From Hernan G. Otero (1995-06-26):
+# From this moment on, the law that mandated the daylight saving
+# time corrections was derogated and no more modifications
+# to the time zones (for daylight saving) are now made.
+#
+# From Rives McDow (2000-01-10):
+# On October 3, 1999, 0:00 local, Argentina implemented daylight savings time,
+# which did not result in the switch of a time zone, as they stayed 9 hours
+# from the International Date Line.
+Rule   Arg     1999    only    -       Oct     Sun>=1  0:00    1:00    S
+# From Paul Eggert (2007-12-28):
+# DST was set to expire on March 5, not March 3, but since it was converted
+# to standard time on March 3 it's more convenient for us to pretend that
+# it ended on March 3.
+Rule   Arg     2000    only    -       Mar     3       0:00    0       -
+#
+# From Peter Gradelski via Steffen Thorsen (2000-03-01):
+# We just checked with our Sao Paulo office and they say the government of
+# Argentina decided not to become one of the countries that go on or off DST.
+# So Buenos Aires should be -3 hours from GMT at all times.
+#
+# From Fabian L. Arce Jofre (2000-04-04):
+# The law that claimed DST for Argentina was derogated by President Fernando
+# de la Rua on March 2, 2000, because it would make people spend more energy
+# in the winter time, rather than less.  The change took effect on March 3.
+#
+# From Mariano Absatz (2001-06-06):
+# one of the major newspapers here in Argentina said that the 1999
+# Timezone Law (which never was effectively applied) will (would?) be
+# in effect.... The article is at
+# http://ar.clarin.com/diario/2001-06-06/e-01701.htm
+# ... The Law itself is "Ley No 25155", sanctioned on 1999-08-25, enacted
+# 1999-09-17, and published 1999-09-21.  The official publication is at:
+# http://www.boletin.jus.gov.ar/BON/Primera/1999/09-Septiembre/21/PDF/BO21-09-99LEG.PDF
+# Regretfully, you have to subscribe (and pay) for the on-line version....
+#
+# (2001-06-12):
+# the timezone for Argentina will not change next Sunday.
+# Apparently it will do so on Sunday 24th....
+# http://ar.clarin.com/diario/2001-06-12/s-03501.htm
+#
+# (2001-06-25):
+# Last Friday (yes, the last working day before the date of the change), the
+# Senate annulled the 1999 law that introduced the changes later postponed.
+# http://www.clarin.com.ar/diario/2001-06-22/s-03601.htm
+# It remains the vote of the Deputies..., but it will be the same....
+# This kind of things had always been done this way in Argentina.
+# We are still -03:00 all year round in all of the country.
+#
+# From Steffen Thorsen (2007-12-21):
+# A user (Leonardo Chaim) reported that Argentina will adopt DST....
+# all of the country (all Zone-entries) are affected.  News reports like
+# http://www.lanacion.com.ar/opinion/nota.asp?nota_id=973037 indicate
+# that Argentina will use DST next year as well, from October to
+# March, although exact rules are not given.
+#
+# From Jesper Norgaard Welen (2007-12-26)
+# The last hurdle of Argentina DST is over, the proposal was approved in
+# the lower chamber too (Deputados) with a vote 192 for and 2 against.
+# By the way thanks to Mariano Absatz and Daniel Mario Vega for the link to
+# the original scanned proposal, where the dates and the zero hours are
+# clear and unambiguous...This is the article about final approval:
+# <a href="http://www.lanacion.com.ar/politica/nota.asp?nota_id=973996">
+# http://www.lanacion.com.ar/politica/nota.asp?nota_id=973996
+# </a>
+#
+# From Paul Eggert (2007-12-22):
+# For dates after mid-2008, the following rules are my guesses and
+# are quite possibly wrong, but are more likely than no DST at all.
+
+# From Alexander Krivenyshev (2008-09-05):
+# As per message from Carlos Alberto Fonseca Arauz (Nicaragua),
+# Argentina will start DST on Sunday October 19, 2008.
+#
+# <a href="http://www.worldtimezone.com/dst_news/dst_news_argentina03.html">
+# http://www.worldtimezone.com/dst_news/dst_news_argentina03.html
+# </a>
+# OR
+# <a href="http://www.impulsobaires.com.ar/nota.php?id=57832 (in spanish)">
+# http://www.impulsobaires.com.ar/nota.php?id=57832 (in spanish)
+# </a>
+
+# From Rodrigo Severo (2008-10-06):
+# Here is some info available at a Gentoo bug related to TZ on Argentina's DST:
+# ...
+# ------- Comment #1 from [jmdocile]  2008-10-06 16:28 0000 -------
+# Hi, there is a problem with timezone-data-2008e and maybe with
+# timezone-data-2008f
+# Argentinian law [Number] 25.155 is no longer valid.
+# <a href="http://www.infoleg.gov.ar/infolegInternet/anexos/60000-64999/60036/norma.htm">
+# http://www.infoleg.gov.ar/infolegInternet/anexos/60000-64999/60036/norma.htm
+# </a>
+# The new one is law [Number] 26.350
+# <a href="http://www.infoleg.gov.ar/infolegInternet/anexos/135000-139999/136191/norma.htm">
+# http://www.infoleg.gov.ar/infolegInternet/anexos/135000-139999/136191/norma.htm
+# </a>
+# So there is no summer time in Argentina for now.
+
+# From Mariano Absatz (2008-10-20):
+# Decree 1693/2008 applies Law 26.350 for the summer 2008/2009 establishing DST in Argentina
+# From 2008-10-19 until 2009-03-15
+# <a href="http://www.boletinoficial.gov.ar/Bora.Portal/CustomControls/PdfContent.aspx?fp=16102008&pi=3&pf=4&s=0&sec=01">
+# http://www.boletinoficial.gov.ar/Bora.Portal/CustomControls/PdfContent.aspx?fp=16102008&pi=3&pf=4&s=0&sec=01
+# </a>
+#
+# Decree 1705/2008 excepting 12 Provinces from applying DST in the summer 2008/2009:
+# Catamarca, La Rioja, Mendoza, Salta, San Juan, San Luis, La Pampa, Neuquen, Rio Negro, Chubut, Santa Cruz
+# and Tierra del Fuego
+# <a href="http://www.boletinoficial.gov.ar/Bora.Portal/CustomControls/PdfContent.aspx?fp=17102008&pi=1&pf=1&s=0&sec=01">
+# http://www.boletinoficial.gov.ar/Bora.Portal/CustomControls/PdfContent.aspx?fp=17102008&pi=1&pf=1&s=0&sec=01
+# </a>
+#
+# Press release 235 dated Saturday October 18th, from the Government of the Province of Jujuy saying
+# it will not apply DST either (even when it was not included in Decree 1705/2008)
+# <a href="http://www.jujuy.gov.ar/index2/partes_prensa/18_10_08/235-181008.doc">
+# http://www.jujuy.gov.ar/index2/partes_prensa/18_10_08/235-181008.doc
+# </a>
+
+Rule   Arg     2007    only    -       Dec     30      0:00    1:00    S
+Rule   Arg     2008    max     -       Mar     Sun>=15 0:00    0       -
+Rule   Arg     2008    max     -       Oct     Sun>=15 0:00    1:00    S
+# From Mariano Absatz (2004-05-21):
+# Today it was officially published that the Province of Mendoza is changing
+# its timezone this winter... starting tomorrow night....
+# http://www.gobernac.mendoza.gov.ar/boletin/pdf/20040521-27158-normas.pdf
+# From Paul Eggert (2004-05-24):
+# It's Law No. 7,210.  This change is due to a public power emergency, so for
+# now we'll assume it's for this year only.
+#
+# From Paul Eggert (2006-03-22):
+# <a href="http://www.spicasc.net/horvera.html">
+# Hora de verano para la Republica Argentina (2003-06-08)
+# </a> says that standard time in Argentina from 1894-10-31
+# to 1920-05-01 was -4:16:48.25.  Go with this more-precise value
+# over Shanks & Pottenger.
+#
+# From Mariano Absatz (2004-06-05):
+# These media articles from a major newspaper mostly cover the current state:
+# http://www.lanacion.com.ar/04/05/27/de_604825.asp
+# http://www.lanacion.com.ar/04/05/28/de_605203.asp
+#
+# The following eight (8) provinces pulled clocks back to UTC-04:00 at
+# midnight Monday May 31st. (that is, the night between 05/31 and 06/01).
+# Apparently, all nine provinces would go back to UTC-03:00 at the same
+# time in October 17th.
+#
+# Catamarca, Chubut, La Rioja, San Juan, San Luis, Santa Cruz,
+# Tierra del Fuego, Tucuman.
+#
+# From Mariano Absatz (2004-06-14):
+# ... this weekend, the Province of Tucuman decided it'd go back to UTC-03:00
+# yesterday midnight (that is, at 24:00 Saturday 12th), since the people's
+# annoyance with the change is much higher than the power savings obtained....
+#
+# From Gwillim Law (2004-06-14):
+# http://www.lanacion.com.ar/04/06/10/de_609078.asp ...
+#     "The time change in Tierra del Fuego was a conflicted decision from
+#   the start.  The government had decreed that the measure would take
+#   effect on June 1, but a normative error forced the new time to begin
+#   three days earlier, from a Saturday to a Sunday....
+# Our understanding was that the change was originally scheduled to take place
+# on June 1 at 00:00 in Chubut, Santa Cruz, Tierra del Fuego (and some other
+# provinces).  Sunday was May 30, only two days earlier.  So the article
+# contains a contradiction.  I would give more credence to the Saturday/Sunday
+# date than the "three days earlier" phrase, and conclude that Tierra del
+# Fuego set its clocks back at 2004-05-30 00:00.
+#
+# From Steffen Thorsen (2004-10-05):
+# The previous law 7210 which changed the province of Mendoza's time zone
+# back in May have been modified slightly in a new law 7277, which set the
+# new end date to 2004-09-26 (original date was 2004-10-17).
+# http://www.gobernac.mendoza.gov.ar/boletin/pdf/20040924-27244-normas.pdf
+#
+# From Mariano Absatz (2004-10-05):
+# San Juan changed from UTC-03:00 to UTC-04:00 at midnight between
+# Sunday, May 30th and Monday, May 31st.  It changed back to UTC-03:00
+# at midnight between Saturday, July 24th and Sunday, July 25th....
+# http://www.sanjuan.gov.ar/prensa/archivo/000329.html
+# http://www.sanjuan.gov.ar/prensa/archivo/000426.html
+# http://www.sanjuan.gov.ar/prensa/archivo/000441.html
+
+# From Alex Krivenyshev (2008-01-17):
+# Here are articles that Argentina Province San Luis is planning to end DST
+# as earlier as upcoming Monday January 21, 2008 or February 2008:
+#
+# Provincia argentina retrasa reloj y marca diferencia con resto del pais
+# (Argentine Province delayed clock and mark difference with the rest of the
+# country)
+# <a href="http://cl.invertia.com/noticias/noticia.aspx?idNoticia=200801171849_EFE_ET4373&idtel">
+# http://cl.invertia.com/noticias/noticia.aspx?idNoticia=200801171849_EFE_ET4373&idtel
+# </a>
+#
+# Es inminente que en San Luis atrasen una hora los relojes
+# (It is imminent in San Luis clocks one hour delay)
+# <a href="http://www.lagaceta.com.ar/vernotae.asp?id_nota=253414">
+# http://www.lagaceta.com.ar/vernotae.asp?id_nota=253414
+# </a>
+#
+# <a href="http://www.worldtimezone.net/dst_news/dst_news_argentina02.html">
+# http://www.worldtimezone.net/dst_news/dst_news_argentina02.html
+# </a>
+
+# From Jesper Norgaard Welen (2008-01-18):
+# The page of the San Luis provincial government
+# <a href="http://www.sanluis.gov.ar/notas.asp?idCanal=0&id=22812">
+# http://www.sanluis.gov.ar/notas.asp?idCanal=0&id=22812
+# </a>
+# confirms what Alex Krivenyshev has earlier sent to the tz
+# emailing list about that San Luis plans to return to standard
+# time much earlier than the rest of the country. It also
+# confirms that upon request the provinces San Juan and Mendoza 
+# refused to follow San Luis in this change. 
+# 
+# The change is supposed to take place Monday the 21.st at 0:00
+# hours. As far as I understand it if this goes ahead, we need
+# a new timezone for San Luis (although there are also documented
+# independent changes in the southamerica file of San Luis in
+# 1990 and 1991 which has not been confirmed).
+
+# From Jesper Norgaard Welen (2008-01-25):
+# Unfortunately the below page has become defunct, about the San Luis
+# time change. Perhaps because it now is part of a group of pages "Most
+# important pages of 2008."
+#
+# You can use
+# <a href="http://www.sanluis.gov.ar/notas.asp?idCanal=8141&id=22834">
+# http://www.sanluis.gov.ar/notas.asp?idCanal=8141&id=22834
+# </a>
+# instead it seems. Or use "Buscador" from the main page of the San Luis
+# government, and fill in "huso" and click OK, and you will get 3 pages
+# from which the first one is identical to the above.
+
+# From Mariano Absatz (2008-01-28):
+# I can confirm that the Province of San Luis (and so far only that
+# province) decided to go back to UTC-3 effective midnight Jan 20th 2008
+# (that is, Monday 21st at 0:00 is the time the clocks were delayed back
+# 1 hour), and they intend to keep UTC-3 as their timezone all year round
+# (that is, unless they change their mind any minute now).
+#
+# So we'll have to add yet another city to 'southamerica' (I think San
+# Luis city is the mos populated city in the Province, so it'd be
+# America/Argentina/San_Luis... of course I can't remember if San Luis's
+# history of particular changes goes along with Mendoza or San Juan :-(
+# (I only remember not being able to collect hard facts about San Luis
+# back in 2004, when these provinces changed to UTC-4 for a few days, I
+# mailed them personally and never got an answer).
+
+# From Paul Eggert (2008-06-30):
+# Unless otherwise specified, data are from Shanks & Pottenger through 1992,
+# from the IATA otherwise.  As noted below, Shanks & Pottenger say that
+# America/Cordoba split into 6 subregions during 1991/1992, one of which
+# was America/San_Luis, but we haven't verified this yet so for now we'll
+# keep America/Cordoba a single region rather than splitting it into the
+# other 5 subregions.
+
+# From Mariano Absatz (2009-03-13):
+# Yesterday (with our usual 2-day notice) the Province of San Luis
+# decided that next Sunday instead of "staying" @utc-03:00 they will go
+# to utc-04:00 until the second Saturday in October...
+#
+# The press release is at
+# <a href="http://www.sanluis.gov.ar/SL/Paginas/NoticiaDetalle.asp?TemaId=1&InfoPrensaId=3102">
+# http://www.sanluis.gov.ar/SL/Paginas/NoticiaDetalle.asp?TemaId=1&InfoPrensaId=3102
+# </a>
+# (I couldn't find the decree, but
+# <a href="http://www.sanluis.gov.ar">
+# www.sanluis.gov.ar
+# <a/>
+# is the official page for the Province Government).
+#
+# There's also a note in only one of the major national papers (La Nación) at
+# <a href="http://www.lanacion.com.ar/nota.asp?nota_id=1107912">
+# http://www.lanacion.com.ar/nota.asp?nota_id=1107912
+# </a>
+# 
+# The press release says:
+#  (...) anunció que el próximo domingo a las 00:00 los puntanos deberán
+# atrasar una hora sus relojes.
+#
+# A partir de entonces, San Luis establecerá el huso horario propio de
+# la Provincia. De esta manera, durante el periodo del calendario anual
+# 2009, el cambio horario quedará comprendido entre las 00:00 del tercer
+# domingo de marzo y las 24:00 del segundo sábado de octubre.
+# Quick&dirty translation
+# (...) announced that next Sunday, at 00:00, Puntanos (the San Luis
+# inhabitants) will have to turn back one hour their clocks
+#
+# Since then, San Luis will establish its own Province timezone. Thus,
+# during 2009, this timezone change will run from 00:00 the third Sunday
+# in March until 24:00 of the second Saturday in October.
+
+# From Arthur David Olson (2009-03-16):
+# The unofficial claim at
+# <a href="http://www.timeanddate.com/news/time/san-luis-new-time-zone.html">
+# http://www.timeanddate.com/news/time/san-luis-new-time-zone.html
+# </a>
+# is that "The province will most likely follow the next daylight saving schedule,
+# which is planned for the second Sunday in October."
+
+#
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+#
+# Buenos Aires (BA), Capital Federal (CF),
+Zone America/Argentina/Buenos_Aires -3:53:48 - LMT 1894 Oct 31
+                       -4:16:48 -      CMT     1920 May # Cordoba Mean Time
+                       -4:00   -       ART     1930 Dec
+                       -4:00   Arg     AR%sT   1969 Oct  5
+                       -3:00   Arg     AR%sT   1999 Oct  3
+                       -4:00   Arg     AR%sT   2000 Mar  3
+                       -3:00   Arg     AR%sT
+#
+# Cordoba (CB), Santa Fe (SF), Entre Rios (ER), Corrientes (CN), Misiones (MN),
+# Chaco (CC), Formosa (FM), Santiago del Estero (SE)
+#
+# Shanks & Pottenger also make the following claims, which we haven't verified:
+# - Formosa switched to -3:00 on 1991-01-07.
+# - Misiones switched to -3:00 on 1990-12-29.
+# - Chaco switched to -3:00 on 1991-01-04.
+# - Santiago del Estero switched to -4:00 on 1991-04-01,
+#   then to -3:00 on 1991-04-26.
+#
+Zone America/Argentina/Cordoba -4:16:48 - LMT  1894 Oct 31
+                       -4:16:48 -      CMT     1920 May
+                       -4:00   -       ART     1930 Dec
+                       -4:00   Arg     AR%sT   1969 Oct  5
+                       -3:00   Arg     AR%sT   1991 Mar  3
+                       -4:00   -       WART    1991 Oct 20
+                       -3:00   Arg     AR%sT   1999 Oct  3
+                       -4:00   Arg     AR%sT   2000 Mar  3
+                       -3:00   Arg     AR%sT
+#
+# Salta (SA), La Pampa (LP), Neuquen (NQ), Rio Negro (RN)
+Zone America/Argentina/Salta -4:21:40 - LMT    1894 Oct 31
+                       -4:16:48 -      CMT     1920 May
+                       -4:00   -       ART     1930 Dec
+                       -4:00   Arg     AR%sT   1969 Oct  5
+                       -3:00   Arg     AR%sT   1991 Mar  3
+                       -4:00   -       WART    1991 Oct 20
+                       -3:00   Arg     AR%sT   1999 Oct  3
+                       -4:00   Arg     AR%sT   2000 Mar  3
+                       -3:00   Arg     AR%sT   2008 Oct 18
+                       -3:00   -       ART
+#
+# Tucuman (TM)
+Zone America/Argentina/Tucuman -4:20:52 - LMT  1894 Oct 31
+                       -4:16:48 -      CMT     1920 May
+                       -4:00   -       ART     1930 Dec
+                       -4:00   Arg     AR%sT   1969 Oct  5
+                       -3:00   Arg     AR%sT   1991 Mar  3
+                       -4:00   -       WART    1991 Oct 20
+                       -3:00   Arg     AR%sT   1999 Oct  3
+                       -4:00   Arg     AR%sT   2000 Mar  3
+                       -3:00   -       ART     2004 Jun  1
+                       -4:00   -       WART    2004 Jun 13
+                       -3:00   Arg     AR%sT
+#
+# La Rioja (LR)
+Zone America/Argentina/La_Rioja -4:27:24 - LMT 1894 Oct 31
+                       -4:16:48 -      CMT     1920 May
+                       -4:00   -       ART     1930 Dec
+                       -4:00   Arg     AR%sT   1969 Oct  5
+                       -3:00   Arg     AR%sT   1991 Mar  1
+                       -4:00   -       WART    1991 May  7
+                       -3:00   Arg     AR%sT   1999 Oct  3
+                       -4:00   Arg     AR%sT   2000 Mar  3
+                       -3:00   -       ART     2004 Jun  1
+                       -4:00   -       WART    2004 Jun 20
+                       -3:00   Arg     AR%sT   2008 Oct 18
+                       -3:00   -       ART
+#
+# San Juan (SJ)
+Zone America/Argentina/San_Juan -4:34:04 - LMT 1894 Oct 31
+                       -4:16:48 -      CMT     1920 May
+                       -4:00   -       ART     1930 Dec
+                       -4:00   Arg     AR%sT   1969 Oct  5
+                       -3:00   Arg     AR%sT   1991 Mar  1
+                       -4:00   -       WART    1991 May  7
+                       -3:00   Arg     AR%sT   1999 Oct  3
+                       -4:00   Arg     AR%sT   2000 Mar  3
+                       -3:00   -       ART     2004 May 31
+                       -4:00   -       WART    2004 Jul 25
+                       -3:00   Arg     AR%sT   2008 Oct 18
+                       -3:00   -       ART
+#
+# Jujuy (JY)
+Zone America/Argentina/Jujuy -4:21:12 -        LMT     1894 Oct 31
+                       -4:16:48 -      CMT     1920 May
+                       -4:00   -       ART     1930 Dec
+                       -4:00   Arg     AR%sT   1969 Oct  5
+                       -3:00   Arg     AR%sT   1990 Mar  4
+                       -4:00   -       WART    1990 Oct 28
+                       -4:00   1:00    WARST   1991 Mar 17
+                       -4:00   -       WART    1991 Oct  6
+                       -3:00   1:00    ARST    1992
+                       -3:00   Arg     AR%sT   1999 Oct  3
+                       -4:00   Arg     AR%sT   2000 Mar  3
+                       -3:00   Arg     AR%sT   2008 Oct 18
+                       -3:00   -       ART
+#
+# Catamarca (CT), Chubut (CH)
+Zone America/Argentina/Catamarca -4:23:08 - LMT        1894 Oct 31
+                       -4:16:48 -      CMT     1920 May
+                       -4:00   -       ART     1930 Dec
+                       -4:00   Arg     AR%sT   1969 Oct  5
+                       -3:00   Arg     AR%sT   1991 Mar  3
+                       -4:00   -       WART    1991 Oct 20
+                       -3:00   Arg     AR%sT   1999 Oct  3
+                       -4:00   Arg     AR%sT   2000 Mar  3
+                       -3:00   -       ART     2004 Jun  1
+                       -4:00   -       WART    2004 Jun 20
+                       -3:00   Arg     AR%sT   2008 Oct 18
+                       -3:00   -       ART
+#
+# Mendoza (MZ)
+Zone America/Argentina/Mendoza -4:35:16 - LMT  1894 Oct 31
+                       -4:16:48 -      CMT     1920 May
+                       -4:00   -       ART     1930 Dec
+                       -4:00   Arg     AR%sT   1969 Oct  5
+                       -3:00   Arg     AR%sT   1990 Mar  4
+                       -4:00   -       WART    1990 Oct 15
+                       -4:00   1:00    WARST   1991 Mar  1
+                       -4:00   -       WART    1991 Oct 15
+                       -4:00   1:00    WARST   1992 Mar  1
+                       -4:00   -       WART    1992 Oct 18
+                       -3:00   Arg     AR%sT   1999 Oct  3
+                       -4:00   Arg     AR%sT   2000 Mar  3
+                       -3:00   -       ART     2004 May 23
+                       -4:00   -       WART    2004 Sep 26
+                       -3:00   Arg     AR%sT   2008 Oct 18
+                       -3:00   -       ART
+#
+# San Luis (SL)
+Zone America/Argentina/San_Luis -4:25:24 - LMT 1894 Oct 31
+                       -4:16:48 -      CMT     1920 May
+                       -4:00   -       ART     1930 Dec
+                       -4:00   Arg     AR%sT   1969 Oct  5
+                       -3:00   Arg     AR%sT   1990
+                       -3:00   1:00    ARST    1990 Mar 14
+                       -4:00   -       WART    1990 Oct 15
+                       -4:00   1:00    WARST   1991 Mar  1
+                       -4:00   -       WART    1991 Jun  1
+                       -3:00   -       ART     1999 Oct  3
+                       -4:00   1:00    WARST   2000 Mar  3
+                       -3:00   -       ART     2004 May 31
+                       -4:00   -       WART    2004 Jul 25
+                       -3:00   Arg     AR%sT   2008 Jan 21
+                       -3:00   -       ART     2009 Mar 15
+                       -4:00   Arg     WAR%sT
+#
+# Santa Cruz (SC)
+Zone America/Argentina/Rio_Gallegos -4:36:52 - LMT 1894 Oct 31
+                       -4:16:48 -      CMT     1920 May # Cordoba Mean Time
+                       -4:00   -       ART     1930 Dec
+                       -4:00   Arg     AR%sT   1969 Oct  5
+                       -3:00   Arg     AR%sT   1999 Oct  3
+                       -4:00   Arg     AR%sT   2000 Mar  3
+                       -3:00   -       ART     2004 Jun  1
+                       -4:00   -       WART    2004 Jun 20
+                       -3:00   Arg     AR%sT   2008 Oct 18
+                       -3:00   -       ART
+#
+# Tierra del Fuego, Antartida e Islas del Atlantico Sur (TF)
+Zone America/Argentina/Ushuaia -4:33:12 - LMT 1894 Oct 31
+                       -4:16:48 -      CMT     1920 May # Cordoba Mean Time
+                       -4:00   -       ART     1930 Dec
+                       -4:00   Arg     AR%sT   1969 Oct  5
+                       -3:00   Arg     AR%sT   1999 Oct  3
+                       -4:00   Arg     AR%sT   2000 Mar  3
+                       -3:00   -       ART     2004 May 30
+                       -4:00   -       WART    2004 Jun 20
+                       -3:00   Arg     AR%sT   2008 Oct 18
+                       -3:00   -       ART
+
+# Aruba
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   America/Aruba   -4:40:24 -      LMT     1912 Feb 12     # Oranjestad
+                       -4:30   -       ANT     1965 # Netherlands Antilles Time
+                       -4:00   -       AST
+
+# Bolivia
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   America/La_Paz  -4:32:36 -      LMT     1890
+                       -4:32:36 -      CMT     1931 Oct 15 # Calamarca MT
+                       -4:32:36 1:00   BOST    1932 Mar 21 # Bolivia ST
+                       -4:00   -       BOT     # Bolivia Time
+
+# Brazil
+
+# From Paul Eggert (1993-11-18):
+# The mayor of Rio recently attempted to change the time zone rules
+# just in his city, in order to leave more summer time for the tourist trade.
+# The rule change lasted only part of the day;
+# the federal government refused to follow the city's rules, and business
+# was in a chaos, so the mayor backed down that afternoon.
+
+# From IATA SSIM (1996-02):
+# _Only_ the following states in BR1 observe DST: Rio Grande do Sul (RS),
+# Santa Catarina (SC), Parana (PR), Sao Paulo (SP), Rio de Janeiro (RJ),
+# Espirito Santo (ES), Minas Gerais (MG), Bahia (BA), Goias (GO),
+# Distrito Federal (DF), Tocantins (TO), Sergipe [SE] and Alagoas [AL].
+# [The last three states are new to this issue of the IATA SSIM.]
+
+# From Gwillim Law (1996-10-07):
+# Geography, history (Tocantins was part of Goias until 1989), and other
+# sources of time zone information lead me to believe that AL, SE, and TO were
+# always in BR1, and so the only change was whether or not they observed DST....
+# The earliest issue of the SSIM I have is 2/91.  Each issue from then until
+# 9/95 says that DST is observed only in the ten states I quoted from 9/95,
+# along with Mato Grosso (MT) and Mato Grosso do Sul (MS), which are in BR2
+# (UTC-4)....  The other two time zones given for Brazil are BR3, which is
+# UTC-5, no DST, and applies only in the state of Acre (AC); and BR4, which is
+# UTC-2, and applies to Fernando de Noronha (formerly FN, but I believe it's
+# become part of the state of Pernambuco).  The boundary between BR1 and BR2
+# has never been clearly stated.  They've simply been called East and West.
+# However, some conclusions can be drawn from another IATA manual: the Airline
+# Coding Directory, which lists close to 400 airports in Brazil.  For each
+# airport it gives a time zone which is coded to the SSIM.  From that
+# information, I'm led to conclude that the states of Amapa (AP), Ceara (CE),
+# Maranhao (MA), Paraiba (PR), Pernambuco (PE), Piaui (PI), and Rio Grande do
+# Norte (RN), and the eastern part of Para (PA) are all in BR1 without DST.
+
+# From Marcos Tadeu (1998-09-27):
+# <a href="http://pcdsh01.on.br/verao1.html">
+# Brazilian official page
+# </a>
+
+# From Jesper Norgaard (2000-11-03):
+# [For an official list of which regions in Brazil use which time zones, see:]
+# http://pcdsh01.on.br/Fusbr.htm
+# http://pcdsh01.on.br/Fusbrhv.htm
+
+# From Celso Doria via David Madeo (2002-10-09):
+# The reason for the delay this year has to do with elections in Brazil.
+#
+# Unlike in the United States, elections in Brazil are 100% computerized and
+# the results are known almost immediately.  Yesterday, it was the first
+# round of the elections when 115 million Brazilians voted for President,
+# Governor, Senators, Federal Deputies, and State Deputies.  Nobody is
+# counting (or re-counting) votes anymore and we know there will be a second
+# round for the Presidency and also for some Governors.  The 2nd round will
+# take place on October 27th.
+#
+# The reason why the DST will only begin November 3rd is that the thousands
+# of electoral machines used cannot have their time changed, and since the
+# Constitution says the elections must begin at 8:00 AM and end at 5:00 PM,
+# the Government decided to postpone DST, instead of changing the Constitution
+# (maybe, for the next elections, it will be possible to change the clock)...
+
+# From Rodrigo Severo (2004-10-04):
+# It's just the biannual change made necessary by the much hyped, supposedly
+# modern Brazilian eletronic voting machines which, apparently, can't deal
+# with a time change between the first and the second rounds of the elections.
+
+# From Steffen Thorsen (2007-09-20):
+# Brazil will start DST on 2007-10-14 00:00 and end on 2008-02-17 00:00:
+# http://www.mme.gov.br/site/news/detail.do;jsessionid=BBA06811AFCAAC28F0285210913513DA?newsId=13975
+
+# From Paul Schulze (2008-06-24):
+# ...by law number 11.662 of April 24, 2008 (published in the "Diario
+# Oficial da Uniao"...) in Brazil there are changes in the timezones,
+# effective today (00:00am at June 24, 2008) as follows:
+#
+# a) The timezone UTC+5 is e[x]tinguished, with all the Acre state and the
+# part of the Amazonas state that had this timezone now being put to the
+# timezone UTC+4
+# b) The whole Para state now is put at timezone UTC+3, instead of just
+# part of it, as was before.
+#
+# This change follows a proposal of senator Tiao Viana of Acre state, that
+# proposed it due to concerns about open television channels displaying
+# programs inappropriate to youths in the states that had the timezone
+# UTC+5 too early in the night. In the occasion, some more corrections
+# were proposed, trying to unify the timezones of any given state. This
+# change modifies timezone rules defined in decree 2.784 of 18 June,
+# 1913.
+
+# From Rodrigo Severo (2008-06-24):
+# Just correcting the URL:
+# <a href="https://www.in.gov.br/imprensa/visualiza/index.jsp?jornal=3Ddo&secao=3D1&pagina=3D1&data=3D25/04/2008">
+# https://www.in.gov.br/imprensa/visualiza/index.jsp?jornal=3Ddo&secao=3D1&pagina=3D1&data=3D25/04/2008
+# </a>
+#
+# As a result of the above Decree I believe the America/Rio_Branco
+# timezone shall be modified from UTC-5 to UTC-4 and a new timezone shall
+# be created to represent the the west side of the Para State. I
+# suggest this new timezone be called Santarem as the most
+# important/populated city in the affected area.
+#
+# This new timezone would be the same as the Rio_Branco timezone up to
+# the 2008/06/24 change which would be to UTC-3 instead of UTC-4.
+
+# From Alex Krivenyshev (2008-06-24):
+# This is a quick reference page for New and Old Brazil Time Zones map.
+# <a href="http://www.worldtimezone.com/brazil-time-new-old.php">
+# http://www.worldtimezone.com/brazil-time-new-old.php
+# </a>
+#
+# - 4 time zones replaced by 3 time zones-eliminating time zone UTC- 05
+# (state Acre and the part of the Amazonas will be UTC/GMT- 04) - western
+# part of Par state is moving to one timezone UTC- 03 (from UTC -04).
+
+# From Paul Eggert (2002-10-10):
+# The official decrees referenced below are mostly taken from
+# <a href="http://pcdsh01.on.br/DecHV.html">
+# Decretos sobre o Horario de Verao no Brasil
+# </a>.
+
+# From Steffen Thorsen (2008-08-29):
+# As announced by the government and many newspapers in Brazil late
+# yesterday, Brazil will start DST on 2008-10-19 (need to change rule) and
+# it will end on 2009-02-15 (current rule for Brazil is fine). Based on
+# past years experience with the elections, there was a good chance that
+# the start was postponed to November, but it did not happen this year.
+#
+# It has not yet been posted to http://pcdsh01.on.br/DecHV.html
+#
+# An official page about it:
+# <a href="http://www.mme.gov.br/site/news/detail.do?newsId=16722">
+# http://www.mme.gov.br/site/news/detail.do?newsId=16722
+# </a>
+# Note that this link does not always work directly, but must be accessed
+# by going to
+# <a href="http://www.mme.gov.br/first">
+# http://www.mme.gov.br/first
+# </a>
+#
+# One example link that works directly:
+# <a href="http://jornale.com.br/index.php?option=com_content&task=view&id=13530&Itemid=54">
+# http://jornale.com.br/index.php?option=com_content&task=view&id=13530&Itemid=54
+# (Portuguese)
+# </a>
+#
+# We have a written a short article about it as well:
+# <a href="http://www.timeanddate.com/news/time/brazil-dst-2008-2009.html">
+# http://www.timeanddate.com/news/time/brazil-dst-2008-2009.html
+# </a>
+
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+# Decree <a href="http://pcdsh01.on.br/HV20466.htm">20,466</a> (1931-10-01)
+# Decree <a href="http://pcdsh01.on.br/HV21896.htm">21,896</a> (1932-01-10)
+Rule   Brazil  1931    only    -       Oct      3      11:00   1:00    S
+Rule   Brazil  1932    1933    -       Apr      1       0:00   0       -
+Rule   Brazil  1932    only    -       Oct      3       0:00   1:00    S
+# Decree <a href="http://pcdsh01.on.br/HV23195.htm">23,195</a> (1933-10-10)
+# revoked DST.
+# Decree <a href="http://pcdsh01.on.br/HV27496.htm">27,496</a> (1949-11-24)
+# Decree <a href="http://pcdsh01.on.br/HV27998.htm">27,998</a> (1950-04-13)
+Rule   Brazil  1949    1952    -       Dec      1       0:00   1:00    S
+Rule   Brazil  1950    only    -       Apr     16       1:00   0       -
+Rule   Brazil  1951    1952    -       Apr      1       0:00   0       -
+# Decree <a href="http://pcdsh01.on.br/HV32308.htm">32,308</a> (1953-02-24)
+Rule   Brazil  1953    only    -       Mar      1       0:00   0       -
+# Decree <a href="http://pcdsh01.on.br/HV34724.htm">34,724</a> (1953-11-30)
+# revoked DST.
+# Decree <a href="http://pcdsh01.on.br/HV52700.htm">52,700</a> (1963-10-18)
+# established DST from 1963-10-23 00:00 to 1964-02-29 00:00
+# in SP, RJ, GB, MG, ES, due to the prolongation of the drought.
+# Decree <a href="http://pcdsh01.on.br/HV53071.htm">53,071</a> (1963-12-03)
+# extended the above decree to all of the national territory on 12-09.
+Rule   Brazil  1963    only    -       Dec      9       0:00   1:00    S
+# Decree <a href="http://pcdsh01.on.br/HV53604.htm">53,604</a> (1964-02-25)
+# extended summer time by one day to 1964-03-01 00:00 (start of school).
+Rule   Brazil  1964    only    -       Mar      1       0:00   0       -
+# Decree <a href="http://pcdsh01.on.br/HV55639.htm">55,639</a> (1965-01-27)
+Rule   Brazil  1965    only    -       Jan     31       0:00   1:00    S
+Rule   Brazil  1965    only    -       Mar     31       0:00   0       -
+# Decree <a href="http://pcdsh01.on.br/HV57303.htm">57,303</a> (1965-11-22)
+Rule   Brazil  1965    only    -       Dec      1       0:00   1:00    S
+# Decree <a href="http://pcdsh01.on.br/HV57843.htm">57,843</a> (1966-02-18)
+Rule   Brazil  1966    1968    -       Mar      1       0:00   0       -
+Rule   Brazil  1966    1967    -       Nov      1       0:00   1:00    S
+# Decree <a href="http://pcdsh01.on.br/HV63429.htm">63,429</a> (1968-10-15)
+# revoked DST.
+# Decree <a href="http://pcdsh01.on.br/HV91698.htm">91,698</a> (1985-09-27)
+Rule   Brazil  1985    only    -       Nov      2       0:00   1:00    S
+# Decree 92,310 (1986-01-21)
+# Decree 92,463 (1986-03-13)
+Rule   Brazil  1986    only    -       Mar     15       0:00   0       -
+# Decree 93,316 (1986-10-01)
+Rule   Brazil  1986    only    -       Oct     25       0:00   1:00    S
+Rule   Brazil  1987    only    -       Feb     14       0:00   0       -
+# Decree <a href="http://pcdsh01.on.br/HV94922.htm">94,922</a> (1987-09-22)
+Rule   Brazil  1987    only    -       Oct     25       0:00   1:00    S
+Rule   Brazil  1988    only    -       Feb      7       0:00   0       -
+# Decree <a href="http://pcdsh01.on.br/HV96676.htm">96,676</a> (1988-09-12)
+# except for the states of AC, AM, PA, RR, RO, and AP (then a territory)
+Rule   Brazil  1988    only    -       Oct     16       0:00   1:00    S
+Rule   Brazil  1989    only    -       Jan     29       0:00   0       -
+# Decree <a href="http://pcdsh01.on.br/HV98077.htm">98,077</a> (1989-08-21)
+# with the same exceptions
+Rule   Brazil  1989    only    -       Oct     15       0:00   1:00    S
+Rule   Brazil  1990    only    -       Feb     11       0:00   0       -
+# Decree <a href="http://pcdsh01.on.br/HV99530.htm">99,530</a> (1990-09-17)
+# adopted by RS, SC, PR, SP, RJ, ES, MG, GO, MS, DF.
+# Decree 99,629 (1990-10-19) adds BA, MT.
+Rule   Brazil  1990    only    -       Oct     21       0:00   1:00    S
+Rule   Brazil  1991    only    -       Feb     17       0:00   0       -
+# <a href="http://pcdsh01.on.br/HV1991.htm">Unnumbered decree</a> (1991-09-25)
+# adopted by RS, SC, PR, SP, RJ, ES, MG, BA, GO, MT, MS, DF.
+Rule   Brazil  1991    only    -       Oct     20       0:00   1:00    S
+Rule   Brazil  1992    only    -       Feb      9       0:00   0       -
+# <a href="http://pcdsh01.on.br/HV1992.htm">Unnumbered decree</a> (1992-10-16)
+# adopted by same states.
+Rule   Brazil  1992    only    -       Oct     25       0:00   1:00    S
+Rule   Brazil  1993    only    -       Jan     31       0:00   0       -
+# Decree <a href="http://pcdsh01.on.br/HV942.htm">942</a> (1993-09-28)
+# adopted by same states, plus AM.
+# Decree <a href="http://pcdsh01.on.br/HV1252.htm">1,252</a> (1994-09-22;
+# web page corrected 2004-01-07) adopted by same states, minus AM.
+# Decree <a href="http://pcdsh01.on.br/HV1636.htm">1,636</a> (1995-09-14)
+# adopted by same states, plus MT and TO.
+# Decree <a href="http://pcdsh01.on.br/HV1674.htm">1,674</a> (1995-10-13)
+# adds AL, SE.
+Rule   Brazil  1993    1995    -       Oct     Sun>=11  0:00   1:00    S
+Rule   Brazil  1994    1995    -       Feb     Sun>=15  0:00   0       -
+Rule   Brazil  1996    only    -       Feb     11       0:00   0       -
+# Decree <a href="http://pcdsh01.on.br/HV2000.htm">2,000</a> (1996-09-04)
+# adopted by same states, minus AL, SE.
+Rule   Brazil  1996    only    -       Oct      6       0:00   1:00    S
+Rule   Brazil  1997    only    -       Feb     16       0:00   0       -
+# From Daniel C. Sobral (1998-02-12):
+# In 1997, the DS began on October 6. The stated reason was that
+# because international television networks ignored Brazil's policy on DS,
+# they bought the wrong times on satellite for coverage of Pope's visit.
+# This year, the ending date of DS was postponed to March 1
+# to help dealing with the shortages of electric power.
+#
+# Decree 2,317 (1997-09-04), adopted by same states.
+Rule   Brazil  1997    only    -       Oct      6       0:00   1:00    S
+# Decree <a href="http://pcdsh01.on.br/figuras/HV2495.JPG">2,495</a>
+# (1998-02-10)
+Rule   Brazil  1998    only    -       Mar      1       0:00   0       -
+# Decree <a href="http://pcdsh01.on.br/figuras/Hv98.jpg">2,780</a> (1998-09-11)
+# adopted by the same states as before.
+Rule   Brazil  1998    only    -       Oct     11       0:00   1:00    S
+Rule   Brazil  1999    only    -       Feb     21       0:00   0       -
+# Decree <a href="http://pcdsh01.on.br/figuras/HV3150.gif">3,150</a>
+# (1999-08-23) adopted by same states.
+# Decree <a href="http://pcdsh01.on.br/DecHV99.gif">3,188</a> (1999-09-30)
+# adds SE, AL, PB, PE, RN, CE, PI, MA and RR.
+Rule   Brazil  1999    only    -       Oct      3       0:00   1:00    S
+Rule   Brazil  2000    only    -       Feb     27       0:00   0       -
+# Decree <a href="http://pcdsh01.on.br/DEC3592.htm">3,592</a> (2000-09-06)
+# adopted by the same states as before.
+# Decree <a href="http://pcdsh01.on.br/Dec3630.jpg">3,630</a> (2000-10-13)
+# repeals DST in PE and RR, effective 2000-10-15 00:00.
+# Decree <a href="http://pcdsh01.on.br/Dec3632.jpg">3,632</a> (2000-10-17)
+# repeals DST in SE, AL, PB, RN, CE, PI and MA, effective 2000-10-22 00:00.
+# Decree <a href="http://pcdsh01.on.br/figuras/HV3916.gif">3,916</a>
+# (2001-09-13) reestablishes DST in AL, CE, MA, PB, PE, PI, RN, SE.
+Rule   Brazil  2000    2001    -       Oct     Sun>=8   0:00   1:00    S
+Rule   Brazil  2001    2006    -       Feb     Sun>=15  0:00   0       -
+# Decree 4,399 (2002-10-01) repeals DST in AL, CE, MA, PB, PE, PI, RN, SE.
+# <a href="http://www.presidencia.gov.br/CCIVIL/decreto/2002/D4399.htm">4,399</a>
+Rule   Brazil  2002    only    -       Nov      3       0:00   1:00    S
+# Decree 4,844 (2003-09-24; corrected 2003-09-26) repeals DST in BA, MT, TO.
+# <a href="http://www.presidencia.gov.br/CCIVIL/decreto/2003/D4844.htm">4,844</a>
+Rule   Brazil  2003    only    -       Oct     19       0:00   1:00    S
+# Decree 5,223 (2004-10-01) reestablishes DST in MT.
+# <a href="http://www.planalto.gov.br/ccivil_03/_Ato2004-2006/2004/Decreto/D5223.htm">5,223</a>
+Rule   Brazil  2004    only    -       Nov      2       0:00   1:00    S
+# Decree <a href="http://pcdsh01.on.br/DecHV5539.gif">5,539</a> (2005-09-19),
+# adopted by the same states as before.
+Rule   Brazil  2005    only    -       Oct     16       0:00   1:00    S
+# Decree <a href="http://pcdsh01.on.br/DecHV5920.gif">5,920</a> (2006-10-03),
+# adopted by the same states as before.
+Rule   Brazil  2006    only    -       Nov      5       0:00   1:00    S
+Rule   Brazil  2007    only    -       Feb     25       0:00   0       -
+# Decree <a href="http://pcdsh01.on.br/DecHV6212.gif">6,212</a> (2007-09-26),
+# adopted by the same states as before.
+Rule   Brazil  2007    only    -       Oct     Sun>=8   0:00   1:00    S
+# From Frederico A. C. Neves (2008-09-10):
+# Acording to this decree
+# <a href="http://www.planalto.gov.br/ccivil_03/_Ato2007-2010/2008/Decreto/D6558.htm">
+# http://www.planalto.gov.br/ccivil_03/_Ato2007-2010/2008/Decreto/D6558.htm
+# </a>
+# [t]he DST period in Brazil now on will be from the 3rd Oct Sunday to the
+# 3rd Feb Sunday. There is an exception on the return date when this is
+# the Carnival Sunday then the return date will be the next Sunday...
+Rule   Brazil  2008    max     -       Oct     Sun>=15 0:00    1:00    S
+Rule   Brazil  2008    2011    -       Feb     Sun>=15 0:00    0       -
+Rule   Brazil  2012    only    -       Feb     Sun>=22 0:00    0       -
+Rule   Brazil  2013    2014    -       Feb     Sun>=15 0:00    0       -
+Rule   Brazil  2015    only    -       Feb     Sun>=22 0:00    0       -
+Rule   Brazil  2016    2022    -       Feb     Sun>=15 0:00    0       -
+Rule   Brazil  2023    only    -       Feb     Sun>=22 0:00    0       -
+Rule   Brazil  2024    2025    -       Feb     Sun>=15 0:00    0       -
+Rule   Brazil  2026    only    -       Feb     Sun>=22 0:00    0       -
+Rule   Brazil  2027    2033    -       Feb     Sun>=15 0:00    0       -
+Rule   Brazil  2034    only    -       Feb     Sun>=22 0:00    0       -
+Rule   Brazil  2035    2036    -       Feb     Sun>=15 0:00    0       -
+Rule   Brazil  2037    only    -       Feb     Sun>=22 0:00    0       -
+# From Arthur David Olson (2008-09-29):
+# The next is wrong in some years but is better than nothing.
+Rule   Brazil  2038    max     -       Feb     Sun>=15 0:00    0       -
+
+# The latest ruleset listed above says that the following states observe DST:
+# DF, ES, GO, MG, MS, MT, PR, RJ, RS, SC, SP.
+
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+#
+# Fernando de Noronha (administratively part of PE)
+Zone America/Noronha   -2:09:40 -      LMT     1914
+                       -2:00   Brazil  FN%sT   1990 Sep 17
+                       -2:00   -       FNT     1999 Sep 30
+                       -2:00   Brazil  FN%sT   2000 Oct 15
+                       -2:00   -       FNT     2001 Sep 13
+                       -2:00   Brazil  FN%sT   2002 Oct  1
+                       -2:00   -       FNT
+# Other Atlantic islands have no permanent settlement.
+# These include Trindade and Martin Vaz (administratively part of ES),
+# Atol das Rocas (RN), and Penedos de Sao Pedro e Sao Paulo (PE).
+# Fernando de Noronha was a separate territory from 1942-09-02 to 1989-01-01;
+# it also included the Penedos.
+#
+# Amapa (AP), east Para (PA)
+# East Para includes Belem, Maraba, Serra Norte, and Sao Felix do Xingu.
+# The division between east and west Para is the river Xingu.
+# In the north a very small part from the river Javary (now Jari I guess,
+# the border with Amapa) to the Amazon, then to the Xingu.
+Zone America/Belem     -3:13:56 -      LMT     1914
+                       -3:00   Brazil  BR%sT   1988 Sep 12
+                       -3:00   -       BRT
+#
+# west Para (PA)
+# West Para includes Altamira, Oribidos, Prainha, Oriximina, and Santarem.
+Zone America/Santarem  -3:38:48 -      LMT     1914
+                       -4:00   Brazil  AM%sT   1988 Sep 12
+                       -4:00   -       AMT     2008 Jun 24 00:00
+                       -3:00   -       BRT
+#
+# Maranhao (MA), Piaui (PI), Ceara (CE), Rio Grande do Norte (RN),
+# Paraiba (PB)
+Zone America/Fortaleza -2:34:00 -      LMT     1914
+                       -3:00   Brazil  BR%sT   1990 Sep 17
+                       -3:00   -       BRT     1999 Sep 30
+                       -3:00   Brazil  BR%sT   2000 Oct 22
+                       -3:00   -       BRT     2001 Sep 13
+                       -3:00   Brazil  BR%sT   2002 Oct  1
+                       -3:00   -       BRT
+#
+# Pernambuco (PE) (except Atlantic islands)
+Zone America/Recife    -2:19:36 -      LMT     1914
+                       -3:00   Brazil  BR%sT   1990 Sep 17
+                       -3:00   -       BRT     1999 Sep 30
+                       -3:00   Brazil  BR%sT   2000 Oct 15
+                       -3:00   -       BRT     2001 Sep 13
+                       -3:00   Brazil  BR%sT   2002 Oct  1
+                       -3:00   -       BRT
+#
+# Tocantins (TO)
+Zone America/Araguaina -3:12:48 -      LMT     1914
+                       -3:00   Brazil  BR%sT   1990 Sep 17
+                       -3:00   -       BRT     1995 Sep 14
+                       -3:00   Brazil  BR%sT   2003 Sep 24
+                       -3:00   -       BRT
+#
+# Alagoas (AL), Sergipe (SE)
+Zone America/Maceio    -2:22:52 -      LMT     1914
+                       -3:00   Brazil  BR%sT   1990 Sep 17
+                       -3:00   -       BRT     1995 Oct 13
+                       -3:00   Brazil  BR%sT   1996 Sep  4
+                       -3:00   -       BRT     1999 Sep 30
+                       -3:00   Brazil  BR%sT   2000 Oct 22
+                       -3:00   -       BRT     2001 Sep 13
+                       -3:00   Brazil  BR%sT   2002 Oct  1
+                       -3:00   -       BRT
+#
+# Bahia (BA)
+# There are too many Salvadors elsewhere, so use America/Bahia instead
+# of America/Salvador.
+Zone America/Bahia     -2:34:04 -      LMT     1914
+                       -3:00   Brazil  BR%sT   2003 Sep 24
+                       -3:00   -       BRT
+#
+# Goias (GO), Distrito Federal (DF), Minas Gerais (MG),
+# Espirito Santo (ES), Rio de Janeiro (RJ), Sao Paulo (SP), Parana (PR),
+# Santa Catarina (SC), Rio Grande do Sul (RS)
+Zone America/Sao_Paulo -3:06:28 -      LMT     1914
+                       -3:00   Brazil  BR%sT   1963 Oct 23 00:00
+                       -3:00   1:00    BRST    1964
+                       -3:00   Brazil  BR%sT
+#
+# Mato Grosso do Sul (MS)
+Zone America/Campo_Grande -3:38:28 -   LMT     1914
+                       -4:00   Brazil  AM%sT
+#
+# Mato Grosso (MT)
+Zone America/Cuiaba    -3:44:20 -      LMT     1914
+                       -4:00   Brazil  AM%sT   2003 Sep 24
+                       -4:00   -       AMT     2004 Oct  1
+                       -4:00   Brazil  AM%sT
+#
+# Rondonia (RO)
+Zone America/Porto_Velho -4:15:36 -    LMT     1914
+                       -4:00   Brazil  AM%sT   1988 Sep 12
+                       -4:00   -       AMT
+#
+# Roraima (RR)
+Zone America/Boa_Vista -4:02:40 -      LMT     1914
+                       -4:00   Brazil  AM%sT   1988 Sep 12
+                       -4:00   -       AMT     1999 Sep 30
+                       -4:00   Brazil  AM%sT   2000 Oct 15
+                       -4:00   -       AMT
+#
+# east Amazonas (AM): Boca do Acre, Jutai, Manaus, Floriano Peixoto
+# The great circle line from Tabatinga to Porto Acre divides
+# east from west Amazonas.
+Zone America/Manaus    -4:00:04 -      LMT     1914
+                       -4:00   Brazil  AM%sT   1988 Sep 12
+                       -4:00   -       AMT     1993 Sep 28
+                       -4:00   Brazil  AM%sT   1994 Sep 22
+                       -4:00   -       AMT
+#
+# west Amazonas (AM): Atalaia do Norte, Boca do Maoco, Benjamin Constant,
+#      Eirunepe, Envira, Ipixuna
+Zone America/Eirunepe  -4:39:28 -      LMT     1914
+                       -5:00   Brazil  AC%sT   1988 Sep 12
+                       -5:00   -       ACT     1993 Sep 28
+                       -5:00   Brazil  AC%sT   1994 Sep 22
+                       -5:00   -       ACT     2008 Jun 24 00:00
+                       -4:00   -       AMT
+#
+# Acre (AC)
+Zone America/Rio_Branco        -4:31:12 -      LMT     1914
+                       -5:00   Brazil  AC%sT   1988 Sep 12
+                       -5:00   -       ACT     2008 Jun 24 00:00
+                       -4:00   -       AMT
+
+# Chile
+
+# From Eduardo Krell (1995-10-19):
+# The law says to switch to DST at midnight [24:00] on the second SATURDAY
+# of October....  The law is the same for March and October.
+# (1998-09-29):
+# Because of the drought this year, the government decided to go into
+# DST earlier (saturday 9/26 at 24:00). This is a one-time change only ...
+# (unless there's another dry season next year, I guess).
+
+# From Julio I. Pacheco Troncoso (1999-03-18):
+# Because of the same drought, the government decided to end DST later,
+# on April 3, (one-time change).
+
+# From Oscar van Vlijmen (2006-10-08):
+# http://www.horaoficial.cl/cambio.htm
+
+# From Jesper Norgaard Welen (2006-10-08):
+# I think that there are some obvious mistakes in the suggested link
+# from Oscar van Vlijmen,... for instance entry 66 says that GMT-4
+# ended 1990-09-12 while entry 67 only begins GMT-3 at 1990-09-15
+# (they should have been 1990-09-15 and 1990-09-16 respectively), but
+# anyhow it clears up some doubts too.
+
+# From Paul Eggert (2006-12-27):
+# The following data for Chile and America/Santiago are from
+# <http://www.horaoficial.cl/horaof.htm> (2006-09-20), transcribed by
+# Jesper Norgaard Welen.  The data for Pacific/Easter are from Shanks
+# & Pottenger, except with DST transitions after 1932 cloned from
+# America/Santiago.  The pre-1980 Pacific/Easter data are dubious,
+# but we have no other source.
+
+# From German Poo-Caaman~o (2008-03-03):
+# Due to drought, Chile extends Daylight Time in three weeks.  This
+# is one-time change (Saturday 3/29 at 24:00 for America/Santiago
+# and Saturday 3/29 at 22:00 for Pacific/Easter)
+# The Supreme Decree is located at 
+# <a href="http://www.shoa.cl/servicios/supremo316.pdf">
+# http://www.shoa.cl/servicios/supremo316.pdf
+# </a>
+# and the instructions for 2008 are located in:
+# <a href="http://www.horaoficial.cl/cambio.htm">
+# http://www.horaoficial.cl/cambio.htm
+# </a>.
+
+# From Jose Miguel Garrido (2008-03-05):
+# ...
+# You could see the announces of the change on 
+# <a href="http://www.shoa.cl/noticias/2008/04hora/hora.htm">
+# http://www.shoa.cl/noticias/2008/04hora/hora.htm
+# </a>.
+
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Chile   1927    1932    -       Sep      1      0:00    1:00    S
+Rule   Chile   1928    1932    -       Apr      1      0:00    0       -
+Rule   Chile   1942    only    -       Jun      1      4:00u   0       -
+Rule   Chile   1942    only    -       Aug      1      5:00u   1:00    S
+Rule   Chile   1946    only    -       Jul     15      4:00u   1:00    S
+Rule   Chile   1946    only    -       Sep      1      3:00u   0:00    -
+Rule   Chile   1947    only    -       Apr      1      4:00u   0       -
+Rule   Chile   1968    only    -       Nov      3      4:00u   1:00    S
+Rule   Chile   1969    only    -       Mar     30      3:00u   0       -
+Rule   Chile   1969    only    -       Nov     23      4:00u   1:00    S
+Rule   Chile   1970    only    -       Mar     29      3:00u   0       -
+Rule   Chile   1971    only    -       Mar     14      3:00u   0       -
+Rule   Chile   1970    1972    -       Oct     Sun>=9  4:00u   1:00    S
+Rule   Chile   1972    1986    -       Mar     Sun>=9  3:00u   0       -
+Rule   Chile   1973    only    -       Sep     30      4:00u   1:00    S
+Rule   Chile   1974    1987    -       Oct     Sun>=9  4:00u   1:00    S
+Rule   Chile   1987    only    -       Apr     12      3:00u   0       -
+Rule   Chile   1988    1989    -       Mar     Sun>=9  3:00u   0       -
+Rule   Chile   1988    only    -       Oct     Sun>=1  4:00u   1:00    S
+Rule   Chile   1989    only    -       Oct     Sun>=9  4:00u   1:00    S
+Rule   Chile   1990    only    -       Mar     18      3:00u   0       -
+Rule   Chile   1990    only    -       Sep     16      4:00u   1:00    S
+Rule   Chile   1991    1996    -       Mar     Sun>=9  3:00u   0       -
+Rule   Chile   1991    1997    -       Oct     Sun>=9  4:00u   1:00    S
+Rule   Chile   1997    only    -       Mar     30      3:00u   0       -
+Rule   Chile   1998    only    -       Mar     Sun>=9  3:00u   0       -
+Rule   Chile   1998    only    -       Sep     27      4:00u   1:00    S
+Rule   Chile   1999    only    -       Apr      4      3:00u   0       -
+Rule   Chile   1999    max     -       Oct     Sun>=9  4:00u   1:00    S
+Rule   Chile   2000    2007    -       Mar     Sun>=9  3:00u   0       -
+# N.B.: the end of March 29 in Chile is March 30 in Universal time,
+# which is used below in specifying the transition.
+Rule   Chile   2008    only    -       Mar     30      3:00u   0       -
+Rule   Chile   2009    max     -       Mar     Sun>=9  3:00u   0       -
+# IATA SSIM anomalies: (1992-02) says 1992-03-14;
+# (1996-09) says 1998-03-08.  Ignore these.
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone America/Santiago  -4:42:46 -      LMT     1890
+                       -4:42:46 -      SMT     1910        # Santiago Mean Time
+                       -5:00   -       CLT     1916 Jul  1 # Chile Time
+                       -4:42:46 -      SMT     1918 Sep  1 # Santiago Mean Time
+                       -4:00   -       CLT     1919 Jul  1 # Chile Time
+                       -4:42:46 -      SMT     1927 Sep  1 # Santiago Mean Time
+                       -5:00   Chile   CL%sT   1947 May 22 # Chile Time
+                       -4:00   Chile   CL%sT
+Zone Pacific/Easter    -7:17:44 -      LMT     1890
+                       -7:17:28 -      EMT     1932 Sep    # Easter Mean Time
+                       -7:00   Chile   EAS%sT  1982 Mar 13 21:00 # Easter I Time
+                       -6:00   Chile   EAS%sT
+#
+# Sala y Gomez Island is like Pacific/Easter.
+# Other Chilean locations, including Juan Fernandez Is, San Ambrosio,
+# San Felix, and Antarctic bases, are like America/Santiago.
+
+# Colombia
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   CO      1992    only    -       May      3      0:00    1:00    S
+Rule   CO      1993    only    -       Apr      4      0:00    0       -
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   America/Bogota  -4:56:20 -      LMT     1884 Mar 13
+                       -4:56:20 -      BMT     1914 Nov 23 # Bogota Mean Time
+                       -5:00   CO      CO%sT   # Colombia Time
+# Malpelo, Providencia, San Andres
+# no information; probably like America/Bogota
+
+# Curacao
+#
+# From Paul Eggert (2006-03-22):
+# Shanks & Pottenger say that The Bottom and Philipsburg have been at
+# -4:00 since standard time was introduced on 1912-03-02; and that
+# Kralendijk and Rincon used Kralendijk Mean Time (-4:33:08) from
+# 1912-02-02 to 1965-01-01.  The former is dubious, since S&P also say
+# Saba Island has been like Curacao.
+# This all predates our 1970 cutoff, though.
+#
+# By July 2007 Curacao and St Maarten are planned to become
+# associated states within the Netherlands, much like Aruba;
+# Bonaire, Saba and St Eustatius would become directly part of the
+# Netherlands as Kingdom Islands.  This won't affect their time zones
+# though, as far as we know.
+#
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   America/Curacao -4:35:44 -      LMT     1912 Feb 12     # Willemstad
+                       -4:30   -       ANT     1965 # Netherlands Antilles Time
+                       -4:00   -       AST
+
+# Ecuador
+#
+# From Paul Eggert (2007-03-04):
+# Apparently Ecuador had a failed experiment with DST in 1992.
+# <http://midena.gov.ec/content/view/1261/208/> (2007-02-27) and
+# <http://www.hoy.com.ec/NoticiaNue.asp?row_id=249856> (2006-11-06) both
+# talk about "hora Sixto".  Leave this alone for now, as we have no data.
+#
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone America/Guayaquil -5:19:20 -      LMT     1890
+                       -5:14:00 -      QMT     1931 # Quito Mean Time
+                       -5:00   -       ECT          # Ecuador Time
+Zone Pacific/Galapagos -5:58:24 -      LMT     1931 # Puerto Baquerizo Moreno
+                       -5:00   -       ECT     1986
+                       -6:00   -       GALT         # Galapagos Time
+
+# Falklands
+
+# From Paul Eggert (2006-03-22):
+# Between 1990 and 2000 inclusive, Shanks & Pottenger and the IATA agree except
+# the IATA gives 1996-09-08.  Go with Shanks & Pottenger.
+
+# From Falkland Islands Government Office, London (2001-01-22)
+# via Jesper Norgaard:
+# ... the clocks revert back to Local Mean Time at 2 am on Sunday 15
+# April 2001 and advance one hour to summer time at 2 am on Sunday 2
+# September.  It is anticipated that the clocks will revert back at 2
+# am on Sunday 21 April 2002 and advance to summer time at 2 am on
+# Sunday 1 September.
+
+# From Rives McDow (2001-02-13):
+#
+# I have communicated several times with people there, and the last
+# time I had communications that was helpful was in 1998.  Here is
+# what was said then:
+#
+# "The general rule was that Stanley used daylight saving and the Camp
+# did not. However for various reasons many people in the Camp have
+# started to use daylight saving (known locally as 'Stanley Time')
+# There is no rule as to who uses daylight saving - it is a matter of
+# personal choice and so it is impossible to draw a map showing who
+# uses it and who does not. Any list would be out of date as soon as
+# it was produced. This year daylight saving ended on April 18/19th
+# and started again on September 12/13th.  I do not know what the rule
+# is, but can find out if you like.  We do not change at the same time
+# as UK or Chile."
+#
+# I did have in my notes that the rule was "Second Saturday in Sep at
+# 0:00 until third Saturday in Apr at 0:00".  I think that this does
+# not agree in some cases with Shanks; is this true?
+#
+# Also, there is no mention in the list that some areas in the
+# Falklands do not use DST.  I have found in my communications there
+# that these areas are on the western half of East Falkland and all of
+# West Falkland.  Stanley is the only place that consistently observes
+# DST.  Again, as in other places in the world, the farmers don't like
+# it.  West Falkland is almost entirely sheep farmers.
+#
+# I know one lady there that keeps a list of which farm keeps DST and
+# which doesn't each year.  She runs a shop in Stanley, and says that
+# the list changes each year.  She uses it to communicate to her
+# customers, catching them when they are home for lunch or dinner.
+
+# From Paul Eggert (2001-03-05):
+# For now, we'll just record the time in Stanley, since we have no
+# better info.
+
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Falk    1937    1938    -       Sep     lastSun 0:00    1:00    S
+Rule   Falk    1938    1942    -       Mar     Sun>=19 0:00    0       -
+Rule   Falk    1939    only    -       Oct     1       0:00    1:00    S
+Rule   Falk    1940    1942    -       Sep     lastSun 0:00    1:00    S
+Rule   Falk    1943    only    -       Jan     1       0:00    0       -
+Rule   Falk    1983    only    -       Sep     lastSun 0:00    1:00    S
+Rule   Falk    1984    1985    -       Apr     lastSun 0:00    0       -
+Rule   Falk    1984    only    -       Sep     16      0:00    1:00    S
+Rule   Falk    1985    2000    -       Sep     Sun>=9  0:00    1:00    S
+Rule   Falk    1986    2000    -       Apr     Sun>=16 0:00    0       -
+Rule   Falk    2001    max     -       Apr     Sun>=15 2:00    0       -
+Rule   Falk    2001    max     -       Sep     Sun>=1  2:00    1:00    S
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone Atlantic/Stanley  -3:51:24 -      LMT     1890
+                       -3:51:24 -      SMT     1912 Mar 12  # Stanley Mean Time
+                       -4:00   Falk    FK%sT   1983 May     # Falkland Is Time
+                       -3:00   Falk    FK%sT   1985 Sep 15
+                       -4:00   Falk    FK%sT
+
+# French Guiana
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone America/Cayenne   -3:29:20 -      LMT     1911 Jul
+                       -4:00   -       GFT     1967 Oct # French Guiana Time
+                       -3:00   -       GFT
+
+# Guyana
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   America/Guyana  -3:52:40 -      LMT     1915 Mar        # Georgetown
+                       -3:45   -       GBGT    1966 May 26 # Br Guiana Time
+                       -3:45   -       GYT     1975 Jul 31 # Guyana Time
+                       -3:00   -       GYT     1991
+# IATA SSIM (1996-06) says -4:00.  Assume a 1991 switch.
+                       -4:00   -       GYT
+
+# Paraguay
+# From Paul Eggert (2006-03-22):
+# Shanks & Pottenger say that spring transitions are from 01:00 -> 02:00,
+# and autumn transitions are from 00:00 -> 23:00.  Go with pre-1999
+# editions of Shanks, and with the IATA, who say transitions occur at 00:00.
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Para    1975    1988    -       Oct      1      0:00    1:00    S
+Rule   Para    1975    1978    -       Mar      1      0:00    0       -
+Rule   Para    1979    1991    -       Apr      1      0:00    0       -
+Rule   Para    1989    only    -       Oct     22      0:00    1:00    S
+Rule   Para    1990    only    -       Oct      1      0:00    1:00    S
+Rule   Para    1991    only    -       Oct      6      0:00    1:00    S
+Rule   Para    1992    only    -       Mar      1      0:00    0       -
+Rule   Para    1992    only    -       Oct      5      0:00    1:00    S
+Rule   Para    1993    only    -       Mar     31      0:00    0       -
+Rule   Para    1993    1995    -       Oct      1      0:00    1:00    S
+Rule   Para    1994    1995    -       Feb     lastSun 0:00    0       -
+Rule   Para    1996    only    -       Mar      1      0:00    0       -
+# IATA SSIM (2000-02) says 1999-10-10; ignore this for now.
+# From Steffen Thorsen (2000-10-02):
+# I have three independent reports that Paraguay changed to DST this Sunday
+# (10-01).
+#
+# Translated by Gwillim Law (2001-02-27) from
+# <a href="http://www.diarionoticias.com.py/011000/nacional/naciona1.htm">
+# Noticias, a daily paper in Asuncion, Paraguay (2000-10-01)
+# </a>:
+# Starting at 0:00 today, the clock will be set forward 60 minutes, in
+# fulfillment of Decree No. 7,273 of the Executive Power....  The time change
+# system has been operating for several years.  Formerly there was a separate
+# decree each year; the new law has the same effect, but permanently.  Every
+# year, the time will change on the first Sunday of October; likewise, the
+# clock will be set back on the first Sunday of March.
+#
+Rule   Para    1996    2001    -       Oct     Sun>=1  0:00    1:00    S
+# IATA SSIM (1997-09) says Mar 1; go with Shanks & Pottenger.
+Rule   Para    1997    only    -       Feb     lastSun 0:00    0       -
+# Shanks & Pottenger say 1999-02-28; IATA SSIM (1999-02) says 1999-02-27, but
+# (1999-09) reports no date; go with above sources and Gerd Knops (2001-02-27).
+Rule   Para    1998    2001    -       Mar     Sun>=1  0:00    0       -
+# From Rives McDow (2002-02-28):
+# A decree was issued in Paraguay (no. 16350) on 2002-02-26 that changed the
+# dst method to be from the first Sunday in September to the first Sunday in
+# April.
+Rule   Para    2002    2004    -       Apr     Sun>=1  0:00    0       -
+Rule   Para    2002    2003    -       Sep     Sun>=1  0:00    1:00    S
+#
+# From Jesper Norgaard Welen (2005-01-02):
+# There are several sources that claim that Paraguay made
+# a timezone rule change in autumn 2004.
+# From Steffen Thorsen (2005-01-05):
+# Decree 1,867 (2004-03-05)
+# From Carlos Raul Perasso via Jesper Norgaard Welen (2006-10-13)
+# <http://www.presidencia.gov.py/decretos/D1867.pdf>
+Rule   Para    2004    max     -       Oct     Sun>=15 0:00    1:00    S
+Rule   Para    2005    max     -       Mar     Sun>=8  0:00    0       -
+
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone America/Asuncion  -3:50:40 -      LMT     1890
+                       -3:50:40 -      AMT     1931 Oct 10 # Asuncion Mean Time
+                       -4:00   -       PYT     1972 Oct # Paraguay Time
+                       -3:00   -       PYT     1974 Apr
+                       -4:00   Para    PY%sT
+
+# Peru
+#
+# <a href="news:xrGmb.39935$gA1.13896113@news4.srv.hcvlny.cv.net">
+# From Evelyn C. Leeper via Mark Brader (2003-10-26):</a>
+# When we were in Peru in 1985-1986, they apparently switched over
+# sometime between December 29 and January 3 while we were on the Amazon.
+#
+# From Paul Eggert (2006-03-22):
+# Shanks & Pottenger don't have this transition.  Assume 1986 was like 1987.
+
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   Peru    1938    only    -       Jan      1      0:00    1:00    S
+Rule   Peru    1938    only    -       Apr      1      0:00    0       -
+Rule   Peru    1938    1939    -       Sep     lastSun 0:00    1:00    S
+Rule   Peru    1939    1940    -       Mar     Sun>=24 0:00    0       -
+Rule   Peru    1986    1987    -       Jan      1      0:00    1:00    S
+Rule   Peru    1986    1987    -       Apr      1      0:00    0       -
+Rule   Peru    1990    only    -       Jan      1      0:00    1:00    S
+Rule   Peru    1990    only    -       Apr      1      0:00    0       -
+# IATA is ambiguous for 1993/1995; go with Shanks & Pottenger.
+Rule   Peru    1994    only    -       Jan      1      0:00    1:00    S
+Rule   Peru    1994    only    -       Apr      1      0:00    0       -
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   America/Lima    -5:08:12 -      LMT     1890
+                       -5:08:36 -      LMT     1908 Jul 28 # Lima Mean Time?
+                       -5:00   Peru    PE%sT   # Peru Time
+
+# South Georgia
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone Atlantic/South_Georgia -2:26:08 - LMT     1890            # Grytviken
+                       -2:00   -       GST     # South Georgia Time
+
+# South Sandwich Is
+# uninhabited; scientific personnel have wintered
+
+# Suriname
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone America/Paramaribo        -3:40:40 -      LMT     1911
+                       -3:40:52 -      PMT     1935     # Paramaribo Mean Time
+                       -3:40:36 -      PMT     1945 Oct # The capital moved?
+                       -3:30   -       NEGT    1975 Nov 20 # Dutch Guiana Time
+                       -3:30   -       SRT     1984 Oct # Suriname Time
+                       -3:00   -       SRT
+
+# Trinidad and Tobago
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone America/Port_of_Spain -4:06:04 -  LMT     1912 Mar 2
+                       -4:00   -       AST
+
+# Uruguay
+# From Paul Eggert (1993-11-18):
+# Uruguay wins the prize for the strangest peacetime manipulation of the rules.
+# From Shanks & Pottenger:
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+# Whitman gives 1923 Oct 1; go with Shanks & Pottenger.
+Rule   Uruguay 1923    only    -       Oct      2       0:00   0:30    HS
+Rule   Uruguay 1924    1926    -       Apr      1       0:00   0       -
+Rule   Uruguay 1924    1925    -       Oct      1       0:00   0:30    HS
+Rule   Uruguay 1933    1935    -       Oct     lastSun  0:00   0:30    HS
+# Shanks & Pottenger give 1935 Apr 1 0:00 & 1936 Mar 30 0:00; go with Whitman.
+Rule   Uruguay 1934    1936    -       Mar     Sat>=25 23:30s  0       -
+Rule   Uruguay 1936    only    -       Nov      1       0:00   0:30    HS
+Rule   Uruguay 1937    1941    -       Mar     lastSun  0:00   0       -
+# Whitman gives 1937 Oct 3; go with Shanks & Pottenger.
+Rule   Uruguay 1937    1940    -       Oct     lastSun  0:00   0:30    HS
+# Whitman gives 1941 Oct 24 - 1942 Mar 27, 1942 Dec 14 - 1943 Apr 13,
+# and 1943 Apr 13 ``to present time''; go with Shanks & Pottenger.
+Rule   Uruguay 1941    only    -       Aug      1       0:00   0:30    HS
+Rule   Uruguay 1942    only    -       Jan      1       0:00   0       -
+Rule   Uruguay 1942    only    -       Dec     14       0:00   1:00    S
+Rule   Uruguay 1943    only    -       Mar     14       0:00   0       -
+Rule   Uruguay 1959    only    -       May     24       0:00   1:00    S
+Rule   Uruguay 1959    only    -       Nov     15       0:00   0       -
+Rule   Uruguay 1960    only    -       Jan     17       0:00   1:00    S
+Rule   Uruguay 1960    only    -       Mar      6       0:00   0       -
+Rule   Uruguay 1965    1967    -       Apr     Sun>=1   0:00   1:00    S
+Rule   Uruguay 1965    only    -       Sep     26       0:00   0       -
+Rule   Uruguay 1966    1967    -       Oct     31       0:00   0       -
+Rule   Uruguay 1968    1970    -       May     27       0:00   0:30    HS
+Rule   Uruguay 1968    1970    -       Dec      2       0:00   0       -
+Rule   Uruguay 1972    only    -       Apr     24       0:00   1:00    S
+Rule   Uruguay 1972    only    -       Aug     15       0:00   0       -
+Rule   Uruguay 1974    only    -       Mar     10       0:00   0:30    HS
+Rule   Uruguay 1974    only    -       Dec     22       0:00   1:00    S
+Rule   Uruguay 1976    only    -       Oct      1       0:00   0       -
+Rule   Uruguay 1977    only    -       Dec      4       0:00   1:00    S
+Rule   Uruguay 1978    only    -       Apr      1       0:00   0       -
+Rule   Uruguay 1979    only    -       Oct      1       0:00   1:00    S
+Rule   Uruguay 1980    only    -       May      1       0:00   0       -
+Rule   Uruguay 1987    only    -       Dec     14       0:00   1:00    S
+Rule   Uruguay 1988    only    -       Mar     14       0:00   0       -
+Rule   Uruguay 1988    only    -       Dec     11       0:00   1:00    S
+Rule   Uruguay 1989    only    -       Mar     12       0:00   0       -
+Rule   Uruguay 1989    only    -       Oct     29       0:00   1:00    S
+# Shanks & Pottenger say no DST was observed in 1990/1 and 1991/2,
+# and that 1992/3's DST was from 10-25 to 03-01.  Go with IATA.
+Rule   Uruguay 1990    1992    -       Mar     Sun>=1   0:00   0       -
+Rule   Uruguay 1990    1991    -       Oct     Sun>=21  0:00   1:00    S
+Rule   Uruguay 1992    only    -       Oct     18       0:00   1:00    S
+Rule   Uruguay 1993    only    -       Feb     28       0:00   0       -
+# From Eduardo Cota (2004-09-20):
+# The uruguayan government has decreed a change in the local time....
+# http://www.presidencia.gub.uy/decretos/2004091502.htm
+Rule   Uruguay 2004    only    -       Sep     19       0:00   1:00    S
+# From Steffen Thorsen (2005-03-11):
+# Uruguay's DST was scheduled to end on Sunday, 2005-03-13, but in order to
+# save energy ... it was postponed two weeks....
+# http://www.presidencia.gub.uy/_Web/noticias/2005/03/2005031005.htm
+Rule   Uruguay 2005    only    -       Mar     27       2:00   0       -
+# From Eduardo Cota (2005-09-27):
+# http://www.presidencia.gub.uy/_Web/decretos/2005/09/CM%20119_09%2009%202005_00001.PDF
+# This means that from 2005-10-09 at 02:00 local time, until 2006-03-12 at
+# 02:00 local time, official time in Uruguay will be at GMT -2.
+Rule   Uruguay 2005    only    -       Oct      9       2:00   1:00    S
+Rule   Uruguay 2006    only    -       Mar     12       2:00   0       -
+# From Jesper Norgaard Welen (2006-09-06):
+# http://www.presidencia.gub.uy/_web/decretos/2006/09/CM%20210_08%2006%202006_00001.PDF
+Rule   Uruguay 2006    max     -       Oct     Sun>=1   2:00   1:00    S
+Rule   Uruguay 2007    max     -       Mar     Sun>=8   2:00   0       -
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone America/Montevideo        -3:44:44 -      LMT     1898 Jun 28
+                       -3:44:44 -      MMT     1920 May  1     # Montevideo MT
+                       -3:30   Uruguay UY%sT   1942 Dec 14     # Uruguay Time
+                       -3:00   Uruguay UY%sT
+
+# Venezuela
+#
+# From John Stainforth (2007-11-28):
+# ... the change for Venezuela originally expected for 2007-12-31 has
+# been brought forward to 2007-12-09.  The official announcement was
+# published today in the "Gaceta Oficial de la Republica Bolivariana
+# de Venezuela, numero 38.819" (official document for all laws or
+# resolution publication)
+# http://www.globovision.com/news.php?nid=72208
+
+# Zone NAME            GMTOFF  RULES   FORMAT  [UNTIL]
+Zone   America/Caracas -4:27:44 -      LMT     1890
+                       -4:27:40 -      CMT     1912 Feb 12 # Caracas Mean Time?
+                       -4:30   -       VET     1965         # Venezuela Time
+                       -4:00   -       VET     2007 Dec  9 03:00
+                       -4:30   -       VET
diff --git a/extra/zoneinfo/systemv b/extra/zoneinfo/systemv
new file mode 100644 (file)
index 0000000..6cf9645
--- /dev/null
@@ -0,0 +1,36 @@
+# @(#)systemv  8.1
+
+# Old rules, should the need arise.
+# No attempt is made to handle Newfoundland, since it cannot be expressed
+# using the System V "TZ" scheme (half-hour offset), or anything outside
+# North America (no support for non-standard DST start/end dates), nor
+# the changes in the DST rules in the US after 1976 (which occurred after
+# the old rules were written).
+#
+# If you need the old rules, uncomment ## lines.
+# Compile this *without* leap second correction for true conformance.
+
+# Rule NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
+Rule   SystemV min     1973    -       Apr     lastSun 2:00    1:00    D
+Rule   SystemV min     1973    -       Oct     lastSun 2:00    0       S
+Rule   SystemV 1974    only    -       Jan     6       2:00    1:00    D
+Rule   SystemV 1974    only    -       Nov     lastSun 2:00    0       S
+Rule   SystemV 1975    only    -       Feb     23      2:00    1:00    D
+Rule   SystemV 1975    only    -       Oct     lastSun 2:00    0       S
+Rule   SystemV 1976    max     -       Apr     lastSun 2:00    1:00    D
+Rule   SystemV 1976    max     -       Oct     lastSun 2:00    0       S
+
+# Zone NAME            GMTOFF  RULES/SAVE      FORMAT  [UNTIL]
+## Zone        SystemV/AST4ADT -4:00   SystemV         A%sT
+## Zone        SystemV/EST5EDT -5:00   SystemV         E%sT
+## Zone        SystemV/CST6CDT -6:00   SystemV         C%sT
+## Zone        SystemV/MST7MDT -7:00   SystemV         M%sT
+## Zone        SystemV/PST8PDT -8:00   SystemV         P%sT
+## Zone        SystemV/YST9YDT -9:00   SystemV         Y%sT
+## Zone        SystemV/AST4    -4:00   -               AST
+## Zone        SystemV/EST5    -5:00   -               EST
+## Zone        SystemV/CST6    -6:00   -               CST
+## Zone        SystemV/MST7    -7:00   -               MST
+## Zone        SystemV/PST8    -8:00   -               PST
+## Zone        SystemV/YST9    -9:00   -               YST
+## Zone        SystemV/HST10   -10:00  -               HST
diff --git a/extra/zoneinfo/zoneinfo.factor b/extra/zoneinfo/zoneinfo.factor
new file mode 100644 (file)
index 0000000..e298046
--- /dev/null
@@ -0,0 +1,157 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: combinators combinators.smart io.encodings.utf8 io.files
+kernel namespaces sequences splitting unicode.case accessors
+math.parser calendar ;
+IN: zoneinfo
+
+CONSTANT: zoneinfo-paths
+{
+    "vocab:zoneinfo/africa"
+    "vocab:zoneinfo/antarctica"
+    "vocab:zoneinfo/asia"
+    "vocab:zoneinfo/australasia"
+    "vocab:zoneinfo/europe"
+    "vocab:zoneinfo/northamerica"
+    "vocab:zoneinfo/pacificnew"
+    "vocab:zoneinfo/solar87"
+    "vocab:zoneinfo/solar88"
+    "vocab:zoneinfo/solar89"
+    "vocab:zoneinfo/southamerica"
+    "vocab:zoneinfo/systemv"
+    "vocab:zoneinfo/leapseconds"
+}
+
+SYMBOL: last-zone
+
+TUPLE: raw-zone name gmt-offset rules/save format until ;
+TUPLE: raw-rule name from to type in on at save letters ;
+TUPLE: raw-link from to ;
+TUPLE: raw-leap year month day hms corr r/s ;
+
+TUPLE: zone name ;
+TUPLE: rule name from to at ;
+TUPLE: link ;
+TUPLE: leap ;
+
+: rule-to ( m string -- m n )
+    {
+        { "only" [ dup ] }
+        { "max" [ 1/0. ] }
+        [ string>number ]
+    } case ;
+
+: raw-rule>rule ( raw-rule -- rule )
+    ;
+
+: parse-rule ( seq -- rule )
+    [
+        {
+            [ drop ]
+            [ ]
+            [ ]
+            [ ]
+            [ ]
+            [ ]
+            [ ]
+            [ ]
+            [ ]
+            [ ]
+        } spread
+    ] input<sequence raw-rule boa ;
+
+: raw-zone>zone ( raw-zone -- zone )
+    ;
+
+: parse-zone ( seq -- zone )
+    {
+        [ second ]
+        [ third ]
+        [ fourth ]
+        [ 4 swap nth ]
+        [ 5 tail harvest ]
+    } cleave raw-zone boa ;
+
+: parse-partial-zone ( seq -- zone )
+    [ last-zone get name>> ] dip
+    {
+        [ first ]
+        [ second ]
+        [ 2 swap nth ]
+        [ 3 tail harvest ]
+    } cleave raw-zone boa ;
+
+: raw-link>link ( raw-link -- link )
+    ;
+
+: parse-link ( seq -- link )
+    [
+        {
+            [ drop ]
+            [ ]
+            [ ]
+        } spread
+    ] input<sequence raw-link boa ;
+
+: raw-leap>leap ( raw-leap -- leap )
+    ;
+
+: parse-leap ( seq -- link )
+    [
+        {
+            [ drop ]
+            [ ]
+            [ ]
+            [ ]
+            [ ]
+            [ ]
+            [ ]
+        } spread
+    ] input<sequence raw-leap boa ;
+
+: parse-line ( seq -- tuple )
+    dup first >lower
+    {
+        { "zone" [ parse-zone dup last-zone set raw-zone>zone ] }
+        { "rule" [ parse-rule raw-rule>rule ] }
+        { "link" [ parse-link raw-link>link ] }
+        { "leap" [ parse-leap raw-leap>leap ] }
+        [ drop harvest parse-partial-zone ]
+    } case ;
+
+: parse-zoneinfo-file ( path -- seq )
+    utf8 file-lines
+    [ "#" split1 drop ] map harvest
+    [ "\t " split harvest ] map harvest
+    [ [ parse-line ] map ] with-scope ;
+
+: load-zoneinfo-files ( -- seq )
+    zoneinfo-paths [ parse-zoneinfo-file ] map ;
+
+
+
+! Rule
+! name - string
+! from - year or "min"
+! name    "France"
+! from    "1938"  or "min"
+! to      "1945" or "max" or "only"
+! type    "-"  always "-"
+! in      "Mar"  -- 3-letter month name
+! on      "26"  or "Mon>=15"  or lastSun lastFri
+! at      "23:00s"  "12:13:00s" "1:00s" "1:00u"
+! save    "-0:00:05" "1:00" "0:14:15"
+! letters "S" or "-" or "AMT" "BDST"
+
+! Zone
+! name       "Indian/Maldives"
+! gmt-offset "4:54:00" "9:55:56" "-9:55:56"
+! rules/save "-" "0:20" "0:30" "1:00" "AN" "W-Eur" "Winn" "Zion" "sol87" "sol88"
+! format     "LMT" "%s" "%sT" "A%sT" "AC%sT" "ACT"
+! until      { "1880" }
+    ! { "1847" "Dec" "1" "0:00s" }
+    ! { "1883" "Nov" "18" "12:12:57" }
+    ! { "1989" "Sep" "lastSun" "2:00s" }
+
+! Link
+! T{ link { from "Asia/Riyadh88" } { to "Mideast/Riyadh88" } }
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
diff --git a/unmaintained/animations/animations-docs.factor b/unmaintained/animations/animations-docs.factor
new file mode 100644 (file)
index 0000000..3e426a2
--- /dev/null
@@ -0,0 +1,67 @@
+USING: help.markup help.syntax ;
+IN: animations
+
+HELP: animate ( quot duration -- )
+
+{ $values
+    { "quot" "a quot which uses " { $link progress } }
+    { "duration" "a duration of time" }
+}
+{ $description
+    { $link animate } " calls " { $link reset-progress }
+    " , then continously calls the given quot until the"
+    " duration of time has elapsed. The quot should use "
+    { $link progress } " at least once."
+}
+{ $examples
+    { $unchecked-example 
+        "USING: animations calendar threads prettyprint ;"
+        "[ 1 sleep progress unparse write \" ms elapsed\" print ] "
+        "1/20 seconds animate ;"
+        "46 ms elapsed\n17 ms elapsed"
+    }
+    { $notes "The amount of time elapsed between these iterations will very." }
+} ;
+
+HELP: reset-progress ( -- )
+{ $description
+    "Initiates the timer. Call this before using "
+    "a loop which makes use of " { $link progress } "."
+} ;
+
+HELP: progress
+{ $values { "time" "an integer" } }
+{ $description
+    "Gives the time elapsed since the last time"
+    " this word was called, in milliseconds." 
+}
+{ $examples
+    { $unchecked-example
+        "USING: animations threads prettyprint ;"
+        "reset-progress 3 "
+        "[ 1 sleep progress unparse write \"ms elapsed\" print ] "
+        "times ;"
+        "31 ms elapsed\n18 ms elapsed\n16 ms elapsed"
+    }
+    { $notes "The amount of time elapsed between these iterations will very." }
+} ;
+
+ARTICLE: "animations" "Animations"
+"Provides a lightweight framework for properly simulating continuous"
+" functions of real time. This framework helps one create animations "
+"that use rates which do not change across platforms. The speed of the "
+"computer should correlate with the smoothness of the animation, not "
+"the speed of the animation!"
+{ $subsections
+    animate
+    reset-progress
+    progress
+}
+! A little talk about when to use progress and when to use animate
+    { $link progress } " specifically provides the length of time since "
+    { $link reset-progress } " was called, and also calls "
+    { $link reset-progress } " as its last action. This can be directly "
+    "used when one's quote runs for a specific number of iterations, instead "
+    "of a length of time. If the animation is like most, and is expected to "
+    "run for a specific length of time, " { $link animate } " should be used." ;
+ABOUT: "animations"
\ No newline at end of file
diff --git a/unmaintained/animations/animations.factor b/unmaintained/animations/animations.factor
new file mode 100644 (file)
index 0000000..8f416dc
--- /dev/null
@@ -0,0 +1,17 @@
+! Small library for cross-platform continuous functions of real time
+
+USING: kernel shuffle system locals
+prettyprint math io namespaces threads calendar ;
+IN: animations
+
+SYMBOL: last-loop
+SYMBOL: sleep-period
+
+: reset-progress ( -- ) millis last-loop set ;
+! : my-progress ( -- progress ) millis 
+: progress ( -- time ) millis last-loop get - reset-progress ;
+: progress-peek ( -- progress ) millis last-loop get - ;
+: set-end ( duration -- end-time ) duration>milliseconds millis + ;
+: loop ( quot end -- ) dup millis > [ [ dup call ] dip loop ] [ 2drop ] if ; inline
+: animate ( quot duration -- ) reset-progress set-end loop ; inline
+: sample ( revs quot -- avg ) reset-progress dupd times progress swap / ; inline
diff --git a/unmaintained/animations/authors.txt b/unmaintained/animations/authors.txt
new file mode 100644 (file)
index 0000000..137b160
--- /dev/null
@@ -0,0 +1 @@
+Reginald Ford
\ No newline at end of file
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
diff --git a/unmaintained/drills/deployed/deploy.factor b/unmaintained/drills/deployed/deploy.factor
new file mode 100644 (file)
index 0000000..c1e9307
--- /dev/null
@@ -0,0 +1,14 @@
+USING: tools.deploy.config ;
+H{
+    { deploy-name "drills" }
+    { deploy-c-types? t }
+    { "stop-after-last-window?" t }
+    { deploy-unicode? t }
+    { deploy-threads? t }
+    { deploy-reflection 6 }
+    { deploy-word-defs? t }
+    { deploy-math? t }
+    { deploy-ui? t }
+    { deploy-word-props? t }
+    { deploy-io 3 }
+}
diff --git a/unmaintained/drills/deployed/deployed.factor b/unmaintained/drills/deployed/deployed.factor
new file mode 100644 (file)
index 0000000..5681c73
--- /dev/null
@@ -0,0 +1,36 @@
+USING: arrays cocoa.dialogs combinators continuations
+fry grouping io.encodings.utf8 io.files io.styles kernel math
+math.parser models models.arrow models.history namespaces random
+sequences splitting ui ui.gadgets.alerts ui.gadgets.book-extras
+ui.gadgets.books ui.gadgets.buttons ui.gadgets.frames
+ui.gadgets.grids ui.gadgets.labels ui.gadgets.tracks fonts
+wrap.strings system ;
+EXCLUDE: accessors => change-model ;
+IN: drills.deployed
+SYMBOLS: it startLength ;
+: big ( gadget -- gadget ) T{ font { name "sans-serif" } { size 30 } } >>font ;
+: card ( model quot -- button ) <arrow> <label-control> big [ next ] <book-btn> ;
+: op ( quot str -- gadget ) <label> big swap <book-bevel-btn> ;
+
+: show ( model -- gadget ) dup it set-global [ random ] <arrow>
+   { [ [ first ] card ]
+     [ [ second ] card ]
+     [ '[ |<< it get _ model-changed ] "No" op ]
+          [ '[ |<< [ it get [
+        _ value>> swap remove
+        [ [ it get go-back ] "Drill Complete" alert return ] when-empty
+     ] change-model ] with-return ] "Yes" op ]
+   } cleave
+2array { 1 0 } <track> swap [ 0.5 track-add ] each
+3array <book*> 3 3 <frame> { 1 1 } >>filled-cell { 450 175 } >>pref-dim swap { 1 1 } grid-add
+it get [ length startLength get swap - number>string "/" startLength get number>string 3append ] <arrow> <label-control> { 1 2 } grid-add ;
+
+: drill ( -- ) [
+   open-panel [
+         [ utf8 file-lines [ "\t" split [ 25 wrap-string ] map ] map dup [ first2 swap 2array ] map append ] map concat
+            [ length startLength set-global ] keep <history> [ add-history ] [ show ] bi
+         "Got it?" open-window
+   ] [ 0 exit ] if*
+] with-ui ;
+
+MAIN: drill
\ No newline at end of file
diff --git a/unmaintained/drills/deployed/tags.txt b/unmaintained/drills/deployed/tags.txt
new file mode 100644 (file)
index 0000000..6bf6830
--- /dev/null
@@ -0,0 +1 @@
+unportable
diff --git a/unmaintained/drills/drills.factor b/unmaintained/drills/drills.factor
new file mode 100644 (file)
index 0000000..1da1fca
--- /dev/null
@@ -0,0 +1,37 @@
+USING: arrays cocoa.dialogs combinators continuations
+fry grouping io.encodings.utf8 io.files io.styles kernel math
+math.parser models models.arrow models.history namespaces random
+sequences splitting ui ui.gadgets.alerts ui.gadgets.book-extras
+ui.gadgets.books ui.gadgets.buttons ui.gadgets.frames
+ui.gadgets.grids ui.gadgets.labels ui.gadgets.tracks fonts
+wrap.strings ;
+EXCLUDE: accessors => change-model ;
+
+IN: drills
+SYMBOLS: it startLength ;
+: big ( gadget -- gadget ) T{ font { name "sans-serif" } { size 30 } } >>font ;
+: card ( model quot -- button ) <arrow> <label-control> big [ next ] <book-btn> ;
+: op ( quot str -- gadget ) <label> big swap <book-border-btn> ;
+
+: show ( model -- gadget ) dup it set-global [ random ] <arrow>
+   { [ [ first ] card ]
+     [ [ second ] card ]
+     [ '[ |<< it get _ model-changed ] "No" op ]
+          [ '[ |<< [ it get [
+        _ value>> swap remove
+        [ [ it get go-back ] "Drill Complete" alert return ] when-empty
+     ] change-model ] with-return ] "Yes" op ]
+   } cleave
+2array { 1 0 } <track> swap [ 0.5 track-add ] each
+3array <book*> 3 3 <frame> { 1 1 } >>filled-cell { 450 175 } >>pref-dim swap { 1 1 } grid-add
+it get [ length startLength get swap - number>string "/" startLength get number>string 3append ] <arrow> <label-control> { 1 2 } grid-add ;
+
+: drill ( -- ) [
+   open-panel [
+         [ utf8 file-lines [ "\t" split [ 25 wrap-string ] map ] map dup [ first2 swap 2array ] map append ] map concat
+            [ length startLength set-global ] keep <history> [ add-history ] [ show ] bi
+         "Got it?" open-window
+   ] when*
+] with-ui ;
+
+MAIN: drill
\ No newline at end of file
diff --git a/unmaintained/drills/tags.txt b/unmaintained/drills/tags.txt
new file mode 100644 (file)
index 0000000..6bf6830
--- /dev/null
@@ -0,0 +1 @@
+unportable
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
diff --git a/unmaintained/models/combinators/authors.txt b/unmaintained/models/combinators/authors.txt
new file mode 100644 (file)
index 0000000..2300f69
--- /dev/null
@@ -0,0 +1 @@
+Sam Anklesaria
diff --git a/unmaintained/models/combinators/combinators-docs.factor b/unmaintained/models/combinators/combinators-docs.factor
new file mode 100644 (file)
index 0000000..8ac3657
--- /dev/null
@@ -0,0 +1,41 @@
+USING: help.markup help.syntax models models.arrow sequences monads ;
+IN: models.combinators
+
+HELP: merge
+{ $values { "models" "a list of models" } { "model" basic-model } }
+{ $description "Creates a model that merges the updates of others" } ;
+
+HELP: filter-model
+{ $values { "model" model } { "quot" "quotation with stack effect ( a b -- c )" } { "filter-model" filter-model } }
+{ $description "Creates a model that uses the updates of another model only when they satisfy a given predicate" } ;
+
+HELP: fold
+{ $values { "model" model } { "oldval" "starting value" } { "quot" "applied to update and previous values" } { "model" model } }
+{ $description "Similar to " { $link reduce } " but works on models, applying a quotation to the previous and new values at each update" } ;
+
+HELP: switch-models
+{ $values { "model1" model } { "model2" model } { "model'" model } }
+{ $description "Creates a model that starts with the behavior of model2 and switches to the behavior of model1 on its update" } ;
+
+HELP: <mapped>
+{ $values { "model" model } { "quot" "applied to model's value on updates" } { "model" model } }
+{ $description "An expanded version of " { $link <arrow> } ". Use " { $link fmap } " instead." } ;
+
+HELP: when-model
+{ $values { "model" model } { "quot" "called on the model if the quot yields true" } { "cond" "a quotation called on the model's value, yielding a boolean value"  } }
+{ $description "Calls quot when model updates if its value meets the condition set in cond" } ;
+
+HELP: with-self
+{ $values { "quot" "quotation that recieves its own return value" } { "model" model } }
+{ $description "Fixed points for models: the quot reacts to the same model to gives" } ;
+
+HELP: #1
+{ $values { "model" model } { "model'" model } }
+{ $description "Moves a model to the top of its dependencies' connections, thus being notified before the others" } ;
+
+ARTICLE: "models.combinators" "Extending models"
+"The " { $vocab-link "models.combinators" } " library expands models to have discrete start and end times. "
+"Also, it provides methods of manipulating and combining models, expecially useful when programming user interfaces: "
+"The output models of some gadgets (see " { $vocab-link "ui.gadgets.controls" } " ) can be manipulated and used as the input models of others. " ;
+
+ABOUT: "models.combinators"
diff --git a/unmaintained/models/combinators/combinators.factor b/unmaintained/models/combinators/combinators.factor
new file mode 100644 (file)
index 0000000..4896910
--- /dev/null
@@ -0,0 +1,105 @@
+USING: accessors arrays kernel models models.product monads
+sequences sequences.extras shuffle ;
+FROM: syntax => >> ;
+IN: models.combinators
+
+TUPLE: multi-model < model important? ;
+GENERIC: (model-changed) ( model observer -- )
+: <multi-model> ( models kind -- model ) f swap new-model [ [ add-dependency ] curry each ] keep ;
+M: multi-model model-changed over value>> [ (model-changed) ] [ 2drop ] if ;
+M: multi-model model-activated dup dependencies>> [ value>> ] find nip
+   [ swap model-changed ] [ drop ] if* ;
+
+: #1 ( model -- model' ) t >>important? ;
+
+IN: models
+: notify-connections ( model -- )
+    dup connections>> dup [ dup multi-model? [ important?>> ] [ drop f ] if ] find-all
+    [ second tuck [ remove ] dip prefix ] each
+    [ model-changed ] with each ;
+IN: models.combinators
+
+TUPLE: basic-model < multi-model ;
+M: basic-model (model-changed) [ value>> ] dip set-model ;
+: merge ( models -- model ) basic-model <multi-model> ;
+: 2merge ( model1 model2 -- model ) 2array merge ;
+: <basic> ( value -- model ) basic-model new-model ;
+
+TUPLE: filter-model < multi-model quot ;
+M: filter-model (model-changed) [ value>> ] dip 2dup quot>> call( a -- ? )
+   [ set-model ] [ 2drop ] if ;
+: filter-model ( model quot -- filter-model ) [ 1array \ filter-model <multi-model> ] dip >>quot ;
+
+TUPLE: fold-model < multi-model quot base values ;
+M: fold-model (model-changed) 2dup base>> =
+    [ [ [ value>> ] [ [ values>> ] [ quot>> ] bi ] bi* swapd reduce* ] keep set-model ]
+    [ [ [ value>> ] [ values>> ] bi* push ]
+      [ [ [ value>> ] [ [ value>> ] [ quot>> ] bi ] bi* call( val oldval -- newval ) ] keep set-model ] 2bi
+    ] if ;
+M: fold-model model-activated drop ;
+: new-fold-model ( deps -- model ) fold-model <multi-model> V{ } clone >>values ;
+: fold ( model oldval quot -- model ) rot 1array new-fold-model swap >>quot
+   swap >>value ;
+: fold* ( model oldmodel quot -- model ) over [ [ 2array new-fold-model ] dip >>quot ]
+    dip [ >>base ] [ value>> >>value ] bi ;
+
+TUPLE: updater-model < multi-model values updates ;
+M: updater-model (model-changed) [ tuck updates>> =
+   [ [ values>> value>> ] keep set-model ]
+   [ drop ] if ] keep f swap (>>value) ;
+: updates ( values updates -- model ) [ 2array updater-model <multi-model> ] 2keep
+   [ >>values ] [ >>updates ] bi* ;
+
+SYMBOL: switch
+TUPLE: switch-model < multi-model original switcher on ;
+M: switch-model (model-changed) 2dup switcher>> =
+   [ [ value>> ] dip over switch = [ nip [ original>> ] keep f >>on model-changed ] [ t >>on set-model ] if ]
+   [ dup on>> [ 2drop ] [ [ value>> ] dip over [ set-model ] [ 2drop ] if ] if ] if ;
+: switch-models ( model1 model2 -- model' ) swap [ 2array switch-model <multi-model> ] 2keep
+   [ [ value>> >>value ] [ >>original ] bi ] [ >>switcher ] bi* ;
+M: switch-model model-activated [ original>> ] keep model-changed ;
+: >behavior ( event -- behavior ) t >>value ;
+
+TUPLE: mapped-model < multi-model model quot ;
+: new-mapped-model ( model quot class -- mapped-model ) [ over 1array ] dip
+   <multi-model> swap >>quot swap >>model ;
+: <mapped> ( model quot -- model ) mapped-model new-mapped-model ;
+M: mapped-model (model-changed)
+    [ [ value>> ] [ quot>> ] bi* call( old -- new ) ] [ nip ] 2bi
+    set-model ;
+
+TUPLE: side-effect-model < mapped-model ;
+M: side-effect-model (model-changed) [ value>> ] dip [ quot>> call( old -- ) ] 2keep set-model ;
+
+TUPLE: quot-model < mapped-model ;
+M: quot-model (model-changed) nip [ quot>> call( -- b ) ] keep set-model ;
+
+TUPLE: action-value < basic-model parent ;
+: <action-value> ( parent value -- model ) action-value new-model swap >>parent ;
+M: action-value model-activated dup parent>> dup activate-model model-changed ; ! a fake dependency of sorts
+
+TUPLE: action < multi-model quot ;
+M: action (model-changed) [ [ value>> ] [ quot>> ] bi* call( a -- b ) ] keep value>>
+   [ swap add-connection ] 2keep model-changed ;
+: <action> ( model quot -- action-model ) [ 1array action <multi-model> ] dip >>quot dup f <action-value> >>value value>> ;
+
+TUPLE: collection < multi-model ;
+: <collection> ( models -- product ) collection <multi-model> ;
+M: collection (model-changed)
+    nip
+    dup dependencies>> [ value>> ] all?
+    [ dup [ value>> ] product-value swap set-model ]
+    [ drop ] if ;
+M: collection model-activated dup (model-changed) ;
+
+! for side effects
+TUPLE: (when-model) < multi-model quot cond ;
+: when-model ( model quot cond -- model ) rot 1array (when-model) <multi-model> swap >>cond swap >>quot ;
+M: (when-model) (model-changed) [ quot>> ] 2keep
+    [ value>> ] [ cond>> ] bi* call( a -- ? ) [ call( model -- ) ] [ 2drop ] if ;
+
+! only used in construction
+: with-self ( quot: ( model -- model ) -- model ) [ f <basic> dup ] dip call swap [ add-dependency ] keep ; inline
+
+USE: models.combinators.templates
+<< { "$>" "<$" "fmap" } [ fmaps ] each >>
diff --git a/unmaintained/models/combinators/summary.txt b/unmaintained/models/combinators/summary.txt
new file mode 100644 (file)
index 0000000..1e5347e
--- /dev/null
@@ -0,0 +1 @@
+Model combination and manipulation
\ No newline at end of file
diff --git a/unmaintained/models/combinators/templates/templates.factor b/unmaintained/models/combinators/templates/templates.factor
new file mode 100644 (file)
index 0000000..685ad93
--- /dev/null
@@ -0,0 +1,23 @@
+USING: kernel sequences functors fry macros generalizations ;
+IN: models.combinators.templates
+FROM: models.combinators => <collection> #1 ;
+FUNCTOR: fmaps ( W -- )
+W        IS ${W}
+w-n      DEFINES ${W}-n
+w-2      DEFINES 2${W}
+w-3      DEFINES 3${W}
+w-4      DEFINES 4${W}
+w-n*     DEFINES ${W}-n*
+w-2*     DEFINES 2${W}*
+w-3*     DEFINES 3${W}*
+w-4*     DEFINES 4${W}*
+WHERE
+MACRO: w-n ( int -- quot ) dup '[ [ _ narray <collection> ] dip [ _ firstn ] prepend W ] ;
+: w-2 ( a b quot -- mapped ) 2 w-n ; inline
+: w-3 ( a b c quot -- mapped ) 3 w-n ; inline
+: w-4 ( a b c d quot -- mapped ) 4 w-n ; inline
+MACRO: w-n* ( int -- quot ) dup '[ [ _ narray <collection> #1 ] dip [ _ firstn ] prepend W ] ;
+: w-2* ( a b quot -- mapped ) 2 w-n* ; inline
+: w-3* ( a b c quot -- mapped ) 3 w-n* ; inline
+: w-4* ( a b c d quot -- mapped ) 4 w-n* ; inline
+;FUNCTOR
\ No newline at end of file
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
diff --git a/unmaintained/recipes/authors.txt b/unmaintained/recipes/authors.txt
new file mode 100644 (file)
index 0000000..ce0899f
--- /dev/null
@@ -0,0 +1 @@
+Sam Anklesaria
\ No newline at end of file
diff --git a/unmaintained/recipes/icons/back.tiff b/unmaintained/recipes/icons/back.tiff
new file mode 100644 (file)
index 0000000..27b8112
Binary files /dev/null and b/unmaintained/recipes/icons/back.tiff differ
diff --git a/unmaintained/recipes/icons/hate.tiff b/unmaintained/recipes/icons/hate.tiff
new file mode 100644 (file)
index 0000000..d7d5f8e
Binary files /dev/null and b/unmaintained/recipes/icons/hate.tiff differ
diff --git a/unmaintained/recipes/icons/love.tiff b/unmaintained/recipes/icons/love.tiff
new file mode 100644 (file)
index 0000000..ae2fa7b
Binary files /dev/null and b/unmaintained/recipes/icons/love.tiff differ
diff --git a/unmaintained/recipes/icons/more.tiff b/unmaintained/recipes/icons/more.tiff
new file mode 100644 (file)
index 0000000..b4ec27b
Binary files /dev/null and b/unmaintained/recipes/icons/more.tiff differ
diff --git a/unmaintained/recipes/icons/submit.tiff b/unmaintained/recipes/icons/submit.tiff
new file mode 100644 (file)
index 0000000..7c98267
Binary files /dev/null and b/unmaintained/recipes/icons/submit.tiff differ
diff --git a/unmaintained/recipes/recipes.factor b/unmaintained/recipes/recipes.factor
new file mode 100644 (file)
index 0000000..d546859
--- /dev/null
@@ -0,0 +1,61 @@
+USING: accessors arrays colors.constants combinators
+db.sqlite db.tuples db.types kernel locals math
+monads persistency sequences sequences.extras ui ui.gadgets.controls
+ui.gadgets.layout models.combinators ui.gadgets.labels
+ui.gadgets.scrollers ui.pens.solid io.files.temp ;
+FROM: sets => prune ;
+IN: recipes
+
+STORED-TUPLE: recipe { title { VARCHAR 100 } } { votes INTEGER } { txt TEXT } { genre { VARCHAR 100 } } ;
+: <recipe> ( title genre text -- recipe ) recipe new swap >>txt swap >>genre swap >>title 0 >>votes ;
+"recipes.db" temp-file <sqlite-db> recipe define-db
+: top-recipes ( offset search -- recipes ) <query> T{ recipe } rot >>title >>tuple
+    "votes" >>order 30 >>limit swap >>offset get-tuples ;
+: top-genres ( -- genres ) f f top-recipes [ genre>> ] map prune 4 short head-slice ;
+
+: interface ( -- book ) [ 
+     [
+        [ $ TOOLBAR $ ] <hbox> COLOR: AliceBlue <solid> >>interior ,
+        [ "Genres:" <label> , <spacer> $ ALL $ $ GENRES $ ] <hbox>
+            { 5 0 } >>gap COLOR: gray <solid> >>interior ,
+        $ RECIPES $
+     ] <vbox> ,
+     [
+        [ "Title:" <label> , $ TITLE $ "Genre:" <label> , $ GENRE $ ] <hbox> ,
+        $ BODY $
+        $ BUTTON $
+     ] <vbox> ,
+  ] <book*> { 350 245 } >>pref-dim ;
+  
+:: recipe-browser ( -- ) [ [
+    interface
+      <table*> :> tbl
+      "okay" <model-border-btn> BUTTON -> :> ok
+      IMG-MODEL-BTN: submit [ store-tuple ] >>value TOOLBAR -> :> submit
+      IMG-MODEL-BTN: love 1 >>value TOOLBAR ->
+      IMG-MODEL-BTN: hate -1 >>value -> 2array merge :> votes
+      IMG-MODEL-BTN: back -> [ -30 ] <$
+      IMG-MODEL-BTN: more -> [ 30 ] <$ 2array merge :> viewed
+      <spacer> <model-field*> ->% 1 :> search
+      submit ok [ [ drop ] ] <$ 2array merge [ drop ] >>value :> quot
+      viewed 0 [ + ] fold search ok t <basic> "all" <model-btn> ALL ->
+      tbl selection>> votes [ [ + ] curry change-votes modify-tuple ] 2$>
+        4array merge
+        [ drop [ f ] [ "%" dup surround <pattern> ] if-empty top-recipes ] 3fmap :> ups
+      ups [ top-genres [ <model-btn> GENRES -> ] map merge ] bind*
+        [ text>> T{ recipe } swap >>genre get-tuples ] fmap
+      tbl swap ups 2merge >>model
+        [ [ title>> ] [ genre>> ] bi 2array ] >>quot
+        { "Title" "Genre" } >>column-titles dup <scroller> RECIPES ,% 1 actions>>
+      submit [ "" dup dup <recipe> ] <$ 2array merge
+        { [ [ title>> ] fmap <model-field> TITLE ->% .5 ]
+          [ [ genre>> ] fmap <model-field> GENRE ->% .5 ]
+          [ [ txt>> ] fmap <model-editor> BODY ->% 1 ]
+        } cleave
+        [ <recipe> ] 3fmap
+      [ [ 1 ] <$ ]
+      [ quot ok updates #1 [ call( recipe -- ) 0 ] 2fmap ] bi
+      2merge 0 <basic> switch-models >>model
+   ] with-interface "recipes" open-window ] with-ui ;
+
+MAIN: recipe-browser
\ No newline at end of file
diff --git a/unmaintained/recipes/summary.txt b/unmaintained/recipes/summary.txt
new file mode 100644 (file)
index 0000000..98b1ece
--- /dev/null
@@ -0,0 +1 @@
+Database backed recipe sharing
\ No newline at end of file
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
diff --git a/unmaintained/sudokus/authors.txt b/unmaintained/sudokus/authors.txt
new file mode 100644 (file)
index 0000000..ce0899f
--- /dev/null
@@ -0,0 +1 @@
+Sam Anklesaria
\ No newline at end of file
diff --git a/unmaintained/sudokus/sudokus.factor b/unmaintained/sudokus/sudokus.factor
new file mode 100644 (file)
index 0000000..c7bc694
--- /dev/null
@@ -0,0 +1,40 @@
+USING: accessors arrays combinators.short-circuit grouping kernel lists
+lists.lazy locals math math.functions math.parser math.ranges
+models.product monads random sequences sets ui ui.gadgets.controls
+ui.gadgets.layout models.combinators ui.gadgets.alerts vectors fry
+ui.gadgets.labels shuffle ;
+IN: sudokus
+
+: row ( index -- row ) 1 + 9 / ceiling ;
+: col ( index -- col ) 9 mod 1 + ;
+: sq ( index -- square ) [ row ] [ col ] bi [ 3 / ceiling ] bi@ 2array ;
+: near ( a pos -- ? ) { [ [ row ] bi@ = ] [ [ col ] bi@ = ] [ [ sq ] bi@ = ] } 2|| ;
+: nth-or-lower ( n seq -- elt ) [ length 1 - 2dup > [ nip ] [ drop ] if ] keep nth ;
+
+:: solutions ( puzzle random? -- solutions )
+    f puzzle random? [ indices [ f ] [ random? swap nth-or-lower ] if-empty ] [ index ] if
+    [ :> pos
+      1 9 [a,b] 80 iota [ pos near ] filter [ puzzle nth ] map prune diff
+      [ 1array puzzle pos cut-slice rest surround ] map >list [ random? solutions ] bind
+    ] [ puzzle list-monad return ] if* ;
+
+: solution ( puzzle random? -- solution ) dupd solutions dup +nil+ = [ drop "Unsolvable" alert* ] [ nip car ] if ;
+: hint ( puzzle -- puzzle' ) [ [ f swap indices random dup ] [ f solution ] bi nth ] keep swapd >vector [ set-nth ] keep ;
+: create ( difficulty -- puzzle ) 81 [ f ] replicate
+    40 random solution [ [ f swap [ length random ] keep set-nth ] curry times ] keep ;
+
+: do-sudoku ( -- ) [ [
+        [
+            81 [ "" ] replicate <basic> switch-models [ [ <basic> ] map 9 group [ 3 group ] map 3 group
+               [ [ [ <spacer> [ [ <model-field> ->% 2 [ string>number ] fmap ]
+                    map <spacer> ] map concat ] <hbox> , ] map concat <spacer> ] map concat <product>
+               [ "Difficulty:" <label> , "1" <basic> <model-field> -> [ string>number 1 or 1 + 10 * ] fmap
+               "Generate" <model-border-btn> -> updates [ create ] fmap <spacer>
+               "Hint" <model-border-btn> -> "Solve" <model-border-btn> -> ] <hbox> ,
+               roll [ swap updates ] curry bi@
+               [ [ hint ] fmap ] [ [ f solution ] fmap ] bi* 3array merge [ [ [ number>string ] [ "" ] if* ] map ] fmap
+           ] bind
+        ] with-self , ] <vbox> { 280 220 } >>pref-dim
+    "Sudoku Sleuth" open-window ] with-ui ;
+
+MAIN: do-sudoku
diff --git a/unmaintained/sudokus/summary.txt b/unmaintained/sudokus/summary.txt
new file mode 100644 (file)
index 0000000..d66e7be
--- /dev/null
@@ -0,0 +1 @@
+graphical sudoku solver
\ No newline at end of file
old mode 100755 (executable)
new mode 100644 (file)
diff --git a/unmaintained/ui/gadgets/alerts/alerts.factor b/unmaintained/ui/gadgets/alerts/alerts.factor
new file mode 100644 (file)
index 0000000..70943e6
--- /dev/null
@@ -0,0 +1,29 @@
+USING: accessors models monads macros generalizations kernel
+ui ui.gadgets.controls models.combinators ui.gadgets.layout ui.gadgets
+ui.gadgets.labels ui.gadgets.editors ui.gadgets.buttons
+ui.gadgets.packs locals sequences fonts io.styles
+wrap.strings ;
+
+IN: ui.gadgets.alerts
+:: alert ( quot string -- ) <pile> { 10 10 } >>gap 1 >>align
+   string 22 wrap-lines <label> T{ font { name "sans-serif" } { size 18 } } >>font { 200 100 } >>pref-dim add-gadget 
+   "okay" [ close-window ] quot append <border-button> add-gadget "" open-window ;
+
+: alert* ( str -- ) [ ] swap alert ;
+
+:: ask-user ( string -- model' )
+    [
+        string <label>  T{ font { name "sans-serif" } { size 14 } } >>font dup , :> lbl
+        <model-field*> ->% 1 :> fldm
+        "okay" <model-border-btn> :> btn
+        btn -> [ fldm swap updates ]
+               [ [ drop lbl close-window ] $> , ] bi
+    ] <vbox> { 161 86 } >>pref-dim "" open-window ;
+
+MACRO: ask-buttons ( buttons -- quot ) dup length [
+      [ swap
+         [ 22 wrap-lines <label> T{ font { name "sans-serif" } { size 18 } } >>font ,
+         [ [ <model-border-btn> [ close-window ] >>hook -> ] map ] <hbox> , ] <vbox>
+         "" open-window
+      ] dip firstn
+   ] 2curry ;
diff --git a/unmaintained/ui/gadgets/alerts/authors.txt b/unmaintained/ui/gadgets/alerts/authors.txt
new file mode 100644 (file)
index 0000000..ce0899f
--- /dev/null
@@ -0,0 +1 @@
+Sam Anklesaria
\ No newline at end of file
diff --git a/unmaintained/ui/gadgets/alerts/summary.txt b/unmaintained/ui/gadgets/alerts/summary.txt
new file mode 100644 (file)
index 0000000..f1cd420
--- /dev/null
@@ -0,0 +1 @@
+Really simple dialog boxes
\ No newline at end of file
diff --git a/unmaintained/ui/gadgets/comboboxes/authors.txt b/unmaintained/ui/gadgets/comboboxes/authors.txt
new file mode 100644 (file)
index 0000000..ce0899f
--- /dev/null
@@ -0,0 +1 @@
+Sam Anklesaria
\ No newline at end of file
diff --git a/unmaintained/ui/gadgets/comboboxes/comboboxes.factor b/unmaintained/ui/gadgets/comboboxes/comboboxes.factor
new file mode 100644 (file)
index 0000000..3eb1180
--- /dev/null
@@ -0,0 +1,22 @@
+USING: accessors arrays kernel math.rectangles sequences
+ui.gadgets.controls models.combinators ui.gadgets ui.gadgets.glass
+ui.gadgets.labels ui.gestures ;
+QUALIFIED-WITH: ui.gadgets.tables tbl
+IN: ui.gadgets.comboboxes
+
+TUPLE: combo-table < table spawner ;
+
+M: combo-table handle-gesture [ call-next-method drop ] 2keep swap
+   T{ button-up } = [
+      [ spawner>> ]
+      [ tbl:selected-row [ swap set-control-value ] [ 2drop ] if ]
+      [ hide-glass ] tri
+   ] [ drop ] if t ;
+
+TUPLE: combobox < label-control table ;
+combobox H{
+   { T{ button-down } [ dup table>> over >>spawner <zero-rect> show-glass ] }
+} set-gestures
+
+: <combobox> ( options -- combobox ) [ first [ combobox new-label ] keep <basic> >>model ] keep
+    <basic> combo-table new-table [ 1array ] >>quot >>table ;
\ No newline at end of file
diff --git a/unmaintained/ui/gadgets/comboboxes/summary.txt b/unmaintained/ui/gadgets/comboboxes/summary.txt
new file mode 100644 (file)
index 0000000..0f2ce2b
--- /dev/null
@@ -0,0 +1 @@
+Combo boxes have a model choosen from a list of options
\ No newline at end of file
diff --git a/unmaintained/ui/gadgets/controls/authors.txt b/unmaintained/ui/gadgets/controls/authors.txt
new file mode 100644 (file)
index 0000000..2300f69
--- /dev/null
@@ -0,0 +1 @@
+Sam Anklesaria
diff --git a/unmaintained/ui/gadgets/controls/controls-docs.factor b/unmaintained/ui/gadgets/controls/controls-docs.factor
new file mode 100644 (file)
index 0000000..1df6005
--- /dev/null
@@ -0,0 +1,71 @@
+USING: accessors help.markup help.syntax ui.gadgets.buttons
+ui.gadgets.editors models ui.gadgets ;
+IN: ui.gadgets.controls
+
+HELP: <model-btn>
+{ $values { "gadget" "the button's label" } { "button" button } }
+{ $description "Creates an button whose signal updates on clicks.  " } ;
+
+HELP: <model-border-btn>
+{ $values { "text" "the button's label" } { "button" button } }
+{ $description "Creates an button whose signal updates on clicks.  " } ;
+
+HELP: <table>
+{ $values { "model" "values the table is to display" } { "table" table } }
+{ $description "Creates an " { $link table } } ;
+
+HELP: <table*>
+{ $values { "table" table } }
+{ $description "Creates an " { $link table } " with no initial values to display" } ;
+
+HELP: <list>
+{ $values { "column-model" "values the table is to display" } { "table" table } }
+{ $description "Creates an " { $link table } " with a val-quot that renders each element as its own row" } ;
+
+HELP: <list*>
+{ $values { "table" table } }
+{ $description "Creates an model-list with no initial values to display" } ;
+
+HELP: indexed
+{ $values { "table" table } }
+{ $description "Sets the output model of an table to the selected-index, rather than the selected-value" } ;
+
+HELP: <model-field>
+{ $values { "model" model } { "gadget" model-field } }
+{ $description "Creates a field with an initial value" } ;
+
+HELP: <model-field*>
+{ $values { "field" model-field } }
+{ $description "Creates a field with an empty initial value" } ;
+
+HELP: <empty-field>
+{ $values { "model" model } { "field" model-field } }
+{ $description "Creates a field with an empty initial value that switches to another signal on its update" } ;
+
+HELP: <model-editor>
+{ $values { "model" model } { "gadget" model-field } }
+{ $description "Creates an editor with an initial value" } ;
+
+HELP: <model-editor*>
+{ $values { "editor" "an editor" } }
+{ $description "Creates a editor with an empty initial value" } ;
+
+HELP: <empty-editor>
+{ $values { "model" model } { "editor" "an editor" } }
+{ $description "Creates a field with an empty initial value that switches to another signal on its update" } ;
+
+HELP: <model-action-field>
+{ $values { "field" action-field } }
+{ $description "Field that updates its model with its contents when the user hits the return key" } ;
+
+HELP: IMG-MODEL-BTN:
+{ $syntax "IMAGE-MODEL-BTN: filename" }
+{ $description "Creates a button using a tiff image named as specified found in the icons subdirectory of the vocabulary path" } ;
+
+HELP: IMG-BTN:
+{ $syntax "[ do-something ] IMAGE-BTN: filename" }
+{ $description "Creates a button using a tiff image named as specified found in the icons subdirectory of the vocabulary path, calling the specified quotation on click" } ;
+
+HELP: output-model
+{ $values { "gadget" gadget } { "model" model } }
+{ $description "Returns the model a gadget uses for output. Often the same as " { $link model>> } } ;
\ No newline at end of file
diff --git a/unmaintained/ui/gadgets/controls/controls.factor b/unmaintained/ui/gadgets/controls/controls.factor
new file mode 100644 (file)
index 0000000..5de6da8
--- /dev/null
@@ -0,0 +1,83 @@
+USING: accessors assocs arrays kernel models monads sequences
+models.combinators ui.gadgets ui.gadgets.borders ui.gadgets.buttons
+ui.gadgets.buttons.private ui.gadgets.editors ui.gadgets.editors.private
+words images.loader ui.gadgets.scrollers ui.images vocabs.parser lexer
+models.range ui.gadgets.sliders ;
+QUALIFIED-WITH: ui.gadgets.sliders slider
+QUALIFIED-WITH: ui.gadgets.tables tbl
+EXCLUDE: ui.gadgets.editors => model-field ;
+IN: ui.gadgets.controls
+
+TUPLE: model-btn < button hook value ;
+: <model-btn> ( gadget -- button ) [
+      [ dup hook>> [ call( button -- ) ] [ drop ] if* ]
+      [ [ [ value>> ] [ ] bi or ] keep set-control-value ]
+      [ model>> f swap (>>value) ] tri
+   ] model-btn new-button f <basic> >>model ;
+: <model-border-btn> ( text -- button ) <model-btn> border-button-theme ;
+
+TUPLE: table < tbl:table { quot initial: [ ] } { val-quot initial: [ ] } color-quot column-titles column-alignment actions ;
+M: table tbl:column-titles column-titles>> ;
+M: table tbl:column-alignment column-alignment>> ;
+M: table tbl:row-columns quot>> [ call( a -- b ) ] [ drop f ] if* ;
+M: table tbl:row-value val-quot>> [ call( a -- b ) ]  [ drop f ] if* ;
+M: table tbl:row-color color-quot>> [ call( a -- b ) ]  [ drop f ] if* ;
+
+: new-table ( model class -- table ) f swap tbl:new-table dup >>renderer
+   f <basic> >>actions dup actions>> [ set-model ] curry >>action ;
+: <table> ( model -- table ) table new-table ;
+: <table*> ( -- table ) V{ } clone <model> <table> ;
+: <list> ( column-model -- table ) <table> [ 1array ] >>quot ;
+: <list*> ( -- table ) V{ } clone <model> <list> ;
+: indexed ( table -- table ) f >>val-quot ;
+
+TUPLE: model-field < field model* ;
+: init-field ( model -- model' ) [ [ ] [ "" ] if* ] change-value ;
+: <model-field> ( model -- gadget ) model-field new-field swap init-field >>model* ;
+M: model-field graft*
+    [ [ model*>> value>> ] [ editor>> ] bi set-editor-string ]
+    [ dup editor>> model>> add-connection ]
+    [ dup model*>> add-connection ] tri ;
+M: model-field ungraft*
+   [ dup editor>> model>> remove-connection ]
+   [ dup model*>> remove-connection ] bi ;
+M: model-field model-changed 2dup model*>> =
+    [ [ value>> ] [ editor>> ] bi* set-editor-string ]
+    [ nip [ editor>> editor-string ] [ model*>> ] bi set-model ] if ;
+: (new-field) ( editor field -- gadget ) [ new-editor ] dip new-border dup gadget-child >>editor
+    field-theme { 1 0 } >>align ; inline
+: <model-field*> ( -- field ) "" <model> <model-field> ;
+: <empty-field> ( model -- field ) "" <model> switch-models <model-field> ;
+: <model-editor> ( model -- gadget ) multiline-editor model-field (new-field) swap init-field >>model* ;
+: <model-editor*> ( -- editor ) "" <model> <model-editor> ;
+: <empty-editor> ( model -- editor ) "" <model> switch-models <model-editor> ;
+
+: <model-action-field> ( -- field ) f <action-field> dup [ set-control-value ] curry >>quot
+    f <model> >>model ;
+
+: <slider> ( init page min max step -- slider ) <range> horizontal slider:<slider> ;
+
+: image-prep ( -- image ) scan current-vocab name>> "vocab:" "/icons/" surround ".tiff" surround <image-name> dup cached-image drop ;
+SYNTAX: IMG-MODEL-BTN: image-prep [ <model-btn> ] curry append! ;
+
+SYNTAX: IMG-BTN: image-prep [ swap <button> ] curry append! ;
+
+GENERIC: output-model ( gadget -- model )
+M: gadget output-model model>> ;
+M: table output-model dup val-quot>> [ selection>> ] [ selection-index>> ] if ;
+M: model-field output-model model*>> ;
+M: scroller output-model viewport>> children>> first output-model ;
+M: slider output-model model>> range-model ;
+
+IN: accessors
+M: model-btn text>> children>> first text>> ;
+
+IN: ui.gadgets.controls
+
+SINGLETON: gadget-monad
+INSTANCE: gadget-monad monad
+INSTANCE: gadget monad
+M: gadget monad-of drop gadget-monad ;
+M: gadget-monad return drop <gadget> swap >>model ;
+M: gadget >>= output-model [ swap call( x -- y ) ] curry ; 
diff --git a/unmaintained/ui/gadgets/controls/summary.txt b/unmaintained/ui/gadgets/controls/summary.txt
new file mode 100644 (file)
index 0000000..eeef94d
--- /dev/null
@@ -0,0 +1 @@
+Gadgets with expanded model usage
\ No newline at end of file
diff --git a/unmaintained/ui/gadgets/layout/authors.txt b/unmaintained/ui/gadgets/layout/authors.txt
new file mode 100644 (file)
index 0000000..2300f69
--- /dev/null
@@ -0,0 +1 @@
+Sam Anklesaria
diff --git a/unmaintained/ui/gadgets/layout/layout-docs.factor b/unmaintained/ui/gadgets/layout/layout-docs.factor
new file mode 100644 (file)
index 0000000..cd8f62b
--- /dev/null
@@ -0,0 +1,53 @@
+USING: help.markup help.syntax models ui.gadgets.tracks ;
+IN: ui.gadgets.layout
+
+HELP: ,
+{ $values { "item" "a gadget or model" } }
+{ $description "Used in a series of gadgets created by a box, accumulating the gadget" } ;
+
+HELP: ,%
+{ $syntax "gadget ,% width" }
+{ $description "Like ',' but stretches the gadget to always fill a percent of the parent" } ;
+
+HELP: ->
+{ $values { "uiitem" "a gadget or model" } { "model" model } }
+{ $description "Like ',' but passes its model on for further use." } ;
+
+HELP: ->%
+{ $syntax "gadget ,% width" }
+{ $description "Like '->' but stretches the gadget to always fill a percent of the parent" } ;
+
+HELP: <spacer>
+{ $description "Grows to fill any empty space in a box" } ;
+
+HELP: <hbox>
+{ $values { "gadgets" "a list of gadgets" } { "track" track } }
+{ $syntax "[ gadget , gadget , ... ] <hbox>" }
+{ $description "Creates an horizontal track containing the gadgets listed in the quotation" } ;
+
+HELP: <vbox>
+{ $values { "gadgets" "a list of gadgets" } { "track" track } }
+{ $syntax "[ gadget , gadget , ... ] <hbox>" }
+{ $description "Creates an vertical track containing the gadgets listed in the quotation" } ;
+
+HELP: $
+{ $syntax "$ PLACEHOLDER-NAME $" }
+{ $description "Defines an insertion point in a template named PLACEHOLDER-NAME which can be used by calling its name" } ;
+
+HELP: with-interface
+{ $values { "quot" "quotation that builds a template and inserts into it" } }
+{ $description "Create templates, used with " { $link POSTPONE: $ } } ;
+
+ARTICLE: "ui.gadgets.layout" "GUI Layout"
+"Laying out GUIs works the same way as building lists with " { $vocab-link "make" }
+". Gadgets are layed out using " { $vocab-link "ui.gadgets.tracks" } " through " { $link <hbox> } " and " { $link <vbox> } ", which allow both fixed and percentage widths. "
+{ $link , } " and " { $link -> }  " add a model or gadget to the gadget you're building. "
+"Also, books can be made with " { $link <book> } ". "
+{ $link <spacer> } "s add flexable space between items. " $nl
+"Using " { $link with-interface } ", one can pre-build templates to add items to later: "
+"Like in the StringTemplate framework for java, placeholders are defined using $ PLACERHOLDER-NAME $ "
+"Using PLACEHOLDER-NAME again sets it as the current insertion point. "
+"For examples using normal layout, see the " { $vocab-link "sudokus" } " demo. "
+"For examples of templating, see the " { $vocab-link "recipes" } " demo. " ;
+
+ABOUT: "ui.gadgets.layout"
\ No newline at end of file
diff --git a/unmaintained/ui/gadgets/layout/layout.factor b/unmaintained/ui/gadgets/layout/layout.factor
new file mode 100644 (file)
index 0000000..c287b9a
--- /dev/null
@@ -0,0 +1,90 @@
+USING: accessors assocs arrays fry kernel lexer make math.parser
+models monads namespaces parser sequences
+sequences.extras models.combinators ui.gadgets
+ui.gadgets.tracks words ui.gadgets.controls ;
+QUALIFIED: make
+QUALIFIED-WITH: ui.gadgets.books book
+IN: ui.gadgets.layout
+
+SYMBOL: templates
+TUPLE: layout gadget size ; C: <layout> layout
+TUPLE: placeholder < gadget members ;
+: <placeholder> ( -- placeholder ) placeholder new V{ } clone >>members ;
+
+: (remove-members) ( placeholder members -- ) [ [ model? ] filter swap parent>> model>> [ remove-connection ] curry each ]
+    [ nip [ gadget? ] filter [ unparent ] each ] 2bi ;
+
+: remove-members ( placeholder -- ) dup members>> [ drop ] [ [ (remove-members) ] keep delete-all ] if-empty ;
+: add-member ( obj placeholder -- ) over layout? [ [ gadget>> ] dip ] when members>> push ;
+
+: , ( item -- ) make:, ;
+: make* ( quot -- list ) { } make ; inline
+
+! Just take the previous mentioned placeholder and use it
+! If there is no previously mentioned placeholder, we're probably making a box, and will create the placeholder ourselves
+DEFER: with-interface
+: insertion-quot ( quot -- quot' )
+    make:building get [ [ placeholder? ] find-last nip [ <placeholder> dup , ] unless*
+    [ templates get ] 2dip swap '[ [ _ templates set _ , @ ] with-interface ] ] when* ;
+
+SYNTAX: ,% scan string>number [ <layout> , ] curry append! ;
+SYNTAX: ->% scan string>number '[ [ _ <layout> , ] [ output-model ] bi ] append! ;
+
+GENERIC: -> ( uiitem -- model )
+M: gadget -> dup , output-model ;
+M: model -> dup , ;
+
+: <spacer> ( -- ) <gadget> 1 <layout> , ;
+
+: add-layout ( track layout -- track ) [ gadget>> ] [ size>> ] bi track-add ;
+: layouts ( sized? gadgets -- layouts ) [ [ gadget? ] [ layout? ] bi or ] filter swap
+   [ [ dup layout? [ f <layout> ] unless ] map ]
+   [ [ dup gadget? [ gadget>> ] unless ] map ] if ;
+: make-layout ( building sized? -- models layouts ) [ swap layouts ] curry
+   [ make* [ [ model? ] filter ] ] dip bi ; inline
+: <box> ( gadgets type -- track )
+   [ t make-layout ] dip <track>
+   swap [ add-layout ] each
+   swap [ <collection> >>model ] unless-empty ; inline
+: <hbox> ( gadgets -- track ) horizontal <box> ; inline
+: <vbox> ( gadgets -- track ) vertical <box> ; inline
+
+: make-book ( models gadgets model -- book ) book:<book> swap [ "No models in books" throw ] unless-empty ;
+: <book> ( quot: ( -- model ) -- book ) f make-layout rot 0 >>value make-book ; inline
+: <book*> ( quot -- book ) f make-layout f make-book ; inline
+
+ERROR: not-in-template word ;
+SYNTAX: $ CREATE-WORD dup
+    [ [ dup templates get at [ nip , ] [ not-in-template ] if* ] curry (( -- )) define-declared "$" expect ]
+    [ [ <placeholder> [ swap templates get set-at ] keep , ] curry ] bi append! ;
+
+: insert-gadget ( number parent gadget -- ) -rot [ but-last insert-nth ] change-children drop ;
+: insert-size ( number parent size -- ) -rot [ but-last insert-nth ] change-sizes drop ;
+: insertion-point ( placeholder -- number parent ) dup parent>> [ children>> index ] keep ;
+
+GENERIC: >layout ( gadget -- layout )
+M: gadget >layout f <layout> ;
+M: layout >layout ;
+
+GENERIC# (add-gadget-at) 2 ( parent item n -- )
+M: gadget (add-gadget-at) -rot [ add-gadget ] keep insert-gadget ;
+M: track (add-gadget-at) -rot >layout [ add-layout ] keep [ gadget>> insert-gadget ] [ size>> insert-size ] 3bi ;
+
+GENERIC# add-gadget-at 1 ( item location -- )
+M: object add-gadget-at insertion-point -rot (add-gadget-at) ;
+M: model add-gadget-at parent>> dup book:book? [ "No models in books" throw ]
+   [ dup model>> dup collection? [ nip swap add-connection ] [ drop [ 1array <collection> ] dip (>>model) ] if ] if ;
+: track-add-at ( item location size -- ) swap [ <layout> ] dip add-gadget-at ;
+: (track-add-at) ( parent item n size -- ) swap [ <layout> ] dip (add-gadget-at) ;
+
+: insert-item ( item location -- ) [ dup get [ drop ] [ remove-members ] if ] [ on ] [ ] tri
+    [ add-member ] 2keep add-gadget-at ;
+
+: insert-items ( makelist -- ) t swap [ dup placeholder? [ nip ] [ over insert-item ] if ] each drop ;
+
+: with-interface ( quot -- ) [ make* ] curry H{ } clone templates rot with-variable [ insert-items ] with-scope ; inline
+
+M: model >>= [ swap insertion-quot <action> ] curry ;
+M: model fmap insertion-quot <mapped> ;
+M: model $> insertion-quot side-effect-model new-mapped-model ;
+M: model <$ insertion-quot quot-model new-mapped-model ;
diff --git a/unmaintained/ui/gadgets/layout/summary.txt b/unmaintained/ui/gadgets/layout/summary.txt
new file mode 100644 (file)
index 0000000..30b5ef5
--- /dev/null
@@ -0,0 +1 @@
+Syntax for easily building GUIs and using templates
\ No newline at end of file
diff --git a/unmaintained/ui/gadgets/poppers/authors.txt b/unmaintained/ui/gadgets/poppers/authors.txt
new file mode 100644 (file)
index 0000000..ce0899f
--- /dev/null
@@ -0,0 +1 @@
+Sam Anklesaria
\ No newline at end of file
diff --git a/unmaintained/ui/gadgets/poppers/poppers.factor b/unmaintained/ui/gadgets/poppers/poppers.factor
new file mode 100644 (file)
index 0000000..1c815d5
--- /dev/null
@@ -0,0 +1,50 @@
+! Copyright (C) 2009 Sam Anklesaria
+! See http://factorcode.org/license.txt for BSD license.
+USING: arrays accessors combinators kernel math
+models models.combinators namespaces sequences
+ui.gadgets ui.gadgets.controls ui.gadgets.layout
+ui.gadgets.tracks ui.gestures ui.gadgets.line-support ;
+EXCLUDE: ui.gadgets.editors => model-field ;
+IN: ui.gadgets.poppers
+
+TUPLE: popped < model-field { fatal? initial: t } ;
+TUPLE: popped-editor < multiline-editor ;
+: <popped> ( text -- gadget ) <basic> init-field popped-editor popped (new-field) swap >>model* ;
+
+: set-expansion ( popped size -- ) over dup parent>> [ children>> index ] [ sizes>> ] bi set-nth relayout ;
+: new-popped ( popped -- ) insertion-point "" <popped>
+    [ rot 1 + f (track-add-at) ] keep [ relayout ] [ request-focus ] bi ;
+: focus-prev ( popped -- ) dup parent>> children>> length 1 =
+    [ drop ] [
+        insertion-point [ 1 - dup -1 = [ drop 1 ] when ] [ children>> ] bi* nth
+        [ request-focus ] [ editor>> end-of-document ] bi
+    ] if ;
+: initial-popped ( popper -- ) "" <popped> [ f track-add drop ] keep request-focus ;
+
+TUPLE: popper < track { unfocus-hook initial: [ drop ] } ;
+! list of strings is model (make shown objects implement sequence protocol)
+: <popper> ( model -- popper ) vertical popper new-track swap >>model ;
+
+M: popped handle-gesture swap {
+    { gain-focus [ 1 set-expansion f ] }
+    { lose-focus [ dup parent>>
+        [ [ unfocus-hook>> call( a -- ) ] curry [ f set-expansion ] bi ]
+        [ drop ] if* f
+    ] }
+    { T{ key-up f f "RET" } [ dup editor>> delete-previous-character new-popped f ] }
+    { T{ key-up f f "BACKSPACE" } [ dup editor>> editor-string "" =
+        [ dup fatal?>> [ [ focus-prev ] [ unparent ] bi ] [ t >>fatal? drop ] if ]
+        [ f >>fatal? drop ] if f
+    ] }
+    [ swap call-next-method ]
+} case ;
+
+M: popper handle-gesture swap T{ button-down f f 1 } =
+    [ hand-click# get 2 = [ initial-popped ] [ drop ] if ] [ drop ] if f ;
+
+M: popper model-changed
+    [ children>> [ unparent ] each ]
+    [ [ value>> [ <popped> ] map ] dip [ f track-add ] reduce request-focus ] bi ;
+
+M: popped pref-dim* editor>> [ pref-dim* first ] [ line-height ] bi 2array ;
+M: popper focusable-child* children>> [ t ] [ first ] if-empty ;
\ No newline at end of file
old mode 100755 (executable)
new mode 100644 (file)
index 1d7e6f9cc67600c1bcf25be756d0d2169ee655e1..8b137891791fe96927ad78e64b0aad7bded08bdc 100644 (file)
@@ -1 +1 @@
-PLAF_DLL_OBJS += vmpp/cpu-arm.o
+
index 384b2fd57aa5f6ad08dfe52ab033d937dcbbb540..a0dbe228e530a99041057c188da9c5d536041e85 100644 (file)
@@ -1,4 +1,4 @@
 include vm/Config.unix
 PLAF_DLL_OBJS += vm/os-genunix.o vm/os-freebsd.o
 CFLAGS += -export-dynamic
-LIBS = -L/usr/local/lib/ -lm $(X11_UI_LIBS)
+LIBS = -L/usr/local/lib/ -lm -lrt $(X11_UI_LIBS)
index eb3a19d75a08fe82673b571a7d9e158f86ea3a7d..4a859b1216ec1c404a5ee04bd182146669000432 100644 (file)
@@ -1,4 +1,4 @@
 include vm/Config.unix
 PLAF_DLL_OBJS += vm/os-genunix.o vm/os-linux.o
 CFLAGS += -export-dynamic
-LIBS = -ldl -lm -lpthread $(X11_UI_LIBS)
+LIBS = -ldl -lm -lrt -lpthread $(X11_UI_LIBS)
index ba5ecd19a5729edd37483b86d83e3a99eb94274e..72a4056c90b4e44c96b9bc66f09a4681f81c7b97 100644 (file)
@@ -2,4 +2,4 @@ include vm/Config.unix
 PLAF_DLL_OBJS += vm/os-genunix.o vm/os-netbsd.o
 CFLAGS += -export-dynamic
 LIBPATH = -L/usr/X11R7/lib -Wl,-rpath,/usr/X11R7/lib -L/usr/pkg/lib -Wl,-rpath,/usr/pkg/lib
-LIBS = -lm -lssl -lcrypto $(X11_UI_LIBS)
+LIBS = -lm -lrt -lssl -lcrypto $(X11_UI_LIBS)
index a172cbfaba3ae47358da23c2609032846aed0e7c..c7d2672e6b326209ee1e11ab4ab8e275e206e8ae 100644 (file)
@@ -2,5 +2,5 @@ include vm/Config.unix
 PLAF_DLL_OBJS += vm/os-genunix.o vm/os-openbsd.o
 CC = egcc
 CPP = eg++
-CFLAGS += -export-dynamic
+CFLAGS += -export-dynamic -fno-inline-functions
 LIBS = -L/usr/local/lib/ -lm $(X11_UI_LIBS) -lz -lssl -lcrypto -lpthread
index 98b7de16d8207fb0fc3b2a4f4be792fc4cfdf861..a2d7b1f271093fb9db609b7078820bdf4911c926 100644 (file)
@@ -1,6 +1,6 @@
 include vm/Config.unix
 PLAF_DLL_OBJS += vm/os-genunix.o vm/os-solaris.o
 CFLAGS += -D_STDC_C99 -Drestrict="" -export-dynamic
-LIBS += -ldl -lsocket -lnsl -lm -R/opt/PM/lib -R/opt/csw/lib \
+LIBS += -ldl -lsocket -lnsl -lm -lrt -R/opt/PM/lib -R/opt/csw/lib \
        -R/usr/local/lib -R/usr/sfw/lib -R/usr/X11R6/lib \
        -R/opt/sfw/lib $(X11_UI_LIBS)
index b0b1352cb244f96949d6420af3cfd597a62d3758..11df4035416f159627d33886c462dd06ec318147 100644 (file)
@@ -1,4 +1,4 @@
-CFLAGS += -DWINDOWS -mno-cygwin
+CFLAGS += -mno-cygwin
 LIBS = -lm
 PLAF_DLL_OBJS += vm/os-windows.o
 SHARED_FLAG = -shared
index e060ef7019eb7acc2fe991a859538a28d9abbde3..8b137891791fe96927ad78e64b0aad7bded08bdc 100644 (file)
@@ -1,5 +1 @@
-BOOT_ARCH = x86
-PLAF_DLL_OBJS += vm/cpu-x86.32.o
 
-# gcc bug workaround
-CFLAGS += -fno-builtin-strlen -fno-builtin-strcat
index 63f06d5a786337245463030ce0ee22f7f1be8d40..8b137891791fe96927ad78e64b0aad7bded08bdc 100644 (file)
@@ -1,2 +1 @@
-PLAF_DLL_OBJS += vm/cpu-x86.64.o
-CFLAGS += -DFACTOR_64
+
index 3572677aa6d54dc801c3647a43f3c8b62ce703ba..c832ca792faf4e1eee2a9397780f87fe254347cf 100644 (file)
@@ -22,7 +22,7 @@ void factor_vm::collect_aging()
 
                to_tenured_collector collector(this);
 
-               current_gc->event->started_code_scan();
+               current_gc->event->started_card_scan();
                collector.trace_cards(data->tenured,
                        card_points_to_aging,
                        full_unmarker());
@@ -33,10 +33,6 @@ void factor_vm::collect_aging()
                current_gc->event->ended_code_scan(collector.code_blocks_scanned);
 
                collector.tenure_reachable_objects();
-
-               current_gc->event->started_code_sweep();
-               update_code_heap_for_minor_gc(&code->points_to_aging);
-               current_gc->event->ended_code_sweep();
        }
        {
                /* If collection fails here, do a to_tenured collection. */
@@ -53,8 +49,7 @@ void factor_vm::collect_aging()
                collector.cheneys_algorithm();
 
                data->reset_generation(&nursery);
-               code->points_to_nursery.clear();
-               code->points_to_aging.clear();
+               code->clear_remembered_set();
        }
 }
 
index 7a28f54ebf1af3cbad2dd92cea53c7f2d423f293..ccb2d1a1a2f21d05e57cc030e9385e1fe4ab8ea7 100644 (file)
@@ -15,15 +15,6 @@ struct aging_space : bump_allocator<object> {
                starts.record_object_start_offset(obj);
                return obj;
        }
-
-       cell next_object_after(cell scan)
-       {
-               cell size = ((object *)scan)->size();
-               if(scan + size < here)
-                       return scan + size;
-               else
-                       return 0;
-       }
 };
 
 }
index d07b6e353b9c6f255326cfa91e5e87b02b1891e0..38078b66790ebf0c7d704d72989d8cc557ea4185 100755 (executable)
@@ -27,9 +27,17 @@ char *factor_vm::pinned_alien_offset(cell obj)
        }
 }
 
+VM_C_API char *pinned_alien_offset(cell obj, factor_vm *parent)
+{
+       return parent->pinned_alien_offset(obj);
+}
+
 /* make an alien */
 cell factor_vm::allot_alien(cell delegate_, cell displacement)
 {
+       if(delegate_ == false_object && displacement == 0)
+               return false_object;
+
        data_root<object> delegate(delegate_,this);
        data_root<alien> new_alien(allot<alien>(sizeof(alien)),this);
 
@@ -49,27 +57,32 @@ cell factor_vm::allot_alien(cell delegate_, cell displacement)
        return new_alien.value();
 }
 
+cell factor_vm::allot_alien(void *address)
+{
+       return allot_alien(false_object,(cell)address);
+}
+
+VM_C_API cell allot_alien(void *address, factor_vm *vm)
+{
+       return vm->allot_alien(address);
+}
+
 /* make an alien pointing at an offset of another alien */
 void factor_vm::primitive_displaced_alien()
 {
-       cell alien = dpop();
-       cell displacement = to_cell(dpop());
+       cell alien = ctx->pop();
+       cell displacement = to_cell(ctx->pop());
 
-       if(!to_boolean(alien) && displacement == 0)
-               dpush(false_object);
-       else
+       switch(tagged<object>(alien).type())
        {
-               switch(tagged<object>(alien).type())
-               {
-               case BYTE_ARRAY_TYPE:
-               case ALIEN_TYPE:
-               case F_TYPE:
-                       dpush(allot_alien(alien,displacement));
-                       break;
-               default:
-                       type_error(ALIEN_TYPE,alien);
-                       break;
-               }
+       case BYTE_ARRAY_TYPE:
+       case ALIEN_TYPE:
+       case F_TYPE:
+               ctx->push(allot_alien(alien,displacement));
+               break;
+       default:
+               type_error(ALIEN_TYPE,alien);
+               break;
        }
 }
 
@@ -77,59 +90,59 @@ void factor_vm::primitive_displaced_alien()
 if the object is a byte array, as a sanity check. */
 void factor_vm::primitive_alien_address()
 {
-       box_unsigned_cell((cell)pinned_alien_offset(dpop()));
+       ctx->push(allot_cell((cell)pinned_alien_offset(ctx->pop())));
 }
 
 /* pop ( alien n ) from datastack, return alien's address plus n */
 void *factor_vm::alien_pointer()
 {
-       fixnum offset = to_fixnum(dpop());
-       return unbox_alien() + offset;
+       fixnum offset = to_fixnum(ctx->pop());
+       return alien_offset(ctx->pop()) + offset;
 }
 
 /* define words to read/write values at an alien address */
-#define DEFINE_ALIEN_ACCESSOR(name,type,boxer,to) \
-       PRIMITIVE(alien_##name) \
+#define DEFINE_ALIEN_ACCESSOR(name,type,from,to) \
+       VM_C_API void primitive_alien_##name(factor_vm *parent) \
        { \
-               parent->boxer(*(type*)(parent->alien_pointer())); \
+               parent->ctx->push(from(*(type*)(parent->alien_pointer()),parent)); \
        } \
-       PRIMITIVE(set_alien_##name) \
+       VM_C_API void primitive_set_alien_##name(factor_vm *parent) \
        { \
                type *ptr = (type *)parent->alien_pointer(); \
-               type value = parent->to(dpop()); \
+               type value = (type)to(parent->ctx->pop(),parent); \
                *ptr = value; \
        }
 
-DEFINE_ALIEN_ACCESSOR(signed_cell,fixnum,box_signed_cell,to_fixnum)
-DEFINE_ALIEN_ACCESSOR(unsigned_cell,cell,box_unsigned_cell,to_cell)
-DEFINE_ALIEN_ACCESSOR(signed_8,s64,box_signed_8,to_signed_8)
-DEFINE_ALIEN_ACCESSOR(unsigned_8,u64,box_unsigned_8,to_unsigned_8)
-DEFINE_ALIEN_ACCESSOR(signed_4,s32,box_signed_4,to_fixnum)
-DEFINE_ALIEN_ACCESSOR(unsigned_4,u32,box_unsigned_4,to_cell)
-DEFINE_ALIEN_ACCESSOR(signed_2,s16,box_signed_2,to_fixnum)
-DEFINE_ALIEN_ACCESSOR(unsigned_2,u16,box_unsigned_2,to_cell)
-DEFINE_ALIEN_ACCESSOR(signed_1,s8,box_signed_1,to_fixnum)
-DEFINE_ALIEN_ACCESSOR(unsigned_1,u8,box_unsigned_1,to_cell)
-DEFINE_ALIEN_ACCESSOR(float,float,box_float,to_float)
-DEFINE_ALIEN_ACCESSOR(double,double,box_double,to_double)
-DEFINE_ALIEN_ACCESSOR(cell,void *,box_alien,pinned_alien_offset)
+DEFINE_ALIEN_ACCESSOR(signed_cell,fixnum,from_signed_cell,to_fixnum)
+DEFINE_ALIEN_ACCESSOR(unsigned_cell,cell,from_unsigned_cell,to_cell)
+DEFINE_ALIEN_ACCESSOR(signed_8,s64,from_signed_8,to_signed_8)
+DEFINE_ALIEN_ACCESSOR(unsigned_8,u64,from_unsigned_8,to_unsigned_8)
+DEFINE_ALIEN_ACCESSOR(signed_4,s32,from_signed_4,to_fixnum)
+DEFINE_ALIEN_ACCESSOR(unsigned_4,u32,from_unsigned_4,to_cell)
+DEFINE_ALIEN_ACCESSOR(signed_2,s16,from_signed_2,to_fixnum)
+DEFINE_ALIEN_ACCESSOR(unsigned_2,u16,from_unsigned_2,to_cell)
+DEFINE_ALIEN_ACCESSOR(signed_1,s8,from_signed_1,to_fixnum)
+DEFINE_ALIEN_ACCESSOR(unsigned_1,u8,from_unsigned_1,to_cell)
+DEFINE_ALIEN_ACCESSOR(float,float,from_float,to_float)
+DEFINE_ALIEN_ACCESSOR(double,double,from_double,to_double)
+DEFINE_ALIEN_ACCESSOR(cell,void *,allot_alien,pinned_alien_offset)
 
 /* open a native library and push a handle */
 void factor_vm::primitive_dlopen()
 {
-       data_root<byte_array> path(dpop(),this);
+       data_root<byte_array> path(ctx->pop(),this);
        path.untag_check(this);
        data_root<dll> library(allot<dll>(sizeof(dll)),this);
        library->path = path.value();
        ffi_dlopen(library.untagged());
-       dpush(library.value());
+       ctx->push(library.value());
 }
 
 /* look up a symbol in a native library */
 void factor_vm::primitive_dlsym()
 {
-       data_root<object> library(dpop(),this);
-       data_root<byte_array> name(dpop(),this);
+       data_root<object> library(ctx->pop(),this);
+       data_root<byte_array> name(ctx->pop(),this);
        name.untag_check(this);
 
        symbol_char *sym = name->data<symbol_char>();
@@ -138,30 +151,30 @@ void factor_vm::primitive_dlsym()
        {
                dll *d = untag_check<dll>(library.value());
 
-               if(d->dll == NULL)
-                       dpush(false_object);
+               if(d->handle == NULL)
+                       ctx->push(false_object);
                else
-                       box_alien(ffi_dlsym(d,sym));
+                       ctx->push(allot_alien(ffi_dlsym(d,sym)));
        }
        else
-               box_alien(ffi_dlsym(NULL,sym));
+               ctx->push(allot_alien(ffi_dlsym(NULL,sym)));
 }
 
 /* close a native library handle */
 void factor_vm::primitive_dlclose()
 {
-       dll *d = untag_check<dll>(dpop());
-       if(d->dll != NULL)
+       dll *d = untag_check<dll>(ctx->pop());
+       if(d->handle != NULL)
                ffi_dlclose(d);
 }
 
 void factor_vm::primitive_dll_validp()
 {
-       cell library = dpop();
+       cell library = ctx->pop();
        if(to_boolean(library))
-               dpush(tag_boolean(untag_check<dll>(library)->dll != NULL));
+               ctx->push(tag_boolean(untag_check<dll>(library)->handle != NULL));
        else
-               dpush(true_object);
+               ctx->push(true_object);
 }
 
 /* gets the address of an object representing a C pointer */
@@ -186,32 +199,7 @@ VM_C_API char *alien_offset(cell obj, factor_vm *parent)
        return parent->alien_offset(obj);
 }
 
-/* pop an object representing a C pointer */
-char *factor_vm::unbox_alien()
-{
-       return alien_offset(dpop());
-}
-
-VM_C_API char *unbox_alien(factor_vm *parent)
-{
-       return parent->unbox_alien();
-}
-
-/* make an alien and push */
-void factor_vm::box_alien(void *ptr)
-{
-       if(ptr == NULL)
-               dpush(false_object);
-       else
-               dpush(allot_alien(false_object,(cell)ptr));
-}
-
-VM_C_API void box_alien(void *ptr, factor_vm *parent)
-{
-       return parent->box_alien(ptr);
-}
-
-/* for FFI calls passing structs by value */
+/* For FFI calls passing structs by value. Cannot allocate */
 void factor_vm::to_value_struct(cell src, void *dest, cell size)
 {
        memcpy(dest,alien_offset(src),size);
@@ -222,52 +210,47 @@ VM_C_API void to_value_struct(cell src, void *dest, cell size, factor_vm *parent
        return parent->to_value_struct(src,dest,size);
 }
 
-/* for FFI callbacks receiving structs by value */
-void factor_vm::box_value_struct(void *src, cell size)
+/* For FFI callbacks receiving structs by value */
+cell factor_vm::from_value_struct(void *src, cell size)
 {
        byte_array *bytes = allot_byte_array(size);
        memcpy(bytes->data<void>(),src,size);
-       dpush(tag<byte_array>(bytes));
+       return tag<byte_array>(bytes);
 }
 
-VM_C_API void box_value_struct(void *src, cell size,factor_vm *parent)
+VM_C_API cell from_value_struct(void *src, cell size, factor_vm *parent)
 {
-       return parent->box_value_struct(src,size);
+       return parent->from_value_struct(src,size);
 }
 
 /* On some x86 OSes, structs <= 8 bytes are returned in registers. */
-void factor_vm::box_small_struct(cell x, cell y, cell size)
+cell factor_vm::from_small_struct(cell x, cell y, cell size)
 {
        cell data[2];
        data[0] = x;
        data[1] = y;
-       box_value_struct(data,size);
+       return from_value_struct(data,size);
 }
 
-VM_C_API void box_small_struct(cell x, cell y, cell size, factor_vm *parent)
+VM_C_API cell from_small_struct(cell x, cell y, cell size, factor_vm *parent)
 {
-       return parent->box_small_struct(x,y,size);
+       return parent->from_small_struct(x,y,size);
 }
 
 /* On OS X/PPC, complex numbers are returned in registers. */
-void factor_vm::box_medium_struct(cell x1, cell x2, cell x3, cell x4, cell size)
+cell factor_vm::from_medium_struct(cell x1, cell x2, cell x3, cell x4, cell size)
 {
        cell data[4];
        data[0] = x1;
        data[1] = x2;
        data[2] = x3;
        data[3] = x4;
-       box_value_struct(data,size);
-}
-
-VM_C_API void box_medium_struct(cell x1, cell x2, cell x3, cell x4, cell size, factor_vm *parent)
-{
-       return parent->box_medium_struct(x1, x2, x3, x4, size);
+       return from_value_struct(data,size);
 }
 
-void factor_vm::primitive_vm_ptr()
+VM_C_API cell from_medium_struct(cell x1, cell x2, cell x3, cell x4, cell size, factor_vm *parent)
 {
-       box_alien(this);
+       return parent->from_medium_struct(x1, x2, x3, x4, size);
 }
 
 }
index 129cc2560a145ea39e973292c987ce5f00d5117b..add6f4ba728ebd1e86946ba787f83403c8cbad6a 100755 (executable)
@@ -2,11 +2,11 @@ namespace factor
 {
 
 VM_C_API char *alien_offset(cell object, factor_vm *vm);
-VM_C_API char *unbox_alien(factor_vm *vm);
-VM_C_API void box_alien(void *ptr, factor_vm *vm);
+VM_C_API char *pinned_alien_offset(cell object, factor_vm *vm);
+VM_C_API cell allot_alien(void *address, factor_vm *vm);
 VM_C_API void to_value_struct(cell src, void *dest, cell size, factor_vm *vm);
-VM_C_API void box_value_struct(void *src, cell size,factor_vm *vm);
-VM_C_API void box_small_struct(cell x, cell y, cell size,factor_vm *vm);
-VM_C_API void box_medium_struct(cell x1, cell x2, cell x3, cell x4, cell size,factor_vm *vm);
+VM_C_API cell from_value_struct(void *src, cell size, factor_vm *vm);
+VM_C_API cell from_small_struct(cell x, cell y, cell size, factor_vm *vm);
+VM_C_API cell from_medium_struct(cell x1, cell x2, cell x3, cell x4, cell size, factor_vm *vm);
 
 }
index 9a00bafd3853ea762f4a0a100249c6add1b3dfc1..9a7c898efa09689b08058aaee6554679e3cec503 100644 (file)
@@ -5,8 +5,12 @@ namespace factor
  * It is up to the caller to fill in the object's fields in a meaningful
  * fashion!
  */
-inline object *factor_vm::allot_object(header header, cell size)
+inline object *factor_vm::allot_object(cell type, cell size)
 {
+#ifdef FACTOR_DEBUG
+       assert(!current_gc);
+#endif
+
        /* If the object is smaller than the nursery, allocate it in the nursery,
        after a GC if needed */
        if(nursery.size > size)
@@ -17,13 +21,13 @@ inline object *factor_vm::allot_object(header header, cell size)
 
                object *obj = nursery.allot(size);
 
-               obj->h = header;
+               obj->initialize(type);
                return obj;
        }
        /* If the object is bigger than the nursery, allocate it in
        tenured space */
        else
-               return allot_large_object(header,size);
+               return allot_large_object(type,size);
 }
 
 }
index 3060ac70a348004f22af63c596514068db6fe707..cdfee274c75d09afc561770bdaa1dae38c2b960d 100644 (file)
@@ -3,21 +3,21 @@
 namespace factor
 {
 
-/* make a new array with an initial element */
 array *factor_vm::allot_array(cell capacity, cell fill_)
 {
        data_root<object> fill(fill_,this);
-       data_root<array> new_array(allot_uninitialized_array<array>(capacity),this);
+       array *new_array = allot_uninitialized_array<array>(capacity);
        memset_cell(new_array->data(),fill.value(),capacity * sizeof(cell));
-       return new_array.untagged();
+       return new_array;
 }
 
-/* push a new array on the stack */
 void factor_vm::primitive_array()
 {
-       cell initial = dpop();
-       cell size = unbox_array_size();
-       dpush(tag<array>(allot_array(size,initial)));
+       data_root<object> fill(ctx->pop(),this);
+       cell capacity = unbox_array_size();
+       array *new_array = allot_uninitialized_array<array>(capacity);
+       memset_cell(new_array->data(),fill.value(),capacity * sizeof(cell));
+       ctx->push(tag<array>(new_array));
 }
 
 cell factor_vm::allot_array_1(cell obj_)
@@ -54,9 +54,10 @@ cell factor_vm::allot_array_4(cell v1_, cell v2_, cell v3_, cell v4_)
 
 void factor_vm::primitive_resize_array()
 {
-       array *a = untag_check<array>(dpop());
+       data_root<array> a(ctx->pop(),this);
+       a.untag_check(this);
        cell capacity = unbox_array_size();
-       dpush(tag<array>(reallot_array(a,capacity)));
+       ctx->push(tag<array>(reallot_array(a.untagged(),capacity)));
 }
 
 void growable_array::add(cell elt_)
index 8eb2b530b0686944d44c34255c657fc9bf7ad6d4..5d6a0445fdd285b7d127e599cbbcf6ffb68ad765 100755 (executable)
@@ -5,7 +5,7 @@ inline cell array_nth(array *array, cell slot)
 {
 #ifdef FACTOR_DEBUG
        assert(slot < array_capacity(array));
-       assert(array->h.hi_tag() == ARRAY_TYPE);
+       assert(array->type() == ARRAY_TYPE);
 #endif
        return array->data()[slot];
 }
@@ -14,7 +14,7 @@ inline void factor_vm::set_array_nth(array *array, cell slot, cell value)
 {
 #ifdef FACTOR_DEBUG
        assert(slot < array_capacity(array));
-       assert(array->h.hi_tag() == ARRAY_TYPE);
+       assert(array->type() == ARRAY_TYPE);
 #endif
        cell *slot_ptr = &array->data()[slot];
        *slot_ptr = value;
diff --git a/vm/asm.h b/vm/asm.h
deleted file mode 100644 (file)
index 9719ae8..0000000
--- a/vm/asm.h
+++ /dev/null
@@ -1,16 +0,0 @@
-#if defined(__APPLE__) || (defined(WINDOWS) && !defined(__arm__))
-       #define MANGLE(sym) _##sym
-#else
-       #define MANGLE(sym) sym
-#endif
-
-/* Apple's PPC assembler is out of date? */
-#if defined(__APPLE__) && defined(__ppc__)
-       #define XX @
-#else
-       #define XX ;
-#endif
-
-/* The returns and args are just for documentation */
-#define DEF(returns,symbol,args) .globl MANGLE(symbol) XX \
-MANGLE(symbol)
index 5a391e7625f3c1faa28ed503c4f07fc76092f408..c3d47d45f37c3549a7209ac0df6bb2cf44de5fad 100755 (executable)
@@ -329,6 +329,7 @@ bignum *factor_vm::bignum_remainder(bignum * numerator, bignum * denominator)
                }
 }
 
+/* allocates memory */
 #define FOO_TO_BIGNUM(name,type,utype)                                 \
 bignum * factor_vm::name##_to_bignum(type n)                           \
 {                                                                      \
@@ -358,13 +359,13 @@ bignum * factor_vm::name##_to_bignum(type n)                              \
                return (result);                                        \
        }                                                               \
 }
-  
-/* all below allocate memory */
+
 FOO_TO_BIGNUM(cell,cell,cell)
 FOO_TO_BIGNUM(fixnum,fixnum,cell)
 FOO_TO_BIGNUM(long_long,s64,u64)
 FOO_TO_BIGNUM(ulong_long,u64,u64)
 
+/* cannot allocate memory */
 #define BIGNUM_TO_FOO(name,type,utype)                                 \
        type factor_vm::bignum_to_##name(bignum * bignum)               \
        {                                                               \
@@ -380,7 +381,6 @@ FOO_TO_BIGNUM(ulong_long,u64,u64)
                }                                                       \
        }
 
-/* all of the below allocate memory */
 BIGNUM_TO_FOO(cell,cell,cell);
 BIGNUM_TO_FOO(fixnum,fixnum,cell);
 BIGNUM_TO_FOO(long_long,s64,u64)
old mode 100644 (file)
new mode 100755 (executable)
index dc685bb..1927cd4
@@ -1,67 +1,62 @@
 namespace factor
 {
 
-/* These algorithms were snarfed from various places. I did not come up with them myself */
-
-inline cell popcount(u64 x)
-{
-       u64 k1 = 0x5555555555555555ll;
-       u64 k2 = 0x3333333333333333ll;
-       u64 k4 = 0x0f0f0f0f0f0f0f0fll;
-       u64 kf = 0x0101010101010101ll;
-       x =  x       - ((x >> 1)  & k1); // put count of each 2 bits into those 2 bits
-       x = (x & k2) + ((x >> 2)  & k2); // put count of each 4 bits into those 4 bits
-       x = (x       +  (x >> 4)) & k4 ; // put count of each 8 bits into those 8 bits
-       x = (x * kf) >> 56; // returns 8 most significant bits of x + (x<<8) + (x<<16) + (x<<24) + ...
-
-       return (cell)x;
-}
-
-inline cell log2(u64 x)
-{
-#ifdef FACTOR_AMD64
-       cell n;
-       asm ("bsr %1, %0;":"=r"(n):"r"((cell)x));
-#else
-       cell n = 0;
-       if (x >= (u64)1 << 32) { x >>= 32; n += 32; }
-       if (x >= (u64)1 << 16) { x >>= 16; n += 16; }
-       if (x >= (u64)1 <<  8) { x >>=  8; n +=  8; }
-       if (x >= (u64)1 <<  4) { x >>=  4; n +=  4; }
-       if (x >= (u64)1 <<  2) { x >>=  2; n +=  2; }
-       if (x >= (u64)1 <<  1) {           n +=  1; }
-#endif
-       return n;
-}
-
-inline cell log2(u16 x)
+inline cell log2(cell x)
 {
-#if defined(FACTOR_X86) || defined(FACTOR_AMD64)
        cell n;
-       asm ("bsr %1, %0;":"=r"(n):"r"((cell)x));
+#if defined(FACTOR_X86)
+       #if defined(_MSC_VER)
+               _BitScanReverse(&n,x);
+       #else
+               asm ("bsr %1, %0;":"=r"(n):"r"(x));
+       #endif
+#elif defined(FACTOR_AMD64)
+       #if defined(_MSC_VER)
+               _BitScanReverse64(&n,x);
+       #else
+               asm ("bsr %1, %0;":"=r"(n):"r"(x));
+       #endif
+#elif defined(FACTOR_PPC)
+       asm ("cntlzw %1, %0;":"=r"(n):"r"(x));
+       n = (31 - n);
 #else
-       cell n = 0;
-       if (x >= 1 << 8) { x >>=  8; n += 8; }
-       if (x >= 1 << 4) { x >>=  4; n += 4; }
-       if (x >= 1 << 2) { x >>=  2; n += 2; }
-       if (x >= 1 << 1) {           n += 1; }
+       #error Unsupported CPU
 #endif
        return n;
 }
 
-inline cell rightmost_clear_bit(u64 x)
+inline cell rightmost_clear_bit(cell x)
 {
        return log2(~x & (x + 1));
 }
 
-inline cell rightmost_set_bit(u64 x)
+inline cell rightmost_set_bit(cell x)
 {
-       return log2(x & -x);
+       return log2(x & (~x + 1));
 }
 
-inline cell rightmost_set_bit(u16 x)
+inline cell popcount(cell x)
 {
-       return log2((u16)(x & -x));
+#ifdef FACTOR_64
+       u64 k1 = 0x5555555555555555ll;
+       u64 k2 = 0x3333333333333333ll;
+       u64 k4 = 0x0f0f0f0f0f0f0f0fll;
+       u64 kf = 0x0101010101010101ll;
+       cell ks = 56;
+#else
+       u32 k1 = 0x55555555;
+       u32 k2 = 0x33333333;
+       u32 k4 = 0xf0f0f0f;
+       u32 kf = 0x1010101;
+       cell ks = 24;
+#endif
+
+       x =  x       - ((x >> 1)  & k1); // put count of each 2 bits into those 2 bits
+       x = (x & k2) + ((x >> 2)  & k2); // put count of each 4 bits into those 4 bits
+       x = (x       +  (x >> 4)) & k4 ; // put count of each 8 bits into those 8 bits
+       x = (x * kf) >> ks; // returns 8 most significant bits of x + (x<<8) + (x<<16) + (x<<24) + ...
+
+       return x;
 }
 
 }
index a7871dcbcbae75408c03426899da87e94334f3f1..dedb385f3d474279a6e08d59f6cd9e97605359c8 100644 (file)
@@ -3,19 +3,14 @@
 namespace factor
 {
 
-void factor_vm::box_boolean(bool value)
-{
-       dpush(tag_boolean(value));
-}
-
-VM_C_API void box_boolean(bool value, factor_vm *parent)
+VM_C_API bool to_boolean(cell value, factor_vm *parent)
 {
-       return parent->box_boolean(value);
+       return to_boolean(value);
 }
 
-VM_C_API bool to_boolean(cell value, factor_vm *parent)
+VM_C_API cell from_boolean(bool value, factor_vm *parent)
 {
-       return parent->to_boolean(value);
+       return parent->tag_boolean(value);
 }
 
 }
index 375c8e3756c5521aa824965282e99b4652715bf8..a11103c5c6f7f8053aad5612fd8dd962d0debb40 100644 (file)
@@ -1,15 +1,11 @@
 namespace factor
 {
 
-VM_C_API void box_boolean(bool value, factor_vm *vm);
 VM_C_API bool to_boolean(cell value, factor_vm *vm);
+VM_C_API cell from_boolean(bool value, factor_vm *vm);
 
-inline cell factor_vm::tag_boolean(cell untagged)
-{
-       return (untagged ? true_object : false_object);
-}
-
-inline bool factor_vm::to_boolean(cell value)
+/* Cannot allocate */
+inline static bool to_boolean(cell value)
 {
        return value != false_object;
 }
index 5488c653239374ec1f7bc474c31d659fae0c3dc0..bbe4df8eec18dbd997aba5c79ffd61d452f3d024 100644 (file)
@@ -32,6 +32,23 @@ template<typename Block> struct bump_allocator {
        {
                return end - here;
        }
+
+       cell next_object_after(cell scan)
+       {
+               cell size = ((Block *)scan)->size();
+               if(scan + size < here)
+                       return scan + size;
+               else
+                       return 0;
+       }
+
+       cell first_object()
+       {
+               if(start != here)
+                       return start;
+               else
+                       return 0;
+       }
 };
 
 }
index b317c39f62e21e274740db5fe4d626bb7454d8ed..1986b5d35cea9333491ee228316a1dc74579bcea 100644 (file)
@@ -13,20 +13,21 @@ byte_array *factor_vm::allot_byte_array(cell size)
 void factor_vm::primitive_byte_array()
 {
        cell size = unbox_array_size();
-       dpush(tag<byte_array>(allot_byte_array(size)));
+       ctx->push(tag<byte_array>(allot_byte_array(size)));
 }
 
 void factor_vm::primitive_uninitialized_byte_array()
 {
        cell size = unbox_array_size();
-       dpush(tag<byte_array>(allot_uninitialized_array<byte_array>(size)));
+       ctx->push(tag<byte_array>(allot_uninitialized_array<byte_array>(size)));
 }
 
 void factor_vm::primitive_resize_byte_array()
 {
-       byte_array *array = untag_check<byte_array>(dpop());
+       data_root<byte_array> array(ctx->pop(),this);
+       array.untag_check(this);
        cell capacity = unbox_array_size();
-       dpush(tag<byte_array>(reallot_array(array,capacity)));
+       ctx->push(tag<byte_array>(reallot_array(array.untagged(),capacity)));
 }
 
 void growable_byte_array::append_bytes(void *elts, cell len)
index a3d6fcf94168654646704d454472cce9678ef345..a96baff6ec33d64a2b796c3be4e880d4d5745f1c 100755 (executable)
@@ -15,14 +15,8 @@ struct growable_byte_array {
 
 template<typename Type> byte_array *factor_vm::byte_array_from_value(Type *value)
 {
-       return byte_array_from_values(value,1);
-}
-
-template<typename Type> byte_array *factor_vm::byte_array_from_values(Type *values, cell len)
-{
-       cell size = sizeof(Type) * len;
-       byte_array *data = allot_uninitialized_array<byte_array>(size);
-       memcpy(data->data<char>(),values,size);
+       byte_array *data = allot_uninitialized_array<byte_array>(sizeof(Type));
+       memcpy(data->data<char>(),value,sizeof(Type));
        return data;
 }
 
index 4fe19c0bc0c481fb23e47cdc08ae2751113036ba..416c1395d43444b45e582db45947f3be8535152b 100644 (file)
@@ -19,48 +19,87 @@ void factor_vm::init_callbacks(cell size)
        callbacks = new callback_heap(size,this);
 }
 
-void callback_heap::update(callback *stub)
+void callback_heap::store_callback_operand(code_block *stub, cell index, cell value)
 {
        tagged<array> code_template(parent->special_objects[CALLBACK_STUB]);
 
-       cell rel_class = untag_fixnum(array_nth(code_template.untagged(),1));
-       cell offset = untag_fixnum(array_nth(code_template.untagged(),3));
+       cell rel_class = untag_fixnum(array_nth(code_template.untagged(),3 * index + 1));
+       cell rel_type  = untag_fixnum(array_nth(code_template.untagged(),3 * index + 2));
+       cell offset    = untag_fixnum(array_nth(code_template.untagged(),3 * index + 3));
 
-       parent->store_address_in_code_block(rel_class,
-               (cell)(stub + 1) + offset,
-               (cell)(stub->compiled + 1));
+       relocation_entry rel(
+               (relocation_type)rel_type,
+               (relocation_class)rel_class,
+               offset);
 
-       flush_icache((cell)stub,stub->size);
+       instruction_operand op(rel,stub,0);
+       op.store_value(value);
 }
 
-callback *callback_heap::add(code_block *compiled)
+void callback_heap::update(code_block *stub)
+{
+       store_callback_operand(stub,1,(cell)callback_entry_point(stub));
+       stub->flush_icache();
+}
+
+code_block *callback_heap::add(cell owner, cell return_rewind)
 {
        tagged<array> code_template(parent->special_objects[CALLBACK_STUB]);
        tagged<byte_array> insns(array_nth(code_template.untagged(),0));
        cell size = array_capacity(insns.untagged());
 
-       cell bump = align(size,sizeof(cell)) + sizeof(callback);
+       cell bump = align(size + sizeof(code_block),data_alignment);
        if(here + bump > seg->end) fatal_error("Out of callback space",0);
 
-       callback *stub = (callback *)here;
-       stub->compiled = compiled;
-       memcpy(stub + 1,insns->data<void>(),size);
-
-       stub->size = align(size,sizeof(cell));
+       free_heap_block *free_block = (free_heap_block *)here;
+       free_block->make_free(bump);
        here += bump;
 
+       code_block *stub = (code_block *)free_block;
+       stub->owner = owner;
+       stub->parameters = false_object;
+       stub->relocation = false_object;
+
+       memcpy(stub->entry_point(),insns->data<void>(),size);
+
+       /* Store VM pointer */
+       store_callback_operand(stub,0,(cell)parent);
+
+       /* On x86, the RET instruction takes an argument which depends on
+       the callback's calling convention */
+#if defined(FACTOR_X86) || defined(FACTOR_AMD64)
+       store_callback_operand(stub,2,return_rewind);
+#endif
+
        update(stub);
 
        return stub;
 }
 
+struct callback_updater {
+       callback_heap *callbacks;
+
+       explicit callback_updater(callback_heap *callbacks_) : callbacks(callbacks_) {}
+
+       void operator()(code_block *stub)
+       {
+               callbacks->update(stub);
+       }
+};
+
+void callback_heap::update()
+{
+       callback_updater updater(this);
+       each_callback(updater);
+}
+
 void factor_vm::primitive_callback()
 {
-       tagged<word> w(dpop());
-       w.untag_check(this);
+       cell return_rewind = to_cell(ctx->pop());
+       tagged<word> w(ctx->pop());
 
-       callback *stub = callbacks->add(w->code);
-       box_alien(stub + 1);
+       w.untag_check(this);
+       ctx->push(allot_alien(callbacks->add(w.value(),return_rewind)->entry_point()));
 }
 
 }
index c499ad47190c269cdd5f396600422d19cc590248..607984ad233c9136c927bdf2c084136c394433e2 100644 (file)
@@ -1,11 +1,28 @@
 namespace factor
 {
 
-struct callback {
-       cell size;
-       code_block *compiled;
-       void *code() { return (void *)(this + 1); }
-};
+/* The callback heap is used to store the machine code that alien-callbacks
+actually jump to when C code invokes them.
+
+The callback heap has entries that look like code_blocks from the code heap, but
+callback heap entries are allocated contiguously, never deallocated, and all
+fields but the owner are set to false_object. The owner points to the callback
+bottom word, whose entry point is the callback body itself, generated by the
+optimizing compiler. The machine code that follows a callback stub consists of a
+single CALLBACK_STUB machine code template, which performs a jump to a "far"
+address (on PowerPC and x86-64, its loaded into a register first).
+
+GC updates the CALLBACK_STUB code if the code block of the callback bottom word
+is ever moved. The callback stub itself won't move, though, and is never
+deallocated. This means that the callback stub itself is a stable function
+pointer that C code can hold on to until the associated Factor VM exits.
+
+Since callback stubs are GC roots, and are never deallocated, the associated
+callback code in the code heap is also never deallocated.
+
+The callback heap is not saved in the image. Running GC in a new session after
+saving the image will deallocate any code heap entries that were only reachable
+from the callback heap in the previous session when the image was saved. */
 
 struct callback_heap {
        segment *seg;
@@ -15,18 +32,29 @@ struct callback_heap {
        explicit callback_heap(cell size, factor_vm *parent);
        ~callback_heap();
 
-       callback *add(code_block *compiled);
-       void update(callback *stub);
+       void *callback_entry_point(code_block *stub)
+       {
+               word *w = (word *)UNTAG(stub->owner);
+               return w->entry_point;
+       }
+
+       void store_callback_operand(code_block *stub, cell index, cell value);
+
+       void update(code_block *stub);
+
+       code_block *add(cell owner, cell return_rewind);
+
+       void update();
 
-       callback *next(callback *stub)
+       code_block *next(code_block *stub)
        {
-               return (callback *)((cell)stub + stub->size + sizeof(callback));
+               return (code_block *)((cell)stub + stub->size());
        }
 
-       template<typename Iterator> void iterate(Iterator &iter)
+       template<typename Iterator> void each_callback(Iterator &iter)
        {
-               callback *scan = (callback *)seg->start;
-               callback *end = (callback *)here;
+               code_block *scan = (code_block *)seg->start;
+               code_block *end = (code_block *)here;
                while(scan < end)
                {
                        iter(scan);
index 85f392af0e6cafbed634bf3c6f3169a86ac5dbe3..4aa9321353517b92c4260cfe5fd631dab0a6eb7d 100755 (executable)
@@ -6,7 +6,7 @@ namespace factor
 void factor_vm::check_frame(stack_frame *frame)
 {
 #ifdef FACTOR_DEBUG
-       check_code_pointer((cell)frame->xt);
+       check_code_pointer((cell)frame->entry_point);
        assert(frame->size != 0);
 #endif
 }
@@ -28,52 +28,42 @@ stack_frame *factor_vm::fix_callstack_top(stack_frame *top, stack_frame *bottom)
        return frame + 1;
 }
 
-/* We ignore the topmost frame, the one calling 'callstack',
+/* We ignore the two topmost frames, the 'callstack' primitive
+frame itself, and the frame calling the 'callstack' primitive,
 so that set-callstack doesn't get stuck in an infinite loop.
 
 This means that if 'callstack' is called in tail position, we
 will have popped a necessary frame... however this word is only
 called by continuation implementation, and user code shouldn't
 be calling it at all, so we leave it as it is for now. */
-stack_frame *factor_vm::capture_start()
+stack_frame *factor_vm::second_from_top_stack_frame()
 {
        stack_frame *frame = ctx->callstack_bottom - 1;
-       while(frame >= ctx->callstack_top && frame_successor(frame) >= ctx->callstack_top)
+       while(frame >= ctx->callstack_top
+               && frame_successor(frame) >= ctx->callstack_top
+               && frame_successor(frame_successor(frame)) >= ctx->callstack_top)
+       {
                frame = frame_successor(frame);
+       }
        return frame + 1;
 }
 
 void factor_vm::primitive_callstack()
 {
-       stack_frame *top = capture_start();
+       stack_frame *top = second_from_top_stack_frame();
        stack_frame *bottom = ctx->callstack_bottom;
 
-       fixnum size = (cell)bottom - (cell)top;
-       if(size < 0)
-               size = 0;
+       fixnum size = std::max((fixnum)0,(fixnum)bottom - (fixnum)top);
 
        callstack *stack = allot_callstack(size);
        memcpy(stack->top(),top,size);
-       dpush(tag<callstack>(stack));
-}
-
-void factor_vm::primitive_set_callstack()
-{
-       callstack *stack = untag_check<callstack>(dpop());
-
-       set_callstack(ctx->callstack_bottom,
-               stack->top(),
-               untag_fixnum(stack->length),
-               memcpy);
-
-       /* We cannot return here ... */
-       critical_error("Bug in set_callstack()",0);
+       ctx->push(tag<callstack>(stack));
 }
 
 code_block *factor_vm::frame_code(stack_frame *frame)
 {
        check_frame(frame);
-       return (code_block *)frame->xt - 1;
+       return (code_block *)frame->entry_point - 1;
 }
 
 code_block_type factor_vm::frame_type(stack_frame *frame)
@@ -86,6 +76,15 @@ cell factor_vm::frame_executing(stack_frame *frame)
        return frame_code(frame)->owner;
 }
 
+cell factor_vm::frame_executing_quot(stack_frame *frame)
+{
+       tagged<object> executing(frame_executing(frame));
+       code_block *compiled = frame_code(frame);
+       if(!compiled->optimized_p() && executing->type() == WORD_TYPE)
+               executing = executing.as<word>()->def;
+       return executing.value();
+}
+
 stack_frame *factor_vm::frame_successor(stack_frame *frame)
 {
        check_frame(frame);
@@ -99,14 +98,17 @@ cell factor_vm::frame_scan(stack_frame *frame)
        {
        case code_block_unoptimized:
                {
-                       cell quot = frame_executing(frame);
-                       if(to_boolean(quot))
+                       tagged<object> obj(frame_executing(frame));
+                       if(obj.type_p(WORD_TYPE))
+                               obj = obj.as<word>()->def;
+
+                       if(obj.type_p(QUOTATION_TYPE))
                        {
                                char *return_addr = (char *)FRAME_RETURN_ADDRESS(frame,this);
-                               char *quot_xt = (char *)(frame_code(frame) + 1);
+                               char *quot_entry_point = (char *)(frame_code(frame) + 1);
 
                                return tag_fixnum(quot_code_offset_to_scan(
-                                       quot,(cell)(return_addr - quot_xt)));
+                                       obj.value(),(cell)(return_addr - quot_entry_point)));
                        }    
                        else
                                return false_object;
@@ -130,7 +132,7 @@ struct stack_frame_accumulator {
 
        void operator()(stack_frame *frame)
        {
-               data_root<object> executing(parent->frame_executing(frame),parent);
+               data_root<object> executing(parent->frame_executing_quot(frame),parent);
                data_root<object> scan(parent->frame_scan(frame),parent);
 
                frames.add(executing.value());
@@ -142,13 +144,13 @@ struct stack_frame_accumulator {
 
 void factor_vm::primitive_callstack_to_array()
 {
-       data_root<callstack> callstack(dpop(),this);
+       data_root<callstack> callstack(ctx->pop(),this);
 
        stack_frame_accumulator accum(this);
        iterate_callstack_object(callstack.untagged(),accum);
        accum.frames.trim();
 
-       dpush(accum.frames.elements.value());
+       ctx->push(accum.frames.elements.value());
 }
 
 stack_frame *factor_vm::innermost_stack_frame(callstack *stack)
@@ -163,50 +165,34 @@ stack_frame *factor_vm::innermost_stack_frame(callstack *stack)
        return frame;
 }
 
-stack_frame *factor_vm::innermost_stack_frame_quot(callstack *callstack)
-{
-       stack_frame *inner = innermost_stack_frame(callstack);
-       tagged<quotation>(frame_executing(inner)).untag_check(this);
-       return inner;
-}
-
 /* Some primitives implementing a limited form of callstack mutation.
 Used by the single stepper. */
 void factor_vm::primitive_innermost_stack_frame_executing()
 {
-       dpush(frame_executing(innermost_stack_frame(untag_check<callstack>(dpop()))));
+       stack_frame *frame = innermost_stack_frame(untag_check<callstack>(ctx->pop()));
+       ctx->push(frame_executing_quot(frame));
 }
 
 void factor_vm::primitive_innermost_stack_frame_scan()
 {
-       dpush(frame_scan(innermost_stack_frame_quot(untag_check<callstack>(dpop()))));
+       stack_frame *frame = innermost_stack_frame(untag_check<callstack>(ctx->pop()));
+       ctx->push(frame_scan(frame));
 }
 
 void factor_vm::primitive_set_innermost_stack_frame_quot()
 {
-       data_root<callstack> callstack(dpop(),this);
-       data_root<quotation> quot(dpop(),this);
+       data_root<callstack> callstack(ctx->pop(),this);
+       data_root<quotation> quot(ctx->pop(),this);
 
        callstack.untag_check(this);
        quot.untag_check(this);
 
-       jit_compile(quot.value(),true);
-
-       stack_frame *inner = innermost_stack_frame_quot(callstack.untagged());
-       cell offset = (char *)FRAME_RETURN_ADDRESS(inner,this) - (char *)inner->xt;
-       inner->xt = quot->xt;
-       FRAME_RETURN_ADDRESS(inner,this) = (char *)quot->xt + offset;
-}
+       jit_compile_quot(quot.value(),true);
 
-/* called before entry into Factor code. */
-void factor_vm::save_callstack_bottom(stack_frame *callstack_bottom)
-{
-       ctx->callstack_bottom = callstack_bottom;
-}
-
-VM_ASM_API void save_callstack_bottom(stack_frame *callstack_bottom, factor_vm *parent)
-{
-       return parent->save_callstack_bottom(callstack_bottom);
+       stack_frame *inner = innermost_stack_frame(callstack.untagged());
+       cell offset = (char *)FRAME_RETURN_ADDRESS(inner,this) - (char *)inner->entry_point;
+       inner->entry_point = quot->entry_point;
+       FRAME_RETURN_ADDRESS(inner,this) = (char *)quot->entry_point + offset;
 }
 
 }
index 76bf3ecea49754997eeb99789691575abdc077f1..9f8867447cc1686dea09a2331c20017c825eeccc 100755 (executable)
@@ -6,8 +6,6 @@ inline static cell callstack_size(cell size)
        return sizeof(callstack) + size;
 }
 
-VM_ASM_API void save_callstack_bottom(stack_frame *callstack_bottom, factor_vm *vm);
-
 /* This is a little tricky. The iterator may allocate memory, so we
 keep the callstack in a GC root and use relative offsets */
 template<typename Iterator> void factor_vm::iterate_callstack_object(callstack *stack_, Iterator &iterator)
@@ -25,12 +23,9 @@ template<typename Iterator> void factor_vm::iterate_callstack_object(callstack *
 
 template<typename Iterator> void factor_vm::iterate_callstack(context *ctx, Iterator &iterator)
 {
-       cell top = (cell)ctx->callstack_top;
-       cell bottom = (cell)ctx->callstack_bottom;
-
-       stack_frame *frame = (stack_frame *)bottom - 1;
+       stack_frame *frame = ctx->callstack_bottom - 1;
 
-       while((cell)frame >= top)
+       while(frame >= ctx->callstack_top)
        {
                iterator(frame);
                frame = frame_successor(frame);
diff --git a/vm/code_block.cpp b/vm/code_block.cpp
deleted file mode 100755 (executable)
index dc6a488..0000000
+++ /dev/null
@@ -1,506 +0,0 @@
-#include "master.hpp"
-
-namespace factor
-{
-
-relocation_type factor_vm::relocation_type_of(relocation_entry r)
-{
-       return (relocation_type)((r & 0xf0000000) >> 28);
-}
-
-relocation_class factor_vm::relocation_class_of(relocation_entry r)
-{
-       return (relocation_class)((r & 0x0f000000) >> 24);
-}
-
-cell factor_vm::relocation_offset_of(relocation_entry r)
-{
-       return (r & 0x00ffffff);
-}
-
-void factor_vm::flush_icache_for(code_block *block)
-{
-       flush_icache((cell)block,block->size());
-}
-
-int factor_vm::number_of_parameters(relocation_type type)
-{
-       switch(type)
-       {
-       case RT_PRIMITIVE:
-       case RT_XT:
-       case RT_XT_PIC:
-       case RT_XT_PIC_TAIL:
-       case RT_IMMEDIATE:
-       case RT_HERE:
-       case RT_UNTAGGED:
-       case RT_VM:
-               return 1;
-       case RT_DLSYM:
-               return 2;
-       case RT_THIS:
-       case RT_CONTEXT:
-       case RT_MEGAMORPHIC_CACHE_HITS:
-       case RT_CARDS_OFFSET:
-       case RT_DECKS_OFFSET:
-               return 0;
-       default:
-               critical_error("Bad rel type",type);
-               return -1; /* Can't happen */
-       }
-}
-
-void *factor_vm::object_xt(cell obj)
-{
-       switch(tagged<object>(obj).type())
-       {
-       case WORD_TYPE:
-               return untag<word>(obj)->xt;
-       case QUOTATION_TYPE:
-               return untag<quotation>(obj)->xt;
-       default:
-               critical_error("Expected word or quotation",obj);
-               return NULL;
-       }
-}
-
-void *factor_vm::xt_pic(word *w, cell tagged_quot)
-{
-       if(!to_boolean(tagged_quot) || max_pic_size == 0)
-               return w->xt;
-       else
-       {
-               quotation *quot = untag<quotation>(tagged_quot);
-               if(quot->code)
-                       return quot->xt;
-               else
-                       return w->xt;
-       }
-}
-
-void *factor_vm::word_xt_pic(word *w)
-{
-       return xt_pic(w,w->pic_def);
-}
-
-void *factor_vm::word_xt_pic_tail(word *w)
-{
-       return xt_pic(w,w->pic_tail_def);
-}
-
-/* References to undefined symbols are patched up to call this function on
-image load */
-void factor_vm::undefined_symbol()
-{
-       general_error(ERROR_UNDEFINED_SYMBOL,false_object,false_object,NULL);
-}
-
-void undefined_symbol()
-{
-       return tls_vm()->undefined_symbol();
-}
-
-/* Look up an external library symbol referenced by a compiled code block */
-void *factor_vm::get_rel_symbol(array *literals, cell index)
-{
-       cell symbol = array_nth(literals,index);
-       cell library = array_nth(literals,index + 1);
-
-       dll *d = (to_boolean(library) ? untag<dll>(library) : NULL);
-
-       if(d != NULL && !d->dll)
-               return (void *)factor::undefined_symbol;
-
-       switch(tagged<object>(symbol).type())
-       {
-       case BYTE_ARRAY_TYPE:
-               {
-                       symbol_char *name = alien_offset(symbol);
-                       void *sym = ffi_dlsym(d,name);
-
-                       if(sym)
-                               return sym;
-                       else
-                       {
-                               return (void *)factor::undefined_symbol;
-                       }
-               }
-       case ARRAY_TYPE:
-               {
-                       array *names = untag<array>(symbol);
-                       for(cell i = 0; i < array_capacity(names); i++)
-                       {
-                               symbol_char *name = alien_offset(array_nth(names,i));
-                               void *sym = ffi_dlsym(d,name);
-
-                               if(sym)
-                                       return sym;
-                       }
-                       return (void *)factor::undefined_symbol;
-               }
-       default:
-               critical_error("Bad symbol specifier",symbol);
-               return (void *)factor::undefined_symbol;
-       }
-}
-
-cell factor_vm::compute_relocation(relocation_entry rel, cell index, code_block *compiled)
-{
-       array *literals = (to_boolean(compiled->literals)
-               ? untag<array>(compiled->literals) : NULL);
-       cell offset = relocation_offset_of(rel) + (cell)compiled->xt();
-
-#define ARG array_nth(literals,index)
-
-       switch(relocation_type_of(rel))
-       {
-       case RT_PRIMITIVE:
-               return (cell)primitives[untag_fixnum(ARG)];
-       case RT_DLSYM:
-               return (cell)get_rel_symbol(literals,index);
-       case RT_IMMEDIATE:
-               return ARG;
-       case RT_XT:
-               return (cell)object_xt(ARG);
-       case RT_XT_PIC:
-               return (cell)word_xt_pic(untag<word>(ARG));
-       case RT_XT_PIC_TAIL:
-               return (cell)word_xt_pic_tail(untag<word>(ARG));
-       case RT_HERE:
-       {
-               fixnum arg = untag_fixnum(ARG);
-               return (arg >= 0 ? offset + arg : (cell)(compiled + 1) - arg);
-       }
-       case RT_THIS:
-               return (cell)(compiled + 1);
-       case RT_CONTEXT:
-               return (cell)&ctx;
-       case RT_UNTAGGED:
-               return untag_fixnum(ARG);
-       case RT_MEGAMORPHIC_CACHE_HITS:
-               return (cell)&dispatch_stats.megamorphic_cache_hits;
-       case RT_VM:
-               return (cell)this + untag_fixnum(ARG);
-       case RT_CARDS_OFFSET:
-               return cards_offset;
-       case RT_DECKS_OFFSET:
-               return decks_offset;
-       default:
-               critical_error("Bad rel type",rel);
-               return 0; /* Can't happen */
-       }
-
-#undef ARG
-}
-
-template<typename Iterator> void factor_vm::iterate_relocations(code_block *compiled, Iterator &iter)
-{
-       if(to_boolean(compiled->relocation))
-       {
-               byte_array *relocation = untag<byte_array>(compiled->relocation);
-
-               cell index = 0;
-               cell length = array_capacity(relocation) / sizeof(relocation_entry);
-
-               for(cell i = 0; i < length; i++)
-               {
-                       relocation_entry rel = relocation->data<relocation_entry>()[i];
-                       iter(rel,index,compiled);
-                       index += number_of_parameters(relocation_type_of(rel));                 
-               }
-       }
-}
-
-/* Store a 32-bit value into a PowerPC LIS/ORI sequence */
-void factor_vm::store_address_2_2(cell *ptr, cell value)
-{
-       ptr[-1] = ((ptr[-1] & ~0xffff) | ((value >> 16) & 0xffff));
-       ptr[ 0] = ((ptr[ 0] & ~0xffff) | (value & 0xffff));
-}
-
-/* Store a value into a bitfield of a PowerPC instruction */
-void factor_vm::store_address_masked(cell *ptr, fixnum value, cell mask, fixnum shift)
-{
-       /* This is unaccurate but good enough */
-       fixnum test = (fixnum)mask >> 1;
-       if(value <= -test || value >= test)
-               critical_error("Value does not fit inside relocation",0);
-
-       *ptr = ((*ptr & ~mask) | ((value >> shift) & mask));
-}
-
-/* Perform a fixup on a code block */
-void factor_vm::store_address_in_code_block(cell klass, cell offset, fixnum absolute_value)
-{
-       fixnum relative_value = absolute_value - offset;
-
-       switch(klass)
-       {
-       case RC_ABSOLUTE_CELL:
-               *(cell *)offset = absolute_value;
-               break;
-       case RC_ABSOLUTE:
-               *(u32*)offset = absolute_value;
-               break;
-       case RC_RELATIVE:
-               *(u32*)offset = relative_value - sizeof(u32);
-               break;
-       case RC_ABSOLUTE_PPC_2_2:
-               store_address_2_2((cell *)offset,absolute_value);
-               break;
-       case RC_ABSOLUTE_PPC_2:
-               store_address_masked((cell *)offset,absolute_value,rel_absolute_ppc_2_mask,0);
-               break;
-       case RC_RELATIVE_PPC_2:
-               store_address_masked((cell *)offset,relative_value,rel_relative_ppc_2_mask,0);
-               break;
-       case RC_RELATIVE_PPC_3:
-               store_address_masked((cell *)offset,relative_value,rel_relative_ppc_3_mask,0);
-               break;
-       case RC_RELATIVE_ARM_3:
-               store_address_masked((cell *)offset,relative_value - sizeof(cell) * 2,
-                       rel_relative_arm_3_mask,2);
-               break;
-       case RC_INDIRECT_ARM:
-               store_address_masked((cell *)offset,relative_value - sizeof(cell),
-                       rel_indirect_arm_mask,0);
-               break;
-       case RC_INDIRECT_ARM_PC:
-               store_address_masked((cell *)offset,relative_value - sizeof(cell) * 2,
-                       rel_indirect_arm_mask,0);
-               break;
-       default:
-               critical_error("Bad rel class",klass);
-               break;
-       }
-}
-
-struct literal_references_updater {
-       factor_vm *parent;
-
-       explicit literal_references_updater(factor_vm *parent_) : parent(parent_) {}
-
-       void operator()(relocation_entry rel, cell index, code_block *compiled)
-       {
-               if(parent->relocation_type_of(rel) == RT_IMMEDIATE)
-               {
-                       cell offset = parent->relocation_offset_of(rel) + (cell)(compiled + 1);
-                       array *literals = untag<array>(compiled->literals);
-                       fixnum absolute_value = array_nth(literals,index);
-                       parent->store_address_in_code_block(parent->relocation_class_of(rel),offset,absolute_value);
-               }
-       }
-};
-
-/* Update pointers to literals from compiled code. */
-void factor_vm::update_literal_references(code_block *compiled)
-{
-       if(!code->needs_fixup_p(compiled))
-       {
-               literal_references_updater updater(this);
-               iterate_relocations(compiled,updater);
-               flush_icache_for(compiled);
-       }
-}
-
-/* Compute an address to store at a relocation */
-void factor_vm::relocate_code_block_step(relocation_entry rel, cell index, code_block *compiled)
-{
-#ifdef FACTOR_DEBUG
-       if(to_boolean(compiled->literals))
-               tagged<array>(compiled->literals).untag_check(this);
-       if(to_boolean(compiled->relocation))
-               tagged<byte_array>(compiled->relocation).untag_check(this);
-#endif
-
-       store_address_in_code_block(relocation_class_of(rel),
-               relocation_offset_of(rel) + (cell)compiled->xt(),
-               compute_relocation(rel,index,compiled));
-}
-
-struct word_references_updater {
-       factor_vm *parent;
-
-       explicit word_references_updater(factor_vm *parent_) : parent(parent_) {}
-       void operator()(relocation_entry rel, cell index, code_block *compiled)
-       {
-               relocation_type type = parent->relocation_type_of(rel);
-               if(type == RT_XT || type == RT_XT_PIC || type == RT_XT_PIC_TAIL)
-                       parent->relocate_code_block_step(rel,index,compiled);
-       }
-};
-
-/* Relocate new code blocks completely; updating references to literals,
-dlsyms, and words. For all other words in the code heap, we only need
-to update references to other words, without worrying about literals
-or dlsyms. */
-void factor_vm::update_word_references(code_block *compiled)
-{
-       if(code->needs_fixup_p(compiled))
-               relocate_code_block(compiled);
-       /* update_word_references() is always applied to every block in
-          the code heap. Since it resets all call sites to point to
-          their canonical XT (cold entry point for non-tail calls,
-          standard entry point for tail calls), it means that no PICs
-          are referenced after this is done. So instead of polluting
-          the code heap with dead PICs that will be freed on the next
-          GC, we add them to the free list immediately. */
-       else if(compiled->pic_p())
-               code->code_heap_free(compiled);
-       else
-       {
-               word_references_updater updater(this);
-               iterate_relocations(compiled,updater);
-               flush_icache_for(compiled);
-       }
-}
-
-/* This runs after a full collection */
-struct literal_and_word_references_updater {
-       factor_vm *parent;
-
-       explicit literal_and_word_references_updater(factor_vm *parent_) : parent(parent_) {}
-
-       void operator()(relocation_entry rel, cell index, code_block *compiled)
-       {
-               relocation_type type = parent->relocation_type_of(rel);
-               switch(type)
-               {
-               case RT_IMMEDIATE:
-               case RT_XT:
-               case RT_XT_PIC:
-               case RT_XT_PIC_TAIL:
-                       parent->relocate_code_block_step(rel,index,compiled);
-                       break;
-               default:
-                       break;
-               }
-       }
-};
-
-void factor_vm::update_code_block_words_and_literals(code_block *compiled)
-{
-       if(code->needs_fixup_p(compiled))
-               relocate_code_block(compiled);
-       else
-       {
-               literal_and_word_references_updater updater(this);
-               iterate_relocations(compiled,updater);
-               flush_icache_for(compiled);
-       }
-}
-
-void factor_vm::check_code_address(cell address)
-{
-#ifdef FACTOR_DEBUG
-       assert(address >= code->seg->start && address < code->seg->end);
-#endif
-}
-
-struct code_block_relocator {
-       factor_vm *parent;
-
-       explicit code_block_relocator(factor_vm *parent_) : parent(parent_) {}
-
-       void operator()(relocation_entry rel, cell index, code_block *compiled)
-       {
-               parent->relocate_code_block_step(rel,index,compiled);
-       }
-};
-
-/* Perform all fixups on a code block */
-void factor_vm::relocate_code_block(code_block *compiled)
-{
-       code->needs_fixup.erase(compiled);
-       code_block_relocator relocator(this);
-       iterate_relocations(compiled,relocator);
-       flush_icache_for(compiled);
-}
-
-/* Fixup labels. This is done at compile time, not image load time */
-void factor_vm::fixup_labels(array *labels, code_block *compiled)
-{
-       cell i;
-       cell size = array_capacity(labels);
-
-       for(i = 0; i < size; i += 3)
-       {
-               cell klass = untag_fixnum(array_nth(labels,i));
-               cell offset = untag_fixnum(array_nth(labels,i + 1));
-               cell target = untag_fixnum(array_nth(labels,i + 2));
-
-               store_address_in_code_block(klass,
-                       offset + (cell)(compiled + 1),
-                       target + (cell)(compiled + 1));
-       }
-}
-
-/* Might GC */
-code_block *factor_vm::allot_code_block(cell size, code_block_type type)
-{
-       code_block *block = code->allocator->allot(size + sizeof(code_block));
-
-       /* If allocation failed, do a full GC and compact the code heap.
-       A full GC that occurs as a result of the data heap filling up does not
-       trigger a compaction. This setup ensures that most GCs do not compact
-       the code heap, but if the code fills up, it probably means it will be
-       fragmented after GC anyway, so its best to compact. */
-       if(block == NULL)
-       {
-               primitive_compact_gc();
-               block = code->allocator->allot(size + sizeof(code_block));
-
-               /* Insufficient room even after code GC, give up */
-               if(block == NULL)
-               {
-                       std::cout << "Code heap used: " << code->allocator->occupied_space() << "\n";
-                       std::cout << "Code heap free: " << code->allocator->free_space() << "\n";
-                       fatal_error("Out of memory in add-compiled-block",0);
-               }
-       }
-
-       block->set_type(type);
-       return block;
-}
-
-/* Might GC */
-code_block *factor_vm::add_code_block(code_block_type type, cell code_, cell labels_, cell owner_, cell relocation_, cell literals_)
-{
-       data_root<byte_array> code(code_,this);
-       data_root<object> labels(labels_,this);
-       data_root<object> owner(owner_,this);
-       data_root<byte_array> relocation(relocation_,this);
-       data_root<array> literals(literals_,this);
-
-       cell code_length = array_capacity(code.untagged());
-       code_block *compiled = allot_code_block(code_length,type);
-
-       compiled->owner = owner.value();
-
-       /* slight space optimization */
-       if(relocation.type() == BYTE_ARRAY_TYPE && array_capacity(relocation.untagged()) == 0)
-               compiled->relocation = false_object;
-       else
-               compiled->relocation = relocation.value();
-
-       if(literals.type() == ARRAY_TYPE && array_capacity(literals.untagged()) == 0)
-               compiled->literals = false_object;
-       else
-               compiled->literals = literals.value();
-
-       /* code */
-       memcpy(compiled + 1,code.untagged() + 1,code_length);
-
-       /* fixup labels */
-       if(to_boolean(labels.value()))
-               fixup_labels(labels.as<array>().untagged(),compiled);
-
-       /* next time we do a minor GC, we have to scan the code heap for
-       literals */
-       this->code->write_barrier(compiled);
-       this->code->needs_fixup.insert(compiled);
-
-       return compiled;
-}
-
-}
diff --git a/vm/code_block.hpp b/vm/code_block.hpp
deleted file mode 100644 (file)
index d31a776..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-namespace factor
-{
-
-enum relocation_type {
-       /* arg is a primitive number */
-       RT_PRIMITIVE,
-       /* arg is a literal table index, holding an array pair (symbol/dll) */
-       RT_DLSYM,
-       /* a pointer to a compiled word reference */
-       RT_DISPATCH,
-       /* a word or quotation's general entry point */
-       RT_XT,
-       /* a word's PIC entry point */
-       RT_XT_PIC,
-       /* a word's tail-call PIC entry point */
-       RT_XT_PIC_TAIL,
-       /* current offset */
-       RT_HERE,
-       /* current code block */
-       RT_THIS,
-       /* immediate literal */
-       RT_IMMEDIATE,
-       /* address of ctx var */
-       RT_CONTEXT,
-       /* untagged fixnum literal */
-       RT_UNTAGGED,
-       /* address of megamorphic_cache_hits var */
-       RT_MEGAMORPHIC_CACHE_HITS,
-       /* address of vm object */
-       RT_VM,
-       /* value of vm->cards_offset */
-       RT_CARDS_OFFSET,
-       /* value of vm->decks_offset */
-       RT_DECKS_OFFSET,
-};
-
-enum relocation_class {
-       /* absolute address in a 64-bit location */
-       RC_ABSOLUTE_CELL,
-       /* absolute address in a 32-bit location */
-       RC_ABSOLUTE,
-       /* relative address in a 32-bit location */
-       RC_RELATIVE,
-       /* absolute address in a PowerPC LIS/ORI sequence */
-       RC_ABSOLUTE_PPC_2_2,
-       /* absolute address in a PowerPC LWZ instruction */
-       RC_ABSOLUTE_PPC_2,
-       /* relative address in a PowerPC LWZ/STW/BC instruction */
-       RC_RELATIVE_PPC_2,
-       /* relative address in a PowerPC B/BL instruction */
-       RC_RELATIVE_PPC_3,
-       /* relative address in an ARM B/BL instruction */
-       RC_RELATIVE_ARM_3,
-       /* pointer to address in an ARM LDR/STR instruction */
-       RC_INDIRECT_ARM,
-       /* pointer to address in an ARM LDR/STR instruction offset by 8 bytes */
-       RC_INDIRECT_ARM_PC
-};
-
-static const cell rel_absolute_ppc_2_mask = 0xffff;
-static const cell rel_relative_ppc_2_mask = 0xfffc;
-static const cell rel_relative_ppc_3_mask = 0x3fffffc;
-static const cell rel_indirect_arm_mask = 0xfff;
-static const cell rel_relative_arm_3_mask = 0xffffff;
-
-/* code relocation table consists of a table of entries for each fixup */
-typedef u32 relocation_entry;
-
-}
index 33e889c9401d3320985c283c179175cdcc7962be..ac5d140783f45d62691a1bba121607b6a065c90b 100644 (file)
@@ -1,7 +1,39 @@
 namespace factor
 {
 
-template<typename Visitor> struct call_frame_code_block_visitor {
+/* Code block visitors iterate over sets of code blocks, applying a functor to
+each one. The functor returns a new code_block pointer, which may or may not
+equal the old one. This is stored back to the original location.
+
+This is used by GC's sweep and compact phases, and the implementation of the
+modify-code-heap primitive.
+
+Iteration is driven by visit_*() methods. Some of them define GC roots:
+- visit_context_code_blocks()
+- visit_callback_code_blocks() */
+template<typename Visitor> struct code_block_visitor {
+       factor_vm *parent;
+       Visitor visitor;
+
+       explicit code_block_visitor(factor_vm *parent_, Visitor visitor_) :
+               parent(parent_), visitor(visitor_) {}
+
+       code_block *visit_code_block(code_block *compiled);
+       void visit_object_code_block(object *obj);
+       void visit_embedded_code_pointers(code_block *compiled);
+       void visit_context_code_blocks();
+       void visit_uninitialized_code_blocks();
+};
+
+template<typename Visitor>
+code_block *code_block_visitor<Visitor>::visit_code_block(code_block *compiled)
+{
+       return visitor(compiled);
+}
+
+template<typename Visitor>
+struct call_frame_code_block_visitor {
        factor_vm *parent;
        Visitor visitor;
 
@@ -10,80 +42,97 @@ template<typename Visitor> struct call_frame_code_block_visitor {
 
        void operator()(stack_frame *frame)
        {
-               cell offset = (cell)FRAME_RETURN_ADDRESS(frame,parent) - (cell)frame->xt;
+               cell offset = (cell)FRAME_RETURN_ADDRESS(frame,parent) - (cell)frame->entry_point;
 
                code_block *new_block = visitor(parent->frame_code(frame));
-               frame->xt = new_block->xt();
+               frame->entry_point = new_block->entry_point();
 
-               FRAME_RETURN_ADDRESS(frame,parent) = (void *)((cell)frame->xt + offset);
+               FRAME_RETURN_ADDRESS(frame,parent) = (void *)((cell)frame->entry_point + offset);
        }
 };
 
-template<typename Visitor> struct callback_code_block_visitor {
-       callback_heap *callbacks;
-       Visitor visitor;
-
-       explicit callback_code_block_visitor(callback_heap *callbacks_, Visitor visitor_) :
-               callbacks(callbacks_), visitor(visitor_) {}
-
-       void operator()(callback *stub)
+template<typename Visitor>
+void code_block_visitor<Visitor>::visit_object_code_block(object *obj)
+{
+       switch(obj->type())
        {
-               stub->compiled = visitor(stub->compiled);
-               callbacks->update(stub);
+       case WORD_TYPE:
+               {
+                       word *w = (word *)obj;
+                       if(w->code)
+                               w->code = visitor(w->code);
+                       if(w->profiling)
+                               w->profiling = visitor(w->profiling);
+
+                       parent->update_word_entry_point(w);
+                       break;
+               }
+       case QUOTATION_TYPE:
+               {
+                       quotation *q = (quotation *)obj;
+                       if(q->code)
+                               parent->set_quot_entry_point(q,visitor(q->code));
+                       break;
+               }
+       case CALLSTACK_TYPE:
+               {
+                       callstack *stack = (callstack *)obj;
+                       call_frame_code_block_visitor<Visitor> call_frame_visitor(parent,visitor);
+                       parent->iterate_callstack_object(stack,call_frame_visitor);
+                       break;
+               }
        }
-};
+}
 
-template<typename Visitor> struct code_block_visitor {
-       factor_vm *parent;
+template<typename Visitor>
+struct embedded_code_pointers_visitor {
        Visitor visitor;
 
-       explicit code_block_visitor(factor_vm *parent_, Visitor visitor_) :
-               parent(parent_), visitor(visitor_) {}
+       explicit embedded_code_pointers_visitor(Visitor visitor_) : visitor(visitor_) {}
 
-       void visit_object_code_block(object *obj)
+       void operator()(instruction_operand op)
        {
-               switch(obj->h.hi_tag())
-               {
-               case WORD_TYPE:
-                       {
-                               word *w = (word *)obj;
-                               if(w->code)
-                                       w->code = visitor(w->code);
-                               if(w->profiling)
-                                       w->code = visitor(w->profiling);
-       
-                               parent->update_word_xt(w);
-                               break;
-                       }
-               case QUOTATION_TYPE:
-                       {
-                               quotation *q = (quotation *)obj;
-                               if(q->code)
-                                       parent->set_quot_xt(q,visitor(q->code));
-                               break;
-                       }
-               case CALLSTACK_TYPE:
-                       {
-                               callstack *stack = (callstack *)obj;
-                               call_frame_code_block_visitor<Visitor> call_frame_visitor(parent,visitor);
-                               parent->iterate_callstack_object(stack,call_frame_visitor);
-                               break;
-                       }
-               }
+               relocation_type type = op.rel_type();
+               if(type == RT_ENTRY_POINT
+                       || type == RT_ENTRY_POINT_PIC
+                       || type == RT_ENTRY_POINT_PIC_TAIL)
+                       op.store_code_block(visitor(op.load_code_block()));
        }
+};
 
-       void visit_context_code_blocks()
+template<typename Visitor>
+void code_block_visitor<Visitor>::visit_embedded_code_pointers(code_block *compiled)
+{
+       if(!parent->code->uninitialized_p(compiled))
        {
-               call_frame_code_block_visitor<Visitor> call_frame_visitor(parent,visitor);
-               parent->iterate_active_frames(call_frame_visitor);
+               embedded_code_pointers_visitor<Visitor> visitor(this->visitor);
+               compiled->each_instruction_operand(visitor);
        }
+}
+
+template<typename Visitor>
+void code_block_visitor<Visitor>::visit_context_code_blocks()
+{
+       call_frame_code_block_visitor<Visitor> call_frame_visitor(parent,visitor);
+       parent->iterate_active_frames(call_frame_visitor);
+}
+
+template<typename Visitor>
+void code_block_visitor<Visitor>::visit_uninitialized_code_blocks()
+{
+       std::map<code_block *, cell> *uninitialized_blocks = &parent->code->uninitialized_blocks;
+       std::map<code_block *, cell>::const_iterator iter = uninitialized_blocks->begin();
+       std::map<code_block *, cell>::const_iterator end = uninitialized_blocks->end();
 
-       void visit_callback_code_blocks()
+       std::map<code_block *, cell> new_uninitialized_blocks;
+       for(; iter != end; iter++)
        {
-               callback_code_block_visitor<Visitor> callback_visitor(parent->callbacks,visitor);
-               parent->callbacks->iterate(callback_visitor);
+               new_uninitialized_blocks.insert(std::make_pair(
+                       visitor(iter->first),
+                       iter->second));
        }
 
-};
+       parent->code->uninitialized_blocks = new_uninitialized_blocks;
+}
 
 }
diff --git a/vm/code_blocks.cpp b/vm/code_blocks.cpp
new file mode 100755 (executable)
index 0000000..8910649
--- /dev/null
@@ -0,0 +1,390 @@
+#include "master.hpp"
+
+namespace factor
+{
+
+cell factor_vm::compute_entry_point_address(cell obj)
+{
+       switch(tagged<object>(obj).type())
+       {
+       case WORD_TYPE:
+               return (cell)untag<word>(obj)->entry_point;
+       case QUOTATION_TYPE:
+               return (cell)untag<quotation>(obj)->entry_point;
+       default:
+               critical_error("Expected word or quotation",obj);
+               return 0;
+       }
+}
+
+cell factor_vm::compute_entry_point_pic_address(word *w, cell tagged_quot)
+{
+       if(!to_boolean(tagged_quot) || max_pic_size == 0)
+               return (cell)w->entry_point;
+       else
+       {
+               quotation *quot = untag<quotation>(tagged_quot);
+               if(quot_compiled_p(quot))
+                       return (cell)quot->entry_point;
+               else
+                       return (cell)w->entry_point;
+       }
+}
+
+cell factor_vm::compute_entry_point_pic_address(cell w_)
+{
+       tagged<word> w(w_);
+       return compute_entry_point_pic_address(w.untagged(),w->pic_def);
+}
+
+cell factor_vm::compute_entry_point_pic_tail_address(cell w_)
+{
+       tagged<word> w(w_);
+       return compute_entry_point_pic_address(w.untagged(),w->pic_tail_def);
+}
+
+cell factor_vm::code_block_owner(code_block *compiled)
+{
+       tagged<object> owner(compiled->owner);
+
+       /* Cold generic word call sites point to quotations that call the
+       inline-cache-miss and inline-cache-miss-tail primitives. */
+       if(owner.type_p(QUOTATION_TYPE))
+       {
+               tagged<quotation> quot(owner.as<quotation>());
+               tagged<array> elements(quot->array);
+#ifdef FACTOR_DEBUG
+               assert(array_capacity(elements.untagged()) == 5);
+               assert(array_nth(elements.untagged(),4) == special_objects[PIC_MISS_WORD]
+                       || array_nth(elements.untagged(),4) == special_objects[PIC_MISS_TAIL_WORD]);
+#endif
+               tagged<wrapper> word_wrapper(array_nth(elements.untagged(),0));
+               return word_wrapper->object;
+       }
+       else
+               return compiled->owner;
+}
+
+struct update_word_references_relocation_visitor {
+       factor_vm *parent;
+
+       explicit update_word_references_relocation_visitor(factor_vm *parent_) : parent(parent_) {}
+
+       void operator()(instruction_operand op)
+       {
+               switch(op.rel_type())
+               {
+               case RT_ENTRY_POINT:
+                       {
+                               code_block *compiled = op.load_code_block();
+                               cell owner = compiled->owner;
+                               if(to_boolean(owner))
+                                       op.store_value(parent->compute_entry_point_address(owner));
+                               break;
+                       }
+               case RT_ENTRY_POINT_PIC:
+                       {
+                               code_block *compiled = op.load_code_block();
+                               cell owner = parent->code_block_owner(compiled);
+                               if(to_boolean(owner))
+                                       op.store_value(parent->compute_entry_point_pic_address(owner));
+                               break;
+                       }
+               case RT_ENTRY_POINT_PIC_TAIL:
+                       {
+                               code_block *compiled = op.load_code_block();
+                               cell owner = parent->code_block_owner(compiled);
+                               if(to_boolean(owner))
+                                       op.store_value(parent->compute_entry_point_pic_tail_address(owner));
+                               break;
+                       }
+               default:
+                       break;
+               }
+       }
+};
+
+/* Relocate new code blocks completely; updating references to literals,
+dlsyms, and words. For all other words in the code heap, we only need
+to update references to other words, without worrying about literals
+or dlsyms. */
+void factor_vm::update_word_references(code_block *compiled)
+{
+       if(code->uninitialized_p(compiled))
+               initialize_code_block(compiled);
+       /* update_word_references() is always applied to every block in
+          the code heap. Since it resets all call sites to point to
+          their canonical entry point (cold entry point for non-tail calls,
+          standard entry point for tail calls), it means that no PICs
+          are referenced after this is done. So instead of polluting
+          the code heap with dead PICs that will be freed on the next
+          GC, we add them to the free list immediately. */
+       else if(compiled->pic_p())
+               code->free(compiled);
+       else
+       {
+               update_word_references_relocation_visitor visitor(this);
+               compiled->each_instruction_operand(visitor);
+               compiled->flush_icache();
+       }
+}
+
+void factor_vm::check_code_address(cell address)
+{
+#ifdef FACTOR_DEBUG
+       assert(address >= code->seg->start && address < code->seg->end);
+#endif
+}
+
+/* References to undefined symbols are patched up to call this function on
+image load */
+void factor_vm::undefined_symbol()
+{
+       general_error(ERROR_UNDEFINED_SYMBOL,false_object,false_object,NULL);
+}
+
+void undefined_symbol()
+{
+       return tls_vm()->undefined_symbol();
+}
+
+/* Look up an external library symbol referenced by a compiled code block */
+cell factor_vm::compute_dlsym_address(array *literals, cell index)
+{
+       cell symbol = array_nth(literals,index);
+       cell library = array_nth(literals,index + 1);
+
+       dll *d = (to_boolean(library) ? untag<dll>(library) : NULL);
+
+       if(d != NULL && !d->handle)
+               return (cell)factor::undefined_symbol;
+
+       switch(tagged<object>(symbol).type())
+       {
+       case BYTE_ARRAY_TYPE:
+               {
+                       symbol_char *name = alien_offset(symbol);
+                       void *sym = ffi_dlsym(d,name);
+
+                       if(sym)
+                               return (cell)sym;
+                       else
+                               return (cell)factor::undefined_symbol;
+               }
+       case ARRAY_TYPE:
+               {
+                       array *names = untag<array>(symbol);
+                       for(cell i = 0; i < array_capacity(names); i++)
+                       {
+                               symbol_char *name = alien_offset(array_nth(names,i));
+                               void *sym = ffi_dlsym(d,name);
+
+                               if(sym)
+                                       return (cell)sym;
+                       }
+                       return (cell)factor::undefined_symbol;
+               }
+       default:
+               critical_error("Bad symbol specifier",symbol);
+               return (cell)factor::undefined_symbol;
+       }
+}
+
+cell factor_vm::compute_vm_address(cell arg)
+{
+       return (cell)this + untag_fixnum(arg);
+}
+
+void factor_vm::store_external_address(instruction_operand op)
+{
+       code_block *compiled = op.parent_code_block();
+       array *parameters = (to_boolean(compiled->parameters) ? untag<array>(compiled->parameters) : NULL);
+       cell index = op.parameter_index();
+
+       switch(op.rel_type())
+       {
+       case RT_DLSYM:
+               op.store_value(compute_dlsym_address(parameters,index));
+               break;
+       case RT_THIS:
+               op.store_value((cell)compiled->entry_point());
+               break;
+       case RT_MEGAMORPHIC_CACHE_HITS:
+               op.store_value((cell)&dispatch_stats.megamorphic_cache_hits);
+               break;
+       case RT_VM:
+               op.store_value(compute_vm_address(array_nth(parameters,index)));
+               break;
+       case RT_CARDS_OFFSET:
+               op.store_value(cards_offset);
+               break;
+       case RT_DECKS_OFFSET:
+               op.store_value(decks_offset);
+               break;
+       default:
+               critical_error("Bad rel type",op.rel_type());
+               break;
+       }
+}
+
+cell factor_vm::compute_here_address(cell arg, cell offset, code_block *compiled)
+{
+       fixnum n = untag_fixnum(arg);
+       if(n >= 0)
+               return (cell)compiled->entry_point() + offset + n;
+       else
+               return (cell)compiled->entry_point() - n;
+}
+
+struct initial_code_block_visitor {
+       factor_vm *parent;
+       cell literals;
+       cell literal_index;
+
+       explicit initial_code_block_visitor(factor_vm *parent_, cell literals_)
+               : parent(parent_), literals(literals_), literal_index(0) {}
+
+       cell next_literal()
+       {
+               return array_nth(untag<array>(literals),literal_index++);
+       }
+
+       void operator()(instruction_operand op)
+       {
+               switch(op.rel_type())
+               {
+               case RT_LITERAL:
+                       op.store_value(next_literal());
+                       break;
+               case RT_ENTRY_POINT:
+                       op.store_value(parent->compute_entry_point_address(next_literal()));
+                       break;
+               case RT_ENTRY_POINT_PIC:
+                       op.store_value(parent->compute_entry_point_pic_address(next_literal()));
+                       break;
+               case RT_ENTRY_POINT_PIC_TAIL:
+                       op.store_value(parent->compute_entry_point_pic_tail_address(next_literal()));
+                       break;
+               case RT_HERE:
+                       op.store_value(parent->compute_here_address(next_literal(),op.rel_offset(),op.parent_code_block()));
+                       break;
+               case RT_UNTAGGED:
+                       op.store_value(untag_fixnum(next_literal()));
+                       break;
+               default:
+                       parent->store_external_address(op);
+                       break;
+               }
+       }
+};
+
+/* Perform all fixups on a code block */
+void factor_vm::initialize_code_block(code_block *compiled)
+{
+       std::map<code_block *,cell>::iterator iter = code->uninitialized_blocks.find(compiled);
+
+       initial_code_block_visitor visitor(this,iter->second);
+       compiled->each_instruction_operand(visitor);
+       compiled->flush_icache();
+
+       code->uninitialized_blocks.erase(iter);
+
+       /* next time we do a minor GC, we have to trace this code block, since
+       the newly-installed instruction operands might point to literals in
+       nursery or aging */
+       code->write_barrier(compiled);
+}
+
+/* Fixup labels. This is done at compile time, not image load time */
+void factor_vm::fixup_labels(array *labels, code_block *compiled)
+{
+       cell size = array_capacity(labels);
+
+       for(cell i = 0; i < size; i += 3)
+       {
+               relocation_class rel_class = (relocation_class)untag_fixnum(array_nth(labels,i));
+               cell offset = untag_fixnum(array_nth(labels,i + 1));
+               cell target = untag_fixnum(array_nth(labels,i + 2));
+
+               relocation_entry new_entry(RT_HERE,rel_class,offset);
+
+               instruction_operand op(new_entry,compiled,0);
+               op.store_value(target + (cell)compiled->entry_point());
+       }
+}
+
+/* Might GC */
+code_block *factor_vm::allot_code_block(cell size, code_block_type type)
+{
+       code_block *block = code->allocator->allot(size + sizeof(code_block));
+
+       /* If allocation failed, do a full GC and compact the code heap.
+       A full GC that occurs as a result of the data heap filling up does not
+       trigger a compaction. This setup ensures that most GCs do not compact
+       the code heap, but if the code fills up, it probably means it will be
+       fragmented after GC anyway, so its best to compact. */
+       if(block == NULL)
+       {
+               primitive_compact_gc();
+               block = code->allocator->allot(size + sizeof(code_block));
+
+               /* Insufficient room even after code GC, give up */
+               if(block == NULL)
+               {
+                       std::cout << "Code heap used: " << code->allocator->occupied_space() << "\n";
+                       std::cout << "Code heap free: " << code->allocator->free_space() << "\n";
+                       fatal_error("Out of memory in add-compiled-block",0);
+               }
+       }
+
+       block->set_type(type);
+       return block;
+}
+
+/* Might GC */
+code_block *factor_vm::add_code_block(code_block_type type, cell code_, cell labels_, cell owner_, cell relocation_, cell parameters_, cell literals_)
+{
+       data_root<byte_array> code(code_,this);
+       data_root<object> labels(labels_,this);
+       data_root<object> owner(owner_,this);
+       data_root<byte_array> relocation(relocation_,this);
+       data_root<array> parameters(parameters_,this);
+       data_root<array> literals(literals_,this);
+
+       cell code_length = array_capacity(code.untagged());
+       code_block *compiled = allot_code_block(code_length,type);
+
+       compiled->owner = owner.value();
+
+       /* slight space optimization */
+       if(relocation.type() == BYTE_ARRAY_TYPE && array_capacity(relocation.untagged()) == 0)
+               compiled->relocation = false_object;
+       else
+               compiled->relocation = relocation.value();
+
+       if(parameters.type() == ARRAY_TYPE && array_capacity(parameters.untagged()) == 0)
+               compiled->parameters = false_object;
+       else
+               compiled->parameters = parameters.value();
+
+       /* code */
+       memcpy(compiled + 1,code.untagged() + 1,code_length);
+
+       /* fixup labels */
+       if(to_boolean(labels.value()))
+               fixup_labels(labels.as<array>().untagged(),compiled);
+
+       /* Once we are ready, fill in literal and word references in this code
+       block's instruction operands. In most cases this is done right after this
+       method returns, except when compiling words with the non-optimizing
+       compiler at the beginning of bootstrap */
+       this->code->uninitialized_blocks.insert(std::make_pair(compiled,literals.value()));
+
+       /* next time we do a minor GC, we have to trace this code block, since
+       the fields of the code_block struct might point into nursery or aging */
+       this->code->write_barrier(compiled);
+
+       return compiled;
+}
+
+}
diff --git a/vm/code_blocks.hpp b/vm/code_blocks.hpp
new file mode 100644 (file)
index 0000000..baf7633
--- /dev/null
@@ -0,0 +1,75 @@
+namespace factor
+{
+
+/* The compiled code heap is structured into blocks. */
+struct code_block
+{
+       cell header;
+       cell owner; /* tagged pointer to word, quotation or f */
+       cell parameters; /* tagged pointer to array or f */
+       cell relocation; /* tagged pointer to byte-array or f */
+
+       bool free_p() const
+       {
+               return (header & 1) == 1;
+       }
+
+       code_block_type type() const
+       {
+               return (code_block_type)((header >> 1) & 0x3);
+       }
+
+       void set_type(code_block_type type)
+       {
+               header = ((header & ~0x7) | (type << 1));
+       }
+
+       bool pic_p() const
+       {
+               return type() == code_block_pic;
+       }
+
+       bool optimized_p() const
+       {
+               return type() == code_block_optimized;
+       }
+
+       cell size() const
+       {
+               cell size = header & ~7;
+#ifdef FACTOR_DEBUG
+               assert(size > 0);
+#endif
+               return size;
+       }
+
+       void *entry_point() const
+       {
+               return (void *)(this + 1);
+       }
+
+       void flush_icache()
+       {
+               factor::flush_icache((cell)this,size());
+       }
+
+       template<typename Iterator> void each_instruction_operand(Iterator &iter)
+       {
+               if(to_boolean(relocation))
+               {
+                       byte_array *rels = (byte_array *)UNTAG(relocation);
+
+                       cell index = 0;
+                       cell length = (rels->capacity >> TAG_BITS) / sizeof(relocation_entry);
+
+                       for(cell i = 0; i < length; i++)
+                       {
+                               relocation_entry rel = rels->data<relocation_entry>()[i];
+                               iter(instruction_operand(rel,this,index));
+                               index += rel.number_of_parameters();
+                       }
+               }
+       }
+};
+
+}
index b4e071d64462a3145e753517fd4416ebc83c0079..b0435bb11f9ebd016d9b35c8b9575452fed01446 100755 (executable)
@@ -5,7 +5,7 @@ namespace factor
 
 code_heap::code_heap(cell size)
 {
-       if(size > (1L << (sizeof(cell) * 8 - 6))) fatal_error("Heap too large",size);
+       if(size > ((u64)1 << (sizeof(cell) * 8 - 6))) fatal_error("Heap too large",size);
        seg = new segment(align_page(size),true);
        if(!seg) fatal_error("Out of memory in heap allocator",size);
        allocator = new free_list_allocator<code_block>(size,seg->start);
@@ -31,9 +31,9 @@ void code_heap::clear_remembered_set()
        points_to_aging.clear();
 }
 
-bool code_heap::needs_fixup_p(code_block *compiled)
+bool code_heap::uninitialized_p(code_block *compiled)
 {
-       return needs_fixup.count(compiled) > 0;
+       return uninitialized_blocks.count(compiled) > 0;
 }
 
 bool code_heap::marked_p(code_block *compiled)
@@ -51,14 +51,19 @@ void code_heap::clear_mark_bits()
        allocator->state.clear_mark_bits();
 }
 
-void code_heap::code_heap_free(code_block *compiled)
+void code_heap::free(code_block *compiled)
 {
+       assert(!uninitialized_p(compiled));
        points_to_nursery.erase(compiled);
        points_to_aging.erase(compiled);
-       needs_fixup.erase(compiled);
        allocator->free(compiled);
 }
 
+void code_heap::flush_icache()
+{
+       factor::flush_icache(seg->start,seg->size);
+}
+
 /* Allocate a code heap during startup */
 void factor_vm::init_code_heap(cell size)
 {
@@ -70,20 +75,6 @@ bool factor_vm::in_code_heap_p(cell ptr)
        return (ptr >= code->seg->start && ptr <= code->seg->end);
 }
 
-/* Compile a word definition with the non-optimizing compiler. Allocates memory */
-void factor_vm::jit_compile_word(cell word_, cell def_, bool relocate)
-{
-       data_root<word> word(word_,this);
-       data_root<quotation> def(def_,this);
-
-       jit_compile(def.value(),relocate);
-
-       word->code = def->code;
-
-       if(to_boolean(word->pic_def)) jit_compile(word->pic_def,relocate);
-       if(to_boolean(word->pic_tail_def)) jit_compile(word->pic_tail_def,relocate);
-}
-
 struct word_updater {
        factor_vm *parent;
 
@@ -100,60 +91,19 @@ defining a new word. */
 void factor_vm::update_code_heap_words()
 {
        word_updater updater(this);
-       iterate_code_heap(updater);
-}
-
-/* After a full GC that did not grow the heap, we have to update references
-to literals and other words. */
-struct word_and_literal_code_heap_updater {
-       factor_vm *parent;
-
-       explicit word_and_literal_code_heap_updater(factor_vm *parent_) : parent(parent_) {}
-
-       void operator()(code_block *block, cell size)
-       {
-               parent->update_code_block_words_and_literals(block);
-       }
-};
-
-void factor_vm::update_code_heap_words_and_literals()
-{
-       current_gc->event->started_code_sweep();
-       word_and_literal_code_heap_updater updater(this);
-       code->allocator->sweep(updater);
-       current_gc->event->ended_code_sweep();
-}
-
-/* After growing the heap, we have to perform a full relocation to update
-references to card and deck arrays. */
-struct code_heap_relocator {
-       factor_vm *parent;
-
-       explicit code_heap_relocator(factor_vm *parent_) : parent(parent_) {}
-
-       void operator()(code_block *block, cell size)
-       {
-               parent->relocate_code_block(block);
-       }
-};
-
-void factor_vm::relocate_code_heap()
-{
-       code_heap_relocator relocator(this);
-       code->allocator->sweep(relocator);
+       each_code_block(updater);
 }
 
 void factor_vm::primitive_modify_code_heap()
 {
-       data_root<array> alist(dpop(),this);
+       data_root<array> alist(ctx->pop(),this);
 
        cell count = array_capacity(alist.untagged());
 
        if(count == 0)
                return;
 
-       cell i;
-       for(i = 0; i < count; i++)
+       for(cell i = 0; i < count; i++)
        {
                data_root<array> pair(array_nth(alist.untagged(),i),this);
 
@@ -168,7 +118,7 @@ void factor_vm::primitive_modify_code_heap()
                case ARRAY_TYPE:
                        {
                                array *compiled_data = data.as<array>().untagged();
-                               cell owner = array_nth(compiled_data,0);
+                               cell parameters = array_nth(compiled_data,0);
                                cell literals = array_nth(compiled_data,1);
                                cell relocation = array_nth(compiled_data,2);
                                cell labels = array_nth(compiled_data,3);
@@ -178,8 +128,9 @@ void factor_vm::primitive_modify_code_heap()
                                        code_block_optimized,
                                        code,
                                        labels,
-                                       owner,
+                                       word.value(),
                                        relocation,
+                                       parameters,
                                        literals);
 
                                word->code = compiled;
@@ -190,7 +141,7 @@ void factor_vm::primitive_modify_code_heap()
                        break;
                }
 
-               update_word_xt(word.untagged());
+               update_word_entry_point(word.untagged());
        }
 
        update_code_heap_words();
@@ -212,7 +163,7 @@ code_heap_room factor_vm::code_room()
 void factor_vm::primitive_code_room()
 {
        code_heap_room room = code_room();
-       dpush(tag<byte_array>(byte_array_from_value(&room)));
+       ctx->push(tag<byte_array>(byte_array_from_value(&room)));
 }
 
 struct stack_trace_stripper {
@@ -227,7 +178,7 @@ struct stack_trace_stripper {
 void factor_vm::primitive_strip_stack_traces()
 {
        stack_trace_stripper stripper;
-       iterate_code_heap(stripper);
+       each_code_block(stripper);
 }
 
 }
index 8f4790d2f9e0bd6d5e3b1e1a5f64c48392c72438..78ffa6c76a19cd06926c002f8031daca7aba8337 100755 (executable)
@@ -8,8 +8,10 @@ struct code_heap {
        /* Memory allocator */
        free_list_allocator<code_block> *allocator;
 
-       /* Set of blocks which need full relocation. */
-       std::set<code_block *> needs_fixup;
+       /* Keys are blocks which need to be initialized by initialize_code_block().
+       Values are literal tables. Literal table arrays are GC roots until the
+       time the block is initialized, after which point they are discarded. */
+       std::map<code_block *, cell> uninitialized_blocks;
 
        /* Code blocks which may reference objects in the nursery */
        std::set<code_block *> points_to_nursery;
@@ -21,11 +23,12 @@ struct code_heap {
        ~code_heap();
        void write_barrier(code_block *compiled);
        void clear_remembered_set();
-       bool needs_fixup_p(code_block *compiled);
+       bool uninitialized_p(code_block *compiled);
        bool marked_p(code_block *compiled);
        void set_marked_p(code_block *compiled);
        void clear_mark_bits();
-       void code_heap_free(code_block *compiled);
+       void free(code_block *compiled);
+       void flush_icache();
 };
 
 struct code_heap_room {
index 29711aeb9ce744268503ed2376f4c43c1abfd24d..ece4926c281464e7ae1ad66b368ef9ba2d12b14a 100644 (file)
@@ -1,12 +1,12 @@
 namespace factor
 {
 
-template<typename TargetGeneration, typename Policy> struct collector_workhorse {
+template<typename TargetGeneration, typename Policy> struct data_workhorse {
        factor_vm *parent;
        TargetGeneration *target;
        Policy policy;
 
-       explicit collector_workhorse(factor_vm *parent_, TargetGeneration *target_, Policy policy_) :
+       explicit data_workhorse(factor_vm *parent_, TargetGeneration *target_, Policy policy_) :
                parent(parent_),
                target(target_),
                policy(policy_) {}
@@ -16,11 +16,10 @@ template<typename TargetGeneration, typename Policy> struct collector_workhorse
                parent->check_data_pointer(untagged);
 
                /* is there another forwarding pointer? */
-               while(untagged->h.forwarding_pointer_p())
-                       untagged = untagged->h.forwarding_pointer();
+               while(untagged->forwarding_pointer_p())
+                       untagged = untagged->forwarding_pointer();
 
                /* we've found the destination */
-               untagged->h.check_header();
                return untagged;
        }
 
@@ -32,7 +31,7 @@ template<typename TargetGeneration, typename Policy> struct collector_workhorse
                if(!newpointer) longjmp(parent->current_gc->gc_unwind,1);
 
                memcpy(newpointer,untagged,size);
-               untagged->h.forward_to(newpointer);
+               untagged->forward_to(newpointer);
 
                policy.promoted_object(newpointer);
 
@@ -62,13 +61,13 @@ template<typename TargetGeneration, typename Policy> struct collector_workhorse
 };
 
 template<typename TargetGeneration, typename Policy>
-inline static slot_visitor<collector_workhorse<TargetGeneration,Policy> > make_collector_workhorse(
+inline static slot_visitor<data_workhorse<TargetGeneration,Policy> > make_data_visitor(
        factor_vm *parent,
        TargetGeneration *target,
        Policy policy)
 {
-       return slot_visitor<collector_workhorse<TargetGeneration,Policy> >(parent,
-               collector_workhorse<TargetGeneration,Policy>(parent,target,policy));
+       return slot_visitor<data_workhorse<TargetGeneration,Policy> >(parent,
+               data_workhorse<TargetGeneration,Policy>(parent,target,policy));
 }
 
 struct dummy_unmarker {
@@ -86,12 +85,13 @@ struct full_unmarker {
        void operator()(card *ptr) { *ptr = 0; }
 };
 
-template<typename TargetGeneration, typename Policy> struct collector {
+template<typename TargetGeneration, typename Policy>
+struct collector {
        factor_vm *parent;
        data_heap *data;
        code_heap *code;
        TargetGeneration *target;
-       slot_visitor<collector_workhorse<TargetGeneration,Policy> > workhorse;
+       slot_visitor<data_workhorse<TargetGeneration,Policy> > data_visitor;
        cell cards_scanned;
        cell decks_scanned;
        cell code_blocks_scanned;
@@ -101,37 +101,41 @@ template<typename TargetGeneration, typename Policy> struct collector {
                data(parent_->data),
                code(parent_->code),
                target(target_),
-               workhorse(make_collector_workhorse(parent_,target_,policy_)),
+               data_visitor(make_data_visitor(parent_,target_,policy_)),
                cards_scanned(0),
                decks_scanned(0),
                code_blocks_scanned(0) {}
 
        void trace_handle(cell *handle)
        {
-               workhorse.visit_handle(handle);
+               data_visitor.visit_handle(handle);
        }
 
        void trace_object(object *ptr)
        {
-               workhorse.visit_slots(ptr);
-               if(ptr->h.hi_tag() == ALIEN_TYPE)
+               data_visitor.visit_slots(ptr);
+               if(ptr->type() == ALIEN_TYPE)
                        ((alien *)ptr)->update_address();
        }
 
        void trace_roots()
        {
-               workhorse.visit_roots();
+               data_visitor.visit_roots();
        }
 
        void trace_contexts()
        {
-               workhorse.visit_contexts();
+               data_visitor.visit_contexts();
+       }
+
+       void trace_code_block_objects(code_block *compiled)
+       {
+               data_visitor.visit_code_block_objects(compiled);
        }
 
-       /* Trace all literals referenced from a code block. Only for aging and nursery collections */
-       void trace_literal_references(code_block *compiled)
+       void trace_embedded_literals(code_block *compiled)
        {
-               workhorse.visit_literal_references(compiled);
+               data_visitor.visit_embedded_literals(compiled);
        }
 
        void trace_code_heap_roots(std::set<code_block *> *remembered_set)
@@ -141,7 +145,10 @@ template<typename TargetGeneration, typename Policy> struct collector {
 
                for(; iter != end; iter++)
                {
-                       trace_literal_references(*iter);
+                       code_block *compiled = *iter;
+                       trace_code_block_objects(compiled);
+                       trace_embedded_literals(compiled);
+                       compiled->flush_icache();
                        code_blocks_scanned++;
                }
        }
@@ -183,11 +190,8 @@ template<typename TargetGeneration, typename Policy> struct collector {
                        cell *slot_ptr = (cell *)start;
                        cell *end_ptr = (cell *)end;
 
-                       if(slot_ptr != end_ptr)
-                       {
-                               for(; slot_ptr < end_ptr; slot_ptr++)
-                                       workhorse.visit_handle(slot_ptr);
-                       }
+                       for(; slot_ptr < end_ptr; slot_ptr++)
+                               data_visitor.visit_handle(slot_ptr);
                }
        }
 
@@ -196,14 +200,14 @@ template<typename TargetGeneration, typename Policy> struct collector {
        {
                card_deck *decks = data->decks;
                card_deck *cards = data->cards;
-       
+
                cell gen_start_card = addr_to_card(gen->start - data->start);
 
                cell first_deck = card_deck_for_address(gen->start);
                cell last_deck = card_deck_for_address(gen->end);
-       
+
                cell start = 0, binary_start = 0, end = 0;
-       
+
                for(cell deck_index = first_deck; deck_index < last_deck; deck_index++)
                {
                        if(decks[deck_index] & mask)
@@ -212,7 +216,7 @@ template<typename TargetGeneration, typename Policy> struct collector {
 
                                cell first_card = first_card_in_deck(deck_index);
                                cell last_card = last_card_in_deck(deck_index);
-       
+
                                for(cell card_index = first_card; card_index < last_card; card_index++)
                                {
                                        if(cards[card_index] & mask)
@@ -225,13 +229,9 @@ template<typename TargetGeneration, typename Policy> struct collector {
                                                        binary_start = start + ((object *)start)->binary_payload_start();
                                                        end = start + ((object *)start)->size();
                                                }
-       
-#ifdef FACTOR_DEBUG
-                                               assert(addr_to_card(start - data->start) <= card_index);
-                                               assert(start < card_end_address(card_index));
-#endif
 
-scan_next_object:                              {
+scan_next_object:                              if(start < card_end_address(card_index))
+                                               {
                                                        trace_partial_objects(
                                                                start,
                                                                binary_start,
@@ -248,13 +248,13 @@ scan_next_object:                         {
                                                                }
                                                        }
                                                }
-       
+
                                                unmarker(&cards[card_index]);
-       
+
                                                if(!start) return;
                                        }
                                }
-       
+
                                unmarker(&decks[deck_index]);
                        }
                }
index 10e37db263ac9c080903acec7c17813e03c51ea1..5e52c70b0c852cd1385b9865e7e2d2d99da02873 100644 (file)
@@ -45,7 +45,7 @@ struct compaction_sizer {
        {
                if(!forwarding_map->marked_p(obj))
                        return forwarding_map->unmarked_block_size(obj);
-               else if(obj->h.hi_tag() == TUPLE_TYPE)
+               else if(obj->type() == TUPLE_TYPE)
                        return align(tuple_size_with_forwarding(forwarding_map,obj),data_alignment);
                else
                        return obj->size();
@@ -54,52 +54,135 @@ struct compaction_sizer {
 
 struct object_compaction_updater {
        factor_vm *parent;
-       slot_visitor<forwarder<object> > slot_forwarder;
-       code_block_visitor<forwarder<code_block> > code_forwarder;
+       mark_bits<code_block> *code_forwarding_map;
        mark_bits<object> *data_forwarding_map;
        object_start_map *starts;
 
        explicit object_compaction_updater(factor_vm *parent_,
-               slot_visitor<forwarder<object> > slot_forwarder_,
-               code_block_visitor<forwarder<code_block> > code_forwarder_,
-               mark_bits<object> *data_forwarding_map_) :
+               mark_bits<object> *data_forwarding_map_,
+               mark_bits<code_block> *code_forwarding_map_) :
                parent(parent_),
-               slot_forwarder(slot_forwarder_),
-               code_forwarder(code_forwarder_),
+               code_forwarding_map(code_forwarding_map_),
                data_forwarding_map(data_forwarding_map_),
                starts(&parent->data->tenured->starts) {}
 
        void operator()(object *old_address, object *new_address, cell size)
        {
                cell payload_start;
-               if(old_address->h.hi_tag() == TUPLE_TYPE)
+               if(old_address->type() == TUPLE_TYPE)
                        payload_start = tuple_size_with_forwarding(data_forwarding_map,old_address);
                else
                        payload_start = old_address->binary_payload_start();
 
                memmove(new_address,old_address,size);
 
+               slot_visitor<forwarder<object> > slot_forwarder(parent,forwarder<object>(data_forwarding_map));
                slot_forwarder.visit_slots(new_address,payload_start);
+
+               code_block_visitor<forwarder<code_block> > code_forwarder(parent,forwarder<code_block>(code_forwarding_map));
                code_forwarder.visit_object_code_block(new_address);
+
                starts->record_object_start_offset(new_address);
        }
 };
 
-template<typename SlotForwarder> struct code_block_compaction_updater {
+template<typename SlotForwarder>
+struct code_block_compaction_relocation_visitor {
        factor_vm *parent;
-       SlotForwarder slot_forwarder;
+       code_block *old_address;
+       slot_visitor<SlotForwarder> slot_forwarder;
+       code_block_visitor<forwarder<code_block> > code_forwarder;
 
-       explicit code_block_compaction_updater(factor_vm *parent_, SlotForwarder slot_forwarder_) :
-               parent(parent_), slot_forwarder(slot_forwarder_) {}
+       explicit code_block_compaction_relocation_visitor(factor_vm *parent_,
+               code_block *old_address_,
+               slot_visitor<SlotForwarder> slot_forwarder_,
+               code_block_visitor<forwarder<code_block> > code_forwarder_) :
+               parent(parent_),
+               old_address(old_address_),
+               slot_forwarder(slot_forwarder_),
+               code_forwarder(code_forwarder_) {}
+
+       void operator()(instruction_operand op)
+       {
+               cell old_offset = op.rel_offset() + (cell)old_address->entry_point();
+
+               switch(op.rel_type())
+               {
+               case RT_LITERAL:
+                       op.store_value(slot_forwarder.visit_pointer(op.load_value(old_offset)));
+                       break;
+               case RT_ENTRY_POINT:
+               case RT_ENTRY_POINT_PIC:
+               case RT_ENTRY_POINT_PIC_TAIL:
+                       op.store_code_block(code_forwarder.visit_code_block(op.load_code_block(old_offset)));
+                       break;
+               case RT_HERE:
+                       op.store_value(op.load_value(old_offset) - (cell)old_address + (cell)op.parent_code_block());
+                       break;
+               case RT_THIS:
+               case RT_CARDS_OFFSET:
+               case RT_DECKS_OFFSET:
+                       parent->store_external_address(op);
+                       break;
+               default:
+                       op.store_value(op.load_value(old_offset));
+                       break;
+               }
+       }
+};
+
+template<typename SlotForwarder>
+struct code_block_compaction_updater {
+       factor_vm *parent;
+       slot_visitor<SlotForwarder> slot_forwarder;
+       code_block_visitor<forwarder<code_block> > code_forwarder;
+
+       explicit code_block_compaction_updater(factor_vm *parent_,
+               slot_visitor<SlotForwarder> slot_forwarder_,
+               code_block_visitor<forwarder<code_block> > code_forwarder_) :
+               parent(parent_),
+               slot_forwarder(slot_forwarder_),
+               code_forwarder(code_forwarder_) {}
 
        void operator()(code_block *old_address, code_block *new_address, cell size)
        {
                memmove(new_address,old_address,size);
-               slot_forwarder.visit_literal_references(new_address);
-               parent->relocate_code_block(new_address);
+
+               slot_forwarder.visit_code_block_objects(new_address);
+
+               code_block_compaction_relocation_visitor<SlotForwarder> visitor(parent,old_address,slot_forwarder,code_forwarder);
+               new_address->each_instruction_operand(visitor);
        }
 };
 
+/* After a compaction, invalidate any code heap roots which are not
+marked, and also slide the valid roots up so that call sites can be updated
+correctly in case an inline cache compilation triggered compaction. */
+void factor_vm::update_code_roots_for_compaction()
+{
+       std::vector<code_root *>::const_iterator iter = code_roots.begin();
+       std::vector<code_root *>::const_iterator end = code_roots.end();
+
+       mark_bits<code_block> *state = &code->allocator->state;
+
+       for(; iter < end; iter++)
+       {
+               code_root *root = *iter;
+               code_block *block = (code_block *)(root->value & (~data_alignment + 1));
+
+               /* Offset of return address within 16-byte allocation line */
+               cell offset = root->value - (cell)block;
+
+               if(root->valid && state->marked_p(block))
+               {
+                       block = state->forward_block(block);
+                       root->value = (cell)block + offset;
+               }
+               else
+                       root->valid = false;
+       }
+}
+
 /* Compact data and code heaps */
 void factor_vm::collect_compact_impl(bool trace_contexts_p)
 {
@@ -116,18 +199,20 @@ void factor_vm::collect_compact_impl(bool trace_contexts_p)
        slot_visitor<forwarder<object> > slot_forwarder(this,forwarder<object>(data_forwarding_map));
        code_block_visitor<forwarder<code_block> > code_forwarder(this,forwarder<code_block>(code_forwarding_map));
 
+       code_forwarder.visit_uninitialized_code_blocks();
+
        /* Object start offsets get recomputed by the object_compaction_updater */
        data->tenured->starts.clear_object_start_offsets();
 
        /* Slide everything in tenured space up, and update data and code heap
        pointers inside objects. */
-       object_compaction_updater object_updater(this,slot_forwarder,code_forwarder,data_forwarding_map);
+       object_compaction_updater object_updater(this,data_forwarding_map,code_forwarding_map);
        compaction_sizer object_sizer(data_forwarding_map);
        tenured->compact(object_updater,object_sizer);
 
        /* Slide everything in the code heap up, and update data and code heap
        pointers inside code blocks. */
-       code_block_compaction_updater<slot_visitor<forwarder<object> > > code_block_updater(this,slot_forwarder);
+       code_block_compaction_updater<forwarder<object> > code_block_updater(this,slot_forwarder,code_forwarder);
        standard_sizer<code_block> code_block_sizer;
        code->allocator->compact(code_block_updater,code_block_sizer);
 
@@ -136,56 +221,75 @@ void factor_vm::collect_compact_impl(bool trace_contexts_p)
        {
                slot_forwarder.visit_contexts();
                code_forwarder.visit_context_code_blocks();
-               code_forwarder.visit_callback_code_blocks();
        }
 
        update_code_roots_for_compaction();
+       callbacks->update();
 
        current_gc->event->ended_compaction();
 }
 
-struct object_code_block_updater {
-       code_block_visitor<forwarder<code_block> > *visitor;
+struct object_grow_heap_updater {
+       code_block_visitor<forwarder<code_block> > code_forwarder;
 
-       explicit object_code_block_updater(code_block_visitor<forwarder<code_block> > *visitor_) :
-               visitor(visitor_) {}
+       explicit object_grow_heap_updater(code_block_visitor<forwarder<code_block> > code_forwarder_) :
+               code_forwarder(code_forwarder_) {}
 
-       void operator()(cell obj)
+       void operator()(object *obj)
        {
-               visitor->visit_object_code_block(tagged<object>(obj).untagged());
+               code_forwarder.visit_object_code_block(obj);
        }
 };
 
 struct dummy_slot_forwarder {
-       void visit_literal_references(code_block *compiled) {}
+       object *operator()(object *obj) { return obj; }
 };
 
-/* Compact just the code heap */
+/* Compact just the code heap, after growing the data heap */
 void factor_vm::collect_compact_code_impl(bool trace_contexts_p)
 {
        /* Figure out where blocks are going to go */
        mark_bits<code_block> *code_forwarding_map = &code->allocator->state;
        code_forwarding_map->compute_forwarding();
+
+       slot_visitor<dummy_slot_forwarder> slot_forwarder(this,dummy_slot_forwarder());
        code_block_visitor<forwarder<code_block> > code_forwarder(this,forwarder<code_block>(code_forwarding_map));
 
+       code_forwarder.visit_uninitialized_code_blocks();
+
        if(trace_contexts_p)
-       {
                code_forwarder.visit_context_code_blocks();
-               code_forwarder.visit_callback_code_blocks();
-       }
 
        /* Update code heap references in data heap */
-       object_code_block_updater updater(&code_forwarder);
+       object_grow_heap_updater updater(code_forwarder);
        each_object(updater);
 
        /* Slide everything in the code heap up, and update code heap
        pointers inside code blocks. */
-       dummy_slot_forwarder slot_forwarder;
-       code_block_compaction_updater<dummy_slot_forwarder> code_block_updater(this,slot_forwarder);
+       code_block_compaction_updater<dummy_slot_forwarder> code_block_updater(this,slot_forwarder,code_forwarder);
        standard_sizer<code_block> code_block_sizer;
        code->allocator->compact(code_block_updater,code_block_sizer);
 
        update_code_roots_for_compaction();
+       callbacks->update();
+}
+
+void factor_vm::collect_compact(bool trace_contexts_p)
+{
+       collect_mark_impl(trace_contexts_p);
+       collect_compact_impl(trace_contexts_p);
+       code->flush_icache();
+}
+
+void factor_vm::collect_growing_heap(cell requested_bytes, bool trace_contexts_p)
+{
+       /* Grow the data heap and copy all live objects to the new heap. */
+       data_heap *old = data;
+       set_data_heap(data->grow(requested_bytes));
+       collect_mark_impl(trace_contexts_p);
+       collect_compact_code_impl(trace_contexts_p);
+       code->flush_icache();
+       delete old;
 }
 
 }
index 7af7fdaa5762682ee406df067463096f50e7b09e..394d14e55dc2a309ab38e84f80e3fc6e8331da97 100644 (file)
@@ -3,33 +3,19 @@
 namespace factor
 {
 
-void factor_vm::reset_datastack()
+context::context(cell ds_size, cell rs_size) :
+       callstack_top(NULL),
+       callstack_bottom(NULL),
+       datastack(0),
+       retainstack(0),
+       datastack_region(new segment(ds_size,false)),
+       retainstack_region(new segment(rs_size,false)),
+       catchstack_save(0),
+       current_callback_save(0),
+       next(NULL)
 {
-       ds = ds_bot - sizeof(cell);
-}
-
-void factor_vm::reset_retainstack()
-{
-       rs = rs_bot - sizeof(cell);
-}
-
-static const cell stack_reserved = (64 * sizeof(cell));
-
-void factor_vm::fix_stacks()
-{
-       if(ds + sizeof(cell) < ds_bot || ds + stack_reserved >= ds_top) reset_datastack();
-       if(rs + sizeof(cell) < rs_bot || rs + stack_reserved >= rs_top) reset_retainstack();
-}
-
-/* called before entry into foreign C code. Note that ds and rs might
-be stored in registers, so callbacks must save and restore the correct values */
-void factor_vm::save_stacks()
-{
-       if(ctx)
-       {
-               ctx->datastack = ds;
-               ctx->retainstack = rs;
-       }
+       reset_datastack();
+       reset_retainstack();
 }
 
 context *factor_vm::alloc_context()
@@ -42,11 +28,7 @@ context *factor_vm::alloc_context()
                unused_contexts = unused_contexts->next;
        }
        else
-       {
-               new_context = new context;
-               new_context->datastack_region = new segment(ds_size,false);
-               new_context->retainstack_region = new segment(rs_size,false);
-       }
+               new_context = new context(ds_size,rs_size);
 
        return new_context;
 }
@@ -58,50 +40,32 @@ void factor_vm::dealloc_context(context *old_context)
 }
 
 /* called on entry into a compiled callback */
-void factor_vm::nest_stacks(stack_frame *magic_frame)
+void factor_vm::nest_stacks()
 {
        context *new_ctx = alloc_context();
 
        new_ctx->callstack_bottom = (stack_frame *)-1;
        new_ctx->callstack_top = (stack_frame *)-1;
 
-       /* note that these register values are not necessarily valid stack
-       pointers. they are merely saved non-volatile registers, and are
-       restored in unnest_stacks(). consider this scenario:
-       - factor code calls C function
-       - C function saves ds/cs registers (since they're non-volatile)
-       - C function clobbers them
-       - C function calls Factor callback
-       - Factor callback returns
-       - C function restores registers
-       - C function returns to Factor code */
-       new_ctx->datastack_save = ds;
-       new_ctx->retainstack_save = rs;
-
-       new_ctx->magic_frame = magic_frame;
-
        /* save per-callback special_objects */
        new_ctx->current_callback_save = special_objects[OBJ_CURRENT_CALLBACK];
        new_ctx->catchstack_save = special_objects[OBJ_CATCHSTACK];
 
+       new_ctx->reset_datastack();
+       new_ctx->reset_retainstack();
+
        new_ctx->next = ctx;
        ctx = new_ctx;
-
-       reset_datastack();
-       reset_retainstack();
 }
 
-void nest_stacks(stack_frame *magic_frame, factor_vm *parent)
+void nest_stacks(factor_vm *parent)
 {
-       return parent->nest_stacks(magic_frame);
+       return parent->nest_stacks();
 }
 
 /* called when leaving a compiled callback */
 void factor_vm::unnest_stacks()
 {
-       ds = ctx->datastack_save;
-       rs = ctx->retainstack_save;
-
        /* restore per-callback special_objects */
        special_objects[OBJ_CURRENT_CALLBACK] = ctx->current_callback_save;
        special_objects[OBJ_CATCHSTACK] = ctx->catchstack_save;
@@ -135,20 +99,20 @@ bool factor_vm::stack_to_array(cell bottom, cell top)
        {
                array *a = allot_uninitialized_array<array>(depth / sizeof(cell));
                memcpy(a + 1,(void*)bottom,depth);
-               dpush(tag<array>(a));
+               ctx->push(tag<array>(a));
                return true;
        }
 }
 
 void factor_vm::primitive_datastack()
 {
-       if(!stack_to_array(ds_bot,ds))
+       if(!stack_to_array(ctx->datastack_region->start,ctx->datastack))
                general_error(ERROR_DS_UNDERFLOW,false_object,false_object,NULL);
 }
 
 void factor_vm::primitive_retainstack()
 {
-       if(!stack_to_array(rs_bot,rs))
+       if(!stack_to_array(ctx->retainstack_region->start,ctx->retainstack))
                general_error(ERROR_RS_UNDERFLOW,false_object,false_object,NULL);
 }
 
@@ -162,38 +126,48 @@ cell factor_vm::array_to_stack(array *array, cell bottom)
 
 void factor_vm::primitive_set_datastack()
 {
-       ds = array_to_stack(untag_check<array>(dpop()),ds_bot);
+       ctx->datastack = array_to_stack(untag_check<array>(ctx->pop()),ctx->datastack_region->start);
 }
 
 void factor_vm::primitive_set_retainstack()
 {
-       rs = array_to_stack(untag_check<array>(dpop()),rs_bot);
+       ctx->retainstack = array_to_stack(untag_check<array>(ctx->pop()),ctx->retainstack_region->start);
 }
 
 /* Used to implement call( */
 void factor_vm::primitive_check_datastack()
 {
-       fixnum out = to_fixnum(dpop());
-       fixnum in = to_fixnum(dpop());
+       fixnum out = to_fixnum(ctx->pop());
+       fixnum in = to_fixnum(ctx->pop());
        fixnum height = out - in;
-       array *saved_datastack = untag_check<array>(dpop());
+       array *saved_datastack = untag_check<array>(ctx->pop());
        fixnum saved_height = array_capacity(saved_datastack);
-       fixnum current_height = (ds - ds_bot + sizeof(cell)) / sizeof(cell);
+       fixnum current_height = (ctx->datastack - ctx->datastack_region->start + sizeof(cell)) / sizeof(cell);
        if(current_height - height != saved_height)
-               dpush(false_object);
+               ctx->push(false_object);
        else
        {
-               fixnum i;
-               for(i = 0; i < saved_height - in; i++)
+               cell *ds_bot = (cell *)ctx->datastack_region->start;
+               for(fixnum i = 0; i < saved_height - in; i++)
                {
-                       if(((cell *)ds_bot)[i] != array_nth(saved_datastack,i))
+                       if(ds_bot[i] != array_nth(saved_datastack,i))
                        {
-                               dpush(false_object);
+                               ctx->push(false_object);
                                return;
                        }
                }
-               dpush(true_object);
+               ctx->push(true_object);
        }
 }
 
+void factor_vm::primitive_load_locals()
+{
+       fixnum count = untag_fixnum(ctx->pop());
+       memcpy((cell *)(ctx->retainstack + sizeof(cell)),
+               (cell *)(ctx->datastack - sizeof(cell) * (count - 1)),
+               sizeof(cell) * count);
+       ctx->datastack -= sizeof(cell) * count;
+       ctx->retainstack += sizeof(cell) * count;
+}
+
 }
index aa6f9ec8cecf7a9fc966ce670d3b35940eb4594d..9ba9bb313cf520daa45a91160becc6ff2aaf50c8 100644 (file)
@@ -1,11 +1,7 @@
 namespace factor
 {
 
-/* Assembly code makes assumptions about the layout of this struct:
-   - callstack_top field is 0
-   - callstack_bottom field is 1
-   - datastack field is 2
-   - retainstack field is 3 */
+/* Assembly code makes assumptions about the layout of this struct */
 struct context {
        /* C stack pointer on entry */
        stack_frame *callstack_top;
@@ -17,24 +13,6 @@ struct context {
        /* current retain stack top pointer */
        cell retainstack;
 
-       /* saved contents of ds register on entry to callback */
-       cell datastack_save;
-
-       /* saved contents of rs register on entry to callback */
-       cell retainstack_save;
-
-       /* callback-bottom stack frame, or NULL for top-level context.
-       When nest_stacks() is called, callstack layout with callbacks
-       is as follows:
-       
-       [ C function ]
-       [ callback stub in code heap ] <-- this is the magic frame
-       [ native frame: c_to_factor() ]
-       [ callback quotation frame ] <-- first call frame in call stack
-       
-       magic frame is retained so that it's XT can be traced and forwarded. */
-       stack_frame *magic_frame;
-
        /* memory region holding current datastack */
        segment *datastack_region;
 
@@ -46,18 +24,57 @@ struct context {
        cell current_callback_save;
 
        context *next;
-};
 
-#define ds_bot (ctx->datastack_region->start)
-#define ds_top (ctx->datastack_region->end)
-#define rs_bot (ctx->retainstack_region->start)
-#define rs_top (ctx->retainstack_region->end)
+       context(cell ds_size, cell rs_size);
+
+       cell peek()
+       {
+               return *(cell *)datastack;
+       }
+
+       void replace(cell tagged)
+       {
+               *(cell *)datastack = tagged;
+       }
+
+       cell pop()
+       {
+               cell value = peek();
+               datastack -= sizeof(cell);
+               return value;
+       }
 
-DEFPUSHPOP(d,ds)
-DEFPUSHPOP(r,rs)
+       void push(cell tagged)
+       {
+               datastack += sizeof(cell);
+               replace(tagged);
+       }
 
-VM_C_API void nest_stacks(stack_frame *magic_frame, factor_vm *vm);
+       void reset_datastack()
+       {
+               datastack = datastack_region->start - sizeof(cell);
+       }
+
+       void reset_retainstack()
+       {
+               retainstack = retainstack_region->start - sizeof(cell);
+       }
+
+       static const cell stack_reserved = (64 * sizeof(cell));
+
+       void fix_stacks()
+       {
+               if(datastack + sizeof(cell) < datastack_region->start
+                       || datastack + stack_reserved >= datastack_region->end)
+                       reset_datastack();
+
+               if(retainstack + sizeof(cell) < retainstack_region->start
+                       || retainstack + stack_reserved >= retainstack_region->end)
+                       reset_retainstack();
+       }
+};
+
+VM_C_API void nest_stacks(factor_vm *vm);
 VM_C_API void unnest_stacks(factor_vm *vm);
 
 }
-
diff --git a/vm/cpu-arm.S b/vm/cpu-arm.S
deleted file mode 100644 (file)
index 09e3331..0000000
+++ /dev/null
@@ -1,127 +0,0 @@
-#include "asm.h"
-
-/* Note that the XT is passed to the quotation in r12 */
-#define CALL_QUOT \
-        ldr r12,[r0, #9]     /* load quotation-xt slot */ ; \
-       mov lr,pc ; \
-        mov pc,r12
-
-#define JUMP_QUOT \
-        ldr r12,[r0, #9]     /* load quotation-xt slot */ ; \
-       mov pc,r12
-
-#define SAVED_REGS_SIZE 32
-
-#define FRAME (RESERVED_SIZE + SAVED_REGS_SIZE + 8)
-
-#define LR_SAVE [sp, #-4]
-#define RESERVED_SIZE 8
-
-#define SAVE_LR str lr,LR_SAVE
-
-#define LOAD_LR ldr lr,LR_SAVE
-
-#define SAVE_AT(offset) (RESERVED_SIZE + 4 * offset)
-
-#define SAVE(register,offset) str register,[sp, #SAVE_AT(offset)]
-
-#define RESTORE(register,offset) ldr register,[sp, #SAVE_AT(offset)]
-
-#define PROLOGUE \
-       SAVE_LR ; \
-       sub sp,sp,#FRAME
-
-#define EPILOGUE \
-       add sp,sp,#FRAME ; \
-       LOAD_LR
-
-DEF(void,c_to_factor,(CELL quot)):
-        PROLOGUE
-
-       SAVE(r4,0)           /* save GPRs */
-                             /* don't save ds pointer */
-                             /* don't save rs pointer */
-        SAVE(r7,3)
-        SAVE(r8,4)
-        SAVE(r9,5)
-        SAVE(r10,6)
-        SAVE(r11,7)
-       SAVE(r0,8)           /* save quotation since we're about to mangle it */
-
-        sub r0,sp,#4         /* pass call stack pointer as an argument */
-       bl MANGLE(save_callstack_bottom)
-
-       RESTORE(r0,8)        /* restore quotation */
-        CALL_QUOT
-
-        RESTORE(r11,7)       /* restore GPRs */
-        RESTORE(r10,6)
-        RESTORE(r9,5)
-        RESTORE(r8,4)
-        RESTORE(r7,3)
-                             /* don't restore rs pointer */
-                             /* don't restore ds pointer */
-        RESTORE(r4,0)
-
-        EPILOGUE
-        mov pc,lr
-
-/* The JIT compiles an 'mov r1',sp in front of every primitive call, since a
-word which was defined as a primitive will not change its definition for the
-lifetime of the image -- adding new primitives requires a bootstrap. However,
-an undefined word can certainly become defined,
-
-DEFER: foo
-...
-: foo ... ;
-
-And calls to non-primitives do not have this one-instruction prologue, so we
-set the XT of undefined words to this symbol. */
-DEF(void,undefined,(CELL word)):
-       sub r1,sp,#4
-       b MANGLE(undefined_error)
-
-/* Here we have two entry points. The first one is taken when profiling is
-enabled */
-DEF(void,docol_profiling,(CELL word)):
-        ldr r1,[r0, #25]     /* load profile-count slot */
-        add r1,r1,#8         /* increment count */
-        str r1,[r0, #25]     /* store profile-count slot */
-DEF(void,docol,(CELL word)):
-        ldr r0,[r0, #13]     /* load word-def slot */
-        JUMP_QUOT
-
-/* We must pass the XT to the quotation in r12. */
-DEF(void,primitive_call,(void)):
-        ldr r0,[r5], #-4     /* load quotation from data stack */
-        JUMP_QUOT
-
-/* We must preserve r1 here in case we're calling a primitive */
-DEF(void,primitive_execute,(void)):
-        ldr r0,[r5], #-4     /* load word from data stack */
-        ldr pc,[r0, #29]     /* jump to word-xt */
-
-DEF(void,set_callstack,(F_STACK_FRAME *to, F_STACK_FRAME *from, CELL length)):
-        sub sp,r0,r2         /* compute new stack pointer */
-        mov r0,sp            /* start of destination of memcpy() */
-       sub sp,sp,#12        /* alignment */
-        bl MANGLE(memcpy)    /* go */
-       add sp,sp,#16        /* point SP at innermost frame */
-        ldr pc,LR_SAVE       /* return */
-
-DEF(void,throw_impl,(CELL quot, F_STACK_FRAME *rewind_to)):
-       add sp,r1,#4         /* compute new stack pointer */
-       ldr lr,LR_SAVE       /* we have rewound the stack; load return address */
-       JUMP_QUOT            /* call the quotation */
-
-DEF(void,lazy_jit_compile,(CELL quot)):
-       mov r1,sp            /* save stack pointer */
-       PROLOGUE
-       bl MANGLE(lazy_jit_compile_impl)
-       EPILOGUE
-        JUMP_QUOT            /* call the quotation */
-
-#ifdef WINCE
-       .section .drectve
-       .ascii " -export:c_to_factor"
-#endif
index b08e76382c07cd4a5dbeaecffe9845cef86b6d6a..e725c6d5962101cb2672ffc23d8dc08a2f324a49 100644 (file)
@@ -3,14 +3,6 @@ namespace factor
 
 #define FACTOR_CPU_STRING "arm"
 
-register cell ds asm("r5");
-register cell rs asm("r6");
-
 #define FRAME_RETURN_ADDRESS(frame,vm) *(XT *)(vm->frame_successor(frame) + 1)
 
-void c_to_factor(cell quot);
-void set_callstack(stack_frame *to, stack_frame *from, cell length, void *memcpy);
-void throw_impl(cell quot, stack_frame *rewind);
-void lazy_jit_compile(cell quot);
-
 }
index 40f2521e501241882460b16a5200abdf4fdc2d64..835ed14cc20a0a62f4cea8d2361052706da47663 100644 (file)
-/* Parts of this file were snarfed from SBCL src/runtime/ppc-assem.S, which is
-in the public domain. */
-#include "asm.h"
-
-#define DS_REG r13
-
-DEF(void,primitive_fixnum_add,(void *vm)):
-       mr r5,r3  /* save vm ptr for overflow */
-       lwz r3,0(DS_REG)
-       lwz r4,-4(DS_REG)
-       subi DS_REG,DS_REG,4
-       li r0,0
-       mtxer r0
-       addo. r6,r3,r4
-       bso add_overflow
-       stw r6,0(DS_REG)
-       blr
-add_overflow:
-       b MANGLE(overflow_fixnum_add)
-
-DEF(void,primitive_fixnum_subtract,(void *vm)):
-       mr r5,r3  /* save vm ptr for overflow */
-       lwz r3,-4(DS_REG)
-       lwz r4,0(DS_REG)
-       subi DS_REG,DS_REG,4
-       li r0,0
-       mtxer r0
-       subfo. r6,r4,r3
-       bso sub_overflow
-       stw r6,0(DS_REG)
-       blr
-sub_overflow:
-       b MANGLE(overflow_fixnum_subtract)
-
-DEF(void,primitive_fixnum_multiply,(void *vm)):
-       mr r5,r3  /* save vm ptr for overflow */
-       lwz r3,0(DS_REG)
-       lwz r4,-4(DS_REG)
-       subi DS_REG,DS_REG,4
-       srawi r3,r3,4
-       mullwo. r6,r3,r4
-       bso multiply_overflow
-       stw r6,0(DS_REG)
-       blr
-multiply_overflow:
-       srawi r4,r4,4
-       b MANGLE(overflow_fixnum_multiply)
-       
-/* Note that the XT is passed to the quotation in r11 */
-#define CALL_OR_JUMP_QUOT \
-       lwz r11,12(r3)     /* load quotation-xt slot */ XX \
-
-#define CALL_QUOT \
-       CALL_OR_JUMP_QUOT XX \
-       mtlr r11           /* prepare to call XT with quotation in r3 */ XX \
-       blrl               /* go */
-
-#define JUMP_QUOT \
-       CALL_OR_JUMP_QUOT XX \
-       mtctr r11          /* prepare to call XT with quotation in r3 */ XX \
-       bctr               /* go */
-
-#define PARAM_SIZE 32
-
-#define SAVED_INT_REGS_SIZE 96
-
-#define SAVED_FP_REGS_SIZE 144
-
-#define SAVED_V_REGS_SIZE 208
-
-#define FRAME (RESERVED_SIZE + PARAM_SIZE + SAVED_INT_REGS_SIZE + SAVED_FP_REGS_SIZE + SAVED_V_REGS_SIZE + 8)
-   
-#if defined( __APPLE__)
-       #define LR_SAVE 8
-       #define RESERVED_SIZE 24
+#if defined(__APPLE__)
+    #define MANGLE(sym) _##sym
+    #define XX @
 #else
-       #define LR_SAVE 4
-       #define RESERVED_SIZE 8
+    #define MANGLE(sym) sym
+    #define XX ;
 #endif
 
-#define SAVE_LR(reg) stw reg,(LR_SAVE + FRAME)(r1)
-
-#define LOAD_LR(reg) lwz reg,(LR_SAVE + FRAME)(r1)
-
-#define SAVE_AT(offset) (RESERVED_SIZE + PARAM_SIZE + 4 * offset)
-
-#define SAVE_INT(register,offset) stw register,SAVE_AT(offset)(r1)
-#define RESTORE_INT(register,offset) lwz register,SAVE_AT(offset)(r1)
-
-#define SAVE_FP(register,offset) stfd register,SAVE_AT(offset)(r1)
-#define RESTORE_FP(register,offset) lfd register,SAVE_AT(offset)(r1)
-
-#define SAVE_V(register,offset) \
-       li r2,SAVE_AT(offset) XX \
-       stvxl register,r2,r1
-
-#define RESTORE_V(register,offset) \
-       li r2,SAVE_AT(offset) XX \
-       lvxl register,r2,r1
-
-#define PROLOGUE \
-       mflr r0 XX         /* get caller's return address */ \
-       stwu r1,-FRAME(r1) XX /* create a stack frame to hold non-volatile registers */ \
-       SAVE_LR(r0)
-
-#define EPILOGUE \
-       LOAD_LR(r0) XX \
-       lwz r1,0(r1) XX    /* destroy the stack frame */ \
-       mtlr r0            /* get ready to return */
-
-/* We have to save and restore nonvolatile registers because
-the Factor compiler treats the entire register file as volatile. */
-DEF(void,c_to_factor,(cell quot, void *vm)):
-       PROLOGUE
-
-       SAVE_INT(r15,0)    /* save GPRs */
-       SAVE_INT(r16,1)
-       SAVE_INT(r17,2)
-       SAVE_INT(r18,3)
-       SAVE_INT(r19,4)
-       SAVE_INT(r20,5)
-       SAVE_INT(r21,6)
-       SAVE_INT(r22,7)
-       SAVE_INT(r23,8)
-       SAVE_INT(r24,9)
-       SAVE_INT(r25,10)
-       SAVE_INT(r26,11)
-       SAVE_INT(r27,12)
-       SAVE_INT(r28,13)
-       SAVE_INT(r29,14)
-       SAVE_INT(r30,15)
-       SAVE_INT(r31,16)
-
-       SAVE_FP(f14,20) /* save FPRs */
-       SAVE_FP(f15,22)
-       SAVE_FP(f16,24)
-       SAVE_FP(f17,26)
-       SAVE_FP(f18,28)
-       SAVE_FP(f19,30)
-       SAVE_FP(f20,32)
-       SAVE_FP(f21,34)
-       SAVE_FP(f22,36)
-       SAVE_FP(f23,38)
-       SAVE_FP(f24,40)
-       SAVE_FP(f25,42)
-       SAVE_FP(f26,44)
-       SAVE_FP(f27,46)
-       SAVE_FP(f28,48)
-       SAVE_FP(f29,50)
-       SAVE_FP(f30,52)
-       SAVE_FP(f31,54)
-
-        SAVE_V(v20,56)
-        SAVE_V(v21,60)
-        SAVE_V(v22,64)
-        SAVE_V(v23,68)
-        SAVE_V(v24,72)
-        SAVE_V(v25,76)
-        SAVE_V(v26,80)
-        SAVE_V(v27,84)
-        SAVE_V(v28,88)
-        SAVE_V(v29,92)
-        SAVE_V(v30,96)
-        SAVE_V(v31,100)
-
-       /* r4 vm ptr preserved */
-        mfvscr v0
-        li r2,SAVE_AT(104)
-        stvxl v0,r2,r1
-        addi r2,r2,0xc
-        lwzx r5,r2,r1
-        lis r6,0x1
-        andc r5,r5,r6
-        stwx r5,r2,r1
-        subi r2,r2,0xc
-        lvxl v0,r2,r1
-        mtvscr v0
-
-        /* save args in non-volatile regs */
-        mr r15,r3
-        mr r16,r4
-
-       /* pass call stack pointer as an argument */
-       mr r3,r1
-       bl MANGLE(save_callstack_bottom)
-
-       /* restore quotation args */
-       mr r3,r15
-       mr r4,r16
-       CALL_QUOT
-
-        RESTORE_V(v0,104)
-        mtvscr v0
-
-        RESTORE_V(v31,100)
-        RESTORE_V(v30,96)
-        RESTORE_V(v29,92)
-        RESTORE_V(v28,88)
-        RESTORE_V(v27,84)
-        RESTORE_V(v26,80)
-        RESTORE_V(v25,76)
-        RESTORE_V(v24,72)
-        RESTORE_V(v23,68)
-        RESTORE_V(v22,64)
-        RESTORE_V(v21,60)
-        RESTORE_V(v20,56)
-
-        /* Restore FPRs */
-       RESTORE_FP(f31,54)
-       RESTORE_FP(f30,52)
-       RESTORE_FP(f29,50)
-       RESTORE_FP(f28,48)
-       RESTORE_FP(f27,46)
-       RESTORE_FP(f26,44)
-       RESTORE_FP(f25,42)
-       RESTORE_FP(f24,40)
-       RESTORE_FP(f23,38)
-       RESTORE_FP(f22,36)
-       RESTORE_FP(f21,34)
-       RESTORE_FP(f20,32)
-       RESTORE_FP(f19,30)
-       RESTORE_FP(f18,28)
-       RESTORE_FP(f17,26)
-       RESTORE_FP(f16,24)
-       RESTORE_FP(f15,22)
-       RESTORE_FP(f14,20)
-
-       /* restore GPRs */
-       RESTORE_INT(r31,16)   
-       RESTORE_INT(r30,15)
-       RESTORE_INT(r29,14)
-       RESTORE_INT(r28,13)
-       RESTORE_INT(r27,12)
-       RESTORE_INT(r26,11)
-       RESTORE_INT(r25,10)
-       RESTORE_INT(r24,9)
-       RESTORE_INT(r23,8)
-       RESTORE_INT(r22,7)
-       RESTORE_INT(r21,6)
-       RESTORE_INT(r20,5)
-       RESTORE_INT(r19,4)
-       RESTORE_INT(r18,3)
-       RESTORE_INT(r17,2)
-       RESTORE_INT(r16,1)
-       RESTORE_INT(r15,0)
-
-       EPILOGUE
-       blr
-
-/* We pass a function pointer to memcpy in r6 to work around a Mac OS X ABI
-limitation which would otherwise require us to do a bizzaro PC-relative
-trampoline to retrieve the function address */
-DEF(void,set_callstack,(F_STACK_FRAME *to, F_STACK_FRAME *from, cell length, void *memcpy)):
-       sub r1,r3,r5       /* compute new stack pointer */
-       mr r3,r1           /* start of destination of memcpy() */
-       stwu r1,-64(r1)    /* setup fake stack frame for memcpy() */
-       mtlr r6            /* prepare to call memcpy() */
-       blrl               /* go */
-       lwz r1,0(r1)       /* tear down fake stack frame */
-       lwz r0,LR_SAVE(r1) /* we have restored the stack; load return address */
-       mtlr r0            /* prepare to return to restored callstack */
-       blr                /* go */
-
-DEF(void,throw_impl,(cell quot, F_STACK_FRAME *rewind_to, void *vm)):
-       mr r1,r4           /* compute new stack pointer */
-       mr r4,r5           /* make vm ptr 2nd arg in case quot_xt = lazy_jit_compile */
-       lwz r0,LR_SAVE(r1) /* we have rewound the stack; load return address */
-       mtlr r0
-       JUMP_QUOT          /* call the quotation */
-
-DEF(void,lazy_jit_compile,(cell quot, void *vm)):
-       mr r5,r4           /* vm ptr is 3rd arg */
-       mr r4,r1           /* save stack pointer */
-       PROLOGUE
-       bl MANGLE(lazy_jit_compile_impl)
-       EPILOGUE
-       JUMP_QUOT          /* call the quotation */
+/* The returns and args are just for documentation */
+#define DEF(returns,symbol,args) .globl MANGLE(symbol) XX \
+MANGLE(symbol)
 
 /* Thanks to Joshua Grams for this code.
 
 On PowerPC processors, we must flush the instruction cache manually
 after writing to the code heap. */
 
-DEF(void,flush_icache,(void *start, int len)):
-       /* compute number of cache lines to flush */
-       add r4,r4,r3
-       clrrwi r3,r3,5     /* align addr to next lower cache line boundary */
-       sub r4,r4,r3       /* then n_lines = (len + 0x1f) / 0x20 */
-       addi r4,r4,0x1f
-       srwi. r4,r4,5      /* note '.' suffix */
-       beqlr              /* if n_lines == 0, just return. */
-       mtctr r4           /* flush cache lines */
-0:     dcbf 0,r3          /* for each line... */
-       sync
-       icbi 0,r3
-       addi r3,r3,0x20
-       bdnz 0b
-       sync               /* finish up */
-       isync
-       blr
-
-DEF(void,primitive_inline_cache_miss,(void *vm)):
-       mflr r6
-DEF(void,primitive_inline_cache_miss_tail,(void *vm)):
-       PROLOGUE
-       mr r4,r3          /* vm ptr in 2nd arg */
-       mr r3,r6
-       bl MANGLE(inline_cache_miss)
-       EPILOGUE
-       mtctr r3
-       bctr
+DEF(void,flush_icache,(void*, int)):
+    /* compute number of cache lines to flush */
+    add r4,r4,r3
+    /* align addr to next lower cache line boundary */
+    clrrwi r3,r3,5
+    /* then n_lines = (len + 0x1f) / 0x20 */
+    sub r4,r4,r3
+    addi r4,r4,0x1f
+    /* note '.' suffix */
+    srwi. r4,r4,5
+    /* if n_lines == 0, just return. */
+    beqlr
+    /* flush cache lines */
+    mtctr r4
+    /* for each line... */
+0:  dcbf 0,r3
+    sync
+    icbi 0,r3
+    addi r3,r3,0x20
+    bdnz 0b
+    /* finish up */
+    sync
+    isync
+    blr
 
 DEF(void,get_ppc_fpu_env,(void*)):
-       mffs f0
-       stfd f0,0(r3)
-       blr
+    mffs f0
+    stfd f0,0(r3)
+    blr
 
 DEF(void,set_ppc_fpu_env,(const void*)):
-       lfd f0,0(r3)
-       mtfsf 0xff,f0
-       blr
+    lfd f0,0(r3)
+    mtfsf 0xff,f0
+    blr
 
 DEF(void,get_ppc_vmx_env,(void*)):
-       mfvscr v0
-       subi r4,r1,16
-       li r5,0xf
-       andc r4,r4,r5
-       stvxl v0,0,r4
-       li r5,0xc
-       lwzx r6,r5,r4
-       stw r6,0(r3)
-       blr
+    mfvscr v0
+    subi r4,r1,16
+    li r5,0xf
+    andc r4,r4,r5
+    stvxl v0,0,r4
+    li r5,0xc
+    lwzx r6,r5,r4
+    stw r6,0(r3)
+    blr
 
 DEF(void,set_ppc_vmx_env,(const void*)):
-       subi r4,r1,16
-       li r5,0xf
-       andc r4,r4,r5
-       li r5,0xc
-       lwz r6,0(r3)
-       stwx r6,r5,r4
-       lvxl v0,0,r4
-       mtvscr v0
-       blr
-
+    subi r4,r1,16
+    li r5,0xf
+    andc r4,r4,r5
+    li r5,0xc
+    lwz r6,0(r3)
+    stwx r6,r5,r4
+    lvxl v0,0,r4
+    mtvscr v0
+    blr
index 495eb375ec6dd7fff3fa93aaa9baf64eceefd40b..cd98d6a6ab553c7b90733416a89c5d43418d4969 100644 (file)
@@ -2,10 +2,6 @@ namespace factor
 {
 
 #define FACTOR_CPU_STRING "ppc"
-#define VM_ASM_API VM_C_API
-
-register cell ds asm("r13");
-register cell rs asm("r14");
 
 /* In the instruction sequence:
 
@@ -13,8 +9,8 @@ register cell rs asm("r14");
    B blah
 
    the offset from the immediate operand to LOAD32 to the instruction after
-   the branch is two instructions. */
-static const fixnum xt_tail_pic_offset = 4 * 2;
+   the branch is one instruction. */
+static const fixnum xt_tail_pic_offset = 4;
 
 inline static void check_call_site(cell return_address)
 {
@@ -81,14 +77,6 @@ inline static unsigned int fpu_status(unsigned int status)
 }
 
 /* Defined in assembly */
-VM_ASM_API void c_to_factor(cell quot, void *vm);
-VM_ASM_API void throw_impl(cell quot, stack_frame *rewind, void *vm);
-VM_ASM_API void lazy_jit_compile(cell quot, void *vm);
-VM_ASM_API void flush_icache(cell start, cell len);
-
-VM_ASM_API void set_callstack(stack_frame *to,
-                              stack_frame *from,
-                              cell length,
-                              void *(*memcpy)(void*,const void*, size_t));
+VM_C_API void flush_icache(cell start, cell len);
 
 }
diff --git a/vm/cpu-x86.32.S b/vm/cpu-x86.32.S
deleted file mode 100644 (file)
index c0532f0..0000000
+++ /dev/null
@@ -1,114 +0,0 @@
-#include "asm.h"
-
-#define ARG0 %eax
-#define ARG1 %edx
-#define ARG2 %ecx
-#define STACK_REG %esp
-#define DS_REG %esi
-#define RETURN_REG %eax
-
-#define NV0 %ebx
-#define NV1 %ebp
-
-#define ARITH_TEMP_1 %ebp
-#define ARITH_TEMP_2 %ebx
-#define DIV_RESULT %eax
-
-#define CELL_SIZE 4
-#define STACK_PADDING 12
-
-#define PUSH_NONVOLATILE \
-       push %ebx ; \
-       push %ebp
-
-#define POP_NONVOLATILE \
-       pop %ebp ; \
-       pop %ebx
-
-#define QUOT_XT_OFFSET 12
-
-/* We pass a function pointer to memcpy to work around a Mac OS X
-ABI limitation which would otherwise require us to do a bizzaro PC-relative
-trampoline to retrieve the function address */
-DEF(void,set_callstack,(F_STACK_FRAME *to, F_STACK_FRAME *from, CELL length, void *memcpy)):
-       mov 4(%esp),%ebp                   /* to */
-       mov 8(%esp),%edx                   /* from */
-       mov 12(%esp),%ecx                  /* length */
-       mov 16(%esp),%eax                  /* memcpy */
-       sub %ecx,%ebp                      /* compute new stack pointer */
-       mov %ebp,%esp
-       push %ecx                          /* pass length */
-       push %edx                          /* pass src */
-       push %ebp                          /* pass dst */
-       call *%eax                         /* call memcpy */
-       add $12,%esp                       /* pop args from the stack */
-       ret                                /* return _with new stack_ */
-
-DEF(long long,read_timestamp_counter,(void)):
-       rdtsc
-       ret
-
-DEF(void,primitive_inline_cache_miss,(void *vm)):
-       mov (%esp),%ebx
-DEF(void,primitive_inline_cache_miss_tail,(void *vm)):
-       sub $4,%esp
-       push ARG0   /* push vm ptr */
-       push %ebx
-       call MANGLE(inline_cache_miss)
-       add $12,%esp
-       jmp *%eax
-
-DEF(void,get_sse_env,(void*)):
-       movl 4(%esp), %eax
-       stmxcsr (%eax)
-       ret
-
-DEF(void,set_sse_env,(const void*)):
-       movl 4(%esp), %eax
-       ldmxcsr (%eax)
-       ret
-
-DEF(void,get_x87_env,(void*)):
-       movl 4(%esp), %eax
-       fnstsw (%eax)
-       fnstcw 2(%eax)
-       ret
-
-DEF(void,set_x87_env,(const void*)):
-       movl 4(%esp), %eax
-       fnclex
-       fldcw 2(%eax)
-       ret
-
-DEF(F_FASTCALL void,throw_impl,(CELL quot, F_STACK_FRAME *rewind_to, void *vm)):
-       mov ARG2,NV0  /* remember vm ptr in case quot_xt = lazy_jit_compile */          
-       /* clear x87 stack, but preserve rounding mode and exception flags */
-       sub $2,STACK_REG
-       fnstcw (STACK_REG)
-       fninit
-       fldcw (STACK_REG)
-       /* rewind_to */
-       mov ARG1,STACK_REG
-       mov NV0,ARG1
-       jmp *QUOT_XT_OFFSET(ARG0)
-
-DEF(F_FASTCALL void,lazy_jit_compile,(CELL quot, void *vm)):
-       mov ARG1,ARG2
-       mov STACK_REG,ARG1           /* Save stack pointer */
-       sub $STACK_PADDING,STACK_REG
-       call MANGLE(lazy_jit_compile_impl)
-       mov RETURN_REG,ARG0          /* No-op on 32-bit */
-       add $STACK_PADDING,STACK_REG
-    jmp *QUOT_XT_OFFSET(ARG0)    /* Call the quotation */
-
-       
-#include "cpu-x86.S"
-
-#ifdef WINDOWS
-       .section .drectve
-       .ascii " -export:read_timestamp_counter"
-       .ascii " -export:get_sse_env"
-       .ascii " -export:set_sse_env"
-       .ascii " -export:get_x87_env"
-       .ascii " -export:set_x87_env"
-#endif
index e74077147091b589c83c76ae554b9ecce8f71936..6143631abc25ea8b3d50065835328ae8b33e243b 100644 (file)
@@ -3,8 +3,4 @@ namespace factor
 
 #define FACTOR_CPU_STRING "x86.32"
 
-register cell ds asm("esi");
-register cell rs asm("edi");
-
-#define VM_ASM_API VM_C_API __attribute__ ((regparm (3)))
 }
diff --git a/vm/cpu-x86.64.S b/vm/cpu-x86.64.S
deleted file mode 100644 (file)
index 8ccd703..0000000
+++ /dev/null
@@ -1,128 +0,0 @@
-#include "asm.h"
-
-#define STACK_REG %rsp
-#define DS_REG %r14
-#define RETURN_REG %rax
-
-#define CELL_SIZE 8
-#define STACK_PADDING 56
-
-#define NV0 %rbp
-#define NV1 %r12
-
-#define ARITH_TEMP_1 %r8
-#define ARITH_TEMP_2 %r9
-#define DIV_RESULT %rax
-
-#ifdef WINDOWS
-
-       #define ARG0 %rcx
-       #define ARG1 %rdx
-       #define ARG2 %r8
-       #define ARG3 %r9
-
-       #define PUSH_NONVOLATILE \
-               push %r12 ; \
-               push %r13 ; \
-               push %rdi ; \
-               push %rsi ; \
-               push %rbx ; \
-               push %rbp
-
-       #define POP_NONVOLATILE \
-               pop %rbp ; \
-               pop %rbx ; \
-               pop %rsi ; \
-               pop %rdi ; \
-               pop %r13 ; \
-               pop %r12
-
-#else
-
-       #define ARG0 %rdi
-       #define ARG1 %rsi
-       #define ARG2 %rdx
-       #define ARG3 %rcx
-
-       #define PUSH_NONVOLATILE \
-               push %rbx ; \
-               push %rbp ; \
-               push %r12 ; \
-               push %r13
-
-       #define POP_NONVOLATILE \
-               pop %r13 ; \
-               pop %r12 ; \
-               pop %rbp ; \
-               pop %rbx
-
-#endif
-
-#define QUOT_XT_OFFSET 28
-
-/* We pass a function pointer to memcpy to work around a Mac OS X
-ABI limitation which would otherwise require us to do a bizzaro PC-relative
-trampoline to retrieve the function address */
-DEF(void,set_callstack,(F_STACK_FRAME *to, F_STACK_FRAME *from, CELL length, void *memcpy)):
-       sub ARG2,ARG0                      /* compute new stack pointer */
-       mov ARG0,%rsp
-       call *ARG3                         /* call memcpy */
-       ret                                /* return _with new stack_ */
-
-DEF(long long,read_timestamp_counter,(void)):
-       mov $0,%rax
-       rdtsc
-       shl $32,%rdx
-       or %rdx,%rax
-       ret
-
-DEF(void,primitive_inline_cache_miss,(void *vm)):
-       mov (%rsp),%rbx
-DEF(void,primitive_inline_cache_miss_tail,(void *vm)):
-       sub $STACK_PADDING,%rsp
-       mov ARG0,ARG1
-       mov %rbx,ARG0
-       call MANGLE(inline_cache_miss)
-       add $STACK_PADDING,%rsp
-       jmp *%rax
-
-DEF(void,get_sse_env,(void*)):
-       stmxcsr (%rdi)
-       ret
-
-DEF(void,set_sse_env,(const void*)):
-       ldmxcsr (%rdi)
-       ret
-
-DEF(void,get_x87_env,(void*)):
-       fnstsw (%rdi)
-       fnstcw 2(%rdi)
-       ret
-
-DEF(void,set_x87_env,(const void*)):
-       fnclex
-       fldcw 2(%rdi)
-       ret
-
-DEF(F_FASTCALL void,throw_impl,(CELL quot, F_STACK_FRAME *rewind_to, void *vm)):
-       /* clear x87 stack, but preserve rounding mode and exception flags */
-       sub $2,STACK_REG
-       fnstcw (STACK_REG)
-       fninit
-       fldcw (STACK_REG)
-       /* rewind_to */
-       mov ARG1,STACK_REG
-       mov ARG2,ARG1  /* make vm ptr 2nd arg in case quot_xt = lazy_jit_compile */
-       jmp *QUOT_XT_OFFSET(ARG0)
-
-DEF(F_FASTCALL void,lazy_jit_compile,(CELL quot, void *vm)):
-       mov ARG1,ARG2                /* vm is 3rd arg */
-       mov STACK_REG,ARG1           /* Save stack pointer */
-       sub $STACK_PADDING,STACK_REG
-       call MANGLE(lazy_jit_compile_impl)
-       mov RETURN_REG,ARG0          /* No-op on 32-bit */
-       add $STACK_PADDING,STACK_REG
-        jmp *QUOT_XT_OFFSET(ARG0)    /* Call the quotation */
-
-       
-#include "cpu-x86.S"
index 75d432ee13a35825933e502fee0210c1ef5e7914..e6a759d0069cd81e7d4e7c1ca46249732feeb06e 100644 (file)
@@ -3,8 +3,4 @@ namespace factor
 
 #define FACTOR_CPU_STRING "x86.64"
 
-register cell ds asm("r14");
-register cell rs asm("r15");
-
-#define VM_ASM_API VM_C_API
 }
diff --git a/vm/cpu-x86.S b/vm/cpu-x86.S
deleted file mode 100644 (file)
index 411a0cd..0000000
+++ /dev/null
@@ -1,115 +0,0 @@
-DEF(void,primitive_fixnum_add,(void *myvm)):
-       mov ARG0, ARG2  /* save vm ptr for overflow */
-       mov (DS_REG),ARG0
-       mov -CELL_SIZE(DS_REG),ARG1
-       sub $CELL_SIZE,DS_REG
-       mov ARG1,ARITH_TEMP_1
-       add ARG0,ARITH_TEMP_1
-       jo MANGLE(overflow_fixnum_add)
-       mov ARITH_TEMP_1,(DS_REG)
-       ret
-
-DEF(void,primitive_fixnum_subtract,(void *myvm)):
-       mov ARG0, ARG2  /* save vm ptr for overflow */
-       mov (DS_REG),ARG1
-       mov -CELL_SIZE(DS_REG),ARG0
-       sub $CELL_SIZE,DS_REG
-       mov ARG0,ARITH_TEMP_1
-       sub ARG1,ARITH_TEMP_1
-       jo MANGLE(overflow_fixnum_subtract)
-       mov ARITH_TEMP_1,(DS_REG)
-       ret
-
-DEF(void,primitive_fixnum_multiply,(void *myvm)):
-       push ARG0  /* save vm ptr for overflow */
-       mov (DS_REG),ARITH_TEMP_1
-       mov ARITH_TEMP_1,DIV_RESULT
-       mov -CELL_SIZE(DS_REG),ARITH_TEMP_2
-       sar $4,ARITH_TEMP_2
-       sub $CELL_SIZE,DS_REG
-       imul ARITH_TEMP_2
-       jo multiply_overflow
-       mov DIV_RESULT,(DS_REG)
-       pop ARG2
-       ret
-multiply_overflow:
-       sar $4,ARITH_TEMP_1
-       mov ARITH_TEMP_1,ARG0
-       mov ARITH_TEMP_2,ARG1
-       pop ARG2
-       jmp MANGLE(overflow_fixnum_multiply)
-
-DEF(F_FASTCALL void,c_to_factor,(CELL quot, void *vm)):
-       PUSH_NONVOLATILE
-       mov ARG0,NV0
-       mov ARG1,NV1
-
-    /* Save old stack pointer and align */
-    mov STACK_REG,ARG0
-    and $-16,STACK_REG
-    add $CELL_SIZE,STACK_REG
-    push ARG0
-
-       /* Create register shadow area for Win64 */
-       sub $32,STACK_REG
-
-       /* Save stack pointer */
-       lea -CELL_SIZE(STACK_REG),ARG0
-       call MANGLE(save_callstack_bottom)
-
-       /* Call quot-xt */
-       mov NV0,ARG0
-       mov NV1,ARG1
-       call *QUOT_XT_OFFSET(ARG0)
-
-       /* Tear down register shadow area */
-       add $32,STACK_REG
-
-    /* Undo stack alignment */
-    mov (STACK_REG),STACK_REG
-
-       POP_NONVOLATILE
-       ret
-
-/* cpu.x86.features calls this */
-DEF(bool,sse_version,(void)):
-       mov $0x1,RETURN_REG
-       cpuid
-       test $0x100000,%ecx
-       jnz sse_42
-       test $0x80000,%ecx
-       jnz sse_41
-       test $0x200,%ecx
-       jnz ssse_3
-       test $0x1,%ecx
-       jnz sse_3
-       test $0x4000000,%edx
-       jnz sse_2
-       test $0x2000000,%edx
-       jnz sse_1
-       mov $0,%eax
-       ret
-sse_42:
-       mov $42,RETURN_REG
-       ret
-sse_41:
-       mov $41,RETURN_REG
-       ret
-ssse_3:
-       mov $33,RETURN_REG
-       ret
-sse_3:
-       mov $30,RETURN_REG
-       ret
-sse_2:
-       mov $20,RETURN_REG
-       ret
-sse_1:
-       mov $10,RETURN_REG
-       ret
-
-#ifdef WINDOWS
-       .section .drectve
-       .ascii " -export:sse_version"
-       .ascii " -export:c_to_factor"
-#endif
index 85585aeda627935446b60d82c105145973a60da4..c96291b0d72da9be33552f2386bb4dfedd21062c 100644 (file)
@@ -15,7 +15,7 @@ inline static void flush_icache(cell start, cell len) {}
    the offset from the immediate operand to MOV to the instruction after
    the jump is a cell for the immediate operand, 4 bytes for the JMP
    destination, and one byte for the JMP opcode. */
-static const fixnum xt_tail_pic_offset = sizeof(cell) + 4 + 1;
+static const fixnum xt_tail_pic_offset = 4 + 1;
 
 static const unsigned char call_opcode = 0xe8;
 static const unsigned char jmp_opcode = 0xe9;
@@ -47,7 +47,12 @@ inline static void set_call_target(cell return_address, void *target)
 
 inline static bool tail_call_site_p(cell return_address)
 {
-       return call_site_opcode(return_address) == jmp_opcode;
+       switch(call_site_opcode(return_address))
+       {
+       case jmp_opcode: return true;
+       case call_opcode: return false;
+       default: abort(); return false;
+       }
 }
 
 inline static unsigned int fpu_status(unsigned int status)
@@ -68,14 +73,4 @@ inline static unsigned int fpu_status(unsigned int status)
         return r;
 }
 
-/* Defined in assembly */
-VM_ASM_API void c_to_factor(cell quot, void *vm);
-VM_ASM_API void throw_impl(cell quot, stack_frame *rewind_to, void *vm);
-VM_ASM_API void lazy_jit_compile(cell quot, void *vm);
-
-VM_C_API void set_callstack(stack_frame *to,
-                             stack_frame *from,
-                             cell length,
-                             void *(*memcpy)(void*,const void*, size_t));
-
 }
index bb705e276c59cc0ea15b14d883132f71010e2ef5..f5946d648b726953f11eb5124103a1eaf238ede8 100755 (executable)
@@ -98,11 +98,22 @@ void data_heap::reset_generation(tenured_space *gen)
        clear_decks(gen);
 }
 
+bool data_heap::high_fragmentation_p()
+{
+       return (tenured->largest_free_block() <= nursery->size + aging->size);
+}
+
 bool data_heap::low_memory_p()
 {
        return (tenured->free_space() <= nursery->size + aging->size);
 }
 
+void data_heap::mark_all_cards()
+{
+       memset(cards,-1,cards_end - cards);
+       memset(decks,-1,decks_end - decks);
+}
+
 void factor_vm::set_data_heap(data_heap *data_)
 {
        data = data_;
@@ -115,21 +126,12 @@ void factor_vm::init_data_heap(cell young_size, cell aging_size, cell tenured_si
        set_data_heap(new data_heap(young_size,aging_size,tenured_size));
 }
 
-/* Size of the object pointed to by a tagged pointer */
-cell factor_vm::object_size(cell tagged)
-{
-       if(immediate_p(tagged))
-               return 0;
-       else
-               return untag<object>(tagged)->size();
-}
-
 /* Size of the object pointed to by an untagged pointer */
 cell object::size() const
 {
        if(free_p()) return ((free_heap_block *)this)->size();
 
-       switch(h.hi_tag())
+       switch(type())
        {
        case ARRAY_TYPE:
                return align(array_size((array*)this),data_alignment);
@@ -169,7 +171,9 @@ the GC. Some types have a binary payload at the end (string, word, DLL) which
 we ignore. */
 cell object::binary_payload_start() const
 {
-       switch(h.hi_tag())
+       if(free_p()) return 0;
+
+       switch(type())
        {
        /* these objects do not refer to other objects at all */
        case FLOAT_TYPE:
@@ -201,11 +205,6 @@ cell object::binary_payload_start() const
        }
 }
 
-void factor_vm::primitive_size()
-{
-       box_unsigned_cell(object_size(dpop()));
-}
-
 data_heap_room factor_vm::data_room()
 {
        data_heap_room room;
@@ -223,7 +222,7 @@ data_heap_room factor_vm::data_room()
        room.tenured_free_block_count = data->tenured->free_block_count();
        room.cards                    = data->cards_end - data->cards;
        room.decks                    = data->decks_end - data->decks;
-       room.mark_stack               = data->tenured->mark_stack.capacity();
+       room.mark_stack               = mark_stack.capacity() * sizeof(cell);
 
        return room;
 }
@@ -231,85 +230,42 @@ data_heap_room factor_vm::data_room()
 void factor_vm::primitive_data_room()
 {
        data_heap_room room = data_room();
-       dpush(tag<byte_array>(byte_array_from_value(&room)));
-}
-
-/* Disables GC and activates next-object ( -- obj ) primitive */
-void factor_vm::begin_scan()
-{
-       heap_scan_ptr = data->tenured->first_object();
-       gc_off = true;
-}
-
-void factor_vm::end_scan()
-{
-       gc_off = false;
+       ctx->push(tag<byte_array>(byte_array_from_value(&room)));
 }
 
-void factor_vm::primitive_begin_scan()
-{
-       begin_scan();
-}
+struct object_accumulator {
+       cell type;
+       std::vector<cell> objects;
 
-cell factor_vm::next_object()
-{
-       if(!gc_off)
-               general_error(ERROR_HEAP_SCAN,false_object,false_object,NULL);
+       explicit object_accumulator(cell type_) : type(type_) {}
 
-       if(heap_scan_ptr)
+       void operator()(object *obj)
        {
-               cell current = heap_scan_ptr;
-               heap_scan_ptr = data->tenured->next_object_after(heap_scan_ptr);
-               return tag_dynamic((object *)current);
+               if(type == TYPE_COUNT || obj->type() == type)
+                       objects.push_back(tag_dynamic(obj));
        }
-       else
-               return false_object;
-}
-
-/* Push object at heap scan cursor and advance; pushes f when done */
-void factor_vm::primitive_next_object()
-{
-       dpush(next_object());
-}
+};
 
-/* Re-enables GC */
-void factor_vm::primitive_end_scan()
+cell factor_vm::instances(cell type)
 {
-       gc_off = false;
-}
-
-struct word_counter {
-       cell count;
-
-       explicit word_counter() : count(0) {}
+       object_accumulator accum(type);
+       each_object(accum);
+       cell object_count = accum.objects.size();
 
-       void operator()(cell obj)
-       {
-               if(tagged<object>(obj).type_p(WORD_TYPE))
-                       count++;
-       }
-};
+       data_roots.push_back(data_root_range(&accum.objects[0],object_count));
 
-struct word_accumulator {
-       growable_array words;
+       array *objects = allot_array(object_count,false_object);
+       memcpy(objects->data(),&accum.objects[0],object_count * sizeof(cell));
 
-       explicit word_accumulator(int count,factor_vm *vm) : words(vm,count) {}
+       data_roots.pop_back();
 
-       void operator()(cell obj)
-       {
-               if(tagged<object>(obj).type_p(WORD_TYPE))
-                       words.add(obj);
-       }
-};
+       return tag<array>(objects);
+}
 
-cell factor_vm::find_all_words()
+void factor_vm::primitive_all_instances()
 {
-       word_counter counter;
-       each_object(counter);
-       word_accumulator accum(counter.count,this);
-       each_object(accum);
-       accum.words.trim();
-       return accum.words.elements.value();
+       primitive_full_gc();
+       ctx->push(instances(TYPE_COUNT));
 }
 
 }
index 760a10942e34737dcf191766a3b4c49a2034dbe3..cef43ef5fe9a03d5863e78ce6240759f2e4460aa 100755 (executable)
@@ -29,7 +29,9 @@ struct data_heap {
        void reset_generation(nursery_space *gen);
        void reset_generation(aging_space *gen);
        void reset_generation(tenured_space *gen);
+       bool high_fragmentation_p();
        bool low_memory_p();
+       void mark_all_cards();
 };
 
 struct data_heap_room {
diff --git a/vm/data_heap_checker.cpp b/vm/data_heap_checker.cpp
new file mode 100644 (file)
index 0000000..0d79abc
--- /dev/null
@@ -0,0 +1,101 @@
+#include "master.hpp"
+
+/* A tool to debug write barriers. Call check_data_heap() to ensure that all
+cards that should be marked are actually marked. */
+
+namespace factor
+{
+
+enum generation {
+       nursery_generation,
+       aging_generation,
+       tenured_generation
+};
+
+inline generation generation_of(factor_vm *parent, object *obj)
+{
+       if(parent->data->nursery->contains_p(obj))
+               return nursery_generation;
+       else if(parent->data->aging->contains_p(obj))
+               return aging_generation;
+       else if(parent->data->tenured->contains_p(obj))
+               return tenured_generation;
+       else
+       {
+               critical_error("Bad object",(cell)obj);
+               return (generation)-1;
+       }
+}
+
+struct slot_checker {
+       factor_vm *parent;
+       object *obj;
+       generation gen;
+
+       explicit slot_checker(factor_vm *parent_, object *obj_, generation gen_) :
+               parent(parent_), obj(obj_), gen(gen_) {}
+
+       void check_write_barrier(cell *slot_ptr, generation target, char mask)
+       {
+               cell object_card_pointer = parent->cards_offset + ((cell)obj >> card_bits);
+               cell slot_card_pointer = parent->cards_offset + ((cell)slot_ptr >> card_bits);
+               char slot_card_value = *(char *)slot_card_pointer;
+               if((slot_card_value & mask) != mask)
+               {
+                       std::cout << "card not marked" << std::endl;
+                       std::cout << "source generation: " << gen << std::endl;
+                       std::cout << "target generation: " << target << std::endl;
+                       std::cout << "object: 0x" << std::hex << (cell)obj << std::dec << std::endl;
+                       std::cout << "object type: " << obj->type() << std::endl;
+                       std::cout << "slot pointer: 0x" << std::hex << (cell)slot_ptr << std::dec << std::endl;
+                       std::cout << "slot value: 0x" << std::hex << *slot_ptr << std::dec << std::endl;
+                       std::cout << "card of object: 0x" << std::hex << object_card_pointer << std::dec << std::endl;
+                       std::cout << "card of slot: 0x" << std::hex << slot_card_pointer << std::dec << std::endl;
+                       std::cout << std::endl;
+                       parent->factorbug();
+               }
+       }
+
+       void operator()(cell *slot_ptr)
+       {
+               if(!immediate_p(*slot_ptr))
+               {
+                       generation target = generation_of(parent,untag<object>(*slot_ptr));
+                       switch(gen)
+                       {
+                       case nursery_generation:
+                               break;
+                       case aging_generation:
+                               if(target == nursery_generation)
+                                       check_write_barrier(slot_ptr,target,card_points_to_nursery);
+                               break;
+                       case tenured_generation:
+                               if(target == nursery_generation)
+                                       check_write_barrier(slot_ptr,target,card_points_to_nursery);
+                               else if(target == aging_generation)
+                                       check_write_barrier(slot_ptr,target,card_points_to_aging);
+                               break;
+                       }
+               }
+       }
+};
+
+struct object_checker {
+       factor_vm *parent;
+
+       explicit object_checker(factor_vm *parent_) : parent(parent_) {}
+
+       void operator()(object *obj)
+       {
+               slot_checker checker(parent,obj,generation_of(parent,obj));
+               obj->each_slot(checker);
+       }
+};
+
+void factor_vm::check_data_heap()
+{
+       object_checker checker(this);
+       each_object(checker);
+}
+
+}
index 52654c49f0274dc14cbf717aeb07fa315a2f40de..8e366a7cfd7c514af73718feb9d2fa57a9ec10bd 100644 (file)
@@ -7,7 +7,7 @@ struct data_root : public tagged<Type> {
 
        void push()
        {
-               parent->data_roots.push_back((cell)this);
+               parent->data_roots.push_back(data_root_range(&this->value_,1));
        }
 
        explicit data_root(cell value_, factor_vm *parent_)
@@ -27,9 +27,6 @@ struct data_root : public tagged<Type> {
 
        ~data_root()
        {
-#ifdef FACTOR_DEBUG
-               assert(parent->data_roots.back() == (cell)this);
-#endif
                parent->data_roots.pop_back();
        }
 };
index fee3e6a2578fffd2c0bd059f1416557ba22efd84..419eb690ff9577ff8fc3ca120fbf42b10d6aeff2 100755 (executable)
@@ -10,7 +10,7 @@ std::ostream &operator<<(std::ostream &out, const string *str)
        return out;
 }
 
-void factor_vm::print_word(wordword, cell nesting)
+void factor_vm::print_word(word *word, cell nesting)
 {
        if(tagged<object>(word->vocabulary).type_p(STRING_TYPE))
                std::cout << untag<string>(word->vocabulary) << ":";
@@ -30,7 +30,7 @@ void factor_vm::print_factor_string(string *str)
        std::cout << '"' << str << '"';
 }
 
-void factor_vm::print_array(arrayarray, cell nesting)
+void factor_vm::print_array(array *array, cell nesting)
 {
        cell length = array_capacity(array);
        cell i;
@@ -145,13 +145,13 @@ void factor_vm::print_objects(cell *start, cell *end)
 void factor_vm::print_datastack()
 {
        std::cout << "==== DATA STACK:\n";
-       print_objects((cell *)ds_bot,(cell *)ds);
+       print_objects((cell *)ctx->datastack_region->start,(cell *)ctx->datastack);
 }
 
 void factor_vm::print_retainstack()
 {
        std::cout << "==== RETAIN STACK:\n";
-       print_objects((cell *)rs_bot,(cell *)rs);
+       print_objects((cell *)ctx->retainstack_region->start,(cell *)ctx->retainstack);
 }
 
 struct stack_frame_printer {
@@ -160,15 +160,18 @@ struct stack_frame_printer {
        explicit stack_frame_printer(factor_vm *parent_) : parent(parent_) {}
        void operator()(stack_frame *frame)
        {
+               std::cout << "frame: " << std::hex << (cell)frame << std::dec << std::endl;
+               std::cout << "executing: ";
                parent->print_obj(parent->frame_executing(frame));
                std::cout << std::endl;
+               std::cout << "scan: ";
                parent->print_obj(parent->frame_scan(frame));
                std::cout << std::endl;
                std::cout << "word/quot addr: ";
                std::cout << std::hex << (cell)parent->frame_executing(frame) << std::dec;
                std::cout << std::endl;
                std::cout << "word/quot xt: ";
-               std::cout << std::hex << (cell)frame->xt << std::dec;
+               std::cout << std::hex << (cell)frame->entry_point << std::dec;
                std::cout << std::endl;
                std::cout << "return address: ";
                std::cout << std::hex << (cell)FRAME_RETURN_ADDRESS(frame,parent) << std::dec;
@@ -241,12 +244,12 @@ struct object_dumper {
        explicit object_dumper(factor_vm *parent_, cell type_) :
                parent(parent_), type(type_) {}
 
-       void operator()(cell obj)
+       void operator()(object *obj)
        {
-               if(type == TYPE_COUNT || tagged<object>(obj).type_p(type))
+               if(type == TYPE_COUNT || obj->type() == type)
                {
-                       std::cout << padded_address(obj) << " ";
-                       parent->print_nested_obj(obj,2);
+                       std::cout << padded_address((cell)obj) << " ";
+                       parent->print_nested_obj(tag_dynamic(obj),2);
                        std::cout << std::endl;
                }
        }
@@ -260,18 +263,19 @@ void factor_vm::dump_objects(cell type)
 }
 
 struct data_reference_slot_visitor {
-       cell look_for, obj;
+       cell look_for;
+       object *obj;
        factor_vm *parent;
 
-       explicit data_reference_slot_visitor(cell look_for_, cell obj_, factor_vm *parent_) :
+       explicit data_reference_slot_visitor(cell look_for_, object *obj_, factor_vm *parent_) :
                look_for(look_for_), obj(obj_), parent(parent_) { }
 
        void operator()(cell *scan)
        {
                if(look_for == *scan)
                {
-                       std::cout << padded_address(obj) << " ";
-                       parent->print_nested_obj(obj,2);
+                       std::cout << padded_address((cell)obj) << " ";
+                       parent->print_nested_obj(tag_dynamic(obj),2);
                        std::cout << std::endl;
                }
        }
@@ -284,10 +288,10 @@ struct data_reference_object_visitor {
        explicit data_reference_object_visitor(cell look_for_, factor_vm *parent_) :
                look_for(look_for_), parent(parent_) {}
 
-       void operator()(cell obj)
+       void operator()(object *obj)
        {
                data_reference_slot_visitor visitor(look_for,obj,parent);
-               parent->do_slots(UNTAG(obj),visitor);
+               obj->each_slot(visitor);
        }
 };
 
@@ -299,32 +303,30 @@ void factor_vm::find_data_references(cell look_for)
 
 struct code_block_printer {
        factor_vm *parent;
-       cell reloc_size, literal_size;
+       cell reloc_size, parameter_size;
 
        explicit code_block_printer(factor_vm *parent_) :
-               parent(parent_), reloc_size(0), literal_size(0) {}
+               parent(parent_), reloc_size(0), parameter_size(0) {}
 
        void operator()(code_block *scan, cell size)
        {
                const char *status;
                if(scan->free_p())
                        status = "free";
-               else if(parent->code->marked_p(scan))
-               {
-                       reloc_size += parent->object_size(scan->relocation);
-                       literal_size += parent->object_size(scan->literals);
-                       status = "marked";
-               }
                else
                {
                        reloc_size += parent->object_size(scan->relocation);
-                       literal_size += parent->object_size(scan->literals);
-                       status = "allocated";
-               }
+                       parameter_size += parent->object_size(scan->parameters);
+
+                       if(parent->code->marked_p(scan))
+                               status = "marked";
+                       else
+                               status = "allocated";
 
-               std::cout << std::hex << (cell)scan << std::dec << " ";
-               std::cout << std::hex << size << std::dec << " ";
-               std::cout << status << std::endl;
+                       std::cout << std::hex << (cell)scan << std::dec << " ";
+                       std::cout << std::hex << size << std::dec << " ";
+                       std::cout << status << std::endl;
+               }
        }
 };
 
@@ -333,8 +335,8 @@ void factor_vm::dump_code_heap()
 {
        code_block_printer printer(this);
        code->allocator->iterate(printer);
-       std::cout << printer.reloc_size << " bytes of relocation data\n";
-       std::cout << printer.literal_size << " bytes of literal data\n";
+       std::cout << printer.reloc_size << " bytes used by relocation tables\n";
+       std::cout << printer.parameter_size << " bytes used by parameter tables\n";
 }
 
 void factor_vm::factorbug()
@@ -419,9 +421,9 @@ void factor_vm::factorbug()
                else if(strcmp(cmd,"t") == 0)
                        full_output = !full_output;
                else if(strcmp(cmd,"s") == 0)
-                       dump_memory(ds_bot,ds);
+                       dump_memory(ctx->datastack_region->start,ctx->datastack);
                else if(strcmp(cmd,"r") == 0)
-                       dump_memory(rs_bot,rs);
+                       dump_memory(ctx->retainstack_region->start,ctx->retainstack);
                else if(strcmp(cmd,".s") == 0)
                        print_datastack();
                else if(strcmp(cmd,".r") == 0)
@@ -457,7 +459,7 @@ void factor_vm::factorbug()
                else if(strcmp(cmd,"push") == 0)
                {
                        cell addr = read_cell_hex();
-                       dpush(addr);
+                       ctx->push(addr);
                }
                else if(strcmp(cmd,"code") == 0)
                        dump_code_heap();
index 3eba483fe655574f03cdfa5563c78838feb6af53..b0f9159da79042bb769fd4c429b46050b92aa7cc 100755 (executable)
@@ -88,9 +88,9 @@ cell factor_vm::lookup_method(cell obj, cell methods)
 
 void factor_vm::primitive_lookup_method()
 {
-       cell methods = dpop();
-       cell obj = dpop();
-       dpush(lookup_method(obj,methods));
+       cell methods = ctx->pop();
+       cell obj = ctx->pop();
+       ctx->push(lookup_method(obj,methods));
 }
 
 cell factor_vm::object_class(cell obj)
@@ -120,17 +120,17 @@ void factor_vm::primitive_mega_cache_miss()
 {
        dispatch_stats.megamorphic_cache_misses++;
 
-       cell cache = dpop();
-       fixnum index = untag_fixnum(dpop());
-       cell methods = dpop();
+       cell cache = ctx->pop();
+       fixnum index = untag_fixnum(ctx->pop());
+       cell methods = ctx->pop();
 
-       cell object = ((cell *)ds)[-index];
+       cell object = ((cell *)ctx->datastack)[-index];
        cell klass = object_class(object);
        cell method = lookup_method(object,methods);
 
        update_method_cache(cache,klass,method);
 
-       dpush(method);
+       ctx->push(method);
 }
 
 void factor_vm::primitive_reset_dispatch_stats()
@@ -140,7 +140,7 @@ void factor_vm::primitive_reset_dispatch_stats()
 
 void factor_vm::primitive_dispatch_stats()
 {
-       dpush(tag<byte_array>(byte_array_from_value(&dispatch_stats)));
+       ctx->push(tag<byte_array>(byte_array_from_value(&dispatch_stats)));
 }
 
 void quotation_jit::emit_mega_cache_lookup(cell methods_, fixnum index, cell cache_)
@@ -152,7 +152,7 @@ void quotation_jit::emit_mega_cache_lookup(cell methods_, fixnum index, cell cac
        emit_class_lookup(index,PIC_TUPLE);
 
        /* Do a cache lookup. */
-       emit_with(parent->special_objects[MEGA_LOOKUP],cache.value());
+       emit_with_literal(parent->special_objects[MEGA_LOOKUP],cache.value());
        
        /* If we end up here, the cache missed. */
        emit(parent->special_objects[JIT_PROLOG]);
@@ -166,7 +166,7 @@ void quotation_jit::emit_mega_cache_lookup(cell methods_, fixnum index, cell cac
        /* Now the new method has been stored into the cache, and its on
           the stack. */
        emit(parent->special_objects[JIT_EPILOG]);
-       emit(parent->special_objects[JIT_EXECUTE_JUMP]);
+       emit(parent->special_objects[JIT_EXECUTE]);
 }
 
 }
diff --git a/vm/entry_points.cpp b/vm/entry_points.cpp
new file mode 100644 (file)
index 0000000..e07e343
--- /dev/null
@@ -0,0 +1,29 @@
+#include "master.hpp"
+
+namespace factor
+{
+
+void factor_vm::c_to_factor(cell quot)
+{
+       /* First time this is called, wrap the c-to-factor sub-primitive inside
+       of a callback stub, which saves and restores non-volatile registers
+       as per platform ABI conventions, so that the Factor compiler can treat
+       all registers as volatile */
+       if(!c_to_factor_func)
+       {
+               tagged<word> c_to_factor_word(special_objects[C_TO_FACTOR_WORD]);
+               code_block *c_to_factor_block = callbacks->add(c_to_factor_word.value(),0);
+               c_to_factor_func = (c_to_factor_func_type)c_to_factor_block->entry_point();
+       }
+
+       c_to_factor_func(quot);
+}
+
+void factor_vm::unwind_native_frames(cell quot, stack_frame *to)
+{
+       tagged<word> unwind_native_frames_word(special_objects[UNWIND_NATIVE_FRAMES_WORD]);
+       unwind_native_frames_func_type unwind_native_frames_func = (unwind_native_frames_func_type)unwind_native_frames_word->entry_point;
+       unwind_native_frames_func(quot,to);
+}
+
+}
diff --git a/vm/entry_points.hpp b/vm/entry_points.hpp
new file mode 100644 (file)
index 0000000..873501f
--- /dev/null
@@ -0,0 +1,7 @@
+namespace factor
+{
+
+typedef void (* c_to_factor_func_type)(cell quot);
+typedef void (* unwind_native_frames_func_type)(cell quot, stack_frame *to);
+
+}
index 7d7b1f00801a7a3a8a434605ab05ac1854a11e92..2dcb773dd1c06b81ec9528708c9e2afb47191791 100755 (executable)
@@ -31,7 +31,7 @@ void factor_vm::throw_error(cell error, stack_frame *callstack_top)
 {
        /* If the error handler is set, we rewind any C stack frames and
        pass the error to user-space. */
-       if(!current_gc && to_boolean(special_objects[OBJ_BREAK]))
+       if(!current_gc && to_boolean(special_objects[ERROR_HANDLER_QUOT]))
        {
                /* If error was thrown during heap scan, we re-enable the GC */
                gc_off = false;
@@ -43,9 +43,9 @@ void factor_vm::throw_error(cell error, stack_frame *callstack_top)
 
                /* If we had an underflow or overflow, stack pointers might be
                out of bounds */
-               fix_stacks();
+               ctx->fix_stacks();
 
-               dpush(error);
+               ctx->push(error);
 
                /* Errors thrown from C code pass NULL for this parameter.
                Errors thrown from Factor code, or signal handlers, pass the
@@ -56,7 +56,7 @@ void factor_vm::throw_error(cell error, stack_frame *callstack_top)
                else
                        callstack_top = ctx->callstack_top;
 
-               throw_impl(special_objects[OBJ_BREAK],callstack_top,this);
+               unwind_native_frames(special_objects[ERROR_HANDLER_QUOT],callstack_top);
        }
        /* Error was thrown in early startup before error handler is set, just
        crash. */
@@ -99,13 +99,13 @@ bool factor_vm::in_page(cell fault, cell area, cell area_size, int offset)
 
 void factor_vm::memory_protection_error(cell addr, stack_frame *native_stack)
 {
-       if(in_page(addr, ds_bot, 0, -1))
+       if(in_page(addr, ctx->datastack_region->start, 0, -1))
                general_error(ERROR_DS_UNDERFLOW,false_object,false_object,native_stack);
-       else if(in_page(addr, ds_bot, ds_size, 0))
+       else if(in_page(addr, ctx->datastack_region->start, ds_size, 0))
                general_error(ERROR_DS_OVERFLOW,false_object,false_object,native_stack);
-       else if(in_page(addr, rs_bot, 0, -1))
+       else if(in_page(addr, ctx->retainstack_region->start, 0, -1))
                general_error(ERROR_RS_UNDERFLOW,false_object,false_object,native_stack);
-       else if(in_page(addr, rs_bot, rs_size, 0))
+       else if(in_page(addr, ctx->retainstack_region->start, rs_size, 0))
                general_error(ERROR_RS_OVERFLOW,false_object,false_object,native_stack);
        else if(in_page(addr, nursery.end, 0, 0))
                critical_error("allot_object() missed GC check",0);
@@ -130,7 +130,7 @@ void factor_vm::fp_trap_error(unsigned int fpu_status, stack_frame *signal_calls
 
 void factor_vm::primitive_call_clear()
 {
-       throw_impl(dpop(),ctx->callstack_bottom,this);
+       unwind_native_frames(ctx->pop(),ctx->callstack_bottom);
 }
 
 /* For testing purposes */
index c1ea2e19071231722304bb3c28c8a1366d6208ef..4b237e03a023c707fec6fc49cbe1e2ca3da37f68 100755 (executable)
@@ -13,7 +13,6 @@ enum vm_error_type
        ERROR_ARRAY_SIZE,
        ERROR_C_STRING,
        ERROR_FFI,
-       ERROR_HEAP_SCAN,
        ERROR_UNDEFINED_SYMBOL,
        ERROR_DS_UNDERFLOW,
        ERROR_DS_OVERFLOW,
index d382745da84dc1f29cc28b7460f4fe6db040373a..d5a1d2f30eae229ea618c3d31f179e36aae5f66f 100755 (executable)
@@ -3,7 +3,6 @@
 namespace factor
 {
 
-factor_vm *vm;
 std::map<THREADHANDLE, factor_vm*> thread_vms;
 
 void init_globals()
@@ -31,11 +30,7 @@ void factor_vm::default_parameters(vm_parameters *p)
 #ifdef WINDOWS
        p->console = false;
 #else
-       if (this == vm)
-               p->console = true;
-       else            
-               p->console = false;
-       
+       p->console = true;
 #endif
 
        p->callback_size = 256;
@@ -79,13 +74,15 @@ void factor_vm::init_parameters_from_args(vm_parameters *p, int argc, vm_char **
        }
 }
 
-/* Do some initialization that we do once only */
-void factor_vm::do_stage1_init()
+/* Compile code in boot image so that we can execute the startup quotation */
+void factor_vm::prepare_boot_image()
 {
        std::cout << "*** Stage 2 early init... ";
        fflush(stdout);
 
        compile_all_words();
+       update_code_heap_words();
+       initialize_all_quotations();
        special_objects[OBJ_STAGE2] = true_object;
 
        std::cout << "done\n";
@@ -118,7 +115,7 @@ void factor_vm::init_factor(vm_parameters *p)
        if(p->image_path == NULL)
                p->image_path = default_image_path();
 
-       srand(current_micros());
+       srand((unsigned int)system_micros());
        init_ffi();
        init_stacks(p->ds_size,p->rs_size);
        init_callbacks(p->callback_size);
@@ -144,18 +141,16 @@ void factor_vm::init_factor(vm_parameters *p)
        gc_off = false;
 
        if(!to_boolean(special_objects[OBJ_STAGE2]))
-               do_stage1_init();
+               prepare_boot_image();
 }
 
 /* May allocate memory */
 void factor_vm::pass_args_to_factor(int argc, vm_char **argv)
 {
        growable_array args(this);
-       int i;
 
-       for(i = 1; i < argc; i++){
+       for(fixnum i = 1; i < argc; i++)
                args.add(allot_alien(false_object,(cell)argv[i]));
-       }
 
        args.trim();
        special_objects[OBJ_ARGS] = args.elements.value();
@@ -165,8 +160,15 @@ void factor_vm::start_factor(vm_parameters *p)
 {
        if(p->fep) factorbug();
 
-       nest_stacks(NULL);
-       c_to_factor_toplevel(special_objects[OBJ_BOOT]);
+       nest_stacks();
+       c_to_factor_toplevel(special_objects[OBJ_STARTUP_QUOT]);
+       unnest_stacks();
+}
+
+void factor_vm::stop_factor()
+{
+       nest_stacks();
+       c_to_factor_toplevel(special_objects[OBJ_SHUTDOWN_QUOT]);
        unnest_stacks();
 }
 
@@ -218,7 +220,7 @@ factor_vm *new_factor_vm()
 }
 
 // arg must be new'ed because we're going to delete it!
-voidstart_standalone_factor_thread(void *arg) 
+void *start_standalone_factor_thread(void *arg) 
 {
        factor_vm *newvm = new_factor_vm();
        startargs *args = (startargs*) arg;
@@ -231,7 +233,6 @@ void* start_standalone_factor_thread(void *arg)
 VM_C_API void start_standalone_factor(int argc, vm_char **argv)
 {
        factor_vm *newvm = new_factor_vm();
-       vm = newvm;
        return newvm->start_standalone_factor(argc,argv);
 }
 
old mode 100644 (file)
new mode 100755 (executable)
index 5f41c95..cec59bc
@@ -2,7 +2,7 @@ namespace factor
 {
 
 VM_C_API void init_globals();
-
 VM_C_API void start_standalone_factor(int argc, vm_char **argv);
 VM_C_API THREADHANDLE start_standalone_factor_in_new_thread(int argc, vm_char **argv);
+
 }
index cde6a2d781d5a4c7fddecb95393fe24f12be6fa0..9b4b06683d8b76c3c1a85db85f9f12229a3274d3 100644 (file)
@@ -30,8 +30,8 @@ void free_list::add_to_free_list(free_heap_block *block)
        free_block_count++;
        free_space += size;
 
-       if(size < free_list_count * block_granularity)
-               small_blocks[size / block_granularity].push_back(block);
+       if(size < free_list_count * data_alignment)
+               small_blocks[size / data_alignment].push_back(block);
        else
                large_blocks.insert(block);
 }
@@ -39,39 +39,59 @@ void free_list::add_to_free_list(free_heap_block *block)
 free_heap_block *free_list::find_free_block(cell size)
 {
        /* Check small free lists */
-       for(cell i = size / block_granularity; i < free_list_count; i++)
+       if(size / data_alignment < free_list_count)
        {
-               std::vector<free_heap_block *> &blocks = small_blocks[i];
-               if(blocks.size())
+               std::vector<free_heap_block *> &blocks = small_blocks[size / data_alignment];
+               if(blocks.size() == 0)
                {
-                       free_heap_block *block = blocks.back();
-                       blocks.pop_back();
-
-                       free_block_count--;
-                       free_space -= block->size();
-
-                       return block;
+                       /* Round up to a multiple of 'size' */
+                       cell large_block_size = ((allocation_page_size + size - 1) / size) * size;
+
+                       /* Allocate a block this big */
+                       free_heap_block *large_block = find_free_block(large_block_size);
+                       if(!large_block) return NULL;
+
+                       large_block = split_free_block(large_block,large_block_size);
+
+                       /* Split it up into pieces and add each piece back to the free list */
+                       for(cell offset = 0; offset < large_block_size; offset += size)
+                       {
+                               free_heap_block *small_block = large_block;
+                               large_block = (free_heap_block *)((cell)large_block + size);
+                               small_block->make_free(size);
+                               add_to_free_list(small_block);
+                       }
                }
-       }
-
-       /* Check large free lists */
-       free_heap_block key;
-       key.make_free(size);
-       large_block_set::iterator iter = large_blocks.lower_bound(&key);
-       large_block_set::iterator end = large_blocks.end();
 
-       if(iter != end)
-       {
-               free_heap_block *block = *iter;
-               large_blocks.erase(iter);
+               free_heap_block *block = blocks.back();
+               blocks.pop_back();
 
                free_block_count--;
                free_space -= block->size();
 
                return block;
        }
+       else
+       {
+               /* Check large free list */
+               free_heap_block key;
+               key.make_free(size);
+               large_block_set::iterator iter = large_blocks.lower_bound(&key);
+               large_block_set::iterator end = large_blocks.end();
 
-       return NULL;
+               if(iter != end)
+               {
+                       free_heap_block *block = *iter;
+                       large_blocks.erase(iter);
+
+                       free_block_count--;
+                       free_space -= block->size();
+
+                       return block;
+               }
+
+               return NULL;
+       }
 }
 
 free_heap_block *free_list::split_free_block(free_heap_block *block, cell size)
@@ -90,22 +110,7 @@ free_heap_block *free_list::split_free_block(free_heap_block *block, cell size)
 
 bool free_list::can_allot_p(cell size)
 {
-       /* Check small free lists */
-       for(cell i = size / block_granularity; i < free_list_count; i++)
-       {
-               if(small_blocks[i].size()) return true;
-       }
-
-       /* Check large free lists */
-       large_block_set::const_iterator iter = large_blocks.begin();
-       large_block_set::const_iterator end = large_blocks.end();
-
-       for(; iter != end; iter++)
-       {
-               if((*iter)->size() >= size) return true;
-       }
-
-       return false;
+       return largest_free_block() >= std::max(size,allocation_page_size);
 }
 
 cell free_list::largest_free_block()
old mode 100644 (file)
new mode 100755 (executable)
index 305de0a..3fb06ba
@@ -2,6 +2,7 @@ namespace factor
 {
 
 static const cell free_list_count = 32;
+static const cell allocation_page_size = 1024;
 
 struct free_heap_block
 {
@@ -9,22 +10,29 @@ struct free_heap_block
 
        bool free_p() const
        {
-               return header & 1 == 1;
+               return (header & 1) == 1;
        }
 
        cell size() const
        {
-               return header >> 3;
+               cell size = header & ~7;
+#ifdef FACTOR_DEBUG
+               assert(size > 0);
+#endif
+               return size;
        }
 
        void make_free(cell size)
        {
-               header = (size << 3) | 1;
+#ifdef FACTOR_DEBUG
+               assert(size > 0);
+#endif
+               header = size | 1;
        }
 };
 
 struct block_size_compare {
-       bool operator()(free_heap_block *a, free_heap_block *b)
+       bool operator()(free_heap_block *a, free_heap_block *b) const
        {
                return a->size() < b->size();
        }
index a4801daa72dce43786074746b844ea8c8f4182d2..4c725bcf4f401961ff7b4e5605dbd1d0eedcc73f 100644 (file)
@@ -23,7 +23,6 @@ template<typename Block> struct free_list_allocator {
        cell largest_free_block();
        cell free_block_count();
        void sweep();
-       template<typename Iterator> void sweep(Iterator &iter);
        template<typename Iterator, typename Sizer> void compact(Iterator &iter, Sizer &sizer);
        template<typename Iterator, typename Sizer> void iterate(Iterator &iter, Sizer &sizer);
        template<typename Iterator> void iterate(Iterator &iter);
@@ -85,7 +84,7 @@ template<typename Block> bool free_list_allocator<Block>::can_allot_p(cell size)
 
 template<typename Block> Block *free_list_allocator<Block>::allot(cell size)
 {
-       size = align(size,block_granularity);
+       size = align(size,data_alignment);
 
        free_heap_block *block = free_blocks.find_free_block(size);
        if(block)
@@ -152,59 +151,6 @@ void free_list_allocator<Block>::sweep()
        }
 }
 
-template<typename Block>
-template<typename Iterator>
-void free_list_allocator<Block>::sweep(Iterator &iter)
-{
-       free_blocks.clear_free_list();
-
-       Block *prev = NULL;
-       Block *scan = this->first_block();
-       Block *end = this->last_block();
-
-       while(scan != end)
-       {
-               cell size = scan->size();
-
-               if(scan->free_p())
-               {
-                       if(prev && prev->free_p())
-                       {
-                               free_heap_block *free_prev = (free_heap_block *)prev;
-                               free_prev->make_free(free_prev->size() + size);
-                       }
-                       else
-                               prev = scan;
-               }
-               else if(this->state.marked_p(scan))
-               {
-                       if(prev && prev->free_p())
-                               free_blocks.add_to_free_list((free_heap_block *)prev);
-                       prev = scan;
-                       iter(scan,size);
-               }
-               else
-               {
-                       if(prev && prev->free_p())
-                       {
-                               free_heap_block *free_prev = (free_heap_block *)prev;
-                               free_prev->make_free(free_prev->size() + size);
-                       }
-                       else
-                       {
-                               free_heap_block *free_block = (free_heap_block *)scan;
-                               free_block->make_free(size);
-                               prev = scan;
-                       }
-               }
-
-               scan = (Block *)((cell)scan + size);
-       }
-
-       if(prev && prev->free_p())
-               free_blocks.add_to_free_list((free_heap_block *)prev);
-}
-
 template<typename Block, typename Iterator> struct heap_compactor {
        mark_bits<Block> *state;
        char *address;
index 3b92e2574e865fb620aa7cc8bdca1d1524e3d9db..4de2814f1dfeb89646692226ff4d8d0fdf63208b 100644 (file)
@@ -3,11 +3,39 @@
 namespace factor
 {
 
+inline static code_block_visitor<code_workhorse> make_code_visitor(factor_vm *parent)
+{
+       return code_block_visitor<code_workhorse>(parent,code_workhorse(parent));
+}
+
 full_collector::full_collector(factor_vm *parent_) :
        collector<tenured_space,full_policy>(
                parent_,
                parent_->data->tenured,
-               full_policy(parent_)) {}
+               full_policy(parent_)),
+       code_visitor(make_code_visitor(parent_)) {}
+
+void full_collector::trace_code_block(code_block *compiled)
+{
+       data_visitor.visit_code_block_objects(compiled);
+       data_visitor.visit_embedded_literals(compiled);
+       code_visitor.visit_embedded_code_pointers(compiled);
+}
+
+void full_collector::trace_context_code_blocks()
+{
+       code_visitor.visit_context_code_blocks();
+}
+
+void full_collector::trace_uninitialized_code_blocks()
+{
+       code_visitor.visit_uninitialized_code_blocks();
+}
+
+void full_collector::trace_object_code_block(object *obj)
+{
+       code_visitor.visit_object_code_block(obj);
+}
 
 /* After a sweep, invalidate any code heap roots which are not marked,
 so that if a block makes a tail call to a generic word, and the PIC
@@ -23,85 +51,45 @@ void factor_vm::update_code_roots_for_sweep()
        for(; iter < end; iter++)
        {
                code_root *root = *iter;
-               code_block *block = (code_block *)(root->value & -block_granularity);
+               code_block *block = (code_block *)(root->value & -data_alignment);
                if(root->valid && !state->marked_p(block))
                        root->valid = false;
        }
 }
 
-/* After a compaction, invalidate any code heap roots which are not
-marked as above, and also slide the valid roots up so that call sites
-can be updated correctly. */
-void factor_vm::update_code_roots_for_compaction()
-{
-       std::vector<code_root *>::const_iterator iter = code_roots.begin();
-       std::vector<code_root *>::const_iterator end = code_roots.end();
-
-       mark_bits<code_block> *state = &code->allocator->state;
-
-       for(; iter < end; iter++)
-       {
-               code_root *root = *iter;
-               code_block *block = (code_block *)(root->value & -block_granularity);
-
-               /* Offset of return address within 16-byte allocation line */
-               cell offset = root->value - (cell)block;
-
-               if(root->valid && state->marked_p((code_block *)root->value))
-               {
-                       block = state->forward_block(block);
-                       root->value = (cell)block + offset;
-               }
-               else
-                       root->valid = false;
-       }
-}
-
-struct code_block_marker {
-       code_heap *code;
-       full_collector *collector;
-
-       explicit code_block_marker(code_heap *code_, full_collector *collector_) :
-               code(code_), collector(collector_) {}
-
-       code_block *operator()(code_block *compiled)
-       {
-               if(!code->marked_p(compiled))
-               {
-                       code->set_marked_p(compiled);
-                       collector->trace_literal_references(compiled);
-               }
-
-               return compiled;
-       }
-};
-
 void factor_vm::collect_mark_impl(bool trace_contexts_p)
 {
        full_collector collector(this);
 
+       mark_stack.clear();
+
        code->clear_mark_bits();
        data->tenured->clear_mark_bits();
-       data->tenured->clear_mark_stack();
-
-       code_block_visitor<code_block_marker> code_marker(this,code_block_marker(code,&collector));
 
        collector.trace_roots();
         if(trace_contexts_p)
        {
                collector.trace_contexts();
-               code_marker.visit_context_code_blocks();
-               code_marker.visit_callback_code_blocks();
+               collector.trace_context_code_blocks();
+               collector.trace_uninitialized_code_blocks();
        }
 
-       std::vector<object *> *mark_stack = &data->tenured->mark_stack;
-
-       while(!mark_stack->empty())
+       while(!mark_stack.empty())
        {
-               object *obj = mark_stack->back();
-               mark_stack->pop_back();
-               collector.trace_object(obj);
-               code_marker.visit_object_code_block(obj);
+               cell ptr = mark_stack.back();
+               mark_stack.pop_back();
+
+               if(ptr & 1)
+               {
+                       code_block *compiled = (code_block *)(ptr - 1);
+                       collector.trace_code_block(compiled);
+               }
+               else
+               {
+                       object *obj = (object *)ptr;
+                       collector.trace_object(obj);
+                       collector.trace_object_code_block(obj);
+               }
        }
 
        data->reset_generation(data->tenured);
@@ -114,34 +102,34 @@ void factor_vm::collect_sweep_impl()
 {
        current_gc->event->started_data_sweep();
        data->tenured->sweep();
-       update_code_roots_for_sweep();
        current_gc->event->ended_data_sweep();
+
+       update_code_roots_for_sweep();
+
+       current_gc->event->started_code_sweep();
+       code->allocator->sweep();
+       current_gc->event->ended_code_sweep();
 }
 
 void factor_vm::collect_full(bool trace_contexts_p)
 {
        collect_mark_impl(trace_contexts_p);
        collect_sweep_impl();
-       if(data->tenured->largest_free_block() <= data->nursery->size + data->aging->size)
-               collect_compact_impl(trace_contexts_p);
-       else
-               update_code_heap_words_and_literals();
-}
 
-void factor_vm::collect_compact(bool trace_contexts_p)
-{
-       collect_mark_impl(trace_contexts_p);
-       collect_compact_impl(trace_contexts_p);
-}
+       if(data->low_memory_p())
+       {
+               current_gc->op = collect_growing_heap_op;
+               current_gc->event->op = collect_growing_heap_op;
+               collect_growing_heap(0,trace_contexts_p);
+       }
+       else if(data->high_fragmentation_p())
+       {
+               current_gc->op = collect_compact_op;
+               current_gc->event->op = collect_compact_op;
+               collect_compact_impl(trace_contexts_p);
+       }
 
-void factor_vm::collect_growing_heap(cell requested_bytes, bool trace_contexts_p)
-{
-       /* Grow the data heap and copy all live objects to the new heap. */
-       data_heap *old = data;
-       set_data_heap(data->grow(requested_bytes));
-       collect_mark_impl(trace_contexts_p);
-       collect_compact_code_impl(trace_contexts_p);
-       delete old;
+       code->flush_icache();
 }
 
 }
index eb125b7429e9a8c4f3abeca3af3477e6abb1c9aa..ba859e28c93c63a6cd63d9b379b4800ee52a30ce 100644 (file)
@@ -14,20 +14,43 @@ struct full_policy {
 
        void promoted_object(object *obj)
        {
-               tenured->mark_and_push(obj);
+               tenured->set_marked_p(obj);
+               parent->mark_stack.push_back((cell)obj);
        }
 
        void visited_object(object *obj)
        {
                if(!tenured->marked_p(obj))
-                       tenured->mark_and_push(obj);
+                       promoted_object(obj);
+       }
+};
+
+struct code_workhorse {
+       factor_vm *parent;
+       code_heap *code;
+
+       explicit code_workhorse(factor_vm *parent_) : parent(parent_), code(parent->code) {}
+
+       code_block *operator()(code_block *compiled)
+       {
+               if(!code->marked_p(compiled))
+               {
+                       code->set_marked_p(compiled);
+                       parent->mark_stack.push_back((cell)compiled + 1);
+               }
+
+               return compiled;
        }
 };
 
 struct full_collector : collector<tenured_space,full_policy> {
-       bool trace_contexts_p;
+       code_block_visitor<code_workhorse> code_visitor;
 
        explicit full_collector(factor_vm *parent_);
+       void trace_code_block(code_block *compiled);
+       void trace_context_code_blocks();
+       void trace_uninitialized_code_blocks();
+       void trace_object_code_block(object *obj);
 };
 
 }
index de8a2886f70574b7c12dbd9c4bc1f5d2139a92e8..a57f338c4473db4c59316cff42cbe588b6cebc8a 100755 (executable)
--- a/vm/gc.cpp
+++ b/vm/gc.cpp
@@ -8,7 +8,7 @@ gc_event::gc_event(gc_op op_, factor_vm *parent) :
        cards_scanned(0),
        decks_scanned(0),
        code_blocks_scanned(0),
-       start_time(current_micros()),
+       start_time(nano_count()),
        card_scan_time(0),
        code_scan_time(0),
        data_sweep_time(0),
@@ -17,70 +17,70 @@ gc_event::gc_event(gc_op op_, factor_vm *parent) :
 {
        data_heap_before = parent->data_room();
        code_heap_before = parent->code_room();
-       start_time = current_micros();
+       start_time = nano_count();
 }
 
 void gc_event::started_card_scan()
 {
-       temp_time = current_micros();
+       temp_time = nano_count();
 }
 
 void gc_event::ended_card_scan(cell cards_scanned_, cell decks_scanned_)
 {
        cards_scanned += cards_scanned_;
        decks_scanned += decks_scanned_;
-       card_scan_time = (current_micros() - temp_time);
+       card_scan_time = (cell)(nano_count() - temp_time);
 }
 
 void gc_event::started_code_scan()
 {
-       temp_time = current_micros();
+       temp_time = nano_count();
 }
 
 void gc_event::ended_code_scan(cell code_blocks_scanned_)
 {
        code_blocks_scanned += code_blocks_scanned_;
-       code_scan_time = (current_micros() - temp_time);
+       code_scan_time = (cell)(nano_count() - temp_time);
 }
 
 void gc_event::started_data_sweep()
 {
-       temp_time = current_micros();
+       temp_time = nano_count();
 }
 
 void gc_event::ended_data_sweep()
 {
-       data_sweep_time = (current_micros() - temp_time);
+       data_sweep_time = (cell)(nano_count() - temp_time);
 }
 
 void gc_event::started_code_sweep()
 {
-       temp_time = current_micros();
+       temp_time = nano_count();
 }
 
 void gc_event::ended_code_sweep()
 {
-       code_sweep_time = (current_micros() - temp_time);
+       code_sweep_time = (cell)(nano_count() - temp_time);
 }
 
 void gc_event::started_compaction()
 {
-       temp_time = current_micros();
+       temp_time = nano_count();
 }
 
 void gc_event::ended_compaction()
 {
-       compaction_time = (current_micros() - temp_time);
+       compaction_time = (cell)(nano_count() - temp_time);
 }
 
 void gc_event::ended_gc(factor_vm *parent)
 {
        data_heap_after = parent->data_room();
        code_heap_after = parent->code_room();
-       total_time = current_micros() - start_time;
+       total_time = (cell)(nano_count() - start_time);
 }
 
-gc_state::gc_state(gc_op op_, factor_vm *parent) : op(op_), start_time(current_micros())
+gc_state::gc_state(gc_op op_, factor_vm *parent) : op(op_), start_time(nano_count())
 {
        event = new gc_event(op,parent);
 }
@@ -126,22 +126,11 @@ void factor_vm::start_gc_again()
        current_gc->event = new gc_event(current_gc->op,this);
 }
 
-void factor_vm::update_code_heap_for_minor_gc(std::set<code_block *> *remembered_set)
-{
-       /* The youngest generation that any code block can now reference */
-       std::set<code_block *>::const_iterator iter = remembered_set->begin();
-       std::set<code_block *>::const_iterator end = remembered_set->end();
-
-       for(; iter != end; iter++) update_literal_references(*iter);
-}
-
 void factor_vm::gc(gc_op op, cell requested_bytes, bool trace_contexts_p)
 {
        assert(!gc_off);
        assert(!current_gc);
 
-       save_stacks();
-
        current_gc = new gc_state(op,this);
 
        /* Keep trying to GC higher and higher generations until we don't run out
@@ -161,7 +150,7 @@ void factor_vm::gc(gc_op op, cell requested_bytes, bool trace_contexts_p)
                break;
        case collect_aging_op:
                collect_aging();
-               if(data->low_memory_p())
+               if(data->high_fragmentation_p())
                {
                        current_gc->op = collect_full_op;
                        current_gc->event->op = collect_full_op;
@@ -170,7 +159,7 @@ void factor_vm::gc(gc_op op, cell requested_bytes, bool trace_contexts_p)
                break;
        case collect_to_tenured_op:
                collect_to_tenured();
-               if(data->low_memory_p())
+               if(data->high_fragmentation_p())
                {
                        current_gc->op = collect_full_op;
                        current_gc->event->op = collect_full_op;
@@ -187,7 +176,7 @@ void factor_vm::gc(gc_op op, cell requested_bytes, bool trace_contexts_p)
                collect_growing_heap(requested_bytes,trace_contexts_p);
                break;
        default:
-               critical_error("Bad GC op\n",current_gc->op);
+               critical_error("Bad GC op",current_gc->op);
                break;
        }
 
@@ -218,46 +207,11 @@ void factor_vm::primitive_compact_gc()
                true /* trace contexts? */);
 }
 
-/* classes.tuple uses this to reshape tuples; tools.deploy.shaker uses this
-   to coalesce equal but distinct quotations and wrappers. */
-void factor_vm::primitive_become()
-{
-       array *new_objects = untag_check<array>(dpop());
-       array *old_objects = untag_check<array>(dpop());
-
-       cell capacity = array_capacity(new_objects);
-       if(capacity != array_capacity(old_objects))
-               critical_error("bad parameters to become",0);
-
-       cell i;
-
-       for(i = 0; i < capacity; i++)
-       {
-               tagged<object> old_obj(array_nth(old_objects,i));
-               tagged<object> new_obj(array_nth(new_objects,i));
-
-               if(old_obj != new_obj)
-                       old_obj->h.forward_to(new_obj.untagged());
-       }
-
-       primitive_full_gc();
-
-       /* If a word's definition quotation was in old_objects and the
-          quotation in new_objects is not compiled, we might leak memory
-          by referencing the old quotation unless we recompile all
-          unoptimized words. */
-       compile_all_words();
-}
-
 void factor_vm::inline_gc(cell *data_roots_base, cell data_roots_size)
 {
-       for(cell i = 0; i < data_roots_size; i++)
-               data_roots.push_back((cell)&data_roots_base[i]);
-
+       data_roots.push_back(data_root_range(data_roots_base,data_roots_size));
        primitive_minor_gc();
-
-       for(cell i = 0; i < data_roots_size; i++)
-               data_roots.pop_back();
+       data_roots.pop_back();
 }
 
 VM_C_API void inline_gc(cell *data_roots_base, cell data_roots_size, factor_vm *parent)
@@ -269,7 +223,7 @@ VM_C_API void inline_gc(cell *data_roots_base, cell data_roots_size, factor_vm *
  * It is up to the caller to fill in the object's fields in a meaningful
  * fashion!
  */
-object *factor_vm::allot_large_object(header header, cell size)
+object *factor_vm::allot_large_object(cell type, cell size)
 {
        /* If tenured space does not have enough room, collect and compact */
        if(!data->tenured->can_allot_p(size))
@@ -290,11 +244,9 @@ object *factor_vm::allot_large_object(header header, cell size)
        /* Allows initialization code to store old->new pointers
        without hitting the write barrier in the common case of
        a nursery allocation */
-       char *start = (char *)obj;
-       for(cell offset = 0; offset < size; offset += card_size)
-               write_barrier((cell *)(start + offset));
+       write_barrier(obj,size);
 
-       obj->h = header;
+       obj->initialize(type);
        return obj;
 }
 
@@ -307,14 +259,28 @@ void factor_vm::primitive_disable_gc_events()
 {
        if(gc_events)
        {
-               byte_array *data = byte_array_from_values(&gc_events->front(),gc_events->size());
-               dpush(tag<byte_array>(data));
+               growable_array result(this);
+
+               std::vector<gc_event> *gc_events = this->gc_events;
+               this->gc_events = NULL;
+
+               std::vector<gc_event>::const_iterator iter = gc_events->begin();
+               std::vector<gc_event>::const_iterator end = gc_events->end();
+
+               for(; iter != end; iter++)
+               {
+                       gc_event event = *iter;
+                       byte_array *obj = byte_array_from_value(&event);
+                       result.add(tag<byte_array>(obj));
+               }
+
+               result.trim();
+               ctx->push(result.elements.value());
 
-               delete gc_events;
-               gc_events = NULL;
+               delete this->gc_events;
        }
        else
-               dpush(false_object);
+               ctx->push(false_object);
 }
 
 }
index a9250eddb20e17f3123d5a96fb5779fa1e099078..d80d57dafefefb0fd74c4028976da401251b4b8f 100755 (executable)
--- a/vm/gc.hpp
+++ b/vm/gc.hpp
@@ -26,7 +26,7 @@ struct gc_event {
        cell data_sweep_time;
        cell code_sweep_time;
        cell compaction_time;
-       cell temp_time;
+       u64 temp_time;
 
        explicit gc_event(gc_op op_, factor_vm *parent);
        void started_card_scan();
index f45785f9ef69d45e10ebb546bc8eeebbd81b0c4f..4c3620277cf22fb9277325d19b582620ace26ecb 100755 (executable)
@@ -4,7 +4,7 @@ namespace factor
 template<typename Array> cell array_capacity(const Array *array)
 {
 #ifdef FACTOR_DEBUG
-       assert(array->h.hi_tag() == Array::type_number);
+       assert(array->type() == Array::type_number);
 #endif
        return array->capacity >> TAG_BITS;
 }
index b3a9eae7a5ea41a13a67a791f082ceea8205b09b..68701c47363468047ca183c50bc55b762a7a496b 100755 (executable)
@@ -55,177 +55,177 @@ void factor_vm::load_code_heap(FILE *file, image_header *h, vm_parameters *p)
        code->allocator->initial_free_list(h->code_size);
 }
 
-void factor_vm::data_fixup(cell *handle, cell data_relocation_base)
-{
-       if(immediate_p(*handle))
-               return;
+struct data_fixupper {
+       cell offset;
 
-       *handle += (data->tenured->start - data_relocation_base);
-}
+       explicit data_fixupper(cell offset_) : offset(offset_) {}
 
-template<typename Type> void factor_vm::code_fixup(Type **handle, cell code_relocation_base)
-{
-       Type *ptr = *handle;
-       Type *new_ptr = (Type *)(((cell)ptr) + (code->seg->start - code_relocation_base));
-       *handle = new_ptr;
-}
+       object *operator()(object *obj)
+       {
+               return (object *)((char *)obj + offset);
+       }
+};
 
-void factor_vm::fixup_word(word *word, cell code_relocation_base)
-{
-       if(word->code)
-               code_fixup(&word->code,code_relocation_base);
-       if(word->profiling)
-               code_fixup(&word->profiling,code_relocation_base);
-       code_fixup(&word->xt,code_relocation_base);
-}
+struct code_fixupper {
+       cell offset;
 
-void factor_vm::fixup_quotation(quotation *quot, cell code_relocation_base)
-{
-       if(quot->code)
+       explicit code_fixupper(cell offset_) : offset(offset_) {}
+
+       code_block *operator()(code_block *compiled)
        {
-               code_fixup(&quot->xt,code_relocation_base);
-               code_fixup(&quot->code,code_relocation_base);
+               return (code_block *)((char *)compiled + offset);
        }
-       else
-               quot->xt = (void *)lazy_jit_compile;
-}
+};
 
-void factor_vm::fixup_alien(alien *ptr)
+static inline cell tuple_size_with_fixup(cell offset, object *obj)
 {
-       if(!to_boolean(ptr->base))
-               ptr->expired = true_object;
-       else
-               ptr->update_address();
+       tuple_layout *layout = (tuple_layout *)((char *)UNTAG(((tuple *)obj)->layout) + offset);
+       return tuple_size(layout);
 }
 
-struct stack_frame_fixupper {
-       factor_vm *parent;
-       cell code_relocation_base;
+struct fixup_sizer {
+       cell offset;
+
+       explicit fixup_sizer(cell offset_) : offset(offset_) {}
 
-       explicit stack_frame_fixupper(factor_vm *parent_, cell code_relocation_base_) :
-               parent(parent_), code_relocation_base(code_relocation_base_) {}
-       void operator()(stack_frame *frame)
+       cell operator()(object *obj)
        {
-               parent->code_fixup(&frame->xt,code_relocation_base);
-               parent->code_fixup(&FRAME_RETURN_ADDRESS(frame,parent),code_relocation_base);
+               if(obj->type() == TUPLE_TYPE)
+                       return align(tuple_size_with_fixup(offset,obj),data_alignment);
+               else
+                       return obj->size();
        }
 };
 
-void factor_vm::fixup_callstack_object(callstack *stack, cell code_relocation_base)
-{
-       stack_frame_fixupper fixupper(this,code_relocation_base);
-       iterate_callstack_object(stack,fixupper);
-}
-
 struct object_fixupper {
        factor_vm *parent;
-       cell data_relocation_base;
+       cell data_offset;
+       slot_visitor<data_fixupper> data_visitor;
+       code_block_visitor<code_fixupper> code_visitor;
 
-       explicit object_fixupper(factor_vm *parent_, cell data_relocation_base_) :
-               parent(parent_), data_relocation_base(data_relocation_base_) { }
+       object_fixupper(factor_vm *parent_, cell data_offset_, cell code_offset_) :
+               parent(parent_),
+               data_offset(data_offset_),
+               data_visitor(slot_visitor<data_fixupper>(parent_,data_fixupper(data_offset_))),
+               code_visitor(code_block_visitor<code_fixupper>(parent_,code_fixupper(code_offset_))) {}
 
-       void operator()(cell *scan)
+       void operator()(object *obj, cell size)
        {
-               parent->data_fixup(scan,data_relocation_base);
+               parent->data->tenured->starts.record_object_start_offset(obj);
+
+               switch(obj->type())
+               {
+               case ALIEN_TYPE:
+                       {
+                               cell payload_start = obj->binary_payload_start();
+                               data_visitor.visit_slots(obj,payload_start);
+
+                               alien *ptr = (alien *)obj;
+
+                               if(to_boolean(ptr->base))
+                                       ptr->update_address();
+                               else
+                                       ptr->expired = parent->true_object;
+                               break;
+                       }
+               case DLL_TYPE:
+                       {
+                               cell payload_start = obj->binary_payload_start();
+                               data_visitor.visit_slots(obj,payload_start);
+
+                               parent->ffi_dlopen((dll *)obj);
+                               break;
+                       }
+               case TUPLE_TYPE:
+                       {
+                               cell payload_start = tuple_size_with_fixup(data_offset,obj);
+                               data_visitor.visit_slots(obj,payload_start);
+                               break;
+                       }
+               default:
+                       {
+                               cell payload_start = obj->binary_payload_start();
+                               data_visitor.visit_slots(obj,payload_start);
+                               code_visitor.visit_object_code_block(obj);
+                               break;
+                       }
+               }
        }
 };
 
-/* Initialize an object in a newly-loaded image */
-void factor_vm::relocate_object(object *object,
-       cell data_relocation_base,
-       cell code_relocation_base)
+void factor_vm::fixup_data(cell data_offset, cell code_offset)
 {
-       cell hi_tag = object->h.hi_tag();
-       
-       /* Tuple relocation is a bit trickier; we have to fix up the
-       layout object before we can get the tuple size, so do_slots is
-       out of the question */
-       if(hi_tag == TUPLE_TYPE)
-       {
-               tuple *t = (tuple *)object;
-               data_fixup(&t->layout,data_relocation_base);
+       slot_visitor<data_fixupper> data_workhorse(this,data_fixupper(data_offset));
+       data_workhorse.visit_roots();
 
-               cell *scan = t->data();
-               cell *end = (cell *)((cell)object + object->size());
+       object_fixupper fixupper(this,data_offset,code_offset);
+       fixup_sizer sizer(data_offset);
+       data->tenured->iterate(fixupper,sizer);
+}
 
-               for(; scan < end; scan++)
-                       data_fixup(scan,data_relocation_base);
-       }
-       else
+struct code_block_fixup_relocation_visitor {
+       factor_vm *parent;
+       cell code_offset;
+       slot_visitor<data_fixupper> data_visitor;
+       code_fixupper code_visitor;
+
+       code_block_fixup_relocation_visitor(factor_vm *parent_, cell data_offset_, cell code_offset_) :
+               parent(parent_),
+               code_offset(code_offset_),
+               data_visitor(slot_visitor<data_fixupper>(parent_,data_fixupper(data_offset_))),
+               code_visitor(code_fixupper(code_offset_)) {}
+
+       void operator()(instruction_operand op)
        {
-               object_fixupper fixupper(this,data_relocation_base);
-               do_slots((cell)object,fixupper);
+               code_block *compiled = op.parent_code_block();
+               cell old_offset = op.rel_offset() + (cell)compiled->entry_point() - code_offset;
 
-               switch(hi_tag)
+               switch(op.rel_type())
                {
-               case WORD_TYPE:
-                       fixup_word((word *)object,code_relocation_base);
+               case RT_LITERAL:
+                       op.store_value(data_visitor.visit_pointer(op.load_value(old_offset)));
                        break;
-               case QUOTATION_TYPE:
-                       fixup_quotation((quotation *)object,code_relocation_base);
+               case RT_ENTRY_POINT:
+               case RT_ENTRY_POINT_PIC:
+               case RT_ENTRY_POINT_PIC_TAIL:
+                       op.store_code_block(code_visitor(op.load_code_block(old_offset)));
                        break;
-               case DLL_TYPE:
-                       ffi_dlopen((dll *)object);
+               case RT_HERE:
+                       op.store_value(op.load_value(old_offset) + code_offset);
                        break;
-               case ALIEN_TYPE:
-                       fixup_alien((alien *)object);
+               case RT_UNTAGGED:
                        break;
-               case CALLSTACK_TYPE:
-                       fixup_callstack_object((callstack *)object,code_relocation_base);
+               default:
+                       parent->store_external_address(op);
                        break;
                }
        }
-}
-
-/* Since the image might have been saved with a different base address than
-where it is loaded, we need to fix up pointers in the image. */
-void factor_vm::relocate_data(cell data_relocation_base, cell code_relocation_base)
-{
-       for(cell i = 0; i < special_object_count; i++)
-               data_fixup(&special_objects[i],data_relocation_base);
-
-       data_fixup(&true_object,data_relocation_base);
-       data_fixup(&bignum_zero,data_relocation_base);
-       data_fixup(&bignum_pos_one,data_relocation_base);
-       data_fixup(&bignum_neg_one,data_relocation_base);
-
-       cell obj = data->tenured->start;
-
-       while(obj)
-       {
-               relocate_object((object *)obj,data_relocation_base,code_relocation_base);
-               data->tenured->starts.record_object_start_offset((object *)obj);
-               obj = data->tenured->next_object_after(obj);
-       }
-}
-
-void factor_vm::fixup_code_block(code_block *compiled, cell data_relocation_base)
-{
-       /* relocate literal table data */
-       data_fixup(&compiled->owner,data_relocation_base);
-       data_fixup(&compiled->literals,data_relocation_base);
-       data_fixup(&compiled->relocation,data_relocation_base);
-
-       relocate_code_block(compiled);
-}
+};
 
 struct code_block_fixupper {
        factor_vm *parent;
-       cell data_relocation_base;
+       cell data_offset;
+       cell code_offset;
 
-       explicit code_block_fixupper(factor_vm *parent_, cell data_relocation_base_) :
-               parent(parent_), data_relocation_base(data_relocation_base_) { }
+       code_block_fixupper(factor_vm *parent_, cell data_offset_, cell code_offset_) :
+               parent(parent_),
+               data_offset(data_offset_),
+               code_offset(code_offset_) {}
 
        void operator()(code_block *compiled, cell size)
        {
-               parent->fixup_code_block(compiled,data_relocation_base);
+               slot_visitor<data_fixupper> data_visitor(parent,data_fixupper(data_offset));
+               data_visitor.visit_code_block_objects(compiled);
+
+               code_block_fixup_relocation_visitor code_visitor(parent,data_offset,code_offset);
+               compiled->each_instruction_operand(code_visitor);
        }
 };
 
-void factor_vm::relocate_code(cell data_relocation_base)
+void factor_vm::fixup_code(cell data_offset, cell code_offset)
 {
-       code_block_fixupper fixupper(this,data_relocation_base);
-       iterate_code_heap(fixupper);
+       code_block_fixupper fixupper(this,data_offset,code_offset);
+       code->allocator->iterate(fixupper);
 }
 
 /* Read an image file from disk, only done once during startup */
@@ -257,8 +257,11 @@ void factor_vm::load_image(vm_parameters *p)
 
        init_objects(&h);
 
-       relocate_data(h.data_relocation_base,h.code_relocation_base);
-       relocate_code(h.data_relocation_base);
+       cell data_offset = data->tenured->start - h.data_relocation_base;
+       cell code_offset = code->seg->start - h.code_relocation_base;
+
+       fixup_data(data_offset,code_offset);
+       fixup_code(data_offset,code_offset);
 
        /* Store image path name */
        special_objects[OBJ_IMAGE] = allot_alien(false_object,(cell)p->image_path);
@@ -291,7 +294,7 @@ bool factor_vm::save_image(const vm_char *filename)
        h.bignum_neg_one = bignum_neg_one;
 
        for(cell i = 0; i < special_object_count; i++)
-               h.special_objects[i] = (save_env_p(i) ? special_objects[i] : false_object);
+               h.special_objects[i] = (save_special_p(i) ? special_objects[i] : false_object);
 
        bool ok = true;
 
@@ -311,7 +314,7 @@ void factor_vm::primitive_save_image()
        /* do a full GC to push everything into tenured space */
        primitive_compact_gc();
 
-       data_root<byte_array> path(dpop(),this);
+       data_root<byte_array> path(ctx->pop(),this);
        path.untag_check(this);
        save_image((vm_char *)(path.untagged() + 1));
 }
@@ -321,12 +324,12 @@ void factor_vm::primitive_save_image_and_exit()
        /* We unbox this before doing anything else. This is the only point
        where we might throw an error, so we have to throw an error here since
        later steps destroy the current image. */
-       data_root<byte_array> path(dpop(),this);
+       data_root<byte_array> path(ctx->pop(),this);
        path.untag_check(this);
 
        /* strip out special_objects data which is set on startup anyway */
        for(cell i = 0; i < special_object_count; i++)
-               if(!save_env_p(i)) special_objects[i] = false_object;
+               if(!save_special_p(i)) special_objects[i] = false_object;
 
        gc(collect_compact_op,
                0, /* requested size */
index cca0e9e378a548d0e81cc735e276f9c14c68c7e4..101482b1dac740dbe905d8d04a986b25ae7e6579 100755 (executable)
@@ -7,12 +7,11 @@ static const cell image_version = 4;
 struct image_header {
        cell magic;
        cell version;
-       /* all pointers in the image file are relocated from
-          relocation_base to here when the image is loaded */
+       /* base address of data heap when image was saved */
        cell data_relocation_base;
        /* size of heap */
        cell data_size;
-       /* code relocation base */
+       /* base address of code heap when image was saved */
        cell code_relocation_base;
        /* size of code heap */
        cell code_size;
index 469bb8bf2e8aa2e007e836fc60a5a5dcc63b21db..c8a1b228790132942e9af38d322d5f1e6bff062d 100755 (executable)
@@ -11,14 +11,14 @@ void factor_vm::init_inline_caching(int max_size)
 void factor_vm::deallocate_inline_cache(cell return_address)
 {
        /* Find the call target. */
-       void *old_xt = get_call_target(return_address);
-       check_code_pointer((cell)old_xt);
+       void *old_entry_point = get_call_target(return_address);
+       check_code_pointer((cell)old_entry_point);
 
-       code_block *old_block = (code_block *)old_xt - 1;
+       code_block *old_block = (code_block *)old_entry_point - 1;
 
        /* Free the old PIC since we know its unreachable */
        if(old_block->pic_p())
-               code->code_heap_free(old_block);
+               code->free(old_block);
 }
 
 /* Figure out what kind of type check the PIC needs based on the methods
@@ -70,7 +70,7 @@ void inline_cache_jit::emit_check(cell klass)
        else
                code_template = parent->special_objects[PIC_CHECK_TUPLE];
 
-       emit_with(code_template,klass);
+       emit_with_literal(code_template,klass);
 }
 
 /* index: 0 = top of stack, 1 = item underneath, etc
@@ -101,19 +101,27 @@ void inline_cache_jit::compile_inline_cache(fixnum index,
 
                /* Yes? Jump to method */
                cell method = array_nth(cache_entries.untagged(),i + 1);
-               emit_with(parent->special_objects[PIC_HIT],method);
+               emit_with_literal(parent->special_objects[PIC_HIT],method);
        }
 
-       /* Generate machine code to handle a cache miss, which ultimately results in
-          this function being called again.
+       /* If none of the above conditionals tested true, then execution "falls
+          through" to here. */
 
-          The inline-cache-miss primitive call receives enough information to
-          reconstruct the PIC. */
+       /* A stack frame is set up, since the inline-cache-miss sub-primitive
+       makes a subroutine call to the VM. */
+       emit(parent->special_objects[JIT_PROLOG]);
+
+       /* The inline-cache-miss sub-primitive call receives enough information to
+          reconstruct the PIC with the new entry. */
        push(generic_word.value());
        push(methods.value());
        push(tag_fixnum(index));
        push(cache_entries.value());
-       word_special(parent->special_objects[tail_call_p ? PIC_MISS_TAIL_WORD : PIC_MISS_WORD]);
+
+       emit_subprimitive(
+               parent->special_objects[tail_call_p ? PIC_MISS_TAIL_WORD : PIC_MISS_WORD],
+               true, /* tail_call_p */
+               true); /* stack_frame_p */
 }
 
 code_block *factor_vm::compile_inline_cache(fixnum index,
@@ -133,14 +141,14 @@ code_block *factor_vm::compile_inline_cache(fixnum index,
                                 cache_entries.value(),
                                 tail_call_p);
        code_block *code = jit.to_code_block();
-       relocate_code_block(code);
+       initialize_code_block(code);
        return code;
 }
 
 /* A generic word's definition performs general method lookup. */
 void *factor_vm::megamorphic_call_stub(cell generic_word)
 {
-       return untag<word>(generic_word)->xt;
+       return untag<word>(generic_word)->entry_point;
 }
 
 cell factor_vm::inline_cache_size(cell cache_entries)
@@ -180,26 +188,28 @@ to take care of the details. */
 void *factor_vm::inline_cache_miss(cell return_address_)
 {
        code_root return_address(return_address_,this);
-
        check_code_pointer(return_address.value);
+       bool tail_call_site = tail_call_site_p(return_address.value);
 
-       /* Since each PIC is only referenced from a single call site,
-          if the old call target was a PIC, we can deallocate it immediately,
-          instead of leaving dead PICs around until the next GC. */
-       deallocate_inline_cache(return_address.value);
-
-       data_root<array> cache_entries(dpop(),this);
-       fixnum index = untag_fixnum(dpop());
-       data_root<array> methods(dpop(),this);
-       data_root<word> generic_word(dpop(),this);
-       data_root<object> object(((cell *)ds)[-index],this);
+#ifdef PIC_DEBUG
+       std::cout << "Inline cache miss at "
+               << (tail_call_site ? "tail" : "non-tail")
+               << " call site 0x" << std::hex << return_address.value << std::dec
+               << std::endl;
+#endif
 
-       void *xt;
+       data_root<array> cache_entries(ctx->pop(),this);
+       fixnum index = untag_fixnum(ctx->pop());
+       data_root<array> methods(ctx->pop(),this);
+       data_root<word> generic_word(ctx->pop(),this);
+       data_root<object> object(((cell *)ctx->datastack)[-index],this);
 
        cell pic_size = inline_cache_size(cache_entries.value());
 
        update_pic_transitions(pic_size);
 
+       void *xt;
+
        if(pic_size >= max_pic_size)
                xt = megamorphic_call_stub(generic_word.value());
        else
@@ -208,26 +218,31 @@ void *factor_vm::inline_cache_miss(cell return_address_)
                cell method = lookup_method(object.value(),methods.value());
 
                data_root<array> new_cache_entries(add_inline_cache_entry(
-                                                          cache_entries.value(),
-                                                          klass,
-                                                          method),this);
+                       cache_entries.value(),
+                       klass,
+                       method),this);
+
                xt = compile_inline_cache(index,
-                                         generic_word.value(),
-                                         methods.value(),
-                                         new_cache_entries.value(),
-                                         tail_call_site_p(return_address.value))->xt();
+                       generic_word.value(),
+                       methods.value(),
+                       new_cache_entries.value(),
+                       tail_call_site)->entry_point();
        }
 
        /* Install the new stub. */
        if(return_address.valid)
        {
+               /* Since each PIC is only referenced from a single call site,
+                  if the old call target was a PIC, we can deallocate it immediately,
+                  instead of leaving dead PICs around until the next GC. */
+               deallocate_inline_cache(return_address.value);
                set_call_target(return_address.value,xt);
 
 #ifdef PIC_DEBUG
                std::cout << "Updated "
-                       << (tail_call_site_p(return_address) ? "tail" : "non-tail")
-                       << " call site 0x" << std::hex << return_address << std::dec
-                       << " with " << std::hex << (cell)xt << std::dec;
+                       << (tail_call_site ? "tail" : "non-tail")
+                       << " call site 0x" << std::hex << return_address.value << std::dec
+                       << " with 0x" << std::hex << (cell)xt << std::dec << std::endl;
 #endif
        }
 
diff --git a/vm/instruction_operands.cpp b/vm/instruction_operands.cpp
new file mode 100644 (file)
index 0000000..db869d9
--- /dev/null
@@ -0,0 +1,138 @@
+#include "master.hpp"
+
+namespace factor
+{
+
+instruction_operand::instruction_operand(relocation_entry rel_, code_block *compiled_, cell index_) :
+       rel(rel_), compiled(compiled_), index(index_), pointer((cell)compiled_->entry_point() + rel_.rel_offset()) {}
+
+/* Load a 32-bit value from a PowerPC LIS/ORI sequence */
+fixnum instruction_operand::load_value_2_2()
+{
+       cell *ptr = (cell *)pointer;
+       cell hi = (ptr[-2] & 0xffff);
+       cell lo = (ptr[-1] & 0xffff);
+       return hi << 16 | lo;
+}
+
+/* Load a value from a bitfield of a PowerPC instruction */
+fixnum instruction_operand::load_value_masked(cell mask, cell bits, cell shift)
+{
+       s32 *ptr = (s32 *)(pointer - sizeof(u32));
+
+       return (((*ptr & (s32)mask) << bits) >> bits) << shift;
+}
+
+fixnum instruction_operand::load_value(cell relative_to)
+{
+       switch(rel.rel_class())
+       {
+       case RC_ABSOLUTE_CELL:
+               return *(cell *)(pointer - sizeof(cell));
+       case RC_ABSOLUTE:
+               return *(u32 *)(pointer - sizeof(u32));
+       case RC_RELATIVE:
+               return *(s32 *)(pointer - sizeof(u32)) + relative_to;
+       case RC_ABSOLUTE_PPC_2_2:
+               return load_value_2_2();
+       case RC_ABSOLUTE_PPC_2:
+               return load_value_masked(rel_absolute_ppc_2_mask,16,0);
+       case RC_RELATIVE_PPC_2:
+               return load_value_masked(rel_relative_ppc_2_mask,16,0) + relative_to - sizeof(cell);
+       case RC_RELATIVE_PPC_3:
+               return load_value_masked(rel_relative_ppc_3_mask,6,0) + relative_to - sizeof(cell);
+       case RC_RELATIVE_ARM_3:
+               return load_value_masked(rel_relative_arm_3_mask,6,2) + relative_to + sizeof(cell);
+       case RC_INDIRECT_ARM:
+               return load_value_masked(rel_indirect_arm_mask,20,0) + relative_to;
+       case RC_INDIRECT_ARM_PC:
+               return load_value_masked(rel_indirect_arm_mask,20,0) + relative_to + sizeof(cell);
+       case RC_ABSOLUTE_2:
+               return *(u16 *)(pointer - sizeof(u16));
+       default:
+               critical_error("Bad rel class",rel.rel_class());
+               return 0;
+       }
+}
+
+fixnum instruction_operand::load_value()
+{
+       return load_value(pointer);
+}
+
+code_block *instruction_operand::load_code_block(cell relative_to)
+{
+       return ((code_block *)load_value(relative_to) - 1);
+}
+
+code_block *instruction_operand::load_code_block()
+{
+       return load_code_block(pointer);
+}
+
+/* Store a 32-bit value into a PowerPC LIS/ORI sequence */
+void instruction_operand::store_value_2_2(fixnum value)
+{
+       cell *ptr = (cell *)pointer;
+       ptr[-2] = ((ptr[-2] & ~0xffff) | ((value >> 16) & 0xffff));
+       ptr[-1] = ((ptr[-1] & ~0xffff) | (value & 0xffff));
+}
+
+/* Store a value into a bitfield of a PowerPC instruction */
+void instruction_operand::store_value_masked(fixnum value, cell mask, cell shift)
+{
+       u32 *ptr = (u32 *)(pointer - sizeof(u32));
+       *ptr = ((*ptr & ~mask) | ((value >> shift) & mask));
+}
+
+void instruction_operand::store_value(fixnum absolute_value)
+{
+       fixnum relative_value = absolute_value - pointer;
+
+       switch(rel.rel_class())
+       {
+       case RC_ABSOLUTE_CELL:
+               *(cell *)(pointer - sizeof(cell)) = absolute_value;
+               break;
+       case RC_ABSOLUTE:
+               *(u32 *)(pointer - sizeof(u32)) = absolute_value;
+               break;
+       case RC_RELATIVE:
+               *(s32 *)(pointer - sizeof(s32)) = relative_value;
+               break;
+       case RC_ABSOLUTE_PPC_2_2:
+               store_value_2_2(absolute_value);
+               break;
+       case RC_ABSOLUTE_PPC_2:
+               store_value_masked(absolute_value,rel_absolute_ppc_2_mask,0);
+               break;
+       case RC_RELATIVE_PPC_2:
+               store_value_masked(relative_value + sizeof(cell),rel_relative_ppc_2_mask,0);
+               break;
+       case RC_RELATIVE_PPC_3:
+               store_value_masked(relative_value + sizeof(cell),rel_relative_ppc_3_mask,0);
+               break;
+       case RC_RELATIVE_ARM_3:
+               store_value_masked(relative_value - sizeof(cell),rel_relative_arm_3_mask,2);
+               break;
+       case RC_INDIRECT_ARM:
+               store_value_masked(relative_value,rel_indirect_arm_mask,0);
+               break;
+       case RC_INDIRECT_ARM_PC:
+               store_value_masked(relative_value - sizeof(cell),rel_indirect_arm_mask,0);
+               break;
+       case RC_ABSOLUTE_2:
+               *(u16 *)(pointer - sizeof(u16)) = (u16)absolute_value;
+               break;
+       default:
+               critical_error("Bad rel class",rel.rel_class());
+               break;
+       }
+}
+
+void instruction_operand::store_code_block(code_block *compiled)
+{
+       store_value((cell)compiled->entry_point());
+}
+
+}
diff --git a/vm/instruction_operands.hpp b/vm/instruction_operands.hpp
new file mode 100644 (file)
index 0000000..d46b5cf
--- /dev/null
@@ -0,0 +1,157 @@
+namespace factor
+{
+
+enum relocation_type {
+       /* arg is a literal table index, holding a pair (symbol/dll) */
+       RT_DLSYM,
+       /* a word or quotation's general entry point */
+       RT_ENTRY_POINT,
+       /* a word's PIC entry point */
+       RT_ENTRY_POINT_PIC,
+       /* a word's tail-call PIC entry point */
+       RT_ENTRY_POINT_PIC_TAIL,
+       /* current offset */
+       RT_HERE,
+       /* current code block */
+       RT_THIS,
+       /* data heap literal */
+       RT_LITERAL,
+       /* untagged fixnum literal */
+       RT_UNTAGGED,
+       /* address of megamorphic_cache_hits var */
+       RT_MEGAMORPHIC_CACHE_HITS,
+       /* address of vm object */
+       RT_VM,
+       /* value of vm->cards_offset */
+       RT_CARDS_OFFSET,
+       /* value of vm->decks_offset */
+       RT_DECKS_OFFSET,
+};
+
+enum relocation_class {
+       /* absolute address in a 64-bit location */
+       RC_ABSOLUTE_CELL,
+       /* absolute address in a 32-bit location */
+       RC_ABSOLUTE,
+       /* relative address in a 32-bit location */
+       RC_RELATIVE,
+       /* absolute address in a PowerPC LIS/ORI sequence */
+       RC_ABSOLUTE_PPC_2_2,
+       /* absolute address in a PowerPC LWZ instruction */
+       RC_ABSOLUTE_PPC_2,
+       /* relative address in a PowerPC LWZ/STW/BC instruction */
+       RC_RELATIVE_PPC_2,
+       /* relative address in a PowerPC B/BL instruction */
+       RC_RELATIVE_PPC_3,
+       /* relative address in an ARM B/BL instruction */
+       RC_RELATIVE_ARM_3,
+       /* pointer to address in an ARM LDR/STR instruction */
+       RC_INDIRECT_ARM,
+       /* pointer to address in an ARM LDR/STR instruction offset by 8 bytes */
+       RC_INDIRECT_ARM_PC,
+       /* absolute address in a 16-bit location */
+       RC_ABSOLUTE_2
+};
+
+static const cell rel_absolute_ppc_2_mask = 0xffff;
+static const cell rel_relative_ppc_2_mask = 0xfffc;
+static const cell rel_relative_ppc_3_mask = 0x3fffffc;
+static const cell rel_indirect_arm_mask = 0xfff;
+static const cell rel_relative_arm_3_mask = 0xffffff;
+
+/* code relocation table consists of a table of entries for each fixup */
+struct relocation_entry {
+       u32 value;
+
+       explicit relocation_entry(u32 value_) : value(value_) {}
+
+       relocation_entry(relocation_type rel_type,
+               relocation_class rel_class,
+               cell offset)
+       {
+               value = (rel_type << 28) | (rel_class << 24) | offset;
+       }
+
+       relocation_type rel_type()
+       {
+               return (relocation_type)((value & 0xf0000000) >> 28);
+       }
+
+       relocation_class rel_class()
+       {
+               return (relocation_class)((value & 0x0f000000) >> 24);
+       }
+
+       cell rel_offset()
+       {
+               return (value & 0x00ffffff);
+       }
+
+       int number_of_parameters()
+       {
+               switch(rel_type())
+               {
+               case RT_VM:
+                       return 1;
+               case RT_DLSYM:
+                       return 2;
+               case RT_ENTRY_POINT:
+               case RT_ENTRY_POINT_PIC:
+               case RT_ENTRY_POINT_PIC_TAIL:
+               case RT_LITERAL:
+               case RT_HERE:
+               case RT_UNTAGGED:
+               case RT_THIS:
+               case RT_MEGAMORPHIC_CACHE_HITS:
+               case RT_CARDS_OFFSET:
+               case RT_DECKS_OFFSET:
+                       return 0;
+               default:
+                       critical_error("Bad rel type",rel_type());
+                       return -1; /* Can't happen */
+               }
+       }
+};
+
+struct instruction_operand {
+       relocation_entry rel;
+       code_block *compiled;
+       cell index;
+       cell pointer;
+
+       instruction_operand(relocation_entry rel_, code_block *compiled_, cell index_);
+
+       relocation_type rel_type()
+       {
+               return rel.rel_type();
+       }
+
+       cell rel_offset()
+       {
+               return rel.rel_offset();
+       }
+
+       cell parameter_index()
+       {
+               return index;
+       }
+
+       code_block *parent_code_block()
+       {
+               return compiled;
+       }
+
+       fixnum load_value_2_2();
+       fixnum load_value_masked(cell mask, cell bits, cell shift);
+       fixnum load_value(cell relative_to);
+       fixnum load_value();
+       code_block *load_code_block(cell relative_to);
+       code_block *load_code_block();
+
+       void store_value_2_2(fixnum value);
+       void store_value_masked(fixnum value, cell mask, cell shift);
+       void store_value(fixnum value);
+       void store_code_block(code_block *compiled);
+};
+
+}
index a8f9cb6897f4507fb05ab931ab68ef071e43bb1a..a45e1d10ab3701f4ae493e71bb1ad9b242dbaf4c 100755 (executable)
--- a/vm/io.cpp
+++ b/vm/io.cpp
@@ -33,8 +33,8 @@ void factor_vm::io_error()
 
 void factor_vm::primitive_fopen()
 {
-       data_root<byte_array> mode(dpop(),this);
-       data_root<byte_array> path(dpop(),this);
+       data_root<byte_array> mode(ctx->pop(),this);
+       data_root<byte_array> path(ctx->pop(),this);
        mode.untag_check(this);
        path.untag_check(this);
 
@@ -46,15 +46,20 @@ void factor_vm::primitive_fopen()
                        io_error();
                else
                {
-                       box_alien(file);
+                       ctx->push(allot_alien(file));
                        break;
                }
        }
 }
 
+FILE *factor_vm::pop_file_handle()
+{
+       return (FILE *)alien_offset(ctx->pop());
+}
+
 void factor_vm::primitive_fgetc()
 {
-       FILE *file = (FILE *)unbox_alien();
+       FILE *file = pop_file_handle();
 
        for(;;)
        {
@@ -63,7 +68,7 @@ void factor_vm::primitive_fgetc()
                {
                        if(feof(file))
                        {
-                               dpush(false_object);
+                               ctx->push(false_object);
                                break;
                        }
                        else
@@ -71,7 +76,7 @@ void factor_vm::primitive_fgetc()
                }
                else
                {
-                       dpush(tag_fixnum(c));
+                       ctx->push(tag_fixnum(c));
                        break;
                }
        }
@@ -79,12 +84,12 @@ void factor_vm::primitive_fgetc()
 
 void factor_vm::primitive_fread()
 {
-       FILE *file = (FILE *)unbox_alien();
+       FILE *file = pop_file_handle();
        fixnum size = unbox_array_size();
 
        if(size == 0)
        {
-               dpush(tag<string>(allot_string(0,0)));
+               ctx->push(tag<string>(allot_string(0,0)));
                return;
        }
 
@@ -97,7 +102,7 @@ void factor_vm::primitive_fread()
                {
                        if(feof(file))
                        {
-                               dpush(false_object);
+                               ctx->push(false_object);
                                break;
                        }
                        else
@@ -111,7 +116,7 @@ void factor_vm::primitive_fread()
                                memcpy(new_buf + 1, buf.untagged() + 1,c);
                                buf = new_buf;
                        }
-                       dpush(buf.value());
+                       ctx->push(buf.value());
                        break;
                }
        }
@@ -119,8 +124,8 @@ void factor_vm::primitive_fread()
 
 void factor_vm::primitive_fputc()
 {
-       FILE *file = (FILE *)unbox_alien();
-       fixnum ch = to_fixnum(dpop());
+       FILE *file = pop_file_handle();
+       fixnum ch = to_fixnum(ctx->pop());
 
        for(;;)
        {
@@ -137,8 +142,8 @@ void factor_vm::primitive_fputc()
 
 void factor_vm::primitive_fwrite()
 {
-       FILE *file = (FILE *)unbox_alien();
-       byte_array *text = untag_check<byte_array>(dpop());
+       FILE *file = pop_file_handle();
+       byte_array *text = untag_check<byte_array>(ctx->pop());
        cell length = array_capacity(text);
        char *string = (char *)(text + 1);
 
@@ -166,20 +171,20 @@ void factor_vm::primitive_fwrite()
 
 void factor_vm::primitive_ftell()
 {
-       FILE *file = (FILE *)unbox_alien();
+       FILE *file = pop_file_handle();
        off_t offset;
 
        if((offset = FTELL(file)) == -1)
                io_error();
 
-       box_signed_8(offset);
+       ctx->push(from_signed_8(offset));
 }
 
 void factor_vm::primitive_fseek()
 {
-       int whence = to_fixnum(dpop());
-       FILE *file = (FILE *)unbox_alien();
-       off_t offset = to_signed_8(dpop());
+       int whence = to_fixnum(ctx->pop());
+       FILE *file = pop_file_handle();
+       off_t offset = to_signed_8(ctx->pop());
 
        switch(whence)
        {
@@ -202,7 +207,7 @@ void factor_vm::primitive_fseek()
 
 void factor_vm::primitive_fflush()
 {
-       FILE *file = (FILE *)unbox_alien();
+       FILE *file = pop_file_handle();
        for(;;)
        {
                if(fflush(file) == EOF)
@@ -214,7 +219,7 @@ void factor_vm::primitive_fflush()
 
 void factor_vm::primitive_fclose()
 {
-       FILE *file = (FILE *)unbox_alien();
+       FILE *file = pop_file_handle();
        for(;;)
        {
                if(fclose(file) == EOF)
index e72e88bfdff70c6c45945cdbfc34bbfec1b32c49..8d2f5abb9a1739c3408e36e98a1d000b1ee15419 100644 (file)
@@ -15,6 +15,7 @@ jit::jit(code_block_type type_, cell owner_, factor_vm *vm)
          owner(owner_,vm),
          code(vm),
          relocation(vm),
+         parameters(vm),
          literals(vm),
          computing_offset_p(false),
          position(0),
@@ -28,14 +29,11 @@ void jit::emit_relocation(cell code_template_)
        cell capacity = array_capacity(code_template.untagged());
        for(cell i = 1; i < capacity; i += 3)
        {
-               cell rel_class = array_nth(code_template.untagged(),i);
-               cell rel_type = array_nth(code_template.untagged(),i + 1);
+               relocation_class rel_class = (relocation_class)untag_fixnum(array_nth(code_template.untagged(),i));
+               relocation_type rel_type = (relocation_type)untag_fixnum(array_nth(code_template.untagged(),i + 1));
                cell offset = array_nth(code_template.untagged(),i + 2);
 
-               relocation_entry new_entry
-                       = (untag_fixnum(rel_type) << 28)
-                       | (untag_fixnum(rel_class) << 24)
-                       | ((code.count + untag_fixnum(offset)));
+               relocation_entry new_entry(rel_type,rel_class,code.count + untag_fixnum(offset));
                relocation.append_bytes(&new_entry,sizeof(relocation_entry));
        }
 }
@@ -70,16 +68,44 @@ void jit::emit(cell code_template_)
        code.append_byte_array(insns.value());
 }
 
-void jit::emit_with(cell code_template_, cell argument_) {
+void jit::emit_with_literal(cell code_template_, cell argument_) {
        data_root<array> code_template(code_template_,parent);
        data_root<object> argument(argument_,parent);
        literal(argument.value());
        emit(code_template.value());
 }
 
+void jit::emit_with_parameter(cell code_template_, cell argument_) {
+       data_root<array> code_template(code_template_,parent);
+       data_root<object> argument(argument_,parent);
+       parameter(argument.value());
+       emit(code_template.value());
+}
+
+bool jit::emit_subprimitive(cell word_, bool tail_call_p, bool stack_frame_p)
+{
+       data_root<word> word(word_,parent);
+       data_root<array> code_template(word->subprimitive,parent);
+       parameters.append(untag<array>(array_nth(code_template.untagged(),0)));
+       literals.append(untag<array>(array_nth(code_template.untagged(),1)));
+       emit(array_nth(code_template.untagged(),2));
+       if(array_capacity(code_template.untagged()) == 5)
+       {
+               if(tail_call_p)
+               {
+                       if(stack_frame_p) emit(parent->special_objects[JIT_EPILOG]);
+                       emit(array_nth(code_template.untagged(),4));
+                       return true;
+               }
+               else
+                       emit(array_nth(code_template.untagged(),3));
+       }
+       return false;
+}
+       
 void jit::emit_class_lookup(fixnum index, cell type)
 {
-       emit_with(parent->special_objects[PIC_LOAD],tag_fixnum(-index * sizeof(cell)));
+       emit_with_literal(parent->special_objects[PIC_LOAD],tag_fixnum(-index * sizeof(cell)));
        emit(parent->special_objects[type]);
 }
 
@@ -98,6 +124,7 @@ code_block *jit::to_code_block()
 {
        code.trim();
        relocation.trim();
+       parameters.trim();
        literals.trim();
 
        return parent->add_code_block(
@@ -106,6 +133,7 @@ code_block *jit::to_code_block()
                false_object, /* no labels */
                owner.value(),
                relocation.elements.value(),
+               parameters.elements.value(),
                literals.elements.value());
 }
 
index b5a2457d570b4495ecc10b904b96e6d8dd13d082..277aecb66d355a3ffac9a362f51a0ef3da9bbe6c 100644 (file)
@@ -6,6 +6,7 @@ struct jit {
        data_root<object> owner;
        growable_byte_array code;
        growable_byte_array relocation;
+       growable_array parameters;
        growable_array literals;
        bool computing_offset_p;
        fixnum position;
@@ -18,12 +19,15 @@ struct jit {
        void emit_relocation(cell code_template);
        void emit(cell code_template);
 
+       void parameter(cell parameter) { parameters.add(parameter); }
+       void emit_with_parameter(cell code_template_, cell parameter_);
+
        void literal(cell literal) { literals.add(literal); }
-       void emit_with(cell code_template_, cell literal_);
+       void emit_with_literal(cell code_template_, cell literal_);
 
        void push(cell literal)
        {
-               emit_with(parent->special_objects[JIT_PUSH_IMMEDIATE],literal);
+               emit_with_literal(parent->special_objects[JIT_PUSH_IMMEDIATE],literal);
        }
 
        void word_jump(cell word_)
@@ -36,21 +40,10 @@ struct jit {
 
        void word_call(cell word)
        {
-               emit_with(parent->special_objects[JIT_WORD_CALL],word);
-       }
-
-       void word_special(cell word)
-       {
-               emit_with(parent->special_objects[JIT_WORD_SPECIAL],word);
+               emit_with_literal(parent->special_objects[JIT_WORD_CALL],word);
        }
 
-       void emit_subprimitive(cell word_)
-       {
-               data_root<word> word(word_,parent);
-               data_root<array> code_pair(word->subprimitive,parent);
-               literals.append(untag<array>(array_nth(code_pair.untagged(),0)));
-               emit(array_nth(code_pair.untagged(),1));
-       }
+       bool emit_subprimitive(cell word_, bool tail_call_p, bool stack_frame_p);
 
        void emit_class_lookup(fixnum index, cell type);
 
index 5f3f3e93100bdbe9ad0c301cec4d35dcd1b9b299..9b574e554d359ebb6307296837e889dddb9c4c77 100644 (file)
@@ -51,8 +51,6 @@ static const cell data_alignment = 16;
 
 #define TYPE_COUNT 14
 
-#define FORWARDING_POINTER 5 /* can be anything other than FIXNUM_TYPE */
-
 enum code_block_type
 {
        code_block_unoptimized,
@@ -95,59 +93,59 @@ inline static cell tag_fixnum(fixnum untagged)
 
 struct object;
 
-struct header {
-       cell value;
+#define NO_TYPE_CHECK static const cell type_number = TYPE_COUNT
+
+struct object {
+       NO_TYPE_CHECK;
+       cell header;
+
+       cell size() const;
+       cell binary_payload_start() const;
 
-        /* Default ctor to make gcc 3.x happy */
-        explicit header() { abort(); }
+       cell *slots() const { return (cell *)this; }
 
-       explicit header(cell value_) : value(value_ << TAG_BITS) {}
+       template<typename Iterator> void each_slot(Iterator &iter);
 
-       void check_header() const
+       /* Only valid for objects in tenured space; must cast to free_heap_block
+       to do anything with it if its free */
+       bool free_p() const
        {
-#ifdef FACTOR_DEBUG
-               assert(TAG(value) == FIXNUM_TYPE && untag_fixnum(value) < TYPE_COUNT);
-#endif
+               return (header & 1) == 1;
        }
 
-       cell hi_tag() const
+       cell type() const
        {
-               check_header();
-               return value >> TAG_BITS;
+               return (header >> 2) & TAG_MASK;
        }
 
-       bool forwarding_pointer_p() const
+       void initialize(cell type)
        {
-               return TAG(value) == FORWARDING_POINTER;
+               header = type << 2;
        }
 
-       object *forwarding_pointer() const
+       cell hashcode() const
        {
-               return (object *)UNTAG(value);
+               return (header >> 6);
        }
 
-       void forward_to(object *pointer)
+       void set_hashcode(cell hashcode)
        {
-               value = RETAG(pointer,FORWARDING_POINTER);
+               header = (header & 0x3f) | (hashcode << 6);
        }
-};
-
-#define NO_TYPE_CHECK static const cell type_number = TYPE_COUNT
-
-struct object {
-       NO_TYPE_CHECK;
-       header h;
 
-       cell size() const;
-       cell binary_payload_start() const;
+       bool forwarding_pointer_p() const
+       {
+               return (header & 2) == 2;
+       }
 
-       cell *slots()  const { return (cell *)this; }
+       object *forwarding_pointer() const
+       {
+               return (object *)UNTAG(header);
+       }
 
-       /* Only valid for objects in tenured space; must fast to free_heap_block
-       to do anything with it if its free */
-       bool free_p() const
+       void forward_to(object *pointer)
        {
-               return h.value & 1 == 1;
+               header = ((cell)pointer | 2);
        }
 };
 
@@ -211,49 +209,7 @@ struct string : public object {
        cell nth(cell i) const;
 };
 
-/* The compiled code heap is structured into blocks. */
-struct code_block
-{
-       cell header;
-       cell owner; /* tagged pointer to word, quotation or f */
-       cell literals; /* tagged pointer to array or f */
-       cell relocation; /* tagged pointer to byte-array or f */
-
-       bool free_p() const
-       {
-               return header & 1 == 1;
-       }
-
-       code_block_type type() const
-       {
-               return (code_block_type)((header >> 1) & 0x3);
-       }
-
-       void set_type(code_block_type type)
-       {
-               header = ((header & ~0x7) | (type << 1));
-       }
-
-       bool pic_p() const
-       {
-               return type() == code_block_pic;
-       }
-
-       bool optimized_p() const
-       {
-               return type() == code_block_optimized;
-       }
-
-       cell size() const
-       {
-               return header >> 3;
-       }
-
-       void *xt() const
-       {
-               return (void *)(this + 1);
-       }
-};
+struct code_block;
 
 /* Assembly code makes assumptions about the layout of this struct */
 struct word : public object {
@@ -276,8 +232,8 @@ struct word : public object {
        cell counter;
        /* TAGGED machine code for sub-primitive */
        cell subprimitive;
-       /* UNTAGGED execution token: jump here to execute word */
-       void *xt;
+       /* UNTAGGED entry point: jump here to execute word */
+       void *entry_point;
        /* UNTAGGED compiled code block */
        code_block *code;
        /* UNTAGGED profiler stub */
@@ -310,8 +266,8 @@ struct quotation : public object {
        cell cached_effect;
        /* tagged */
        cell cache_counter;
-       /* UNTAGGED */
-       void *xt;
+       /* UNTAGGED entry point; jump here to call quotation */
+       void *entry_point;
        /* UNTAGGED compiled code block */
        code_block *code;
 };
@@ -342,11 +298,12 @@ struct dll : public object {
        /* tagged byte array holding a C string */
        cell path;
        /* OS-specific handle */
-       void *dll;
+       void *handle;
 };
 
 struct stack_frame {
-       void *xt;
+       /* Updated by procedure prologue with procedure start address */
+       void *entry_point;
        /* Frame size in bytes */
        cell size;
 };
@@ -373,4 +330,12 @@ struct tuple : public object {
        cell *data() const { return (cell *)(this + 1); }
 };
 
+struct data_root_range {
+       cell *start;
+       cell len;
+
+       explicit data_root_range(cell *start_, cell len_) :
+               start(start_), len(len_) {}
+};
+
 }
old mode 100644 (file)
new mode 100755 (executable)
index 526f3b2..ed58441
@@ -1,29 +1,22 @@
 #include "master.hpp"
 
 /* 
-       Windows CE argument parsing ported to work on
+       Windows argument parsing ported to work on
        int main(int argc, wchar_t **argv).
 
-       This would not be necessary if Windows CE had CommandLineToArgvW.
-
        Based on MinGW's public domain char** version.
-
 */
 
-int __argc;
-wchar_t **__argv;
-
-static int
-parse_tokens(wchar_t* string, wchar_t*** tokens, int length)
+VM_C_API int parse_tokens(wchar_t *string, wchar_t ***tokens, int length)
 {
        /* Extract whitespace- and quotes- delimited tokens from the given string
           and put them into the tokens array. Returns number of tokens
           extracted. Length specifies the current size of tokens[].
           THIS METHOD MODIFIES string.  */
 
-       const wchar_twhitespace = L" \t\r\n";
-       wchar_ttokenEnd = 0;
-       const wchar_tquoteCharacters = L"\"\'";
+       const wchar_t *whitespace = L" \t\r\n";
+       wchar_t *tokenEnd = 0;
+       const wchar_t *quoteCharacters = L"\"\'";
        wchar_t *end = string + wcslen(string);
 
        if (string == NULL)
@@ -31,7 +24,7 @@ parse_tokens(wchar_t* string, wchar_t*** tokens, int length)
 
        while (1)
        {
-               const wchar_tq;
+               const wchar_t *q;
                /* Skip over initial whitespace.  */
                string += wcsspn(string, whitespace);
                if (*string == '\0')
@@ -59,9 +52,9 @@ parse_tokens(wchar_t* string, wchar_t*** tokens, int length)
                *tokenEnd = '\0';
 
                {
-                       wchar_t** new_tokens;
+                       wchar_t **new_tokens;
                        int newlen = length + 1;
-                       new_tokens = realloc (*tokens, sizeof (wchar_t**) * newlen);
+                       new_tokens = (wchar_t **)realloc (*tokens, sizeof (wchar_t**) * newlen);
                        if (!new_tokens)
                        {
                                /* Out of memory.  */
@@ -79,16 +72,9 @@ parse_tokens(wchar_t* string, wchar_t*** tokens, int length)
        return length;
 }
 
-static void
-parse_args(int *argc, wchar_t ***argv, wchar_t *cmdlinePtrW)
+VM_C_API void parse_args(int *argc, wchar_t ***argv, wchar_t *cmdlinePtrW)
 {
-       wchar_t cmdnameBufW[MAX_UNICODE_PATH];
        int cmdlineLen = 0;
-       int modlen;
-
-       /* argv[0] is the path of invoked program - get this from CE.  */
-       cmdnameBufW[0] = 0;
-       modlen = GetModuleFileNameW(NULL, cmdnameBufW, sizeof (cmdnameBufW)/sizeof (cmdnameBufW[0]));
 
        if (!cmdlinePtrW)
                cmdlineLen = 0;
@@ -96,39 +82,51 @@ parse_args(int *argc, wchar_t ***argv, wchar_t *cmdlinePtrW)
                cmdlineLen = wcslen(cmdlinePtrW);
 
        /* gets realloc()'d later */
-       *argv = malloc (sizeof (wchar_t**) * 1);
+       *argc = 0;
+       *argv = (wchar_t **)malloc (sizeof (wchar_t**));
+
        if (!*argv)
-               ExitProcess(-1);
+               ExitProcess(1);
+
+#ifdef WINCE
+       wchar_t cmdnameBufW[MAX_UNICODE_PATH];
+
+       /* argv[0] is the path of invoked program - get this from CE.  */
+       cmdnameBufW[0] = 0;
+       GetModuleFileNameW(NULL, cmdnameBufW, sizeof (cmdnameBufW)/sizeof (cmdnameBufW[0]));
 
        (*argv)[0] = wcsdup(cmdnameBufW);
        if(!(*argv[0]))
-               ExitProcess(-1);
+               ExitProcess(1);
        /* Add one to account for argv[0] */
        (*argc)++;
+#endif
 
        if (cmdlineLen > 0)
        {
-               wchar_t* argv1 = (*argv)[0] + wcslen((*argv)[0]) + 1;
-               argv1 = wcsdup(cmdlinePtrW);
-               if(!argv1)
-                       ExitProcess(-1);
-               *argc = parse_tokens(argv1, argv, 1);
+               wchar_t *string = wcsdup(cmdlinePtrW);
+               if(!string)
+                       ExitProcess(1);
+               *argc = parse_tokens(string, argv, *argc);
                if (*argc < 0)
-                       ExitProcess(-1);
+                       ExitProcess(1);
        }
        (*argv)[*argc] = 0;
        return;
 }
 
-int WINAPI
-WinMain(
+int WINAPI WinMain(
        HINSTANCE hInstance,
        HINSTANCE hPrevInstance,
        LPWSTR lpCmdLine,
        int nCmdShow)
 {
-       parse_args(&__argc, &__argv, lpCmdLine);
+       int __argc;
+       wchar_t **__argv;
+       factor::parse_args(&__argc, &__argv, lpCmdLine);
+       factor::init_globals();
        factor::start_standalone_factor(__argc,(LPWSTR*)__argv);
+
        // memory leak from malloc, wcsdup
        return 0;
 }
old mode 100644 (file)
new mode 100755 (executable)
index df4a117..64e2cce
@@ -1,30 +1,29 @@
 #include "master.hpp"
 
+VM_C_API int wmain(int argc, wchar_t **argv)
+{
+       factor::init_globals();
+#ifdef FACTOR_MULTITHREADED
+       factor::THREADHANDLE thread = factor::start_standalone_factor_in_new_thread(argv,argc);
+       WaitForSingleObject(thread, INFINITE);
+#else
+       factor::start_standalone_factor(argc,argv);
+#endif
+       return 0;
+}
+
 int WINAPI WinMain(
        HINSTANCE hInstance,
        HINSTANCE hPrevInstance,
        LPSTR lpCmdLine,
        int nCmdShow)
 {
-       LPWSTR *szArglist;
-       int nArgs;
-
-       szArglist = CommandLineToArgvW(GetCommandLineW(), &nArgs);
-       if(NULL == szArglist)
-       {
-               puts("CommandLineToArgvW failed");
-               return 1;
-       }
-
-       factor::init_globals();
-  #ifdef FACTOR_MULTITHREADED
-       factor::THREADHANDLE thread = factor::start_standalone_factor_in_new_thread(nArgs,szArglist);
-       WaitForSingleObject(thread, INFINITE);
-  #else
-       factor::start_standalone_factor(nArgs,szArglist);
-  #endif
+       int argc;
+       wchar_t **argv;
 
-       LocalFree(szArglist);
+       argv = CommandLineToArgvW(GetCommandLine(),&argc);
+       wmain(argc,argv);
 
+       // memory leak from malloc, wcsdup
        return 0;
 }
index b54a2c9d46fb4f21699db2939909102e01345e23..5115f9a8214489045451d054ac8ec724c6bfea77 100644 (file)
@@ -1,19 +1,19 @@
 namespace factor
 {
 
-const int block_granularity = 16;
-const int forwarding_granularity = 64;
+const int mark_bits_granularity = sizeof(cell) * 8;
+const int mark_bits_mask = sizeof(cell) * 8 - 1;
 
 template<typename Block> struct mark_bits {
        cell size;
        cell start;
        cell bits_size;
-       u64 *marked;
+       cell *marked;
        cell *forwarding;
 
        void clear_mark_bits()
        {
-               memset(marked,0,bits_size * sizeof(u64));
+               memset(marked,0,bits_size * sizeof(cell));
        }
 
        void clear_forwarding()
@@ -24,8 +24,8 @@ template<typename Block> struct mark_bits {
        explicit mark_bits(cell size_, cell start_) :
                size(size_),
                start(start_),
-               bits_size(size / block_granularity / forwarding_granularity),
-               marked(new u64[bits_size]),
+               bits_size(size / data_alignment / mark_bits_granularity),
+               marked(new cell[bits_size]),
                forwarding(new cell[bits_size])
        {
                clear_mark_bits();
@@ -42,26 +42,26 @@ template<typename Block> struct mark_bits {
 
        cell block_line(Block *address)
        {
-               return (((cell)address - start) / block_granularity);
+               return (((cell)address - start) / data_alignment);
        }
 
        Block *line_block(cell line)
        {
-               return (Block *)(line * block_granularity + start);
+               return (Block *)(line * data_alignment + start);
        }
 
        std::pair<cell,cell> bitmap_deref(Block *address)
        {
                cell line_number = block_line(address);
-               cell word_index = (line_number >> 6);
-               cell word_shift = (line_number & 63);
+               cell word_index = (line_number / mark_bits_granularity);
+               cell word_shift = (line_number & mark_bits_mask);
                return std::make_pair(word_index,word_shift);
        }
 
-       bool bitmap_elt(u64 *bits, Block *address)
+       bool bitmap_elt(cell *bits, Block *address)
        {
                std::pair<cell,cell> position = bitmap_deref(address);
-               return (bits[position.first] & ((u64)1 << position.second)) != 0;
+               return (bits[position.first] & ((cell)1 << position.second)) != 0;
        }
 
        Block *next_block_after(Block *block)
@@ -69,13 +69,13 @@ template<typename Block> struct mark_bits {
                return (Block *)((cell)block + block->size());
        }
 
-       void set_bitmap_range(u64 *bits, Block *address)
+       void set_bitmap_range(cell *bits, Block *address)
        {
                std::pair<cell,cell> start = bitmap_deref(address);
                std::pair<cell,cell> end = bitmap_deref(next_block_after(address));
 
-               u64 start_mask = ((u64)1 << start.second) - 1;
-               u64 end_mask = ((u64)1 << end.second) - 1;
+               cell start_mask = ((cell)1 << start.second) - 1;
+               cell end_mask = ((cell)1 << end.second) - 1;
 
                if(start.first == end.first)
                        bits[start.first] |= start_mask ^ end_mask;
@@ -87,7 +87,7 @@ template<typename Block> struct mark_bits {
                        bits[start.first] |= ~start_mask;
 
                        for(cell index = start.first + 1; index < end.first; index++)
-                               bits[index] = (u64)-1;
+                               bits[index] = (cell)-1;
 
                        if(end_mask != 0)
                        {
@@ -121,7 +121,8 @@ template<typename Block> struct mark_bits {
                }
        }
 
-       /* We have the popcount for every 64 entries; look up and compute the rest */
+       /* We have the popcount for every mark_bits_granularity entries; look
+       up and compute the rest */
        Block *forward_block(Block *original)
        {
 #ifdef FACTOR_DEBUG
@@ -130,7 +131,7 @@ template<typename Block> struct mark_bits {
                std::pair<cell,cell> position = bitmap_deref(original);
 
                cell approx_popcount = forwarding[position.first];
-               u64 mask = ((u64)1 << position.second) - 1;
+               cell mask = ((cell)1 << position.second) - 1;
 
                cell new_line_number = approx_popcount + popcount(marked[position.first] & mask);
                Block *new_block = line_block(new_line_number);
@@ -147,13 +148,13 @@ template<typename Block> struct mark_bits {
 
                for(cell index = position.first; index < bits_size; index++)
                {
-                       u64 mask = ((s64)marked[index] >> bit_index);
+                       cell mask = ((fixnum)marked[index] >> bit_index);
                        if(~mask)
                        {
                                /* Found an unmarked block on this page.
                                Stop, it's hammer time */
                                cell clear_bit = rightmost_clear_bit(mask);
-                               return line_block(index * 64 + bit_index + clear_bit);
+                               return line_block(index * mark_bits_granularity + bit_index + clear_bit);
                        }
                        else
                        {
@@ -174,13 +175,13 @@ template<typename Block> struct mark_bits {
 
                for(cell index = position.first; index < bits_size; index++)
                {
-                       u64 mask = (marked[index] >> bit_index);
+                       cell mask = (marked[index] >> bit_index);
                        if(mask)
                        {
                                /* Found an marked block on this page.
                                Stop, it's hammer time */
                                cell set_bit = rightmost_set_bit(mask);
-                               return line_block(index * 64 + bit_index + set_bit);
+                               return line_block(index * mark_bits_granularity + bit_index + set_bit);
                        }
                        else
                        {
index 39242a36afc6092ac2267db7adb6e5ca534999d8..f4c093447847c498160fd0862ee2c5f64cf2b854 100755 (executable)
@@ -16,7 +16,6 @@
 #include <fcntl.h>
 #include <limits.h>
 #include <math.h>
-#include <stdbool.h>
 #include <setjmp.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <vector>
 #include <iostream>
 
+/* Detect target CPU type */
+#if defined(__arm__)
+       #define FACTOR_ARM
+#elif defined(__amd64__) || defined(__x86_64__)
+       #define FACTOR_AMD64
+       #define FACTOR_64
+#elif defined(i386) || defined(__i386) || defined(__i386__) || defined(WIN32) || defined(_MSC_VER)
+       #define FACTOR_X86
+#elif defined(__POWERPC__) || defined(__ppc__) || defined(_ARCH_PPC)
+       #define FACTOR_PPC
+#else
+       #error "Unsupported architecture"
+#endif
+
+#if defined(_MSC_VER)
+       #define WINDOWS
+       #define WINNT
+#elif defined(WIN32)
+       #define WINDOWS
+#endif
+
+#ifndef _MSC_VER
+       #include <stdbool.h>
+#endif
+
 /* Forward-declare this since it comes up in function prototypes */
 namespace factor
 {
@@ -40,15 +64,17 @@ namespace factor
 #include "layouts.hpp"
 #include "platform.hpp"
 #include "primitives.hpp"
-#include "stacks.hpp"
 #include "segments.hpp"
 #include "contexts.hpp"
 #include "run.hpp"
+#include "objects.hpp"
 #include "profiler.hpp"
 #include "errors.hpp"
 #include "bignumint.hpp"
 #include "bignum.hpp"
-#include "code_block.hpp"
+#include "booleans.hpp"
+#include "instruction_operands.hpp"
+#include "code_blocks.hpp"
 #include "bump_allocator.hpp"
 #include "bitwise_hacks.hpp"
 #include "mark_bits.hpp"
@@ -72,11 +98,13 @@ namespace factor
 #include "alien.hpp"
 #include "callbacks.hpp"
 #include "dispatch.hpp"
+#include "entry_points.hpp"
 #include "vm.hpp"
 #include "allot.hpp"
 #include "tagged.hpp"
 #include "data_roots.hpp"
 #include "code_roots.hpp"
+#include "generic_arrays.hpp"
 #include "slot_visitor.hpp"
 #include "collector.hpp"
 #include "copying_collector.hpp"
@@ -87,10 +115,8 @@ namespace factor
 #include "compaction.hpp"
 #include "full_collector.hpp"
 #include "callstack.hpp"
-#include "generic_arrays.hpp"
 #include "arrays.hpp"
 #include "math.hpp"
-#include "booleans.hpp"
 #include "byte_arrays.hpp"
 #include "jit.hpp"
 #include "quotations.hpp"
index 4266edc09c3dec40d5eee9bb3e617c4892ca2a2f..a2c69c31f2a6af0514570b7c52469d944359e8aa 100755 (executable)
@@ -5,40 +5,40 @@ namespace factor
 
 void factor_vm::primitive_bignum_to_fixnum()
 {
-       drepl(tag_fixnum(bignum_to_fixnum(untag<bignum>(dpeek()))));
+       ctx->replace(tag_fixnum(bignum_to_fixnum(untag<bignum>(ctx->peek()))));
 }
 
 void factor_vm::primitive_float_to_fixnum()
 {
-       drepl(tag_fixnum(float_to_fixnum(dpeek())));
+       ctx->replace(tag_fixnum(float_to_fixnum(ctx->peek())));
 }
 
 /* Division can only overflow when we are dividing the most negative fixnum
 by -1. */
 void factor_vm::primitive_fixnum_divint()
 {
-       fixnum y = untag_fixnum(dpop()); \
-       fixnum x = untag_fixnum(dpeek());
+       fixnum y = untag_fixnum(ctx->pop()); \
+       fixnum x = untag_fixnum(ctx->peek());
        fixnum result = x / y;
        if(result == -fixnum_min)
-               drepl(allot_integer(-fixnum_min));
+               ctx->replace(allot_integer(-fixnum_min));
        else
-               drepl(tag_fixnum(result));
+               ctx->replace(tag_fixnum(result));
 }
 
 void factor_vm::primitive_fixnum_divmod()
 {
-       cell y = ((cell *)ds)[0];
-       cell x = ((cell *)ds)[-1];
+       cell y = ((cell *)ctx->datastack)[0];
+       cell x = ((cell *)ctx->datastack)[-1];
        if(y == tag_fixnum(-1) && x == tag_fixnum(fixnum_min))
        {
-               ((cell *)ds)[-1] = allot_integer(-fixnum_min);
-               ((cell *)ds)[0] = tag_fixnum(0);
+               ((cell *)ctx->datastack)[-1] = allot_integer(-fixnum_min);
+               ((cell *)ctx->datastack)[0] = tag_fixnum(0);
        }
        else
        {
-               ((cell *)ds)[-1] = tag_fixnum(untag_fixnum(x) / untag_fixnum(y));
-               ((cell *)ds)[0] = (fixnum)x % (fixnum)y;
+               ((cell *)ctx->datastack)[-1] = tag_fixnum(untag_fixnum(x) / untag_fixnum(y));
+               ((cell *)ctx->datastack)[0] = (fixnum)x % (fixnum)y;
        }
 }
 
@@ -63,15 +63,15 @@ inline fixnum factor_vm::branchless_abs(fixnum x)
 
 void factor_vm::primitive_fixnum_shift()
 {
-       fixnum y = untag_fixnum(dpop());
-       fixnum x = untag_fixnum(dpeek());
+       fixnum y = untag_fixnum(ctx->pop());
+       fixnum x = untag_fixnum(ctx->peek());
 
        if(x == 0)
                return;
        else if(y < 0)
        {
                y = branchless_max(y,-WORD_SIZE + 1);
-               drepl(tag_fixnum(x >> -y));
+               ctx->replace(tag_fixnum(x >> -y));
                return;
        }
        else if(y < WORD_SIZE - TAG_BITS)
@@ -79,57 +79,57 @@ void factor_vm::primitive_fixnum_shift()
                fixnum mask = -((fixnum)1 << (WORD_SIZE - 1 - TAG_BITS - y));
                if(!(branchless_abs(x) & mask))
                {
-                       drepl(tag_fixnum(x << y));
+                       ctx->replace(tag_fixnum(x << y));
                        return;
                }
        }
 
-       drepl(tag<bignum>(bignum_arithmetic_shift(
+       ctx->replace(tag<bignum>(bignum_arithmetic_shift(
                fixnum_to_bignum(x),y)));
 }
 
 void factor_vm::primitive_fixnum_to_bignum()
 {
-       drepl(tag<bignum>(fixnum_to_bignum(untag_fixnum(dpeek()))));
+       ctx->replace(tag<bignum>(fixnum_to_bignum(untag_fixnum(ctx->peek()))));
 }
 
 void factor_vm::primitive_float_to_bignum()
 {
-       drepl(tag<bignum>(float_to_bignum(dpeek())));
+       ctx->replace(tag<bignum>(float_to_bignum(ctx->peek())));
 }
 
 #define POP_BIGNUMS(x,y) \
-       bignum * y = untag<bignum>(dpop()); \
-       bignum * x = untag<bignum>(dpop());
+       bignum * y = untag<bignum>(ctx->pop()); \
+       bignum * x = untag<bignum>(ctx->pop());
 
 void factor_vm::primitive_bignum_eq()
 {
        POP_BIGNUMS(x,y);
-       box_boolean(bignum_equal_p(x,y));
+       ctx->push(tag_boolean(bignum_equal_p(x,y)));
 }
 
 void factor_vm::primitive_bignum_add()
 {
        POP_BIGNUMS(x,y);
-       dpush(tag<bignum>(bignum_add(x,y)));
+       ctx->push(tag<bignum>(bignum_add(x,y)));
 }
 
 void factor_vm::primitive_bignum_subtract()
 {
        POP_BIGNUMS(x,y);
-       dpush(tag<bignum>(bignum_subtract(x,y)));
+       ctx->push(tag<bignum>(bignum_subtract(x,y)));
 }
 
 void factor_vm::primitive_bignum_multiply()
 {
        POP_BIGNUMS(x,y);
-       dpush(tag<bignum>(bignum_multiply(x,y)));
+       ctx->push(tag<bignum>(bignum_multiply(x,y)));
 }
 
 void factor_vm::primitive_bignum_divint()
 {
        POP_BIGNUMS(x,y);
-       dpush(tag<bignum>(bignum_quotient(x,y)));
+       ctx->push(tag<bignum>(bignum_quotient(x,y)));
 }
 
 void factor_vm::primitive_bignum_divmod()
@@ -137,85 +137,85 @@ void factor_vm::primitive_bignum_divmod()
        bignum *q, *r;
        POP_BIGNUMS(x,y);
        bignum_divide(x,y,&q,&r);
-       dpush(tag<bignum>(q));
-       dpush(tag<bignum>(r));
+       ctx->push(tag<bignum>(q));
+       ctx->push(tag<bignum>(r));
 }
 
 void factor_vm::primitive_bignum_mod()
 {
        POP_BIGNUMS(x,y);
-       dpush(tag<bignum>(bignum_remainder(x,y)));
+       ctx->push(tag<bignum>(bignum_remainder(x,y)));
 }
 
 void factor_vm::primitive_bignum_and()
 {
        POP_BIGNUMS(x,y);
-       dpush(tag<bignum>(bignum_bitwise_and(x,y)));
+       ctx->push(tag<bignum>(bignum_bitwise_and(x,y)));
 }
 
 void factor_vm::primitive_bignum_or()
 {
        POP_BIGNUMS(x,y);
-       dpush(tag<bignum>(bignum_bitwise_ior(x,y)));
+       ctx->push(tag<bignum>(bignum_bitwise_ior(x,y)));
 }
 
 void factor_vm::primitive_bignum_xor()
 {
        POP_BIGNUMS(x,y);
-       dpush(tag<bignum>(bignum_bitwise_xor(x,y)));
+       ctx->push(tag<bignum>(bignum_bitwise_xor(x,y)));
 }
 
 void factor_vm::primitive_bignum_shift()
 {
-       fixnum y = untag_fixnum(dpop());
-        bignum* x = untag<bignum>(dpop());
-       dpush(tag<bignum>(bignum_arithmetic_shift(x,y)));
+       fixnum y = untag_fixnum(ctx->pop());
+        bignum* x = untag<bignum>(ctx->pop());
+       ctx->push(tag<bignum>(bignum_arithmetic_shift(x,y)));
 }
 
 void factor_vm::primitive_bignum_less()
 {
        POP_BIGNUMS(x,y);
-       box_boolean(bignum_compare(x,y) == bignum_comparison_less);
+       ctx->push(tag_boolean(bignum_compare(x,y) == bignum_comparison_less));
 }
 
 void factor_vm::primitive_bignum_lesseq()
 {
        POP_BIGNUMS(x,y);
-       box_boolean(bignum_compare(x,y) != bignum_comparison_greater);
+       ctx->push(tag_boolean(bignum_compare(x,y) != bignum_comparison_greater));
 }
 
 void factor_vm::primitive_bignum_greater()
 {
        POP_BIGNUMS(x,y);
-       box_boolean(bignum_compare(x,y) == bignum_comparison_greater);
+       ctx->push(tag_boolean(bignum_compare(x,y) == bignum_comparison_greater));
 }
 
 void factor_vm::primitive_bignum_greatereq()
 {
        POP_BIGNUMS(x,y);
-       box_boolean(bignum_compare(x,y) != bignum_comparison_less);
+       ctx->push(tag_boolean(bignum_compare(x,y) != bignum_comparison_less));
 }
 
 void factor_vm::primitive_bignum_not()
 {
-       drepl(tag<bignum>(bignum_bitwise_not(untag<bignum>(dpeek()))));
+       ctx->replace(tag<bignum>(bignum_bitwise_not(untag<bignum>(ctx->peek()))));
 }
 
 void factor_vm::primitive_bignum_bitp()
 {
-       fixnum bit = to_fixnum(dpop());
-       bignum *x = untag<bignum>(dpop());
-       box_boolean(bignum_logbitp(bit,x));
+       fixnum bit = to_fixnum(ctx->pop());
+       bignum *x = untag<bignum>(ctx->pop());
+       ctx->push(tag_boolean(bignum_logbitp(bit,x)));
 }
 
 void factor_vm::primitive_bignum_log2()
 {
-       drepl(tag<bignum>(bignum_integer_length(untag<bignum>(dpeek()))));
+       ctx->replace(tag<bignum>(bignum_integer_length(untag<bignum>(ctx->peek()))));
 }
 
 unsigned int factor_vm::bignum_producer(unsigned int digit)
 {
-       unsigned char *ptr = (unsigned char *)alien_offset(dpeek());
+       unsigned char *ptr = (unsigned char *)alien_offset(ctx->peek());
        return *(ptr + digit);
 }
 
@@ -226,145 +226,146 @@ unsigned int bignum_producer(unsigned int digit, factor_vm *parent)
 
 void factor_vm::primitive_byte_array_to_bignum()
 {
-       cell n_digits = array_capacity(untag_check<byte_array>(dpeek()));
+       cell n_digits = array_capacity(untag_check<byte_array>(ctx->peek()));
        bignum * result = digit_stream_to_bignum(n_digits,factor::bignum_producer,0x100,0);
-       drepl(tag<bignum>(result));
+       ctx->replace(tag<bignum>(result));
 }
 
 cell factor_vm::unbox_array_size_slow()
 {
-       if(tagged<object>(dpeek()).type() == BIGNUM_TYPE)
+       if(tagged<object>(ctx->peek()).type() == BIGNUM_TYPE)
        {
                bignum *zero = untag<bignum>(bignum_zero);
                bignum *max = cell_to_bignum(array_size_max);
-               bignum *n = untag<bignum>(dpeek());
+               bignum *n = untag<bignum>(ctx->peek());
                if(bignum_compare(n,zero) != bignum_comparison_less
                        && bignum_compare(n,max) == bignum_comparison_less)
                {
-                       dpop();
+                       ctx->pop();
                        return bignum_to_cell(n);
                }
        }
 
-       general_error(ERROR_ARRAY_SIZE,dpop(),tag_fixnum(array_size_max),NULL);
+       general_error(ERROR_ARRAY_SIZE,ctx->pop(),tag_fixnum(array_size_max),NULL);
        return 0; /* can't happen */
 }
 
 void factor_vm::primitive_fixnum_to_float()
 {
-       drepl(allot_float(fixnum_to_float(dpeek())));
+       ctx->replace(allot_float(fixnum_to_float(ctx->peek())));
 }
 
 void factor_vm::primitive_bignum_to_float()
 {
-       drepl(allot_float(bignum_to_float(dpeek())));
+       ctx->replace(allot_float(bignum_to_float(ctx->peek())));
 }
 
 void factor_vm::primitive_str_to_float()
 {
-       byte_array *bytes = untag_check<byte_array>(dpeek());
+       byte_array *bytes = untag_check<byte_array>(ctx->peek());
        cell capacity = array_capacity(bytes);
 
        char *c_str = (char *)(bytes + 1);
        char *end = c_str;
        double f = strtod(c_str,&end);
        if(end == c_str + capacity - 1)
-               drepl(allot_float(f));
+               ctx->replace(allot_float(f));
        else
-               drepl(false_object);
+               ctx->replace(false_object);
 }
 
 void factor_vm::primitive_float_to_str()
 {
        byte_array *array = allot_byte_array(33);
-       snprintf((char *)(array + 1),32,"%.16g",untag_float_check(dpop()));
-       dpush(tag<byte_array>(array));
+       SNPRINTF((char *)(array + 1),32,"%.16g",untag_float_check(ctx->pop()));
+       ctx->push(tag<byte_array>(array));
 }
 
 #define POP_FLOATS(x,y) \
-       double y = untag_float(dpop()); \
-       double x = untag_float(dpop());
+       double y = untag_float(ctx->pop()); \
+       double x = untag_float(ctx->pop());
 
 void factor_vm::primitive_float_eq()
 {
        POP_FLOATS(x,y);
-       box_boolean(x == y);
+       ctx->push(tag_boolean(x == y));
 }
 
 void factor_vm::primitive_float_add()
 {
        POP_FLOATS(x,y);
-       box_double(x + y);
+       ctx->push(allot_float(x + y));
 }
 
 void factor_vm::primitive_float_subtract()
 {
        POP_FLOATS(x,y);
-       box_double(x - y);
+       ctx->push(allot_float(x - y));
 }
 
 void factor_vm::primitive_float_multiply()
 {
        POP_FLOATS(x,y);
-       box_double(x * y);
+       ctx->push(allot_float(x * y));
 }
 
 void factor_vm::primitive_float_divfloat()
 {
        POP_FLOATS(x,y);
-       box_double(x / y);
+       ctx->push(allot_float(x / y));
 }
 
 void factor_vm::primitive_float_mod()
 {
        POP_FLOATS(x,y);
-       box_double(fmod(x,y));
+       ctx->push(allot_float(fmod(x,y)));
 }
 
 void factor_vm::primitive_float_less()
 {
        POP_FLOATS(x,y);
-       box_boolean(x < y);
+       ctx->push(tag_boolean(x < y));
 }
 
 void factor_vm::primitive_float_lesseq()
 {
        POP_FLOATS(x,y);
-       box_boolean(x <= y);
+       ctx->push(tag_boolean(x <= y));
 }
 
 void factor_vm::primitive_float_greater()
 {
        POP_FLOATS(x,y);
-       box_boolean(x > y);
+       ctx->push(tag_boolean(x > y));
 }
 
 void factor_vm::primitive_float_greatereq()
 {
        POP_FLOATS(x,y);
-       box_boolean(x >= y);
+       ctx->push(tag_boolean(x >= y));
 }
 
 void factor_vm::primitive_float_bits()
 {
-       box_unsigned_4(float_bits(untag_float_check(dpop())));
+       ctx->push(from_unsigned_4(float_bits((float)untag_float_check(ctx->pop()))));
 }
 
 void factor_vm::primitive_bits_float()
 {
-       box_float(bits_float(to_cell(dpop())));
+       ctx->push(allot_float(bits_float(to_cell(ctx->pop()))));
 }
 
 void factor_vm::primitive_double_bits()
 {
-       box_unsigned_8(double_bits(untag_float_check(dpop())));
+       ctx->push(from_unsigned_8(double_bits(untag_float_check(ctx->pop()))));
 }
 
 void factor_vm::primitive_bits_double()
 {
-       box_double(bits_double(to_unsigned_8(dpop())));
+       ctx->push(allot_float(bits_double(to_unsigned_8(ctx->pop()))));
 }
 
+/* Cannot allocate */
 fixnum factor_vm::to_fixnum(cell tagged)
 {
        switch(TAG(tagged))
@@ -394,99 +395,100 @@ VM_C_API cell to_cell(cell tagged, factor_vm *parent)
        return parent->to_cell(tagged);
 }
 
-void factor_vm::box_signed_1(s8 n)
+cell factor_vm::from_signed_1(s8 n)
 {
-       dpush(tag_fixnum(n));
+       return tag_fixnum(n);
 }
 
-VM_C_API void box_signed_1(s8 n, factor_vm *parent)
+VM_C_API cell from_signed_1(s8 n, factor_vm *parent)
 {
-       return parent->box_signed_1(n);
+       return parent->from_signed_1(n);
 }
 
-void factor_vm::box_unsigned_1(u8 n)
+cell factor_vm::from_unsigned_1(u8 n)
 {
-       dpush(tag_fixnum(n));
+       return tag_fixnum(n);
 }
 
-VM_C_API void box_unsigned_1(u8 n, factor_vm *parent)
+VM_C_API cell from_unsigned_1(u8 n, factor_vm *parent)
 {
-       return parent->box_unsigned_1(n);
+       return parent->from_unsigned_1(n);
 }
 
-void factor_vm::box_signed_2(s16 n)
+cell factor_vm::from_signed_2(s16 n)
 {
-       dpush(tag_fixnum(n));
+       return tag_fixnum(n);
 }
 
-VM_C_API void box_signed_2(s16 n, factor_vm *parent)
+VM_C_API cell from_signed_2(s16 n, factor_vm *parent)
 {
-       return parent->box_signed_2(n);
+       return parent->from_signed_2(n);
 }
 
-void factor_vm::box_unsigned_2(u16 n)
+cell factor_vm::from_unsigned_2(u16 n)
 {
-       dpush(tag_fixnum(n));
+       return tag_fixnum(n);
 }
 
-VM_C_API void box_unsigned_2(u16 n, factor_vm *parent)
+VM_C_API cell from_unsigned_2(u16 n, factor_vm *parent)
 {
-       return parent->box_unsigned_2(n);
+       return parent->from_unsigned_2(n);
 }
 
-void factor_vm::box_signed_4(s32 n)
+cell factor_vm::from_signed_4(s32 n)
 {
-       dpush(allot_integer(n));
+       return allot_integer(n);
 }
 
-VM_C_API void box_signed_4(s32 n, factor_vm *parent)
+VM_C_API cell from_signed_4(s32 n, factor_vm *parent)
 {
-       return parent->box_signed_4(n);
+       return parent->from_signed_4(n);
 }
 
-void factor_vm::box_unsigned_4(u32 n)
+cell factor_vm::from_unsigned_4(u32 n)
 {
-       dpush(allot_cell(n));
+       return allot_cell(n);
 }
 
-VM_C_API void box_unsigned_4(u32 n, factor_vm *parent)
+VM_C_API cell from_unsigned_4(u32 n, factor_vm *parent)
 {
-       return parent->box_unsigned_4(n);
+       return parent->from_unsigned_4(n);
 }
 
-void factor_vm::box_signed_cell(fixnum integer)
+cell factor_vm::from_signed_cell(fixnum integer)
 {
-       dpush(allot_integer(integer));
+       return allot_integer(integer);
 }
 
-VM_C_API void box_signed_cell(fixnum integer, factor_vm *parent)
+cell factor_vm::from_unsigned_cell(cell integer)
 {
-       return parent->box_signed_cell(integer);
+       return allot_cell(integer);
 }
 
-void factor_vm::box_unsigned_cell(cell cell)
+VM_C_API cell from_signed_cell(fixnum integer, factor_vm *parent)
 {
-       dpush(allot_cell(cell));
+       return parent->from_signed_cell(integer);
 }
 
-VM_C_API void box_unsigned_cell(cell cell, factor_vm *parent)
+VM_C_API cell from_unsigned_cell(cell integer, factor_vm *parent)
 {
-       return parent->box_unsigned_cell(cell);
+       return parent->from_unsigned_cell(integer);
 }
 
-void factor_vm::box_signed_8(s64 n)
+cell factor_vm::from_signed_8(s64 n)
 {
        if(n < fixnum_min || n > fixnum_max)
-               dpush(tag<bignum>(long_long_to_bignum(n)));
+               return tag<bignum>(long_long_to_bignum(n));
        else
-               dpush(tag_fixnum(n));
+               return tag_fixnum((fixnum)n);
 }
 
-VM_C_API void box_signed_8(s64 n, factor_vm *parent)
+VM_C_API cell from_signed_8(s64 n, factor_vm *parent)
 {
-       return parent->box_signed_8(n);
+       return parent->from_signed_8(n);
 }
 
+/* Cannot allocate */
 s64 factor_vm::to_signed_8(cell obj)
 {
        switch(tagged<object>(obj).type())
@@ -506,19 +508,20 @@ VM_C_API s64 to_signed_8(cell obj, factor_vm *parent)
        return parent->to_signed_8(obj);
 }
 
-void factor_vm::box_unsigned_8(u64 n)
+cell factor_vm::from_unsigned_8(u64 n)
 {
        if(n > (u64)fixnum_max)
-               dpush(tag<bignum>(ulong_long_to_bignum(n)));
+               return tag<bignum>(ulong_long_to_bignum(n));
        else
-               dpush(tag_fixnum(n));
+               return tag_fixnum((fixnum)n);
 }
 
-VM_C_API void box_unsigned_8(u64 n, factor_vm *parent)
+VM_C_API cell from_unsigned_8(u64 n, factor_vm *parent)
 {
-       return parent->box_unsigned_8(n);
+       return parent->from_unsigned_8(n);
 }
 
+/* Cannot allocate */
 u64 factor_vm::to_unsigned_8(cell obj)
 {
        switch(tagged<object>(obj).type())
@@ -538,19 +541,15 @@ VM_C_API u64 to_unsigned_8(cell obj, factor_vm *parent)
        return parent->to_unsigned_8(obj);
 }
  
-void factor_vm::box_float(float flo)
+VM_C_API cell from_float(float flo, factor_vm *parent)
 {
-        dpush(allot_float(flo));
-}
-
-VM_C_API void box_float(float flo, factor_vm *parent)
-{
-       return parent->box_float(flo);
+       return parent->allot_float(flo);
 }
 
+/* Cannot allocate */
 float factor_vm::to_float(cell value)
 {
-       return untag_float_check(value);
+       return (float)untag_float_check(value);
 }
 
 VM_C_API float to_float(cell value, factor_vm *parent)
@@ -558,16 +557,12 @@ VM_C_API float to_float(cell value, factor_vm *parent)
        return parent->to_float(value);
 }
 
-void factor_vm::box_double(double flo)
-{
-        dpush(allot_float(flo));
-}
-
-VM_C_API void box_double(double flo, factor_vm *parent)
+VM_C_API cell from_double(double flo, factor_vm *parent)
 {
-       return parent->box_double(flo);
+       return parent->allot_float(flo);
 }
 
+/* Cannot allocate */
 double factor_vm::to_double(cell value)
 {
        return untag_float_check(value);
@@ -582,22 +577,22 @@ VM_C_API double to_double(cell value, factor_vm *parent)
 overflow, they call these functions. */
 inline void factor_vm::overflow_fixnum_add(fixnum x, fixnum y)
 {
-       drepl(tag<bignum>(fixnum_to_bignum(
+       ctx->replace(tag<bignum>(fixnum_to_bignum(
                untag_fixnum(x) + untag_fixnum(y))));
 }
 
-VM_ASM_API void overflow_fixnum_add(fixnum x, fixnum y, factor_vm *parent)
+VM_C_API void overflow_fixnum_add(fixnum x, fixnum y, factor_vm *parent)
 {
        parent->overflow_fixnum_add(x,y);
 }
 
 inline void factor_vm::overflow_fixnum_subtract(fixnum x, fixnum y)
 {
-       drepl(tag<bignum>(fixnum_to_bignum(
+       ctx->replace(tag<bignum>(fixnum_to_bignum(
                untag_fixnum(x) - untag_fixnum(y))));
 }
 
-VM_ASM_API void overflow_fixnum_subtract(fixnum x, fixnum y, factor_vm *parent)
+VM_C_API void overflow_fixnum_subtract(fixnum x, fixnum y, factor_vm *parent)
 {
        parent->overflow_fixnum_subtract(x,y);
 }
@@ -608,10 +603,10 @@ inline void factor_vm::overflow_fixnum_multiply(fixnum x, fixnum y)
        GC_BIGNUM(bx);
        bignum *by = fixnum_to_bignum(y);
        GC_BIGNUM(by);
-       drepl(tag<bignum>(bignum_multiply(bx,by)));
+       ctx->replace(tag<bignum>(bignum_multiply(bx,by)));
 }
 
-VM_ASM_API void overflow_fixnum_multiply(fixnum x, fixnum y, factor_vm *parent)
+VM_C_API void overflow_fixnum_multiply(fixnum x, fixnum y, factor_vm *parent)
 {
        parent->overflow_fixnum_multiply(x,y);
 }
index 2fed585f98075b597dba69a52ae7c7853d1af672..d78ae54010af1bbfb7027e9569c83668e537b86e 100644 (file)
@@ -60,13 +60,13 @@ inline double factor_vm::fixnum_to_float(cell tagged)
 
 inline cell factor_vm::unbox_array_size()
 {
-       cell obj = dpeek();
+       cell obj = ctx->peek();
        if(TAG(obj) == FIXNUM_TYPE)
        {
                fixnum n = untag_fixnum(obj);
                if(n >= 0 && n < (fixnum)array_size_max)
                {
-                       dpop();
+                       ctx->pop();
                        return n;
                }
        }
@@ -74,21 +74,21 @@ inline cell factor_vm::unbox_array_size()
        return unbox_array_size_slow();
 }
 
-VM_C_API void box_float(float flo, factor_vm *vm);
+VM_C_API cell from_float(float flo, factor_vm *vm);
 VM_C_API float to_float(cell value, factor_vm *vm);
-VM_C_API void box_double(double flo, factor_vm *vm);
+VM_C_API cell from_double(double flo, factor_vm *vm);
 VM_C_API double to_double(cell value, factor_vm *vm);
 
-VM_C_API void box_signed_1(s8 n, factor_vm *vm);
-VM_C_API void box_unsigned_1(u8 n, factor_vm *vm);
-VM_C_API void box_signed_2(s16 n, factor_vm *vm);
-VM_C_API void box_unsigned_2(u16 n, factor_vm *vm);
-VM_C_API void box_signed_4(s32 n, factor_vm *vm);
-VM_C_API void box_unsigned_4(u32 n, factor_vm *vm);
-VM_C_API void box_signed_cell(fixnum integer, factor_vm *vm);
-VM_C_API void box_unsigned_cell(cell cell, factor_vm *vm);
-VM_C_API void box_signed_8(s64 n, factor_vm *vm);
-VM_C_API void box_unsigned_8(u64 n, factor_vm *vm);
+VM_C_API cell from_signed_1(s8 n, factor_vm *vm);
+VM_C_API cell from_unsigned_1(u8 n, factor_vm *vm);
+VM_C_API cell from_signed_2(s16 n, factor_vm *vm);
+VM_C_API cell from_unsigned_2(u16 n, factor_vm *vm);
+VM_C_API cell from_signed_4(s32 n, factor_vm *vm);
+VM_C_API cell from_unsigned_4(u32 n, factor_vm *vm);
+VM_C_API cell from_signed_cell(fixnum integer, factor_vm *vm);
+VM_C_API cell from_unsigned_cell(cell integer, factor_vm *vm);
+VM_C_API cell from_signed_8(s64 n, factor_vm *vm);
+VM_C_API cell from_unsigned_8(u64 n, factor_vm *vm);
 
 VM_C_API s64 to_signed_8(cell obj, factor_vm *vm);
 VM_C_API u64 to_unsigned_8(cell obj, factor_vm *vm);
@@ -96,8 +96,8 @@ VM_C_API u64 to_unsigned_8(cell obj, factor_vm *vm);
 VM_C_API fixnum to_fixnum(cell tagged, factor_vm *vm);
 VM_C_API cell to_cell(cell tagged, factor_vm *vm);
 
-VM_ASM_API void overflow_fixnum_add(fixnum x, fixnum y, factor_vm *vm);
-VM_ASM_API void overflow_fixnum_subtract(fixnum x, fixnum y, factor_vm *vm);
-VM_ASM_API void overflow_fixnum_multiply(fixnum x, fixnum y, factor_vm *vm);
+VM_C_API void overflow_fixnum_add(fixnum x, fixnum y, factor_vm *parent);
+VM_C_API void overflow_fixnum_subtract(fixnum x, fixnum y, factor_vm *parent);
+VM_C_API void overflow_fixnum_multiply(fixnum x, fixnum y, factor_vm *parent);
 
 }
index 155da243d42d997af072a966bbf4a82b3795777e..062aa6aed33294b8f4b0bf092eefaabfc848a52b 100644 (file)
@@ -22,9 +22,12 @@ void factor_vm::collect_nursery()
        collector.trace_cards(data->tenured,
                card_points_to_nursery,
                simple_unmarker(card_points_to_nursery));
-       collector.trace_cards(data->aging,
-               card_points_to_nursery,
-               full_unmarker());
+       if(data->aging->here != data->aging->start)
+       {
+               collector.trace_cards(data->aging,
+                       card_points_to_nursery,
+                       full_unmarker());
+       }
        current_gc->event->ended_card_scan(collector.cards_scanned,collector.decks_scanned);
 
        current_gc->event->started_code_scan();
@@ -33,10 +36,6 @@ void factor_vm::collect_nursery()
 
        collector.cheneys_algorithm();
 
-       current_gc->event->started_code_sweep();
-       update_code_heap_for_minor_gc(&code->points_to_nursery);
-       current_gc->event->ended_code_sweep();
-
        data->reset_generation(&nursery);
        code->points_to_nursery.clear();
 }
index 724f365e794a404c29aa40b5f8962a3525dd8b52..6b5b5139b9082ee4e3d86707037d13c1dd1b0112 100644 (file)
@@ -60,7 +60,7 @@ void object_start_map::update_card_for_sweep(cell index, u16 mask)
        cell offset = object_start_offsets[index];
        if(offset != card_starts_inside_object)
        {
-               mask >>= (offset / block_granularity);
+               mask >>= (offset / data_alignment);
 
                if(mask == 0)
                {
@@ -70,7 +70,7 @@ void object_start_map::update_card_for_sweep(cell index, u16 mask)
                else
                {
                        /* Move the object start forward if necessary */
-                       object_start_offsets[index] = offset + (rightmost_set_bit(mask) * block_granularity);
+                       object_start_offsets[index] = (card)(offset + (rightmost_set_bit(mask) * data_alignment));
                }
        }
 }
@@ -79,11 +79,16 @@ void object_start_map::update_for_sweep(mark_bits<object> *state)
 {
        for(cell index = 0; index < state->bits_size; index++)
        {
-               u64 mask = state->marked[index];
+               cell mask = state->marked[index];
+#ifdef FACTOR_64
                update_card_for_sweep(index * 4,      mask        & 0xffff);
                update_card_for_sweep(index * 4 + 1, (mask >> 16) & 0xffff);
                update_card_for_sweep(index * 4 + 2, (mask >> 32) & 0xffff);
                update_card_for_sweep(index * 4 + 3, (mask >> 48) & 0xffff);
+#else
+               update_card_for_sweep(index * 2,      mask        & 0xffff);
+               update_card_for_sweep(index * 2 + 1, (mask >> 16) & 0xffff);
+#endif
        }
 }
 
diff --git a/vm/objects.cpp b/vm/objects.cpp
new file mode 100644 (file)
index 0000000..21948e5
--- /dev/null
@@ -0,0 +1,150 @@
+#include "master.hpp"
+
+namespace factor
+{
+
+void factor_vm::primitive_special_object()
+{
+       fixnum e = untag_fixnum(ctx->peek());
+       ctx->replace(special_objects[e]);
+}
+
+void factor_vm::primitive_set_special_object()
+{
+       fixnum e = untag_fixnum(ctx->pop());
+       cell value = ctx->pop();
+       special_objects[e] = value;
+}
+
+void factor_vm::primitive_identity_hashcode()
+{
+       cell tagged = ctx->peek();
+       object *obj = untag<object>(tagged);
+       ctx->replace(tag_fixnum(obj->hashcode()));
+}
+
+void factor_vm::compute_identity_hashcode(object *obj)
+{
+       object_counter++;
+       if(object_counter == 0) object_counter++;
+       obj->set_hashcode((cell)obj ^ object_counter);
+}
+
+void factor_vm::primitive_compute_identity_hashcode()
+{
+       object *obj = untag<object>(ctx->pop());
+       compute_identity_hashcode(obj);
+}
+
+void factor_vm::primitive_set_slot()
+{
+       fixnum slot = untag_fixnum(ctx->pop());
+       object *obj = untag<object>(ctx->pop());
+       cell value = ctx->pop();
+
+       cell *slot_ptr = &obj->slots()[slot];
+       *slot_ptr = value;
+       write_barrier(slot_ptr);
+}
+
+cell factor_vm::clone_object(cell obj_)
+{
+       data_root<object> obj(obj_,this);
+
+       if(immediate_p(obj.value()))
+               return obj.value();
+       else
+       {
+               cell size = object_size(obj.value());
+               object *new_obj = allot_object(obj.type(),size);
+               memcpy(new_obj,obj.untagged(),size);
+               new_obj->set_hashcode(0);
+               return tag_dynamic(new_obj);
+       }
+}
+
+void factor_vm::primitive_clone()
+{
+       ctx->replace(clone_object(ctx->peek()));
+}
+
+/* Size of the object pointed to by a tagged pointer */
+cell factor_vm::object_size(cell tagged)
+{
+       if(immediate_p(tagged))
+               return 0;
+       else
+               return untag<object>(tagged)->size();
+}
+
+void factor_vm::primitive_size()
+{
+       ctx->push(allot_cell(object_size(ctx->pop())));
+}
+
+struct slot_become_visitor {
+       std::map<object *,object *> *become_map;
+
+       explicit slot_become_visitor(std::map<object *,object *> *become_map_) :
+               become_map(become_map_) {}
+
+       object *operator()(object *old)
+       {
+               std::map<object *,object *>::const_iterator iter = become_map->find(old);
+               if(iter != become_map->end())
+                       return iter->second;
+               else
+                       return old;
+       }
+};
+
+struct object_become_visitor {
+       slot_visitor<slot_become_visitor> *workhorse;
+
+       explicit object_become_visitor(slot_visitor<slot_become_visitor> *workhorse_) :
+               workhorse(workhorse_) {}
+
+       void operator()(object *obj)
+       {
+               workhorse->visit_slots(obj);
+       }
+};
+
+/* classes.tuple uses this to reshape tuples; tools.deploy.shaker uses this
+   to coalesce equal but distinct quotations and wrappers. */
+void factor_vm::primitive_become()
+{
+       array *new_objects = untag_check<array>(ctx->pop());
+       array *old_objects = untag_check<array>(ctx->pop());
+
+       cell capacity = array_capacity(new_objects);
+       if(capacity != array_capacity(old_objects))
+               critical_error("bad parameters to become",0);
+
+       /* Build the forwarding map */
+       std::map<object *,object *> become_map;
+
+       for(cell i = 0; i < capacity; i++)
+       {
+               tagged<object> old_obj(array_nth(old_objects,i));
+               tagged<object> new_obj(array_nth(new_objects,i));
+
+               if(old_obj != new_obj)
+                       become_map[old_obj.untagged()] = new_obj.untagged();
+       }
+
+       /* Update all references to old objects to point to new objects */
+       slot_visitor<slot_become_visitor> workhorse(this,slot_become_visitor(&become_map));
+       workhorse.visit_roots();
+       workhorse.visit_contexts();
+
+       object_become_visitor object_visitor(&workhorse);
+       each_object(object_visitor);
+
+       /* Since we may have introduced old->new references, need to revisit
+       all objects on a minor GC. */
+       data->mark_all_cards();
+       primitive_minor_gc();
+}
+
+}
diff --git a/vm/objects.hpp b/vm/objects.hpp
new file mode 100644 (file)
index 0000000..fdc5758
--- /dev/null
@@ -0,0 +1,125 @@
+namespace factor
+{
+
+static const cell special_object_count = 70;
+
+enum special_object {
+       OBJ_NAMESTACK,             /* used by library only */
+       OBJ_CATCHSTACK,            /* used by library only, per-callback */
+
+       OBJ_CURRENT_CALLBACK = 2,  /* used by library only, per-callback */
+       OBJ_WALKER_HOOK,           /* non-local exit hook, used by library only */
+       OBJ_CALLCC_1,              /* used to pass the value in callcc1 */
+
+       ERROR_HANDLER_QUOT = 5,    /* quotation called when VM throws an error */
+       OBJ_ERROR,                 /* a marker consed onto kernel errors */
+
+       OBJ_CELL_SIZE = 7,         /* sizeof(cell) */
+       OBJ_CPU,                   /* CPU architecture */
+       OBJ_OS,                    /* operating system name */
+
+       OBJ_ARGS = 10,             /* command line arguments */
+       OBJ_STDIN,                 /* stdin FILE* handle */
+       OBJ_STDOUT,                /* stdout FILE* handle */
+
+       OBJ_IMAGE = 13,            /* image path name */
+       OBJ_EXECUTABLE,            /* runtime executable path name */
+
+       OBJ_EMBEDDED = 15,         /* are we embedded in another app? */
+       OBJ_EVAL_CALLBACK,         /* used when Factor is embedded in a C app */
+       OBJ_YIELD_CALLBACK,        /* used when Factor is embedded in a C app */
+       OBJ_SLEEP_CALLBACK,        /* used when Factor is embedded in a C app */
+
+       OBJ_COCOA_EXCEPTION = 19,  /* Cocoa exception handler quotation */
+
+       OBJ_STARTUP_QUOT = 20,     /* startup quotation */
+       OBJ_GLOBAL,                /* global namespace */
+       OBJ_SHUTDOWN_QUOT,         /* shutdown quotation */
+
+       /* Quotation compilation in quotations.c */
+       JIT_PROLOG = 23,
+       JIT_PRIMITIVE_WORD,
+       JIT_PRIMITIVE,
+       JIT_WORD_JUMP,
+       JIT_WORD_CALL,
+       JIT_IF_WORD,
+       JIT_IF,
+       JIT_EPILOG,
+       JIT_RETURN,
+       JIT_PROFILING,
+       JIT_PUSH_IMMEDIATE,
+       JIT_DIP_WORD,
+       JIT_DIP,
+       JIT_2DIP_WORD,
+       JIT_2DIP,
+       JIT_3DIP_WORD,
+       JIT_3DIP,
+       JIT_EXECUTE,
+       JIT_DECLARE_WORD,
+
+       /* External entry points */
+       C_TO_FACTOR_WORD,
+       LAZY_JIT_COMPILE_WORD,
+       UNWIND_NATIVE_FRAMES_WORD,
+
+       /* Incremented on every modify-code-heap call; invalidates call( inline
+       caching */
+       REDEFINITION_COUNTER = 47,
+
+       /* Callback stub generation in callbacks.c */
+       CALLBACK_STUB = 48,
+       
+       /* Polymorphic inline cache generation in inline_cache.c */
+       PIC_LOAD = 49,
+       PIC_TAG,
+       PIC_TUPLE,
+       PIC_CHECK_TAG,
+       PIC_CHECK_TUPLE,
+       PIC_HIT,
+       PIC_MISS_WORD,
+       PIC_MISS_TAIL_WORD,
+
+       /* Megamorphic cache generation in dispatch.c */
+       MEGA_LOOKUP = 57,
+       MEGA_LOOKUP_WORD,
+       MEGA_MISS_WORD,
+
+       OBJ_UNDEFINED = 60,       /* default quotation for undefined words */
+
+       OBJ_STDERR = 61,          /* stderr FILE* handle */
+
+       OBJ_STAGE2 = 62,          /* have we bootstrapped? */
+
+       OBJ_CURRENT_THREAD = 63,
+
+       OBJ_THREADS = 64,
+       OBJ_RUN_QUEUE = 65,
+       OBJ_SLEEP_QUEUE = 66,
+};
+
+/* save-image-and-exit discards special objects that are filled in on startup
+anyway, to reduce image size */
+#define OBJ_FIRST_SAVE OBJ_STARTUP_QUOT
+#define OBJ_LAST_SAVE OBJ_STAGE2
+
+inline static bool save_special_p(cell i)
+{
+       return (i >= OBJ_FIRST_SAVE && i <= OBJ_LAST_SAVE);
+}
+
+template<typename Iterator> void object::each_slot(Iterator &iter)
+{
+       cell scan = (cell)this;
+       cell payload_start = binary_payload_start();
+       cell end = scan + payload_start;
+
+       scan += sizeof(cell);
+
+       while(scan < end)
+       {
+               iter((cell *)scan);
+               scan += sizeof(cell);
+       }
+}
+
+}
index 065f0dfd4094174d49603976bedac5ad43359fdc..301b68fb528bb96ce302f5d3b54675a12110c4bb 100644 (file)
@@ -1,11 +1,12 @@
 #include "master.hpp"
+#include <time.h>
 
 namespace factor
 {
 
 void factor_vm::c_to_factor_toplevel(cell quot)
 {
-       c_to_factor(quot,this);
+       c_to_factor(quot);
 }
 
 void init_signals()
@@ -34,4 +35,14 @@ const char *default_image_path()
        return new_path;
 }
 
+u64 nano_count()
+{
+       struct timespec t;
+       int ret;
+       ret = clock_gettime(CLOCK_MONOTONIC,&t);
+       if(ret != 0)
+               fatal_error("clock_gettime failed", 0);
+       return (u64)t.tv_sec * 1000000000 + t.tv_nsec;
+}
+
 }
index 438957bd047ff2c765b3a2d75d5bff0f537cb814..92694a4599a19770b1db16807189e9221c9d0901 100644 (file)
@@ -1,5 +1,6 @@
 #import <Cocoa/Cocoa.h>
 
+#include <mach/mach_time.h>
 #include "master.hpp"
 
 namespace factor
@@ -10,15 +11,15 @@ void factor_vm::c_to_factor_toplevel(cell quot)
        for(;;)
        {
 NS_DURING
-               c_to_factor(quot,this);
+               c_to_factor(quot);
                NS_VOIDRETURN;
 NS_HANDLER
-               dpush(allot_alien(false_object,(cell)localException));
+               ctx->push(allot_alien(false_object,(cell)localException));
                quot = special_objects[OBJ_COCOA_EXCEPTION];
                if(!tagged<object>(quot).type_p(QUOTATION_TYPE))
                {
                        /* No Cocoa exception handler was registered, so
-                       extra/cocoa/ is not loaded. So we pass the exception
+                       basis/cocoa/ is not loaded. So we pass the exception
                        along. */
                        [localException raise];
                }
@@ -30,7 +31,7 @@ void early_init(void)
 {
        SInt32 version;
        Gestalt(gestaltSystemVersion,&version);
-       if(version <= 0x1050)
+       if(version < 0x1050)
        {
                printf("Factor requires Mac OS X 10.5 or later.\n");
                exit(1);
@@ -84,4 +85,16 @@ Protocol *objc_getProtocol(char *name)
                return nil;
 }
 
+u64 nano_count()
+{
+       u64 t;
+       mach_timebase_info_data_t info;
+       kern_return_t ret;
+       t = mach_absolute_time();
+       ret = mach_timebase_info(&info);
+       if(ret != 0)
+               fatal_error("mach_timebase_info failed",ret);
+       return t * (info.numer/info.denom);
+}
+
 }
index cd885411369fc83c6b4715e4f349b60442edca82..4b5040ab8bd0d88c8a8abf2c2ae4af35589a7a82 100644 (file)
@@ -40,16 +40,29 @@ factor_vm *tls_vm()
 
 static void *null_dll;
 
-s64 current_micros()
+u64 system_micros()
 {
        struct timeval t;
        gettimeofday(&t,NULL);
-       return (s64)t.tv_sec * 1000000 + t.tv_usec;
+       return (u64)t.tv_sec * 1000000 + t.tv_usec;
 }
 
-void sleep_micros(cell usec)
+void sleep_nanos(u64 nsec)
 {
-       usleep(usec);
+       timespec ts;
+       timespec ts_rem;
+       int ret;
+       ts.tv_sec = nsec / 1000000000;
+       ts.tv_nsec = nsec % 1000000000;
+       ret = nanosleep(&ts,&ts_rem);
+       while(ret == -1 && errno == EINTR)
+       {
+               memcpy(&ts, &ts_rem, sizeof(ts));
+               ret = nanosleep(&ts, &ts_rem);
+       }
+
+       if(ret == -1)
+               fatal_error("nanosleep failed", 0);
 }
 
 void factor_vm::init_ffi()
@@ -60,27 +73,27 @@ void factor_vm::init_ffi()
 
 void factor_vm::ffi_dlopen(dll *dll)
 {
-       dll->dll = dlopen(alien_offset(dll->path), RTLD_LAZY);
+       dll->handle = dlopen(alien_offset(dll->path), RTLD_LAZY);
 }
 
 void *factor_vm::ffi_dlsym(dll *dll, symbol_char *symbol)
 {
-       void *handle = (dll == NULL ? null_dll : dll->dll);
+       void *handle = (dll == NULL ? null_dll : dll->handle);
        return dlsym(handle,symbol);
 }
 
 void factor_vm::ffi_dlclose(dll *dll)
 {
-       if(dlclose(dll->dll))
+       if(dlclose(dll->handle))
                general_error(ERROR_FFI,false_object,false_object,NULL);
-       dll->dll = NULL;
+       dll->handle = NULL;
 }
 
 void factor_vm::primitive_existsp()
 {
        struct stat sb;
-       char *path = (char *)(untag_check<byte_array>(dpop()) + 1);
-       box_boolean(stat(path,&sb) >= 0);
+       char *path = (char *)(untag_check<byte_array>(ctx->pop()) + 1);
+       ctx->push(tag_boolean(stat(path,&sb) >= 0));
 }
 
 segment::segment(cell size_, bool executable_p)
index 05ab8b1120e3a4f29219aadb8d3d307074bd7882..7faab4d8b85ec505da5e5cba7ac49c14d267e102 100644 (file)
@@ -22,22 +22,13 @@ typedef char symbol_char;
 #define STRCMP strcmp
 #define STRNCMP strncmp
 #define STRDUP strdup
+#define SNPRINTF snprintf
 
 #define FTELL ftello
 #define FSEEK fseeko
 
-#define FIXNUM_FORMAT "%ld"
-#define CELL_FORMAT "%lu"
 #define CELL_HEX_FORMAT "%lx"
 
-#ifdef FACTOR_64
-       #define CELL_HEX_PAD_FORMAT "%016lx"
-#else
-       #define CELL_HEX_PAD_FORMAT "%08lx"
-#endif
-
-#define FIXNUM_FORMAT "%ld"
-
 #define OPEN_READ(path) fopen(path,"rb")
 #define OPEN_WRITE(path) fopen(path,"wb")
 
@@ -52,8 +43,9 @@ void unix_init_signals();
 void signal_handler(int signal, siginfo_t* siginfo, void* uap);
 void dump_stack_signal(int signal, siginfo_t* siginfo, void* uap);
 
-s64 current_micros();
-void sleep_micros(cell usec);
+u64 system_micros();
+u64 nano_count();
+void sleep_nanos(u64 nsec);
 
 void init_platform_globals();
 
index f51953e6ebf737337465103f9132990810b92244..a57db667c421b76c549ad604b0681cb735c59e70 100644 (file)
@@ -3,7 +3,7 @@
 namespace factor
 {
 
-s64 current_micros()
+u64 system_micros()
 {
        SYSTEMTIME st;
        FILETIME ft;
old mode 100644 (file)
new mode 100755 (executable)
index f41262e..02de1cd
@@ -12,7 +12,6 @@ typedef wchar_t symbol_char;
 
 #define FACTOR_OS_STRING "wince"
 #define FACTOR_DLL L"factor-ce.dll"
-#define FACTOR_DLL_NAME "factor-ce.dll"
 
 int errno;
 char *strerror(int err);
@@ -22,7 +21,7 @@ char *getenv(char *name);
 #define snprintf _snprintf
 #define snwprintf _snwprintf
 
-s64 current_micros();
+u64 system_micros();
 void c_to_factor_toplevel(cell quot);
 void open_console();
 
index 0c5ddd99e19b40ae46eebe4e8606e78243cf0e79..2fceb130f4e8eb29be189ff8d6515c5fe3be3d5f 100755 (executable)
@@ -3,8 +3,9 @@
 namespace factor
 {
 
-THREADHANDLE start_thread(void *(*start_routine)(void *),void *args){
-    return (void*) CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)start_routine, args, 0, 0); 
+THREADHANDLE start_thread(void *(*start_routine)(void *), void *args)
+{
+       return (void *)CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)start_routine, args, 0, 0);
 }
 
 DWORD dwTlsIndex; 
@@ -28,14 +29,42 @@ factor_vm *tls_vm()
        return vm;
 }
 
-s64 current_micros()
+u64 system_micros()
 {
        FILETIME t;
        GetSystemTimeAsFileTime(&t);
-       return (((s64)t.dwLowDateTime | (s64)t.dwHighDateTime<<32)
+       return (((u64)t.dwLowDateTime | (u64)t.dwHighDateTime<<32)
                - EPOCH_OFFSET) / 10;
 }
 
+/* On VirtualBox, QueryPerformanceCounter does not increment
+the high part every time the low part overflows.  Workaround. */
+u64 nano_count()
+{
+       LARGE_INTEGER count;
+       LARGE_INTEGER frequency;
+       static u32 hi = 0;
+       static u32 lo = 0;
+       BOOL ret;
+       ret = QueryPerformanceCounter(&count);
+       if(ret == 0)
+               fatal_error("QueryPerformanceCounter", 0);
+       ret = QueryPerformanceFrequency(&frequency);
+       if(ret == 0)
+               fatal_error("QueryPerformanceFrequency", 0);
+
+       if(count.LowPart < lo)
+               hi += 1;
+       lo = count.LowPart;
+
+       return (u64)((((u64)hi << 32) | (u64)lo)*(1000000000.0/frequency.QuadPart));
+}
+
+void sleep_nanos(u64 nsec)
+{
+       Sleep((DWORD)(nsec/1000000));
+}
+
 LONG factor_vm::exception_handler(PEXCEPTION_POINTERS pe)
 {
        PEXCEPTION_RECORD e = (PEXCEPTION_RECORD)pe->ExceptionRecord;
@@ -83,21 +112,18 @@ LONG factor_vm::exception_handler(PEXCEPTION_POINTERS pe)
        return EXCEPTION_CONTINUE_EXECUTION;
 }
 
-FACTOR_STDCALL LONG exception_handler(PEXCEPTION_POINTERS pe)
+FACTOR_STDCALL(LONG) exception_handler(PEXCEPTION_POINTERS pe)
 {
        return tls_vm()->exception_handler(pe);
 }
 
-bool handler_added = 0;
-
 void factor_vm::c_to_factor_toplevel(cell quot)
 {
-       if(!handler_added){
-               if(!AddVectoredExceptionHandler(0, (PVECTORED_EXCEPTION_HANDLER)factor::exception_handler))
-                       fatal_error("AddVectoredExceptionHandler failed", 0);
-               handler_added = 1;
-       }
-       c_to_factor(quot,this);
+       if(!AddVectoredExceptionHandler(0, (PVECTORED_EXCEPTION_HANDLER)factor::exception_handler))
+               fatal_error("AddVectoredExceptionHandler failed", 0);
+
+       c_to_factor(quot);
+
        RemoveVectoredExceptionHandler((void *)factor::exception_handler);
 }
 
index 5b55ce1f2b7a5f27942a143a1b1a30fa50ae80cf..8ad34ed147c7011d1eb94363343c82a7183043bf 100755 (executable)
@@ -8,23 +8,37 @@
 #include <windows.h>
 #include <shellapi.h>
 
+#ifdef _MSC_VER
+       #undef min
+       #undef max
+#endif
+
 namespace factor
 {
 
 typedef char symbol_char;
 
 #define FACTOR_OS_STRING "winnt"
+
 #define FACTOR_DLL L"factor.dll"
-#define FACTOR_DLL_NAME "factor.dll"
 
-#define FACTOR_STDCALL __attribute__((stdcall))
+#ifdef _MSC_VER
+       #define FACTOR_STDCALL(return_type) return_type __stdcall
+#else
+       #define FACTOR_STDCALL(return_type) __attribute__((stdcall)) return_type
+#endif
 
-FACTOR_STDCALL LONG exception_handler(PEXCEPTION_POINTERS pe);
+FACTOR_STDCALL(LONG) exception_handler(PEXCEPTION_POINTERS pe);
 
 // SSE traps raise these exception codes, which are defined in internal NT headers
 // but not winbase.h
+#ifndef STATUS_FLOAT_MULTIPLE_FAULTS
 #define STATUS_FLOAT_MULTIPLE_FAULTS 0xC00002B4
+#endif
+
+#ifndef STATUS_FLOAT_MULTIPLE_TRAPS
 #define STATUS_FLOAT_MULTIPLE_TRAPS  0xC00002B5
+#endif
 
 typedef HANDLE THREADHANDLE;
 
index 48745584d3c29ee8d4513e635cdfff08a4b0975c..df2a57f2e80de2aa3fa51fd00675d57f4086b93c 100755 (executable)
@@ -9,26 +9,26 @@ void factor_vm::init_ffi()
 {
        hFactorDll = GetModuleHandle(FACTOR_DLL);
        if(!hFactorDll)
-               fatal_error("GetModuleHandle(\"" FACTOR_DLL_NAME "\") failed", 0);
+               fatal_error("GetModuleHandle() failed", 0);
 }
 
 void factor_vm::ffi_dlopen(dll *dll)
 {
-       dll->dll = LoadLibraryEx((WCHAR *)alien_offset(dll->path), NULL, 0);
+       dll->handle = LoadLibraryEx((WCHAR *)alien_offset(dll->path), NULL, 0);
 }
 
 void *factor_vm::ffi_dlsym(dll *dll, symbol_char *symbol)
 {
-       return (void *)GetProcAddress(dll ? (HMODULE)dll->dll : hFactorDll, symbol);
+       return (void *)GetProcAddress(dll ? (HMODULE)dll->handle : hFactorDll, symbol);
 }
 
 void factor_vm::ffi_dlclose(dll *dll)
 {
-       FreeLibrary((HMODULE)dll->dll);
-       dll->dll = NULL;
+       FreeLibrary((HMODULE)dll->handle);
+       dll->handle = NULL;
 }
 
-bool factor_vm::windows_stat(vm_char *path)
+BOOL factor_vm::windows_stat(vm_char *path)
 {
        BY_HANDLE_FILE_INFORMATION bhfi;
        HANDLE h = CreateFileW(path,
@@ -50,15 +50,14 @@ bool factor_vm::windows_stat(vm_char *path)
                FindClose(h);
                return true;
        }
-       bool ret;
-       ret = GetFileInformationByHandle(h, &bhfi);
+       BOOL ret = GetFileInformationByHandle(h, &bhfi);
        CloseHandle(h);
        return ret;
 }
 
 void factor_vm::windows_image_path(vm_char *full_path, vm_char *temp_path, unsigned int length)
 {
-       snwprintf(temp_path, length-1, L"%s.image", full_path); 
+       SNWPRINTF(temp_path, length-1, L"%s.image", full_path); 
        temp_path[length - 1] = 0;
 }
 
@@ -75,7 +74,7 @@ const vm_char *factor_vm::default_image_path()
        if((ptr = wcsrchr(full_path, '.')))
                *ptr = 0;
 
-       snwprintf(temp_path, MAX_UNICODE_PATH-1, L"%s.image", full_path); 
+       SNWPRINTF(temp_path, MAX_UNICODE_PATH-1, L"%s.image", full_path); 
        temp_path[MAX_UNICODE_PATH - 1] = 0;
 
        return safe_strdup(temp_path);
@@ -92,8 +91,8 @@ const vm_char *factor_vm::vm_executable_path()
 
 void factor_vm::primitive_existsp()
 {
-       vm_char *path = untag_check<byte_array>(dpop())->data<vm_char>();
-       box_boolean(windows_stat(path));
+       vm_char *path = untag_check<byte_array>(ctx->pop())->data<vm_char>();
+       ctx->push(tag_boolean(windows_stat(path)));
 }
 
 segment::segment(cell size_, bool executable_p)
@@ -126,11 +125,6 @@ segment::~segment()
                fatal_error("Segment deallocation failed",0);
 }
 
-void factor_vm::sleep_micros(u64 usec)
-{
-       Sleep((DWORD)(usec / 1000));
-}
-
 long getpagesize()
 {
        static long g_pagesize = 0;
old mode 100644 (file)
new mode 100755 (executable)
index 403842b..8a2dfe3
@@ -1,8 +1,8 @@
 #include <ctype.h>
 
 #ifndef wcslen
-  /* for cygwin */
-  #include <wchar.h>
+       /* for cygwin */
+       #include <wchar.h>
 #endif
 
 namespace factor
@@ -18,20 +18,23 @@ typedef wchar_t vm_char;
 #define STRCMP wcscmp
 #define STRNCMP wcsncmp
 #define STRDUP _wcsdup
-#define MIN(a,b) ((a)>(b)?(b):(a))
-#define FTELL ftello64
-#define FSEEK fseeko64
+
+#ifdef _MSC_VER
+       #define FTELL ftell
+       #define FSEEK fseek
+       #define SNPRINTF _snprintf
+       #define SNWPRINTF _snwprintf
+#else
+       #define FTELL ftello64
+       #define FSEEK fseeko64
+       #define SNPRINTF snprintf
+       #define SNWPRINTF snwprintf
+#endif
 
 #ifdef WIN64
-       #define CELL_FORMAT "%Iu"
        #define CELL_HEX_FORMAT "%Ix"
-       #define CELL_HEX_PAD_FORMAT "%016Ix"
-       #define FIXNUM_FORMAT "%Id"
 #else
-       #define CELL_FORMAT "%lu"
        #define CELL_HEX_FORMAT "%lx"
-       #define CELL_HEX_PAD_FORMAT "%08lx"
-       #define FIXNUM_FORMAT "%ld"
 #endif
 
 #define OPEN_READ(path) _wfopen(path,L"rb")
@@ -43,7 +46,9 @@ typedef wchar_t vm_char;
 inline static void init_signals() {}
 inline static void early_init() {}
 
-s64 current_micros();
+u64 system_micros();
+u64 nano_count();
+void sleep_nanos(u64 nsec);
 long getpagesize();
 
 }
old mode 100644 (file)
new mode 100755 (executable)
index 7b4356a..2a38c91
@@ -1,27 +1,20 @@
-#if defined(__arm__)
-       #define FACTOR_ARM
-#elif defined(__amd64__) || defined(__x86_64__)
-       #define FACTOR_AMD64
-#elif defined(i386) || defined(__i386) || defined(__i386__) || defined(WIN32)
-       #define FACTOR_X86
-#elif defined(__POWERPC__) || defined(__ppc__) || defined(_ARCH_PPC)
-       #define FACTOR_PPC
-#else
-       #error "Unsupported architecture"
-#endif
-
 #if defined(WINDOWS)
        #if defined(WINCE)
                #include "os-windows-ce.hpp"
-       #else
+               #include "os-windows.hpp"
+       #elif defined(WINNT)
                #include "os-windows-nt.hpp"
-       #endif
+               #include "os-windows.hpp"
 
-       #include "os-windows.hpp"
-       #if defined(FACTOR_AMD64)
-               #include "os-windows-nt.64.hpp"
-       #elif defined(FACTOR_X86)
-               #include "os-windows-nt.32.hpp"
+               #if defined(FACTOR_AMD64)
+                       #include "os-windows-nt.64.hpp"
+               #elif defined(FACTOR_X86)
+                       #include "os-windows-nt.32.hpp"
+               #else
+                       #error "Unsupported Windows flavor"
+               #endif
+       #else
+               #error "Unsupported Windows flavor"
        #endif
 #else
        #include "os-unix.hpp"
index 957e6128ed4a75a09e71d4a5b9c33c7adfb4b54e..f288a796c282e6eba79b9341b2bbd8ead4f747b0 100644 (file)
 namespace factor
 {
 
-PRIMITIVE_FORWARD(bignum_to_fixnum)
-PRIMITIVE_FORWARD(float_to_fixnum)
-PRIMITIVE_FORWARD(fixnum_to_bignum)
-PRIMITIVE_FORWARD(float_to_bignum)
-PRIMITIVE_FORWARD(fixnum_to_float)
-PRIMITIVE_FORWARD(bignum_to_float)
-PRIMITIVE_FORWARD(str_to_float)
-PRIMITIVE_FORWARD(float_to_str)
-PRIMITIVE_FORWARD(float_bits)
-PRIMITIVE_FORWARD(double_bits)
-PRIMITIVE_FORWARD(bits_float)
-PRIMITIVE_FORWARD(bits_double)
-PRIMITIVE_FORWARD(fixnum_divint)
-PRIMITIVE_FORWARD(fixnum_divmod)
-PRIMITIVE_FORWARD(fixnum_shift)
-PRIMITIVE_FORWARD(bignum_eq)
-PRIMITIVE_FORWARD(bignum_add)
-PRIMITIVE_FORWARD(bignum_subtract)
-PRIMITIVE_FORWARD(bignum_multiply)
-PRIMITIVE_FORWARD(bignum_divint)
-PRIMITIVE_FORWARD(bignum_mod)
-PRIMITIVE_FORWARD(bignum_divmod)
-PRIMITIVE_FORWARD(bignum_and)
-PRIMITIVE_FORWARD(bignum_or)
-PRIMITIVE_FORWARD(bignum_xor)
-PRIMITIVE_FORWARD(bignum_not)
-PRIMITIVE_FORWARD(bignum_shift)
-PRIMITIVE_FORWARD(bignum_less)
-PRIMITIVE_FORWARD(bignum_lesseq)
-PRIMITIVE_FORWARD(bignum_greater)
-PRIMITIVE_FORWARD(bignum_greatereq)
-PRIMITIVE_FORWARD(bignum_bitp)
-PRIMITIVE_FORWARD(bignum_log2)
-PRIMITIVE_FORWARD(byte_array_to_bignum)
-PRIMITIVE_FORWARD(float_eq)
-PRIMITIVE_FORWARD(float_add)
-PRIMITIVE_FORWARD(float_subtract)
-PRIMITIVE_FORWARD(float_multiply)
-PRIMITIVE_FORWARD(float_divfloat)
-PRIMITIVE_FORWARD(float_mod)
-PRIMITIVE_FORWARD(float_less)
-PRIMITIVE_FORWARD(float_lesseq)
-PRIMITIVE_FORWARD(float_greater)
-PRIMITIVE_FORWARD(float_greatereq)
-PRIMITIVE_FORWARD(word)
-PRIMITIVE_FORWARD(word_xt)
-PRIMITIVE_FORWARD(getenv)
-PRIMITIVE_FORWARD(setenv)
-PRIMITIVE_FORWARD(existsp)
-PRIMITIVE_FORWARD(minor_gc)
-PRIMITIVE_FORWARD(full_gc)
-PRIMITIVE_FORWARD(compact_gc)
-PRIMITIVE_FORWARD(save_image)
-PRIMITIVE_FORWARD(save_image_and_exit)
-PRIMITIVE_FORWARD(datastack)
-PRIMITIVE_FORWARD(retainstack)
-PRIMITIVE_FORWARD(callstack)
-PRIMITIVE_FORWARD(set_datastack)
-PRIMITIVE_FORWARD(set_retainstack)
-PRIMITIVE_FORWARD(set_callstack)
-PRIMITIVE_FORWARD(exit)
-PRIMITIVE_FORWARD(data_room)
-PRIMITIVE_FORWARD(code_room)
-PRIMITIVE_FORWARD(micros)
-PRIMITIVE_FORWARD(modify_code_heap)
-PRIMITIVE_FORWARD(dlopen)
-PRIMITIVE_FORWARD(dlsym)
-PRIMITIVE_FORWARD(dlclose)
-PRIMITIVE_FORWARD(byte_array)
-PRIMITIVE_FORWARD(uninitialized_byte_array)
-PRIMITIVE_FORWARD(displaced_alien)
-PRIMITIVE_FORWARD(alien_address)
-PRIMITIVE_FORWARD(set_slot)
-PRIMITIVE_FORWARD(string_nth)
-PRIMITIVE_FORWARD(set_string_nth_fast)
-PRIMITIVE_FORWARD(set_string_nth_slow)
-PRIMITIVE_FORWARD(resize_array)
-PRIMITIVE_FORWARD(resize_string)
-PRIMITIVE_FORWARD(array)
-PRIMITIVE_FORWARD(begin_scan)
-PRIMITIVE_FORWARD(next_object)
-PRIMITIVE_FORWARD(end_scan)
-PRIMITIVE_FORWARD(size)
-PRIMITIVE_FORWARD(die)
-PRIMITIVE_FORWARD(fopen)
-PRIMITIVE_FORWARD(fgetc)
-PRIMITIVE_FORWARD(fread)
-PRIMITIVE_FORWARD(fputc)
-PRIMITIVE_FORWARD(fwrite)
-PRIMITIVE_FORWARD(fflush)
-PRIMITIVE_FORWARD(ftell)
-PRIMITIVE_FORWARD(fseek)
-PRIMITIVE_FORWARD(fclose)
-PRIMITIVE_FORWARD(wrapper)
-PRIMITIVE_FORWARD(clone)
-PRIMITIVE_FORWARD(string)
-PRIMITIVE_FORWARD(array_to_quotation)
-PRIMITIVE_FORWARD(quotation_xt)
-PRIMITIVE_FORWARD(tuple)
-PRIMITIVE_FORWARD(profiling)
-PRIMITIVE_FORWARD(become)
-PRIMITIVE_FORWARD(sleep)
-PRIMITIVE_FORWARD(tuple_boa)
-PRIMITIVE_FORWARD(callstack_to_array)
-PRIMITIVE_FORWARD(innermost_stack_frame_executing)
-PRIMITIVE_FORWARD(innermost_stack_frame_scan)
-PRIMITIVE_FORWARD(set_innermost_stack_frame_quot)
-PRIMITIVE_FORWARD(call_clear)
-PRIMITIVE_FORWARD(resize_byte_array)
-PRIMITIVE_FORWARD(dll_validp)
-PRIMITIVE_FORWARD(unimplemented)
-PRIMITIVE_FORWARD(jit_compile)
-PRIMITIVE_FORWARD(load_locals)
-PRIMITIVE_FORWARD(check_datastack)
-PRIMITIVE_FORWARD(mega_cache_miss)
-PRIMITIVE_FORWARD(lookup_method)
-PRIMITIVE_FORWARD(reset_dispatch_stats)
-PRIMITIVE_FORWARD(dispatch_stats)
-PRIMITIVE_FORWARD(optimized_p)
-PRIMITIVE_FORWARD(quot_compiled_p)
-PRIMITIVE_FORWARD(vm_ptr)
-PRIMITIVE_FORWARD(strip_stack_traces)
-PRIMITIVE_FORWARD(callback)
-PRIMITIVE_FORWARD(enable_gc_events)
-PRIMITIVE_FORWARD(disable_gc_events)
+#define PRIMITIVE(name) VM_C_API void primitive_##name(factor_vm *parent) \
+{ \
+       parent->primitive_##name(); \
+}
 
-const primitive_type primitives[] = {
-       primitive_bignum_to_fixnum,
-       primitive_float_to_fixnum,
-       primitive_fixnum_to_bignum,
-       primitive_float_to_bignum,
-       primitive_fixnum_to_float,
-       primitive_bignum_to_float,
-       primitive_str_to_float,
-       primitive_float_to_str,
-       primitive_float_bits,
-       primitive_double_bits,
-       primitive_bits_float,
-       primitive_bits_double,
-       primitive_fixnum_add,
-       primitive_fixnum_subtract,
-       primitive_fixnum_multiply,
-       primitive_fixnum_divint,
-       primitive_fixnum_divmod,
-       primitive_fixnum_shift,
-       primitive_bignum_eq,
-       primitive_bignum_add,
-       primitive_bignum_subtract,
-       primitive_bignum_multiply,
-       primitive_bignum_divint,
-       primitive_bignum_mod,
-       primitive_bignum_divmod,
-       primitive_bignum_and,
-       primitive_bignum_or,
-       primitive_bignum_xor,
-       primitive_bignum_not,
-       primitive_bignum_shift,
-       primitive_bignum_less,
-       primitive_bignum_lesseq,
-       primitive_bignum_greater,
-       primitive_bignum_greatereq,
-       primitive_bignum_bitp,
-       primitive_bignum_log2,
-       primitive_byte_array_to_bignum,
-       primitive_float_eq,
-       primitive_float_add,
-       primitive_float_subtract,
-       primitive_float_multiply,
-       primitive_float_divfloat,
-       primitive_float_mod,
-       primitive_float_less,
-       primitive_float_lesseq,
-       primitive_float_greater,
-       primitive_float_greatereq,
-       /* The unordered comparison primitives don't have a non-optimizing
-       compiler implementation */
-       primitive_float_less,
-       primitive_float_lesseq,
-       primitive_float_greater,
-       primitive_float_greatereq,
-       primitive_word,
-       primitive_word_xt,
-       primitive_getenv,
-       primitive_setenv,
-       primitive_existsp,
-       primitive_minor_gc,
-       primitive_full_gc,
-       primitive_compact_gc,
-       primitive_save_image,
-       primitive_save_image_and_exit,
-       primitive_datastack,
-       primitive_retainstack,
-       primitive_callstack,
-       primitive_set_datastack,
-       primitive_set_retainstack,
-       primitive_set_callstack,
-       primitive_exit,
-       primitive_data_room,
-       primitive_code_room,
-       primitive_micros,
-       primitive_modify_code_heap,
-       primitive_dlopen,
-       primitive_dlsym,
-       primitive_dlclose,
-       primitive_byte_array,
-       primitive_uninitialized_byte_array,
-       primitive_displaced_alien,
-       primitive_alien_signed_cell,
-       primitive_set_alien_signed_cell,
-       primitive_alien_unsigned_cell,
-       primitive_set_alien_unsigned_cell,
-       primitive_alien_signed_8,
-       primitive_set_alien_signed_8,
-       primitive_alien_unsigned_8,
-       primitive_set_alien_unsigned_8,
-       primitive_alien_signed_4,
-       primitive_set_alien_signed_4,
-       primitive_alien_unsigned_4,
-       primitive_set_alien_unsigned_4,
-       primitive_alien_signed_2,
-       primitive_set_alien_signed_2,
-       primitive_alien_unsigned_2,
-       primitive_set_alien_unsigned_2,
-       primitive_alien_signed_1,
-       primitive_set_alien_signed_1,
-       primitive_alien_unsigned_1,
-       primitive_set_alien_unsigned_1,
-       primitive_alien_float,
-       primitive_set_alien_float,
-       primitive_alien_double,
-       primitive_set_alien_double,
-       primitive_alien_cell,
-       primitive_set_alien_cell,
-       primitive_alien_address,
-       primitive_set_slot,
-       primitive_string_nth,
-       primitive_set_string_nth_fast,
-       primitive_set_string_nth_slow,
-       primitive_resize_array,
-       primitive_resize_string,
-       primitive_array,
-       primitive_begin_scan,
-       primitive_next_object,
-       primitive_end_scan,
-       primitive_size,
-       primitive_die,
-       primitive_fopen,
-       primitive_fgetc,
-       primitive_fread,
-       primitive_fputc,
-       primitive_fwrite,
-       primitive_fflush,
-       primitive_ftell,
-       primitive_fseek,
-       primitive_fclose,
-       primitive_wrapper,
-       primitive_clone,
-       primitive_string,
-       primitive_array_to_quotation,
-       primitive_quotation_xt,
-       primitive_tuple,
-       primitive_profiling,
-       primitive_become,
-       primitive_sleep,
-       primitive_tuple_boa,
-       primitive_callstack_to_array,
-       primitive_innermost_stack_frame_executing,
-       primitive_innermost_stack_frame_scan,
-       primitive_set_innermost_stack_frame_quot,
-       primitive_call_clear,
-       primitive_resize_byte_array,
-       primitive_dll_validp,
-       primitive_unimplemented,
-       primitive_jit_compile,
-       primitive_load_locals,
-       primitive_check_datastack,
-       primitive_inline_cache_miss,
-       primitive_inline_cache_miss_tail,
-       primitive_mega_cache_miss,
-       primitive_lookup_method,
-       primitive_reset_dispatch_stats,
-       primitive_dispatch_stats,
-       primitive_optimized_p,
-       primitive_quot_compiled_p,
-       primitive_vm_ptr,
-       primitive_strip_stack_traces,
-       primitive_callback,
-       primitive_enable_gc_events,
-       primitive_disable_gc_events,
-};
+PRIMITIVE(alien_address)
+PRIMITIVE(all_instances)
+PRIMITIVE(array)
+PRIMITIVE(array_to_quotation)
+PRIMITIVE(become)
+PRIMITIVE(bignum_add)
+PRIMITIVE(bignum_and)
+PRIMITIVE(bignum_bitp)
+PRIMITIVE(bignum_divint)
+PRIMITIVE(bignum_divmod)
+PRIMITIVE(bignum_eq)
+PRIMITIVE(bignum_greater)
+PRIMITIVE(bignum_greatereq)
+PRIMITIVE(bignum_less)
+PRIMITIVE(bignum_lesseq)
+PRIMITIVE(bignum_log2)
+PRIMITIVE(bignum_mod)
+PRIMITIVE(bignum_multiply)
+PRIMITIVE(bignum_not)
+PRIMITIVE(bignum_or)
+PRIMITIVE(bignum_shift)
+PRIMITIVE(bignum_subtract)
+PRIMITIVE(bignum_to_fixnum)
+PRIMITIVE(bignum_to_float)
+PRIMITIVE(bignum_xor)
+PRIMITIVE(bits_double)
+PRIMITIVE(bits_float)
+PRIMITIVE(byte_array)
+PRIMITIVE(byte_array_to_bignum)
+PRIMITIVE(call_clear)
+PRIMITIVE(callback)
+PRIMITIVE(callstack)
+PRIMITIVE(callstack_to_array)
+PRIMITIVE(check_datastack)
+PRIMITIVE(clone)
+PRIMITIVE(code_room)
+PRIMITIVE(compact_gc)
+PRIMITIVE(compute_identity_hashcode)
+PRIMITIVE(data_room)
+PRIMITIVE(datastack)
+PRIMITIVE(die)
+PRIMITIVE(disable_gc_events)
+PRIMITIVE(dispatch_stats)
+PRIMITIVE(displaced_alien)
+PRIMITIVE(dlclose)
+PRIMITIVE(dll_validp)
+PRIMITIVE(dlopen)
+PRIMITIVE(dlsym)
+PRIMITIVE(double_bits)
+PRIMITIVE(enable_gc_events)
+PRIMITIVE(existsp)
+PRIMITIVE(exit)
+PRIMITIVE(fclose)
+PRIMITIVE(fflush)
+PRIMITIVE(fgetc)
+PRIMITIVE(fixnum_divint)
+PRIMITIVE(fixnum_divmod)
+PRIMITIVE(fixnum_shift)
+PRIMITIVE(fixnum_to_bignum)
+PRIMITIVE(fixnum_to_float)
+PRIMITIVE(float_add)
+PRIMITIVE(float_bits)
+PRIMITIVE(float_divfloat)
+PRIMITIVE(float_eq)
+PRIMITIVE(float_greater)
+PRIMITIVE(float_greatereq)
+PRIMITIVE(float_less)
+PRIMITIVE(float_lesseq)
+PRIMITIVE(float_mod)
+PRIMITIVE(float_multiply)
+PRIMITIVE(float_subtract)
+PRIMITIVE(float_to_bignum)
+PRIMITIVE(float_to_fixnum)
+PRIMITIVE(float_to_str)
+PRIMITIVE(fopen)
+PRIMITIVE(fputc)
+PRIMITIVE(fread)
+PRIMITIVE(fseek)
+PRIMITIVE(ftell)
+PRIMITIVE(full_gc)
+PRIMITIVE(fwrite)
+PRIMITIVE(identity_hashcode)
+PRIMITIVE(innermost_stack_frame_executing)
+PRIMITIVE(innermost_stack_frame_scan)
+PRIMITIVE(jit_compile)
+PRIMITIVE(load_locals)
+PRIMITIVE(lookup_method)
+PRIMITIVE(mega_cache_miss)
+PRIMITIVE(minor_gc)
+PRIMITIVE(modify_code_heap)
+PRIMITIVE(nano_count)
+PRIMITIVE(optimized_p)
+PRIMITIVE(profiling)
+PRIMITIVE(quot_compiled_p)
+PRIMITIVE(quotation_code)
+PRIMITIVE(reset_dispatch_stats)
+PRIMITIVE(resize_array)
+PRIMITIVE(resize_byte_array)
+PRIMITIVE(resize_string)
+PRIMITIVE(retainstack)
+PRIMITIVE(save_image)
+PRIMITIVE(save_image_and_exit)
+PRIMITIVE(set_datastack)
+PRIMITIVE(set_innermost_stack_frame_quot)
+PRIMITIVE(set_retainstack)
+PRIMITIVE(set_slot)
+PRIMITIVE(set_special_object)
+PRIMITIVE(set_string_nth_fast)
+PRIMITIVE(set_string_nth_slow)
+PRIMITIVE(size)
+PRIMITIVE(sleep)
+PRIMITIVE(special_object)
+PRIMITIVE(str_to_float)
+PRIMITIVE(string)
+PRIMITIVE(string_nth)
+PRIMITIVE(strip_stack_traces)
+PRIMITIVE(system_micros)
+PRIMITIVE(tuple)
+PRIMITIVE(tuple_boa)
+PRIMITIVE(unimplemented)
+PRIMITIVE(uninitialized_byte_array)
+PRIMITIVE(word)
+PRIMITIVE(word_code)
+PRIMITIVE(wrapper)
 
 }
index 8e4efd8d1427af078119ab18bb0541464faedaf0..1ace3c0f7e7a271ce0498fbc4a8bae819911033f 100644 (file)
 namespace factor
 {
 
-#if defined(FACTOR_X86)
-  extern "C" __attribute__ ((regparm (1))) typedef void (*primitive_type)(factor_vm *parent);
-  #define PRIMITIVE(name) extern "C" __attribute__ ((regparm (1)))  void primitive_##name(factor_vm *parent)
-  #define PRIMITIVE_FORWARD(name) extern "C" __attribute__ ((regparm (1)))  void primitive_##name(factor_vm *parent) \
-  { \
-       parent->primitive_##name(); \
-  }
-#else
-  extern "C" typedef void (*primitive_type)(factor_vm *parent);
-  #define PRIMITIVE(name) extern "C" void primitive_##name(factor_vm *parent)
-  #define PRIMITIVE_FORWARD(name) extern "C" void primitive_##name(factor_vm *parent) \
-  { \
-       parent->primitive_##name(); \
-  }
-#endif
-extern const primitive_type primitives[];
+#define DECLARE_PRIMITIVE(name) VM_C_API void primitive_##name(factor_vm *parent);
 
-/* These are defined in assembly */
-PRIMITIVE(fixnum_add);
-PRIMITIVE(fixnum_subtract);
-PRIMITIVE(fixnum_multiply);
-PRIMITIVE(inline_cache_miss);
-PRIMITIVE(inline_cache_miss_tail);
+/* Generated with PRIMITIVE in primitives.cpp */
+DECLARE_PRIMITIVE(alien_address)
+DECLARE_PRIMITIVE(all_instances)
+DECLARE_PRIMITIVE(array)
+DECLARE_PRIMITIVE(array_to_quotation)
+DECLARE_PRIMITIVE(become)
+DECLARE_PRIMITIVE(bignum_add)
+DECLARE_PRIMITIVE(bignum_and)
+DECLARE_PRIMITIVE(bignum_bitp)
+DECLARE_PRIMITIVE(bignum_divint)
+DECLARE_PRIMITIVE(bignum_divmod)
+DECLARE_PRIMITIVE(bignum_eq)
+DECLARE_PRIMITIVE(bignum_greater)
+DECLARE_PRIMITIVE(bignum_greatereq)
+DECLARE_PRIMITIVE(bignum_less)
+DECLARE_PRIMITIVE(bignum_lesseq)
+DECLARE_PRIMITIVE(bignum_log2)
+DECLARE_PRIMITIVE(bignum_mod)
+DECLARE_PRIMITIVE(bignum_multiply)
+DECLARE_PRIMITIVE(bignum_not)
+DECLARE_PRIMITIVE(bignum_or)
+DECLARE_PRIMITIVE(bignum_shift)
+DECLARE_PRIMITIVE(bignum_subtract)
+DECLARE_PRIMITIVE(bignum_to_fixnum)
+DECLARE_PRIMITIVE(bignum_to_float)
+DECLARE_PRIMITIVE(bignum_xor)
+DECLARE_PRIMITIVE(bits_double)
+DECLARE_PRIMITIVE(bits_float)
+DECLARE_PRIMITIVE(byte_array)
+DECLARE_PRIMITIVE(byte_array_to_bignum)
+DECLARE_PRIMITIVE(call_clear)
+DECLARE_PRIMITIVE(callback)
+DECLARE_PRIMITIVE(callstack)
+DECLARE_PRIMITIVE(callstack_to_array)
+DECLARE_PRIMITIVE(check_datastack)
+DECLARE_PRIMITIVE(clone)
+DECLARE_PRIMITIVE(code_room)
+DECLARE_PRIMITIVE(compact_gc)
+DECLARE_PRIMITIVE(compute_identity_hashcode)
+DECLARE_PRIMITIVE(data_room)
+DECLARE_PRIMITIVE(datastack)
+DECLARE_PRIMITIVE(die)
+DECLARE_PRIMITIVE(disable_gc_events)
+DECLARE_PRIMITIVE(dispatch_stats)
+DECLARE_PRIMITIVE(displaced_alien)
+DECLARE_PRIMITIVE(dlclose)
+DECLARE_PRIMITIVE(dll_validp)
+DECLARE_PRIMITIVE(dlopen)
+DECLARE_PRIMITIVE(dlsym)
+DECLARE_PRIMITIVE(double_bits)
+DECLARE_PRIMITIVE(enable_gc_events)
+DECLARE_PRIMITIVE(existsp)
+DECLARE_PRIMITIVE(exit)
+DECLARE_PRIMITIVE(fclose)
+DECLARE_PRIMITIVE(fflush)
+DECLARE_PRIMITIVE(fgetc)
+DECLARE_PRIMITIVE(fixnum_divint)
+DECLARE_PRIMITIVE(fixnum_divmod)
+DECLARE_PRIMITIVE(fixnum_shift)
+DECLARE_PRIMITIVE(fixnum_to_bignum)
+DECLARE_PRIMITIVE(fixnum_to_float)
+DECLARE_PRIMITIVE(float_add)
+DECLARE_PRIMITIVE(float_bits)
+DECLARE_PRIMITIVE(float_divfloat)
+DECLARE_PRIMITIVE(float_eq)
+DECLARE_PRIMITIVE(float_greater)
+DECLARE_PRIMITIVE(float_greatereq)
+DECLARE_PRIMITIVE(float_less)
+DECLARE_PRIMITIVE(float_lesseq)
+DECLARE_PRIMITIVE(float_mod)
+DECLARE_PRIMITIVE(float_multiply)
+DECLARE_PRIMITIVE(float_subtract)
+DECLARE_PRIMITIVE(float_to_bignum)
+DECLARE_PRIMITIVE(float_to_fixnum)
+DECLARE_PRIMITIVE(float_to_str)
+DECLARE_PRIMITIVE(fopen)
+DECLARE_PRIMITIVE(fputc)
+DECLARE_PRIMITIVE(fread)
+DECLARE_PRIMITIVE(fseek)
+DECLARE_PRIMITIVE(ftell)
+DECLARE_PRIMITIVE(full_gc)
+DECLARE_PRIMITIVE(fwrite)
+DECLARE_PRIMITIVE(identity_hashcode)
+DECLARE_PRIMITIVE(innermost_stack_frame_executing)
+DECLARE_PRIMITIVE(innermost_stack_frame_scan)
+DECLARE_PRIMITIVE(jit_compile)
+DECLARE_PRIMITIVE(load_locals)
+DECLARE_PRIMITIVE(lookup_method)
+DECLARE_PRIMITIVE(mega_cache_miss)
+DECLARE_PRIMITIVE(minor_gc)
+DECLARE_PRIMITIVE(modify_code_heap)
+DECLARE_PRIMITIVE(nano_count)
+DECLARE_PRIMITIVE(optimized_p)
+DECLARE_PRIMITIVE(profiling)
+DECLARE_PRIMITIVE(quot_compiled_p)
+DECLARE_PRIMITIVE(quotation_code)
+DECLARE_PRIMITIVE(reset_dispatch_stats)
+DECLARE_PRIMITIVE(resize_array)
+DECLARE_PRIMITIVE(resize_byte_array)
+DECLARE_PRIMITIVE(resize_string)
+DECLARE_PRIMITIVE(retainstack)
+DECLARE_PRIMITIVE(save_image)
+DECLARE_PRIMITIVE(save_image_and_exit)
+DECLARE_PRIMITIVE(set_datastack)
+DECLARE_PRIMITIVE(set_innermost_stack_frame_quot)
+DECLARE_PRIMITIVE(set_retainstack)
+DECLARE_PRIMITIVE(set_slot)
+DECLARE_PRIMITIVE(set_special_object)
+DECLARE_PRIMITIVE(set_string_nth_fast)
+DECLARE_PRIMITIVE(set_string_nth_slow)
+DECLARE_PRIMITIVE(size)
+DECLARE_PRIMITIVE(sleep)
+DECLARE_PRIMITIVE(special_object)
+DECLARE_PRIMITIVE(str_to_float)
+DECLARE_PRIMITIVE(string)
+DECLARE_PRIMITIVE(string_nth)
+DECLARE_PRIMITIVE(strip_stack_traces)
+DECLARE_PRIMITIVE(system_micros)
+DECLARE_PRIMITIVE(tuple)
+DECLARE_PRIMITIVE(tuple_boa)
+DECLARE_PRIMITIVE(unimplemented)
+DECLARE_PRIMITIVE(uninitialized_byte_array)
+DECLARE_PRIMITIVE(word)
+DECLARE_PRIMITIVE(word_code)
+DECLARE_PRIMITIVE(wrapper)
 
-/* These are generated with macros in alien.c */
-PRIMITIVE(alien_signed_cell);
-PRIMITIVE(set_alien_signed_cell);
-PRIMITIVE(alien_unsigned_cell);
-PRIMITIVE(set_alien_unsigned_cell);
-PRIMITIVE(alien_signed_8);
-PRIMITIVE(set_alien_signed_8);
-PRIMITIVE(alien_unsigned_8);
-PRIMITIVE(set_alien_unsigned_8);
-PRIMITIVE(alien_signed_4);
-PRIMITIVE(set_alien_signed_4);
-PRIMITIVE(alien_unsigned_4);
-PRIMITIVE(set_alien_unsigned_4);
-PRIMITIVE(alien_signed_2);
-PRIMITIVE(set_alien_signed_2);
-PRIMITIVE(alien_unsigned_2);
-PRIMITIVE(set_alien_unsigned_2);
-PRIMITIVE(alien_signed_1);
-PRIMITIVE(set_alien_signed_1);
-PRIMITIVE(alien_unsigned_1);
-PRIMITIVE(set_alien_unsigned_1);
-PRIMITIVE(alien_float);
-PRIMITIVE(set_alien_float);
-PRIMITIVE(alien_double);
-PRIMITIVE(set_alien_double);
-PRIMITIVE(alien_cell);
-PRIMITIVE(set_alien_cell);
+/* These are generated with macros in alien.cpp, and not with PRIMIIVE in
+primitives.cpp */
+DECLARE_PRIMITIVE(alien_signed_cell)
+DECLARE_PRIMITIVE(set_alien_signed_cell)
+DECLARE_PRIMITIVE(alien_unsigned_cell)
+DECLARE_PRIMITIVE(set_alien_unsigned_cell)
+DECLARE_PRIMITIVE(alien_signed_8)
+DECLARE_PRIMITIVE(set_alien_signed_8)
+DECLARE_PRIMITIVE(alien_unsigned_8)
+DECLARE_PRIMITIVE(set_alien_unsigned_8)
+DECLARE_PRIMITIVE(alien_signed_4)
+DECLARE_PRIMITIVE(set_alien_signed_4)
+DECLARE_PRIMITIVE(alien_unsigned_4)
+DECLARE_PRIMITIVE(set_alien_unsigned_4)
+DECLARE_PRIMITIVE(alien_signed_2)
+DECLARE_PRIMITIVE(set_alien_signed_2)
+DECLARE_PRIMITIVE(alien_unsigned_2)
+DECLARE_PRIMITIVE(set_alien_unsigned_2)
+DECLARE_PRIMITIVE(alien_signed_1)
+DECLARE_PRIMITIVE(set_alien_signed_1)
+DECLARE_PRIMITIVE(alien_unsigned_1)
+DECLARE_PRIMITIVE(set_alien_unsigned_1)
+DECLARE_PRIMITIVE(alien_float)
+DECLARE_PRIMITIVE(set_alien_float)
+DECLARE_PRIMITIVE(alien_double)
+DECLARE_PRIMITIVE(set_alien_double)
+DECLARE_PRIMITIVE(alien_cell)
+DECLARE_PRIMITIVE(set_alien_cell)
 
 }
index 50e88cc57ad9c55f2a1d261a22593f37341752d4..fea78692eac3e91f70f7c372503beba87a240b6c 100755 (executable)
@@ -14,7 +14,7 @@ code_block *factor_vm::compile_profiling_stub(cell word_)
        data_root<word> word(word_,this);
 
        jit jit(code_block_profiling,word.value(),this);
-       jit.emit_with(special_objects[JIT_PROFILING],word.value());
+       jit.emit_with_literal(special_objects[JIT_PROFILING],word.value());
 
        return jit.to_code_block();
 }
@@ -25,22 +25,34 @@ void factor_vm::set_profiling(bool profiling)
        if(profiling == profiling_p)
                return;
 
-       profiling_p = profiling;
-
        /* Push everything to tenured space so that we can heap scan
        and allocate profiling blocks if necessary */
        primitive_full_gc();
 
        data_root<array> words(find_all_words(),this);
 
-       cell i;
+       profiling_p = profiling;
+
        cell length = array_capacity(words.untagged());
-       for(i = 0; i < length; i++)
+       for(cell i = 0; i < length; i++)
        {
                tagged<word> word(array_nth(words.untagged(),i));
+
+               /* Note: can't do w->profiling = ... since LHS evaluates
+               before RHS, and if RHS does a GC, we will have an
+               invalid pointer on the LHS */
                if(profiling)
+               {
+                       if(!word->profiling)
+                       {
+                               code_block *profiling_block = compile_profiling_stub(word.value());
+                               word->profiling = profiling_block;
+                       }
+
                        word->counter = tag_fixnum(0);
-               update_word_xt(word.untagged());
+               }
+
+               update_word_entry_point(word.untagged());
        }
 
        update_code_heap_words();
@@ -48,7 +60,7 @@ void factor_vm::set_profiling(bool profiling)
 
 void factor_vm::primitive_profiling()
 {
-       set_profiling(to_boolean(dpop()));
+       set_profiling(to_boolean(ctx->pop()));
 }
 
 }
index fc19266cee1876fa8c3750fc583ee39526554383..faa770c5122432f0a5d3016f0716aa1df1462e8c 100755 (executable)
@@ -36,9 +36,14 @@ includes stack shufflers, some fixnum arithmetic words, and words such as tag,
 slot and eq?. A primitive call is relatively expensive (two subroutine calls)
 so this results in a big speedup for relatively little effort. */
 
+void quotation_jit::init_quotation(cell quot)
+{
+       elements = untag<quotation>(quot)->array;
+}
+
 bool quotation_jit::primitive_call_p(cell i, cell length)
 {
-       return (i + 2) == length && array_nth(elements.untagged(),i + 1) == parent->special_objects[JIT_PRIMITIVE_WORD];
+       return (i + 2) <= length && array_nth(elements.untagged(),i + 1) == parent->special_objects[JIT_PRIMITIVE_WORD];
 }
 
 bool quotation_jit::fast_if_p(cell i, cell length)
@@ -77,18 +82,23 @@ bool quotation_jit::declare_p(cell i, cell length)
                && array_nth(elements.untagged(),i + 1) == parent->special_objects[JIT_DECLARE_WORD];
 }
 
+bool quotation_jit::word_stack_frame_p(cell obj)
+{
+       return to_boolean(untag<word>(obj)->subprimitive)
+               || obj == parent->special_objects[JIT_PRIMITIVE_WORD];
+}
+
 bool quotation_jit::stack_frame_p()
 {
        fixnum length = array_capacity(elements.untagged());
-       fixnum i;
 
-       for(i = 0; i < length - 1; i++)
+       for(fixnum i = 0; i < length; i++)
        {
                cell obj = array_nth(elements.untagged(),i);
                switch(tagged<object>(obj).type())
                {
                case WORD_TYPE:
-                       if(!parent->to_boolean(untag<word>(obj)->subprimitive))
+                       if(i != length - 1 || word_stack_frame_p(obj))
                                return true;
                        break;
                case QUOTATION_TYPE:
@@ -120,7 +130,7 @@ void quotation_jit::emit_quot(cell quot_)
                literal(array_nth(elements,0));
        else
        {
-               if(compiling) parent->jit_compile(quot.value(),relocate);
+               if(compiling) parent->jit_compile_quot(quot.value(),relocate);
                literal(quot.value());
        }
 }
@@ -148,64 +158,41 @@ void quotation_jit::iterate_quotation()
                switch(obj.type())
                {
                case WORD_TYPE:
-                       /* Intrinsics */
-                       if(parent->to_boolean(obj.as<word>()->subprimitive))
-                               emit_subprimitive(obj.value());
-                       /* The (execute) primitive is special-cased */
-                       else if(obj.value() == parent->special_objects[JIT_EXECUTE_WORD])
+                       /* Sub-primitives */
+                       if(to_boolean(obj.as<word>()->subprimitive))
                        {
-                               if(i == length - 1)
-                               {
-                                       if(stack_frame) emit(parent->special_objects[JIT_EPILOG]);
-                                       tail_call = true;
-                                       emit(parent->special_objects[JIT_EXECUTE_JUMP]);
-                               }
-                               else
-                                       emit(parent->special_objects[JIT_EXECUTE_CALL]);
+                               tail_call = emit_subprimitive(obj.value(), /* word */
+                                       i == length - 1, /* tail_call_p */
+                                       stack_frame); /* stack_frame_p */
                        }
                        /* Everything else */
-                       else
+                       else if(i == length - 1)
                        {
-                               if(i == length - 1)
-                               {
-                                       if(stack_frame) emit(parent->special_objects[JIT_EPILOG]);
-                                       tail_call = true;
-                                       /* Inline cache misses are special-cased.
-                                          The calling convention for tail
-                                          calls stores the address of the next
-                                          instruction in a register. However,
-                                          PIC miss stubs themselves tail-call
-                                          the inline cache miss primitive, and
-                                          we don't want to clobber the saved
-                                          address. */
-                                       if(obj.value() == parent->special_objects[PIC_MISS_WORD]
-                                          || obj.value() == parent->special_objects[PIC_MISS_TAIL_WORD])
-                                       {
-                                               word_special(obj.value());
-                                       }
-                                       else
-                                       {
-                                               word_jump(obj.value());
-                                       }
-                               }
-                               else
-                                       word_call(obj.value());
+                               if(stack_frame) emit(parent->special_objects[JIT_EPILOG]);
+                               tail_call = true;
+                               word_jump(obj.value());
                        }
+                       else
+                               word_call(obj.value());
                        break;
                case WRAPPER_TYPE:
                        push(obj.as<wrapper>()->object);
                        break;
-               case FIXNUM_TYPE:
+               case BYTE_ARRAY_TYPE:
                        /* Primitive calls */
                        if(primitive_call_p(i,length))
                        {
-                               literal(tag_fixnum(0));
-                               literal(obj.value());
+                               /* On x86-64 and PowerPC, the VM pointer is stored in
+                               a register; on other platforms, the RT_VM relocation
+                               is used and it needs an offset parameter */
+#ifdef FACTOR_X86
+                               parameter(tag_fixnum(0));
+#endif
+                               parameter(obj.value());
+                               parameter(false_object);
                                emit(parent->special_objects[JIT_PRIMITIVE]);
 
                                i++;
-
-                               tail_call = true;
                        }
                        else
                                push(obj.value());
@@ -252,12 +239,13 @@ void quotation_jit::iterate_quotation()
                        /* Method dispatch */
                        if(mega_lookup_p(i,length))
                        {
+                               if(stack_frame) emit(parent->special_objects[JIT_EPILOG]);
+                               tail_call = true;
                                emit_mega_cache_lookup(
                                        array_nth(elements.untagged(),i),
                                        untag_fixnum(array_nth(elements.untagged(),i + 1)),
                                        array_nth(elements.untagged(),i + 2));
                                i += 3;
-                               tail_call = true;
                        }
                        /* Non-optimizing compiler ignores declarations */
                        else if(declare_p(i,length))
@@ -275,74 +263,73 @@ void quotation_jit::iterate_quotation()
        {
                set_position(length);
 
-               if(stack_frame)
-                       emit(parent->special_objects[JIT_EPILOG]);
+               if(stack_frame) emit(parent->special_objects[JIT_EPILOG]);
                emit(parent->special_objects[JIT_RETURN]);
        }
 }
 
-void factor_vm::set_quot_xt(quotation *quot, code_block *code)
+void factor_vm::set_quot_entry_point(quotation *quot, code_block *code)
 {
        quot->code = code;
-       quot->xt = code->xt();
+       quot->entry_point = code->entry_point();
 }
 
 /* Allocates memory */
-void factor_vm::jit_compile(cell quot_, bool relocating)
+code_block *factor_vm::jit_compile_quot(cell owner_, cell quot_, bool relocating)
 {
+       data_root<object> owner(owner_,this);
        data_root<quotation> quot(quot_,this);
-       if(quot->code) return;
 
-       quotation_jit compiler(quot.value(),true,relocating,this);
+       quotation_jit compiler(owner.value(),true,relocating,this);
+       compiler.init_quotation(quot.value());
        compiler.iterate_quotation();
 
        code_block *compiled = compiler.to_code_block();
-       set_quot_xt(quot.untagged(),compiled);
 
-       if(relocating) relocate_code_block(compiled);
+       if(relocating) initialize_code_block(compiled);
+
+       return compiled;
+}
+
+void factor_vm::jit_compile_quot(cell quot_, bool relocating)
+{
+       data_root<quotation> quot(quot_,this);
+       if(!quot_compiled_p(quot.untagged()))
+       {
+               code_block *compiled = jit_compile_quot(quot.value(),quot.value(),relocating);
+               set_quot_entry_point(quot.untagged(),compiled);
+       }
 }
 
 void factor_vm::primitive_jit_compile()
 {
-       jit_compile(dpop(),true);
+       jit_compile_quot(ctx->pop(),true);
+}
+
+code_block *factor_vm::lazy_jit_compile_block()
+{
+       return untag<word>(special_objects[LAZY_JIT_COMPILE_WORD])->code;
 }
 
 /* push a new quotation on the stack */
 void factor_vm::primitive_array_to_quotation()
 {
        quotation *quot = allot<quotation>(sizeof(quotation));
-       quot->array = dpeek();
+
+       quot->array = ctx->peek();
        quot->cached_effect = false_object;
        quot->cache_counter = false_object;
-       quot->xt = (void *)lazy_jit_compile;
-       quot->code = NULL;
-       drepl(tag<quotation>(quot));
-}
+       set_quot_entry_point(quot,lazy_jit_compile_block());
 
-void factor_vm::primitive_quotation_xt()
-{
-       quotation *quot = untag_check<quotation>(dpeek());
-       drepl(allot_cell((cell)quot->xt));
+       ctx->replace(tag<quotation>(quot));
 }
 
-void factor_vm::compile_all_words()
+void factor_vm::primitive_quotation_code()
 {
-       data_root<array> words(find_all_words(),this);
-
-       cell i;
-       cell length = array_capacity(words.untagged());
-       for(i = 0; i < length; i++)
-       {
-               data_root<word> word(array_nth(words.untagged(),i),this);
-
-               if(!word->code || !word->code->optimized_p())
-                       jit_compile_word(word.value(),word->def,false);
+       quotation *quot = untag_check<quotation>(ctx->pop());
 
-               update_word_xt(word.untagged());
-
-       }
-
-       update_code_heap_words();
+       ctx->push(allot_cell((cell)quot->code->entry_point()));
+       ctx->push(allot_cell((cell)quot->code + quot->code->size()));
 }
 
 /* Allocates memory */
@@ -352,30 +339,58 @@ fixnum factor_vm::quot_code_offset_to_scan(cell quot_, cell offset)
        data_root<array> array(quot->array,this);
 
        quotation_jit compiler(quot.value(),false,false,this);
+       compiler.init_quotation(quot.value());
        compiler.compute_position(offset);
        compiler.iterate_quotation();
 
        return compiler.get_position();
 }
 
-cell factor_vm::lazy_jit_compile_impl(cell quot_, stack_frame *stack)
+cell factor_vm::lazy_jit_compile(cell quot_)
 {
        data_root<quotation> quot(quot_,this);
-       ctx->callstack_top = stack;
-       jit_compile(quot.value(),true);
+
+       assert(!quot_compiled_p(quot.untagged()));
+
+       code_block *compiled = jit_compile_quot(quot.value(),quot.value(),true);
+       set_quot_entry_point(quot.untagged(),compiled);
+
        return quot.value();
 }
 
-VM_ASM_API cell lazy_jit_compile_impl(cell quot_, stack_frame *stack, factor_vm *parent)
+VM_C_API cell lazy_jit_compile(cell quot, factor_vm *parent)
 {
-       return parent->lazy_jit_compile_impl(quot_,stack);
+       return parent->lazy_jit_compile(quot);
+}
+
+bool factor_vm::quot_compiled_p(quotation *quot)
+{
+       return quot->code != NULL && quot->code != lazy_jit_compile_block();
 }
 
 void factor_vm::primitive_quot_compiled_p()
 {
-       tagged<quotation> quot(dpop());
+       tagged<quotation> quot(ctx->pop());
        quot.untag_check(this);
-       dpush(tag_boolean(quot->code != NULL));
+       ctx->push(tag_boolean(quot_compiled_p(quot.untagged())));
+}
+
+cell factor_vm::find_all_quotations()
+{
+       return instances(QUOTATION_TYPE);
+}
+
+void factor_vm::initialize_all_quotations()
+{
+       data_root<array> quotations(find_all_quotations(),this);
+
+       cell length = array_capacity(quotations.untagged());
+       for(cell i = 0; i < length; i++)
+       {
+               data_root<quotation> quot(array_nth(quotations.untagged(),i),this);
+               if(!quot->code)
+                       set_quot_entry_point(quot.untagged(),lazy_jit_compile_block());
+       }
 }
 
 }
index 6d04d80de3d872ad4a33f9288db2fe96d21f0eba..69755302ea8df5cdd901b24a12c1555acaa047d3 100755 (executable)
@@ -5,12 +5,13 @@ struct quotation_jit : public jit {
        data_root<array> elements;
        bool compiling, relocate;
 
-       explicit quotation_jit(cell quot, bool compiling_, bool relocate_, factor_vm *vm)
-               : jit(code_block_unoptimized,quot,vm),
-                 elements(owner.as<quotation>().untagged()->array,vm),
+       explicit quotation_jit(cell owner, bool compiling_, bool relocate_, factor_vm *vm)
+               : jit(code_block_unoptimized,owner,vm),
+                 elements(false_object,vm),
                  compiling(compiling_),
                  relocate(relocate_){};
 
+       void init_quotation(cell quot);
        void emit_mega_cache_lookup(cell methods, fixnum index, cell cache);
        bool primitive_call_p(cell i, cell length);
        bool trivial_quotation_p(array *elements);
@@ -21,10 +22,11 @@ struct quotation_jit : public jit {
        bool fast_3dip_p(cell i, cell length);
        bool mega_lookup_p(cell i, cell length);
        bool declare_p(cell i, cell length);
+       bool word_stack_frame_p(cell obj);
        bool stack_frame_p();
        void iterate_quotation();
 };
 
-VM_ASM_API cell lazy_jit_compile_impl(cell quot, stack_frame *stack, factor_vm *parent);
+VM_C_API cell lazy_jit_compile(cell quot, factor_vm *parent);
 
 }
index 6d3e9f7374695e18d08744989b3ea6a23e6d5e5e..dfff8f2f2d30e4c662a590f62807de8e15eda8fa 100755 (executable)
@@ -3,71 +3,27 @@
 namespace factor
 {
 
-void factor_vm::primitive_getenv()
-{
-       fixnum e = untag_fixnum(dpeek());
-       drepl(special_objects[e]);
-}
-
-void factor_vm::primitive_setenv()
-{
-       fixnum e = untag_fixnum(dpop());
-       cell value = dpop();
-       special_objects[e] = value;
-}
-
 void factor_vm::primitive_exit()
 {
-       exit(to_fixnum(dpop()));
+       exit(to_fixnum(ctx->pop()));
 }
 
-void factor_vm::primitive_micros()
+void factor_vm::primitive_system_micros()
 {
-       box_unsigned_8(current_micros());
+       ctx->push(from_unsigned_8(system_micros()));
 }
 
-void factor_vm::primitive_sleep()
+void factor_vm::primitive_nano_count()
 {
-       sleep_micros(to_cell(dpop()));
+       u64 nanos = nano_count();
+       if(nanos < last_nano_count) critical_error("Monotonic counter decreased",0);
+       last_nano_count = nanos;
+       ctx->push(from_unsigned_8(nanos));
 }
 
-void factor_vm::primitive_set_slot()
-{
-       fixnum slot = untag_fixnum(dpop());
-       object *obj = untag<object>(dpop());
-       cell value = dpop();
-
-       cell *slot_ptr = &obj->slots()[slot];
-       *slot_ptr = value;
-       write_barrier(slot_ptr);
-}
-
-void factor_vm::primitive_load_locals()
-{
-       fixnum count = untag_fixnum(dpop());
-       memcpy((cell *)(rs + sizeof(cell)),(cell *)(ds - sizeof(cell) * (count - 1)),sizeof(cell) * count);
-       ds -= sizeof(cell) * count;
-       rs += sizeof(cell) * count;
-}
-
-cell factor_vm::clone_object(cell obj_)
-{
-       data_root<object> obj(obj_,this);
-
-       if(immediate_p(obj.value()))
-               return obj.value();
-       else
-       {
-               cell size = object_size(obj.value());
-               object *new_obj = allot_object(header(obj.type()),size);
-               memcpy(new_obj,obj.untagged(),size);
-               return tag_dynamic(new_obj);
-       }
-}
-
-void factor_vm::primitive_clone()
+void factor_vm::primitive_sleep()
 {
-       drepl(clone_object(dpeek()));
+       sleep_nanos(to_unsigned_8(ctx->pop()));
 }
 
 }
index 6ca2e504646d527ce9918011398cad160ab1583a..412ef35bb4403ee39e5aa0ef975114ad79a07a9b 100755 (executable)
@@ -1,103 +1,4 @@
 namespace factor
 {
 
-static const cell special_object_count = 70;
-
-enum special_object {
-       OBJ_NAMESTACK,            /* used by library only */
-       OBJ_CATCHSTACK,           /* used by library only, per-callback */
-
-       OBJ_CURRENT_CALLBACK = 2, /* used by library only, per-callback */
-       OBJ_WALKER_HOOK,          /* non-local exit hook, used by library only */
-       OBJ_CALLCC_1,             /* used to pass the value in callcc1 */
-
-       OBJ_BREAK            = 5, /* quotation called by throw primitive */
-       OBJ_ERROR,                /* a marker consed onto kernel errors */
-
-       OBJ_CELL_SIZE        = 7, /* sizeof(cell) */
-       OBJ_CPU,                  /* CPU architecture */
-       OBJ_OS,                   /* operating system name */
-
-       OBJ_ARGS            = 10, /* command line arguments */
-       OBJ_STDIN,                /* stdin FILE* handle */
-       OBJ_STDOUT,               /* stdout FILE* handle */
-
-       OBJ_IMAGE           = 13, /* image path name */
-       OBJ_EXECUTABLE,           /* runtime executable path name */
-
-       OBJ_EMBEDDED        = 15, /* are we embedded in another app? */
-       OBJ_EVAL_CALLBACK,        /* used when Factor is embedded in a C app */
-       OBJ_YIELD_CALLBACK,       /* used when Factor is embedded in a C app */
-       OBJ_SLEEP_CALLBACK,       /* used when Factor is embedded in a C app */
-
-       OBJ_COCOA_EXCEPTION = 19, /* Cocoa exception handler quotation */
-
-       OBJ_BOOT            = 20, /* boot quotation */
-       OBJ_GLOBAL,               /* global namespace */
-
-       /* Quotation compilation in quotations.c */
-       JIT_PROLOG          = 23,
-       JIT_PRIMITIVE_WORD,
-       JIT_PRIMITIVE,
-       JIT_WORD_JUMP,
-       JIT_WORD_CALL,
-       JIT_WORD_SPECIAL,
-       JIT_IF_WORD,
-       JIT_IF,
-       JIT_EPILOG,
-       JIT_RETURN,
-       JIT_PROFILING,
-       JIT_PUSH_IMMEDIATE,
-       JIT_DIP_WORD,
-       JIT_DIP,
-       JIT_2DIP_WORD,
-       JIT_2DIP,
-       JIT_3DIP_WORD,
-       JIT_3DIP,
-       JIT_EXECUTE_WORD,
-       JIT_EXECUTE_JUMP,
-       JIT_EXECUTE_CALL,
-       JIT_DECLARE_WORD,
-
-       /* Callback stub generation in callbacks.c */
-       CALLBACK_STUB       = 45,
-
-       /* Polymorphic inline cache generation in inline_cache.c */
-       PIC_LOAD            = 47,
-       PIC_TAG,
-       PIC_TUPLE,
-       PIC_CHECK_TAG,
-       PIC_CHECK_TUPLE,
-       PIC_HIT,
-       PIC_MISS_WORD,
-       PIC_MISS_TAIL_WORD,
-
-       /* Megamorphic cache generation in dispatch.c */
-       MEGA_LOOKUP         = 57,
-       MEGA_LOOKUP_WORD,
-       MEGA_MISS_WORD,
-
-       OBJ_UNDEFINED       = 60, /* default quotation for undefined words */
-
-       OBJ_STDERR          = 61, /* stderr FILE* handle */
-
-       OBJ_STAGE2          = 62, /* have we bootstrapped? */
-
-       OBJ_CURRENT_THREAD  = 63,
-
-       OBJ_THREADS         = 64,
-       OBJ_RUN_QUEUE       = 65,
-       OBJ_SLEEP_QUEUE     = 66,
-};
-
-#define OBJ_FIRST_SAVE OBJ_BOOT
-#define OBJ_LAST_SAVE OBJ_STAGE2
-
-inline static bool save_env_p(cell i)
-{
-       return (i >= OBJ_FIRST_SAVE && i <= OBJ_LAST_SAVE);
 }
-
-}
-
index e777347622b3ccc9970d6e73f2f15dbe087a6145..0ab9cc171d703f36e0e4dee65f09c892f87bc822 100644 (file)
@@ -1,6 +1,22 @@
 namespace factor
 {
 
+/* Slot visitors iterate over the slots of an object, applying a functor to
+each one that is a non-immediate slot. The pointer is untagged first. The
+functor returns a new untagged object pointer. The return value may or may not equal the old one,
+however the new pointer receives the same tag before being stored back to the
+original location.
+
+Slots storing immediate values are left unchanged and the visitor does inspect
+them.
+
+This is used by GC's copying, sweep and compact phases, and the implementation
+of the become primitive.
+
+Iteration is driven by visit_*() methods. Some of them define GC roots:
+- visit_roots()
+- visit_contexts() */
+
 template<typename Visitor> struct slot_visitor {
        factor_vm *parent;
        Visitor visitor;
@@ -8,99 +24,194 @@ template<typename Visitor> struct slot_visitor {
        explicit slot_visitor<Visitor>(factor_vm *parent_, Visitor visitor_) :
                parent(parent_), visitor(visitor_) {}
 
-       void visit_handle(cell *handle)
-       {
-               cell pointer = *handle;
+       cell visit_pointer(cell pointer);
+       void visit_handle(cell *handle);
+       void visit_slots(object *ptr, cell payload_start);
+       void visit_slots(object *ptr);
+       void visit_stack_elements(segment *region, cell *top);
+       void visit_data_roots();
+       void visit_bignum_roots();
+       void visit_callback_roots();
+       void visit_literal_table_roots();
+       void visit_roots();
+       void visit_contexts();
+       void visit_code_block_objects(code_block *compiled);
+       void visit_embedded_literals(code_block *compiled);
+};
+
+template<typename Visitor>
+cell slot_visitor<Visitor>::visit_pointer(cell pointer)
+{
+       if(immediate_p(pointer)) return pointer;
 
-               if(immediate_p(pointer)) return;
+       object *untagged = untag<object>(pointer);
+       untagged = visitor(untagged);
+       return RETAG(untagged,TAG(pointer));
+}
 
-               object *untagged = untag<object>(pointer);
-               untagged = visitor(untagged);
-               *handle = RETAG(untagged,TAG(pointer));
-       }
+template<typename Visitor>
+void slot_visitor<Visitor>::visit_handle(cell *handle)
+{
+       *handle = visit_pointer(*handle);
+}
 
-       void visit_slots(object *ptr, cell payload_start)
-       {
-               cell *slot = (cell *)ptr;
-               cell *end = (cell *)((cell)ptr + payload_start);
-
-               if(slot != end)
-               {
-                       slot++;
-                       for(; slot < end; slot++) visit_handle(slot);
-               }
-       }
+template<typename Visitor>
+void slot_visitor<Visitor>::visit_slots(object *ptr, cell payload_start)
+{
+       cell *slot = (cell *)ptr;
+       cell *end = (cell *)((cell)ptr + payload_start);
 
-       void visit_slots(object *ptr)
+       if(slot != end)
        {
-               visit_slots(ptr,ptr->binary_payload_start());
+               slot++;
+               for(; slot < end; slot++) visit_handle(slot);
        }
+}
+
+template<typename Visitor>
+void slot_visitor<Visitor>::visit_slots(object *ptr)
+{
+       visit_slots(ptr,ptr->binary_payload_start());
+}
+
+template<typename Visitor>
+void slot_visitor<Visitor>::visit_stack_elements(segment *region, cell *top)
+{
+       for(cell *ptr = (cell *)region->start; ptr <= top; ptr++)
+               visit_handle(ptr);
+}
+
+template<typename Visitor>
+void slot_visitor<Visitor>::visit_data_roots()
+{
+       std::vector<data_root_range>::const_iterator iter = parent->data_roots.begin();
+       std::vector<data_root_range>::const_iterator end = parent->data_roots.end();
 
-       void visit_stack_elements(segment *region, cell *top)
+       for(; iter < end; iter++)
        {
-               for(cell *ptr = (cell *)region->start; ptr <= top; ptr++)
-                       visit_handle(ptr);
+               data_root_range r = *iter;
+               for(cell index = 0; index < r.len; index++)
+                       visit_handle(r.start + index);
        }
+}
 
-       void visit_data_roots()
+template<typename Visitor>
+void slot_visitor<Visitor>::visit_bignum_roots()
+{
+       std::vector<cell>::const_iterator iter = parent->bignum_roots.begin();
+       std::vector<cell>::const_iterator end = parent->bignum_roots.end();
+
+       for(; iter < end; iter++)
        {
-               std::vector<cell>::const_iterator iter = parent->data_roots.begin();
-               std::vector<cell>::const_iterator end = parent->data_roots.end();
+               cell *handle = (cell *)(*iter);
 
-               for(; iter < end; iter++)
-                       visit_handle((cell *)(*iter));
+               if(*handle)
+                       *handle = (cell)visitor(*(object **)handle);
        }
+}
 
-       void visit_bignum_roots()
-       {
-               std::vector<cell>::const_iterator iter = parent->bignum_roots.begin();
-               std::vector<cell>::const_iterator end = parent->bignum_roots.end();
+template<typename Visitor>
+struct callback_slot_visitor {
+       callback_heap *callbacks;
+       slot_visitor<Visitor> *visitor;
 
-               for(; iter < end; iter++)
-               {
-                       cell *handle = (cell *)(*iter);
+       explicit callback_slot_visitor(callback_heap *callbacks_, slot_visitor<Visitor> *visitor_) :
+               callbacks(callbacks_), visitor(visitor_) {}
 
-                       if(*handle)
-                               *handle = (cell)visitor(*(object **)handle);
-               }
+       void operator()(code_block *stub)
+       {
+               visitor->visit_handle(&stub->owner);
        }
+};
 
-       void visit_roots()
-       {
-               visit_handle(&parent->true_object);
-               visit_handle(&parent->bignum_zero);
-               visit_handle(&parent->bignum_pos_one);
-               visit_handle(&parent->bignum_neg_one);
+template<typename Visitor>
+void slot_visitor<Visitor>::visit_callback_roots()
+{
+       callback_slot_visitor<Visitor> callback_visitor(parent->callbacks,this);
+       parent->callbacks->each_callback(callback_visitor);
+}
 
-               visit_data_roots();
-               visit_bignum_roots();
+template<typename Visitor>
+void slot_visitor<Visitor>::visit_literal_table_roots()
+{
+       std::map<code_block *, cell> *uninitialized_blocks = &parent->code->uninitialized_blocks;
+       std::map<code_block *, cell>::const_iterator iter = uninitialized_blocks->begin();
+       std::map<code_block *, cell>::const_iterator end = uninitialized_blocks->end();
 
-               for(cell i = 0; i < special_object_count; i++)
-                       visit_handle(&parent->special_objects[i]);
+       std::map<code_block *, cell> new_uninitialized_blocks;
+       for(; iter != end; iter++)
+       {
+               new_uninitialized_blocks.insert(std::make_pair(
+                       iter->first,
+                       visit_pointer(iter->second)));
        }
 
-       void visit_contexts()
-       {
-               context *ctx = parent->ctx;
+       parent->code->uninitialized_blocks = new_uninitialized_blocks;
+}
 
-               while(ctx)
-               {
-                       visit_stack_elements(ctx->datastack_region,(cell *)ctx->datastack);
-                       visit_stack_elements(ctx->retainstack_region,(cell *)ctx->retainstack);
+template<typename Visitor>
+void slot_visitor<Visitor>::visit_roots()
+{
+       visit_handle(&parent->true_object);
+       visit_handle(&parent->bignum_zero);
+       visit_handle(&parent->bignum_pos_one);
+       visit_handle(&parent->bignum_neg_one);
+
+       visit_data_roots();
+       visit_bignum_roots();
+       visit_callback_roots();
+       visit_literal_table_roots();
+
+       for(cell i = 0; i < special_object_count; i++)
+               visit_handle(&parent->special_objects[i]);
+}
 
-                       visit_handle(&ctx->catchstack_save);
-                       visit_handle(&ctx->current_callback_save);
+template<typename Visitor>
+void slot_visitor<Visitor>::visit_contexts()
+{
+       context *ctx = parent->ctx;
 
-                       ctx = ctx->next;
-               }
+       while(ctx)
+       {
+               visit_stack_elements(ctx->datastack_region,(cell *)ctx->datastack);
+               visit_stack_elements(ctx->retainstack_region,(cell *)ctx->retainstack);
+
+               visit_handle(&ctx->catchstack_save);
+               visit_handle(&ctx->current_callback_save);
+
+               ctx = ctx->next;
        }
+}
+
+template<typename Visitor>
+struct literal_references_visitor {
+       slot_visitor<Visitor> *visitor;
 
-       void visit_literal_references(code_block *compiled)
+       explicit literal_references_visitor(slot_visitor<Visitor> *visitor_) : visitor(visitor_) {}
+
+       void operator()(instruction_operand op)
        {
-               visit_handle(&compiled->owner);
-               visit_handle(&compiled->literals);
-               visit_handle(&compiled->relocation);
+               if(op.rel_type() == RT_LITERAL)
+                       op.store_value(visitor->visit_pointer(op.load_value()));
        }
 };
 
+template<typename Visitor>
+void slot_visitor<Visitor>::visit_code_block_objects(code_block *compiled)
+{
+       visit_handle(&compiled->owner);
+       visit_handle(&compiled->parameters);
+       visit_handle(&compiled->relocation);
+}
+
+template<typename Visitor>
+void slot_visitor<Visitor>::visit_embedded_literals(code_block *compiled)
+{
+       if(!parent->code->uninitialized_p(compiled))
+       {
+               literal_references_visitor<Visitor> visitor(this);
+               compiled->each_instruction_operand(visitor);
+       }
+}
+
 }
diff --git a/vm/stacks.hpp b/vm/stacks.hpp
deleted file mode 100644 (file)
index 4906d10..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-namespace factor
-{
-
-#define DEFPUSHPOP(prefix,ptr) \
-       inline cell prefix##peek() { return *(cell *)ptr; } \
-       inline void prefix##repl(cell tagged) { *(cell *)ptr = tagged; } \
-       inline cell prefix##pop() \
-       { \
-               cell value = prefix##peek(); \
-               ptr -= sizeof(cell); \
-               return value; \
-       } \
-       inline void prefix##push(cell tagged) \
-       { \
-               ptr += sizeof(cell); \
-               prefix##repl(tagged); \
-       }
-
-}
index 9e135e6779d501bfe47d53bcf973eb823dd48ac0..67e4fb4508b909fe2af48a5b9ca6e74a24528183 100644 (file)
@@ -24,7 +24,7 @@ cell string::nth(cell index) const
 
 void factor_vm::set_string_nth_fast(string *str, cell index, cell ch)
 {
-       str->data()[index] = ch;
+       str->data()[index] = (u8)ch;
 }
 
 void factor_vm::set_string_nth_slow(string *str_, cell index, cell ch)
@@ -51,7 +51,7 @@ void factor_vm::set_string_nth_slow(string *str_, cell index, cell ch)
                write_barrier(&str->aux);
        }
 
-       aux->data<u16>()[index] = ((ch >> 7) ^ 1);
+       aux->data<u16>()[index] = (u16)((ch >> 7) ^ 1);
 }
 
 /* allocates memory */
@@ -101,9 +101,9 @@ string *factor_vm::allot_string(cell capacity, cell fill)
 
 void factor_vm::primitive_string()
 {
-       cell initial = to_cell(dpop());
+       cell initial = to_cell(ctx->pop());
        cell length = unbox_array_size();
-       dpush(tag<string>(allot_string(length,initial)));
+       ctx->push(tag<string>(allot_string(length,initial)));
 }
 
 bool factor_vm::reallot_string_in_place_p(string *str, cell capacity)
@@ -157,31 +157,32 @@ string* factor_vm::reallot_string(string *str_, cell capacity)
 
 void factor_vm::primitive_resize_string()
 {
-       string* str = untag_check<string>(dpop());
+       data_root<string> str(ctx->pop(),this);
+       str.untag_check(this);
        cell capacity = unbox_array_size();
-       dpush(tag<string>(reallot_string(str,capacity)));
+       ctx->push(tag<string>(reallot_string(str.untagged(),capacity)));
 }
 
 void factor_vm::primitive_string_nth()
 {
-       string *str = untag<string>(dpop());
-       cell index = untag_fixnum(dpop());
-       dpush(tag_fixnum(str->nth(index)));
+       string *str = untag<string>(ctx->pop());
+       cell index = untag_fixnum(ctx->pop());
+       ctx->push(tag_fixnum(str->nth(index)));
 }
 
 void factor_vm::primitive_set_string_nth_fast()
 {
-       string *str = untag<string>(dpop());
-       cell index = untag_fixnum(dpop());
-       cell value = untag_fixnum(dpop());
+       string *str = untag<string>(ctx->pop());
+       cell index = untag_fixnum(ctx->pop());
+       cell value = untag_fixnum(ctx->pop());
        set_string_nth_fast(str,index,value);
 }
 
 void factor_vm::primitive_set_string_nth_slow()
 {
-       string *str = untag<string>(dpop());
-       cell index = untag_fixnum(dpop());
-       cell value = untag_fixnum(dpop());
+       string *str = untag<string>(ctx->pop());
+       cell index = untag_fixnum(ctx->pop());
+       cell value = untag_fixnum(ctx->pop());
        set_string_nth_slow(str,index,value);
 }
 
index e520e326fa95325787f947d0366844552a77ba8f..e9f89528bc3b0f68c6bd18240b9ae8e59590e32f 100755 (executable)
@@ -8,7 +8,7 @@ template<typename Type> cell tag(Type *value)
 
 inline static cell tag_dynamic(object *value)
 {
-       return RETAG(value,value->h.hi_tag());
+       return RETAG(value,value->type());
 }
 
 template<typename Type>
index baab47e383f3bc3c5435158634ba6795bdcde44e..1b1ff5369c82dbd74e3e2fe5ff8b99ccceeb2ccf 100644 (file)
@@ -3,7 +3,6 @@ namespace factor
 
 struct tenured_space : free_list_allocator<object> {
        object_start_map starts;
-       std::vector<object *> mark_stack;
 
        explicit tenured_space(cell size, cell start) :
                free_list_allocator<object>(size,start), starts(size,start) {}
@@ -37,20 +36,14 @@ struct tenured_space : free_list_allocator<object> {
                state.clear_mark_bits();
        }
 
-       void clear_mark_stack()
-       {
-               mark_stack.clear();
-       }
-
        bool marked_p(object *obj)
        {
                return this->state.marked_p(obj);
        }
 
-       void mark_and_push(object *obj)
+       void set_marked_p(object *obj)
        {
                this->state.set_marked_p(obj);
-               this->mark_stack.push_back(obj);
        }
 
        void sweep()
index 0cee7482058a9f3493dae9a37f647a260d9069f9..b29affc480ccfbbd3d26d8e2dbf0f8c37b8d593f 100644 (file)
@@ -3,20 +3,20 @@
 namespace factor
 {
 
-to_tenured_collector::to_tenured_collector(factor_vm *myvm_) :
+to_tenured_collector::to_tenured_collector(factor_vm *parent_) :
        collector<tenured_space,to_tenured_policy>(
-               myvm_,
-               myvm_->data->tenured,
-               to_tenured_policy(myvm_)) {}
+               parent_,
+               parent_->data->tenured,
+               to_tenured_policy(parent_)) {}
 
 void to_tenured_collector::tenure_reachable_objects()
 {
-       std::vector<object *> *mark_stack = &this->target->mark_stack;
+       std::vector<cell> *mark_stack = &parent->mark_stack;
        while(!mark_stack->empty())
        {
-               object *obj = mark_stack->back();
+               cell ptr = mark_stack->back();
                mark_stack->pop_back();
-               this->trace_object(obj);
+               this->trace_object((object *)ptr);
        }
 }
 
@@ -25,7 +25,7 @@ void factor_vm::collect_to_tenured()
        /* Copy live objects from aging space to tenured space. */
        to_tenured_collector collector(this);
 
-       data->tenured->clear_mark_stack();
+       mark_stack.clear();
 
        collector.trace_roots();
        collector.trace_contexts();
@@ -42,10 +42,6 @@ void factor_vm::collect_to_tenured()
 
        collector.tenure_reachable_objects();
 
-       current_gc->event->started_code_sweep();
-       update_code_heap_for_minor_gc(&code->points_to_aging);
-       current_gc->event->ended_code_sweep();
-
        data->reset_generation(&nursery);
        data->reset_generation(data->aging);
        code->clear_remembered_set();
index 2f2717efd1c2b2cc69dc94576c0748a4506c52a0..8709b9a221855a5dd2aa96d7cb937a1af8582f66 100644 (file)
@@ -2,10 +2,10 @@ namespace factor
 {
 
 struct to_tenured_policy {
-       factor_vm *myvm;
+       factor_vm *parent;
        tenured_space *tenured;
 
-       explicit to_tenured_policy(factor_vm *myvm_) : myvm(myvm_), tenured(myvm->data->tenured) {}
+       explicit to_tenured_policy(factor_vm *parent_) : parent(parent_), tenured(parent->data->tenured) {}
 
        bool should_copy_p(object *untagged)
        {
@@ -14,14 +14,14 @@ struct to_tenured_policy {
 
        void promoted_object(object *obj)
        {
-               tenured->mark_stack.push_back(obj);
+               parent->mark_stack.push_back((cell)obj);
        }
 
        void visited_object(object *obj) {}
 };
 
 struct to_tenured_collector : collector<tenured_space,to_tenured_policy> {
-       explicit to_tenured_collector(factor_vm *myvm_);
+       explicit to_tenured_collector(factor_vm *parent_);
        void tenure_reachable_objects();
 };
 
index eaac437753d90e41e4ca1e159b0bb5fc81403e97..e09bf17e1150f2a12ba8ac0c20769ed7779b0835 100755 (executable)
@@ -6,27 +6,27 @@ namespace factor
 /* push a new tuple on the stack, filling its slots with f */
 void factor_vm::primitive_tuple()
 {
-       data_root<tuple_layout> layout(dpop(),this);
+       data_root<tuple_layout> layout(ctx->pop(),this);
        tagged<tuple> t(allot<tuple>(tuple_size(layout.untagged())));
        t->layout = layout.value();
 
        memset_cell(t->data(),false_object,tuple_size(layout.untagged()) - sizeof(cell));
 
-       dpush(t.value());
+       ctx->push(t.value());
 }
 
 /* push a new tuple on the stack, filling its slots from the stack */
 void factor_vm::primitive_tuple_boa()
 {
-       data_root<tuple_layout> layout(dpop(),this);
+       data_root<tuple_layout> layout(ctx->pop(),this);
        tagged<tuple> t(allot<tuple>(tuple_size(layout.untagged())));
        t->layout = layout.value();
 
        cell size = untag_fixnum(layout.untagged()->size) * sizeof(cell);
-       memcpy(t->data(),(cell *)(ds - size + sizeof(cell)),size);
-       ds -= size;
+       memcpy(t->data(),(cell *)(ctx->datastack - size + sizeof(cell)),size);
+       ctx->datastack -= size;
 
-       dpush(t.value());
+       ctx->push(t.value());
 }
 
 }
index 8f063a9ad4628686d3e366d007181a076a17d611..3e976d06195a23fb030c12ccbd990541a5f6dcfe 100755 (executable)
@@ -18,4 +18,11 @@ cell read_cell_hex()
        return cell;
 }
 
+/* On Windows, memcpy() is in a different DLL and the non-optimizing
+compiler can't find it */
+VM_C_API void *factor_memcpy(void *dst, void *src, size_t len)
+{
+       return memcpy(dst,src,len);
+}
+
 }
index 94b9de6f483d98cbaf9fd8a66a64e2fbae65d28c..cea70c0c372e755468ae2a5095b75a55ffa7bdb3 100755 (executable)
@@ -27,5 +27,6 @@ inline static void memset_cell(void *dst, cell pattern, size_t size)
 
 vm_char *safe_strdup(const vm_char *str);
 cell read_cell_hex();
+VM_C_API void *factor_memcpy(void *dst, void *src, size_t len);
 
 }
index 72c63292fd94d25d89d85a9832fb492c0eaaae61..623556416ab3ece478241406fc283646a3e14137 100755 (executable)
--- a/vm/vm.cpp
+++ b/vm/vm.cpp
@@ -5,12 +5,14 @@ namespace factor
 \r
 factor_vm::factor_vm() :\r
        nursery(0,0),\r
+       c_to_factor_func(NULL),\r
        profiling_p(false),\r
        gc_off(false),\r
        current_gc(NULL),\r
        gc_events(NULL),\r
        fep_disabled(false),\r
-       full_output(false)\r
+       full_output(false),\r
+       last_nano_count(0)\r
 {\r
        primitive_reset_dispatch_stats();\r
 }\r
index aa5a3051e6cd05768c98dba6a7c82df1762b6760..6f826ed9e0d59d91be0016d4359f7c65602f3d82 100755 (executable)
--- a/vm/vm.hpp
+++ b/vm/vm.hpp
@@ -30,6 +30,9 @@ struct factor_vm
        /* Canonical truth value. In Factor, 't' */
        cell true_object;
 
+       /* External entry points */
+       c_to_factor_func_type c_to_factor_func;
+
        /* Is call counting enabled? */
        bool profiling_p;
 
@@ -40,10 +43,6 @@ struct factor_vm
        unsigned int signal_fpu_status;
        stack_frame *signal_callstack_top;
 
-       /* A heap walk allows useful things to be done, like finding all
-          references to an object for debugging purposes. */
-       cell heap_scan_ptr;
-
        /* GC is off during heap walking */
        bool gc_off;
 
@@ -59,6 +58,9 @@ struct factor_vm
        /* Only set if we're performing a GC */
        gc_state *current_gc;
 
+       /* Mark stack */
+       std::vector<cell> mark_stack;
+
        /* If not NULL, we push GC events here */
        std::vector<gc_event> *gc_events;
 
@@ -66,7 +68,7 @@ struct factor_vm
           allocates memory, it must wrap any references to the data and code
           heaps with data_root and code_root smart pointers, which register
           themselves here. See data_roots.hpp and code_roots.hpp */
-       std::vector<cell> data_roots;
+       std::vector<data_root_range> data_roots;
        std::vector<cell> bignum_roots;
        std::vector<code_root *> code_roots;
 
@@ -85,14 +87,17 @@ struct factor_vm
        /* Number of entries in a polymorphic inline cache */
        cell max_pic_size;
 
+       /* Incrementing object counter for identity hashing */
+       cell object_counter;
+
+       /* Sanity check to ensure that monotonic counter doesn't
+       decrease */
+       u64 last_nano_count;
+
        // contexts
-       void reset_datastack();
-       void reset_retainstack();
-       void fix_stacks();
-       void save_stacks();
        context *alloc_context();
        void dealloc_context(context *old_context);
-       void nest_stacks(stack_frame *magic_frame);
+       void nest_stacks();
        void unnest_stacks();
        void init_stacks(cell ds_size_, cell rs_size_);
        bool stack_to_array(cell bottom, cell top);
@@ -102,6 +107,7 @@ struct factor_vm
        void primitive_set_datastack();
        void primitive_set_retainstack();
        void primitive_check_datastack();
+       void primitive_load_locals();
 
        template<typename Iterator> void iterate_active_frames(Iterator &iter)
        {
@@ -110,21 +116,27 @@ struct factor_vm
                while(ctx)
                {
                        iterate_callstack(ctx,iter);
-                       if(ctx->magic_frame) iter(ctx->magic_frame);
                        ctx = ctx->next;
                }
        }
 
        // run
-       void primitive_getenv();
-       void primitive_setenv();
        void primitive_exit();
-       void primitive_micros();
+       void primitive_system_micros();
+       void primitive_nano_count();
        void primitive_sleep();
        void primitive_set_slot();
-       void primitive_load_locals();
+
+       // objects
+       void primitive_special_object();
+       void primitive_set_special_object();
+       void primitive_identity_hashcode();
+       void compute_identity_hashcode(object *obj);
+       void primitive_compute_identity_hashcode();
+       cell object_size(cell tagged);
        cell clone_object(cell obj_);
        void primitive_clone();
+       void primitive_become();
 
        // profiler
        void init_profiler();
@@ -220,20 +232,29 @@ struct factor_vm
        void primitive_data_room();
        void begin_scan();
        void end_scan();
-       void primitive_begin_scan();
-       cell next_object();
-       void primitive_next_object();
-       void primitive_end_scan();
-       cell find_all_words();
-       cell object_size(cell tagged);
+       cell instances(cell type);
+       void primitive_all_instances();
+
+       template<typename Generation, typename Iterator>
+       inline void each_object(Generation *gen, Iterator &iterator)
+       {
+               cell obj = gen->first_object();
+               while(obj)
+               {
+                       iterator((object *)obj);
+                       obj = gen->next_object_after(obj);
+               }
+       }
 
        template<typename Iterator> inline void each_object(Iterator &iterator)
        {
-               begin_scan();
-               cell obj;
-               while(to_boolean(obj = next_object()))
-                       iterator(obj);
-               end_scan();
+               gc_off = true;
+
+               each_object(data->tenured,iterator);
+               each_object(data->aging,iterator);
+               each_object(data->nursery,iterator);
+
+               gc_off = false;
        }
 
        /* the write barrier must be called any time we are potentially storing a
@@ -244,6 +265,18 @@ struct factor_vm
                *(char *)(decks_offset + ((cell)slot_ptr >> deck_bits)) = card_mark_mask;
        }
 
+       inline void write_barrier(object *obj, cell size)
+       {
+               cell start = (cell)obj & (~card_size + 1);
+               cell end = ((cell)obj + size + card_size - 1) & (~card_size + 1);
+
+               for(cell offset = start; offset < end; offset += card_size)
+                       write_barrier((cell *)offset);
+       }
+
+       // data heap checker
+       void check_data_heap();
+
        // gc
        void end_gc();
        void start_gc_again();
@@ -264,16 +297,15 @@ struct factor_vm
        void primitive_minor_gc();
        void primitive_full_gc();
        void primitive_compact_gc();
-       void primitive_become();
        void inline_gc(cell *data_roots_base, cell data_roots_size);
        void primitive_enable_gc_events();
        void primitive_disable_gc_events();
-       object *allot_object(header header, cell size);
-       object *allot_large_object(header header, cell size);
+       object *allot_object(cell type, cell size);
+       object *allot_large_object(cell type, cell size);
 
        template<typename Type> Type *allot(cell size)
        {
-               return (Type *)allot_object(header(Type::type_number),size);
+               return (Type *)allot_object(Type::type_number,size);
        }
 
        inline void check_data_pointer(object *pointer)
@@ -341,9 +373,10 @@ struct factor_vm
        void primitive_set_string_nth_slow();
 
        //booleans
-       void box_boolean(bool value);
-       bool to_boolean(cell value);
-       inline cell tag_boolean(cell untagged);
+       cell tag_boolean(cell untagged)
+       {
+               return (untagged ? true_object : false_object);
+       }
 
        //byte arrays
        byte_array *allot_byte_array(cell size);
@@ -352,7 +385,6 @@ struct factor_vm
        void primitive_resize_byte_array();
 
        template<typename Type> byte_array *byte_array_from_value(Type *value);
-       template<typename Type> byte_array *byte_array_from_values(Type *values, cell len);
 
        //tuples
        void primitive_tuple();
@@ -361,10 +393,13 @@ struct factor_vm
        //words
        word *allot_word(cell name_, cell vocab_, cell hashcode_);
        void primitive_word();
-       void primitive_word_xt();
-       void update_word_xt(word *w_);
+       void primitive_word_code();
+       void update_word_entry_point(word *w_);
        void primitive_optimized_p();
        void primitive_wrapper();
+       void jit_compile_word(cell word_, cell def_, bool relocating);
+       cell find_all_words();
+       void compile_all_words();
 
        //math
        void primitive_bignum_to_fixnum();
@@ -423,21 +458,19 @@ struct factor_vm
        void primitive_bits_double();
        fixnum to_fixnum(cell tagged);
        cell to_cell(cell tagged);
-       void box_signed_1(s8 n);
-       void box_unsigned_1(u8 n);
-       void box_signed_2(s16 n);
-       void box_unsigned_2(u16 n);
-       void box_signed_4(s32 n);
-       void box_unsigned_4(u32 n);
-       void box_signed_cell(fixnum integer);
-       void box_unsigned_cell(cell cell);
-       void box_signed_8(s64 n);
+       cell from_signed_1(s8 n);
+       cell from_unsigned_1(u8 n);
+       cell from_signed_2(s16 n);
+       cell from_unsigned_2(u16 n);
+       cell from_signed_4(s32 n);
+       cell from_unsigned_4(u32 n);
+       cell from_signed_cell(fixnum integer);
+       cell from_unsigned_cell(cell integer);
+       cell from_signed_8(s64 n);
        s64 to_signed_8(cell obj);
-       void box_unsigned_8(u64 n);
+       cell from_unsigned_8(u64 n);
        u64 to_unsigned_8(cell obj);
-       void box_float(float flo);
        float to_float(cell value);
-       void box_double(double flo);
        double to_double(cell value);
        inline void overflow_fixnum_add(fixnum x, fixnum y);
        inline void overflow_fixnum_subtract(fixnum x, fixnum y);
@@ -459,6 +492,7 @@ struct factor_vm
        void init_c_io();
        void io_error();
        void primitive_fopen();
+       FILE *pop_file_handle();
        void primitive_fgetc();
        void primitive_fread();
        void primitive_fputc();
@@ -469,31 +503,22 @@ struct factor_vm
        void primitive_fclose();
 
        //code_block
-       relocation_type relocation_type_of(relocation_entry r);
-       relocation_class relocation_class_of(relocation_entry r);
-       cell relocation_offset_of(relocation_entry r);
-       void flush_icache_for(code_block *block);
-       int number_of_parameters(relocation_type type);
-       void *object_xt(cell obj);
-       void *xt_pic(word *w, cell tagged_quot);
-       void *word_xt_pic(word *w);
-       void *word_xt_pic_tail(word *w);
-       void undefined_symbol();
-       void *get_rel_symbol(array *literals, cell index);
-       cell compute_relocation(relocation_entry rel, cell index, code_block *compiled);
-       template<typename Iterator> void iterate_relocations(code_block *compiled, Iterator &iter);
-       void store_address_2_2(cell *ptr, cell value);
-       void store_address_masked(cell *ptr, fixnum value, cell mask, fixnum shift);
-       void store_address_in_code_block(cell klass, cell offset, fixnum absolute_value);
-       void update_literal_references(code_block *compiled);
-       void relocate_code_block_step(relocation_entry rel, cell index, code_block *compiled);
+       cell compute_entry_point_address(cell obj);
+       cell compute_entry_point_pic_address(word *w, cell tagged_quot);
+       cell compute_entry_point_pic_address(cell w_);
+       cell compute_entry_point_pic_tail_address(cell w_);
+       cell code_block_owner(code_block *compiled);
        void update_word_references(code_block *compiled);
-       void update_code_block_words_and_literals(code_block *compiled);
        void check_code_address(cell address);
-       void relocate_code_block(code_block *compiled);
+       void undefined_symbol();
+       cell compute_dlsym_address(array *literals, cell index);
+       cell compute_vm_address(cell arg);
+       void store_external_address(instruction_operand op);
+       cell compute_here_address(cell arg, cell offset, code_block *compiled);
+       void initialize_code_block(code_block *compiled);
        void fixup_labels(array *labels, code_block *compiled);
        code_block *allot_code_block(cell size, code_block_type type);
-       code_block *add_code_block(code_block_type type, cell code_, cell labels_, cell owner_, cell relocation_, cell literals_);
+       code_block *add_code_block(code_block_type type, cell code_, cell labels_, cell owner_, cell relocation_, cell parameters_, cell literals_);
 
        //code heap
        inline void check_code_pointer(cell ptr)
@@ -505,17 +530,13 @@ struct factor_vm
 
        void init_code_heap(cell size);
        bool in_code_heap_p(cell ptr);
-       void jit_compile_word(cell word_, cell def_, bool relocate);
        void update_code_heap_words();
-       void update_code_heap_words_and_literals();
-       void relocate_code_heap();
        void primitive_modify_code_heap();
        code_heap_room code_room();
        void primitive_code_room();
        void primitive_strip_stack_traces();
 
-       /* Apply a function to every code block */
-       template<typename Iterator> void iterate_code_heap(Iterator &iter)
+       template<typename Iterator> void each_code_block(Iterator &iter)
        {
                code->allocator->iterate(iter);
        }
@@ -531,16 +552,8 @@ struct factor_vm
        bool save_image(const vm_char *filename);
        void primitive_save_image();
        void primitive_save_image_and_exit();
-       void data_fixup(cell *handle, cell data_relocation_base);
-       template<typename Type> void code_fixup(Type **handle, cell code_relocation_base);
-       void fixup_word(word *word, cell code_relocation_base);
-       void fixup_quotation(quotation *quot, cell code_relocation_base);
-       void fixup_alien(alien *d);
-       void fixup_callstack_object(callstack *stack, cell code_relocation_base);
-       void relocate_object(object *object, cell data_relocation_base, cell code_relocation_base);
-       void relocate_data(cell data_relocation_base, cell code_relocation_base);
-       void fixup_code_block(code_block *compiled, cell data_relocation_base);
-       void relocate_code(cell data_relocation_base);
+       void fixup_data(cell data_offset, cell code_offset);
+       void fixup_code(cell data_offset, cell code_offset);
        void load_image(vm_parameters *p);
 
        //callstack
@@ -548,44 +561,25 @@ struct factor_vm
        void check_frame(stack_frame *frame);
        callstack *allot_callstack(cell size);
        stack_frame *fix_callstack_top(stack_frame *top, stack_frame *bottom);
-       stack_frame *capture_start();
+       stack_frame *second_from_top_stack_frame();
        void primitive_callstack();
-       void primitive_set_callstack();
        code_block *frame_code(stack_frame *frame);
        code_block_type frame_type(stack_frame *frame);
        cell frame_executing(stack_frame *frame);
+       cell frame_executing_quot(stack_frame *frame);
        stack_frame *frame_successor(stack_frame *frame);
        cell frame_scan(stack_frame *frame);
        void primitive_callstack_to_array();
        stack_frame *innermost_stack_frame(callstack *stack);
-       stack_frame *innermost_stack_frame_quot(callstack *callstack);
        void primitive_innermost_stack_frame_executing();
        void primitive_innermost_stack_frame_scan();
        void primitive_set_innermost_stack_frame_quot();
-       void save_callstack_bottom(stack_frame *callstack_bottom);
        template<typename Iterator> void iterate_callstack(context *ctx, Iterator &iterator);
 
-       /* Every object has a regular representation in the runtime, which makes GC
-       much simpler. Every slot of the object until binary_payload_start is a pointer
-       to some other object. */
-       template<typename Iterator> void do_slots(cell obj, Iterator &iter)
-       {
-               cell scan = obj;
-               cell payload_start = ((object *)obj)->binary_payload_start();
-               cell end = obj + payload_start;
-
-               scan += sizeof(cell);
-
-               while(scan < end)
-               {
-                       iter((cell *)scan);
-                       scan += sizeof(cell);
-               }
-       }
-
        //alien
        char *pinned_alien_offset(cell obj);
        cell allot_alien(cell delegate_, cell displacement);
+       cell allot_alien(void *address);
        void primitive_displaced_alien();
        void primitive_alien_address();
        void *alien_pointer();
@@ -593,25 +587,26 @@ struct factor_vm
        void primitive_dlsym();
        void primitive_dlclose();
        void primitive_dll_validp();
-       void primitive_vm_ptr();
        char *alien_offset(cell obj);
-       char *unbox_alien();
-       void box_alien(void *ptr);
        void to_value_struct(cell src, void *dest, cell size);
-       void box_value_struct(void *src, cell size);
-       void box_small_struct(cell x, cell y, cell size);
-       void box_medium_struct(cell x1, cell x2, cell x3, cell x4, cell size);
+       cell from_value_struct(void *src, cell size);
+       cell from_small_struct(cell x, cell y, cell size);
+       cell from_medium_struct(cell x1, cell x2, cell x3, cell x4, cell size);
 
        //quotations
        void primitive_jit_compile();
+       code_block *lazy_jit_compile_block();
        void primitive_array_to_quotation();
-       void primitive_quotation_xt();
-       void set_quot_xt(quotation *quot, code_block *code);
-       void jit_compile(cell quot_, bool relocating);
-       void compile_all_words();
+       void primitive_quotation_code();
+       void set_quot_entry_point(quotation *quot, code_block *code);
+       code_block *jit_compile_quot(cell owner_, cell quot_, bool relocating);
+       void jit_compile_quot(cell quot_, bool relocating);
        fixnum quot_code_offset_to_scan(cell quot_, cell offset);
-       cell lazy_jit_compile_impl(cell quot_, stack_frame *stack);
+       cell lazy_jit_compile(cell quot);
+       bool quot_compiled_p(quotation *quot);
        void primitive_quot_compiled_p();
+       cell find_all_quotations();
+       void initialize_all_quotations();
 
        //dispatch
        cell search_lookup_alist(cell table, cell klass);
@@ -640,14 +635,19 @@ struct factor_vm
        void update_pic_transitions(cell pic_size);
        void *inline_cache_miss(cell return_address);
 
+       //entry points
+       void c_to_factor(cell quot);
+       void unwind_native_frames(cell quot, stack_frame *to);
+
        //factor
        void default_parameters(vm_parameters *p);
-       bool factor_arg(const vm_char* str, const vm_char* arg, cell* value);
+       bool factor_arg(const vm_char *str, const vm_char *arg, cell *value);
        void init_parameters_from_args(vm_parameters *p, int argc, vm_char **argv);
-       void do_stage1_init();
+       void prepare_boot_image();
        void init_factor(vm_parameters *p);
        void pass_args_to_factor(int argc, vm_char **argv);
        void start_factor(vm_parameters *p);
+       void stop_factor();
        void start_embedded_factor(vm_parameters *p);
        void start_standalone_factor(int argc, vm_char **argv);
        char *factor_eval_string(char *string);
@@ -665,11 +665,10 @@ struct factor_vm
 
        // os-windows
   #if defined(WINDOWS)
-       void sleep_micros(u64 usec);
        const vm_char *vm_executable_path();
        const vm_char *default_image_path();
        void windows_image_path(vm_char *full_path, vm_char *temp_path, unsigned int length);
-       bool windows_stat(vm_char *path);
+       BOOL windows_stat(vm_char *path);
 
   #if defined(WINNT)
        void open_console();
index dfaeed2496300b5e844a9f49dc088f2a11934a4b..31041a6a1964a8871a2df5663748b1ebe7ac3afa 100644 (file)
@@ -3,6 +3,45 @@
 namespace factor
 {
 
+/* Compile a word definition with the non-optimizing compiler. Allocates memory */
+void factor_vm::jit_compile_word(cell word_, cell def_, bool relocating)
+{
+       data_root<word> word(word_,this);
+       data_root<quotation> def(def_,this);
+
+       /* Refuse to compile this word more than once, because quot_compiled_p()
+       depends on the identity of its code block */
+       if(word->code && word.value() == special_objects[LAZY_JIT_COMPILE_WORD])
+               return;
+
+       code_block *compiled = jit_compile_quot(word.value(),def.value(),relocating);
+       word->code = compiled;
+
+       if(to_boolean(word->pic_def)) jit_compile_quot(word->pic_def,relocating);
+       if(to_boolean(word->pic_tail_def)) jit_compile_quot(word->pic_tail_def,relocating);
+}
+
+cell factor_vm::find_all_words()
+{
+       return instances(WORD_TYPE);
+}
+
+void factor_vm::compile_all_words()
+{
+       data_root<array> words(find_all_words(),this);
+
+       cell length = array_capacity(words.untagged());
+       for(cell i = 0; i < length; i++)
+       {
+               data_root<word> word(array_nth(words.untagged(),i),this);
+
+               if(!word->code || !word->code->optimized_p())
+                       jit_compile_word(word.value(),word->def,false);
+
+               update_word_entry_point(word.untagged());
+       }
+}
+
 word *factor_vm::allot_word(cell name_, cell vocab_, cell hashcode_)
 {
        data_root<object> vocab(vocab_,this);
@@ -23,10 +62,14 @@ word *factor_vm::allot_word(cell name_, cell vocab_, cell hashcode_)
        new_word->code = NULL;
 
        jit_compile_word(new_word.value(),new_word->def,true);
-       update_word_xt(new_word.untagged());
-
        if(profiling_p)
-               relocate_code_block(new_word->profiling);
+       {
+               code_block *profiling_block = compile_profiling_stub(new_word.value());
+               new_word->profiling = profiling_block;
+               initialize_code_block(new_word->profiling);
+       }
+
+       update_word_entry_point(new_word.untagged());
 
        return new_word.untagged();
 }
@@ -34,63 +77,49 @@ word *factor_vm::allot_word(cell name_, cell vocab_, cell hashcode_)
 /* (word) ( name vocabulary hashcode -- word ) */
 void factor_vm::primitive_word()
 {
-       cell hashcode = dpop();
-       cell vocab = dpop();
-       cell name = dpop();
-       dpush(tag<word>(allot_word(name,vocab,hashcode)));
+       cell hashcode = ctx->pop();
+       cell vocab = ctx->pop();
+       cell name = ctx->pop();
+       ctx->push(tag<word>(allot_word(name,vocab,hashcode)));
 }
 
-/* word-xt ( word -- start end ) */
-void factor_vm::primitive_word_xt()
+/* word-code ( word -- start end ) */
+void factor_vm::primitive_word_code()
 {
-       data_root<word> w(dpop(),this);
+       data_root<word> w(ctx->pop(),this);
        w.untag_check(this);
 
        if(profiling_p)
        {
-               dpush(allot_cell((cell)w->profiling->xt()));
-               dpush(allot_cell((cell)w->profiling + w->profiling->size()));
+               ctx->push(allot_cell((cell)w->profiling->entry_point()));
+               ctx->push(allot_cell((cell)w->profiling + w->profiling->size()));
        }
        else
        {
-               dpush(allot_cell((cell)w->code->xt()));
-               dpush(allot_cell((cell)w->code + w->code->size()));
+               ctx->push(allot_cell((cell)w->code->entry_point()));
+               ctx->push(allot_cell((cell)w->code + w->code->size()));
        }
 }
 
-/* Allocates memory */
-void factor_vm::update_word_xt(word *w_)
+void factor_vm::update_word_entry_point(word *w)
 {
-       data_root<word> w(w_,this);
-
-       if(profiling_p)
-       {
-               if(!w->profiling)
-               {
-                       /* Note: can't do w->profiling = ... since LHS evaluates
-                       before RHS, and if RHS does a GC, we will have an
-                       invalid pointer on the LHS */
-                       code_block *profiling = compile_profiling_stub(w.value());
-                       w->profiling = profiling;
-               }
-
-               w->xt = w->profiling->xt();
-       }
+       if(profiling_p && w->profiling)
+               w->entry_point = w->profiling->entry_point();
        else
-               w->xt = w->code->xt();
+               w->entry_point = w->code->entry_point();
 }
 
 void factor_vm::primitive_optimized_p()
 {
-       word *w = untag_check<word>(dpeek());
-       drepl(tag_boolean(w->code->optimized_p()));
+       word *w = untag_check<word>(ctx->peek());
+       ctx->replace(tag_boolean(w->code->optimized_p()));
 }
 
 void factor_vm::primitive_wrapper()
 {
        wrapper *new_wrapper = allot<wrapper>(sizeof(wrapper));
-       new_wrapper->object = dpeek();
-       drepl(tag<wrapper>(new_wrapper));
+       new_wrapper->object = ctx->peek();
+       ctx->replace(tag<wrapper>(new_wrapper));
 }
 
 }