From f0824b64b67d8faf9964b23fc3369be54067c617 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Thu, 13 Nov 2008 09:48:42 -0800 Subject: [PATCH 001/157] change cairo-gadget so it can handle constantly updating content --- extra/cairo/gadgets/gadgets.factor | 58 +++++++++-------------------- extra/opengl/gadgets/gadgets.factor | 5 +++ 2 files changed, 22 insertions(+), 41 deletions(-) diff --git a/extra/cairo/gadgets/gadgets.factor b/extra/cairo/gadgets/gadgets.factor index d160740c44..8ed7a3c31b 100644 --- a/extra/cairo/gadgets/gadgets.factor +++ b/extra/cairo/gadgets/gadgets.factor @@ -1,58 +1,34 @@ ! Copyright (C) 2008 Matthew Willis. ! See http://factorcode.org/license.txt for BSD license. -USING: sequences math opengl.gadgets kernel -byte-arrays cairo.ffi cairo io.backend -ui.gadgets accessors opengl.gl -arrays fry classes ; +USING: sequences math kernel byte-arrays cairo.ffi cairo +io.backend ui.gadgets accessors opengl.gl arrays fry +classes ui.render namespaces ; IN: cairo.gadgets : width>stride ( width -- stride ) 4 * ; -: copy-cairo ( dim quot -- byte-array ) - >r first2 over width>stride - [ * nip dup CAIRO_FORMAT_ARGB32 ] - [ cairo_image_surface_create_for_data ] 3bi - r> with-cairo-from-surface ; inline +GENERIC: render-cairo* ( gadget -- ) -TUPLE: cairo-gadget < texture-gadget ; +: render-cairo ( gadget -- byte-array ) + dup dim>> first2 over width>stride + [ * nip dup CAIRO_FORMAT_ARGB32 ] + [ cairo_image_surface_create_for_data ] 3bi + rot '[ _ render-cairo* ] with-cairo-from-surface ; inline + +TUPLE: cairo-gadget < gadget ; : ( dim -- gadget ) cairo-gadget new-gadget swap >>dim ; -M: cairo-gadget cache-key* [ dim>> ] [ class ] bi 2array ; - -: render-cairo ( dim quot -- bytes format ) - >r 2^-bounds r> copy-cairo GL_BGRA ; inline - -GENERIC: render-cairo* ( gadget -- ) - -M: cairo-gadget render* - [ dim>> dup ] [ '[ _ render-cairo* ] ] bi - render-cairo render-bytes* ; - -! maybe also texture>png -! : cairo>png ( gadget path -- ) -! >r [ cairo>bytes CAIRO_FORMAT_ARGB32 ] [ width>> ] -! [ height>> ] tri over width>stride -! cairo_image_surface_create_for_data -! r> [ cairo_surface_write_to_png check-cairo ] curry with-surface ; +M: cairo-gadget draw-gadget* + [ dim>> ] [ render-cairo ] bi + origin get first2 glRasterPos2i + 1.0 -1.0 glPixelZoom + >r first2 GL_BGRA GL_UNSIGNED_BYTE r> + glDrawPixels ; : copy-surface ( surface -- ) cr swap 0 0 cairo_set_source_surface cr cairo_paint ; - -TUPLE: png-gadget < texture-gadget path ; -: ( path -- gadget ) - png-gadget new-gadget - swap >>path ; - -M: png-gadget render* - path>> normalize-path cairo_image_surface_create_from_png - [ cairo_image_surface_get_width ] - [ cairo_image_surface_get_height 2array dup 2^-bounds ] - [ [ copy-surface ] curry copy-cairo ] tri - GL_BGRA render-bytes* ; - -M: png-gadget cache-key* path>> ; diff --git a/extra/opengl/gadgets/gadgets.factor b/extra/opengl/gadgets/gadgets.factor index cfedf32079..1fefcd5665 100644 --- a/extra/opengl/gadgets/gadgets.factor +++ b/extra/opengl/gadgets/gadgets.factor @@ -47,6 +47,11 @@ C: cache-entry cache-key* textures get delete-at* [ tex>> delete-texture ] [ drop ] if ; +: clear-textures ( -- ) + textures get values [ tex>> delete-texture ] each + H{ } clone textures set-global + H{ } clone refcounts set-global ; + M: texture-gadget graft* ( gadget -- ) [ 1+ ] refcount-change ; M: texture-gadget ungraft* ( gadget -- ) From a9f8856b0d7c4cb757fa6c9e5e5871618e973621 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Thu, 13 Nov 2008 09:49:18 -0800 Subject: [PATCH 002/157] make shader code in spheres a little more readable --- basis/io/encodings/utf16/.utf16.factor.swo | Bin 16384 -> 0 bytes extra/spheres/spheres.factor | 22 +++++++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) delete mode 100644 basis/io/encodings/utf16/.utf16.factor.swo diff --git a/basis/io/encodings/utf16/.utf16.factor.swo b/basis/io/encodings/utf16/.utf16.factor.swo deleted file mode 100644 index 01be8fdab2946825bf902b05af5135496b67501b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16384 zcmeI2O^h5z6~~JZJ2)Xgk^>yynghG?_Uz0o*wI+KE7mc=!kZA*YZ+E6rDwW&rnNoY z)iI3Oil$N>d};6Q}Pkxwa+V&wxN1rQP!j)@fhue!RYyLY^- zk3rSeZ`RZO>Q%jey{hi6nr`#rxivb~XbK!36XLVK`tgImeC~w!?FWPi1EoUgxe;GG z;8=5eL8Rhz;Iu#82;-g`PB;E);c&rsdn!&AdT}Bbf_Onjz1Rz)e!4JLe(PlR*~pBh z`?6=P0#<=rRp9Q8#dfRt$>TG0-@O~RTG-lK1*`&A0jq#jz$#!BunJfOtOD;4@$rdfj;oT61WGv^1%If@|OsSOj;0x9<|-1#k^0kb-s40!<*m zjXQ;S5quLo3eJF4a1Z#`F(G~iz5~7u*1;M$0gi$q_{UKp{s4XtehRLGC%^!F2`m8uN5S8ZAWrZycosYZ z6iC5&@CD$2Bj9%M>g__j0)7IX2Tz0R;1ZYz$H2Q-$ax3+4m=H>0#`vBw7`GR?>E3} z;8}1TJOM6(4WRP^@=lHpr6ac|X_gY129LYlP?Fac`SasT@y+vhOO13nec>6euVEl?bZNycU(9ep8=guAmWz zb?eFO$0vt$J45FpQUgi;Sd9}okN*cLrGt1JdgMtZdy3r1qo5z**Dd7I>ceZ~DqW;2 z`#}`phc4p6#uv|@ou~vA;8)QVH>F-Y3ZzGV5)Ube8+p`e10mk8U7O0fXhU#SdMJ8f zAW;|E;YJj9)1Hh_^DrJqieeugJxShp6b3z41#v`doe8vui)id=trjb`OPi!<3!hpS z>BuCB6P(zqm}t4Xa;0o(&P}%sr`RGra=*KxlUJzSaA(NNoLJ~kPAQ`mSE(Mni$?4=I*(){&lk4{q%g+T<}JGuA5&M)lCcHFE@{Ob+eWI1ox7D=}^fNm(f zM?-g;M@qF}Xm`D7?27wzu-skfW>L-4JWd5Z8YcKMA4Y@}BLV@#Lg>@@K=$NU{UAwI z<)RL@)x<%LF2UCNaI=geByKU7YA(D&<=(<6)8s zSs!MDTvurN<4{#`Pfn_GTFtC66Yn|)GUuB#Yi0_QqI2lG>BVEd zp%oRI?^S1d8i$RS#3QO%@I4pU{Jbg+`P?tQ28j($(VOoVa|bMDrEV}L#RpU+pbKOwACcu#eMNs!!_M_ zsAy{`-<1cXd^SlPCgsfo!vRW_Z^8Kh`Cr{$%Wp2mL#EWpZ9Uu8ec#exsds(ZS!J;3 zFWF7DRO`Mm!-`gW;*ev;iyb3lE&rAi$}>J$u4maKyB2F%lb0#Y!g+qx#|q1cHk&by zaWZXW7n23wcZ)nOW|DH_OIK?no%^swTZKU}4EPS*G`9&J3y;erUeRWH$WIvpW~}H~ zs(n+E|0ZL;oO#)N&o?lB6e-UGB|i}4Ca$W(oSl@N*HzVzT9clhWv>&lF$0(sz;odG zm)BMwKHo8Cim!U`RKB$<-&)1Dtiy!hyEPuh^({`6pUUz4JnROMi~BO(0`Q2f6rS%P z#K!u$haT+U2~7=XTPBeV`8jcn2M`HEO#LZ6hIa)n7P&*IU#e2BgS{m?c&J~Ok_JkR zIt%9a^86g%h?D*T9^_?|%7(hC$j8(9>iPqepF_bj@n|Or`U6F?XXdEgY@VFw&r|e( z8wF^`*+C*B%#r~@8JCY&wKuV#ykF>!1Lfa5QDSe2>2)7<@ufeb?`EH z3VaJ}1AgDX7uDRspMkRlq7>6|f3e1*`&Af&T*q z2nSXiYI_P;cqn$avTZ8oN)pt!y2@9w6;^m^;Vi#a!bSNyUNcLZWaTTZ(#miAm_%EK zBekA2rcVo)|kyUpRRGL2<$p@T3ZO3 z;y_2kVUGgdgw(s6s1qVg_AV=%Q&^Dh4aU(n1lg8yq|2j|ba8(ihASuw2aCG(%kaWo zw*^^6vEx?>AX_6TmN2qvc~!#{)e9b(Qt)~leK U6w0WN#fU9xV|69mAqVFF1)sD~> [ - drop + { + [ "checker_size_inv" glGetUniformLocation 0.125 glUniform1f ] + [ "checker_color_1" glGetUniformLocation 1.0 0.5 0.0 1.0 glUniform4f ] + [ "checker_color_2" glGetUniformLocation 0.0 0.0 0.0 1.0 glUniform4f ] + } cleave GL_QUADS [ -1000.0 -30.0 1000.0 glVertex3f -1000.0 -30.0 -1000.0 glVertex3f From bcd314aa465b96e2ed9e04af15ebbf2d387bf93e Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Tue, 18 Nov 2008 22:54:22 -0600 Subject: [PATCH 003/157] less aggressive make clean --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 973ba1f3d4..7ef6be33da 100644 --- a/Makefile +++ b/Makefile @@ -161,7 +161,7 @@ factor: $(DLL_OBJS) $(EXE_OBJS) clean: rm -f vm/*.o - rm -f factor*.dll libfactor*.* + rm -f factor*.dll libfactor{.a,.so} vm/resources.o: $(WINDRES) vm/factor.rs vm/resources.o From 020a866e426d6554225e54938170d79936518a49 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Tue, 18 Nov 2008 23:56:51 -0600 Subject: [PATCH 004/157] disable regexp failing tests for now --- basis/regexp/regexp-tests.factor | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/basis/regexp/regexp-tests.factor b/basis/regexp/regexp-tests.factor index 4878b67d0f..388a71e028 100644 --- a/basis/regexp/regexp-tests.factor +++ b/basis/regexp/regexp-tests.factor @@ -347,6 +347,8 @@ IN: regexp-tests [ { 23 24 } ] [ "aaaaaaaaaaaaaaaaaaaaaaab" "((a*)*b)*b" first-match ] unit-test -[ t ] [ "a:b" ".+:?" matches? ] unit-test +! Disable tests so builds will upload, for now... -[ 1 ] [ "hello" ".+?" match length ] unit-test +! [ t ] [ "a:b" ".+:?" matches? ] unit-test + +! [ 1 ] [ "hello" ".+?" match length ] unit-test From fb2523dc8187d0e8d13184d872bf350a39c110c8 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 19 Nov 2008 01:57:44 -0600 Subject: [PATCH 005/157] Revert "disable regexp failing tests for now" This reverts commit 020a866e426d6554225e54938170d79936518a49. --- basis/regexp/regexp-tests.factor | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/basis/regexp/regexp-tests.factor b/basis/regexp/regexp-tests.factor index 388a71e028..4878b67d0f 100644 --- a/basis/regexp/regexp-tests.factor +++ b/basis/regexp/regexp-tests.factor @@ -347,8 +347,6 @@ IN: regexp-tests [ { 23 24 } ] [ "aaaaaaaaaaaaaaaaaaaaaaab" "((a*)*b)*b" first-match ] unit-test -! Disable tests so builds will upload, for now... +[ t ] [ "a:b" ".+:?" matches? ] unit-test -! [ t ] [ "a:b" ".+:?" matches? ] unit-test - -! [ 1 ] [ "hello" ".+?" match length ] unit-test +[ 1 ] [ "hello" ".+?" match length ] unit-test From 358f99d7dd8aa3adae2db7f6eb1bab0039ed5b9a Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 19 Nov 2008 01:58:22 -0600 Subject: [PATCH 006/157] Revert "less aggressive make clean" This reverts commit bcd314aa465b96e2ed9e04af15ebbf2d387bf93e. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 7ef6be33da..973ba1f3d4 100644 --- a/Makefile +++ b/Makefile @@ -161,7 +161,7 @@ factor: $(DLL_OBJS) $(EXE_OBJS) clean: rm -f vm/*.o - rm -f factor*.dll libfactor{.a,.so} + rm -f factor*.dll libfactor*.* vm/resources.o: $(WINDRES) vm/factor.rs vm/resources.o From 5df0a0073f74a02c90d22b69b0b2f1a624fcb13d Mon Sep 17 00:00:00 2001 From: "Jose A. Ortega Ruiz" Date: Wed, 19 Nov 2008 10:37:54 +0100 Subject: [PATCH 007/157] Emacs factor-mode: small indentation fixes and cleanups. --- misc/factor.el | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/misc/factor.el b/misc/factor.el index f75cb7f359..170da980be 100644 --- a/misc/factor.el +++ b/misc/factor.el @@ -265,7 +265,7 @@ value from the existing code in the buffer." (defsubst factor--ppss-brackets-start () (nth 1 (syntax-ppss))) -(defsubst factor--line-indent (pos) +(defsubst factor--indentation-at (pos) (save-excursion (goto-char pos) (current-indentation))) (defconst factor--regex-closing-paren "[])}]") @@ -276,7 +276,8 @@ value from the existing code in the buffer." (= (- (point) (line-beginning-position)) (current-indentation))) (defconst factor--regex-single-liner - (format "^%s" (regexp-opt '("DEFER:" "GENERIC:" "IN:" "PRIVATE>" "" " (line-number-at-pos) (line-number-at-pos op)) (if (factor--at-closing-paren-p) - (factor--line-indent op) - (+ (factor--line-indent op) factor-indent-width))))))) + (factor--indentation-at op) + (factor--increased-indentation (factor--indentation-at op)))))))) (defun factor--indent-definition () (save-excursion @@ -323,29 +329,26 @@ value from the existing code in the buffer." (defun factor--indent-setter-line () (when (factor--at-setter-line) (save-excursion - (beginning-of-line) - (let ((indent (when (factor--at-constructor-line) (current-indentation)))) + (let ((indent (and (factor--at-constructor-line) (current-indentation)))) (while (not (or indent (bobp) (factor--at-begin-of-def) (factor--at-end-of-def))) (if (factor--at-constructor-line) - (setq indent (+ (current-indentation) factor-indent-width)) + (setq indent (factor--increased-indentation)) (forward-line -1))) indent)))) (defun factor--indent-continuation () (save-excursion (forward-line -1) - (beginning-of-line) - (if (bobp) 0 - (if (factor--looking-at-emptiness) - (factor--indent-continuation) - (if (or (factor--at-end-of-def) (factor--at-setter-line)) - (- (current-indentation) factor-indent-width) - (if (factor--at-begin-of-def) - (+ (current-indentation) factor-indent-width) - (current-indentation))))))) + (while (and (not (bobp)) (factor--looking-at-emptiness)) + (forward-line -1)) + (if (or (factor--at-end-of-def) (factor--at-setter-line)) + (factor--decreased-indentation) + (if (factor--at-begin-of-def) + (factor--increased-indentation) + (current-indentation))))) (defun factor--calculate-indentation () "Calculate Factor indentation for line at point." From 12601b7eb03938bdb588dd2151e6b34240b7d81e Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 19 Nov 2008 13:02:33 -0600 Subject: [PATCH 008/157] Add failing unit test --- basis/locals/locals-tests.factor | 2 ++ 1 file changed, 2 insertions(+) diff --git a/basis/locals/locals-tests.factor b/basis/locals/locals-tests.factor index ca6697be1c..04e077fc4f 100644 --- a/basis/locals/locals-tests.factor +++ b/basis/locals/locals-tests.factor @@ -388,6 +388,8 @@ M:: integer lambda-method-forget-test ( a -- b ) ; [ ] [ [ { integer lambda-method-forget-test } forget ] with-compilation-unit ] unit-test +[ { [ 10 ] } ] [ 10 [| A | { [ A ] } ] call ] unit-test + ! :: wlet-&&-test ( a -- ? ) ! [wlet | is-integer? [ a integer? ] ! is-even? [ a even? ] From 5bf4065314f7661fba3d0ca56e92b06f5dd99a7f Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Wed, 19 Nov 2008 14:28:26 -0600 Subject: [PATCH 009/157] better fix for deleting the factor library on make clean --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 973ba1f3d4..ffcbf6364c 100644 --- a/Makefile +++ b/Makefile @@ -161,7 +161,7 @@ factor: $(DLL_OBJS) $(EXE_OBJS) clean: rm -f vm/*.o - rm -f factor*.dll libfactor*.* + rm -f factor*.dll libfactor.{a,so,dylib} vm/resources.o: $(WINDRES) vm/factor.rs vm/resources.o From cdf743666715a99546e44085429ab83fbaa1c2cd Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 19 Nov 2008 16:01:48 -0600 Subject: [PATCH 010/157] Add parallel-cleave, parallel-spread, parallel-napply combinators --- .../combinators/combinators-docs.factor | 10 ++++- .../combinators/combinators-tests.factor | 10 ++++- .../combinators/combinators.factor | 40 +++++++++++++++---- 3 files changed, 49 insertions(+), 11 deletions(-) diff --git a/basis/concurrency/combinators/combinators-docs.factor b/basis/concurrency/combinators/combinators-docs.factor index cb07e5a8d6..c61967fc8a 100644 --- a/basis/concurrency/combinators/combinators-docs.factor +++ b/basis/concurrency/combinators/combinators-docs.factor @@ -27,11 +27,17 @@ HELP: parallel-filter { $errors "Throws an error if one of the iterations throws an error." } ; ARTICLE: "concurrency.combinators" "Concurrent combinators" -"The " { $vocab-link "concurrency.combinators" } " vocabulary provides concurrent variants of " { $link each } ", " { $link map } " and " { $link filter } ":" +"The " { $vocab-link "concurrency.combinators" } " vocabulary provides concurrent variants of various combinators." +$nl +"Concurrent sequence combinators:" { $subsection parallel-each } { $subsection 2parallel-each } { $subsection parallel-map } { $subsection 2parallel-map } -{ $subsection parallel-filter } ; +{ $subsection parallel-filter } +"Concurrent cleave combinators:" +{ $subsection parallel-cleave } +{ $subsection parallel-spread } +{ $subsection parallel-napply } ; ABOUT: "concurrency.combinators" diff --git a/basis/concurrency/combinators/combinators-tests.factor b/basis/concurrency/combinators/combinators-tests.factor index 562111242d..3a38daed86 100644 --- a/basis/concurrency/combinators/combinators-tests.factor +++ b/basis/concurrency/combinators/combinators-tests.factor @@ -1,6 +1,7 @@ IN: concurrency.combinators.tests USING: concurrency.combinators tools.test random kernel math -concurrency.mailboxes threads sequences accessors arrays ; +concurrency.mailboxes threads sequences accessors arrays +math.parser ; [ [ drop ] parallel-each ] must-infer { 2 0 } [ [ 2drop ] 2parallel-each ] must-infer-as @@ -45,3 +46,10 @@ concurrency.mailboxes threads sequences accessors arrays ; ] unit-test [ { f } [ "OOPS" throw ] parallel-each ] must-fail + +[ "1a" "4b" "3c" ] [ + 2 + { [ 1- ] [ sq ] [ 1+ ] } parallel-cleave + [ number>string ] 3 parallel-napply + { [ "a" append ] [ "b" append ] [ "c" append ] } parallel-spread +] unit-test diff --git a/basis/concurrency/combinators/combinators.factor b/basis/concurrency/combinators/combinators.factor index ab3ca7ed4a..4608faf79b 100644 --- a/basis/concurrency/combinators/combinators.factor +++ b/basis/concurrency/combinators/combinators.factor @@ -1,34 +1,58 @@ ! Copyright (C) 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: concurrency.futures concurrency.count-downs sequences -kernel ; +kernel macros fry combinators generalizations ; IN: concurrency.combinators r r> keep await ; inline + [ ] dip keep await ; inline + PRIVATE> : parallel-each ( seq quot -- ) over length [ - [ >r curry r> spawn-stage ] 2curry each + '[ _ curry _ spawn-stage ] each ] (parallel-each) ; inline : 2parallel-each ( seq1 seq2 quot -- ) 2over min-length [ - [ >r 2curry r> spawn-stage ] 2curry 2each + '[ _ 2curry _ spawn-stage ] 2each ] (parallel-each) ; inline : parallel-filter ( seq quot -- newseq ) - over >r pusher >r each r> r> like ; inline + over [ pusher [ each ] dip ] dip like ; inline : parallel-map ( seq quot -- newseq ) - [ curry future ] curry map future-values ; - inline + [future] map future-values ; inline : 2parallel-map ( seq1 seq2 quot -- newseq ) - [ 2curry future ] curry 2map future-values ; + '[ _ 2curry future ] 2map future-values ; + + ; inline + +: (parallel-cleave) ( quots -- quot-array spread-array ) + [ [future] ] map dup length (parallel-spread) ; inline + +PRIVATE> + +MACRO: parallel-cleave ( quots -- ) + (parallel-cleave) '[ _ cleave _ spread ] ; + +MACRO: parallel-spread ( quots -- ) + (parallel-cleave) '[ _ spread _ spread ] ; + +MACRO: parallel-napply ( quot n -- ) + [ [future] ] dip dup (parallel-spread) '[ _ _ napply _ spread ] ; From 84d1a91966cc056cf279867b6cc0117c7ffcd291 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 19 Nov 2008 16:02:43 -0600 Subject: [PATCH 011/157] limited-completions now gives you the most relevant completions if there are too many, instead of just giving back the empty list --- basis/tools/completion/completion.factor | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/basis/tools/completion/completion.factor b/basis/tools/completion/completion.factor index 4bb6d6142f..2306ff53a8 100644 --- a/basis/tools/completion/completion.factor +++ b/basis/tools/completion/completion.factor @@ -72,7 +72,9 @@ IN: tools.completion ] if ; : string-completions ( short strs -- seq ) - [ dup ] { } map>assoc completions ; + dup zip completions ; : limited-completions ( short candidates -- seq ) - completions dup length 1000 > [ drop f ] when ; + [ completions ] [ drop ] 2bi + 2dup [ length 50 > ] [ empty? ] bi* and + [ 2drop f ] [ drop 50 short head ] if ; From 60855571162c8bbc407819587fb8c69771436e2e Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 19 Nov 2008 16:03:05 -0600 Subject: [PATCH 012/157] Parser now prints an IN:/USING: form if restarts were invoked; add more restarts for certain errors --- basis/prettyprint/prettyprint.factor | 18 ++++++++++- core/parser/parser.factor | 48 ++++++++++++++++++++++------ 2 files changed, 55 insertions(+), 11 deletions(-) diff --git a/basis/prettyprint/prettyprint.factor b/basis/prettyprint/prettyprint.factor index 3befdaff2b..1ecca0ec19 100644 --- a/basis/prettyprint/prettyprint.factor +++ b/basis/prettyprint/prettyprint.factor @@ -7,7 +7,7 @@ prettyprint.config sorting splitting grouping math.parser vocabs definitions effects classes.builtin classes.tuple io.files classes continuations hashtables classes.mixin classes.union classes.intersection classes.predicate classes.singleton -combinators quotations sets accessors colors ; +combinators quotations sets accessors colors parser ; IN: prettyprint : make-pprint ( obj quot -- block in use ) @@ -48,6 +48,22 @@ IN: prettyprint dupd remove [ { "syntax" "scratchpad" } member? not ] filter use. in. ; +: vocab-names ( words -- vocabs ) + dictionary get + [ [ words>> eq? nip ] with assoc-find 2drop ] curry map sift ; + +: prelude. ( -- ) + in get use get vocab-names vocabs. ; + +[ + nl + "Restarts were invoked adding vocabularies to the search path." print + "To avoid doing this in the future, add the following USING:" print + "and IN: forms at the top of the source file:" print nl + prelude. + nl +] print-use-hook set-global + : with-use ( obj quot -- ) make-pprint vocabs. do-pprint ; inline diff --git a/core/parser/parser.factor b/core/parser/parser.factor index ed8fc4510b..00d13e6e56 100644 --- a/core/parser/parser.factor +++ b/core/parser/parser.factor @@ -52,7 +52,12 @@ SYMBOL: in M: parsing-word stack-effect drop (( parsed -- parsed )) ; -ERROR: no-current-vocab ; +TUPLE: no-current-vocab ; + +: no-current-vocab ( -- vocab ) + \ no-current-vocab boa + { { "Define words in scratchpad vocabulary" "scratchpad" } } + throw-restarts dup set-in ; : current-vocab ( -- str ) in get [ no-current-vocab ] unless* ; @@ -64,20 +69,31 @@ ERROR: no-current-vocab ; : CREATE-WORD ( -- word ) CREATE dup reset-generic ; -: word-restarts ( possibilities -- restarts ) - natural-sort [ +: word-restarts ( possibilities name -- restarts ) + [ + natural-sort [ - "Use the " swap vocabulary>> " vocabulary" 3append - ] keep - ] { } map>assoc ; + [ "Use the " swap vocabulary>> " vocabulary" 3append ] keep + ] { } map>assoc + ] + [ "Defer word in current vocabulary" swap 2array ] bi* + suffix ; ERROR: no-word-error name ; +SYMBOL: amended-use? + +: no-word-restarted ( restart-value -- word ) + dup word? + [ amended-use? on dup vocabulary>> (use+) ] + [ create-in ] + if ; + : no-word ( name -- newword ) dup \ no-word-error boa - swap words-named [ forward-reference? not ] filter + swap [ words-named [ forward-reference? not ] filter ] keep word-restarts throw-restarts - dup vocabulary>> (use+) ; + no-word-restarted ; : check-forward ( str word -- word/f ) dup forward-reference? [ @@ -127,7 +143,9 @@ ERROR: staging-violation word ; : parsed ( accum obj -- accum ) over push ; : (parse-lines) ( lexer -- quot ) - [ f parse-until >quotation ] with-lexer ; + [ + f parse-until >quotation + ] with-lexer ; : parse-lines ( lines -- quot ) lexer-factory get call (parse-lines) ; @@ -206,8 +224,18 @@ SYMBOL: interactive-vocabs call ] with-scope ; inline +SYMBOL: print-use-hook + +[ ] print-use-hook set-global + : parse-fresh ( lines -- quot ) - [ parse-lines ] with-file-vocabs ; + [ + amended-use? off + parse-lines + amended-use? get [ + print-use-hook get call + ] when + ] with-file-vocabs ; : parsing-file ( file -- ) "quiet" get [ From 3ea773fa80b5afb5415d998915b379075022a97d Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Wed, 19 Nov 2008 16:10:00 -0600 Subject: [PATCH 013/157] remove UNKNOWN test --- vm/os-netbsd.h | 1 - 1 file changed, 1 deletion(-) diff --git a/vm/os-netbsd.h b/vm/os-netbsd.h index 54b5d0bcff..6486acda4a 100644 --- a/vm/os-netbsd.h +++ b/vm/os-netbsd.h @@ -2,5 +2,4 @@ #define UAP_PROGRAM_COUNTER(uap) _UC_MACHINE_PC((ucontext_t *)uap) -#define UNKNOWN_TYPE_P(file) ((file)->d_type == DT_UNKNOWN) #define DIRECTORY_P(file) ((file)->d_type == DT_DIR) From 25d9fd68fc62247a2ddd15d4c66f384fb20383bb Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Wed, 19 Nov 2008 16:22:42 -0600 Subject: [PATCH 014/157] translate directory-type flags to our factor symbols --- basis/io/unix/files/files.factor | 9 ++++++--- basis/unix/bsd/bsd.factor | 10 ---------- basis/unix/unix.factor | 25 ++++++++++++++++++++++++- core/io/files/files.factor | 1 + 4 files changed, 31 insertions(+), 14 deletions(-) diff --git a/basis/io/unix/files/files.factor b/basis/io/unix/files/files.factor index 3f254e7713..98206bc992 100644 --- a/basis/io/unix/files/files.factor +++ b/basis/io/unix/files/files.factor @@ -117,8 +117,8 @@ M: unix stat>file-info ( stat -- file-info ) [ stat-st_blksize >>blocksize ] } cleave ; -M: unix stat>type ( stat -- type ) - stat-st_mode S_IFMT bitand { +: n>file-type ( n -- type ) + S_IFMT bitand { { S_IFREG [ +regular-file+ ] } { S_IFDIR [ +directory+ ] } { S_IFCHR [ +character-device+ ] } @@ -129,6 +129,9 @@ M: unix stat>type ( stat -- type ) [ drop +unknown+ ] } case ; +M: unix stat>type ( stat -- type ) + stat-st_mode n>file-type ; + ! Linux has no extra fields in its stat struct os { { macosx [ "io.unix.files.bsd" require ] } @@ -150,7 +153,7 @@ os { M: unix >directory-entry ( byte-array -- directory-entry ) [ dirent-d_name utf8 alien>string ] - [ dirent-d_type ] bi directory-entry boa ; + [ dirent-d_type dirent-type>file-type ] bi directory-entry boa ; M: unix (directory-entries) ( path -- seq ) [ diff --git a/basis/unix/bsd/bsd.factor b/basis/unix/bsd/bsd.factor index bd66c5253e..bf426ad867 100644 --- a/basis/unix/bsd/bsd.factor +++ b/basis/unix/bsd/bsd.factor @@ -83,16 +83,6 @@ C-STRUCT: passwd : SEEK_CUR 1 ; inline : SEEK_END 2 ; inline -: DT_UNKNOWN 0 ; inline -: DT_FIFO 1 ; inline -: DT_CHR 2 ; inline -: DT_DIR 4 ; inline -: DT_BLK 6 ; inline -: DT_REG 8 ; inline -: DT_LNK 10 ; inline -: DT_SOCK 12 ; inline -: DT_WHT 14 ; inline - os { { macosx [ "unix.bsd.macosx" require ] } { freebsd [ "unix.bsd.freebsd" require ] } diff --git a/basis/unix/unix.factor b/basis/unix/unix.factor index 4950daef2c..ca8a7a2e60 100644 --- a/basis/unix/unix.factor +++ b/basis/unix/unix.factor @@ -4,7 +4,7 @@ USING: alien alien.c-types alien.syntax kernel libc sequences continuations byte-arrays strings math namespaces system combinators vocabs.loader qualified accessors stack-checker macros locals generalizations unix.types -debugger io prettyprint ; +debugger io prettyprint io.files ; IN: unix : PROT_NONE 0 ; inline @@ -20,6 +20,29 @@ IN: unix : NGROUPS_MAX 16 ; inline +: DT_UNKNOWN 0 ; inline +: DT_FIFO 1 ; inline +: DT_CHR 2 ; inline +: DT_DIR 4 ; inline +: DT_BLK 6 ; inline +: DT_REG 8 ; inline +: DT_LNK 10 ; inline +: DT_SOCK 12 ; inline +: DT_WHT 14 ; inline + +: dirent-type>file-type ( ch -- type ) + { + { DT_BLK [ +block-device+ ] } + { DT_CHR [ +character-device+ ] } + { DT_DIR [ +directory+ ] } + { DT_LNK [ +symbolic-link+ ] } + { DT_SOCK [ +socket+ ] } + { DT_FIFO [ +fifo+ ] } + { DT_REG [ +regular-file+ ] } + { DT_WHT [ +whiteout+ ] } + [ drop +unknown+ ] + } case ; + C-STRUCT: group { "char*" "gr_name" } { "char*" "gr_passwd" } diff --git a/core/io/files/files.factor b/core/io/files/files.factor index ca8125d936..25f6f36e7c 100644 --- a/core/io/files/files.factor +++ b/core/io/files/files.factor @@ -175,6 +175,7 @@ SYMBOL: +character-device+ SYMBOL: +block-device+ SYMBOL: +fifo+ SYMBOL: +socket+ +SYMBOL: +whiteout+ SYMBOL: +unknown+ ! File metadata From e121a0822d3bc608df2d955de550b6008adfe7f4 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Wed, 19 Nov 2008 16:27:12 -0600 Subject: [PATCH 015/157] make a backup of the factor binary, library, and image before bootstrapping --- build-support/factor.sh | 69 +++++++++++++++++++++++++++++++++-------- 1 file changed, 56 insertions(+), 13 deletions(-) diff --git a/build-support/factor.sh b/build-support/factor.sh index 8d75b8cff2..1a4aa9f965 100755 --- a/build-support/factor.sh +++ b/build-support/factor.sh @@ -131,10 +131,10 @@ check_library_exists() { $ECHO "***Factor will compile NO_UI=1" NO_UI=1 fi - rm -f $GCC_TEST - check_ret rm - rm -f $GCC_OUT - check_ret rm + $DELETE -f $GCC_TEST + check_ret $DELETE + $DELETE -f $GCC_OUT + check_ret $DELETE $ECHO "found." } @@ -209,7 +209,7 @@ c_find_word_size() { gcc -o $C_WORD $C_WORD.c WORD=$(./$C_WORD) check_ret $C_WORD - rm -f $C_WORD* + $DELETE -f $C_WORD* } intel_macosx_word_size() { @@ -236,17 +236,30 @@ find_word_size() { set_factor_binary() { case $OS in - # winnt) FACTOR_BINARY=factor-nt;; - # macosx) FACTOR_BINARY=./Factor.app/Contents/MacOS/factor;; + winnt) FACTOR_BINARY=factor.exe;; *) FACTOR_BINARY=factor;; esac } +set_factor_library() { + case $OS in + winnt) FACTOR_LIBRARY=factor.dll;; + macosx) FACTOR_LIBRARY=libfactor.dylib;; + *) FACTOR_LIBRARY=libfactor.a;; + esac +} + +set_factor_image() { + FACTOR_IMAGE=factor.image +} + echo_build_info() { $ECHO OS=$OS $ECHO ARCH=$ARCH $ECHO WORD=$WORD $ECHO FACTOR_BINARY=$FACTOR_BINARY + $ECHO FACTOR_LIBRARY=$FACTOR_LIBRARY + $ECHO FACTOR_IMAGE=$FACTOR_IMAGE $ECHO MAKE_TARGET=$MAKE_TARGET $ECHO BOOT_IMAGE=$BOOT_IMAGE $ECHO MAKE_IMAGE_TARGET=$MAKE_IMAGE_TARGET @@ -255,6 +268,8 @@ echo_build_info() { $ECHO DOWNLOADER=$DOWNLOADER $ECHO CC=$CC $ECHO MAKE=$MAKE + $ECHO COPY=$COPY + $ECHO DELETE=$DELETE } check_os_arch_word() { @@ -312,6 +327,8 @@ find_build_info() { find_architecture find_word_size set_factor_binary + set_factor_library + set_factor_image set_build_info set_downloader set_gcc @@ -339,6 +356,28 @@ cd_factor() { check_ret cd } +set_copy() { + case $OS in + winnt) COPY=cp;; + *) COPY=cp;; + esac +} + +set_delete() { + case $OS in + winnt) DELETE=rm;; + *) DELETE=rm;; + esac +} + +backup_factor() { + $ECHO "Backing up factor..." + $COPY $FACTOR_BINARY $FACTOR_BINARY.bak + $COPY $FACTOR_LIBRARY $FACTOR_LIBRARY.bak + $COPY $FACTOR_IMAGE $FACTOR_IMAGE.bak + $ECHO "Done with backup." +} + check_makefile_exists() { if [[ ! -e "Makefile" ]] ; then echo "" @@ -366,9 +405,9 @@ make_factor() { update_boot_images() { echo "Deleting old images..." - rm checksums.txt* > /dev/null 2>&1 - rm $BOOT_IMAGE.* > /dev/null 2>&1 - rm temp/staging.*.image > /dev/null 2>&1 + $DELETE checksums.txt* > /dev/null 2>&1 + $DELETE $BOOT_IMAGE.* > /dev/null 2>&1 + $DELETE temp/staging.*.image > /dev/null 2>&1 if [[ -f $BOOT_IMAGE ]] ; then get_url http://factorcode.org/images/latest/checksums.txt factorcode_md5=`cat checksums.txt|grep $BOOT_IMAGE|cut -f2 -d' '`; @@ -382,7 +421,7 @@ update_boot_images() { if [[ "$factorcode_md5" == "$disk_md5" ]] ; then echo "Your disk boot image matches the one on factorcode.org." else - rm $BOOT_IMAGE > /dev/null 2>&1 + $DELETE $BOOT_IMAGE > /dev/null 2>&1 get_boot_image; fi else @@ -459,6 +498,7 @@ install() { update() { get_config_info git_pull_factorcode + backup_factor make_clean make_factor } @@ -469,12 +509,12 @@ update_bootstrap() { } refresh_image() { - ./$FACTOR_BINARY -script -e="USE: vocabs.loader refresh-all USE: memory save 0 USE: system exit" + ./$FACTOR_BINARY -script -e="USE: vocabs.loader USE: system refresh-all USE: memory save 0 exit" check_ret factor } make_boot_image() { - ./$FACTOR_BINARY -script -e="\"$MAKE_IMAGE_TARGET\" USE: bootstrap.image make-image save 0 USE: system exit" + ./$FACTOR_BINARY -script -e="\"$MAKE_IMAGE_TARGET\" USE: system USE: bootstrap.image make-image save 0 exit" check_ret factor } @@ -513,6 +553,9 @@ if [[ -n "$2" ]] ; then parse_build_info $2 fi +set_copy +set_delete + case "$1" in install) install ;; install-x11) install_build_system_apt; install ;; From 002563ce44e958c6ef95ed5f19946031327ef10a Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 19 Nov 2008 16:27:16 -0600 Subject: [PATCH 016/157] Add DWIM mode --- core/parser/parser.factor | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/core/parser/parser.factor b/core/parser/parser.factor index 00d13e6e56..007120fd19 100644 --- a/core/parser/parser.factor +++ b/core/parser/parser.factor @@ -69,20 +69,21 @@ TUPLE: no-current-vocab ; : CREATE-WORD ( -- word ) CREATE dup reset-generic ; -: word-restarts ( possibilities name -- restarts ) - [ - natural-sort - [ - [ "Use the " swap vocabulary>> " vocabulary" 3append ] keep - ] { } map>assoc - ] - [ "Defer word in current vocabulary" swap 2array ] bi* +: word-restarts ( name possibilities -- restarts ) + natural-sort + [ [ "Use the " swap vocabulary>> " vocabulary" 3append ] keep ] { } map>assoc + swap "Defer word in current vocabulary" swap 2array suffix ; ERROR: no-word-error name ; +: ( name possibilities -- error restarts ) + [ drop \ no-word-error boa ] [ word-restarts ] 2bi ; + SYMBOL: amended-use? +SYMBOL: do-what-i-mean? + : no-word-restarted ( restart-value -- word ) dup word? [ amended-use? on dup vocabulary>> (use+) ] @@ -90,10 +91,11 @@ SYMBOL: amended-use? if ; : no-word ( name -- newword ) - dup \ no-word-error boa - swap [ words-named [ forward-reference? not ] filter ] keep - word-restarts throw-restarts - no-word-restarted ; + dup words-named [ forward-reference? not ] filter + dup length 1 = do-what-i-mean? get and + [ nip first no-word-restarted ] + [ throw-restarts no-word-restarted ] + if ; : check-forward ( str word -- word/f ) dup forward-reference? [ @@ -226,7 +228,7 @@ SYMBOL: interactive-vocabs SYMBOL: print-use-hook -[ ] print-use-hook set-global +print-use-hook global [ [ ] or ] change-at : parse-fresh ( lines -- quot ) [ From a62641e4698466ceb84585c6ad204adafed47abc Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Wed, 19 Nov 2008 16:32:12 -0600 Subject: [PATCH 017/157] add .bak to gitignore for factor backups --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 290f075aae..f4334f3727 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,4 @@ temp logs work build-support/wordsize +*.bak From 1ef21ba2d3626ee4186ba129543abf21534f4ae9 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Wed, 19 Nov 2008 16:40:50 -0600 Subject: [PATCH 018/157] add type to directory-entry on windows --- basis/io/windows/files/files.factor | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/basis/io/windows/files/files.factor b/basis/io/windows/files/files.factor index d0409ce59a..5746eb252d 100755 --- a/basis/io/windows/files/files.factor +++ b/basis/io/windows/files/files.factor @@ -114,11 +114,6 @@ M: windows delete-directory ( path -- ) normalize-path RemoveDirectory win32-error=0/f ; -M: windows >directory-entry ( byte-array -- directory-entry ) - [ WIN32_FIND_DATA-cFileName utf16n alien>string ] - [ WIN32_FIND_DATA-dwFileAttributes ] - bi directory-entry boa ; - : find-first-file ( path -- WIN32_FIND_DATA handle ) "WIN32_FIND_DATA" tuck FindFirstFile @@ -177,6 +172,14 @@ TUPLE: windows-file-info < file-info attributes ; : win32-file-type ( n -- symbol ) FILE_ATTRIBUTE_DIRECTORY mask? +directory+ +regular-file+ ? ; +TUPLE: windows-directory-entry < directory-entry attributes ; + +M: windows >directory-entry ( byte-array -- directory-entry ) + [ WIN32_FIND_DATA-cFileName utf16n alien>string ] + [ WIN32_FIND_DATA-dwFileAttributes win32-file-type ] + [ WIN32_FIND_DATA-dwFileAttributes win32-file-attributes ] + tri windows-directory-entry boa ; + : WIN32_FIND_DATA>file-info ( WIN32_FIND_DATA -- file-info ) [ \ windows-file-info new ] dip { From 4849636fd7b7ad6ceb6e37f93493d566e1b02286 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Wed, 19 Nov 2008 16:45:13 -0600 Subject: [PATCH 019/157] remove attribute if it's the same as the type --- basis/io/windows/files/files.factor | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/basis/io/windows/files/files.factor b/basis/io/windows/files/files.factor index 5746eb252d..7f84b9d9e5 100755 --- a/basis/io/windows/files/files.factor +++ b/basis/io/windows/files/files.factor @@ -178,7 +178,8 @@ M: windows >directory-entry ( byte-array -- directory-entry ) [ WIN32_FIND_DATA-cFileName utf16n alien>string ] [ WIN32_FIND_DATA-dwFileAttributes win32-file-type ] [ WIN32_FIND_DATA-dwFileAttributes win32-file-attributes ] - tri windows-directory-entry boa ; + tri + dupd remove windows-directory-entry boa ; : WIN32_FIND_DATA>file-info ( WIN32_FIND_DATA -- file-info ) [ \ windows-file-info new ] dip From 3e93d3599c75a423795ea67366681544ce06b971 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Wed, 19 Nov 2008 17:00:35 -0600 Subject: [PATCH 020/157] make a copy of your boot image before deleting it --- build-support/factor.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/build-support/factor.sh b/build-support/factor.sh index 1a4aa9f965..b2b6ad1ff9 100755 --- a/build-support/factor.sh +++ b/build-support/factor.sh @@ -374,6 +374,7 @@ backup_factor() { $ECHO "Backing up factor..." $COPY $FACTOR_BINARY $FACTOR_BINARY.bak $COPY $FACTOR_LIBRARY $FACTOR_LIBRARY.bak + $COPY $BOOT_IMAGE $BOOT_IMAGE.bak $COPY $FACTOR_IMAGE $FACTOR_IMAGE.bak $ECHO "Done with backup." } @@ -406,7 +407,8 @@ make_factor() { update_boot_images() { echo "Deleting old images..." $DELETE checksums.txt* > /dev/null 2>&1 - $DELETE $BOOT_IMAGE.* > /dev/null 2>&1 + # delete boot images with one or two characters after the dot + $DELETE $BOOT_IMAGE.{?,??} > /dev/null 2>&1 $DELETE temp/staging.*.image > /dev/null 2>&1 if [[ -f $BOOT_IMAGE ]] ; then get_url http://factorcode.org/images/latest/checksums.txt From 6aff81052eab0b4273a6c53d8f7f7dc25479d25a Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 19 Nov 2008 17:10:19 -0600 Subject: [PATCH 021/157] Doc update --- basis/math/geometry/rect/rect-docs.factor | 16 ++++++++++++++++ basis/ui/ui-docs.factor | 19 +------------------ 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/basis/math/geometry/rect/rect-docs.factor b/basis/math/geometry/rect/rect-docs.factor index a892940363..0e34ace943 100644 --- a/basis/math/geometry/rect/rect-docs.factor +++ b/basis/math/geometry/rect/rect-docs.factor @@ -47,3 +47,19 @@ HELP: { $values { "rect" "a new " { $link rect } } } { $description "Creates a rectangle located at the origin with zero dimensions." } ; +ARTICLE: "math.geometry.rect" "Rectangles" +"The " { $vocab-link "math.geometry.rect" } " vocabulary defines a rectangle data type and operations on them." +{ $subsection rect } +"Rectangles can be taken apart:" +{ $subsection rect-loc } +{ $subsection rect-dim } +{ $subsection rect-bounds } +{ $subsection rect-extent } +"New rectangles can be created:" +{ $subsection } +{ $subsection } +{ $subsection } +"More utility words for working with rectangles:" +{ $subsection offset-rect } +{ $subsection rect-intersect } +{ $subsection intersects? } ; diff --git a/basis/ui/ui-docs.factor b/basis/ui/ui-docs.factor index 58509fc2df..c10205ed26 100644 --- a/basis/ui/ui-docs.factor +++ b/basis/ui/ui-docs.factor @@ -105,24 +105,7 @@ ARTICLE: "gadgets" "Pre-made UI gadgets" ARTICLE: "ui-geometry" "Gadget geometry" "The " { $link gadget } " class inherits from the " { $link rect } " class, and thus all gadgets have a bounding box:" -{ $subsection rect } -"Rectangles can be taken apart:" -{ $subsection rect-loc } -{ $subsection rect-dim } -{ $subsection rect-bounds } -{ $subsection rect-extent } -"New rectangles can be created:" -{ $subsection } -{ $subsection } -{ $subsection } -"More utility words for working with rectangles:" -{ $subsection offset-rect } -{ $subsection rect-intersect } -{ $subsection intersects? } - -! "A gadget's bounding box is always relative to its parent. " -! { $subsection gadget-parent } - +{ $subsection "math.geometry.rect" } "Word for converting from a child gadget's co-ordinate system to a parent's:" { $subsection relative-loc } { $subsection screen-loc } From 6681d4bca3f98d92147ed0ad3662dabd70209297 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 19 Nov 2008 17:13:10 -0600 Subject: [PATCH 022/157] Add an ABOUT: to math.geometry.rect --- basis/math/geometry/rect/rect-docs.factor | 2 ++ 1 file changed, 2 insertions(+) diff --git a/basis/math/geometry/rect/rect-docs.factor b/basis/math/geometry/rect/rect-docs.factor index 0e34ace943..31c9e44b1d 100644 --- a/basis/math/geometry/rect/rect-docs.factor +++ b/basis/math/geometry/rect/rect-docs.factor @@ -63,3 +63,5 @@ ARTICLE: "math.geometry.rect" "Rectangles" { $subsection offset-rect } { $subsection rect-intersect } { $subsection intersects? } ; + +ABOUT: "math.geometry.rect" From 344657b93b59360875ebab60bc5da1d8528f7a72 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 19 Nov 2008 17:13:39 -0600 Subject: [PATCH 023/157] Improve scroll>rect and scroll>caret so that the caret is always visible --- basis/ui/gadgets/editors/editors.factor | 7 ++++--- basis/ui/gadgets/scrollers/scrollers.factor | 10 +++++----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/basis/ui/gadgets/editors/editors.factor b/basis/ui/gadgets/editors/editors.factor index 2cf6d24154..d42df93b72 100644 --- a/basis/ui/gadgets/editors/editors.factor +++ b/basis/ui/gadgets/editors/editors.factor @@ -120,9 +120,10 @@ M: editor ungraft* : scroll>caret ( editor -- ) dup graft-state>> second [ - dup caret-loc over caret-dim - over scroll>rect - ] when drop ; + [ + [ caret-loc ] [ caret-dim { 1 0 } v+ ] bi + ] keep scroll>rect + ] [ drop ] if ; : draw-caret ( -- ) editor get focused?>> [ diff --git a/basis/ui/gadgets/scrollers/scrollers.factor b/basis/ui/gadgets/scrollers/scrollers.factor index d1429c4006..6c37c37acf 100644 --- a/basis/ui/gadgets/scrollers/scrollers.factor +++ b/basis/ui/gadgets/scrollers/scrollers.factor @@ -43,7 +43,7 @@ scroller H{ dup model>> dependencies>> second >>y dup y>> @right grid-add tuck model>> >>viewport - dup viewport>> @center grid-add ; + dup viewport>> @center grid-add ; inline : ( gadget -- scroller ) scroller new-scroller ; @@ -54,18 +54,18 @@ scroller H{ ] keep 2dup control-value = [ 2drop ] [ set-control-value ] if ; -: rect-min ( rect1 rect2 -- rect ) - >r [ rect-loc ] keep r> [ rect-dim ] bi@ vmin ; +: rect-min ( rect dim -- rect' ) + [ [ loc>> ] [ dim>> ] bi ] dip vmin ; : (scroll>rect) ( rect scroller -- ) [ scroller-value vneg offset-rect viewport-gap offset-rect ] keep - [ viewport>> rect-min ] keep + [ viewport>> dim>> rect-min ] keep [ viewport>> 2rect-extent - >r >r v- { 0 0 } vmin r> r> v- { 0 0 } vmax v+ + [ v- { 1 1 } v- { 0 0 } vmin ] [ v- { 0 0 } vmax ] 2bi* v+ ] keep dup scroller-value rot v+ swap scroll ; : relative-scroll-rect ( rect gadget scroller -- newrect ) From eb6cdcc06eb439c7ad67e9511cf8a02f318637ca Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 19 Nov 2008 17:41:39 -0600 Subject: [PATCH 024/157] Fix parser tests --- core/parser/parser-tests.factor | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/parser/parser-tests.factor b/core/parser/parser-tests.factor index c4fa0890f9..d2d407e147 100644 --- a/core/parser/parser-tests.factor +++ b/core/parser/parser-tests.factor @@ -428,7 +428,7 @@ must-fail-with "USE: this-better-not-exist" eval ] must-fail -[ ": foo ;" eval ] [ error>> no-current-vocab? ] must-fail-with +[ ": foo ;" eval ] [ error>> error>> no-current-vocab? ] must-fail-with [ 92 ] [ "CHAR: \\" eval ] unit-test [ 92 ] [ "CHAR: \\\\" eval ] unit-test @@ -483,7 +483,7 @@ must-fail-with [ t ] [ "staging-problem-test-2" "parser.tests" lookup >boolean ] unit-test -[ "DEFER: blah" eval ] [ error>> no-current-vocab? ] must-fail-with +[ "DEFER: blah" eval ] [ error>> error>> no-current-vocab? ] must-fail-with [ "IN: parser.tests : blah ; parsing FORGET: blah" eval From 6e9b2a6c739f911fc721ab017473b1ab8d785a89 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 19 Nov 2008 17:47:12 -0600 Subject: [PATCH 025/157] Make limited scrollers more versatile: they now have a min-dim and a max-dim --- basis/ui/gadgets/scrollers/scrollers.factor | 10 ++++++---- basis/ui/tools/deploy/deploy.factor | 7 +++++-- basis/ui/tools/listener/listener.factor | 4 +++- basis/ui/tools/traceback/traceback.factor | 5 ++++- basis/ui/tools/workspace/workspace.factor | 11 +++++++---- 5 files changed, 25 insertions(+), 12 deletions(-) diff --git a/basis/ui/gadgets/scrollers/scrollers.factor b/basis/ui/gadgets/scrollers/scrollers.factor index 6c37c37acf..045ecc7990 100644 --- a/basis/ui/gadgets/scrollers/scrollers.factor +++ b/basis/ui/gadgets/scrollers/scrollers.factor @@ -129,10 +129,12 @@ M: scroller focusable-child* M: scroller model-changed nip f >>follows drop ; -TUPLE: limited-scroller < scroller fixed-dim ; +TUPLE: limited-scroller < scroller +{ min-dim initial: { 0 0 } } +{ max-dim initial: { 1/0. 1/0. } } ; -: ( gadget dim -- scroller ) - >r limited-scroller new-scroller r> >>fixed-dim ; +: ( gadget -- scroller ) + limited-scroller new-scroller ; M: limited-scroller pref-dim* - fixed-dim>> ; + [ call-next-method ] [ min-dim>> vmax ] [ max-dim>> vmin ] tri ; diff --git a/basis/ui/tools/deploy/deploy.factor b/basis/ui/tools/deploy/deploy.factor index 0ac89e122f..f310f72780 100644 --- a/basis/ui/tools/deploy/deploy.factor +++ b/basis/ui/tools/deploy/deploy.factor @@ -96,9 +96,12 @@ TUPLE: deploy-gadget < pack vocab settings ; : com-close ( gadget -- ) close-window ; +deploy-gadget "misc" "Miscellaneous commands" { + { T{ key-down f f "ESC" } com-close } +} define-command-map + deploy-gadget "toolbar" f { - { f com-close } - { f com-help } + { T{ key-down f f "F1" } com-help } { f com-revert } { f com-save } { T{ key-down f f "RET" } com-deploy } diff --git a/basis/ui/tools/listener/listener.factor b/basis/ui/tools/listener/listener.factor index d842bf8a68..49ce5203d3 100644 --- a/basis/ui/tools/listener/listener.factor +++ b/basis/ui/tools/listener/listener.factor @@ -25,7 +25,9 @@ TUPLE: listener-gadget < track input output stack ; : listener-input, ( listener -- listener ) dup >>input dup input>> - { 0 100 } + + { 0 100 } >>min-dim + { 1/0. 100 } >>max-dim "Input" f track-add ; diff --git a/basis/ui/tools/traceback/traceback.factor b/basis/ui/tools/traceback/traceback.factor index 6cb79916e0..7e2158e0e9 100644 --- a/basis/ui/tools/traceback/traceback.factor +++ b/basis/ui/tools/traceback/traceback.factor @@ -43,7 +43,10 @@ M: traceback-gadget pref-dim* drop { 550 600 } ; ; : ( model -- gadget ) - { 400 400 } ; + + + { 400 400 } >>min-dim + { 400 400 } >>max-dim ; : variables ( traceback -- ) model>> diff --git a/basis/ui/tools/workspace/workspace.factor b/basis/ui/tools/workspace/workspace.factor index bbe4b12712..f06e0aae26 100644 --- a/basis/ui/tools/workspace/workspace.factor +++ b/basis/ui/tools/workspace/workspace.factor @@ -47,12 +47,15 @@ M: gadget tool-scroller drop f ; : get-tool ( class -- gadget ) get-workspace find-tool nip ; +: ( topic -- pane ) + [ [ help ] with-pane ] keep ; + : help-window ( topic -- ) [ - [ [ help ] with-pane ] keep - { 550 700 } - ] keep - article-title open-window ; + + { 550 700 } >>max-dim + ] [ article-title ] bi + open-window ; : hide-popup ( workspace -- ) dup popup>> track-remove From b9e1f5bf8ae2382f5f4b247bd7751452ec4eda2a Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 19 Nov 2008 17:47:25 -0600 Subject: [PATCH 026/157] M: track pref-dim did not take the gap into account --- basis/ui/gadgets/tracks/tracks.factor | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/basis/ui/gadgets/tracks/tracks.factor b/basis/ui/gadgets/tracks/tracks.factor index 5a9683ceff..771c489ce3 100644 --- a/basis/ui/gadgets/tracks/tracks.factor +++ b/basis/ui/gadgets/tracks/tracks.factor @@ -1,8 +1,8 @@ ! Copyright (C) 2006, 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors io kernel math namespaces - sequences words math.vectors ui.gadgets ui.gadgets.packs - math.geometry.rect fry ; +USING: accessors io kernel namespaces fry +math math.vectors math.geometry.rect math.order +sequences words ui.gadgets ui.gadgets.packs ; IN: ui.gadgets.tracks @@ -35,13 +35,16 @@ TUPLE: track < pack sizes ; M: track layout* ( track -- ) dup track-layout pack-layout ; -: track-pref-dims-1 ( track -- dim ) children>> pref-dims max-dim ; +: track-pref-dims-1 ( track -- dim ) + children>> pref-dims max-dim ; : track-pref-dims-2 ( track -- dim ) - [ children>> pref-dims ] [ normalized-sizes ] bi - [ [ v/n ] when* ] 2map - max-dim - [ >fixnum ] map ; + [ + [ children>> pref-dims ] [ normalized-sizes ] bi + [ [ v/n ] when* ] 2map max-dim [ >fixnum ] map + ] + [ [ gap>> ] [ children>> length 1 [-] ] bi v*n ] bi + v+ ; M: track pref-dim* ( gadget -- dim ) [ track-pref-dims-1 ] From 503c0a09710c5b465d6f357e7912b02c44f064eb Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 19 Nov 2008 18:23:19 -0600 Subject: [PATCH 027/157] Add a new cookbook page --- basis/help/cookbook/cookbook.factor | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/basis/help/cookbook/cookbook.factor b/basis/help/cookbook/cookbook.factor index 9fb837a873..6e27bd9256 100644 --- a/basis/help/cookbook/cookbook.factor +++ b/basis/help/cookbook/cookbook.factor @@ -1,5 +1,6 @@ USING: help.markup help.syntax io kernel math namespaces parser -prettyprint sequences vocabs.loader namespaces stack-checker ; +prettyprint sequences vocabs.loader namespaces stack-checker +help ; IN: help.cookbook ARTICLE: "cookbook-syntax" "Basic syntax cookbook" @@ -324,6 +325,19 @@ ARTICLE: "cookbook-pitfalls" "Pitfalls to avoid" { "If " { $link run-file } " throws a stack depth assertion, it means that the top-level form in the file left behind values on the stack. The stack depth is compared before and after loading a source file, since this type of situation is almost always an error. If you have a legitimate need to load a source file which returns data in some manner, define a word in the source file which produces this data on the stack and call the word after loading the file." } } ; +ARTICLE: "cookbook-next" "Next steps" +"Once you have read through " { $link "first-program" } " and " { $link "cookbook" } ", the best way to keep learning Factor is to start looking at some simple example programs. Here are a few particularly nice vocabularies which should keep you busy for a little while:" +{ $list + { $vocab-link "base64" } + { $vocab-link "roman" } + { $vocab-link "rot13" } + { $vocab-link "smtp" } + { $vocab-link "time-server" } + { $vocab-link "tools.hexdump" } + { $vocab-link "webapps.counter" } +} +"If you see code in there that you do not understand, use " { $link see } " and " { $link help } " to explore." ; + ARTICLE: "cookbook" "Factor cookbook" "The Factor cookbook is a high-level overview of the most important concepts required to program in Factor." { $subsection "cookbook-syntax" } @@ -336,6 +350,7 @@ ARTICLE: "cookbook" "Factor cookbook" { $subsection "cookbook-scripts" } { $subsection "cookbook-compiler" } { $subsection "cookbook-philosophy" } -{ $subsection "cookbook-pitfalls" } ; +{ $subsection "cookbook-pitfalls" } +{ $subsection "cookbook-next" } ; ABOUT: "cookbook" From af5e5611dceb9c625ba085ab2f2238e56da3f6ef Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 19 Nov 2008 18:59:30 -0600 Subject: [PATCH 028/157] Better invalid callable check --- basis/prettyprint/backend/backend.factor | 16 +++++++++++++--- basis/prettyprint/prettyprint-tests.factor | 5 +++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/basis/prettyprint/backend/backend.factor b/basis/prettyprint/backend/backend.factor index 31b6ba3f26..2af0224e32 100644 --- a/basis/prettyprint/backend/backend.factor +++ b/basis/prettyprint/backend/backend.factor @@ -217,14 +217,24 @@ M: vector pprint* pprint-object ; M: byte-vector pprint* pprint-object ; M: hashtable pprint* pprint-object ; +GENERIC: valid-callable? ( obj -- ? ) + +M: object valid-callable? drop f ; + +M: quotation valid-callable? drop t ; + +M: curry valid-callable? quot>> valid-callable? ; + +M: compose valid-callable? + [ first>> ] [ second>> ] bi [ valid-callable? ] both? ; + M: curry pprint* - dup quot>> callable? [ pprint-object ] [ + dup valid-callable? [ pprint-object ] [ "( invalid curry )" swap present-text ] if ; M: compose pprint* - dup [ first>> callable? ] [ second>> callable? ] bi and - [ pprint-object ] [ + dup valid-callable? [ pprint-object ] [ "( invalid compose )" swap present-text ] if ; diff --git a/basis/prettyprint/prettyprint-tests.factor b/basis/prettyprint/prettyprint-tests.factor index 8eaaab3c1d..7fa3c5a1a3 100644 --- a/basis/prettyprint/prettyprint-tests.factor +++ b/basis/prettyprint/prettyprint-tests.factor @@ -365,3 +365,8 @@ M: started-out-hustlin' ended-up-ballin' ; inline [ "USING: prettyprint.tests ;\nM: started-out-hustlin' ended-up-ballin' ; inline\n" ] [ [ { started-out-hustlin' ended-up-ballin' } see ] with-string-writer ] unit-test + +[ "( invalid curry )" ] [ 1 2 curry unparse ] unit-test +[ "( invalid curry )" ] [ 1 2 3 curry curry unparse ] unit-test +[ "( invalid compose )" ] [ 1 2 compose unparse ] unit-test +[ "( invalid compose )" ] [ [ 1 ] 2 3 curry compose unparse ] unit-test From e687d179e6b9fa4b1448464cf36b8cf25fd4974f Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 19 Nov 2008 18:59:53 -0600 Subject: [PATCH 029/157] Re-word fry docs slightly --- basis/fry/fry-docs.factor | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/basis/fry/fry-docs.factor b/basis/fry/fry-docs.factor index 286dbb469e..03ac01ad61 100644 --- a/basis/fry/fry-docs.factor +++ b/basis/fry/fry-docs.factor @@ -15,7 +15,7 @@ HELP: fry } ; HELP: '[ -{ $syntax "code... ]" } +{ $syntax "'[ code... ]" } { $description "Literal fried quotation. Expands into code which takes values from the stack and substitutes them in place of the fry specifiers " { $link _ } " and " { $link @ } "." } { $examples "See " { $link "fry.examples" } "." } ; @@ -49,6 +49,8 @@ $nl "{ 8 13 14 27 } [ even? ] 5 [ dup ] swap [ ? ] curry 3compose map" "{ 8 13 14 27 } [ even? dup 5 ? ] map" } +"The following is a no-op:" +{ $code "'[ @ ]" } "Here are some built-in combinators rewritten in terms of fried quotations:" { $table { { $link literalize } { $snippet ": literalize '[ _ ] ;" } } @@ -74,14 +76,14 @@ ARTICLE: "fry.limitations" "Fried quotation limitations" "As with " { $vocab-link "locals" } ", fried quotations cannot contain " { $link >r } " and " { $link r> } ". This is not a real limitation in practice, since " { $link dip } " can be used instead." ; ARTICLE: "fry" "Fried quotations" -"A " { $emphasis "fried quotation" } " differs from a literal quotation in that when it is evaluated, instead of just pushing itself on the stack, it consumes zero or more stack values and inserts them into the quotation." +"The " { $vocab-link "fry" } " vocabulary implements " { $emphasis "fried quotation" } ". Conceptually, fried quotations are quotations with ``holes'' (more formally, " { $emphasis "fry specifiers" } "), and the holes are filled in when the fried quotation is pushed on the stack." $nl -"Fried quotations are denoted with a special parsing word:" +"Fried quotations are started by a special parsing word:" { $subsection POSTPONE: '[ } -"Fried quotations contain zero or more " { $emphasis "fry specifiers" } ":" +"There are two types of fry specifiers; the first can hold a value, and the second ``splices'' a quotation, as if it were inserted without surrounding brackets:" { $subsection _ } { $subsection @ } -"When a fried quotation is being evaluated, values are consumed from the stack and spliced into the quotation from right to left." +"The holes are filled in with the top of stack going in the rightmost hole, the second item on the stack going in the second hole from the right, and so on." { $subsection "fry.examples" } { $subsection "fry.philosophy" } { $subsection "fry.limitations" } From 044d3f06659cdcbfbc550a40f53229deb5098d9c Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 19 Nov 2008 19:06:41 -0600 Subject: [PATCH 030/157] Add another piece of info --- basis/fry/fry-docs.factor | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/basis/fry/fry-docs.factor b/basis/fry/fry-docs.factor index 03ac01ad61..8f402f2e8c 100644 --- a/basis/fry/fry-docs.factor +++ b/basis/fry/fry-docs.factor @@ -87,7 +87,10 @@ $nl { $subsection "fry.examples" } { $subsection "fry.philosophy" } { $subsection "fry.limitations" } -"Quotations can also be fried without using a parsing word:" -{ $subsection fry } ; +"Fry is implemented as a parsing word which reads a quotation and scans for occurrences of " { $link _ } " and " { $link @ } "; these words are not actually executed, and doing so raises an error (this can happen if they're accidentally used outside of a fry)." +$nl +"Fried quotations can also be constructed without using a parsing word; this is useful when meta-programming:" +{ $subsection fry } +"Fried quotations are an abstraction on top of the " { $link "compositional-combinators" } "; their use is encouraged over the combinators, because often the fry form is shorter and clearer than the combinator form." ; ABOUT: "fry" From c75c4efefd73a599485fa3d9963c0ced0b5739a2 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 19 Nov 2008 19:08:12 -0600 Subject: [PATCH 031/157] Add unit test for pack pref-dim bug --- basis/ui/gadgets/labels/labels-tests.factor | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 basis/ui/gadgets/labels/labels-tests.factor diff --git a/basis/ui/gadgets/labels/labels-tests.factor b/basis/ui/gadgets/labels/labels-tests.factor new file mode 100644 index 0000000000..a9b5074e4c --- /dev/null +++ b/basis/ui/gadgets/labels/labels-tests.factor @@ -0,0 +1,9 @@ +USING: accessors tools.test ui.gadgets ui.gadgets.labels ; +IN: ui.gadgets.labels.tests + +[ { 119 14 } ] [ + { 100 14 } >>dim + { 14 14 } >>dim + label-on-right { 5 5 } >>gap + pref-dim +] unit-test From ae2f5e54398575e258b7602798b00b5ba7dc3231 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 19 Nov 2008 19:17:47 -0600 Subject: [PATCH 032/157] Clarify tail-call optimization documentation --- basis/help/handbook/handbook.factor | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/basis/help/handbook/handbook.factor b/basis/help/handbook/handbook.factor index d1d9ca049a..2ed86a0a19 100644 --- a/basis/help/handbook/handbook.factor +++ b/basis/help/handbook/handbook.factor @@ -65,6 +65,11 @@ $nl { "word" { "the basic unit of code, analogous to a function or procedure in other programming languages. See " { $link "words" } } } } ; +ARTICLE: "tail-call-opt" "Tail-call optimization" +"If the last action performed is the execution of a word, the current quotation is not saved on the call stack; this is known as " { $emphasis "tail-call optimization" } " and the Factor implementation guarantees that it will be performed." +$nl +"Tail-call optimization allows iterative algorithms to be implemented in an efficient manner using recursion, without the need for any kind of primitive looping construct in the language. However, in practice, most iteration is performed via combinators such as " { $link while } ", " { $link each } ", " { $link map } ", " { $link assoc-each } ", and so on. The definitions of these combinators do bottom-out in recursive words, however." ; + ARTICLE: "evaluator" "Evaluation semantics" { $link "quotations" } " are evaluated sequentially from beginning to end. When the end is reached, the quotation returns to its caller. As each object in the quotation is evaluated in turn, an action is taken based on its type:" { $list @@ -72,7 +77,7 @@ ARTICLE: "evaluator" "Evaluation semantics" { "a " { $link wrapper } " - the wrapped object is pushed on the data stack. Wrappers are used to push word objects directly on the stack when they would otherwise execute. See the " { $link POSTPONE: \ } " parsing word." } { "All other types of objects are pushed on the data stack." } } -"If the last action performed is the execution of a word, the current quotation is not saved on the call stack; this is known as " { $snippet "tail-recursion" } " and allows iterative algorithms to execute without incurring unbounded call stack usage." +{ $subsection "tail-call-opt" } { $see-also "compiler" } ; ARTICLE: "objects" "Objects" From 3d8f432856044bbd56c2ec18c0dc3aa445397292 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 19 Nov 2008 19:23:11 -0600 Subject: [PATCH 033/157] Clarify math.bitwise -vs- bitwise-arithmetic docs --- basis/math/bitwise/bitwise-docs.factor | 5 +++-- core/math/math-docs.factor | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/basis/math/bitwise/bitwise-docs.factor b/basis/math/bitwise/bitwise-docs.factor index 4f2606bda0..9ed164330b 100644 --- a/basis/math/bitwise/bitwise-docs.factor +++ b/basis/math/bitwise/bitwise-docs.factor @@ -310,8 +310,9 @@ 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:" { $subsection bitfield } ; -ARTICLE: "math.bitwise" "Bitwise arithmetic" -"The " { $vocab-link "math.bitwise" } " vocabulary can implements bitwise arithmetic words that are useful for efficiency, low-level programming, and interfacing with C libraries." $nl +ARTICLE: "math.bitwise" "Additional bitwise arithmetic" +"The " { $vocab-link "math.bitwise" } " vocabulary provides bitwise arithmetic words extending " { $link "bitwise-arithmetic" } ". They are useful for efficiency, low-level programming, and interfacing with C libraries." +$nl "Setting and clearing bits:" { $subsection set-bit } { $subsection clear-bit } diff --git a/core/math/math-docs.factor b/core/math/math-docs.factor index 20b4e0bbbe..aca43add5c 100644 --- a/core/math/math-docs.factor +++ b/core/math/math-docs.factor @@ -348,6 +348,7 @@ ARTICLE: "bitwise-arithmetic" "Bitwise arithmetic" { $subsection 2/ } { $subsection 2^ } { $subsection bit? } +"The " { $vocab-link "math.bitwise" } " vocabulary implements additional bitwise integer operations." { $see-also "conditionals" } ; ARTICLE: "arithmetic" "Arithmetic" From d6264a32ce82a1bfb427d92a36cec5de0929c7f6 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 19 Nov 2008 19:43:11 -0600 Subject: [PATCH 034/157] Better values docs --- basis/values/values-docs.factor | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/basis/values/values-docs.factor b/basis/values/values-docs.factor index 69e2801110..866af469e9 100644 --- a/basis/values/values-docs.factor +++ b/basis/values/values-docs.factor @@ -2,7 +2,7 @@ USING: help.markup help.syntax ; IN: values ARTICLE: "values" "Global values" -"Usually, dynamically scoped variables are sufficient for holding data which is not literal. But occasionally, for global information that's calculated just once, it's useful to use the word mechanism instead, and set the word to the appropriate value just once. Values abstract over this concept. To create a new word as a value, use the following syntax:" +"Usually, dynamically scoped variables are sufficient for holding data which is not literal. But occasionally, for global information that's calculated just once, it's useful to use the word mechanism instead, and set the word to the appropriate value just once. The " { $vocab-link "values" } " vocabulary implements " { $emphasis "values" } ", which abstract over this concept. To create a new word as a value, use the following syntax:" { $subsection POSTPONE: VALUE: } "To get the value, just call the word. The following words manipulate values:" { $subsection get-value } @@ -10,6 +10,8 @@ ARTICLE: "values" "Global values" { $subsection POSTPONE: to: } { $subsection change-value } ; +ABOUT: "values" + HELP: VALUE: { $syntax "VALUE: word" } { $values { "word" "a word to be created" } } From a100968f030fc1d67fa69c22f69045182c11974e Mon Sep 17 00:00:00 2001 From: Eduardo Cavazos Date: Wed, 19 Nov 2008 20:32:28 -0600 Subject: [PATCH 035/157] boids: another indentation fix --- extra/boids/boids.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extra/boids/boids.factor b/extra/boids/boids.factor index 3d4cd392ca..097b952db9 100644 --- a/extra/boids/boids.factor +++ b/extra/boids/boids.factor @@ -156,7 +156,7 @@ VAR: separation-radius 2&& ; : alignment-neighborhood ( self -- boids ) -boids> [ within-alignment-neighborhood? ] with filter ; + boids> [ within-alignment-neighborhood? ] with filter ; : alignment-force ( self -- force ) alignment-neighborhood From 10d57d7edda3eab3512df259d2e67656a4a5aaf3 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Wed, 19 Nov 2008 20:48:30 -0600 Subject: [PATCH 036/157] move mime-types to mime.types --- basis/mime/types/authors.txt | 1 + basis/mime/types/mime.types | 988 ++++++++++++++++++ .../types/types-docs.factor} | 8 +- .../types/types-tests.factor} | 4 +- .../types/types.factor} | 4 +- 5 files changed, 997 insertions(+), 8 deletions(-) create mode 100755 basis/mime/types/authors.txt create mode 100644 basis/mime/types/mime.types rename basis/{mime-types/mime-types-docs.factor => mime/types/types-docs.factor} (90%) rename basis/{mime-types/mime-types-tests.factor => mime/types/types-tests.factor} (77%) rename basis/{mime-types/mime-types.factor => mime/types/types.factor} (91%) diff --git a/basis/mime/types/authors.txt b/basis/mime/types/authors.txt new file mode 100755 index 0000000000..1901f27a24 --- /dev/null +++ b/basis/mime/types/authors.txt @@ -0,0 +1 @@ +Slava Pestov diff --git a/basis/mime/types/mime.types b/basis/mime/types/mime.types new file mode 100644 index 0000000000..b602e9dc68 --- /dev/null +++ b/basis/mime/types/mime.types @@ -0,0 +1,988 @@ +# This is a comment. I love comments. + +# This file controls what Internet media types are sent to the client for +# given file extension(s). Sending the correct media type to the client +# is important so they know how to handle the content of the file. +# Extra types can either be added here or by using an AddType directive +# in your config files. For more information about Internet media types, +# please read RFC 2045, 2046, 2047, 2048, and 2077. The Internet media type +# registry is at . + +# MIME type Extensions +application/activemessage +application/andrew-inset ez +application/applefile +application/atom+xml atom +application/atomcat+xml atomcat +application/atomicmail +application/atomsvc+xml atomsvc +application/auth-policy+xml +application/batch-smtp +application/beep+xml +application/cals-1840 +application/ccxml+xml ccxml +application/cellml+xml +application/cnrp+xml +application/commonground +application/conference-info+xml +application/cpl+xml +application/csta+xml +application/cstadata+xml +application/cybercash +application/davmount+xml davmount +application/dca-rft +application/dec-dx +application/dialog-info+xml +application/dicom +application/dns +application/dvcs +application/ecmascript ecma +application/edi-consent +application/edi-x12 +application/edifact +application/epp+xml +application/eshop +application/fastinfoset +application/fastsoap +application/fits +application/font-tdpfr pfr +application/h224 +application/http +application/hyperstudio stk +application/iges +application/im-iscomposing+xml +application/index +application/index.cmd +application/index.obj +application/index.response +application/index.vnd +application/iotp +application/ipp +application/isup +application/javascript js +application/json json +application/kpml-request+xml +application/kpml-response+xml +application/mac-binhex40 hqx +application/mac-compactpro cpt +application/macwriteii +application/marc mrc +application/mathematica ma nb mb +application/mathml+xml mathml +application/mbms-associated-procedure-description+xml +application/mbms-deregister+xml +application/mbms-envelope+xml +application/mbms-msk+xml +application/mbms-msk-response+xml +application/mbms-protection-description+xml +application/mbms-reception-report+xml +application/mbms-register+xml +application/mbms-register-response+xml +application/mbms-user-service-description+xml +application/mbox mbox +application/mediaservercontrol+xml mscml +application/mikey +application/mp4 mp4s +application/mpeg4-generic +application/mpeg4-iod +application/mpeg4-iod-xmt +application/msword doc dot +application/mxf mxf +application/nasdata +application/news-message-id +application/news-transmission +application/nss +application/ocsp-request +application/ocsp-response +application/octet-stream bin dms lha lzh class so iso dmg dist distz pkg bpk dump elc scpt +application/oda oda +application/oebps-package+xml +application/ogg ogg +application/parityfec +application/pdf pdf +application/pgp-encrypted pgp +application/pgp-keys +application/pgp-signature asc sig +application/pics-rules prf +application/pidf+xml +application/pkcs10 p10 +application/pkcs7-mime p7m p7c +application/pkcs7-signature p7s +application/pkix-cert cer +application/pkix-crl crl +application/pkix-pkipath pkipath +application/pkixcmp pki +application/pls+xml pls +application/poc-settings+xml +application/postscript ai eps ps +application/prs.alvestrand.titrax-sheet +application/prs.cww cww +application/prs.nprend +application/prs.plucker +application/qsig +application/rdf+xml rdf +application/reginfo+xml rif +application/relax-ng-compact-syntax rnc +application/remote-printing +application/resource-lists+xml rl +application/riscos +application/rlmi+xml +application/rls-services+xml rs +application/rsd+xml rsd +application/rss+xml rss +application/rtf rtf +application/rtx +application/samlassertion+xml +application/samlmetadata+xml +application/sbml+xml sbml +application/sdp sdp +application/set-payment +application/set-payment-initiation setpay +application/set-registration +application/set-registration-initiation setreg +application/sgml +application/sgml-open-catalog +application/shf+xml shf +application/sieve +application/simple-filter+xml +application/simple-message-summary +application/simplesymbolcontainer +application/slate +application/smil +application/smil+xml smi smil +application/soap+fastinfoset +application/soap+xml +application/spirits-event+xml +application/srgs gram +application/srgs+xml grxml +application/ssml+xml ssml +application/timestamp-query +application/timestamp-reply +application/tve-trigger +application/vemmi +application/vividence.scriptfile +application/vnd.3gpp.bsf+xml +application/vnd.3gpp.pic-bw-large plb +application/vnd.3gpp.pic-bw-small psb +application/vnd.3gpp.pic-bw-var pvb +application/vnd.3gpp.sms +application/vnd.3gpp2.bcmcsinfo+xml +application/vnd.3gpp2.sms +application/vnd.3m.post-it-notes pwn +application/vnd.accpac.simply.aso aso +application/vnd.accpac.simply.imp imp +application/vnd.acucobol acu +application/vnd.acucorp atc acutc +application/vnd.adobe.xdp+xml xdp +application/vnd.adobe.xfdf xfdf +application/vnd.aether.imp +application/vnd.amiga.ami ami +application/vnd.anser-web-certificate-issue-initiation cii +application/vnd.anser-web-funds-transfer-initiation fti +application/vnd.antix.game-component atx +application/vnd.apple.installer+xml mpkg +application/vnd.audiograph aep +application/vnd.autopackage +application/vnd.avistar+xml +application/vnd.blueice.multipass mpm +application/vnd.bmi bmi +application/vnd.businessobjects rep +application/vnd.cab-jscript +application/vnd.canon-cpdl +application/vnd.canon-lips +application/vnd.cendio.thinlinc.clientconf +application/vnd.chemdraw+xml cdxml +application/vnd.chipnuts.karaoke-mmd mmd +application/vnd.cinderella cdy +application/vnd.cirpack.isdn-ext +application/vnd.claymore cla +application/vnd.clonk.c4group c4g c4d c4f c4p c4u +application/vnd.commerce-battelle +application/vnd.commonspace csp cst +application/vnd.contact.cmsg cdbcmsg +application/vnd.cosmocaller cmc +application/vnd.crick.clicker clkx +application/vnd.crick.clicker.keyboard clkk +application/vnd.crick.clicker.palette clkp +application/vnd.crick.clicker.template clkt +application/vnd.crick.clicker.wordbank clkw +application/vnd.criticaltools.wbs+xml wbs +application/vnd.ctc-posml pml +application/vnd.cups-pdf +application/vnd.cups-postscript +application/vnd.cups-ppd ppd +application/vnd.cups-raster +application/vnd.cups-raw +application/vnd.curl curl +application/vnd.cybank +application/vnd.data-vision.rdz rdz +application/vnd.denovo.fcselayout-link fe_launch +application/vnd.dna dna +application/vnd.dolby.mlp mlp +application/vnd.dpgraph dpg +application/vnd.dreamfactory dfac +application/vnd.dvb.esgcontainer +application/vnd.dvb.ipdcesgaccess +application/vnd.dxr +application/vnd.ecdis-update +application/vnd.ecowin.chart mag +application/vnd.ecowin.filerequest +application/vnd.ecowin.fileupdate +application/vnd.ecowin.series +application/vnd.ecowin.seriesrequest +application/vnd.ecowin.seriesupdate +application/vnd.enliven nml +application/vnd.epson.esf esf +application/vnd.epson.msf msf +application/vnd.epson.quickanime qam +application/vnd.epson.salt slt +application/vnd.epson.ssf ssf +application/vnd.ericsson.quickcall +application/vnd.eszigno3+xml es3 et3 +application/vnd.eudora.data +application/vnd.ezpix-album ez2 +application/vnd.ezpix-package ez3 +application/vnd.fdf fdf +application/vnd.ffsns +application/vnd.fints +application/vnd.flographit gph +application/vnd.fluxtime.clip ftc +application/vnd.framemaker fm frame maker +application/vnd.frogans.fnc fnc +application/vnd.frogans.ltf ltf +application/vnd.fsc.weblaunch fsc +application/vnd.fujitsu.oasys oas +application/vnd.fujitsu.oasys2 oa2 +application/vnd.fujitsu.oasys3 oa3 +application/vnd.fujitsu.oasysgp fg5 +application/vnd.fujitsu.oasysprs bh2 +application/vnd.fujixerox.art-ex +application/vnd.fujixerox.art4 +application/vnd.fujixerox.hbpl +application/vnd.fujixerox.ddd ddd +application/vnd.fujixerox.docuworks xdw +application/vnd.fujixerox.docuworks.binder xbd +application/vnd.fut-misnet +application/vnd.fuzzysheet fzs +application/vnd.genomatix.tuxedo txd +application/vnd.google-earth.kml+xml kml +application/vnd.google-earth.kmz kmz +application/vnd.grafeq gqf gqs +application/vnd.gridmp +application/vnd.groove-account gac +application/vnd.groove-help ghf +application/vnd.groove-identity-message gim +application/vnd.groove-injector grv +application/vnd.groove-tool-message gtm +application/vnd.groove-tool-template tpl +application/vnd.groove-vcard vcg +application/vnd.handheld-entertainment+xml zmm +application/vnd.hbci hbci +application/vnd.hcl-bireports +application/vnd.hhe.lesson-player les +application/vnd.hp-hpgl hpgl +application/vnd.hp-hpid hpid +application/vnd.hp-hps hps +application/vnd.hp-jlyt jlt +application/vnd.hp-pcl pcl +application/vnd.hp-pclxl pclxl +application/vnd.httphone +application/vnd.hzn-3d-crossword x3d +application/vnd.ibm.afplinedata +application/vnd.ibm.electronic-media +application/vnd.ibm.minipay mpy +application/vnd.ibm.modcap afp listafp list3820 +application/vnd.ibm.rights-management irm +application/vnd.ibm.secure-container sc +application/vnd.igloader igl +application/vnd.immervision-ivp ivp +application/vnd.immervision-ivu ivu +application/vnd.informedcontrol.rms+xml +application/vnd.intercon.formnet xpw xpx +application/vnd.intertrust.digibox +application/vnd.intertrust.nncp +application/vnd.intu.qbo qbo +application/vnd.intu.qfx qfx +application/vnd.ipunplugged.rcprofile rcprofile +application/vnd.irepository.package+xml irp +application/vnd.is-xpr xpr +application/vnd.jam jam +application/vnd.japannet-directory-service +application/vnd.japannet-jpnstore-wakeup +application/vnd.japannet-payment-wakeup +application/vnd.japannet-registration +application/vnd.japannet-registration-wakeup +application/vnd.japannet-setstore-wakeup +application/vnd.japannet-verification +application/vnd.japannet-verification-wakeup +application/vnd.jcp.javame.midlet-rms rms +application/vnd.jisp jisp +application/vnd.kahootz ktz ktr +application/vnd.kde.karbon karbon +application/vnd.kde.kchart chrt +application/vnd.kde.kformula kfo +application/vnd.kde.kivio flw +application/vnd.kde.kontour kon +application/vnd.kde.kpresenter kpr kpt +application/vnd.kde.kspread ksp +application/vnd.kde.kword kwd kwt +application/vnd.kenameaapp htke +application/vnd.kidspiration kia +application/vnd.kinar kne knp +application/vnd.koan skp skd skt skm +application/vnd.liberty-request+xml +application/vnd.llamagraphics.life-balance.desktop lbd +application/vnd.llamagraphics.life-balance.exchange+xml lbe +application/vnd.lotus-1-2-3 123 +application/vnd.lotus-approach apr +application/vnd.lotus-freelance pre +application/vnd.lotus-notes nsf +application/vnd.lotus-organizer org +application/vnd.lotus-screencam scm +application/vnd.lotus-wordpro lwp +application/vnd.macports.portpkg portpkg +application/vnd.marlin.drm.actiontoken+xml +application/vnd.marlin.drm.conftoken+xml +application/vnd.marlin.drm.mdcf +application/vnd.mcd mcd +application/vnd.medcalcdata mc1 +application/vnd.mediastation.cdkey cdkey +application/vnd.meridian-slingshot +application/vnd.mfer mwf +application/vnd.mfmp mfm +application/vnd.micrografx.flo flo +application/vnd.micrografx.igx igx +application/vnd.mif mif +application/vnd.minisoft-hp3000-save +application/vnd.mitsubishi.misty-guard.trustweb +application/vnd.mobius.daf daf +application/vnd.mobius.dis dis +application/vnd.mobius.mbk mbk +application/vnd.mobius.mqy mqy +application/vnd.mobius.msl msl +application/vnd.mobius.plc plc +application/vnd.mobius.txf txf +application/vnd.mophun.application mpn +application/vnd.mophun.certificate mpc +application/vnd.motorola.flexsuite +application/vnd.motorola.flexsuite.adsi +application/vnd.motorola.flexsuite.fis +application/vnd.motorola.flexsuite.gotap +application/vnd.motorola.flexsuite.kmr +application/vnd.motorola.flexsuite.ttc +application/vnd.motorola.flexsuite.wem +application/vnd.mozilla.xul+xml xul +application/vnd.ms-artgalry cil +application/vnd.ms-asf asf +application/vnd.ms-cab-compressed cab +application/vnd.ms-excel xls xlm xla xlc xlt xlw +application/vnd.ms-fontobject eot +application/vnd.ms-htmlhelp chm +application/vnd.ms-ims ims +application/vnd.ms-lrm lrm +application/vnd.ms-playready.initiator+xml +application/vnd.ms-powerpoint ppt pps pot +application/vnd.ms-project mpp mpt +application/vnd.ms-tnef +application/vnd.ms-wmdrm.lic-chlg-req +application/vnd.ms-wmdrm.lic-resp +application/vnd.ms-wmdrm.meter-chlg-req +application/vnd.ms-wmdrm.meter-resp +application/vnd.ms-works wps wks wcm wdb +application/vnd.ms-wpl wpl +application/vnd.ms-xpsdocument xps +application/vnd.mseq mseq +application/vnd.msign +application/vnd.music-niff +application/vnd.musician mus +application/vnd.ncd.control +application/vnd.nervana +application/vnd.netfpx +application/vnd.neurolanguage.nlu nlu +application/vnd.noblenet-directory nnd +application/vnd.noblenet-sealer nns +application/vnd.noblenet-web nnw +application/vnd.nokia.catalogs +application/vnd.nokia.conml+wbxml +application/vnd.nokia.conml+xml +application/vnd.nokia.isds-radio-presets +application/vnd.nokia.iptv.config+xml +application/vnd.nokia.landmark+wbxml +application/vnd.nokia.landmark+xml +application/vnd.nokia.landmarkcollection+xml +application/vnd.nokia.n-gage.ac+xml +application/vnd.nokia.n-gage.data ngdat +application/vnd.nokia.n-gage.symbian.install n-gage +application/vnd.nokia.ncd +application/vnd.nokia.pcd+wbxml +application/vnd.nokia.pcd+xml +application/vnd.nokia.radio-preset rpst +application/vnd.nokia.radio-presets rpss +application/vnd.novadigm.edm edm +application/vnd.novadigm.edx edx +application/vnd.novadigm.ext ext +application/vnd.oasis.opendocument.chart odc +application/vnd.oasis.opendocument.chart-template otc +application/vnd.oasis.opendocument.formula odf +application/vnd.oasis.opendocument.formula-template otf +application/vnd.oasis.opendocument.graphics odg +application/vnd.oasis.opendocument.graphics-template otg +application/vnd.oasis.opendocument.image odi +application/vnd.oasis.opendocument.image-template oti +application/vnd.oasis.opendocument.presentation odp +application/vnd.oasis.opendocument.presentation-template otp +application/vnd.oasis.opendocument.spreadsheet ods +application/vnd.oasis.opendocument.spreadsheet-template ots +application/vnd.oasis.opendocument.text odt +application/vnd.oasis.opendocument.text-master otm +application/vnd.oasis.opendocument.text-template ott +application/vnd.oasis.opendocument.text-web oth +application/vnd.obn +application/vnd.olpc-sugar xo +application/vnd.oma-scws-config +application/vnd.oma-scws-http-request +application/vnd.oma-scws-http-response +application/vnd.oma.bcast.associated-procedure-parameter+xml +application/vnd.oma.bcast.drm-trigger+xml +application/vnd.oma.bcast.imd+xml +application/vnd.oma.bcast.notification+xml +application/vnd.oma.bcast.sgboot +application/vnd.oma.bcast.sgdd+xml +application/vnd.oma.bcast.sgdu +application/vnd.oma.bcast.simple-symbol-container +application/vnd.oma.bcast.smartcard-trigger+xml +application/vnd.oma.bcast.sprov+xml +application/vnd.oma.dd2+xml dd2 +application/vnd.oma.drm.risd+xml +application/vnd.oma.group-usage-list+xml +application/vnd.oma.poc.groups+xml +application/vnd.oma.xcap-directory+xml +application/vnd.omads-email+xml +application/vnd.omads-file+xml +application/vnd.omads-folder+xml +application/vnd.omaloc-supl-init +application/vnd.openofficeorg.extension oxt +application/vnd.osa.netdeploy +application/vnd.osgi.dp dp +application/vnd.otps.ct-kip+xml +application/vnd.palm prc pdb pqa oprc +application/vnd.paos.xml +application/vnd.pg.format str +application/vnd.pg.osasli ei6 +application/vnd.piaccess.application-licence +application/vnd.picsel efif +application/vnd.poc.group-advertisement+xml +application/vnd.pocketlearn plf +application/vnd.powerbuilder6 pbd +application/vnd.powerbuilder6-s +application/vnd.powerbuilder7 +application/vnd.powerbuilder7-s +application/vnd.powerbuilder75 +application/vnd.powerbuilder75-s +application/vnd.preminet +application/vnd.previewsystems.box box +application/vnd.proteus.magazine mgz +application/vnd.publishare-delta-tree qps +application/vnd.pvi.ptid1 ptid +application/vnd.pwg-multiplexed +application/vnd.pwg-xhtml-print+xml +application/vnd.qualcomm.brew-app-res +application/vnd.quark.quarkxpress qxd qxt qwd qwt qxl qxb +application/vnd.rapid +application/vnd.recordare.musicxml mxl +application/vnd.recordare.musicxml+xml +application/vnd.renlearn.rlprint +application/vnd.rn-realmedia rm +application/vnd.ruckus.download +application/vnd.s3sms +application/vnd.scribus +application/vnd.sealed.3df +application/vnd.sealed.csf +application/vnd.sealed.doc +application/vnd.sealed.eml +application/vnd.sealed.mht +application/vnd.sealed.net +application/vnd.sealed.ppt +application/vnd.sealed.tiff +application/vnd.sealed.xls +application/vnd.sealedmedia.softseal.html +application/vnd.sealedmedia.softseal.pdf +application/vnd.seemail see +application/vnd.sema sema +application/vnd.semd semd +application/vnd.semf semf +application/vnd.shana.informed.formdata ifm +application/vnd.shana.informed.formtemplate itp +application/vnd.shana.informed.interchange iif +application/vnd.shana.informed.package ipk +application/vnd.simtech-mindmapper twd twds +application/vnd.smaf mmf +application/vnd.solent.sdkm+xml sdkm sdkd +application/vnd.spotfire.dxp dxp +application/vnd.spotfire.sfs sfs +application/vnd.sss-cod +application/vnd.sss-dtf +application/vnd.sss-ntf +application/vnd.street-stream +application/vnd.sun.wadl+xml +application/vnd.sus-calendar sus susp +application/vnd.svd svd +application/vnd.swiftview-ics +application/vnd.syncml+xml xsm +application/vnd.syncml.dm+wbxml bdm +application/vnd.syncml.dm+xml xdm +application/vnd.syncml.ds.notification +application/vnd.tao.intent-module-archive tao +application/vnd.tmobile-livetv tmo +application/vnd.trid.tpt tpt +application/vnd.triscape.mxs mxs +application/vnd.trueapp tra +application/vnd.truedoc +application/vnd.ufdl ufd ufdl +application/vnd.uiq.theme utz +application/vnd.umajin umj +application/vnd.unity unityweb +application/vnd.uoml+xml uoml +application/vnd.uplanet.alert +application/vnd.uplanet.alert-wbxml +application/vnd.uplanet.bearer-choice +application/vnd.uplanet.bearer-choice-wbxml +application/vnd.uplanet.cacheop +application/vnd.uplanet.cacheop-wbxml +application/vnd.uplanet.channel +application/vnd.uplanet.channel-wbxml +application/vnd.uplanet.list +application/vnd.uplanet.list-wbxml +application/vnd.uplanet.listcmd +application/vnd.uplanet.listcmd-wbxml +application/vnd.uplanet.signal +application/vnd.vcx vcx +application/vnd.vd-study +application/vnd.vectorworks +application/vnd.vidsoft.vidconference +application/vnd.visio vsd vst vss vsw +application/vnd.visionary vis +application/vnd.vividence.scriptfile +application/vnd.vsf vsf +application/vnd.wap.sic +application/vnd.wap.slc +application/vnd.wap.wbxml wbxml +application/vnd.wap.wmlc wmlc +application/vnd.wap.wmlscriptc wmlsc +application/vnd.webturbo wtb +application/vnd.wfa.wsc +application/vnd.wordperfect wpd +application/vnd.wqd wqd +application/vnd.wrq-hp3000-labelled +application/vnd.wt.stf stf +application/vnd.wv.csp+wbxml +application/vnd.wv.csp+xml +application/vnd.wv.ssp+xml +application/vnd.xara xar +application/vnd.xfdl xfdl +application/vnd.xmpie.cpkg +application/vnd.xmpie.dpkg +application/vnd.xmpie.plan +application/vnd.xmpie.ppkg +application/vnd.xmpie.xlim +application/vnd.yamaha.hv-dic hvd +application/vnd.yamaha.hv-script hvs +application/vnd.yamaha.hv-voice hvp +application/vnd.yamaha.smaf-audio saf +application/vnd.yamaha.smaf-phrase spf +application/vnd.yellowriver-custom-menu cmp +application/vnd.zzazz.deck+xml zaz +application/voicexml+xml vxml +application/watcherinfo+xml +application/whoispp-query +application/whoispp-response +application/winhlp hlp +application/wita +application/wordperfect5.1 +application/wsdl+xml wsdl +application/wspolicy+xml wspolicy +application/x-ace-compressed ace +application/x-bcpio bcpio +application/x-bittorrent torrent +application/x-bzip bz +application/x-bzip2 bz2 boz +application/x-cdlink vcd +application/x-chat chat +application/x-chess-pgn pgn +application/x-compress +application/x-cpio cpio +application/x-csh csh +application/x-director dcr dir dxr fgd +application/x-dvi dvi +application/x-futuresplash spl +application/x-gtar gtar +application/x-gzip +application/x-hdf hdf +application/x-java-jnlp-file jnlp +application/x-latex latex +application/x-ms-wmd wmd +application/x-ms-wmz wmz +application/x-msaccess mdb +application/x-msbinder obd +application/x-mscardfile crd +application/x-msclip clp +application/x-msdownload exe dll com bat msi +application/x-msmediaview mvb m13 m14 +application/x-msmetafile wmf +application/x-msmoney mny +application/x-mspublisher pub +application/x-msschedule scd +application/x-msterminal trm +application/x-mswrite wri +application/x-netcdf nc cdf +application/x-pkcs12 p12 pfx +application/x-pkcs7-certificates p7b spc +application/x-pkcs7-certreqresp p7r +application/x-rar-compressed rar +application/x-sh sh +application/x-shar shar +application/x-shockwave-flash swf +application/x-stuffit sit +application/x-stuffitx sitx +application/x-sv4cpio sv4cpio +application/x-sv4crc sv4crc +application/x-tar tar +application/x-tcl tcl +application/x-tex tex +application/x-texinfo texinfo texi +application/x-ustar ustar +application/x-wais-source src +application/x-x509-ca-cert der crt +application/x400-bp +application/xcap-att+xml +application/xcap-caps+xml +application/xcap-el+xml +application/xcap-error+xml +application/xcap-ns+xml +application/xenc+xml xenc +application/xhtml+xml xhtml xht +application/xml xml xsl +application/xml-dtd dtd +application/xml-external-parsed-entity +application/xmpp+xml +application/xop+xml xop +application/xslt+xml xslt +application/xspf+xml xspf +application/xv+xml mxml xhvml xvml xvm +application/zip zip +audio/32kadpcm +audio/3gpp +audio/3gpp2 +audio/ac3 +audio/amr +audio/amr-wb +audio/amr-wb+ +audio/asc +audio/basic au snd +audio/bv16 +audio/bv32 +audio/clearmode +audio/cn +audio/dat12 +audio/dls +audio/dsr-es201108 +audio/dsr-es202050 +audio/dsr-es202211 +audio/dsr-es202212 +audio/dvi4 +audio/eac3 +audio/evrc +audio/evrc-qcp +audio/evrc0 +audio/evrc1 +audio/evrcb +audio/evrcb0 +audio/evrcb1 +audio/g722 +audio/g7221 +audio/g723 +audio/g726-16 +audio/g726-24 +audio/g726-32 +audio/g726-40 +audio/g728 +audio/g729 +audio/g7291 +audio/g729d +audio/g729e +audio/gsm +audio/gsm-efr +audio/ilbc +audio/l16 +audio/l20 +audio/l24 +audio/l8 +audio/lpc +audio/midi mid midi kar rmi +audio/mobile-xmf +audio/mp4 mp4a +audio/mp4a-latm m4a m4p +audio/mpa +audio/mpa-robust +audio/mpeg mpga mp2 mp2a mp3 m2a m3a +audio/mpeg4-generic +audio/parityfec +audio/pcma +audio/pcmu +audio/prs.sid +audio/qcelp +audio/red +audio/rtp-enc-aescm128 +audio/rtp-midi +audio/rtx +audio/smv +audio/smv0 +audio/smv-qcp +audio/sp-midi +audio/t140c +audio/t38 +audio/telephone-event +audio/tone +audio/vdvi +audio/vmr-wb +audio/vnd.3gpp.iufp +audio/vnd.4sb +audio/vnd.audiokoz +audio/vnd.celp +audio/vnd.cisco.nse +audio/vnd.cmles.radio-events +audio/vnd.cns.anp1 +audio/vnd.cns.inf1 +audio/vnd.digital-winds eol +audio/vnd.dlna.adts +audio/vnd.dolby.mlp +audio/vnd.everad.plj +audio/vnd.hns.audio +audio/vnd.lucent.voice lvp +audio/vnd.nokia.mobile-xmf +audio/vnd.nortel.vbk +audio/vnd.nuera.ecelp4800 ecelp4800 +audio/vnd.nuera.ecelp7470 ecelp7470 +audio/vnd.nuera.ecelp9600 ecelp9600 +audio/vnd.octel.sbc +audio/vnd.qcelp +audio/vnd.rhetorex.32kadpcm +audio/vnd.sealedmedia.softseal.mpeg +audio/vnd.vmx.cvsd +audio/wav wav +audio/x-aiff aif aiff aifc +audio/x-mpegurl m3u +audio/x-ms-wax wax +audio/x-ms-wma wma +audio/x-pn-realaudio ram ra +audio/x-pn-realaudio-plugin rmp +audio/x-wav wav +chemical/x-cdx cdx +chemical/x-cif cif +chemical/x-cmdf cmdf +chemical/x-cml cml +chemical/x-csml csml +chemical/x-pdb pdb +chemical/x-xyz xyz +image/bmp bmp +image/cgm cgm +image/fits +image/g3fax g3 +image/gif gif +image/ief ief +image/jp2 jp2 +image/jpeg jpeg jpg jpe +image/jpm +image/jpx +image/naplps +image/pict pict pic pct +image/png png +image/prs.btif btif +image/prs.pti +image/svg+xml svg svgz +image/t38 +image/tiff tiff tif +image/tiff-fx +image/vnd.adobe.photoshop psd +image/vnd.cns.inf2 +image/vnd.djvu djvu djv +image/vnd.dwg dwg +image/vnd.dxf dxf +image/vnd.fastbidsheet fbs +image/vnd.fpx fpx +image/vnd.fst fst +image/vnd.fujixerox.edmics-mmr mmr +image/vnd.fujixerox.edmics-rlc rlc +image/vnd.globalgraphics.pgb +image/vnd.microsoft.icon ico +image/vnd.mix +image/vnd.ms-modi mdi +image/vnd.net-fpx npx +image/vnd.sealed.png +image/vnd.sealedmedia.softseal.gif +image/vnd.sealedmedia.softseal.jpg +image/vnd.svf +image/vnd.wap.wbmp wbmp +image/vnd.xiff xif +image/x-cmu-raster ras +image/x-cmx cmx +image/x-icon +image/x-macpaint pntg pnt mac +image/x-pcx pcx +image/x-pict pic pct +image/x-portable-anymap pnm +image/x-portable-bitmap pbm +image/x-portable-graymap pgm +image/x-portable-pixmap ppm +image/x-quicktime qtif qti +image/x-rgb rgb +image/x-xbitmap xbm +image/x-xpixmap xpm +image/x-xwindowdump xwd +message/cpim +message/delivery-status +message/disposition-notification +message/external-body +message/http +message/news +message/partial +message/rfc822 eml mime +message/s-http +message/sip +message/sipfrag +message/tracking-status +model/iges igs iges +model/mesh msh mesh silo +model/vnd.dwf dwf +model/vnd.flatland.3dml +model/vnd.gdl gdl +model/vnd.gs.gdl +model/vnd.gtw gtw +model/vnd.moml+xml +model/vnd.mts mts +model/vnd.parasolid.transmit.binary +model/vnd.parasolid.transmit.text +model/vnd.vtu vtu +model/vrml wrl vrml +multipart/alternative +multipart/appledouble +multipart/byteranges +multipart/digest +multipart/encrypted +multipart/form-data +multipart/header-set +multipart/mixed +multipart/parallel +multipart/related +multipart/report +multipart/signed +multipart/voice-message +text/calendar ics ifb +text/css css +text/csv csv +text/directory +text/dns +text/enriched +text/html html htm +text/parityfec +text/plain txt text conf def list log in +text/prs.fallenstein.rst +text/prs.lines.tag dsc +text/red +text/rfc822-headers +text/richtext rtx +text/rtf +text/rtp-enc-aescm128 +text/rtx +text/sgml sgml sgm +text/t140 +text/tab-separated-values tsv +text/troff t tr roff man me ms +text/uri-list uri uris urls +text/vnd.abc +text/vnd.curl +text/vnd.dmclientscript +text/vnd.esmertec.theme-descriptor +text/vnd.fly fly +text/vnd.fmi.flexstor flx +text/vnd.in3d.3dml 3dml +text/vnd.in3d.spot spot +text/vnd.iptc.newsml +text/vnd.iptc.nitf +text/vnd.latex-z +text/vnd.motorola.reflex +text/vnd.ms-mediapackage +text/vnd.net2phone.commcenter.command +text/vnd.sun.j2me.app-descriptor jad +text/vnd.trolltech.linguist +text/vnd.wap.si +text/vnd.wap.sl +text/vnd.wap.wml wml +text/vnd.wap.wmlscript wmls +text/x-asm s asm +text/x-c c cc cxx cpp h hh dic +text/x-fortran f for f77 f90 +text/x-pascal p pas +text/x-java-source java +text/x-setext etx +text/x-uuencode uu +text/x-vcalendar vcs +text/x-vcard vcf +text/xml +text/xml-external-parsed-entity +video/3gpp 3gp +video/3gpp-tt +video/3gpp2 3g2 +video/bmpeg +video/bt656 +video/celb +video/dv +video/h261 h261 +video/h263 h263 +video/h263-1998 +video/h263-2000 +video/h264 h264 +video/jpeg jpgv +video/jpm jpm jpgm +video/mj2 mj2 mjp2 +video/mp1s +video/mp2p +video/mp2t +video/mp4 mp4 mp4v mpg4 m4v +video/mp4v-es +video/mpeg mpeg mpg mpe m1v m2v +video/mpeg4-generic +video/mpv +video/nv +video/parityfec +video/pointer +video/quicktime qt mov +video/raw +video/rtp-enc-aescm128 +video/rtx +video/smpte292m +video/vc1 +video/vnd.dlna.mpeg-tts +video/vnd.fvt fvt +video/vnd.hns.video +video/vnd.motorola.video +video/vnd.motorola.videop +video/vnd.mpegurl mxu m4u +video/vnd.nokia.interleaved-multimedia +video/vnd.nokia.videovoip +video/vnd.objectvideo +video/vnd.sealed.mpeg1 +video/vnd.sealed.mpeg4 +video/vnd.sealed.swf +video/vnd.sealedmedia.softseal.mov +video/vnd.vivo viv +video/x-dv dv dif +video/x-fli fli +video/x-ms-asf asf asx +video/x-ms-wm wm +video/x-ms-wmv wmv +video/x-ms-wmx wmx +video/x-ms-wvx wvx +video/x-msvideo avi +video/x-sgi-movie movie +x-conference/x-cooltalk ice diff --git a/basis/mime-types/mime-types-docs.factor b/basis/mime/types/types-docs.factor similarity index 90% rename from basis/mime-types/mime-types-docs.factor rename to basis/mime/types/types-docs.factor index b7fa46d587..fc14227e2d 100644 --- a/basis/mime-types/mime-types-docs.factor +++ b/basis/mime/types/types-docs.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. USING: assocs help.markup help.syntax io.streams.string sequences ; -IN: mime-types +IN: mime.types HELP: mime-db { $values @@ -27,9 +27,9 @@ HELP: nonstandard-mime-types { "assoc" assoc } } { $description "A list of Factor-specific MIME types that are added to the MIME database loaded from disk." } ; -ARTICLE: "mime-types" "MIME types" -"The " { $vocab-link "mime-types" } " vocabulary loads a file of MIME types and provides a word to look up the MIME type based on a file extension." $nl +ARTICLE: "mime.types" "MIME types" +"The " { $vocab-link "mime.types" } " vocabulary loads a file of MIME types and provides a word to look up the MIME type based on a file extension." $nl "Looking up a MIME type:" { $subsection mime-type } ; -ABOUT: "mime-types" +ABOUT: "mime.types" diff --git a/basis/mime-types/mime-types-tests.factor b/basis/mime/types/types-tests.factor similarity index 77% rename from basis/mime-types/mime-types-tests.factor rename to basis/mime/types/types-tests.factor index 925eca2e9d..63535afa9a 100644 --- a/basis/mime-types/mime-types-tests.factor +++ b/basis/mime/types/types-tests.factor @@ -1,5 +1,5 @@ -IN: mime-types.tests -USING: mime-types tools.test ; +IN: mime.types.tests +USING: mime.types tools.test ; [ "application/postscript" ] [ "foo.ps" mime-type ] unit-test [ "application/octet-stream" ] [ "foo.ps.gz" mime-type ] unit-test diff --git a/basis/mime-types/mime-types.factor b/basis/mime/types/types.factor similarity index 91% rename from basis/mime-types/mime-types.factor rename to basis/mime/types/types.factor index 909f762c50..bb0d674f23 100644 --- a/basis/mime-types/mime-types.factor +++ b/basis/mime/types/types.factor @@ -2,10 +2,10 @@ ! See http://factorcode.org/license.txt for BSD license. USING: io.files io.encodings.ascii assocs sequences splitting kernel namespaces fry memoize ; -IN: mime-types +IN: mime.types MEMO: mime-db ( -- seq ) - "resource:basis/mime-types/mime.types" ascii file-lines + "resource:basis/mime/types/mime.types" ascii file-lines [ "#" head? not ] filter [ " \t" split harvest ] map harvest ; : nonstandard-mime-types ( -- assoc ) From 825ad4e59de9bb6a2afea502850c9e7590bfb33f Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 19 Nov 2008 21:02:21 -0600 Subject: [PATCH 037/157] Remove unmaintained/io/ since basis/io/ now has all of the features from the old I/O library --- unmaintained/io/load.factor | 24 ------- unmaintained/io/os-unix-shell.factor | 46 ------------- unmaintained/io/os-unix.factor | 24 ------- unmaintained/io/os-winnt-shell.factor | 55 --------------- unmaintained/io/os-winnt.factor | 96 --------------------------- unmaintained/io/shell.factor | 40 ----------- unmaintained/io/test/io.factor | 42 ------------ unmaintained/io/test/mmap.factor | 21 ------ 8 files changed, 348 deletions(-) delete mode 100644 unmaintained/io/load.factor delete mode 100644 unmaintained/io/os-unix-shell.factor delete mode 100644 unmaintained/io/os-unix.factor delete mode 100644 unmaintained/io/os-winnt-shell.factor delete mode 100644 unmaintained/io/os-winnt.factor delete mode 100644 unmaintained/io/shell.factor delete mode 100644 unmaintained/io/test/io.factor delete mode 100644 unmaintained/io/test/mmap.factor diff --git a/unmaintained/io/load.factor b/unmaintained/io/load.factor deleted file mode 100644 index ac9b9542c5..0000000000 --- a/unmaintained/io/load.factor +++ /dev/null @@ -1,24 +0,0 @@ -USING: kernel ; - -REQUIRES: libs/calendar libs/shuffle ; - -PROVIDE: libs/io -{ +files+ { - "io.factor" - "mmap.factor" - "shell.factor" - { "os-unix.factor" [ unix? ] } - { "os-unix-shell.factor" [ unix? ] } - { "mmap-os-unix.factor" [ unix? ] } - - { "os-winnt.factor" [ winnt? ] } - { "os-winnt-shell.factor" [ winnt? ] } - { "mmap-os-winnt.factor" [ winnt? ] } - - { "os-wince.factor" [ wince? ] } -} } -{ +tests+ { - "test/io.factor" - "test/mmap.factor" -} } ; - diff --git a/unmaintained/io/os-unix-shell.factor b/unmaintained/io/os-unix-shell.factor deleted file mode 100644 index 6c3919ddb2..0000000000 --- a/unmaintained/io/os-unix-shell.factor +++ /dev/null @@ -1,46 +0,0 @@ -USING: arrays kernel libs-io sequences prettyprint unix-internals -calendar namespaces math ; -USE: io -IN: shell - -TUPLE: unix-shell ; - -T{ unix-shell } \ shell set-global - -TUPLE: file name mode nlink uid gid size mtime symbol ; - -M: unix-shell directory* ( path -- seq ) - dup (directory) [ tuck >r "/" r> 3append stat* 2array ] map-with ; - -M: unix-shell make-file ( path -- file ) - first2 - [ stat-mode ] keep - [ stat-nlink ] keep - [ stat-uid ] keep - [ stat-gid ] keep - [ stat-size ] keep - [ stat-mtime timespec>timestamp >local-time ] keep - stat-mode mode>symbol ; - -M: unix-shell file. ( file -- ) - [ [ file-mode >oct write ] keep ] with-cell - [ bl ] with-cell - [ [ file-nlink unparse write ] keep ] with-cell - [ bl ] with-cell - [ [ file-uid unparse write ] keep ] with-cell - [ bl ] with-cell - [ [ file-gid unparse write ] keep ] with-cell - [ bl ] with-cell - [ [ file-size unparse write ] keep ] with-cell - [ bl ] with-cell - [ [ file-mtime file-time-string write ] keep ] with-cell - [ bl ] with-cell - [ file-name write ] with-cell ; - -USE: unix-internals -M: unix-shell touch-file ( path -- ) - dup open-append dup -1 = [ - drop now dup set-file-times - ] [ - nip [ now dup set-file-times* ] keep close - ] if ; diff --git a/unmaintained/io/os-unix.factor b/unmaintained/io/os-unix.factor deleted file mode 100644 index 280908b406..0000000000 --- a/unmaintained/io/os-unix.factor +++ /dev/null @@ -1,24 +0,0 @@ -! Copyright (C) 2007 Doug Coleman. -! See http://factorcode.org/license.txt for BSD license. -USING: alien arrays calendar errors io io-internals kernel -math nonblocking-io sequences unix-internals unix-io ; -IN: libs-io - -: O_APPEND HEX: 100 ; inline -: O_EXCL HEX: 800 ; inline -: SEEK_SET 0 ; inline -: SEEK_CUR 1 ; inline -: SEEK_END 2 ; inline -: EEXIST 17 ; inline - -: mode>symbol ( mode -- ch ) - S_IFMT bitand - { - { [ dup S_IFDIR = ] [ drop "/" ] } - { [ dup S_IFIFO = ] [ drop "|" ] } - { [ dup S_IXUSR = ] [ drop "*" ] } - { [ dup S_IFLNK = ] [ drop "@" ] } - { [ dup S_IFWHT = ] [ drop "%" ] } - { [ dup S_IFSOCK = ] [ drop "=" ] } - { [ t ] [ drop "" ] } - } cond ; diff --git a/unmaintained/io/os-winnt-shell.factor b/unmaintained/io/os-winnt-shell.factor deleted file mode 100644 index a2be22daf8..0000000000 --- a/unmaintained/io/os-winnt-shell.factor +++ /dev/null @@ -1,55 +0,0 @@ -USING: alien calendar io io-internals kernel libs-io math -namespaces prettyprint sequences windows-api ; -IN: shell - -TUPLE: winnt-shell ; - -T{ winnt-shell } \ shell set-global - -TUPLE: file name size mtime attributes ; - -: ((directory*)) ( handle -- ) - "WIN32_FIND_DATA" [ FindNextFile ] 2keep - rot zero? [ 2drop ] [ , ((directory*)) ] if ; - -: (directory*) ( path -- ) - "WIN32_FIND_DATA" [ - FindFirstFile dup INVALID_HANDLE_VALUE = [ - win32-error - ] when - ] keep , - [ ((directory*)) ] keep FindClose win32-error=0/f ; - -: append-star ( path -- path ) - dup peek CHAR: \\ = "*" "\\*" ? append ; - -M: winnt-shell directory* ( path -- seq ) - normalize-pathname append-star [ (directory*) ] { } make ; - -: WIN32_FIND_DATA>file-size ( WIN32_FILE_ATTRIBUTE_DATA -- n ) - [ WIN32_FIND_DATA-nFileSizeLow ] keep - WIN32_FIND_DATA-nFileSizeHigh 32 shift + ; - -M: winnt-shell make-file ( WIN32_FIND_DATA -- file ) - [ WIN32_FIND_DATA-cFileName alien>u16-string ] keep - [ WIN32_FIND_DATA>file-size ] keep - [ - WIN32_FIND_DATA-ftCreationTime - FILETIME>timestamp >local-time - ] keep - WIN32_FIND_DATA-dwFileAttributes ; - -M: winnt-shell file. ( file -- ) - [ [ file-attributes >oct write ] keep ] with-cell - [ bl ] with-cell - [ [ file-size unparse write ] keep ] with-cell - [ bl ] with-cell - [ [ file-mtime file-time-string write ] keep ] with-cell - [ bl ] with-cell - [ file-name write ] with-cell ; - -M: winnt-shell touch-file ( path -- ) - #! Set the file write time to 'now' - normalize-pathname - dup maybe-create-file [ drop ] [ now set-file-write-time ] if ; - diff --git a/unmaintained/io/os-winnt.factor b/unmaintained/io/os-winnt.factor deleted file mode 100644 index 971ae79097..0000000000 --- a/unmaintained/io/os-winnt.factor +++ /dev/null @@ -1,96 +0,0 @@ -USING: alien calendar errors generic io io-internals kernel -math namespaces nonblocking-io parser quotations sequences -shuffle windows-api words ; -IN: libs-io - -: stat* ( path -- WIN32_FIND_DATA ) - "WIN32_FIND_DATA" - [ - FindFirstFile - [ INVALID_HANDLE_VALUE = [ win32-error ] when ] keep - FindClose win32-error=0/f - ] keep ; - -: set-file-time ( path timestamp/f timestamp/f timestamp/f -- ) - #! timestamp order: creation access write - >r >r >r open-existing dup r> r> r> - [ timestamp>FILETIME ] 3 napply - SetFileTime win32-error=0/f - close-handle ; - -: set-file-times ( path timestamp/f timestamp/f -- ) - f -rot set-file-time ; - -: set-file-create-time ( path timestamp -- ) - f f set-file-time ; - -: set-file-access-time ( path timestamp -- ) - >r f r> f set-file-time ; - -: set-file-write-time ( path timestamp -- ) - >r f f r> set-file-time ; - -: maybe-make-filetime ( ? -- FILETIME/f ) - [ "FILETIME" ] [ f ] if ; - -: file-time ( path ? ? ? -- FILETIME/f FILETIME/f FILETIME/f ) - >r >r >r open-existing dup r> r> r> - [ maybe-make-filetime ] 3 napply - [ GetFileTime win32-error=0/f close-handle ] 3keep ; - -: file-times ( path -- FILETIME FILETIME FILETIME ) - t t t file-time [ FILETIME>timestamp ] 3 napply ; - -: file-create-time ( path -- FILETIME ) - t f f file-time 2drop FILETIME>timestamp ; - -: file-access-time ( path -- FILETIME ) - f t f file-time drop nip FILETIME>timestamp ; - -: file-write-time ( path -- FILETIME ) - f f t file-time 2nip FILETIME>timestamp ; - -: attrib ( path -- n ) - [ stat* WIN32_FIND_DATA-dwFileAttributes ] catch - [ drop 0 ] when ; - -: (read-only?) ( mode -- ? ) - FILE_ATTRIBUTE_READONLY bit-set? ; - -: read-only? ( path -- ? ) - attrib (read-only?) ; - -: (hidden?) ( mode -- ? ) - FILE_ATTRIBUTE_HIDDEN bit-set? ; - -: hidden? ( path -- ? ) - attrib (hidden?) ; - -: (system?) ( mode -- ? ) - FILE_ATTRIBUTE_SYSTEM bit-set? ; - -: system? ( path -- ? ) - attrib (system?) ; - -: (directory?) ( mode -- ? ) - FILE_ATTRIBUTE_DIRECTORY bit-set? ; - -: directory? ( path -- ? ) - attrib (directory?) ; - -: (archive?) ( mode -- ? ) - FILE_ATTRIBUTE_ARCHIVE bit-set? ; - -: archive? ( path -- ? ) - attrib (archive?) ; - -! FILE_ATTRIBUTE_DEVICE -! FILE_ATTRIBUTE_NORMAL -! FILE_ATTRIBUTE_TEMPORARY -! FILE_ATTRIBUTE_SPARSE_FILE -! FILE_ATTRIBUTE_REPARSE_POINT -! FILE_ATTRIBUTE_COMPRESSED -! FILE_ATTRIBUTE_OFFLINE -! FILE_ATTRIBUTE_NOT_CONTENT_INDEXED -! FILE_ATTRIBUTE_ENCRYPTED - diff --git a/unmaintained/io/shell.factor b/unmaintained/io/shell.factor deleted file mode 100644 index 5213eb22c7..0000000000 --- a/unmaintained/io/shell.factor +++ /dev/null @@ -1,40 +0,0 @@ -USING: calendar io io-internals kernel math namespaces -nonblocking-io prettyprint quotations sequences ; -IN: shell - -SYMBOL: shell -HOOK: directory* shell ( path -- seq ) -HOOK: make-file shell ( bytes -- file ) -HOOK: file. shell ( file -- ) -HOOK: touch-file shell ( path -- ) - -: (ls) ( path -- ) - >r H{ } r> directory* - [ - [ [ make-file file. ] with-row ] each - ] curry tabular-output ; - -: ls ( -- ) - cwd (ls) ; - -: pwd ( -- ) - cwd pprint nl ; - -: (slurp) ( quot -- ) - >r default-buffer-size read r> over [ - dup slip (slurp) - ] [ - 2drop - ] if ; - -: slurp ( stream quot -- ) - [ (slurp) ] curry with-stream ; - -: cat ( path -- ) - stdio get - duplex-stream-out - [ write ] slurp ; - -: copy-file ( path path -- ) - >r r> - [ write ] slurp ; diff --git a/unmaintained/io/test/io.factor b/unmaintained/io/test/io.factor deleted file mode 100644 index 379e1233f0..0000000000 --- a/unmaintained/io/test/io.factor +++ /dev/null @@ -1,42 +0,0 @@ -USING: calendar errors io kernel libs-io math namespaces sequences -shell test ; -IN: temporary - -SYMBOL: file "file-appender-test.txt" \ file set -[ \ file get delete-file ] catch drop -[ f ] [ \ file get exists? ] unit-test -\ file get [ "asdf" write ] with-stream -[ t ] [ \ file get exists? ] unit-test -[ 4 ] [ \ file get file-length ] unit-test -\ file get [ "jkl;" write ] with-stream -[ t ] [ \ file get exists? ] unit-test -[ 8 ] [ \ file get file-length ] unit-test -[ "asdfjkl;" ] [ \ file get contents ] unit-test -\ file get delete-file -[ f ] [ \ file get exists? ] unit-test - -SYMBOL: directory "test-directory" \ directory set -\ directory get create-directory -[ t ] [ \ directory get directory? ] unit-test -\ directory get delete-directory -[ f ] [ \ directory get directory? ] unit-test - -SYMBOL: time "time-test.txt" \ time set -[ \ time get delete-file ] catch drop -\ time get touch-file -[ 0 ] [ \ time get file-length ] unit-test -[ t ] [ \ time get exists? ] unit-test -\ time get 0 unix-time>timestamp dup set-file-times -[ t ] [ \ time get file-write-time 0 unix-time>timestamp = ] unit-test -[ t ] [ \ time get file-access-time 0 unix-time>timestamp = ] unit-test -\ time get touch-file -[ t ] [ now \ time get file-write-time timestamp- 10 < ] unit-test -\ time get delete-file - -SYMBOL: longname "" 255 CHAR: a pad-left \ longname set -\ longname get touch-file -[ t ] [ \ longname get exists? ] unit-test -[ 0 ] [ \ longname get file-length ] unit-test -\ longname get delete-file -[ f ] [ \ longname get exists? ] unit-test - diff --git a/unmaintained/io/test/mmap.factor b/unmaintained/io/test/mmap.factor deleted file mode 100644 index faeca551c0..0000000000 --- a/unmaintained/io/test/mmap.factor +++ /dev/null @@ -1,21 +0,0 @@ -USING: alien errors io kernel libs-io mmap namespaces test ; - -IN: temporary -SYMBOL: mmap "mmap-test.txt" \ mmap set - -[ \ mmap get delete-file ] catch drop -\ mmap get [ - "Four" write -] with-file-writer - -\ mmap get [ - >r CHAR: R r> mmap-address 3 set-alien-unsigned-1 -] with-mmap - -\ mmap get [ - mmap-address 3 alien-unsigned-1 CHAR: R = [ - "mmap test failed" throw - ] unless -] with-mmap - -[ \ mmap get delete-file ] catch drop From 8f0b335f4b7c3acbbd3240231ceef6bd415626d7 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 19 Nov 2008 21:13:50 -0600 Subject: [PATCH 038/157] Clean up --- basis/ui/gadgets/frames/frames.factor | 29 +++++++++++++-------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/basis/ui/gadgets/frames/frames.factor b/basis/ui/gadgets/frames/frames.factor index c210d1b7e2..2005fefed7 100644 --- a/basis/ui/gadgets/frames/frames.factor +++ b/basis/ui/gadgets/frames/frames.factor @@ -11,16 +11,16 @@ TUPLE: frame < grid ; : ( -- grid ) 9 [ ] replicate 3 group ; -: @center 1 1 ; -: @left 0 1 ; -: @right 2 1 ; -: @top 1 0 ; -: @bottom 1 2 ; +: @center 1 1 ; inline +: @left 0 1 ; inline +: @right 2 1 ; inline +: @top 1 0 ; inline +: @bottom 1 2 ; inline -: @top-left 0 0 ; -: @top-right 2 0 ; -: @bottom-left 0 2 ; -: @bottom-right 2 2 ; +: @top-left 0 0 ; inline +: @top-right 2 0 ; inline +: @bottom-left 0 2 ; inline +: @bottom-right 2 2 ; inline : new-frame ( class -- frame ) swap new-grid ; inline @@ -28,13 +28,12 @@ TUPLE: frame < grid ; : ( -- frame ) frame new-frame ; -: (fill-center) ( vec n -- ) - over first pick third v+ [v-] 1 rot set-nth ; +: (fill-center) ( n vec -- ) + [ [ first ] [ third ] bi v+ [v-] ] keep set-second ; -: fill-center ( horiz vert dim -- ) - tuck (fill-center) (fill-center) ; +: fill-center ( dim horiz vert -- ) + [ over ] dip [ (fill-center) ] 2bi@ ; M: frame layout* dup compute-grid - [ rot rect-dim fill-center ] 3keep - grid-layout ; + [ [ rect-dim ] 2dip fill-center ] [ grid-layout ] 3bi ; From f5b19f8c3193d3ebbde6dc9b4c05428f09689252 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Wed, 19 Nov 2008 21:15:27 -0600 Subject: [PATCH 039/157] add the characters for ls -F to io.files.listing --- basis/io/files/listing/unix/unix.factor | 14 +++++++++++++- basis/io/unix/files/files.factor | 12 +++++++++++- basis/unix/stat/stat.factor | 1 + 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/basis/io/files/listing/unix/unix.factor b/basis/io/files/listing/unix/unix.factor index 313ce1f79a..bef8d3dc56 100755 --- a/basis/io/files/listing/unix/unix.factor +++ b/basis/io/files/listing/unix/unix.factor @@ -3,7 +3,7 @@ USING: accessors combinators kernel system unicode.case io.unix.files io.files.listing generalizations strings arrays sequences io.files math.parser unix.groups unix.users -io.files.listing.private ; +io.files.listing.private unix.stat math ; IN: io.files.listing.unix string ] } cleave 10 narray concat ; +: mode>symbol ( mode -- ch ) + S_IFMT bitand + { + { [ dup S_IFDIR = ] [ drop "/" ] } + { [ dup S_IFIFO = ] [ drop "|" ] } + { [ dup any-execute? ] [ drop "*" ] } + { [ dup S_IFLNK = ] [ drop "@" ] } + { [ dup S_IFWHT = ] [ drop "%" ] } + { [ dup S_IFSOCK = ] [ drop "=" ] } + { [ t ] [ drop "" ] } + } cond ; + M: unix (directory.) ( path -- lines ) [ [ [ diff --git a/basis/io/unix/files/files.factor b/basis/io/unix/files/files.factor index 98206bc992..ad5c192a39 100644 --- a/basis/io/unix/files/files.factor +++ b/basis/io/unix/files/files.factor @@ -6,7 +6,8 @@ math.bitwise byte-arrays alien combinators calendar io.encodings.binary accessors sequences strings system io.files.private destructors vocabs.loader calendar.unix unix.stat alien.c-types arrays unix.users unix.groups -environment fry io.encodings.utf8 alien.strings unix.statfs ; +environment fry io.encodings.utf8 alien.strings unix.statfs +combinators.short-circuit ; IN: io.unix.files M: unix cwd ( -- path ) @@ -228,6 +229,15 @@ GENERIC: other-read? ( obj -- ? ) GENERIC: other-write? ( obj -- ? ) GENERIC: other-execute? ( obj -- ? ) +: any-read? ( obj -- ? ) + { [ user-read? ] [ group-read? ] [ other-read? ] } 1|| ; + +: any-write? ( obj -- ? ) + { [ user-write? ] [ group-write? ] [ other-write? ] } 1|| ; + +: any-execute? ( obj -- ? ) + { [ user-execute? ] [ group-execute? ] [ other-execute? ] } 1|| ; + M: integer uid? ( integer -- ? ) UID mask? ; M: integer gid? ( integer -- ? ) GID mask? ; M: integer sticky? ( integer -- ? ) STICKY mask? ; diff --git a/basis/unix/stat/stat.factor b/basis/unix/stat/stat.factor index 17d6604fc0..a3b0ed11b7 100644 --- a/basis/unix/stat/stat.factor +++ b/basis/unix/stat/stat.factor @@ -13,6 +13,7 @@ IN: unix.stat : S_IFIFO OCT: 010000 ; inline ! FIFO. : S_IFLNK OCT: 120000 ; inline ! Symbolic link. : S_IFSOCK OCT: 140000 ; inline ! Socket. +: S_IFWHT OCT: 160000 ; inline ! Whiteout. FUNCTION: int chmod ( char* path, mode_t mode ) ; FUNCTION: int fchmod ( int fd, mode_t mode ) ; From 5a99526598d7df109c76b5bca5b50cf1bd0593e6 Mon Sep 17 00:00:00 2001 From: Eduardo Cavazos Date: Wed, 19 Nov 2008 21:15:29 -0600 Subject: [PATCH 040/157] boids: adjust 'USING:' line --- extra/boids/boids.factor | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/extra/boids/boids.factor b/extra/boids/boids.factor index 097b952db9..eeebe1c12d 100644 --- a/extra/boids/boids.factor +++ b/extra/boids/boids.factor @@ -1,5 +1,5 @@ -USING: combinators.short-circuit kernel namespaces +USING: kernel namespaces math math.constants math.functions @@ -10,6 +10,7 @@ USING: combinators.short-circuit kernel namespaces math.physics.vel combinators arrays sequences random vars combinators.lib + combinators.short-circuit accessors ; IN: boids From bcd2ffc830fa5d35b39872462fe52cc7d8e00cbb Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 19 Nov 2008 21:57:59 -0600 Subject: [PATCH 041/157] If rendering an error popup fails, don't open an endless stream --- basis/ui/gadgets/worlds/worlds.factor | 4 ++-- basis/ui/tools/debugger/debugger.factor | 10 +++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/basis/ui/gadgets/worlds/worlds.factor b/basis/ui/gadgets/worlds/worlds.factor index 6f901c37ee..e338d6d4f4 100644 --- a/basis/ui/gadgets/worlds/worlds.factor +++ b/basis/ui/gadgets/worlds/worlds.factor @@ -30,7 +30,7 @@ ERROR: no-world-found ; : (request-focus) ( child world ? -- ) pick parent>> pick eq? [ - >r >r dup parent>> dup r> r> + [ dup parent>> dup ] 2dip [ (request-focus) ] keep ] unless focus-child ; @@ -80,7 +80,7 @@ SYMBOL: ui-error-hook : ui-error ( error -- ) ui-error-hook get [ call ] [ print-error ] if* ; -[ rethrow ] ui-error-hook set-global +ui-error-hook global [ [ rethrow ] or ] change-at : draw-world ( world -- ) dup draw-world? [ diff --git a/basis/ui/tools/debugger/debugger.factor b/basis/ui/tools/debugger/debugger.factor index 4ba4374bb8..1f019fca7c 100644 --- a/basis/ui/tools/debugger/debugger.factor +++ b/basis/ui/tools/debugger/debugger.factor @@ -35,7 +35,15 @@ M: debugger focusable-child* restarts>> ; #! No restarts for the debugger window f [ drop ] "Error" open-window ; -[ debugger-window ] ui-error-hook set-global +GENERIC: error-in-debugger? ( error -- ? ) + +M: world-error error-in-debugger? world>> gadget-child debugger? ; + +M: object error-in-debugger? drop f ; + +[ + dup error-in-debugger? [ rethrow ] [ debugger-window ] if +] ui-error-hook set-global M: world-error error. "An error occurred while drawing the world " write From 4af2592369d2ddeb41436398b84be36e45a09a6f Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 19 Nov 2008 21:58:45 -0600 Subject: [PATCH 042/157] Fix some scrollers problems --- .../gadgets/scrollers/scrollers-tests.factor | 23 ++++++- basis/ui/gadgets/scrollers/scrollers.factor | 62 ++++++++++--------- 2 files changed, 53 insertions(+), 32 deletions(-) diff --git a/basis/ui/gadgets/scrollers/scrollers-tests.factor b/basis/ui/gadgets/scrollers/scrollers-tests.factor index 625bfd7880..d6792abd49 100644 --- a/basis/ui/gadgets/scrollers/scrollers-tests.factor +++ b/basis/ui/gadgets/scrollers/scrollers-tests.factor @@ -2,7 +2,8 @@ USING: ui.gadgets ui.gadgets.scrollers namespaces tools.test kernel models models.compose models.range ui.gadgets.viewports ui.gadgets.labels ui.gadgets.grids ui.gadgets.frames ui.gadgets.sliders math math.vectors arrays sequences -tools.test.ui math.geometry.rect accessors ; +tools.test.ui math.geometry.rect accessors ui.gadgets.buttons +ui.gadgets.packs ; IN: ui.gadgets.scrollers.tests [ ] [ @@ -74,7 +75,7 @@ dup layout "g2" get scroll>gadget "s" get layout "s" get scroller-value - ] map [ { 3 0 } = ] all? + ] map [ { 2 0 } = ] all? ] unit-test [ ] [ "Hi"