]> gitweb.factorcode.org Git - factor.git/commitdiff
Merge branch 'mongo-factor-driver' of git@github.com:x6j8x/factor into mongo-factor...
authorSascha Matzke <sascha.matzke@didolo.org>
Mon, 11 May 2009 08:08:22 +0000 (10:08 +0200)
committerSascha Matzke <sascha.matzke@didolo.org>
Mon, 11 May 2009 08:08:22 +0000 (10:08 +0200)
70 files changed:
basis/alien/c-types/c-types.factor
basis/base64/base64-tests.factor
basis/cocoa/application/application.factor
basis/cocoa/messages/messages.factor
basis/compiler/codegen/codegen.factor
basis/compiler/tests/curry.factor
basis/compiler/tree/escape-analysis/escape-analysis-tests.factor
basis/compiler/tree/tuple-unboxing/tuple-unboxing-tests.factor
basis/cpu/ppc/ppc.factor
basis/fry/fry-docs.factor
basis/generalizations/generalizations-docs.factor
basis/generalizations/generalizations-tests.factor
basis/generalizations/generalizations.factor
basis/io/directories/search/search-docs.factor
basis/io/directories/search/search.factor
basis/io/launcher/unix/unix-tests.factor
basis/io/streams/string/string-tests.factor
basis/stack-checker/known-words/known-words.factor
basis/stack-checker/stack-checker-tests.factor
basis/tools/deploy/deploy-docs.factor
basis/tools/deploy/deploy-tests.factor
basis/tools/deploy/shaker/shaker.factor
basis/tools/deploy/shaker/strip-cocoa.factor
basis/ui/backend/windows/windows.factor
basis/ui/gadgets/worlds/worlds.factor
basis/ui/gestures/gestures.factor
basis/ui/pixel-formats/pixel-formats.factor
basis/urls/encoding/encoding-tests.factor
basis/urls/urls.factor
basis/windows/com/com.factor
basis/windows/com/wrapper/wrapper.factor
basis/xml/xml.factor
core/combinators/combinators-docs.factor
core/io/io-docs.factor
core/io/io.factor
core/io/streams/byte-array/byte-array-tests.factor
core/kernel/kernel-docs.factor
core/kernel/kernel-tests.factor
core/kernel/kernel.factor
core/quotations/quotations.factor
core/sequences/sequences-docs.factor
core/sequences/sequences.factor
extra/crypto/rsa/rsa.factor
extra/crypto/timing/authors.txt [deleted file]
extra/crypto/timing/timing-tests.factor [deleted file]
extra/crypto/timing/timing.factor [deleted file]
extra/hashcash/authors.txt [new file with mode: 0755]
extra/hashcash/hashcash-docs.factor [new file with mode: 0644]
extra/hashcash/hashcash-tests.factor [new file with mode: 0644]
extra/hashcash/hashcash.factor [new file with mode: 0755]
extra/hashcash/summary.txt [new file with mode: 0644]
extra/id3/id3.factor
extra/mason/common/common.factor
extra/mason/notify/notify.factor
extra/random/blum-blum-shub/blum-blum-shub.factor
extra/redis/authors.txt [new file with mode: 0644]
extra/redis/command-writer/authors.txt [new file with mode: 0644]
extra/redis/command-writer/command-writer-tests.factor [new file with mode: 0644]
extra/redis/command-writer/command-writer.factor [new file with mode: 0644]
extra/redis/command-writer/summary.txt [new file with mode: 0644]
extra/redis/redis.factor [new file with mode: 0644]
extra/redis/response-parser/authors.txt [new file with mode: 0644]
extra/redis/response-parser/response-parser-tests.factor [new file with mode: 0644]
extra/redis/response-parser/response-parser.factor [new file with mode: 0644]
extra/redis/response-parser/summary.txt [new file with mode: 0644]
extra/redis/summary.txt [new file with mode: 0644]
extra/reports/noise/noise.factor
extra/spheres/deploy.factor
extra/spider/unique-deque/unique-deque.factor
extra/terrain/deploy.factor [new file with mode: 0644]

index 6067c90f2df95e1c6702cd8363a87850df0ceaff..df5a5bbba8ea2bc46cfd8ca97f4dfcfc3dc97ce5 100755 (executable)
@@ -259,8 +259,9 @@ M: long-long-type box-return ( type -- )
     [ dup c-setter '[ _ <c-object> [ 0 @ ] keep ] ] bi
     (( value -- c-ptr )) define-inline ;
 
-: c-bool> ( int -- ? )
-    0 = not ; inline
+: >c-bool ( ? -- int ) 1 0 ? ; inline
+
+: c-bool> ( int -- ? ) 0 = not ; inline
 
 : define-primitive-type ( type name -- )
     [ typedef ]
@@ -409,8 +410,8 @@ CONSTANT: primitive-types
     "uchar" define-primitive-type
 
     <c-type>
-        [ alien-unsigned-1 zero? not ] >>getter
-        [ [ 1 0 ? ] 2dip set-alien-unsigned-1 ] >>setter
+        [ alien-unsigned-1 c-bool> ] >>getter
+        [ [ >c-bool ] 2dip set-alien-unsigned-1 ] >>setter
         1 >>size
         1 >>align
         "box_boolean" >>boxer
index 9094286575ce78ec4aced1611619f368aaa7ef5d..e962fa7e5937598aa1e125b9139395ae56530a07 100644 (file)
@@ -4,7 +4,7 @@ IN: base64.tests
 
 [ "abcdefghijklmnopqrstuvwxyz" ] [ "abcdefghijklmnopqrstuvwxyz" ascii encode >base64 base64> ascii decode
 ] unit-test
-[ f ] [ "" ascii encode >base64 base64> ascii decode ] unit-test
+[ "" ] [ "" ascii encode >base64 base64> ascii decode ] unit-test
 [ "a" ] [ "a" ascii encode >base64 base64> ascii decode ] unit-test
 [ "ab" ] [ "ab" ascii encode >base64 base64> ascii decode ] unit-test
 [ "abc" ] [ "abc" ascii encode >base64 base64> ascii decode ] unit-test
index 8b33986fc2864a938bfe35497118987fb811ebf5..66093645c1d40abdd58a8d2dc284c5299365fbee 100644 (file)
@@ -14,7 +14,7 @@ NSApplicationDelegateReplyCancel
 NSApplicationDelegateReplyFailure ;
 
 : with-autorelease-pool ( quot -- )
-    NSAutoreleasePool -> new slip -> release ; inline
+    NSAutoreleasePool -> new [ call ] [ -> release ] bi* ; inline
 
 : NSApp ( -- app ) NSApplication -> sharedApplication ;
 
index 65bb2c02ef19fd372b1f9d56f01ea4c7498837cb..fdd4ba81d75d6e88ef1dfdc46c6c22b520cf61fa 100644 (file)
@@ -68,7 +68,7 @@ MACRO: (send) ( selector super? -- quot )
     [ dup lookup-method ] dip
     [ make-prepare-send ] 2keep
     super-message-senders message-senders ? get at
-    '[ _ call _ execute ] ;
+    1quotation append ;
 
 : send ( receiver args... selector -- return... ) f (send) ; inline
 
index 47593878fae2025fe67102069f3df7a09429b7b3..c7b67b72b4d0bc01ffdf3850927c902ea321862b 100755 (executable)
@@ -444,8 +444,7 @@ TUPLE: callback-context ;
 
 : do-callback ( quot token -- )
     init-catchstack
-    dup 2 setenv
-    slip
+    [ 2 setenv call ] keep
     wait-to-return ; inline
 
 : callback-return-quot ( ctype -- quot )
index 32611ba87a1d36ba1386f76d2ee958552da592a0..b541e19f34bf6c904ad30db38bb56843b604677f 100644 (file)
@@ -33,7 +33,7 @@ IN: compiler.tests.curry
 ] unit-test
 
 : foobar ( quot: ( -- ) -- )
-    dup slip swap [ foobar ] [ drop ] if ; inline recursive
+    [ call ] keep swap [ foobar ] [ drop ] if ; inline recursive
 
 [ ] [ [ [ f ] foobar ] compile-call ] unit-test
 
index 5f89372ebe2d7bec6898d15156f6c6390b5a9caf..3d9d77ae56b235c94da3c8356e49691fc2987b98 100644 (file)
@@ -302,7 +302,7 @@ C: <ro-box> ro-box
 [ 0 ] [ [ 1 cons boa "x" get slot ] count-unboxed-allocations ] unit-test
 
 : impeach-node ( quot: ( node -- ) -- )
-    dup slip impeach-node ; inline recursive
+    [ call ] keep impeach-node ; inline recursive
 
 : bleach-node ( quot: ( node -- ) -- )
     [ bleach-node ] curry [ ] compose impeach-node ; inline recursive
index 70670648b1666816d80b597bde1f3de9473b5bb4..0d5f05fab0592823f6e2eafadadaa99a2e01b2b1 100644 (file)
@@ -39,7 +39,7 @@ TUPLE: empty-tuple ;
 
 ! A more complicated example
 : impeach-node ( quot: ( node -- ) -- )
-    dup slip impeach-node ; inline recursive
+    [ call ] keep impeach-node ; inline recursive
 
 : bleach-node ( quot: ( node -- ) -- )
     [ bleach-node ] curry [ ] compose impeach-node ; inline recursive
index 442dd8e7eaabce36afe5c2b5e9cc16d3691d55ce..dc7108b3a11a143953fe3f9e986ffceed8a4d0e0 100644 (file)
@@ -2,11 +2,11 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors assocs sequences kernel combinators make math
 math.order math.ranges system namespaces locals layouts words
-alien alien.c-types literals cpu.architecture cpu.ppc.assembler
-cpu.ppc.assembler.backend literals compiler.cfg.registers
+alien alien.accessors alien.c-types literals cpu.architecture
+cpu.ppc.assembler cpu.ppc.assembler.backend literals compiler.cfg.registers
 compiler.cfg.instructions compiler.constants compiler.codegen
 compiler.codegen.fixup compiler.cfg.intrinsics
-compiler.cfg.stack-frame ;
+compiler.cfg.stack-frame compiler.units ;
 IN: cpu.ppc
 
 ! PowerPC register assignments:
@@ -713,4 +713,14 @@ USE: vocabs.loader
 } cond
 
 "complex-double" c-type t >>return-in-registers? drop
