From aea0fed14c26bb9ef5e1b0e9a3cddd7578566f44 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Fri, 5 Sep 2008 19:29:14 -0500 Subject: [PATCH] Fixing basis -> extra dependencies --- basis/channels/channels.factor | 4 +- .../analyzer => checksums/common}/authors.txt | 0 basis/checksums/common/common.factor | 21 +++++ basis/checksums/common/summary.txt | 1 + basis/checksums/md5/md5.factor | 11 ++- basis/checksums/sha1/sha1.factor | 21 ++++- basis/checksums/sha2/sha2.factor | 19 +++- basis/cocoa/windows/windows.factor | 2 +- basis/compiler/generator/fixup/fixup.factor | 2 +- .../cpu/ppc/assembler/backend/backend.factor | 2 +- basis/db/db.factor | 4 +- basis/db/postgresql/postgresql.factor | 4 +- basis/db/queries/queries.factor | 11 +-- basis/db/sql/sql.factor | 4 +- basis/db/sqlite/sqlite.factor | 14 ++- basis/db/tuples/tuples-tests.factor | 4 +- basis/db/tuples/tuples.factor | 10 +- basis/db/types/types.factor | 2 +- basis/html/forms/forms.factor | 2 +- basis/http/http.factor | 7 +- basis/io/unix/files/files.factor | 2 +- basis/io/unix/files/unique/unique.factor | 2 +- basis/io/unix/kqueue/kqueue.factor | 2 +- basis/io/unix/linux/monitors/monitors.factor | 2 +- basis/io/unix/mmap/mmap.factor | 2 +- basis/io/windows/files/files.factor | 3 +- basis/io/windows/mmap/mmap.factor | 2 +- basis/io/windows/nt/monitors/monitors.factor | 2 +- basis/io/windows/nt/pipes/pipes.factor | 2 +- .../windows/nt/privileges/privileges.factor | 2 +- basis/io/windows/windows.factor | 2 +- basis/lcs/lcs.factor | 3 +- basis/logging/parser/parser.factor | 3 +- basis/math/bitfields/bitfields-tests.factor | 27 ------ basis/math/bitfields/bitfields.factor | 37 -------- basis/math/bitfields/summary.txt | 1 - basis/math/{bitfields => bitwise}/authors.txt | 1 + .../bitwise-docs.factor} | 15 ++- basis/math/bitwise/bitwise-tests.factor | 29 ++++++ basis/math/bitwise/bitwise.factor | 94 +++++++++++++++++++ basis/math/bitwise/summary.txt | 1 + basis/nmake/nmake-tests.factor | 8 ++ basis/nmake/nmake.factor | 44 +++++++++ basis/openssl/libssl/libssl.factor | 2 +- basis/peg/ebnf/ebnf.factor | 2 +- {extra => basis}/peg/search/authors.txt | 0 .../peg/search/search-docs.factor | 0 .../peg/search/search-tests.factor | 0 {extra => basis}/peg/search/search.factor | 0 {extra => basis}/peg/search/summary.txt | 0 {extra => basis}/peg/search/tags.txt | 0 .../hashtables/nodes/bitmap/bitmap.factor | 4 +- .../nodes/collision/collision.factor | 2 +- .../hashtables/nodes/full/full.factor | 2 +- .../persistent/hashtables/nodes/nodes.factor | 2 +- .../mersenne-twister/mersenne-twister.factor | 2 +- basis/random/random-tests.factor | 5 +- basis/random/random.factor | 3 + basis/smtp/smtp.factor | 24 +---- basis/state-parser/state-parser.factor | 4 +- basis/tools/scaffold/scaffold.factor | 16 ++-- basis/ui/gadgets/canvas/canvas.factor | 2 +- basis/ui/gadgets/lib/lib.factor | 8 -- basis/ui/gadgets/slate/authors.txt | 1 - basis/ui/gadgets/worlds/worlds.factor | 6 ++ basis/ui/windows/windows.factor | 2 +- basis/unix/linux/inotify/inotify.factor | 2 +- basis/validators/validators.factor | 2 +- basis/windows/advapi32/advapi32.factor | 2 +- basis/windows/opengl32/opengl32.factor | 2 +- basis/windows/user32/user32.factor | 2 +- basis/windows/winsock/winsock.factor | 2 +- basis/x11/windows/windows.factor | 4 +- basis/x11/xlib/xlib.factor | 2 +- basis/xml/generator/generator.factor | 56 +---------- basis/xmode/marker/marker.factor | 2 +- core/sequences/sequences-docs.factor | 9 ++ core/sequences/sequences-tests.factor | 3 + core/sequences/sequences.factor | 14 +++ extra/crypto/common/common.factor | 40 +------- .../html/parser/analyzer/analyzer.factor | 0 .../html/parser/analyzer}/authors.txt | 0 .../printer => extra/html/parser}/authors.txt | 0 .../html/parser/parser-tests.factor | 0 {basis => extra}/html/parser/parser.factor | 0 .../html/parser/printer}/authors.txt | 0 .../html/parser/printer/printer.factor | 0 .../html/parser/utils}/authors.txt | 0 .../html/parser/utils/utils-tests.factor | 0 .../html/parser/utils/utils.factor | 0 extra/io/files/unique/unique.factor | 2 +- extra/io/serial/serial.factor | 2 +- extra/io/serial/unix/bsd/bsd.factor | 2 +- extra/io/serial/unix/unix-tests.factor | 2 +- extra/io/serial/unix/unix.factor | 2 +- extra/math/bit-count/bit-count.factor | 38 -------- extra/math/bitfields/lib/lib-docs.factor | 16 ---- extra/math/bitfields/lib/lib-tests.factor | 14 --- extra/math/bitfields/lib/lib.factor | 30 ------ extra/namespaces/lib/lib-tests.factor | 7 -- extra/namespaces/lib/lib.factor | 39 -------- .../opengl/capabilities/authors.txt | 0 .../capabilities/capabilities-docs.factor | 0 .../opengl/capabilities/capabilities.factor | 0 .../opengl/capabilities/summary.txt | 0 {basis => extra}/opengl/capabilities/tags.txt | 0 .../opengl/demo-support/authors.txt | 0 .../opengl/demo-support/demo-support.factor | 0 .../opengl/demo-support/summary.txt | 0 {basis => extra}/opengl/demo-support/tags.txt | 0 .../opengl/framebuffers/authors.txt | 0 .../framebuffers/framebuffers-docs.factor | 0 .../opengl/framebuffers/framebuffers.factor | 0 .../opengl/framebuffers/summary.txt | 0 {basis => extra}/opengl/framebuffers/tags.txt | 0 .../opengl/gadgets/gadgets-tests.factor | 0 .../opengl/gadgets/gadgets.factor | 0 {basis => extra}/opengl/shaders/authors.txt | 0 .../opengl/shaders/shaders-docs.factor | 0 .../opengl/shaders/shaders.factor | 0 {basis => extra}/opengl/shaders/summary.txt | 0 {basis => extra}/opengl/shaders/tags.txt | 0 extra/pack/pack.factor | 2 +- extra/sequences/lib/lib-tests.factor | 6 -- extra/sequences/lib/lib.factor | 9 -- extra/serial/serial.factor | 2 +- extra/serial/unix/bsd/bsd.factor | 2 +- extra/serial/unix/unix-tests.factor | 2 +- extra/serial/unix/unix.factor | 2 +- .../ui/gadgets/cartesian/cartesian.factor | 0 .../gadgets/frame-buffer/frame-buffer.factor | 0 .../ui/gadgets/handler/authors.txt | 0 .../ui/gadgets/handler/handler.factor | 0 {basis => extra}/ui/gadgets/plot/plot.factor | 0 .../ui/gadgets/slate}/authors.txt | 0 .../ui/gadgets/slate/slate.factor | 0 {basis => extra}/ui/gadgets/tabs/authors.txt | 0 {basis => extra}/ui/gadgets/tabs/summary.txt | 0 {basis => extra}/ui/gadgets/tabs/tabs.factor | 0 .../ui/gadgets/tiling/tiling.factor | 0 .../constants => extra/units}/authors.txt | 0 .../units/constants}/authors.txt | 0 .../units/constants/constants.factor | 0 .../units/constants/constants.txt | 0 .../si => extra/units/imperial}/authors.txt | 0 .../units/imperial/imperial-tests.factor | 0 .../units/imperial/imperial.factor | 0 extra/units/si/authors.txt | 1 + {basis => extra}/units/si/si-tests.factor | 0 {basis => extra}/units/si/si.factor | 0 {basis => extra}/units/units-tests.factor | 0 {basis => extra}/units/units.factor | 0 extra/x/widgets/wm/frame/frame.factor | 2 +- extra/xml/syntax/syntax.factor | 58 ++++++++++++ 154 files changed, 448 insertions(+), 452 deletions(-) rename basis/{html/parser/analyzer => checksums/common}/authors.txt (100%) mode change 100755 => 100644 create mode 100644 basis/checksums/common/common.factor create mode 100644 basis/checksums/common/summary.txt delete mode 100755 basis/math/bitfields/bitfields-tests.factor delete mode 100644 basis/math/bitfields/bitfields.factor delete mode 100644 basis/math/bitfields/summary.txt rename basis/math/{bitfields => bitwise}/authors.txt (50%) rename basis/math/{bitfields/bitfields-docs.factor => bitwise/bitwise-docs.factor} (75%) create mode 100755 basis/math/bitwise/bitwise-tests.factor create mode 100644 basis/math/bitwise/bitwise.factor create mode 100644 basis/math/bitwise/summary.txt create mode 100644 basis/nmake/nmake-tests.factor create mode 100644 basis/nmake/nmake.factor rename {extra => basis}/peg/search/authors.txt (100%) rename {extra => basis}/peg/search/search-docs.factor (100%) rename {extra => basis}/peg/search/search-tests.factor (100%) rename {extra => basis}/peg/search/search.factor (100%) rename {extra => basis}/peg/search/summary.txt (100%) rename {extra => basis}/peg/search/tags.txt (100%) delete mode 100644 basis/ui/gadgets/lib/lib.factor delete mode 100755 basis/ui/gadgets/slate/authors.txt rename {basis => extra}/html/parser/analyzer/analyzer.factor (100%) rename {basis/html/parser => extra/html/parser/analyzer}/authors.txt (100%) rename {basis/html/parser/printer => extra/html/parser}/authors.txt (100%) rename {basis => extra}/html/parser/parser-tests.factor (100%) rename {basis => extra}/html/parser/parser.factor (100%) rename {basis/html/parser/utils => extra/html/parser/printer}/authors.txt (100%) rename {basis => extra}/html/parser/printer/printer.factor (100%) rename {basis/units => extra/html/parser/utils}/authors.txt (100%) rename {basis => extra}/html/parser/utils/utils-tests.factor (100%) rename {basis => extra}/html/parser/utils/utils.factor (100%) delete mode 100644 extra/math/bit-count/bit-count.factor delete mode 100644 extra/math/bitfields/lib/lib-docs.factor delete mode 100644 extra/math/bitfields/lib/lib-tests.factor delete mode 100644 extra/math/bitfields/lib/lib.factor rename {basis => extra}/opengl/capabilities/authors.txt (100%) rename {basis => extra}/opengl/capabilities/capabilities-docs.factor (100%) rename {basis => extra}/opengl/capabilities/capabilities.factor (100%) rename {basis => extra}/opengl/capabilities/summary.txt (100%) rename {basis => extra}/opengl/capabilities/tags.txt (100%) rename {basis => extra}/opengl/demo-support/authors.txt (100%) rename {basis => extra}/opengl/demo-support/demo-support.factor (100%) rename {basis => extra}/opengl/demo-support/summary.txt (100%) rename {basis => extra}/opengl/demo-support/tags.txt (100%) rename {basis => extra}/opengl/framebuffers/authors.txt (100%) rename {basis => extra}/opengl/framebuffers/framebuffers-docs.factor (100%) rename {basis => extra}/opengl/framebuffers/framebuffers.factor (100%) rename {basis => extra}/opengl/framebuffers/summary.txt (100%) rename {basis => extra}/opengl/framebuffers/tags.txt (100%) rename {basis => extra}/opengl/gadgets/gadgets-tests.factor (100%) rename {basis => extra}/opengl/gadgets/gadgets.factor (100%) rename {basis => extra}/opengl/shaders/authors.txt (100%) rename {basis => extra}/opengl/shaders/shaders-docs.factor (100%) rename {basis => extra}/opengl/shaders/shaders.factor (100%) rename {basis => extra}/opengl/shaders/summary.txt (100%) rename {basis => extra}/opengl/shaders/tags.txt (100%) rename {basis => extra}/ui/gadgets/cartesian/cartesian.factor (100%) rename {basis => extra}/ui/gadgets/frame-buffer/frame-buffer.factor (100%) rename {basis => extra}/ui/gadgets/handler/authors.txt (100%) rename {basis => extra}/ui/gadgets/handler/handler.factor (100%) rename {basis => extra}/ui/gadgets/plot/plot.factor (100%) rename {basis/ui/gadgets/lib => extra/ui/gadgets/slate}/authors.txt (100%) rename {basis => extra}/ui/gadgets/slate/slate.factor (100%) rename {basis => extra}/ui/gadgets/tabs/authors.txt (100%) rename {basis => extra}/ui/gadgets/tabs/summary.txt (100%) rename {basis => extra}/ui/gadgets/tabs/tabs.factor (100%) rename {basis => extra}/ui/gadgets/tiling/tiling.factor (100%) rename {basis/units/constants => extra/units}/authors.txt (100%) rename {basis/units/imperial => extra/units/constants}/authors.txt (100%) rename {basis => extra}/units/constants/constants.factor (100%) rename {basis => extra}/units/constants/constants.txt (100%) rename {basis/units/si => extra/units/imperial}/authors.txt (100%) rename {basis => extra}/units/imperial/imperial-tests.factor (100%) rename {basis => extra}/units/imperial/imperial.factor (100%) create mode 100755 extra/units/si/authors.txt rename {basis => extra}/units/si/si-tests.factor (100%) rename {basis => extra}/units/si/si.factor (100%) rename {basis => extra}/units/units-tests.factor (100%) rename {basis => extra}/units/units.factor (100%) create mode 100644 extra/xml/syntax/syntax.factor diff --git a/basis/channels/channels.factor b/basis/channels/channels.factor index 9b5cbee04b..545d8a0e1d 100755 --- a/basis/channels/channels.factor +++ b/basis/channels/channels.factor @@ -2,8 +2,8 @@ ! See http://factorcode.org/license.txt for BSD license. ! ! Channels - based on ideas from newsqueak -USING: kernel sequences sequences.lib threads continuations -random math accessors ; +USING: kernel sequences threads continuations +random math accessors random ; IN: channels TUPLE: channel receivers senders ; diff --git a/basis/html/parser/analyzer/authors.txt b/basis/checksums/common/authors.txt old mode 100755 new mode 100644 similarity index 100% rename from basis/html/parser/analyzer/authors.txt rename to basis/checksums/common/authors.txt diff --git a/basis/checksums/common/common.factor b/basis/checksums/common/common.factor new file mode 100644 index 0000000000..ea1c6f5b39 --- /dev/null +++ b/basis/checksums/common/common.factor @@ -0,0 +1,21 @@ +! Copyright (C) 2006, 2008 Doug Coleman. +! See http://factorcode.org/license.txt for BSD license. +USING: kernel math math.bitwise strings io.binary namespaces +grouping ; +IN: checksums.common + +SYMBOL: bytes-read + +: calculate-pad-length ( length -- pad-length ) + dup 56 < 55 119 ? swap - ; + +: pad-last-block ( str big-endian? length -- str ) + [ + rot % + HEX: 80 , + dup HEX: 3f bitand calculate-pad-length 0 % + 3 shift 8 rot [ >be ] [ >le ] if % + ] "" make 64 group ; + +: update-old-new ( old new -- ) + [ get >r get r> ] 2keep >r >r w+ dup r> set r> set ; inline diff --git a/basis/checksums/common/summary.txt b/basis/checksums/common/summary.txt new file mode 100644 index 0000000000..0956c052a4 --- /dev/null +++ b/basis/checksums/common/summary.txt @@ -0,0 +1 @@ +Some code shared by MD5, SHA1 and SHA2 implementations diff --git a/basis/checksums/md5/md5.factor b/basis/checksums/md5/md5.factor index f0e0c71c19..6158254f84 100755 --- a/basis/checksums/md5/md5.factor +++ b/basis/checksums/md5/md5.factor @@ -1,11 +1,14 @@ -! See http://www.faqs.org/rfcs/rfc1321.html - +! Copyright (C) 2006, 2008 Doug Coleman. +! See http://factorcode.org/license.txt for BSD license. USING: kernel io io.binary io.files io.streams.byte-array math math.functions math.parser namespaces splitting grouping strings -sequences crypto.common byte-arrays locals sequences.private -io.encodings.binary symbols math.bitfields.lib checksums ; +sequences byte-arrays locals sequences.private +io.encodings.binary symbols math.bitwise checksums +checksums.common ; IN: checksums.md5 +! See http://www.faqs.org/rfcs/rfc1321.html + be> ; inline + : make-w ( str -- ) #! compute w, steps a-b of RFC 3174, section 6.1 16 [ nth-int-be w get push ] with each @@ -113,6 +118,14 @@ INSTANCE: sha1 checksum M: sha1 checksum-stream ( stream -- sha1 ) drop [ initialize-sha1 stream>sha1 get-sha1 ] with-input-stream ; +: seq>2seq ( seq -- seq1 seq2 ) + #! { abcdefgh } -> { aceg } { bdfh } + 2 group flip dup empty? [ drop { } { } ] [ first2 ] if ; + +: 2seq>seq ( seq1 seq2 -- seq ) + #! { aceg } { bdfh } -> { abcdefgh } + [ zip concat ] keep like ; + : sha1-interleave ( string -- seq ) [ zero? ] left-trim dup length odd? [ rest ] when diff --git a/basis/checksums/sha2/sha2.factor b/basis/checksums/sha2/sha2.factor index 6cf7914e6c..ac93c05260 100755 --- a/basis/checksums/sha2/sha2.factor +++ b/basis/checksums/sha2/sha2.factor @@ -1,6 +1,8 @@ -USING: crypto.common kernel splitting grouping -math sequences namespaces io.binary symbols -math.bitfields.lib checksums ; +! Copyright (C) 2008 Doug Coleman. +! See http://factorcode.org/license.txt for BSD license. +USING: kernel splitting grouping math sequences namespaces +io.binary symbols math.bitwise checksums checksums.common +sbufs strings ; IN: checksums.sha2 r dup 3 + r> first3 ; inline + : T1 ( W n -- T1 ) [ swap nth ] keep K get nth + @@ -112,6 +116,15 @@ SYMBOLS: vars M K H S0 S1 process-M word-size block-size ; : seq>byte-array ( n seq -- string ) [ swap [ >be % ] curry each ] B{ } make ; +: preprocess-plaintext ( string big-endian? -- padded-string ) + #! pad 0x80 then 00 til 8 bytes left, then 64bit length in bits + >r >sbuf r> over [ + HEX: 80 , + dup length HEX: 3f bitand + calculate-pad-length 0 % + length 3 shift 8 rot [ >be ] [ >le ] if % + ] "" make over push-all ; + : byte-array>sha2 ( byte-array -- string ) t preprocess-plaintext block-size get group [ process-chunk ] each diff --git a/basis/cocoa/windows/windows.factor b/basis/cocoa/windows/windows.factor index 74a181f9a2..dd2d1bfd41 100755 --- a/basis/cocoa/windows/windows.factor +++ b/basis/cocoa/windows/windows.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2006, 2007 Slava Pestov ! See http://factorcode.org/license.txt for BSD license. USING: arrays kernel math cocoa cocoa.messages cocoa.classes -sequences math.bitfields ; +sequences math.bitwise ; IN: cocoa.windows : NSBorderlessWindowMask 0 ; inline diff --git a/basis/compiler/generator/fixup/fixup.factor b/basis/compiler/generator/fixup/fixup.factor index ae30502524..5a3337fb32 100755 --- a/basis/compiler/generator/fixup/fixup.factor +++ b/basis/compiler/generator/fixup/fixup.factor @@ -3,7 +3,7 @@ USING: arrays byte-arrays generic assocs hashtables io.binary kernel kernel.private math namespaces sequences words quotations strings alien.accessors alien.strings layouts system -combinators math.bitfields words.private cpu.architecture +combinators math.bitwise words.private cpu.architecture math.order accessors growable ; IN: compiler.generator.fixup diff --git a/basis/cpu/ppc/assembler/backend/backend.factor b/basis/cpu/ppc/assembler/backend/backend.factor index 072f50520c..b881f5a974 100644 --- a/basis/cpu/ppc/assembler/backend/backend.factor +++ b/basis/cpu/ppc/assembler/backend/backend.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: compiler.generator.fixup kernel namespaces sequences -words math math.bitfields io.binary parser lexer ; +words math math.bitwise io.binary parser lexer ; IN: cpu.ppc.assembler.backend : insn ( operand opcode -- ) { 26 0 } bitfield , ; diff --git a/basis/db/db.factor b/basis/db/db.factor index c269341240..10da653c9f 100755 --- a/basis/db/db.factor +++ b/basis/db/db.factor @@ -1,8 +1,8 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. USING: arrays assocs classes continuations destructors kernel math -namespaces sequences sequences.lib classes.tuple words strings -tools.walker accessors combinators.lib combinators ; +namespaces sequences classes.tuple words strings +tools.walker accessors combinators ; IN: db TUPLE: db diff --git a/basis/db/postgresql/postgresql.factor b/basis/db/postgresql/postgresql.factor index 692241fab0..d833063b51 100755 --- a/basis/db/postgresql/postgresql.factor +++ b/basis/db/postgresql/postgresql.factor @@ -4,8 +4,8 @@ USING: arrays assocs alien alien.syntax continuations io kernel math math.parser namespaces prettyprint quotations sequences debugger db db.postgresql.lib db.postgresql.ffi db.tuples db.types tools.annotations math.ranges -combinators sequences.lib classes locals words tools.walker -namespaces.lib accessors random db.queries destructors ; +combinators classes locals words tools.walker +nmake accessors random db.queries destructors ; USE: tools.walker IN: db.postgresql diff --git a/basis/db/queries/queries.factor b/basis/db/queries/queries.factor index e5334703f6..a28f283d30 100644 --- a/basis/db/queries/queries.factor +++ b/basis/db/queries/queries.factor @@ -1,9 +1,8 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors kernel math namespaces sequences random -strings math.parser math.intervals combinators -math.bitfields.lib namespaces.lib db db.tuples db.types -sequences.lib db.sql classes words shuffle arrays ; +USING: accessors kernel math namespaces sequences random strings +math.parser math.intervals combinators math.bitwise nmake db +db.tuples db.types db.sql classes words shuffle arrays ; IN: db.queries GENERIC: where ( specs obj -- ) @@ -142,8 +141,8 @@ M: db ( tuple class -- statement ) : make-query ( tuple query -- tuple' ) dupd { - [ group>> [ do-group ] [ drop ] if-seq ] - [ order>> [ do-order ] [ drop ] if-seq ] + [ group>> [ drop ] [ do-group ] if-empty ] + [ order>> [ drop ] [ do-order ] if-empty ] [ limit>> [ do-limit ] [ drop ] if* ] [ offset>> [ do-offset ] [ drop ] if* ] } 2cleave ; diff --git a/basis/db/sql/sql.factor b/basis/db/sql/sql.factor index 7dd4abf4be..06428485e1 100755 --- a/basis/db/sql/sql.factor +++ b/basis/db/sql/sql.factor @@ -1,6 +1,6 @@ USING: kernel parser quotations classes.tuple words math.order -namespaces.lib namespaces sequences arrays combinators -prettyprint strings math.parser sequences.lib math symbols ; +nmake namespaces sequences arrays combinators +prettyprint strings math.parser math symbols ; IN: db.sql SYMBOLS: insert update delete select distinct columns from as diff --git a/basis/db/sqlite/sqlite.factor b/basis/db/sqlite/sqlite.factor index 49d79b1b8c..dc8104ba00 100755 --- a/basis/db/sqlite/sqlite.factor +++ b/basis/db/sqlite/sqlite.factor @@ -1,13 +1,11 @@ ! Copyright (C) 2005, 2008 Chris Double, Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. -USING: alien arrays assocs classes compiler db -hashtables io.files kernel math math.parser namespaces -prettyprint sequences strings classes.tuple alien.c-types -continuations db.sqlite.lib db.sqlite.ffi db.tuples -words combinators.lib db.types combinators math.intervals -io namespaces.lib accessors vectors math.ranges random -math.bitfields.lib db.queries destructors ; -USE: tools.walker +USING: alien arrays assocs classes compiler db hashtables +io.files kernel math math.parser namespaces prettyprint +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.bitwise db.queries destructors ; IN: db.sqlite TUPLE: sqlite-db < db path ; diff --git a/basis/db/tuples/tuples-tests.factor b/basis/db/tuples/tuples-tests.factor index 5dd3ec8ae0..3b04454995 100755 --- a/basis/db/tuples/tuples-tests.factor +++ b/basis/db/tuples/tuples-tests.factor @@ -3,8 +3,8 @@ USING: io.files kernel tools.test db db.tuples classes db.types continuations namespaces math math.ranges prettyprint calendar sequences db.sqlite math.intervals -db.postgresql accessors random math.bitfields.lib -math.ranges strings sequences.lib urls fry ; +db.postgresql accessors random math.bitwise +math.ranges strings urls fry ; IN: db.tuples.tests TUPLE: person the-id the-name the-number the-real diff --git a/basis/db/tuples/tuples.factor b/basis/db/tuples/tuples.factor index 1b7ab24366..437224ea5a 100755 --- a/basis/db/tuples/tuples.factor +++ b/basis/db/tuples/tuples.factor @@ -3,7 +3,7 @@ USING: arrays assocs classes db kernel namespaces classes.tuple words sequences slots math accessors math.parser io prettyprint db.types continuations -destructors mirrors sequences.lib combinators.lib ; +destructors mirrors ; IN: db.tuples : define-persistent ( class table columns -- ) @@ -71,13 +71,14 @@ SINGLETON: retryable ] 2map >>bind-params ; M: retryable execute-statement* ( statement type -- ) - drop [ + drop [ retries>> ] [ [ + nip [ query-results dispose t ] [ ] [ regenerate-params bind-statement* f ] cleanup ] curry - ] [ retries>> ] bi retry drop ; + ] bi attempt-all drop ; : resulting-tuple ( class row out-params -- tuple ) rot class new [ @@ -159,7 +160,8 @@ M: retryable execute-statement* ( statement type -- ) dup dup class do-select ; : select-tuple ( tuple -- tuple/f ) - dup dup class \ query new 1 >>limit do-select ?first ; + dup dup class \ query new 1 >>limit do-select + [ f ] [ first ] if-empty ; : do-count ( exemplar-tuple statement -- tuples ) [ diff --git a/basis/db/types/types.factor b/basis/db/types/types.factor index 2efa41c401..d3b99fcff3 100755 --- a/basis/db/types/types.factor +++ b/basis/db/types/types.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. USING: arrays assocs db kernel math math.parser -sequences continuations sequences.deep sequences.lib +sequences continuations sequences.deep words namespaces slots slots.private classes mirrors classes.tuple combinators calendar.format symbols classes.singleton accessors quotations random ; diff --git a/basis/html/forms/forms.factor b/basis/html/forms/forms.factor index 0da3fcb0b3..911e545f87 100644 --- a/basis/html/forms/forms.factor +++ b/basis/html/forms/forms.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2008 Slava Pestov ! See http://factorcode.org/license.txt for BSD license. USING: kernel accessors strings namespaces assocs hashtables -mirrors math fry sequences sequences.lib words continuations ; +mirrors math fry sequences words continuations ; IN: html.forms TUPLE: form errors values validation-failed ; diff --git a/basis/http/http.factor b/basis/http/http.factor index 2a5a19036f..e450631d94 100755 --- a/basis/http/http.factor +++ b/basis/http/http.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2003, 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: accessors kernel combinators math namespaces -assocs assocs.lib sequences splitting sorting sets debugger +assocs sequences splitting sorting sets debugger strings vectors hashtables quotations arrays byte-arrays math.parser calendar calendar.format present @@ -27,9 +27,12 @@ IN: http : (read-header) ( -- alist ) [ read-crlf dup f like ] [ parse-header-line ] [ drop ] produce ; +: collect-headers ( assoc -- assoc' ) + H{ } clone [ '[ , push-at ] assoc-each ] keep ; + : process-header ( alist -- assoc ) f swap [ [ swap or dup ] dip swap ] assoc-map nip - [ ?push ] histogram [ "; " join ] assoc-map + collect-headers [ "; " join ] assoc-map >hashtable ; : read-header ( -- assoc ) diff --git a/basis/io/unix/files/files.factor b/basis/io/unix/files/files.factor index 63712cd45c..c6eda50855 100755 --- a/basis/io/unix/files/files.factor +++ b/basis/io/unix/files/files.factor @@ -2,7 +2,7 @@ ! See http://factorcode.org/license.txt for BSD license. USING: io.backend io.ports io.unix.backend io.files io unix unix.stat unix.time kernel math continuations -math.bitfields byte-arrays alien combinators calendar +math.bitwise byte-arrays alien combinators calendar io.encodings.binary accessors sequences strings system io.files.private destructors ; diff --git a/basis/io/unix/files/unique/unique.factor b/basis/io/unix/files/unique/unique.factor index dca2f51958..95e321fd93 100644 --- a/basis/io/unix/files/unique/unique.factor +++ b/basis/io/unix/files/unique/unique.factor @@ -1,4 +1,4 @@ -USING: kernel io.ports io.unix.backend math.bitfields +USING: kernel io.ports io.unix.backend math.bitwise unix io.files.unique.backend system ; IN: io.unix.files.unique diff --git a/basis/io/unix/kqueue/kqueue.factor b/basis/io/unix/kqueue/kqueue.factor index 8888d0182f..b3e69a453c 100755 --- a/basis/io/unix/kqueue/kqueue.factor +++ b/basis/io/unix/kqueue/kqueue.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: alien.c-types kernel math math.bitfields namespaces +USING: alien.c-types kernel math math.bitwise namespaces locals accessors combinators threads vectors hashtables sequences assocs continuations sets unix unix.time unix.kqueue unix.process diff --git a/basis/io/unix/linux/monitors/monitors.factor b/basis/io/unix/linux/monitors/monitors.factor index 5a980266f1..ff23fba0c6 100644 --- a/basis/io/unix/linux/monitors/monitors.factor +++ b/basis/io/unix/linux/monitors/monitors.factor @@ -4,7 +4,7 @@ USING: kernel io.backend io.monitors io.monitors.recursive io.files io.buffers io.monitors io.ports io.timeouts io.unix.backend io.unix.select io.encodings.utf8 unix.linux.inotify assocs namespaces threads continuations init -math math.bitfields sets alien alien.strings alien.c-types +math math.bitwise sets alien alien.strings alien.c-types vocabs.loader accessors system hashtables destructors unix ; IN: io.unix.linux.monitors diff --git a/basis/io/unix/mmap/mmap.factor b/basis/io/unix/mmap/mmap.factor index c31e23849e..d5dcda9436 100755 --- a/basis/io/unix/mmap/mmap.factor +++ b/basis/io/unix/mmap/mmap.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2007 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. -USING: alien io io.files kernel math math.bitfields system unix +USING: alien io io.files kernel math math.bitwise system unix io.unix.backend io.ports io.mmap destructors locals accessors ; IN: io.unix.mmap diff --git a/basis/io/windows/files/files.factor b/basis/io/windows/files/files.factor index 1377f82ced..5698ab6cf2 100755 --- a/basis/io/windows/files/files.factor +++ b/basis/io/windows/files/files.factor @@ -4,8 +4,7 @@ USING: alien.c-types io.binary io.backend io.files io.buffers io.windows kernel math splitting windows windows.kernel32 windows.time calendar combinators math.functions sequences namespaces words symbols system -io.ports destructors accessors -math.bitfields math.bitfields.lib ; +io.ports destructors accessors math.bitwise ; IN: io.windows.files : open-file ( path access-mode create-mode flags -- handle ) diff --git a/basis/io/windows/mmap/mmap.factor b/basis/io/windows/mmap/mmap.factor index 660a4017be..e5b0d10f2f 100755 --- a/basis/io/windows/mmap/mmap.factor +++ b/basis/io/windows/mmap/mmap.factor @@ -1,6 +1,6 @@ USING: alien alien.c-types arrays destructors generic io.mmap io.ports io.windows io.windows.files io.windows.privileges -kernel libc math math.bitfields namespaces quotations sequences +kernel libc math math.bitwise namespaces quotations sequences windows windows.advapi32 windows.kernel32 io.backend system accessors locals ; IN: io.windows.mmap diff --git a/basis/io/windows/nt/monitors/monitors.factor b/basis/io/windows/nt/monitors/monitors.factor index fa4d19a46e..54cb3b1104 100755 --- a/basis/io/windows/nt/monitors/monitors.factor +++ b/basis/io/windows/nt/monitors/monitors.factor @@ -2,7 +2,7 @@ ! See http://factorcode.org/license.txt for BSD license. USING: alien alien.c-types libc destructors locals kernel math assocs namespaces continuations sequences hashtables -sorting arrays combinators math.bitfields strings system +sorting arrays combinators math.bitwise strings system accessors threads splitting io.backend io.windows io.windows.nt.backend io.windows.nt.files io.monitors io.ports io.buffers io.files io.timeouts io diff --git a/basis/io/windows/nt/pipes/pipes.factor b/basis/io/windows/nt/pipes/pipes.factor index dc0d7cf1e5..aa52152b75 100755 --- a/basis/io/windows/nt/pipes/pipes.factor +++ b/basis/io/windows/nt/pipes/pipes.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2007, 2008 Doug Coleman, Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: alien alien.c-types arrays destructors io io.windows libc -windows.types math.bitfields windows.kernel32 windows namespaces +windows.types math.bitwise windows.kernel32 windows namespaces kernel sequences windows.errors assocs math.parser system random combinators accessors io.pipes io.ports ; IN: io.windows.nt.pipes diff --git a/basis/io/windows/nt/privileges/privileges.factor b/basis/io/windows/nt/privileges/privileges.factor index 007d05f9af..8418d09a5e 100755 --- a/basis/io/windows/nt/privileges/privileges.factor +++ b/basis/io/windows/nt/privileges/privileges.factor @@ -1,6 +1,6 @@ USING: alien alien.c-types alien.syntax arrays continuations destructors generic io.mmap io.ports io.windows io.windows.files -kernel libc math math.bitfields namespaces quotations sequences windows +kernel libc math math.bitwise namespaces quotations sequences windows windows.advapi32 windows.kernel32 io.backend system accessors io.windows.privileges ; IN: io.windows.nt.privileges diff --git a/basis/io/windows/windows.factor b/basis/io/windows/windows.factor index a290821163..6f6c29fc55 100755 --- a/basis/io/windows/windows.factor +++ b/basis/io/windows/windows.factor @@ -5,7 +5,7 @@ io.buffers io.files io.ports io.sockets io.binary io.sockets io.timeouts windows.errors strings kernel math namespaces sequences windows windows.kernel32 windows.shell32 windows.types windows.winsock splitting -continuations math.bitfields system accessors ; +continuations math.bitwise system accessors ; IN: io.windows : set-inherit ( handle ? -- ) diff --git a/basis/lcs/lcs.factor b/basis/lcs/lcs.factor index 2fa0b6cc71..6f9ae3c883 100755 --- a/basis/lcs/lcs.factor +++ b/basis/lcs/lcs.factor @@ -1,6 +1,5 @@ USING: sequences kernel math locals math.order math.ranges -accessors combinators.lib arrays namespaces combinators -combinators.short-circuit ; +accessors arrays namespaces combinators combinators.short-circuit ; IN: lcs r dup word? [ swapd execute ] when r> shift bitor ; - -: bitfield ( values... bitspec -- n ) - 0 [ (bitfield) ] reduce ; - -: flags ( values -- n ) - 0 [ dup word? [ execute ] when bitor ] reduce ; - -GENERIC: (bitfield-quot) ( spec -- quot ) - -M: integer (bitfield-quot) ( spec -- quot ) - [ swapd shift bitor ] curry ; - -M: pair (bitfield-quot) ( spec -- quot ) - first2 over word? [ >r swapd execute r> ] [ ] ? - [ shift bitor ] append 2curry ; - -: bitfield-quot ( spec -- quot ) - [ (bitfield-quot) ] map [ 0 ] prefix concat ; - -\ bitfield [ bitfield-quot ] 1 define-transform - -\ flags [ - [ 0 , [ , \ bitor , ] each ] [ ] make -] 1 define-transform diff --git a/basis/math/bitfields/summary.txt b/basis/math/bitfields/summary.txt deleted file mode 100644 index d622f818fd..0000000000 --- a/basis/math/bitfields/summary.txt +++ /dev/null @@ -1 +0,0 @@ -Domain-specific language for constructing integers diff --git a/basis/math/bitfields/authors.txt b/basis/math/bitwise/authors.txt similarity index 50% rename from basis/math/bitfields/authors.txt rename to basis/math/bitwise/authors.txt index 1901f27a24..f372b574ae 100644 --- a/basis/math/bitfields/authors.txt +++ b/basis/math/bitwise/authors.txt @@ -1 +1,2 @@ Slava Pestov +Doug Coleman diff --git a/basis/math/bitfields/bitfields-docs.factor b/basis/math/bitwise/bitwise-docs.factor similarity index 75% rename from basis/math/bitfields/bitfields-docs.factor rename to basis/math/bitwise/bitwise-docs.factor index f9d16d2b6c..247523369b 100644 --- a/basis/math/bitfields/bitfields-docs.factor +++ b/basis/math/bitwise/bitwise-docs.factor @@ -1,5 +1,5 @@ USING: help.markup help.syntax math ; -IN: math.bitfields +IN: math.bitwise ARTICLE: "math-bitfields" "Constructing bit fields" "Some applications, such as binary communication protocols and assemblers, need to construct integers from elaborate bit field specifications. Hand-coding this using " { $link shift } " and " { $link bitor } " results in repetitive code. A higher-level facility exists to factor out this repetition:" @@ -35,3 +35,16 @@ HELP: bitfield " } ;" } } ; + +HELP: bits +{ $values { "m" integer } { "n" integer } { "m'" integer } } +{ $description "Keep only n bits from the integer m." } +{ $example "USING: math.bitwise prettyprint ;" "HEX: 123abcdef 16 bits .h" "cdef" } ; + +HELP: bitroll +{ $values { "x" "an integer (input)" } { "s" "an integer (shift)" } { "w" "an integer (wrap)" } { "y" integer } } +{ $description "Roll n by s bits to the left, wrapping around after w bits." } +{ $examples + { $example "USING: math.bitwise prettyprint ;" "1 -1 32 bitroll .b" "10000000000000000000000000000000" } + { $example "USING: math.bitwise prettyprint ;" "HEX: ffff0000 8 32 bitroll .h" "ff0000ff" } +} ; diff --git a/basis/math/bitwise/bitwise-tests.factor b/basis/math/bitwise/bitwise-tests.factor new file mode 100755 index 0000000000..8b13cb23b3 --- /dev/null +++ b/basis/math/bitwise/bitwise-tests.factor @@ -0,0 +1,29 @@ +USING: accessors math math.bitwise tools.test kernel words ; +IN: math.bitwise.tests + +[ 0 ] [ 1 0 0 bitroll ] unit-test +[ 1 ] [ 1 0 1 bitroll ] unit-test +[ 1 ] [ 1 1 1 bitroll ] unit-test +[ 1 ] [ 1 0 2 bitroll ] unit-test +[ 1 ] [ 1 0 1 bitroll ] unit-test +[ 1 ] [ 1 20 2 bitroll ] unit-test +[ 1 ] [ 1 8 8 bitroll ] unit-test +[ 1 ] [ 1 -8 8 bitroll ] unit-test +[ 1 ] [ 1 -32 8 bitroll ] unit-test +[ 128 ] [ 1 -1 8 bitroll ] unit-test +[ 8 ] [ 1 3 32 bitroll ] unit-test + +[ 0 ] [ { } bitfield ] unit-test +[ 256 ] [ 1 { 8 } bitfield ] unit-test +[ 268 ] [ 3 1 { 8 2 } bitfield ] unit-test +[ 268 ] [ 1 { 8 { 3 2 } } bitfield ] unit-test +[ 512 ] [ 1 { { 1+ 8 } } bitfield ] unit-test + +: a 1 ; inline +: b 2 ; inline + +: foo ( -- flags ) { a b } flags ; + +[ 3 ] [ foo ] unit-test +[ 3 ] [ { a b } flags ] unit-test +\ foo must-infer diff --git a/basis/math/bitwise/bitwise.factor b/basis/math/bitwise/bitwise.factor new file mode 100644 index 0000000000..60c585c779 --- /dev/null +++ b/basis/math/bitwise/bitwise.factor @@ -0,0 +1,94 @@ +! Copyright (C) 2007, 2008 Slava Pestov. +! See http://factorcode.org/license.txt for BSD license. +USING: arrays kernel math math.functions sequences +sequences.private words namespaces macros hints +combinators fry ; +IN: math.bitwise + +! utilities +: clear-bit ( x n -- y ) 2^ bitnot bitand ; inline +: set-bit ( x n -- y ) 2^ bitor ; inline +: bit-clear? ( x n -- ? ) 2^ bitand zero? ; inline +: unmask ( x n -- ? ) bitnot bitand ; inline +: unmask? ( x n -- ? ) unmask 0 > ; inline +: mask ( x n -- ? ) bitand ; inline +: mask? ( x n -- ? ) mask 0 > ; inline +: wrap ( m n -- m' ) 1- bitand ; inline +: bits ( m n -- m' ) 2^ wrap ; inline +: mask-bit ( m n -- m' ) 1- 2^ mask ; inline + +: shift-mod ( n s w -- n ) + >r shift r> 2^ wrap ; inline + +: bitroll ( x s w -- y ) + [ wrap ] keep + [ shift-mod ] + [ [ - ] keep shift-mod ] 3bi bitor ; inline + +: bitroll-32 ( n s -- n' ) 32 bitroll ; + +HINTS: bitroll-32 bignum fixnum ; + +: bitroll-64 ( n s -- n' ) 64 bitroll ; + +HINTS: bitroll-64 bignum fixnum ; + +! 32-bit arithmetic +: w+ ( int int -- int ) + 32 bits ; inline +: w- ( int int -- int ) - 32 bits ; inline +: w* ( int int -- int ) * 32 bits ; inline + +! flags +MACRO: flags ( values -- ) + [ 0 ] [ [ execute bitor ] curry compose ] reduce ; + +! bitfield +r swapd execute r> ] [ ] ? + [ shift bitor ] append 2curry ; + +PRIVATE> + +MACRO: bitfield ( bitspec -- ) + [ 0 ] [ (bitfield-quot) compose ] reduce ; + +! bit-count +> + +GENERIC: (bit-count) ( x -- n ) + +M: fixnum (bit-count) + { + [ byte-bit-count ] + [ -8 shift byte-bit-count ] + [ -16 shift byte-bit-count ] + [ -24 shift byte-bit-count ] + } cleave + + + ; + +M: bignum (bit-count) + dup 0 = [ drop 0 ] [ + [ byte-bit-count ] [ -8 shift (bit-count) ] bi + + ] if ; + +PRIVATE> + +: bit-count ( x -- n ) + dup 0 >= [ (bit-count) ] [ bitnot (bit-count) ] if ; inline diff --git a/basis/math/bitwise/summary.txt b/basis/math/bitwise/summary.txt new file mode 100644 index 0000000000..23f73db76c --- /dev/null +++ b/basis/math/bitwise/summary.txt @@ -0,0 +1 @@ +Bitwise arithmetic utilities diff --git a/basis/nmake/nmake-tests.factor b/basis/nmake/nmake-tests.factor new file mode 100644 index 0000000000..a6b1afb297 --- /dev/null +++ b/basis/nmake/nmake-tests.factor @@ -0,0 +1,8 @@ +IN: nmake.tests +USING: nmake kernel tools.test ; + +[ ] [ [ ] { } nmake ] unit-test + +[ { 1 } { 2 } ] [ [ 1 0, 2 1, ] { { } { } } nmake ] unit-test + +[ [ ] [ call ] curry { { } } nmake ] must-infer diff --git a/basis/nmake/nmake.factor b/basis/nmake/nmake.factor new file mode 100644 index 0000000000..80c3ce3411 --- /dev/null +++ b/basis/nmake/nmake.factor @@ -0,0 +1,44 @@ +! Copyright (C) 2008 Doug Coleman. +! See http://factorcode.org/license.txt for BSD license. +USING: namespaces sequences math.parser kernel macros +generalizations locals ; +IN: nmake + +SYMBOL: building-seq +: get-building-seq ( n -- seq ) + building-seq get nth ; + +: n, ( obj n -- ) get-building-seq push ; +: n% ( seq n -- ) get-building-seq push-all ; +: n# ( num n -- ) >r number>string r> n% ; + +: 0, ( obj -- ) 0 n, ; +: 0% ( seq -- ) 0 n% ; +: 0# ( num -- ) 0 n# ; +: 1, ( obj -- ) 1 n, ; +: 1% ( seq -- ) 1 n% ; +: 1# ( num -- ) 1 n# ; +: 2, ( obj -- ) 2 n, ; +: 2% ( seq -- ) 2 n% ; +: 2# ( num -- ) 2 n# ; +: 3, ( obj -- ) 3 n, ; +: 3% ( seq -- ) 3 n% ; +: 3# ( num -- ) 3 n# ; +: 4, ( obj -- ) 4 n, ; +: 4% ( seq -- ) 4 n% ; +: 4# ( num -- ) 4 n# ; + +MACRO: finish-nmake ( exemplars -- ) + length [ firstn ] curry ; + +:: nmake ( quot exemplars -- ) + [ + exemplars + [ 0 swap new-resizable ] map + building-seq set + + quot call + + building-seq get + exemplars [ [ like ] 2map ] [ finish-nmake ] bi + ] with-scope ; inline diff --git a/basis/openssl/libssl/libssl.factor b/basis/openssl/libssl/libssl.factor index e951ad8858..f1dc21f993 100755 --- a/basis/openssl/libssl/libssl.factor +++ b/basis/openssl/libssl/libssl.factor @@ -2,7 +2,7 @@ ! Portions copyright (C) 2008 Slava Pestov ! See http://factorcode.org/license.txt for BSD license. USING: alien alien.syntax combinators kernel system namespaces -assocs parser lexer sequences words quotations math.bitfields ; +assocs parser lexer sequences words quotations math.bitwise ; IN: openssl.libssl diff --git a/basis/peg/ebnf/ebnf.factor b/basis/peg/ebnf/ebnf.factor index 6e9d78e649..7083262c49 100644 --- a/basis/peg/ebnf/ebnf.factor +++ b/basis/peg/ebnf/ebnf.factor @@ -2,7 +2,7 @@ ! See http://factorcode.org/license.txt for BSD license. USING: kernel compiler.units words arrays strings math.parser sequences quotations vectors namespaces math assocs continuations peg - peg.parsers unicode.categories multiline combinators.lib + peg.parsers unicode.categories multiline splitting accessors effects sequences.deep peg.search combinators.short-circuit lexer io.streams.string stack-checker io prettyprint combinators parser ; diff --git a/extra/peg/search/authors.txt b/basis/peg/search/authors.txt similarity index 100% rename from extra/peg/search/authors.txt rename to basis/peg/search/authors.txt diff --git a/extra/peg/search/search-docs.factor b/basis/peg/search/search-docs.factor similarity index 100% rename from extra/peg/search/search-docs.factor rename to basis/peg/search/search-docs.factor diff --git a/extra/peg/search/search-tests.factor b/basis/peg/search/search-tests.factor similarity index 100% rename from extra/peg/search/search-tests.factor rename to basis/peg/search/search-tests.factor diff --git a/extra/peg/search/search.factor b/basis/peg/search/search.factor similarity index 100% rename from extra/peg/search/search.factor rename to basis/peg/search/search.factor diff --git a/extra/peg/search/summary.txt b/basis/peg/search/summary.txt similarity index 100% rename from extra/peg/search/summary.txt rename to basis/peg/search/summary.txt diff --git a/extra/peg/search/tags.txt b/basis/peg/search/tags.txt similarity index 100% rename from extra/peg/search/tags.txt rename to basis/peg/search/tags.txt diff --git a/basis/persistent/hashtables/nodes/bitmap/bitmap.factor b/basis/persistent/hashtables/nodes/bitmap/bitmap.factor index 7fb14a4541..f231043274 100644 --- a/basis/persistent/hashtables/nodes/bitmap/bitmap.factor +++ b/basis/persistent/hashtables/nodes/bitmap/bitmap.factor @@ -1,7 +1,7 @@ ! Based on Clojure's PersistentHashMap by Rich Hickey. -USING: math math.bit-count arrays kernel accessors locals sequences -sequences.private sequences.lib +USING: math math.bitwise arrays kernel accessors locals sequences +sequences.private persistent.sequences persistent.hashtables.config persistent.hashtables.nodes ; diff --git a/basis/persistent/hashtables/nodes/collision/collision.factor b/basis/persistent/hashtables/nodes/collision/collision.factor index b74a2ed45d..83003e5c47 100644 --- a/basis/persistent/hashtables/nodes/collision/collision.factor +++ b/basis/persistent/hashtables/nodes/collision/collision.factor @@ -1,6 +1,6 @@ ! Based on Clojure's PersistentHashMap by Rich Hickey. -USING: kernel accessors math arrays fry sequences sequences.lib +USING: kernel accessors math arrays fry sequences locals persistent.sequences persistent.hashtables.config persistent.hashtables.nodes diff --git a/basis/persistent/hashtables/nodes/full/full.factor b/basis/persistent/hashtables/nodes/full/full.factor index e0fcc1a0ab..5c60c91dca 100644 --- a/basis/persistent/hashtables/nodes/full/full.factor +++ b/basis/persistent/hashtables/nodes/full/full.factor @@ -1,7 +1,7 @@ ! Based on Clojure's PersistentHashMap by Rich Hickey. USING: math accessors kernel arrays sequences sequences.private -locals sequences.lib +locals persistent.sequences persistent.hashtables.config persistent.hashtables.nodes ; diff --git a/basis/persistent/hashtables/nodes/nodes.factor b/basis/persistent/hashtables/nodes/nodes.factor index 6201e68c6a..d681cd57fa 100644 --- a/basis/persistent/hashtables/nodes/nodes.factor +++ b/basis/persistent/hashtables/nodes/nodes.factor @@ -1,6 +1,6 @@ ! Based on Clojure's PersistentHashMap by Rich Hickey. -USING: math arrays kernel sequences sequences.lib +USING: math arrays kernel sequences accessors locals persistent.hashtables.config ; IN: persistent.hashtables.nodes diff --git a/basis/random/mersenne-twister/mersenne-twister.factor b/basis/random/mersenne-twister/mersenne-twister.factor index 01e79abff2..0a730190c2 100755 --- a/basis/random/mersenne-twister/mersenne-twister.factor +++ b/basis/random/mersenne-twister/mersenne-twister.factor @@ -3,7 +3,7 @@ ! mersenne twister based on ! http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/MT2002/CODES/mt19937ar.c USING: arrays kernel math namespaces sequences system init -accessors math.ranges random circular math.bitfields.lib +accessors math.ranges random circular math.bitwise combinators ; IN: random.mersenne-twister diff --git a/basis/random/random-tests.factor b/basis/random/random-tests.factor index d85df3e0be..eed4bf2e13 100644 --- a/basis/random/random-tests.factor +++ b/basis/random/random-tests.factor @@ -1,4 +1,4 @@ -USING: random sequences tools.test ; +USING: random sequences tools.test kernel ; IN: random.tests [ 4 ] [ 4 random-bytes length ] unit-test @@ -6,3 +6,6 @@ IN: random.tests [ 4 ] [ [ 4 random-bytes length ] with-secure-random ] unit-test [ 7 ] [ [ 7 random-bytes length ] with-secure-random ] unit-test + +[ 2 ] [ V{ 10 20 30 } [ delete-random drop ] keep length ] unit-test +[ V{ } [ delete-random drop ] keep length ] must-fail diff --git a/basis/random/random.factor b/basis/random/random.factor index 74b7a78723..d37e2fc2b7 100755 --- a/basis/random/random.factor +++ b/basis/random/random.factor @@ -43,6 +43,9 @@ M: f random-32* ( obj -- * ) no-random-number-generator ; ] keep nth ] if ; +: delete-random ( seq -- elt ) + [ length random ] keep [ nth ] 2keep delete-nth ; + : random-bits ( n -- r ) 2^ random ; : with-random ( tuple quot -- ) diff --git a/basis/smtp/smtp.factor b/basis/smtp/smtp.factor index 5df4b80614..fa98c7a947 100755 --- a/basis/smtp/smtp.factor +++ b/basis/smtp/smtp.factor @@ -1,8 +1,8 @@ ! Copyright (C) 2007, 2008 Elie CHAFTARI, Dirk Vleugels, ! Slava Pestov, Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. -USING: arrays namespaces io io.timeouts kernel logging io.sockets -sequences combinators sequences.lib splitting assocs strings +USING: arrays namespaces io io.timeouts kernel logging +io.sockets sequences combinators splitting assocs strings math.parser random system calendar io.encodings.ascii summary calendar.format accessors sets hashtables ; IN: smtp @@ -112,7 +112,7 @@ ERROR: smtp-transaction-failed < smtp-error ; } cond ; : multiline? ( response -- boolean ) - ?fourth CHAR: - = ; + 3 swap ?nth CHAR: - = ; : process-multiline ( multiline -- response ) >r readln r> 2dup " " append head? [ @@ -184,21 +184,3 @@ PRIVATE> : send-email ( email -- ) [ email>headers ] keep (send-email) ; - -! Dirk's old AUTH CRAM-MD5 code. I don't know anything about -! CRAM MD5, and the old code didn't work properly either, so here -! it is in case anyone wants to fix it later. -! -! check-response used to have this clause: -! { [ dup "334" head? ] [ " " split 1 swap nth base64> challenge set ] } -! -! and the rest of the code was as follows: -! : (cram-md5-auth) ( -- response ) -! swap challenge get -! string>md5-hmac hex-string -! " " prepend append -! >base64 ; -! -! : cram-md5-auth ( key login -- ) -! "AUTH CRAM-MD5\r\n" get-ok -! (cram-md5-auth) "\r\n" append get-ok ; diff --git a/basis/state-parser/state-parser.factor b/basis/state-parser/state-parser.factor index ee5a5113bf..15c83bf73a 100644 --- a/basis/state-parser/state-parser.factor +++ b/basis/state-parser/state-parser.factor @@ -2,7 +2,7 @@ ! See http://factorcode.org/license.txt for BSD license. USING: io io.streams.string kernel math namespaces sequences strings circular prettyprint debugger ascii sbufs fry summary -accessors sequences.lib ; +accessors ; IN: state-parser ! * Basic underlying words @@ -120,7 +120,7 @@ M: not-enough-characters summary ( obj -- str ) : take ( n -- string ) [ 1- ] [ ] bi [ - '[ drop get-char [ next , push f ] [ t ] if* ] attempt-each drop + '[ drop get-char [ next , push f ] [ t ] if* ] contains? drop ] keep get-char [ over push ] when* >string ; : pass-blank ( -- ) diff --git a/basis/tools/scaffold/scaffold.factor b/basis/tools/scaffold/scaffold.factor index 69eac5dc15..1312681f85 100644 --- a/basis/tools/scaffold/scaffold.factor +++ b/basis/tools/scaffold/scaffold.factor @@ -3,8 +3,8 @@ USING: assocs io.files hashtables kernel namespaces sequences vocabs.loader io combinators io.encodings.utf8 calendar accessors math.parser io.streams.string ui.tools.operations quotations -strings arrays prettyprint words vocabs sorting sets cords -classes sequences.lib combinators.lib ; +strings arrays prettyprint words vocabs sorting sets +classes ; IN: tools.scaffold SYMBOL: developer-name @@ -160,16 +160,18 @@ ERROR: no-vocab vocab ; : help-file-string ( str1 -- str2 ) [ - [ "IN: " write print nl ] - [ interesting-words. ] - [ "ARTICLE: " write unparse dup write bl print ";" print nl ] - [ "ABOUT: " write unparse print ] quad + { + [ "IN: " write print nl ] + [ interesting-words. ] + [ "ARTICLE: " write unparse dup write bl print ";" print nl ] + [ "ABOUT: " write unparse print ] + } cleave ] with-string-writer ; : write-using ( -- ) "USING:" write using get keys - { "help.markup" "help.syntax" } cord-append natural-sort + { "help.markup" "help.syntax" } append natural-sort [ bl write ] each " ;" print ; diff --git a/basis/ui/gadgets/canvas/canvas.factor b/basis/ui/gadgets/canvas/canvas.factor index 85149f4551..4ff7519a85 100755 --- a/basis/ui/gadgets/canvas/canvas.factor +++ b/basis/ui/gadgets/canvas/canvas.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2007 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: ui.backend ui.gadgets ui.gadgets.theme ui.gadgets.lib +USING: ui.backend ui.gadgets ui.gadgets.theme ui.gadgets.worlds ui.render opengl opengl.gl kernel namespaces classes.tuple colors accessors ; IN: ui.gadgets.canvas diff --git a/basis/ui/gadgets/lib/lib.factor b/basis/ui/gadgets/lib/lib.factor deleted file mode 100644 index 866369b0af..0000000000 --- a/basis/ui/gadgets/lib/lib.factor +++ /dev/null @@ -1,8 +0,0 @@ - -USING: accessors kernel ui.backend ui.gadgets.worlds ; - -IN: ui.gadgets.lib - -ERROR: no-world-found ; -: find-gl-context ( gadget -- ) - find-world dup [ handle>> select-gl-context ] [ no-world-found ] if ; diff --git a/basis/ui/gadgets/slate/authors.txt b/basis/ui/gadgets/slate/authors.txt deleted file mode 100755 index 6cfd5da273..0000000000 --- a/basis/ui/gadgets/slate/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Eduardo Cavazos diff --git a/basis/ui/gadgets/worlds/worlds.factor b/basis/ui/gadgets/worlds/worlds.factor index bf4c275dc2..cedd03e39e 100755 --- a/basis/ui/gadgets/worlds/worlds.factor +++ b/basis/ui/gadgets/worlds/worlds.factor @@ -22,6 +22,12 @@ window-loc ; : hide-status ( gadget -- ) f swap show-status ; +ERROR: no-world-found ; + +: find-gl-context ( gadget -- ) + find-world dup + [ handle>> select-gl-context ] [ no-world-found ] if ; + : (request-focus) ( child world ? -- ) pick parent>> pick eq? [ >r >r dup parent>> dup r> r> diff --git a/basis/ui/windows/windows.factor b/basis/ui/windows/windows.factor index 5f67ed4a4b..f6481225ae 100755 --- a/basis/ui/windows/windows.factor +++ b/basis/ui/windows/windows.factor @@ -8,7 +8,7 @@ sequences strings vectors words windows.kernel32 windows.gdi32 windows.user32 windows.opengl32 windows.messages windows.types windows.nt windows threads libc combinators continuations command-line shuffle opengl ui.render unicode.case ascii -math.bitfields locals symbols accessors math.geometry.rect ; +math.bitwise locals symbols accessors math.geometry.rect ; IN: ui.windows SINGLETON: windows-ui-backend diff --git a/basis/unix/linux/inotify/inotify.factor b/basis/unix/linux/inotify/inotify.factor index f94dc74ab9..3385e454d2 100644 --- a/basis/unix/linux/inotify/inotify.factor +++ b/basis/unix/linux/inotify/inotify.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: alien.syntax math math.bitfields ; +USING: alien.syntax math math.bitwise ; IN: unix.linux.inotify C-STRUCT: inotify-event diff --git a/basis/validators/validators.factor b/basis/validators/validators.factor index 37c0216740..b786ef5529 100644 --- a/basis/validators/validators.factor +++ b/basis/validators/validators.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2006, 2008 Slava Pestov ! See http://factorcode.org/license.txt for BSD license. -USING: kernel continuations sequences sequences.lib math +USING: kernel continuations sequences math namespaces sets math.parser math.ranges assocs regexp unicode.categories arrays hashtables words classes quotations xmode.catalog ; diff --git a/basis/windows/advapi32/advapi32.factor b/basis/windows/advapi32/advapi32.factor index b7381968a5..251b59a4d8 100755 --- a/basis/windows/advapi32/advapi32.factor +++ b/basis/windows/advapi32/advapi32.factor @@ -1,4 +1,4 @@ -USING: alias alien.syntax kernel math windows.types math.bitfields ; +USING: alias alien.syntax kernel math windows.types math.bitwise ; IN: windows.advapi32 LIBRARY: advapi32 diff --git a/basis/windows/opengl32/opengl32.factor b/basis/windows/opengl32/opengl32.factor index ca2206eac4..df09d9327a 100755 --- a/basis/windows/opengl32/opengl32.factor +++ b/basis/windows/opengl32/opengl32.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2005, 2006 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. USING: alien alien.c-types alien.syntax parser namespaces kernel -math math.bitfields windows.types windows.types init assocs +math math.bitwise windows.types windows.types init assocs sequences libc ; IN: windows.opengl32 diff --git a/basis/windows/user32/user32.factor b/basis/windows/user32/user32.factor index 481f00f36b..e5c9f96275 100755 --- a/basis/windows/user32/user32.factor +++ b/basis/windows/user32/user32.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2005, 2006 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. USING: alien alien.syntax parser namespaces kernel math -windows.types generalizations math.bitfields alias ; +windows.types generalizations math.bitwise alias ; IN: windows.user32 ! HKL for ActivateKeyboardLayout diff --git a/basis/windows/winsock/winsock.factor b/basis/windows/winsock/winsock.factor index 303aefeb5f..3c4230e21e 100755 --- a/basis/windows/winsock/winsock.factor +++ b/basis/windows/winsock/winsock.factor @@ -2,7 +2,7 @@ USING: alien alien.c-types alien.strings alien.syntax arrays byte-arrays kernel math sequences windows.types windows.kernel32 -windows.errors structs windows math.bitfields alias ; +windows.errors structs windows math.bitwise alias ; IN: windows.winsock USE: libc diff --git a/basis/x11/windows/windows.factor b/basis/x11/windows/windows.factor index f9158c2956..aed45655f6 100755 --- a/basis/x11/windows/windows.factor +++ b/basis/x11/windows/windows.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2005, 2006 Eduardo Cavazos and Slava Pestov ! See http://factorcode.org/license.txt for BSD license. -USING: alien alien.c-types hashtables kernel math math.vectors math.bitfields -namespaces sequences x11.xlib x11.constants x11.glx ; +USING: alien alien.c-types hashtables kernel math math.vectors +math.bitwise namespaces sequences x11.xlib x11.constants x11.glx ; IN: x11.windows : create-window-mask ( -- n ) diff --git a/basis/x11/xlib/xlib.factor b/basis/x11/xlib/xlib.factor index 6fc586106c..eecf427c9e 100755 --- a/basis/x11/xlib/xlib.factor +++ b/basis/x11/xlib/xlib.factor @@ -12,7 +12,7 @@ ! and note the section. USING: kernel arrays alien alien.c-types alien.strings -alien.syntax math math.bitfields words sequences namespaces +alien.syntax math math.bitwise words sequences namespaces continuations io.encodings.ascii ; IN: x11.xlib diff --git a/basis/xml/generator/generator.factor b/basis/xml/generator/generator.factor index d5cf4dac40..0de1692e00 100644 --- a/basis/xml/generator/generator.factor +++ b/basis/xml/generator/generator.factor @@ -1,7 +1,6 @@ ! Copyright (C) 2006, 2007 Daniel Ehrenberg ! See http://factorcode.org/license.txt for BSD license. -USING: namespaces kernel xml.data xml.utilities assocs splitting -sequences parser lexer quotations sequences.lib xml.utilities ; +USING: namespaces kernel xml.data xml.utilities assocs sequences ; IN: xml.generator : comment, ( string -- ) , ; @@ -24,56 +23,3 @@ IN: xml.generator (tag,) build-xml ; inline : make-xml ( name quot -- xml ) f swap make-xml* ; inline - -! Word-based XML literal syntax -: parsed-name ( accum -- accum ) - scan ":" split1 [ f ] [ ] if* parsed ; - -: run-combinator ( accum quot1 quot2 -- accum ) - >r [ ] like parsed r> [ parsed ] each ; - -: parse-tag-contents ( accum contained? -- accum ) - [ \ contained*, parsed ] [ - scan-word \ [ = - [ POSTPONE: [ \ tag*, parsed ] - [ "Expected [ missing" throw ] if - ] if ; - -DEFER: >> - -: attributes-parsed ( accum quot -- accum ) - dup empty? [ drop f parsed ] [ - >r \ >r parsed r> parsed - [ H{ } make-assoc r> swap ] [ parsed ] each - ] if ; - -: << - parsed-name [ - \ >> parse-until >quotation - attributes-parsed \ contained? get - ] with-scope parse-tag-contents ; parsing - -: == - \ call parsed parsed-name \ set parsed ; parsing - -: // - \ contained? on ; parsing - -: parse-special ( accum end-token word -- accum ) - >r parse-tokens " " join parsed r> parsed ; - -: " \ comment, parse-special ; parsing - -: " \ directive, parse-special ; parsing - -: " \ instruction, parse-special ; parsing - -: >xml-document ( seq -- xml ) - dup first prolog? [ unclip-slice ] [ standard-prolog ] if swap - [ tag? ] split-around ; - -DEFER: XML> - -: [ >quotation ] parse-literal - { } parsed \ make parsed \ >xml-document parsed ; parsing diff --git a/basis/xmode/marker/marker.factor b/basis/xmode/marker/marker.factor index f11ac6b5b2..dfdd6c801a 100755 --- a/basis/xmode/marker/marker.factor +++ b/basis/xmode/marker/marker.factor @@ -1,7 +1,7 @@ IN: xmode.marker USING: kernel namespaces xmode.rules xmode.tokens xmode.marker.state xmode.marker.context xmode.utilities -xmode.catalog sequences math assocs combinators combinators.lib +xmode.catalog sequences math assocs combinators strings regexp splitting parser-combinators ascii unicode.case combinators.short-circuit accessors ; diff --git a/core/sequences/sequences-docs.factor b/core/sequences/sequences-docs.factor index 1bcd01d9b9..baf68db112 100755 --- a/core/sequences/sequences-docs.factor +++ b/core/sequences/sequences-docs.factor @@ -315,6 +315,15 @@ HELP: empty? { $values { "seq" sequence } { "?" "a boolean" } } { $description "Tests if the sequence has zero length." } ; +HELP: if-empty +{ $values { "seq" sequence } { "quot1" quotation } { "quot2" quotation } } +{ $description "Makes an implicit check if the sequence is empty. An empty sequence is dropped and " { $snippet "quot1" } " is called. Otherwise, if the sequence has any elements, " { $snippet "quot2" } " is called on it." } +{ $example + "USING: kernel prettyprint sequences sequences.lib ;" + "{ 1 2 3 } [ \"empty sequence\" ] [ sum ] if-empty ." + "6" +} ; + HELP: delete-all { $values { "seq" "a resizable sequence" } } { $description "Resizes the sequence to zero length, removing all elements. Not all sequences are resizable." } diff --git a/core/sequences/sequences-tests.factor b/core/sequences/sequences-tests.factor index 4b7b8a3151..fa5a3aecfb 100755 --- a/core/sequences/sequences-tests.factor +++ b/core/sequences/sequences-tests.factor @@ -3,6 +3,9 @@ sequences.private strings sbufs tools.test vectors generic vocabs.loader ; 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 >vector ] unit-test [ 3 ] [ 1 4 dup length ] unit-test [ 2 ] [ 1 3 { 1 2 3 4 } length ] unit-test diff --git a/core/sequences/sequences.factor b/core/sequences/sequences.factor index 73c9289415..c70d15701e 100755 --- a/core/sequences/sequences.factor +++ b/core/sequences/sequences.factor @@ -28,6 +28,14 @@ M: sequence lengthen 2dup length > [ set-length ] [ 2drop ] if ; M: sequence shorten 2dup length < [ set-length ] [ 2drop ] if ; : empty? ( seq -- ? ) length zero? ; inline + +: if-empty ( seq quot1 quot2 -- ) + [ dup empty? ] [ [ drop ] prepose ] [ ] tri* if ; inline + +: when-empty ( seq quot1 -- ) [ ] if-empty ; inline + +: unless-empty ( seq quot1 -- ) [ ] swap if-empty ; inline + : delete-all ( seq -- ) 0 swap set-length ; : first ( seq -- first ) 0 swap nth ; inline @@ -582,6 +590,9 @@ M: slice equal? over slice? [ sequence= ] [ 2drop f ] if ; [ >r >r dup pick length + r> - over r> open-slice ] keep copy ; +: remove-nth ( n seq -- seq' ) + [ swap head-slice ] [ swap 1+ tail-slice ] 2bi append ; + : pop ( seq -- elt ) [ length 1- ] [ [ nth ] [ shorten ] 2bi ] bi ; @@ -659,6 +670,9 @@ M: slice equal? over slice? [ sequence= ] [ 2drop f ] if ; : cut-slice ( seq n -- before after ) [ head-slice ] [ tail-slice ] 2bi ; +: insert-nth ( elt n seq -- seq' ) + swap cut-slice [ swap suffix ] dip append ; + : midpoint@ ( seq -- n ) length 2/ ; inline : halves ( seq -- first second ) diff --git a/extra/crypto/common/common.factor b/extra/crypto/common/common.factor index 651bd51774..61cc11f959 100644 --- a/extra/crypto/common/common.factor +++ b/extra/crypto/common/common.factor @@ -1,55 +1,17 @@ USING: arrays kernel io io.binary sbufs splitting grouping strings sequences namespaces math math.parser parser -hints math.bitfields.lib assocs ; +hints math.bitwise assocs ; IN: crypto.common -: w+ ( int int -- int ) + 32 bits ; inline - : (nth-int) ( string n -- int ) 2 shift dup 4 + rot ; inline : nth-int ( string n -- int ) (nth-int) le> ; inline -: nth-int-be ( string n -- int ) (nth-int) be> ; inline - : update ( num var -- ) [ w+ ] change ; inline - -: calculate-pad-length ( length -- pad-length ) - dup 56 < 55 119 ? swap - ; -: preprocess-plaintext ( string big-endian? -- padded-string ) - #! pad 0x80 then 00 til 8 bytes left, then 64bit length in bits - >r >sbuf r> over [ - HEX: 80 , - dup length HEX: 3f bitand - calculate-pad-length 0 % - length 3 shift 8 rot [ >be ] [ >le ] if % - ] "" make over push-all ; - -SYMBOL: bytes-read SYMBOL: big-endian? -: pad-last-block ( str big-endian? length -- str ) - [ - rot % - HEX: 80 , - dup HEX: 3f bitand calculate-pad-length 0 % - 3 shift 8 rot [ >be ] [ >le ] if % - ] "" make 64 group ; - -: update-old-new ( old new -- ) - [ get >r get r> ] 2keep >r >r w+ dup r> set r> set ; inline - -: slice3 ( n seq -- a b c ) >r dup 3 + r> first3 ; - -: seq>2seq ( seq -- seq1 seq2 ) - #! { abcdefgh } -> { aceg } { bdfh } - 2 group flip dup empty? [ drop { } { } ] [ first2 ] if ; - -: 2seq>seq ( seq1 seq2 -- seq ) - #! { aceg } { bdfh } -> { abcdefgh } - [ zip concat ] keep like ; - : mod-nth ( n seq -- elt ) #! 5 "abcd" -> b [ length mod ] [ nth ] bi ; diff --git a/basis/html/parser/analyzer/analyzer.factor b/extra/html/parser/analyzer/analyzer.factor similarity index 100% rename from basis/html/parser/analyzer/analyzer.factor rename to extra/html/parser/analyzer/analyzer.factor diff --git a/basis/html/parser/authors.txt b/extra/html/parser/analyzer/authors.txt similarity index 100% rename from basis/html/parser/authors.txt rename to extra/html/parser/analyzer/authors.txt diff --git a/basis/html/parser/printer/authors.txt b/extra/html/parser/authors.txt similarity index 100% rename from basis/html/parser/printer/authors.txt rename to extra/html/parser/authors.txt diff --git a/basis/html/parser/parser-tests.factor b/extra/html/parser/parser-tests.factor similarity index 100% rename from basis/html/parser/parser-tests.factor rename to extra/html/parser/parser-tests.factor diff --git a/basis/html/parser/parser.factor b/extra/html/parser/parser.factor similarity index 100% rename from basis/html/parser/parser.factor rename to extra/html/parser/parser.factor diff --git a/basis/html/parser/utils/authors.txt b/extra/html/parser/printer/authors.txt similarity index 100% rename from basis/html/parser/utils/authors.txt rename to extra/html/parser/printer/authors.txt diff --git a/basis/html/parser/printer/printer.factor b/extra/html/parser/printer/printer.factor similarity index 100% rename from basis/html/parser/printer/printer.factor rename to extra/html/parser/printer/printer.factor diff --git a/basis/units/authors.txt b/extra/html/parser/utils/authors.txt similarity index 100% rename from basis/units/authors.txt rename to extra/html/parser/utils/authors.txt diff --git a/basis/html/parser/utils/utils-tests.factor b/extra/html/parser/utils/utils-tests.factor similarity index 100% rename from basis/html/parser/utils/utils-tests.factor rename to extra/html/parser/utils/utils-tests.factor diff --git a/basis/html/parser/utils/utils.factor b/extra/html/parser/utils/utils.factor similarity index 100% rename from basis/html/parser/utils/utils.factor rename to extra/html/parser/utils/utils.factor diff --git a/extra/io/files/unique/unique.factor b/extra/io/files/unique/unique.factor index 3efef66ae3..db11471a7a 100644 --- a/extra/io/files/unique/unique.factor +++ b/extra/io/files/unique/unique.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. -USING: kernel math math.bitfields combinators.lib math.parser +USING: kernel math math.bitwise combinators.lib math.parser random sequences sequences.lib continuations namespaces io.files io arrays io.files.unique.backend system combinators vocabs.loader ; diff --git a/extra/io/serial/serial.factor b/extra/io/serial/serial.factor index c24f08906c..936bc182bc 100644 --- a/extra/io/serial/serial.factor +++ b/extra/io/serial/serial.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. USING: accessors alien.c-types assocs combinators destructors -kernel math math.bitfields math.parser sequences summary system +kernel math math.bitwise math.parser sequences summary system vocabs.loader ; IN: io.serial diff --git a/extra/io/serial/unix/bsd/bsd.factor b/extra/io/serial/unix/bsd/bsd.factor index 3c5ce62c63..b684190698 100644 --- a/extra/io/serial/unix/bsd/bsd.factor +++ b/extra/io/serial/unix/bsd/bsd.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. -USING: alien.syntax kernel math.bitfields sequences system io.serial ; +USING: alien.syntax kernel math.bitwise sequences system io.serial ; IN: io.serial.unix M: bsd lookup-baud ( m -- n ) diff --git a/extra/io/serial/unix/unix-tests.factor b/extra/io/serial/unix/unix-tests.factor index bbfd10b943..6dd056feb5 100644 --- a/extra/io/serial/unix/unix-tests.factor +++ b/extra/io/serial/unix/unix-tests.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors kernel math.bitfields serial serial.unix ; +USING: accessors kernel math.bitwise serial serial.unix ; IN: io.serial.unix : serial-obj ( -- obj ) diff --git a/extra/io/serial/unix/unix.factor b/extra/io/serial/unix/unix.factor index ed60d941dd..1da6385f96 100644 --- a/extra/io/serial/unix/unix.factor +++ b/extra/io/serial/unix/unix.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. USING: accessors alien.c-types alien.syntax combinators io.ports -io.streams.duplex io.unix.backend system kernel math math.bitfields +io.streams.duplex io.unix.backend system kernel math math.bitwise vocabs.loader unix io.serial io.serial.unix.termios ; IN: io.serial.unix diff --git a/extra/math/bit-count/bit-count.factor b/extra/math/bit-count/bit-count.factor deleted file mode 100644 index f5b0cc53df..0000000000 --- a/extra/math/bit-count/bit-count.factor +++ /dev/null @@ -1,38 +0,0 @@ -! Copyright (C) 2008 Slava Pestov. -! See http://factorcode.org/license.txt for BSD license. -USING: kernel math math.functions quotations words sequences -sequences.private combinators fry ; -IN: math.bit-count - -> - -GENERIC: (bit-count) ( x -- n ) - -M: fixnum (bit-count) - { - [ byte-bit-count ] - [ -8 shift byte-bit-count ] - [ -16 shift byte-bit-count ] - [ -24 shift byte-bit-count ] - } cleave + + + ; - -M: bignum (bit-count) - dup 0 = [ drop 0 ] [ - [ byte-bit-count ] [ -8 shift (bit-count) ] bi + - ] if ; - -PRIVATE> - -: bit-count ( x -- n ) - dup 0 >= [ (bit-count) ] [ bitnot (bit-count) ] if ; inline diff --git a/extra/math/bitfields/lib/lib-docs.factor b/extra/math/bitfields/lib/lib-docs.factor deleted file mode 100644 index bfbe9eaded..0000000000 --- a/extra/math/bitfields/lib/lib-docs.factor +++ /dev/null @@ -1,16 +0,0 @@ -USING: help.markup help.syntax kernel math sequences ; -IN: math.bitfields.lib - -HELP: bits -{ $values { "m" integer } { "n" integer } { "m'" integer } } -{ $description "Keep only n bits from the integer m." } -{ $example "USING: math.bitfields.lib prettyprint ;" "HEX: 123abcdef 16 bits .h" "cdef" } ; - -HELP: bitroll -{ $values { "x" "an integer (input)" } { "s" "an integer (shift)" } { "w" "an integer (wrap)" } { "y" integer } } -{ $description "Roll n by s bits to the left, wrapping around after w bits." } -{ $examples - { $example "USING: math.bitfields.lib prettyprint ;" "1 -1 32 bitroll .b" "10000000000000000000000000000000" } - { $example "USING: math.bitfields.lib prettyprint ;" "HEX: ffff0000 8 32 bitroll .h" "ff0000ff" } -} ; - diff --git a/extra/math/bitfields/lib/lib-tests.factor b/extra/math/bitfields/lib/lib-tests.factor deleted file mode 100644 index c002240e69..0000000000 --- a/extra/math/bitfields/lib/lib-tests.factor +++ /dev/null @@ -1,14 +0,0 @@ -USING: math.bitfields.lib tools.test ; -IN: math.bitfields.lib.test - -[ 0 ] [ 1 0 0 bitroll ] unit-test -[ 1 ] [ 1 0 1 bitroll ] unit-test -[ 1 ] [ 1 1 1 bitroll ] unit-test -[ 1 ] [ 1 0 2 bitroll ] unit-test -[ 1 ] [ 1 0 1 bitroll ] unit-test -[ 1 ] [ 1 20 2 bitroll ] unit-test -[ 1 ] [ 1 8 8 bitroll ] unit-test -[ 1 ] [ 1 -8 8 bitroll ] unit-test -[ 1 ] [ 1 -32 8 bitroll ] unit-test -[ 128 ] [ 1 -1 8 bitroll ] unit-test -[ 8 ] [ 1 3 32 bitroll ] unit-test diff --git a/extra/math/bitfields/lib/lib.factor b/extra/math/bitfields/lib/lib.factor deleted file mode 100644 index 1e755d71d9..0000000000 --- a/extra/math/bitfields/lib/lib.factor +++ /dev/null @@ -1,30 +0,0 @@ -USING: hints kernel math ; -IN: math.bitfields.lib - -: clear-bit ( x n -- y ) 2^ bitnot bitand ; inline -: set-bit ( x n -- y ) 2^ bitor ; inline -: bit-clear? ( x n -- ? ) 2^ bitand zero? ; inline -: unmask ( x n -- ? ) bitnot bitand ; inline -: unmask? ( x n -- ? ) unmask 0 > ; inline -: mask ( x n -- ? ) bitand ; inline -: mask? ( x n -- ? ) mask 0 > ; inline -: wrap ( m n -- m' ) 1- bitand ; inline -: bits ( m n -- m' ) 2^ wrap ; inline -: mask-bit ( m n -- m' ) 1- 2^ mask ; inline - -: shift-mod ( n s w -- n ) - >r shift r> 2^ wrap ; inline - -: bitroll ( x s w -- y ) - [ wrap ] keep - [ shift-mod ] - [ [ - ] keep shift-mod ] 3bi bitor ; inline - -: bitroll-32 ( n s -- n' ) 32 bitroll ; - -HINTS: bitroll-32 bignum fixnum ; - -: bitroll-64 ( n s -- n' ) 64 bitroll ; - -HINTS: bitroll-64 bignum fixnum ; - diff --git a/extra/namespaces/lib/lib-tests.factor b/extra/namespaces/lib/lib-tests.factor index 0bc2e6311a..d3f5a12faa 100755 --- a/extra/namespaces/lib/lib-tests.factor +++ b/extra/namespaces/lib/lib-tests.factor @@ -1,8 +1 @@ -IN: namespaces.lib.tests -USING: namespaces.lib kernel tools.test ; -[ ] [ [ ] { } nmake ] unit-test - -[ { 1 } { 2 } ] [ [ 1 0, 2 1, ] { { } { } } nmake ] unit-test - -[ [ ] [ call ] curry { { } } nmake ] must-infer diff --git a/extra/namespaces/lib/lib.factor b/extra/namespaces/lib/lib.factor index da9fde9d79..ae0887e45a 100755 --- a/extra/namespaces/lib/lib.factor +++ b/extra/namespaces/lib/lib.factor @@ -16,45 +16,6 @@ IN: namespaces.lib : set* ( val var -- ) namestack* set-assoc-stack ; -SYMBOL: building-seq -: get-building-seq ( n -- seq ) - building-seq get nth ; - -: n, ( obj n -- ) get-building-seq push ; -: n% ( seq n -- ) get-building-seq push-all ; -: n# ( num n -- ) >r number>string r> n% ; - -: 0, ( obj -- ) 0 n, ; -: 0% ( seq -- ) 0 n% ; -: 0# ( num -- ) 0 n# ; -: 1, ( obj -- ) 1 n, ; -: 1% ( seq -- ) 1 n% ; -: 1# ( num -- ) 1 n# ; -: 2, ( obj -- ) 2 n, ; -: 2% ( seq -- ) 2 n% ; -: 2# ( num -- ) 2 n# ; -: 3, ( obj -- ) 3 n, ; -: 3% ( seq -- ) 3 n% ; -: 3# ( num -- ) 3 n# ; -: 4, ( obj -- ) 4 n, ; -: 4% ( seq -- ) 4 n% ; -: 4# ( num -- ) 4 n# ; - -MACRO: finish-nmake ( exemplars -- ) - length [ firstn ] curry ; - -:: nmake ( quot exemplars -- ) - [ - exemplars - [ 0 swap new-resizable ] map - building-seq set - - quot call - - building-seq get - exemplars [ [ like ] 2map ] [ finish-nmake ] bi - ] with-scope ; inline - : make-object ( quot class -- object ) new [ swap bind ] keep ; inline diff --git a/basis/opengl/capabilities/authors.txt b/extra/opengl/capabilities/authors.txt similarity index 100% rename from basis/opengl/capabilities/authors.txt rename to extra/opengl/capabilities/authors.txt diff --git a/basis/opengl/capabilities/capabilities-docs.factor b/extra/opengl/capabilities/capabilities-docs.factor similarity index 100% rename from basis/opengl/capabilities/capabilities-docs.factor rename to extra/opengl/capabilities/capabilities-docs.factor diff --git a/basis/opengl/capabilities/capabilities.factor b/extra/opengl/capabilities/capabilities.factor similarity index 100% rename from basis/opengl/capabilities/capabilities.factor rename to extra/opengl/capabilities/capabilities.factor diff --git a/basis/opengl/capabilities/summary.txt b/extra/opengl/capabilities/summary.txt similarity index 100% rename from basis/opengl/capabilities/summary.txt rename to extra/opengl/capabilities/summary.txt diff --git a/basis/opengl/capabilities/tags.txt b/extra/opengl/capabilities/tags.txt similarity index 100% rename from basis/opengl/capabilities/tags.txt rename to extra/opengl/capabilities/tags.txt diff --git a/basis/opengl/demo-support/authors.txt b/extra/opengl/demo-support/authors.txt similarity index 100% rename from basis/opengl/demo-support/authors.txt rename to extra/opengl/demo-support/authors.txt diff --git a/basis/opengl/demo-support/demo-support.factor b/extra/opengl/demo-support/demo-support.factor similarity index 100% rename from basis/opengl/demo-support/demo-support.factor rename to extra/opengl/demo-support/demo-support.factor diff --git a/basis/opengl/demo-support/summary.txt b/extra/opengl/demo-support/summary.txt similarity index 100% rename from basis/opengl/demo-support/summary.txt rename to extra/opengl/demo-support/summary.txt diff --git a/basis/opengl/demo-support/tags.txt b/extra/opengl/demo-support/tags.txt similarity index 100% rename from basis/opengl/demo-support/tags.txt rename to extra/opengl/demo-support/tags.txt diff --git a/basis/opengl/framebuffers/authors.txt b/extra/opengl/framebuffers/authors.txt similarity index 100% rename from basis/opengl/framebuffers/authors.txt rename to extra/opengl/framebuffers/authors.txt diff --git a/basis/opengl/framebuffers/framebuffers-docs.factor b/extra/opengl/framebuffers/framebuffers-docs.factor similarity index 100% rename from basis/opengl/framebuffers/framebuffers-docs.factor rename to extra/opengl/framebuffers/framebuffers-docs.factor diff --git a/basis/opengl/framebuffers/framebuffers.factor b/extra/opengl/framebuffers/framebuffers.factor similarity index 100% rename from basis/opengl/framebuffers/framebuffers.factor rename to extra/opengl/framebuffers/framebuffers.factor diff --git a/basis/opengl/framebuffers/summary.txt b/extra/opengl/framebuffers/summary.txt similarity index 100% rename from basis/opengl/framebuffers/summary.txt rename to extra/opengl/framebuffers/summary.txt diff --git a/basis/opengl/framebuffers/tags.txt b/extra/opengl/framebuffers/tags.txt similarity index 100% rename from basis/opengl/framebuffers/tags.txt rename to extra/opengl/framebuffers/tags.txt diff --git a/basis/opengl/gadgets/gadgets-tests.factor b/extra/opengl/gadgets/gadgets-tests.factor similarity index 100% rename from basis/opengl/gadgets/gadgets-tests.factor rename to extra/opengl/gadgets/gadgets-tests.factor diff --git a/basis/opengl/gadgets/gadgets.factor b/extra/opengl/gadgets/gadgets.factor similarity index 100% rename from basis/opengl/gadgets/gadgets.factor rename to extra/opengl/gadgets/gadgets.factor diff --git a/basis/opengl/shaders/authors.txt b/extra/opengl/shaders/authors.txt similarity index 100% rename from basis/opengl/shaders/authors.txt rename to extra/opengl/shaders/authors.txt diff --git a/basis/opengl/shaders/shaders-docs.factor b/extra/opengl/shaders/shaders-docs.factor similarity index 100% rename from basis/opengl/shaders/shaders-docs.factor rename to extra/opengl/shaders/shaders-docs.factor diff --git a/basis/opengl/shaders/shaders.factor b/extra/opengl/shaders/shaders.factor similarity index 100% rename from basis/opengl/shaders/shaders.factor rename to extra/opengl/shaders/shaders.factor diff --git a/basis/opengl/shaders/summary.txt b/extra/opengl/shaders/summary.txt similarity index 100% rename from basis/opengl/shaders/summary.txt rename to extra/opengl/shaders/summary.txt diff --git a/basis/opengl/shaders/tags.txt b/extra/opengl/shaders/tags.txt similarity index 100% rename from basis/opengl/shaders/tags.txt rename to extra/opengl/shaders/tags.txt diff --git a/extra/pack/pack.factor b/extra/pack/pack.factor index ed2756bb80..adceab72f6 100755 --- a/extra/pack/pack.factor +++ b/extra/pack/pack.factor @@ -1,7 +1,7 @@ USING: alien alien.c-types arrays assocs byte-arrays io io.binary io.streams.string kernel math math.parser namespaces parser prettyprint quotations sequences strings vectors words -macros math.functions math.bitfields.lib ; +macros math.functions math.bitwise ; IN: pack SYMBOL: big-endian diff --git a/extra/sequences/lib/lib-tests.factor b/extra/sequences/lib/lib-tests.factor index 3744a7217a..76f3bb4f5b 100755 --- a/extra/sequences/lib/lib-tests.factor +++ b/extra/sequences/lib/lib-tests.factor @@ -43,9 +43,6 @@ IN: sequences.lib.tests [ { { 1 1 1 1 } { 2 2 } { 3 } { 4 } { 5 } { 6 6 6 } } ] [ { 1 1 1 1 2 2 3 4 5 6 6 6 } [ = ] monotonic-split [ >array ] map ] unit-test -[ 2 ] [ V{ 10 20 30 } [ delete-random drop ] keep length ] unit-test -[ V{ } [ delete-random drop ] keep length ] must-fail - [ { 1 9 25 } ] [ { 1 3 5 6 } [ sq ] [ even? ] map-until ] unit-test [ { 2 4 } ] [ { 2 4 1 3 } [ even? ] take-while ] unit-test @@ -69,6 +66,3 @@ IN: sequences.lib.tests [ "empty" ] [ { } [ "not empty" ] [ "empty" ] if-seq ] unit-test [ { 1 } "not empty" ] [ { 1 } [ "not empty" ] [ "empty" ] if-seq ] unit-test - -[ "empty" ] [ { } [ "empty" ] [ "not empty" ] if-empty ] unit-test -[ { 1 } "not empty" ] [ { 1 } [ "empty" ] [ "not empty" ] if-empty ] unit-test diff --git a/extra/sequences/lib/lib.factor b/extra/sequences/lib/lib.factor index 9e984857f6..a09b3d5b82 100755 --- a/extra/sequences/lib/lib.factor +++ b/extra/sequences/lib/lib.factor @@ -88,9 +88,6 @@ IN: sequences.lib : monotonic-split ( seq quot -- newseq ) over empty? [ 2drop { } ] [ (monotonic-split) ] if ; -: delete-random ( seq -- value ) - [ length random ] keep [ nth ] 2keep delete-nth ; - ERROR: element-not-found ; : split-around ( seq quot -- before elem after ) dupd find over [ element-not-found ] unless @@ -202,12 +199,6 @@ PRIVATE> : ?nth* ( n seq -- elt/f ? ) 2dup bounds-check? [ nth-unsafe t ] [ 2drop f f ] if ; flushable -: remove-nth ( n seq -- seq' ) - [ swap head-slice ] [ swap 1+ tail-slice ] 2bi append ; - -: insert-nth ( elt n seq -- seq' ) - swap cut-slice [ swap 1array ] dip 3append ; - : if-seq ( seq quot1 quot2 -- ) [ f like ] 2dip if* ; inline : if-empty ( seq quot1 quot2 -- ) swap if-seq ; inline diff --git a/extra/serial/serial.factor b/extra/serial/serial.factor index 39a63927da..df304e0f04 100644 --- a/extra/serial/serial.factor +++ b/extra/serial/serial.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. USING: accessors alien.c-types assocs combinators destructors -kernel math math.bitfields math.parser sequences summary system +kernel math math.bitwise math.parser sequences summary system vocabs.loader ; IN: serial diff --git a/extra/serial/unix/bsd/bsd.factor b/extra/serial/unix/bsd/bsd.factor index feed85348b..d31d947dcb 100644 --- a/extra/serial/unix/bsd/bsd.factor +++ b/extra/serial/unix/bsd/bsd.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. -USING: alien.syntax kernel math.bitfields sequences system serial ; +USING: alien.syntax kernel math.bitwise sequences system serial ; IN: serial.unix M: bsd lookup-baud ( m -- n ) diff --git a/extra/serial/unix/unix-tests.factor b/extra/serial/unix/unix-tests.factor index bab6c3f4f1..e9126a5961 100644 --- a/extra/serial/unix/unix-tests.factor +++ b/extra/serial/unix/unix-tests.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors kernel math.bitfields serial serial.unix ; +USING: accessors kernel math.bitwise serial serial.unix ; IN: serial.unix : serial-obj ( -- obj ) diff --git a/extra/serial/unix/unix.factor b/extra/serial/unix/unix.factor index 7ed5bced37..90dbd185bd 100644 --- a/extra/serial/unix/unix.factor +++ b/extra/serial/unix/unix.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. USING: accessors alien.c-types alien.syntax combinators io.ports -io.streams.duplex io.unix.backend system kernel math math.bitfields +io.streams.duplex io.unix.backend system kernel math math.bitwise vocabs.loader unix serial serial.unix.termios ; IN: serial.unix diff --git a/basis/ui/gadgets/cartesian/cartesian.factor b/extra/ui/gadgets/cartesian/cartesian.factor similarity index 100% rename from basis/ui/gadgets/cartesian/cartesian.factor rename to extra/ui/gadgets/cartesian/cartesian.factor diff --git a/basis/ui/gadgets/frame-buffer/frame-buffer.factor b/extra/ui/gadgets/frame-buffer/frame-buffer.factor similarity index 100% rename from basis/ui/gadgets/frame-buffer/frame-buffer.factor rename to extra/ui/gadgets/frame-buffer/frame-buffer.factor diff --git a/basis/ui/gadgets/handler/authors.txt b/extra/ui/gadgets/handler/authors.txt similarity index 100% rename from basis/ui/gadgets/handler/authors.txt rename to extra/ui/gadgets/handler/authors.txt diff --git a/basis/ui/gadgets/handler/handler.factor b/extra/ui/gadgets/handler/handler.factor similarity index 100% rename from basis/ui/gadgets/handler/handler.factor rename to extra/ui/gadgets/handler/handler.factor diff --git a/basis/ui/gadgets/plot/plot.factor b/extra/ui/gadgets/plot/plot.factor similarity index 100% rename from basis/ui/gadgets/plot/plot.factor rename to extra/ui/gadgets/plot/plot.factor diff --git a/basis/ui/gadgets/lib/authors.txt b/extra/ui/gadgets/slate/authors.txt similarity index 100% rename from basis/ui/gadgets/lib/authors.txt rename to extra/ui/gadgets/slate/authors.txt diff --git a/basis/ui/gadgets/slate/slate.factor b/extra/ui/gadgets/slate/slate.factor similarity index 100% rename from basis/ui/gadgets/slate/slate.factor rename to extra/ui/gadgets/slate/slate.factor diff --git a/basis/ui/gadgets/tabs/authors.txt b/extra/ui/gadgets/tabs/authors.txt similarity index 100% rename from basis/ui/gadgets/tabs/authors.txt rename to extra/ui/gadgets/tabs/authors.txt diff --git a/basis/ui/gadgets/tabs/summary.txt b/extra/ui/gadgets/tabs/summary.txt similarity index 100% rename from basis/ui/gadgets/tabs/summary.txt rename to extra/ui/gadgets/tabs/summary.txt diff --git a/basis/ui/gadgets/tabs/tabs.factor b/extra/ui/gadgets/tabs/tabs.factor similarity index 100% rename from basis/ui/gadgets/tabs/tabs.factor rename to extra/ui/gadgets/tabs/tabs.factor diff --git a/basis/ui/gadgets/tiling/tiling.factor b/extra/ui/gadgets/tiling/tiling.factor similarity index 100% rename from basis/ui/gadgets/tiling/tiling.factor rename to extra/ui/gadgets/tiling/tiling.factor diff --git a/basis/units/constants/authors.txt b/extra/units/authors.txt similarity index 100% rename from basis/units/constants/authors.txt rename to extra/units/authors.txt diff --git a/basis/units/imperial/authors.txt b/extra/units/constants/authors.txt similarity index 100% rename from basis/units/imperial/authors.txt rename to extra/units/constants/authors.txt diff --git a/basis/units/constants/constants.factor b/extra/units/constants/constants.factor similarity index 100% rename from basis/units/constants/constants.factor rename to extra/units/constants/constants.factor diff --git a/basis/units/constants/constants.txt b/extra/units/constants/constants.txt similarity index 100% rename from basis/units/constants/constants.txt rename to extra/units/constants/constants.txt diff --git a/basis/units/si/authors.txt b/extra/units/imperial/authors.txt similarity index 100% rename from basis/units/si/authors.txt rename to extra/units/imperial/authors.txt diff --git a/basis/units/imperial/imperial-tests.factor b/extra/units/imperial/imperial-tests.factor similarity index 100% rename from basis/units/imperial/imperial-tests.factor rename to extra/units/imperial/imperial-tests.factor diff --git a/basis/units/imperial/imperial.factor b/extra/units/imperial/imperial.factor similarity index 100% rename from basis/units/imperial/imperial.factor rename to extra/units/imperial/imperial.factor diff --git a/extra/units/si/authors.txt b/extra/units/si/authors.txt new file mode 100755 index 0000000000..7c1b2f2279 --- /dev/null +++ b/extra/units/si/authors.txt @@ -0,0 +1 @@ +Doug Coleman diff --git a/basis/units/si/si-tests.factor b/extra/units/si/si-tests.factor similarity index 100% rename from basis/units/si/si-tests.factor rename to extra/units/si/si-tests.factor diff --git a/basis/units/si/si.factor b/extra/units/si/si.factor similarity index 100% rename from basis/units/si/si.factor rename to extra/units/si/si.factor diff --git a/basis/units/units-tests.factor b/extra/units/units-tests.factor similarity index 100% rename from basis/units/units-tests.factor rename to extra/units/units-tests.factor diff --git a/basis/units/units.factor b/extra/units/units.factor similarity index 100% rename from basis/units/units.factor rename to extra/units/units.factor diff --git a/extra/x/widgets/wm/frame/frame.factor b/extra/x/widgets/wm/frame/frame.factor index b75671fa3c..d20c5bf672 100755 --- a/extra/x/widgets/wm/frame/frame.factor +++ b/extra/x/widgets/wm/frame/frame.factor @@ -4,7 +4,7 @@ USING: kernel io combinators namespaces quotations arrays sequences x11.xlib x11.constants mortar mortar.sugar slot-accessors geom.rect - math.bitfields + math.bitwise x x.gc x.widgets x.widgets.button x.widgets.wm.child diff --git a/extra/xml/syntax/syntax.factor b/extra/xml/syntax/syntax.factor new file mode 100644 index 0000000000..283efa8412 --- /dev/null +++ b/extra/xml/syntax/syntax.factor @@ -0,0 +1,58 @@ +! Copyright (C) 2008 Daniel Ehrenberg. +! See http://factorcode.org/license.txt for BSD license. +USING: lexer parser splitting kernel quotations namespaces +sequences assocs sequences.lib xml.generator xml.utilities +xml.data ; +IN: xml.syntax + +: parsed-name ( accum -- accum ) + scan ":" split1 [ f ] [ ] if* parsed ; + +: run-combinator ( accum quot1 quot2 -- accum ) + >r [ ] like parsed r> [ parsed ] each ; + +: parse-tag-contents ( accum contained? -- accum ) + [ \ contained*, parsed ] [ + scan-word \ [ = + [ POSTPONE: [ \ tag*, parsed ] + [ "Expected [ missing" throw ] if + ] if ; + +DEFER: >> + +: attributes-parsed ( accum quot -- accum ) + dup empty? [ drop f parsed ] [ + >r \ >r parsed r> parsed + [ H{ } make-assoc r> swap ] [ parsed ] each + ] if ; + +: << + parsed-name [ + \ >> parse-until >quotation + attributes-parsed \ contained? get + ] with-scope parse-tag-contents ; parsing + +: == + \ call parsed parsed-name \ set parsed ; parsing + +: // + \ contained? on ; parsing + +: parse-special ( accum end-token word -- accum ) + >r parse-tokens " " join parsed r> parsed ; + +: " \ comment, parse-special ; parsing + +: " \ directive, parse-special ; parsing + +: " \ instruction, parse-special ; parsing + +: >xml-document ( seq -- xml ) + dup first prolog? [ unclip-slice ] [ standard-prolog ] if swap + [ tag? ] split-around ; + +DEFER: XML> + +: [ >quotation ] parse-literal + { } parsed \ make parsed \ >xml-document parsed ; parsing -- 2.34.1