-"bool" c-type 4 >>size 4 >>align drop
\ No newline at end of file
+
+[
+    <c-type>
+        [ alien-unsigned-4 c-bool> ] >>getter
+        [ [ >c-bool ] 2dip set-alien-unsigned-4 ] >>setter
+        4 >>size
+        4 >>align
+        "box_boolean" >>boxer
+        "to_boolean" >>unboxer
+    "bool" define-primitive-type
+] with-compilation-unit
index 5d750775e571d0885fc70b2dc49c7a1f37e3d435..32ad856d004e9c82f350a91f048fae609039b790 100644 (file)
@@ -57,7 +57,6 @@ $nl
 "Here are some built-in combinators rewritten in terms of fried quotations:"\r
 { $table\r
     { { $link literalize } { $snippet ": literalize '[ _ ] ;" } }\r
-    { { $link slip } { $snippet ": slip '[ @ _ ] call ;" } }\r
     { { $link curry } { $snippet ": curry '[ _ @ ] ;" } }\r
     { { $link compose } { $snippet ": compose '[ @ @ ] ;" } }\r
     { { $link bi@ } { $snippet ": bi@ tuck '[ _ @ _ @ ] call ;" } }\r
index 36715111940242937ab1e43d6976993a4151f139..d6a3aa948a8489f0bfdc4cf2f722a412cc411f0e 100644 (file)
@@ -161,22 +161,6 @@ HELP: ndip
     }\r
 } ;\r
 \r
-HELP: nslip\r
-{ $values { "n" integer } }\r
-{ $description "A generalization of " { $link slip } " that can work " \r
-"for any stack depth. The first " { $snippet "n" } " items after the quotation will be "\r
-"removed from the stack, the quotation called, and the items restored."\r
-} \r
-{ $examples\r
-  { $example "USING: generalizations kernel prettyprint ;" "[ 99 ] 1 2 3 4 5 5 nslip 6 narray ." "{ 99 1 2 3 4 5 }" }\r
-  "Some core words expressed in terms of " { $link nslip } ":"\r
-    { $table\r
-        { { $link slip } { $snippet "1 nslip" } }\r
-        { { $link 2slip } { $snippet "2 nslip" } }\r
-        { { $link 3slip } { $snippet "3 nslip" } }\r
-    }\r
-} ;\r
-\r
 HELP: nkeep\r
 { $values { "quot" quotation } { "n" integer } }\r
 { $description "A generalization of " { $link keep } " that can work " \r
@@ -339,7 +323,6 @@ ARTICLE: "shuffle-generalizations" "Generalized shuffle words"
 \r
 ARTICLE: "combinator-generalizations" "Generalized combinators"\r
 { $subsection ndip }\r
-{ $subsection nslip }\r
 { $subsection nkeep }\r
 { $subsection napply }\r
 { $subsection ncleave }\r
index 7ede271d017d0fec830904498e06e664b7bdb913..d0f614f9cdbaeb6cba920e90280f333435fbe68e 100644 (file)
@@ -26,8 +26,6 @@ IN: generalizations.tests
 [ [ 1 ] 5 ndip ] must-infer\r
 [ 1 2 3 4 ] [ 2 3 4 [ 1 ] 3 ndip ] unit-test\r
 \r
-[ [ 99 ] 1 2 3 4 5 5 nslip ] must-infer\r
-{ 99 1 2 3 4 5 } [ [ 99 ] 1 2 3 4 5 5 nslip ] unit-test\r
 [ 1 2 3 4 5 [ drop drop drop drop drop 2 ] 5 nkeep ] must-infer\r
 { 2 1 2 3 4 5 } [ 1 2 3 4 5 [ drop drop drop drop drop 2 ] 5 nkeep ] unit-test\r
 [ [ 1 2 3 + ] ] [ 1 2 3 [ + ] 3 ncurry ] unit-test\r
index 139b7a528add97756ddd2848585b57fc7368e7fc..397166a4182af0bb28febe6fd5f38577a6fcb4d4 100644 (file)
@@ -60,9 +60,6 @@ MACRO: ntuck ( n -- )
 MACRO: ndip ( quot n -- )
     [ '[ _ dip ] ] times ;
 
-MACRO: nslip ( n -- )
-    '[ [ call ] _ ndip ] ;
-
 MACRO: nkeep ( quot n -- )
     tuck '[ _ ndup _ _ ndip ] ;
 
index a6c82a1bff21e16ae374384c388fb943b051e88b..6bfaa07227058fb8f32f91f1b9ab15a8665fbf8c 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2009 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: help.markup help.syntax kernel quotations ;
+USING: help.markup help.syntax kernel quotations sequences ;
 IN: io.directories.search
 
 HELP: each-file
@@ -57,6 +57,32 @@ HELP: find-all-in-directories
 }
 { $description "Finds all files in the input directories matching the predicate quotation in a breadth-first or depth-first traversal." } ;
 
+HELP: find-by-extension
+{ $values
+    { "path" "a pathname string" } { "extension" "a file extension" }
+    { "seq" sequence }
+}
+{ $description "Searches a directory for all files with the given extension. File extension and filenames are converted to lower-case and compared using the " { $link tail? } " word. The file extension should contain the period." }
+{ $examples
+    { $unchecked-example
+        "USING: io.directories.search ;"
+        "\"/\" \".mp3\" find-by-extension"
+    }
+} ;
+
+HELP: find-by-extensions
+{ $values
+    { "path" "a pathname string" } { "extensions" "a sequence of file extensions" }
+    { "seq" sequence }
+}
+{ $description "Searches a directory for all files in the given list of extensions. File extensions and filenames are converted to lower-case and compared using the " { $link tail? } " word. File extensions should contain the period." }
+{ $examples
+    { $unchecked-example
+        "USING: io.directories.search ;"
+        "\"/\" { \".jpg\" \".gif\" \".tiff\" \".png\" \".bmp\" } find-by-extensions"
+    }
+} ;
+
 { find-file find-all-files find-in-directories find-all-in-directories } related-words
 
 ARTICLE: "io.directories.search" "Searching directories"
@@ -65,10 +91,13 @@ ARTICLE: "io.directories.search" "Searching directories"
 { $subsection recursive-directory-files }
 { $subsection recursive-directory-entries }
 { $subsection each-file }
-"Finding files:"
+"Finding files by name:"
 { $subsection find-file }
 { $subsection find-all-files }
 { $subsection find-in-directories }
-{ $subsection find-all-in-directories } ;
+{ $subsection find-all-in-directories }
+"Finding files by extension:"
+{ $subsection find-by-extension }
+{ $subsection find-by-extensions } ;
 
 ABOUT: "io.directories.search"
index f7d18306f8a1cff9bd106da87dd48a29425ea299..3fbf09a3c3a71ef1a91e69998ef9ce7d38bf626e 100755 (executable)
@@ -3,7 +3,7 @@
 USING: accessors arrays continuations deques dlists fry
 io.directories io.files io.files.info io.pathnames kernel
 sequences system vocabs.loader locals math namespaces
-sorting assocs calendar threads io math.parser ;
+sorting assocs calendar threads io math.parser unicode.case ;
 IN: io.directories.search
 
 : qualified-directory-entries ( path -- seq )
@@ -106,4 +106,11 @@ ERROR: file-not-found path bfs? quot ;
         ] { } map>assoc
     ] with-qualified-directory-entries sort-values ;
 
+: find-by-extensions ( path extensions -- seq )
+    [ >lower ] map
+    '[ >lower _ [ tail? ] with any? ] find-all-files ;
+    
+: find-by-extension ( path extension -- seq )
+    1array find-by-extensions ;
+
 os windows? [ "io.directories.search.windows" require ] when
index 99d45e4fd7ca0c80a40eeeef030ddd2de8347c0d..852d8171e403233ea31a49ea4d295fe7ed2eb5ac 100644 (file)
@@ -48,7 +48,7 @@ concurrency.promises threads unix.process ;
     try-process
 ] unit-test
 
-[ f ] [
+[ "" ] [
     "cat"
     "launcher-test-1" temp-file
     2array
index 967c0d461347c1c1075379c8c430290f6bdf8a19..27971f14316fab75f4a62f5c831ca04c92e317a6 100644 (file)
@@ -2,6 +2,8 @@ USING: io.streams.string io kernel arrays namespaces make
 tools.test ;
 IN: io.streams.string.tests
 
+[ "" ] [ "" [ contents ] with-string-reader ] unit-test
+
 [ "line 1" CHAR: l ]
 [
     "line 1\nline 2\nline 3" <string-reader>
index 7603324200fb5aef3efae892c45d907a7550df8e..56ef67d2a8d2a0973d8a9dd60f4837a74cfbe035 100644 (file)
@@ -95,15 +95,6 @@ M: composed infer-call*
 M: object infer-call*
     "literal quotation" literal-expected ;
 
-: infer-nslip ( n -- )
-    [ infer->r infer-call ] [ infer-r> ] bi ;
-
-: infer-slip ( -- ) 1 infer-nslip ;
-
-: infer-2slip ( -- ) 2 infer-nslip ;
-
-: infer-3slip ( -- ) 3 infer-nslip ;
-
 : infer-ndip ( word n -- )
     [ literals get ] 2dip
     [ '[ _ def>> infer-quot-here ] ]
@@ -180,9 +171,6 @@ M: object infer-call*
         { \ declare [ infer-declare ] }
         { \ call [ infer-call ] }
         { \ (call) [ infer-call ] }
-        { \ slip [ infer-slip ] }
-        { \ 2slip [ infer-2slip ] }
-        { \ 3slip [ infer-3slip ] }
         { \ dip [ infer-dip ] }
         { \ 2dip [ infer-2dip ] }
         { \ 3dip [ infer-3dip ] }
@@ -216,7 +204,7 @@ M: object infer-call*
     "local-word-def" word-prop infer-quot-here ;
 
 {
-    declare call (call) slip 2slip 3slip dip 2dip 3dip curry compose
+    declare call (call) dip 2dip 3dip curry compose
     execute (execute) call-effect-unsafe execute-effect-unsafe if
     dispatch <tuple-boa> exit load-local load-locals get-local
     drop-locals do-primitive alien-invoke alien-indirect
index 919cd098f6c286bafe168a4b6a707680b3596eff..201f3ce30b8003b5a15840be40351e54655ac50f 100644 (file)
@@ -180,7 +180,7 @@ DEFER: blah4
     over [
         2drop
     ] [
-        [ swap slip ] keep swap bad-combinator
+        [ dip ] keep swap bad-combinator
     ] if ; inline recursive
 
 [ [ [ 1 ] [ ] bad-combinator ] infer ] must-fail
index 4c03047eb86960ea856790387553076ac1acb339..71701b6a56d6faa1316371011ed495290a5d63b0 100644 (file)
@@ -29,6 +29,8 @@ ARTICLE: "tools.deploy.caveats" "Deploy tool caveats"
 "In deployed applications, the " { $link boa } " word does not verify that the parameters on the stack satisfy the tuple's slot declarations, if any. This reduces deploy image size but can make bugs harder to track down. Make sure your program is fully debugged before deployment."
 { $heading "Behavior of " { $link POSTPONE: execute( } }
 "Similarly, the " { $link POSTPONE: execute( } " word does not check word stack effects in deployed applications, since stack effects are stripped out, and so it behaves exactly like " { $link POSTPONE: execute-effect-unsafe } "."
+{ $heading "Behavior of " { $link POSTPONE: call-next-method } }
+"The " { $link POSTPONE: call-next-method } " word does not check if the input is of the right type in deployed applications."
 { $heading "Error reporting" }
 "If the " { $link deploy-reflection } " level in the configuration is low enough, the debugger is stripped out, and error messages can be rather cryptic. Increase the reflection level to get readable error messages."
 { $heading "Choosing the right deploy flags" }
index 3bebf7236d6074c1db7ecbc62fb4af785febfebf..1c12e8b781285afa970ff34f4a41ad4a61f159c2 100644 (file)
@@ -20,6 +20,10 @@ io.directories tools.deploy.test ;
 \r
 [ t ] [ "tetris" shake-and-bake 1500000 small-enough? ] unit-test\r
 \r
+[ t ] [ "spheres" shake-and-bake 1500000 small-enough? ] unit-test\r
+\r
+[ t ] [ "terrain" shake-and-bake 1600000 small-enough? ] unit-test\r
+\r
 [ t ] [ "bunny" shake-and-bake 2500000 small-enough? ] unit-test\r
 \r
 os macosx? [\r
index 816dbb797934bffe0508ca1b8ca240b3ea0ff246..7bbc726d309df98c497b64dced5bba746430fc78 100755 (executable)
@@ -1,13 +1,11 @@
 ! Copyright (C) 2007, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors io.backend io.streams.c init fry
-namespaces make assocs kernel parser lexer strings.parser vocabs
-sequences words memory kernel.private
-continuations io vocabs.loader system strings sets
-vectors quotations byte-arrays sorting compiler.units
-definitions generic generic.standard tools.deploy.config ;
+USING: arrays accessors io.backend io.streams.c init fry namespaces
+make assocs kernel parser lexer strings.parser vocabs sequences words
+memory kernel.private continuations io vocabs.loader system strings
+sets vectors quotations byte-arrays sorting compiler.units definitions
+generic generic.standard tools.deploy.config combinators classes ;
 QUALIFIED: bootstrap.stage2
-QUALIFIED: classes
 QUALIFIED: command-line
 QUALIFIED: compiler.errors
 QUALIFIED: continuations
@@ -193,6 +191,11 @@ IN: tools.deploy.shaker
     strip-word-names? [ dup strip-word-names ] when
     2drop ;
 
+: strip-compiler-classes ( -- )
+    "Stripping compiler classes" show
+    "compiler" child-vocabs [ words ] map concat [ class? ] filter
+    [ dup implementors [ "methods" word-prop delete-at ] with each ] each ;
+
 : strip-default-methods ( -- )
     strip-debugger? [
         "Stripping default methods" show
@@ -255,14 +258,14 @@ IN: tools.deploy.shaker
             {
                 gensym
                 name>char-hook
-                classes:next-method-quot-cache
-                classes:class-and-cache
-                classes:class-not-cache
-                classes:class-or-cache
-                classes:class<=-cache
-                classes:classes-intersect-cache
-                classes:implementors-map
-                classes:update-map
+                next-method-quot-cache
+                class-and-cache
+                class-not-cache
+                class-or-cache
+                class<=-cache
+                classes-intersect-cache
+                implementors-map
+                update-map
                 command-line:main-vocab-hook
                 compiled-crossref
                 compiled-generic-crossref
@@ -334,8 +337,16 @@ IN: tools.deploy.shaker
     [ instances dup H{ } clone [ [ ] cache ] curry map ] dip call
     become ; inline
 
-: compress-byte-arrays ( -- )
-    [ byte-array? ] [ ] "byte arrays" compress ;
+: compress-objects ( -- )
+    [
+        {
+            [ dup array? [ empty? ] [ drop f ] if ]
+            [ byte-array? ]
+            [ string? ]
+            [ wrapper? ]
+        } cleave
+        or or or
+    ] [ ] "objects" compress ;
 
 : remain-compiled ( old new -- old new )
     #! Quotations which were formerly compiled must remain
@@ -349,12 +360,6 @@ IN: tools.deploy.shaker
     [ quotation? ] [ remain-compiled ] "quotations" compress
     [ quotation? ] instances [ f >>cached-effect f >>cache-counter drop ] each ;
 
-: compress-strings ( -- )
-    [ string? ] [ ] "strings" compress ;
-
-: compress-wrappers ( -- )
-    [ wrapper? ] [ ] "wrappers" compress ;
-
 SYMBOL: deploy-vocab
 
 : [:c] ( -- word ) ":c" "debugger" lookup ;
@@ -385,18 +390,23 @@ SYMBOL: deploy-vocab
     t "quiet" set-global
     f output-stream set-global ;
 
+: unsafe-next-method-quot ( method -- quot )
+    [ "method-class" word-prop ]
+    [ "method-generic" word-prop ] bi
+    next-method 1quotation ;
+
 : compute-next-methods ( -- )
     [ standard-generic? ] instances [
         "methods" word-prop [
-            nip
-            dup next-method-quot "next-method-quot" set-word-prop
+            nip dup
+            unsafe-next-method-quot
+            "next-method-quot" set-word-prop
         ] assoc-each
     ] each
     "vocab:tools/deploy/shaker/next-methods.factor" run-file ;
 
 : strip ( -- )
     init-stripper
-    strip-default-methods
     strip-libc
     strip-call
     strip-cocoa
@@ -404,14 +414,14 @@ SYMBOL: deploy-vocab
     compute-next-methods
     strip-init-hooks
     strip-c-io
+    strip-compiler-classes
+    strip-default-methods
     f 5 setenv ! we can't use the Factor debugger or Factor I/O anymore
     deploy-vocab get vocab-main deploy-boot-quot
     stripped-word-props
     stripped-globals strip-globals
-    compress-byte-arrays
+    compress-objects
     compress-quotations
-    compress-strings
-    compress-wrappers
     strip-words ;
 
 : deploy-error-handler ( quot -- )
index df64443b7b1d88bcd1871f22c0264539af86f781..133308b7329858a4f26656c6cce3d7933e5a7efb 100644 (file)
@@ -1,8 +1,8 @@
-! Copyright (C) 2007, 2008 Slava Pestov
+! Copyright (C) 2007, 2009 Slava Pestov
 ! See http://factorcode.org/license.txt for BSD license.
 USING: cocoa cocoa.messages cocoa.application cocoa.nibs assocs
 namespaces kernel kernel.private words compiler.units sequences
-init vocabs ;
+init vocabs memoize accessors ;
 IN: tools.deploy.shaker.cocoa
 
 : pool ( obj -- obj' ) \ pool get [ ] cache ;
@@ -42,3 +42,8 @@ H{ } clone \ pool [
         [ get values compile ] each
     ] bind
 ] with-variable
+
+\ make-prepare-send reset-memoized
+\ <selector> reset-memoized
+
+\ (send) def>> second clear-assoc
\ No newline at end of file
index ba4926d97e9c9be5697e5d8b2cc69ea3c98c09a0..2cf409193785897aff01fd08b432912819bf4cfa 100755 (executable)
@@ -616,19 +616,21 @@ M: windows-ui-backend do-events
     GetDoubleClickTime milliseconds double-click-timeout set-global ;
 
 : cleanup-win32-ui ( -- )
-    class-name-ptr get-global [ dup f UnregisterClass drop free ] when*
-    msg-obj get-global [ free ] when*
-    f class-name-ptr set-global
-    f msg-obj set-global ;
+    class-name-ptr [
+        [ [ f UnregisterClass drop ] [ free ] bi ] when* f
+    ] change-global
+    msg-obj change-global [ [ free ] when* f ] ;
 
-: get-dc ( world -- ) handle>> dup hWnd>> GetDC dup win32-error=0/f >>hDC drop ;
+: get-dc ( world -- )
+    handle>> dup hWnd>> GetDC dup win32-error=0/f >>hDC drop ;
 
 : get-rc ( world -- )
     handle>> dup hDC>> dup wglCreateContext dup win32-error=0/f
     [ wglMakeCurrent win32-error=0/f ] keep >>hRC drop ;
 
 : set-pixel-format ( pixel-format hdc -- )
-    swap handle>> "PIXELFORMATDESCRIPTOR" <c-object> SetPixelFormat win32-error=0/f ;
+    swap handle>>
+    "PIXELFORMATDESCRIPTOR" <c-object> SetPixelFormat win32-error=0/f ;
 
 : setup-gl ( world -- )
     [ get-dc ] keep
@@ -715,6 +717,7 @@ M: windows-ui-backend beep ( -- )
 M: windows-ui-backend (grab-input) ( handle -- )
     0 ShowCursor drop
     hWnd>> client-area>RECT ClipCursor drop ;
+
 M: windows-ui-backend (ungrab-input) ( handle -- )
     drop
     f ClipCursor drop
index eec5666f0eb33ac6b950c9592995b6c180d35b9d..2e7b84ef6e257786b4aefcb217ab032fbaf6a9be 100755 (executable)
@@ -4,7 +4,7 @@ USING: accessors arrays assocs continuations kernel math models
 namespaces opengl opengl.textures sequences io combinators
 combinators.short-circuit fry math.vectors math.rectangles cache
 ui.gadgets ui.gestures ui.render ui.backend ui.gadgets.tracks
-ui.commands ui.pixel-formats destructors literals ;
+ui.pixel-formats destructors literals ;
 IN: ui.gadgets.worlds
 
 CONSTANT: default-world-pixel-format-attributes
index 7e038ef2e0de6ece498911fc86f68350eaa24350..073b2d5e2683ff20f2d084cd7d669888e87cbd8c 100644 (file)
@@ -3,8 +3,8 @@
 USING: accessors arrays assocs kernel math math.order models
 namespaces make sequences words strings system hashtables math.parser
 math.vectors classes.tuple classes boxes calendar alarms combinators
-sets columns fry deques ui.gadgets ui.gadgets.private unicode.case
-unicode.categories combinators.short-circuit ;
+sets columns fry deques ui.gadgets ui.gadgets.private ascii
+combinators.short-circuit ;
 IN: ui.gestures
 
 GENERIC: handle-gesture ( gesture gadget -- ? )
@@ -296,10 +296,10 @@ HOOK: modifiers>string os ( modifiers -- string )
 M: macosx modifiers>string
     [
         {
-            { A+ [ "\u{place-of-interest-sign}" ] }
-            { M+ [ "\u{option-key}" ] }
-            { S+ [ "\u{upwards-white-arrow}" ] }
-            { C+ [ "\u{up-arrowhead}" ] }
+            { A+ [ "\u002318" ] }
+            { M+ [ "\u002325" ] }
+            { S+ [ "\u0021e7" ] }
+            { C+ [ "\u002303" ] }
         } case
     ] map "" join ;
 
index 52abf4436224a7c5616a5d506d14886ca20ca70d..a280ab0666fb75307a3ddaeb350ad0097bc4f2f8 100644 (file)
@@ -1,6 +1,6 @@
 USING: accessors assocs classes destructors functors kernel
 lexer math parser sequences specialized-arrays.int ui.backend
-words.symbol ;
+words ;
 IN: ui.pixel-formats
 
 SYMBOLS:
@@ -71,7 +71,7 @@ GENERIC: >PFA ( attribute -- pfas )
 
 M: object >PFA
     drop { } ;
-M: symbol >PFA
+M: word >PFA
     TABLE at [ { } ] unless* ;
 M: pixel-format-attribute >PFA
     dup class TABLE at
index 78e31a764df16020d3debd71f959eb7cd8ce17b4..f3e04975882ed82f623cb2f8a4b24b145e906c53 100644 (file)
@@ -2,8 +2,8 @@ IN: urls.encoding.tests
 USING: urls.encoding tools.test arrays kernel assocs present accessors ;
 
 [ "~hello world" ] [ "%7ehello world" url-decode ] unit-test
-[ f ] [ "%XX%XX%XX" url-decode ] unit-test
-[ f ] [ "%XX%XX%X" url-decode ] unit-test
+[ "" ] [ "%XX%XX%XX" url-decode ] unit-test
+[ "" ] [ "%XX%XX%X" url-decode ] unit-test
 
 [ "hello world" ] [ "hello%20world" url-decode ] unit-test
 [ " ! "         ] [ "%20%21%20"     url-decode ] unit-test
index 1e886ae3e26e1e6fac90f75bb175640023d031d9..a72fac567a28b0f532e786f78583da339ffc228c 100644 (file)
@@ -25,12 +25,14 @@ TUPLE: url protocol username password host port path query anchor ;
     ] if ;
 
 : parse-host ( string -- host port )
-    ":" split1 [ url-decode ] [
-        dup [
-            string>number
-            dup [ "Invalid port" throw ] unless
-        ] when
-    ] bi* ;
+    [
+        ":" split1 [ url-decode ] [
+            dup [
+                string>number
+                dup [ "Invalid port" throw ] unless
+            ] when
+        ] bi*
+    ] [ f f ] if* ;
 
 GENERIC: >url ( obj -- url )
 
index af828c9145c61f00dc6b72eba13d0148e3226d0c..d485692a910fbef397b53e4c872661973280066c 100644 (file)
@@ -40,6 +40,6 @@ COM-INTERFACE: IDropTarget IUnknown {00000122-0000-0000-C000-000000000046}
     IUnknown::Release drop ; inline\r
 \r
 : with-com-interface ( interface quot -- )\r
-    over [ slip ] [ com-release ] [ ] cleanup ; inline\r
+    over [ com-release ] curry [ ] cleanup ; inline\r
 \r
 DESTRUCTOR: com-release\r
index e78c987cd4ac6ee8de1136dc37bb2e2b884af740..9d52378da912855bfbb39619b611fe53d83d7deb 100755 (executable)
@@ -93,7 +93,7 @@ unless
 
 : compile-alien-callback ( word return parameters abi quot -- word )
     '[ _ _ _ _ alien-callback ]
-    [ [ (( -- alien )) define-declared ] pick slip ]
+    [ [ (( -- alien )) define-declared ] pick [ call ] dip ]
     with-compilation-unit ;
 
 : (callback-word) ( function-name interface-name counter -- word )
index fba2eafaba84f72f40364c4eca307950a9077cfb..9df7165e6cd7da88f48ef0555e9bda6a84c3654a 100755 (executable)
@@ -143,7 +143,7 @@ PRIVATE>
 <PRIVATE
 
 : call-under ( quot object -- quot )
-    swap dup slip ; inline
+    swap [ call ] keep ; inline
 
 : xml-loop ( quot: ( xml-elem -- ) -- )
     parse-text call-under
index 8b301affbd995e1cd02edb06e0f3723b1efca838..1a17e8c1fbf34e99549600db5c7a7feac1573150 100755 (executable)
@@ -62,9 +62,6 @@ $nl
     ": dip   [ ] bi* ;"
     ": 2dip  [ ] [ ] tri* ;"
     ""
-    ": slip  [ call ] [ ] bi* ;"
-    ": 2slip [ call ] [ ] [ ] tri* ;"
-    ""
     ": nip   [ drop ] [ ] bi* ;"
     ": 2nip  [ drop ] [ drop ] [ ] tri* ;"
     ""
@@ -121,7 +118,7 @@ $nl
 { $subsection both? }
 { $subsection either? } ;
 
-ARTICLE: "slip-keep-combinators" "Retain stack combinators"
+ARTICLE: "retainstack-combinators" "Retain stack combinators"
 "Sometimes an additional storage area is needed to hold objects. The " { $emphasis "retain stack" } " is an auxilliary stack for this purpose. Objects can be moved between the data and retain stacks using a set of combinators."
 $nl
 "The dip combinators invoke the quotation at the top of the stack, hiding the values underneath:"
@@ -129,10 +126,6 @@ $nl
 { $subsection 2dip }
 { $subsection 3dip }
 { $subsection 4dip }
-"The slip combinators invoke a quotation further down on the stack. They are most useful for implementing other combinators:"
-{ $subsection slip }
-{ $subsection 2slip }
-{ $subsection 3slip }
 "The keep combinators invoke a quotation which takes a number of values off the stack, and then they restore those values:"
 { $subsection keep }
 { $subsection 2keep }
@@ -259,7 +252,7 @@ ARTICLE: "conditionals" "Conditional combinators"
 
 ARTICLE: "dataflow-combinators" "Data flow combinators"
 "Data flow combinators pass values between quotations:"
-{ $subsection "slip-keep-combinators" }
+{ $subsection "retainstack-combinators" }
 { $subsection "cleave-combinators" }
 { $subsection "spread-combinators" }
 { $subsection "apply-combinators" }
index 97b143e989e7b6fdcf4bbdbd8d2445f6c872ed45..ac74e6b11e68163667991b8a48fa862e47355b2d 100644 (file)
@@ -239,13 +239,13 @@ HELP: each-block
 { $description "Calls the quotation with successive blocks of data, until the current " { $link input-stream } " is exhausted." } ;
 
 HELP: stream-contents
-{ $values { "stream" "an input stream" } { "seq" "a string, byte array or " { $link f } } }
-{ $description "Reads the entire contents of a stream. If the stream is empty, outputs "  { $link f } "." }
+{ $values { "stream" "an input stream" } { "seq" { $or string byte-array } } }
+{ $description "Reads all elements in the given stream until the stream is exhausted. The type of the sequence depends on the stream's element type." }
 $io-error ;
 
 HELP: contents
-{ $values { "seq" "a string, byte array or " { $link f } } }
-{ $description "Reads the entire contents of a the stream stored in " { $link input-stream } ". If the stream is empty, outputs " { $link f } "." }
+{ $values { "seq" { $or string byte-array } } }
+{ $description "Reads all elements in the " { $link input-stream } " until the stream is exhausted. The type of the sequence depends on the stream's element type." }
 $io-error ;
 
 ARTICLE: "stream-protocol" "Stream protocol"
index b43098bcd4feaa83582f103d7acaec097aacaac4..669f104a5f6f8a42aee93e1bc51b51564b63e2ef 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2003, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: hashtables generic kernel math namespaces make sequences
-continuations destructors assocs ;
+continuations destructors assocs combinators ;
 IN: io
 
 SYMBOLS: +byte+ +character+ ;
@@ -20,7 +20,9 @@ GENERIC: stream-flush ( stream -- )
 GENERIC: stream-nl ( stream -- )
 
 ERROR: bad-seek-type type ;
+
 SINGLETONS: seek-absolute seek-relative seek-end ;
+
 GENERIC: stream-seek ( n seek-type stream -- )
 
 : stream-print ( str stream -- ) [ stream-write ] keep stream-nl ;
@@ -68,29 +70,39 @@ SYMBOL: error-stream
 
 : bl ( -- ) " " write ;
 
-: stream-lines ( stream -- seq )
-    [ [ readln dup ] [ ] produce nip ] with-input-stream ;
-
-: lines ( -- seq )
-    input-stream get stream-lines ;
-
 <PRIVATE
 
 : each-morsel ( handler: ( data -- ) reader: ( -- data ) -- )
     [ dup ] compose swap while drop ; inline
 
+: stream-element-exemplar ( type -- exemplar )
+    {
+        { +byte+ [ B{ } ] }
+        { +character+ [ "" ] }
+    } case ;
+
+: element-exemplar ( -- exemplar )
+    input-stream get
+    stream-element-type
+    stream-element-exemplar ;
+
 PRIVATE>
 
 : each-line ( quot -- )
     [ readln ] each-morsel ; inline
 
-: stream-contents ( stream -- seq )
-    [
-        [ 65536 read-partial dup ] [ ] produce nip concat f like
-    ] with-input-stream ;
+: lines ( -- seq )
+    [ ] accumulator [ each-line ] dip { } like ;
+
+: stream-lines ( stream -- seq )
+    [ lines ] with-input-stream ;
 
 : contents ( -- seq )
-    input-stream get stream-contents ;
+    [ 65536 read-partial dup ] [ ] produce nip
+    element-exemplar concat-as ;
+
+: stream-contents ( stream -- seq )
+    [ contents ] with-input-stream ;
 
 : each-block ( quot: ( block -- ) -- )
     [ 8192 read-partial ] each-morsel ; inline
index 0cd35dfa213b11583f61ad91958703ffbe53004a..43a8373232d9c9c397d32db00a0e3f466c8ff220 100644 (file)
@@ -1,6 +1,7 @@
 USING: tools.test io.streams.byte-array io.encodings.binary
 io.encodings.utf8 io kernel arrays strings namespaces ;
 
+[ B{ } ] [ B{ } binary [ contents ] with-byte-reader ] unit-test
 [ B{ 1 2 3 } ] [ binary [ B{ 1 2 3 } write ] with-byte-writer ] unit-test
 [ B{ 1 2 3 } ] [ { 1 2 3 } binary [ 3 read ] with-byte-reader ] unit-test
 
index e67e2bc0ddb5de076284329b03ffd1e09549d758..22e0e76451f87222df5e0d88e836fee8b3b0ff46 100644 (file)
@@ -212,18 +212,6 @@ HELP: call-clear ( quot -- )
 { $description "Calls a quotation with an empty call stack. If the quotation returns, Factor will exit.." }
 { $notes "Used to implement " { $link "threads" } "." } ;
 
-HELP: slip
-{ $values { "quot" quotation } { "x" object } }
-{ $description "Calls a quotation while hiding the top of the stack." } ;
-
-HELP: 2slip
-{ $values { "quot" quotation } { "x" object } { "y" object } }
-{ $description "Calls a quotation while hiding the top two stack elements." } ;
-
-HELP: 3slip
-{ $values { "quot" quotation } { "x" object } { "y" object } { "z" object } }
-{ $description "Calls a quotation while hiding the top three stack elements." } ;
-
 HELP: keep
 { $values { "quot" { $quotation "( x -- ... )" } } { "x" object } }
 { $description "Call a quotation with a value on the stack, restoring the value when the quotation returns." }
index 5a88db4f9e0595e26fce7c28bf40f0799bfa6539..c8e0fcd2a98c7e2355ca12a4ec4645ec092963a0 100644 (file)
@@ -61,20 +61,16 @@ IN: kernel.tests
 [ 2 ] [ f 2 xor ] unit-test
 [ f ] [ f f xor ] unit-test
 
-[ slip ] must-fail
+[ dip ] must-fail
 [ ] [ :c ] unit-test
 
-[ 1 slip ] must-fail
+[ 1 [ call ] dip ] must-fail
 [ ] [ :c ] unit-test
 
-[ 1 2 slip ] must-fail
+[ 1 2 [ call ] dip ] must-fail
 [ ] [ :c ] unit-test
 
-[ 1 2 3 slip ] must-fail
-[ ] [ :c ] unit-test
-
-
-[ 5 ] [ [ 2 2 + ] 1 slip + ] unit-test
+[ 5 ] [ 1 [ 2 2 + ] dip + ] unit-test
 
 [ [ ] keep ] must-fail
 
index 624508022595f40d9944617fdc50b12ea3e1b4db..d6350e0420241ffbd5d2001f3c75f9d1805db265 100644 (file)
@@ -58,37 +58,19 @@ DEFER: if
 : ?if ( default cond true false -- )
     pick [ drop [ drop ] 2dip call ] [ 2nip call ] if ; inline
 
-! Slippers and dippers.
+! Dippers.
 ! Not declared inline because the compiler special-cases them
 
-: slip ( quot x -- x )
-    #! 'slip' and 'dip' can be defined in terms of each other
-    #! because the JIT special-cases a 'dip' preceeded by
-    #! a literal quotation.
-    [ call ] dip ;
+: dip ( x quot -- x ) swap [ call ] dip ;
 
-: 2slip ( quot x y -- x y )
-    #! '2slip' and '2dip' can be defined in terms of each other
-    #! because the JIT special-cases a '2dip' preceeded by
-    #! a literal quotation.
-    [ call ] 2dip ;
+: 2dip ( x y quot -- x y ) -rot [ call ] 2dip ;
 
-: 3slip ( quot x y z -- x y z )
-    #! '3slip' and '3dip' can be defined in terms of each other
-    #! because the JIT special-cases a '3dip' preceeded by
-    #! a literal quotation.
-    [ call ] 3dip ;
-
-: dip ( x quot -- x ) swap slip ;
-
-: 2dip ( x y quot -- x y ) -rot 2slip ;
-
-: 3dip ( x y z quot -- x y z ) -roll 3slip ;
+: 3dip ( x y z quot -- x y z ) -roll [ call ] 3dip ;
 
 : 4dip ( w x y z quot -- w x y z ) swap [ 3dip ] dip ; inline
 
 ! Keepers
-: keep ( x quot -- x ) over slip ; inline
+: keep ( x quot -- x ) over [ call ] dip ; inline
 
 : 2keep ( x y quot -- x y ) [ 2dup ] dip 2dip ; inline
 
index 3245ac1e206bda428464352efd80422fe5489741..af3c110d61db516a333fa34cc20daf2a75d4caf6 100644 (file)
@@ -19,7 +19,7 @@ M: quotation call (call) ;
 
 M: curry call uncurry call ;
 
-M: compose call uncompose slip call ;
+M: compose call uncompose [ call ] dip call ;
 
 M: wrapper equal?
     over wrapper? [ [ wrapped>> ] bi@ = ] [ 2drop f ] if ;
index cfd96789b4be5505c9d0196d5e0ee459737c48c4..b6cfface122944b6c53562f877ad3dbe06ccdc25 100755 (executable)
@@ -533,12 +533,18 @@ HELP: concat
 { $description "Concatenates a sequence of sequences together into one sequence. If " { $snippet "seq" } " is empty, outputs " { $snippet "{ }" } ", otherwise the resulting sequence is of the same class as the first element of " { $snippet "seq" } "." }
 { $errors "Throws an error if one of the sequences in " { $snippet "seq" } " contains elements not permitted in sequences of the same class as the first element of " { $snippet "seq" } "." } ;
 
+HELP: concat-as
+{ $values { "seq" sequence } { "exemplar" sequence } { "newseq" sequence } }
+{ $description "Concatenates a sequence of sequences together into one sequence with the same type as " { $snippet "exemplar" } "." }
+{ $errors "Throws an error if one of the sequences in " { $snippet "seq" } " contains elements not permitted in sequences of the same class as " { $snippet "exemplar" } "." } ;
+
 HELP: join
 { $values { "seq" sequence } { "glue" sequence } { "newseq" sequence } }
 { $description "Concatenates a sequence of sequences together into one sequence, placing a copy of " { $snippet "glue" } " between each pair of sequences. The resulting sequence is of the same class as " { $snippet "glue" } "." }
+{ $notes "If the " { $snippet "glue" } " sequence is empty, this word calls " { $link concat-as } "." }
 { $errors "Throws an error if one of the sequences in " { $snippet "seq" } " contains elements not permitted in sequences of the same class as " { $snippet "glue" } "." } ;
 
-{ join concat } related-words
+{ join concat concat-as } related-words
 
 HELP: peek
 { $values { "seq" sequence } { "elt" object } }
index d60602fc719893a62f07c8b8492e32e0d0759d8a..dd48501fa03ec6060c848dfe5ca6f35708768f62 100755 (executable)
@@ -704,13 +704,14 @@ PRIVATE>
 : sum-lengths ( seq -- n )
     0 [ length + ] reduce ;
 
+: concat-as ( seq exemplar -- newseq )
+    swap [ { } ] [
+        [ sum-lengths over new-resizable ] keep
+        [ over push-all ] each
+    ] if-empty swap like ;
+
 : concat ( seq -- newseq )
-    [ { } ] [
-        [ sum-lengths ] keep
-        [ first new-resizable ] keep
-        [ [ over push-all ] each ] keep
-        first like
-    ] if-empty ;
+    [ { } ] [ dup first concat-as ] if-empty ;
 
 <PRIVATE
 
@@ -720,12 +721,14 @@ PRIVATE>
 PRIVATE>
 
 : join ( seq glue -- newseq )
-    [
-        2dup joined-length over new-resizable [
-            [ [ push-all ] 2curry ] [ [ nip push-all ] 2curry ] 2bi
-            interleave
-        ] keep
-    ] keep like ;
+    dup empty? [ concat-as ] [
+        [
+            2dup joined-length over new-resizable [
+                [ [ push-all ] 2curry ] [ [ nip push-all ] 2curry ] 2bi
+                interleave
+            ] keep
+        ] keep like
+    ] if ;
 
 : padding ( seq n elt quot -- newseq )
     [
index 1da170d19787ef88e774989fb21cefcadec27ffa..f4ef4687b5b98a2c1b60b9094be7540eb57116ce 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2008 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: math.primes.miller-rabin kernel math math.functions
-namespaces sequences accessors ;
+USING: math.primes kernel math math.functions namespaces
+sequences accessors ;
 IN: crypto.rsa
 
 ! The private key is the only secret.
@@ -21,7 +21,7 @@ C: <rsa> rsa
 CONSTANT: public-key 65537
 
 : rsa-primes ( numbits -- p q )
-    2/ 2 unique-primes first2 ;
+    2/ 2 swap unique-primes first2 ;
 
 : modulus-phi ( numbits -- n phi ) 
     #! Loop until phi is not divisible by the public key.
diff --git a/extra/crypto/timing/authors.txt b/extra/crypto/timing/authors.txt
deleted file mode 100755 (executable)
index 7c1b2f2..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Doug Coleman
diff --git a/extra/crypto/timing/timing-tests.factor b/extra/crypto/timing/timing-tests.factor
deleted file mode 100644 (file)
index 9afb913..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-USING: crypto.timing kernel tools.test system math ;
-IN: crypto.timing.tests
-
-[ t ] [ millis [ ] 1000 with-timing millis swap - 1000 >= ] unit-test
diff --git a/extra/crypto/timing/timing.factor b/extra/crypto/timing/timing.factor
deleted file mode 100644 (file)
index b2a59a1..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-! Copyright (C) 2008 Doug Coleman.
-! See http://factorcode.org/license.txt for BSD license.
-USING: kernel math threads system calendar ;
-IN: crypto.timing
-
-: with-timing ( quot n -- )
-    #! force the quotation to execute in, at minimum, n milliseconds
-    millis 2slip millis - + milliseconds sleep ; inline
diff --git a/extra/hashcash/authors.txt b/extra/hashcash/authors.txt
new file mode 100755 (executable)
index 0000000..f6e3b59
--- /dev/null
@@ -0,0 +1 @@
+Diego Martinelli
diff --git a/extra/hashcash/hashcash-docs.factor b/extra/hashcash/hashcash-docs.factor
new file mode 100644 (file)
index 0000000..2cfe0bb
--- /dev/null
@@ -0,0 +1,60 @@
+USING: help.markup help.syntax kernel math ;
+IN: hashcash
+
+ARTICLE: "hashcash" "Hashcash"
+"Hashcash is a denial-of-service counter measure tool."
+$nl
+"A hashcash stamp constitutes a proof-of-work which takes a parameterizable amount of work to compute for the sender. The recipient can verify received hashcash stamps efficiently."
+$nl
+"More info on hashcash:"
+$nl
+{ $url "http://www.hashcash.org/" } $nl
+{ $url "http://en.wikipedia.org/wiki/Hashcash" } $nl
+{ $url "http://www.ibm.com/developerworks/linux/library/l-hashcash.html?ca=dgr-lnxw01HashCash" } $nl
+"This library provide basic utilities for hashcash creation and validation."
+$nl
+"Creating stamps:"
+{ $subsection mint }
+{ $subsection mint* }
+"Validation:"
+{ $subsection check-stamp }
+"Hashcash tuple and constructor:"
+{ $subsection hashcash }
+{ $subsection <hashcash> }
+"Utilities:"
+{ $subsection salt } ;
+
+{ mint mint* <hashcash> check-stamp salt } related-words
+
+HELP: mint
+{ $values { "resource" "a string" } { "stamp" "generated stamp" } }
+{ $description "This word generate a valid stamp with default parameters and the specified resource." } ;
+
+HELP: mint*
+{ $values { "tuple" "a tuple" } { "stamp" "generated stamp" } }
+{ $description "As " { $snippet "mint" } " but it takes an hashcash tuple as a parameter." } ;
+
+HELP: check-stamp
+{ $values { "stamp" "a string" } { "?" boolean } }
+{ $description "Check for stamp's validity. Only supports hashcash version 1." } ;
+
+HELP: salt
+{ $values { "length" integer } { "salted" "a string" } }
+{ $description "It generates a random string of " { $snippet "length" } " characters." } ;
+
+HELP: <hashcash>
+{ $values { "tuple" object } }
+{ $description "It fill an hashcash tuple with the default values: 1 as hashcash version, 20 as bits, today's date as date and a random 8 character long salt" } ;
+
+HELP: hashcash
+{ $class-description "An hashcash object. An hashcash have the following slots:"
+    { $table
+        { { $slot "version" } "The version number. Only version 1 is supported." }
+        { { $slot "bits" } "The claimed bit value." }
+        { { $slot "date" } "The date a stamp was minted." }
+        { { $slot "resource" } "The resource for which a stamp is minted." }
+        { { $slot "ext" } "Extensions that a specialized application may want." }
+        { { $slot "salt" } "A random salt." }
+        { { $slot "suffix" } "The computed suffix. This is supposed to be manipulated by the library." }
+    }
+} ;
diff --git a/extra/hashcash/hashcash-tests.factor b/extra/hashcash/hashcash-tests.factor
new file mode 100644 (file)
index 0000000..efef40a
--- /dev/null
@@ -0,0 +1,15 @@
+USING: accessors sequences tools.test hashcash ;
+
+[ t ] [ "foo@bar.com" mint check-stamp ] unit-test
+
+[ t ] [ 
+    <hashcash> 
+        "foo@bar.com" >>resource 
+        16 >>bits 
+    mint* check-stamp ] unit-test
+
+[ t ] [ 
+    "1:20:040927:mertz@gnosis.cx::odVZhQMP:7ca28" check-stamp
+] unit-test
+
+[ 8 ] [ 8 salt length ] unit-test
diff --git a/extra/hashcash/hashcash.factor b/extra/hashcash/hashcash.factor
new file mode 100755 (executable)
index 0000000..1eb690b
--- /dev/null
@@ -0,0 +1,90 @@
+! Copyright (C) 2009 Diego Martinelli.
+! See http://factorcode.org/license.txt for BSD license.
+USING: accessors byte-arrays calendar calendar.format 
+checksums checksums.openssl classes.tuple 
+fry kernel make math math.functions math.parser math.ranges 
+present random sequences splitting strings syntax ;
+IN: hashcash
+
+! Hashcash implementation
+! Reference materials listed below:
+! 
+! http://hashcash.org
+! http://en.wikipedia.org/wiki/Hashcash
+! http://www.ibm.com/developerworks/linux/library/l-hashcash.html?ca=dgr-lnxw01HashCash
+! 
+! And the reference implementation (in python):
+! http://www.gnosis.cx/download/gnosis/util/hashcash.py
+
+<PRIVATE
+
+! Return a string with today's date in the form YYMMDD
+: get-date ( -- str )
+    now [ year>> 100 mod pad-00 ] 
+        [ month>> pad-00 ] 
+        [ day>> pad-00 ] tri 3append ;
+
+! Random salt is formed by ascii characters
+! between 33 and 126
+: available-chars ( -- seq )
+    33 126 [a,b] [ CHAR: : = not ] filter ;
+
+PRIVATE>
+
+! Generate a 'length' long random salt
+: salt ( length -- salted )
+    available-chars '[ _ random ] "" replicate-as ;
+
+TUPLE: hashcash version bits date resource ext salt suffix ;
+
+: <hashcash> ( -- tuple )
+    hashcash new
+        1 >>version
+        20 >>bits
+        get-date >>date
+        8 salt >>salt ;
+
+M: hashcash string>> 
+    tuple-slots [ present ] map ":" join ;
+
+<PRIVATE
+
+: sha1-checksum ( str -- bytes )
+    openssl-sha1 checksum-bytes ; inline
+
+: set-suffix ( tuple guess -- tuple )
+    >hex >>suffix ;
+
+: get-bits ( bytes -- str )
+    [ >bin 8 CHAR: 0 pad-head ] { } map-as concat ;
+
+: checksummed-bits ( tuple -- relevant-bits )
+    dup string>> sha1-checksum
+    swap bits>> 8 / ceiling head get-bits ;
+
+: all-char-zero? ( seq -- ? )
+    [ CHAR: 0 = ] all? ; inline
+
+: valid-guess? ( checksum tuple -- ? )
+    bits>> head all-char-zero? ;
+
+: (mint) ( tuple counter -- tuple ) 
+    2dup set-suffix checksummed-bits pick 
+    valid-guess? [ drop ] [ 1+ (mint) ] if ;
+
+PRIVATE>
+
+: mint* ( tuple -- stamp )
+    0 (mint) string>> ;
+
+: mint ( resource -- stamp )
+    <hashcash>
+        swap >>resource
+    mint* ;
+
+! One might wanna add check based on the date,
+! passing a 'good-until' duration param
+: check-stamp ( stamp -- ? )
+    dup ":" split [ sha1-checksum get-bits ] dip
+    second string>number head all-char-zero? ;
+
diff --git a/extra/hashcash/summary.txt b/extra/hashcash/summary.txt
new file mode 100644 (file)
index 0000000..e5ec1d4
--- /dev/null
@@ -0,0 +1 @@
+Hashcash implementation
index 79df00ff5e723c91acb6ee825c634143200fd60f..6acace858276fa25cec8f85a05b209a048ad46a7 100644 (file)
@@ -233,8 +233,7 @@ PRIVATE>
 : genre ( id3 -- string/f )
     "TCON" find-id3-frame parse-genre ;
 
-: find-mp3s ( path -- seq )
-    [ >lower ".mp3" tail? ] find-all-files ;
+: find-mp3s ( path -- seq ) ".mp3" find-by-extension ;
 
 ERROR: id3-parse-error path error ;
 
index d020c68fc4627a0aeddebb09a71b347ecc2c9a56..b7545a3c9e63e2c94fdcf937d3901be1476c79e5 100755 (executable)
@@ -5,12 +5,12 @@ 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
 calendar.format arrays mason.config locals system debugger fry
-continuations ;
+continuations strings ;
 IN: mason.common
 
 SYMBOL: current-git-id
 
-ERROR: output-process-error output process ;
+ERROR: output-process-error { output string } { process process } ;
 
 M: output-process-error error.
     [ "Process:" print process>> . nl ]
index 96e31c4a450cecfaaef1ecad18d16d43b7a19ab2..c75014e1b0ea233a612669e3c697717f6e26e30b 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: arrays accessors io io.sockets io.encodings.utf8 io.files
 io.launcher kernel make mason.config mason.common mason.email
-mason.twitter namespaces sequences prettyprint ;
+mason.twitter namespaces sequences prettyprint fry ;
 IN: mason.notify
 
 : status-notify ( input-file args -- )
@@ -14,10 +14,12 @@ IN: mason.notify
             target-cpu get ,
             target-os get ,
         ] { } make prepend
-        <process>
-            swap >>command
-            swap [ +closed+ ] unless* >>stdin
-        try-output-process
+        [ 5 ] 2dip '[
+            <process>
+                _ >>command
+                _ [ +closed+ ] unless* >>stdin
+            try-output-process
+        ] retry
     ] [ 2drop ] if ;
 
 : notify-begin-build ( git-id -- )
index 4a52a2f79c58e612f3b5ec4b4febf3ca437b3433..8229abca69caaeba103398fa7ce831cbd7ba4f51 100755 (executable)
@@ -1,5 +1,5 @@
-USING: kernel math sequences namespaces
-math.primes.miller-rabin math.functions accessors random ;
+USING: kernel math sequences namespaces math.primes
+math.functions accessors random ;
 IN: random.blum-blum-shub
 
 ! Blum Blum Shub, n = pq, x_i+1 = x_i ^ 2 mod n
diff --git a/extra/redis/authors.txt b/extra/redis/authors.txt
new file mode 100644 (file)
index 0000000..f4a8cb1
--- /dev/null
@@ -0,0 +1 @@
+Bruno Deferrari
diff --git a/extra/redis/command-writer/authors.txt b/extra/redis/command-writer/authors.txt
new file mode 100644 (file)
index 0000000..f4a8cb1
--- /dev/null
@@ -0,0 +1 @@
+Bruno Deferrari
diff --git a/extra/redis/command-writer/command-writer-tests.factor b/extra/redis/command-writer/command-writer-tests.factor
new file mode 100644 (file)
index 0000000..901c4e4
--- /dev/null
@@ -0,0 +1,138 @@
+! Copyright (C) 2009 Bruno Deferrari
+! See http://factorcode.org/license.txt for BSD license.
+USING: tools.test redis.command-writer io.streams.string ;
+IN: redis.command-writer.tests
+
+#! Connection
+[ "QUIT\r\n" ] [ [ quit ] with-string-writer ] unit-test
+
+[ "PING\r\n" ] [ [ ping ] with-string-writer ] unit-test
+
+[ "AUTH password\r\n" ] [ [ "password" auth ] with-string-writer ] unit-test
+
+#! String values
+[ "SET key 3\r\nfoo\r\n" ] [ [ "foo" "key" set ] with-string-writer ] unit-test
+
+[ "GET key\r\n" ] [ [ "key" get ] with-string-writer ] unit-test
+
+[ "GETSET key 3\r\nfoo\r\n" ] [
+    [ "foo" "key" getset ] with-string-writer
+] unit-test
+
+[ "MGET key1 key2 key3\r\n" ] [
+    [ { "key1" "key2" "key3" } mget ] with-string-writer
+] unit-test
+
+[ "SETNX key 3\r\nfoo\r\n" ] [
+    [ "foo" "key" setnx ] with-string-writer
+] unit-test
+
+[ "INCR key\r\n" ] [ [ "key" incr ] with-string-writer ] unit-test
+
+[ "INCRBY key 7\r\n" ] [ [ 7 "key" incrby ] with-string-writer ] unit-test
+
+[ "DECR key\r\n" ] [ [ "key" decr ] with-string-writer ] unit-test
+
+[ "DECRBY key 7\r\n" ] [ [ 7 "key" decrby ] with-string-writer ] unit-test
+
+[ "EXISTS key\r\n" ] [ [ "key" exists ] with-string-writer ] unit-test
+
+[ "DEL key\r\n" ] [ [ "key" del ] with-string-writer ] unit-test
+
+[ "TYPE key\r\n" ] [ [ "key" type ] with-string-writer ] unit-test
+
+#! Key space
+[ "KEYS pat*\r\n" ] [ [ "pat*" keys ] with-string-writer ] unit-test
+
+[ "RANDOMKEY\r\n" ] [ [ randomkey ] with-string-writer ] unit-test
+
+[ "RENAME key newkey\r\n" ] [
+    [ "newkey" "key" rename ] with-string-writer
+] unit-test
+
+[ "RENAMENX key newkey\r\n" ] [
+    [ "newkey" "key" renamenx ] with-string-writer
+] unit-test
+
+[ "DBSIZE\r\n" ] [ [ dbsize ] with-string-writer ] unit-test
+
+[ "EXPIRE key 7\r\n" ] [ [ 7 "key" expire ] with-string-writer ] unit-test
+
+#! Lists
+[ "RPUSH key 3\r\nfoo\r\n" ] [ [ "foo" "key" rpush ] with-string-writer ] unit-test
+
+[ "LPUSH key 3\r\nfoo\r\n" ] [ [ "foo" "key" lpush ] with-string-writer ] unit-test
+
+[ "LLEN key\r\n" ] [ [ "key" llen ] with-string-writer ] unit-test
+
+[ "LRANGE key 5 9\r\n" ] [ [ 5 9 "key" lrange ] with-string-writer ] unit-test
+
+[ "LTRIM key 5 9\r\n" ] [ [ 5 9 "key" ltrim ] with-string-writer ] unit-test
+
+[ "LINDEX key 7\r\n" ] [ [ 7 "key" lindex ] with-string-writer ] unit-test
+
+[ "LSET key 0 3\r\nfoo\r\n" ] [ [ "foo" 0 "key" lset ] with-string-writer ] unit-test
+
+[ "LREM key 1 3\r\nfoo\r\n" ] [ [ "foo" 1 "key" lrem ] with-string-writer ] unit-test
+
+[ "LPOP key\r\n" ] [ [ "key" lpop ] with-string-writer ] unit-test
+
+[ "RPOP key\r\n" ] [ [ "key" rpop ] with-string-writer ] unit-test
+
+#! Sets
+[ "SADD key 3\r\nfoo\r\n" ] [ [ "foo" "key" sadd ] with-string-writer ] unit-test
+
+[ "SREM key 3\r\nfoo\r\n" ] [ [ "foo" "key" srem ] with-string-writer ] unit-test
+
+[ "SMOVE srckey dstkey 3\r\nfoo\r\n" ] [
+    [ "foo" "dstkey" "srckey" smove ] with-string-writer
+] unit-test
+
+[ "SCARD key\r\n" ] [ [ "key" scard ] with-string-writer ] unit-test
+
+[ "SISMEMBER key 3\r\nfoo\r\n" ] [
+    [ "foo" "key" sismember ] with-string-writer
+] unit-test
+
+[ "SINTER key1 key2 key3\r\n" ] [
+    [ { "key1" "key2" "key3" } sinter ] with-string-writer
+] unit-test
+
+[ "SINTERSTORE dstkey key1 key2 key3\r\n" ] [
+    [ { "key1" "key2" "key3" } "dstkey" sinterstore ] with-string-writer
+] unit-test
+
+[ "SUNION key1 key2 key3\r\n" ] [
+    [ { "key1" "key2" "key3" } sunion ] with-string-writer
+] unit-test
+
+[ "SUNIONSTORE dstkey key1 key2 key3\r\n" ] [
+    [ { "key1" "key2" "key3" } "dstkey" sunionstore ] with-string-writer
+] unit-test
+
+[ "SMEMBERS key\r\n" ] [ [ "key" smembers ] with-string-writer ] unit-test
+
+#! Multiple db
+[ "SELECT 2\r\n" ] [ [ 2 select ] with-string-writer ] unit-test
+
+[ "MOVE key 2\r\n" ] [ [ 2 "key" move ] with-string-writer ] unit-test
+
+[ "FLUSHDB\r\n" ] [ [ flushdb ] with-string-writer ] unit-test
+
+[ "FLUSHALL\r\n" ] [ [ flushall ] with-string-writer ] unit-test
+
+#! Sorting
+
+#! Persistence control
+[ "SAVE\r\n" ] [ [ save ] with-string-writer ] unit-test
+
+[ "BGSAVE\r\n" ] [ [ bgsave ] with-string-writer ] unit-test
+
+[ "LASTSAVE\r\n" ] [ [ lastsave ] with-string-writer ] unit-test
+
+[ "SHUTDOWN\r\n" ] [ [ shutdown ] with-string-writer ] unit-test
+
+#! Remote server control
+[ "INFO\r\n" ] [ [ info ] with-string-writer ] unit-test
+
+[ "MONITOR\r\n" ] [ [ monitor ] with-string-writer ] unit-test
diff --git a/extra/redis/command-writer/command-writer.factor b/extra/redis/command-writer/command-writer.factor
new file mode 100644 (file)
index 0000000..e5e635f
--- /dev/null
@@ -0,0 +1,104 @@
+! Copyright (C) 2009 Bruno Deferrari
+! See http://factorcode.org/license.txt for BSD license.
+USING: io io.crlf kernel math.parser sequences strings interpolate locals ;
+IN: redis.command-writer
+
+<PRIVATE
+
+GENERIC: write-value-with-length ( value -- )
+
+M: string write-value-with-length
+    [ length number>string write crlf ]
+    [ write ] bi ;
+
+: space ( -- ) CHAR: space write1 ;
+
+: write-key/value ( value key -- )
+    write space
+    write-value-with-length ;
+
+: write-key/integer ( integer key -- )
+    write space
+    number>string write ;
+
+PRIVATE>
+
+#! Connection
+: quit ( -- ) "QUIT" write crlf ;
+: ping ( -- ) "PING" write crlf ;
+: auth ( password -- ) "AUTH " write write crlf ;
+
+#! String values
+: set ( value key -- ) "SET " write write-key/value crlf ;
+: get ( key -- ) "GET " write write crlf ;
+: getset ( value key -- ) "GETSET " write write-key/value crlf ;
+: mget ( keys -- ) "MGET " write " " join write crlf ;
+: setnx ( value key -- ) "SETNX " write write-key/value crlf ;
+: incr ( key -- ) "INCR " write write crlf ;
+: incrby ( integer key -- ) "INCRBY " write write-key/integer crlf ;
+: decr ( key -- ) "DECR " write write crlf ;
+: decrby ( integer key -- ) "DECRBY " write write-key/integer crlf ;
+: exists ( key -- ) "EXISTS " write write crlf ;
+: del ( key -- ) "DEL " write write crlf ;
+: type ( key -- ) "TYPE " write write crlf ;
+
+#! Key space
+: keys ( pattern -- ) "KEYS " write write crlf ;
+: randomkey ( -- ) "RANDOMKEY" write crlf ;
+: rename ( newkey key -- ) "RENAME " write write space write crlf ;
+: renamenx ( newkey key -- ) "RENAMENX " write write space write crlf ;
+: dbsize ( -- ) "DBSIZE" write crlf ;
+: expire ( integer key -- ) "EXPIRE " write write-key/integer crlf ;
+
+#! Lists
+: rpush ( value key -- ) "RPUSH " write write-key/value crlf ;
+: lpush ( value key -- ) "LPUSH " write write-key/value crlf ;
+: llen ( key -- ) "LLEN " write write crlf ;
+: lrange ( start end key -- )
+    "LRANGE " write write [ space number>string write ] bi@ crlf ;
+: ltrim ( start end key -- )
+    "LTRIM " write write [ space number>string write ] bi@ crlf ;
+: lindex ( integer key -- ) "LINDEX " write write-key/integer crlf ;
+: lset ( value index key -- )
+    "LSET " write write-key/integer space write-value-with-length crlf ;
+: lrem ( value amount key -- )
+    "LREM " write write-key/integer space write-value-with-length crlf ;
+: lpop ( key -- ) "LPOP " write write crlf ;
+: rpop ( key -- ) "RPOP " write write crlf ;
+
+#! Sets
+: sadd ( member key -- )
+    "SADD " write write space write-value-with-length crlf ;
+: srem  ( member key -- )
+    "SREM " write write space write-value-with-length crlf ;
+: smove ( member newkey key -- )
+    "SMOVE " write write space write space write-value-with-length crlf ;
+: scard ( key -- ) "SCARD " write write crlf ;
+: sismember ( member key -- )
+    "SISMEMBER " write write space write-value-with-length crlf ;
+: sinter ( keys -- ) "SINTER " write " " join write crlf ;
+: sinterstore ( keys destkey -- )
+    "SINTERSTORE " write write space " " join write crlf ;
+: sunion ( keys -- ) "SUNION " write " " join write crlf ;
+: sunionstore ( keys destkey -- )
+    "SUNIONSTORE " write write " " join space write crlf ;
+: smembers ( key -- ) "SMEMBERS " write write crlf ;
+
+#! Multiple db
+: select ( integer -- ) "SELECT " write number>string write crlf ;
+: move ( integer key -- ) "MOVE " write write-key/integer crlf ;
+: flushdb ( -- ) "FLUSHDB" write crlf ;
+: flushall ( -- ) "FLUSHALL" write crlf ;
+
+#! Sorting
+! sort
+
+#! Persistence control
+: save ( -- ) "SAVE" write crlf ;
+: bgsave ( -- ) "BGSAVE" write crlf ;
+: lastsave ( -- ) "LASTSAVE" write crlf ;
+: shutdown ( -- ) "SHUTDOWN" write crlf ;
+
+#! Remote server control
+: info ( -- ) "INFO" write crlf ;
+: monitor ( -- ) "MONITOR" write crlf ;
diff --git a/extra/redis/command-writer/summary.txt b/extra/redis/command-writer/summary.txt
new file mode 100644 (file)
index 0000000..917b915
--- /dev/null
@@ -0,0 +1 @@
+Definitions of messages sent to Redis
diff --git a/extra/redis/redis.factor b/extra/redis/redis.factor
new file mode 100644 (file)
index 0000000..1f6d732
--- /dev/null
@@ -0,0 +1,74 @@
+! Copyright (C) 2009 Bruno Deferrari
+! See http://factorcode.org/license.txt for BSD license.
+USING: io redis.response-parser redis.command-writer ;
+IN: redis
+
+#! Connection
+: redis-quit ( -- ) quit flush ;
+: redis-ping ( -- response ) ping flush read-response ;
+: redis-auth ( password -- response ) auth flush read-response ;
+
+#! String values
+: redis-set ( value key -- response ) set flush read-response ;
+: redis-get ( key -- response ) get flush read-response ;
+: redis-getset ( value key -- response ) getset flush read-response ;
+: redis-mget ( keys -- response ) mget flush read-response ;
+: redis-setnx ( value key -- response ) setnx flush read-response ;
+: redis-incr ( key -- response ) incr flush read-response ;
+: redis-incrby ( integer key -- response ) incrby flush read-response ;
+: redis-decr ( key -- response ) decr flush read-response ;
+: redis-decrby ( integer key -- response ) decrby flush read-response ;
+: redis-exists ( key -- response ) exists flush read-response ;
+: redis-del ( key -- response ) del flush read-response ;
+: redis-type ( key -- response ) type flush read-response ;
+
+#! Key space
+: redis-keys ( pattern -- response ) keys flush read-response ;
+: redis-randomkey ( -- response ) randomkey flush read-response ;
+: redis-rename ( newkey key -- response ) rename flush read-response ;
+: redis-renamenx ( newkey key -- response ) renamenx flush read-response ;
+: redis-dbsize ( -- response ) dbsize flush read-response ;
+: redis-expire ( integer key -- response ) expire flush read-response ;
+
+#! Lists
+: redis-rpush ( value key -- response ) rpush flush read-response ;
+: redis-lpush ( value key -- response ) lpush flush read-response ;
+: redis-llen ( key -- response ) llen flush read-response ;
+: redis-lrange ( start end key -- response ) lrange flush read-response ;
+: redis-ltrim ( start end key -- response ) ltrim flush read-response ;
+: redis-lindex ( integer key -- response ) lindex flush read-response ;
+: redis-lset ( value index key -- response ) lset flush read-response ;
+: redis-lrem ( value amount key -- response ) lrem flush read-response ;
+: redis-lpop ( key -- response ) lpop flush read-response ;
+: redis-rpop ( key -- response ) rpop flush read-response ;
+
+#! Sets
+: redis-sadd ( member key -- response ) sadd flush read-response ;
+: redis-srem  ( member key -- response ) srem flush read-response ;
+: redis-smove ( member newkey key -- response ) smove flush read-response ;
+: redis-scard ( key -- response ) scard flush read-response ;
+: redis-sismember ( member key -- response ) sismember flush read-response ;
+: redis-sinter ( keys -- response ) sinter flush read-response ;
+: redis-sinterstore ( keys destkey -- response ) sinterstore flush read-response ;
+: redis-sunion ( keys -- response ) sunion flush read-response ;
+: redis-sunionstore ( keys destkey -- response ) sunionstore flush read-response ;
+: redis-smembers ( key -- response ) smembers flush read-response ;
+
+#! Multiple db
+: redis-select ( integer -- response ) select flush read-response ;
+: redis-move ( integer key -- response ) move flush read-response ;
+: redis-flushdb ( -- response ) flushdb flush read-response ;
+: redis-flushall ( -- response ) flushall flush read-response ;
+
+#! Sorting
+! sort
+
+#! Persistence control
+: redis-save ( -- response ) save flush read-response ;
+: redis-bgsave ( -- response ) bgsave flush read-response ;
+: redis-lastsave ( -- response ) lastsave flush read-response ;
+: redis-shutdown ( -- response ) shutdown flush read-response ;
+
+#! Remote server control
+: redis-info ( -- response ) info flush read-response ;
+: redis-monitor ( -- response ) monitor flush read-response ;
diff --git a/extra/redis/response-parser/authors.txt b/extra/redis/response-parser/authors.txt
new file mode 100644 (file)
index 0000000..f4a8cb1
--- /dev/null
@@ -0,0 +1 @@
+Bruno Deferrari
diff --git a/extra/redis/response-parser/response-parser-tests.factor b/extra/redis/response-parser/response-parser-tests.factor
new file mode 100644 (file)
index 0000000..bde3611
--- /dev/null
@@ -0,0 +1,20 @@
+! Copyright (C) 2009 Bruno Deferrari
+! See http://factorcode.org/license.txt for BSD license.
+USING: tools.test redis.response-parser io.streams.string ;
+IN: redis.response-parser.tests
+
+[ 1 ] [ ":1\r\n" [ read-response ] with-string-reader ] unit-test
+
+[ "hello" ] [ "$5\r\nhello\r\n" [ read-response ] with-string-reader ] unit-test
+
+[ f ] [ "$-1\r\n" [ read-response ] with-string-reader ] unit-test
+
+[ { "hello" "world!" } ] [
+    "*2\r\n$5\r\nhello\r\n$6\r\nworld!\r\n" [ read-response ] with-string-reader
+] unit-test
+
+[ { "hello" f "world!" } ] [
+    "*3\r\n$5\r\nhello\r\n$-1\r\n$6\r\nworld!\r\n" [
+        read-response
+    ] with-string-reader
+] unit-test
diff --git a/extra/redis/response-parser/response-parser.factor b/extra/redis/response-parser/response-parser.factor
new file mode 100644 (file)
index 0000000..3d92d55
--- /dev/null
@@ -0,0 +1,27 @@
+! Copyright (C) 2009 Bruno Deferrari
+! See http://factorcode.org/license.txt for BSD license.
+USING: combinators io kernel math math.parser sequences ;
+IN: redis.response-parser
+
+<PRIVATE
+
+: read-bulk ( n -- bytes ) dup 0 < [ drop f ] [ read 2 read drop ] if ;
+: (read-multi-bulk) ( -- bytes ) readln rest string>number read-bulk ;
+: read-multi-bulk ( n -- seq/f )
+    dup 0 < [ drop f ] [
+        iota [ drop (read-multi-bulk) ] map
+    ] if ;
+
+: handle-response ( string -- string ) ; ! TODO
+: handle-error ( string -- string ) ; ! TODO
+
+PRIVATE>
+
+: read-response ( -- response )
+    readln unclip {
+        { CHAR: : [ string>number ] }
+        { CHAR: + [ handle-response ] }
+        { CHAR: $ [ string>number read-bulk ] }
+        { CHAR: * [ string>number read-multi-bulk ] }
+        { CHAR: - [ handle-error ] }
+    } case ;
diff --git a/extra/redis/response-parser/summary.txt b/extra/redis/response-parser/summary.txt
new file mode 100644 (file)
index 0000000..b89407c
--- /dev/null
@@ -0,0 +1 @@
+Parser for responses sent by the Redis server
diff --git a/extra/redis/summary.txt b/extra/redis/summary.txt
new file mode 100644 (file)
index 0000000..0cd6e69
--- /dev/null
@@ -0,0 +1 @@
+Words for communicating with the Redis key-value database
index 89e00f88c56670bb4dc05eeaf5b0f279cb9b96e4..f5c2ea9811b0b25eb4d00fba5e83e48bed9e14b0 100755 (executable)
@@ -19,13 +19,11 @@ IN: reports.noise
         { 2keep 1 }\r
         { 2nip 2 }\r
         { 2over 4 }\r
-        { 2slip 2 }\r
         { 2swap 3 }\r
         { 3curry 2 }\r
         { 3drop 1 }\r
         { 3dup 2 }\r
         { 3keep 3 }\r
-        { 3slip 3 }\r
         { 4drop 2 }\r
         { 4dup 3 }\r
         { compose 1/2 }\r
@@ -52,14 +50,12 @@ IN: reports.noise
         { nkeep 5 }\r
         { npick 6 }\r
         { nrot 5 }\r
-        { nslip 5 }\r
         { ntuck 6 }\r
         { nwith 4 }\r
         { over 2 }\r
         { pick 4 }\r
         { roll 4 }\r
         { rot 3 }\r
-        { slip 1 }\r
         { spin 3 }\r
         { swap 1 }\r
         { swapd 3 }\r
index d6591a1a26781ae73d3844d6668278e8e9b98894..22c5de09630ac89759f5c318ae77b86632fda278 100644 (file)
@@ -1,14 +1,15 @@
 USING: tools.deploy.config ;
 H{
+    { deploy-ui? t }
     { deploy-reflection 1 }
-    { deploy-word-defs? f }
-    { deploy-word-props? f }
+    { deploy-unicode? f }
+    { deploy-math? t }
+    { deploy-io 2 }
+    { deploy-c-types? f }
     { deploy-name "Spheres" }
+    { deploy-word-props? f }
+    { deploy-word-defs? f }
+    { "stop-after-last-window?" t }
     { deploy-compiler? t }
-    { deploy-math? t }
-    { deploy-io 1 }
     { deploy-threads? t }
-    { "stop-after-last-window?" t }
-    { deploy-ui? t }
-    { deploy-c-types? f }
 }
index b26797f8d51dabb58f20d401edf39b1d5b327439..b4bbc9fbf8a5f5566f30189420940803bd0220ba 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2009 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors assocs deques dlists kernel spider ;
+USING: accessors assocs deques dlists kernel ;
 IN: spider.unique-deque
 
 TUPLE: todo-url url depth ;
@@ -32,6 +32,6 @@ TUPLE: unique-deque assoc deque ;
 
 : slurp-deque-when ( deque quot1 quot2: ( value -- ) -- )
     pick deque-empty? [ 3drop ] [
-        [ [ pop-front dup ] 2dip slip [ t ] compose [ drop f ] if ]
+        [ [ pop-front dup ] 2dip [ call ] dip [ t ] compose [ drop f ] if ]
         [ roll [ slurp-deque-when ] [ 3drop ] if ] 3bi
     ] if ; inline recursive
diff --git a/extra/terrain/deploy.factor b/extra/terrain/deploy.factor
new file mode 100644 (file)
index 0000000..e51f8d1
--- /dev/null
@@ -0,0 +1,15 @@
+USING: tools.deploy.config ;
+H{
+    { deploy-ui? t }
+    { deploy-reflection 1 }
+    { deploy-unicode? f }
+    { deploy-math? t }
+    { deploy-io 2 }
+    { deploy-c-types? f }
+    { deploy-name "Terrain" }
+    { deploy-word-props? f }
+    { deploy-word-defs? f }
+    { "stop-after-last-window?" t }
+    { deploy-compiler? t }
+    { deploy-threads? t }
+}