]> gitweb.factorcode.org Git - factor.git/commitdiff
Merge branch 'master' of git://factorcode.org/git/factor
authorU-FROGGER\erg <erg@frogger.(none)>
Wed, 26 Mar 2008 11:51:02 +0000 (06:51 -0500)
committerU-FROGGER\erg <erg@frogger.(none)>
Wed, 26 Mar 2008 11:51:02 +0000 (06:51 -0500)
core/io/backend/backend.factor
core/io/files/files-tests.factor
core/io/files/files.factor
extra/io/unix/files/files.factor
extra/io/unix/launcher/launcher-tests.factor
extra/io/unix/launcher/launcher.factor
extra/io/windows/files/files.factor
extra/io/windows/windows.factor
extra/peg/peg.factor
extra/ui/gadgets/scrollers/scrollers.factor
extra/ui/tools/listener/listener.factor

index 1595ecd576a4db126966e41c0674d2c24bc704cd..151dbc7df7a21ef6961d12c988677f5e94901a0f 100755 (executable)
@@ -17,11 +17,9 @@ HOOK: io-multiplex io-backend ( ms -- )
 
 HOOK: normalize-directory io-backend ( str -- newstr )
 
-M: object normalize-directory ;
-
 HOOK: normalize-pathname io-backend ( str -- newstr )
 
-M: object normalize-pathname ;
+M: object normalize-directory normalize-pathname ;
 
 : set-io-backend ( io-backend -- )
     io-backend set-global init-io init-stdio ;
index 36b32ea34c498e8773e24cd5afd6fcc5358659ac..369ecc6868b7af5caf3d98f0fab7d71d710d07ef 100755 (executable)
@@ -1,6 +1,7 @@
 IN: io.files.tests
-USING: tools.test io.files io threads kernel continuations io.encodings.ascii
-io.files.unique sequences strings accessors ;
+USING: tools.test io.files io threads kernel continuations
+io.encodings.ascii io.files.unique sequences strings accessors
+io.encodings.utf8 ;
 
 [ ] [ "blahblah" temp-file dup exists? [ delete-directory ] [ drop ] if ] unit-test
 [ ] [ "blahblah" temp-file make-directory ] unit-test
@@ -82,6 +83,12 @@ io.files.unique sequences strings accessors ;
     "delete-tree-test" temp-file delete-tree
 ] unit-test
 
+[ { { "kernel" t } } ] [
+    "core" resource-path [
+        "." directory [ first "kernel" = ] subset
+    ] with-directory
+] unit-test
+
 [ ] [
     "copy-tree-test/a/b/c" temp-file make-directories
 ] unit-test
@@ -130,6 +137,15 @@ io.files.unique sequences strings accessors ;
 
 [ t ] [ cwd "misc" resource-path [ ] with-directory cwd = ] unit-test
 
+[ t ] [
+    temp-directory [ "hi41" "test41" utf8 set-file-contents ] with-directory
+    temp-directory "test41" append-path utf8 file-contents "hi41" =
+] unit-test
+
+[ t ] [
+    temp-directory [ "test41" file-info size>> ] with-directory 4 =
+] unit-test
+
 [ ] [ "append-test" temp-file dup exists? [ delete-file ] [ drop ] if ] unit-test
 
 [ ] [ "append-test" temp-file ascii <file-appender> dispose ] unit-test
index 6500bdb387976a3feab1b4df5d17bd79e802c5c6..78f1612cb82cce91895ae10e0d0bcac44b4d7a14 100755 (executable)
@@ -13,13 +13,13 @@ HOOK: (file-writer) io-backend ( path -- stream )
 HOOK: (file-appender) io-backend ( path -- stream )
 
 : <file-reader> ( path encoding -- stream )
-    swap (file-reader) swap <decoder> ;
+    swap normalize-pathname (file-reader) swap <decoder> ;
 
 : <file-writer> ( path encoding -- stream )
-    swap (file-writer) swap <encoder> ;
+    swap normalize-pathname (file-writer) swap <encoder> ;
 
 : <file-appender> ( path encoding -- stream )
-    swap (file-appender) swap <encoder> ;
+    swap normalize-pathname (file-appender) swap <encoder> ;
 
 : file-lines ( path encoding -- seq )
     <file-reader> lines ;
@@ -272,6 +272,9 @@ DEFER: copy-tree-into
 
 : temp-file ( name -- path ) temp-directory prepend-path ;
 
+M: object normalize-pathname ( path -- path' )
+    current-directory get prepend-path ;
+
 ! Pathname presentations
 TUPLE: pathname string ;
 
index 1e7d6823140c9e14fad5f8f0a30eaeef58b0d323..2888231e2001dd0ea8c7e74957aa80937bfe8b1c 100755 (executable)
@@ -94,7 +94,7 @@ M: unix-io copy-file ( from to -- )
     \ file-info construct-boa ;
 
 M: unix-io file-info ( path -- info )
-    stat* stat>file-info ;
+    normalize-pathname stat* stat>file-info ;
 
 M: unix-io link-info ( path -- info )
-    lstat* stat>file-info ;
+    normalize-pathname lstat* stat>file-info ;
index 9e19245d010d364c7446083d6fe2e6563f52a61f..7e527196be012b579b8ab2fb9ecee12a2afe5fc3 100755 (executable)
@@ -1,7 +1,7 @@
 IN: io.unix.launcher.tests
 USING: io.files tools.test io.launcher arrays io namespaces
 continuations math io.encodings.binary io.encodings.ascii
-accessors kernel sequences ;
+accessors kernel sequences io.encodings.utf8 ;
 
 [ ] [
     [ "launcher-test-1" temp-file delete-file ] ignore-errors
@@ -95,3 +95,15 @@ accessors kernel sequences ;
         +replace-environment+ >>environment-mode
     ascii <process-stream> lines
 ] unit-test
+
+[ "hi\n" ] [
+    temp-directory [
+        [ "aloha" delete-file ] ignore-errors
+        <process>
+            { "echo" "hi" } >>command
+            "aloha" >>stdout
+        try-process
+    ] with-directory
+    temp-directory "aloha" append-path
+    utf8 file-contents
+] unit-test
index 0cbb78b881b2d18686c7f5815b5f5d8fa7865859..1292f2cacf815fcfab3ef15a2996ca0bd0b80f4d 100755 (executable)
@@ -37,7 +37,8 @@ USE: unix
     2nip reset-fd ;
 
 : redirect-file ( obj mode fd -- )
-    >r file-mode open dup io-error r> redirect-fd ;
+    >r >r normalize-pathname r> file-mode
+    open dup io-error r> redirect-fd ;
 
 : redirect-closed ( obj mode fd -- )
     >r >r drop "/dev/null" r> r> redirect-file ;
@@ -67,9 +68,9 @@ USE: unix
 
 : spawn-process ( process -- * )
     [
-        current-directory get cd
         setup-priority
         setup-redirection
+        current-directory get cd
         dup pass-environment? [
             dup get-environment set-os-envs
         ] when
index 094014fac6113271614205562375bd1131e047ab..b4513f7da88da0b1c0174e18e80bd89a3cdef12a 100755 (executable)
@@ -89,4 +89,7 @@ SYMBOLS: +read-only+ +hidden+ +system+
     ] if ;
 
 M: windows-nt-io file-info ( path -- info )
-    get-file-information-stat ;
+    normalize-pathname get-file-information-stat ;
+
+M: windows-nt-io link-info ( path -- info )
+    file-info ;
index dac55664a4a63c6cfdfb363947323bfe49d7b4b3..635a9927772aa154f2be54313be5bf83e4cccbc4 100755 (executable)
@@ -51,7 +51,7 @@ M: win32-file close-handle ( handle -- )
 ! Clean up resources (open handle) if add-completion fails
 : open-file ( path access-mode create-mode flags -- handle )
     [
-        >r >r >r normalize-pathname r>
+        >r >r
         share-mode security-attributes-inherit r> r> CreateFile-flags f CreateFile
         dup invalid-handle? dup close-later
         dup add-completion
index 00271a9ad380b1ee4b2710049d2ec263c76d7c96..dd0b11fce3f54dd1b5c522bb8d3c2d0884cd584b 100755 (executable)
@@ -3,7 +3,8 @@
 USING: kernel sequences strings namespaces math assocs shuffle 
        vectors arrays combinators.lib math.parser match
        unicode.categories sequences.lib compiler.units parser
-       words quotations effects memoize accessors combinators.cleave ;
+       words quotations effects memoize accessors 
+       combinators.cleave locals ;
 IN: peg
 
 TUPLE: parse-result remaining ast ;
@@ -14,9 +15,23 @@ SYMBOL: ignore
   parse-result construct-boa ;
 
 SYMBOL: compiled-parsers
+SYMBOL: packrat
+SYMBOL: failed
 
 GENERIC: (compile) ( parser -- quot )
 
+:: run-packrat-parser ( input quot c -- result )
+  input slice? [ input slice-from ] [ 0 ] if
+  quot c [ drop H{ } clone ] cache 
+  [
+    drop input quot call  
+  ] cache ; inline
+
+: run-parser ( input quot -- result )
+  #! If a packrat cache is available, use memoization for
+  #! packrat parsing, otherwise do a standard peg call.
+  packrat get [ run-packrat-parser ] [ call ] if* ; inline
+
 : compiled-parser ( parser -- word )
   #! Look to see if the given parser has been compiled.
   #! If not, compile it to a temporary word, cache it,
@@ -24,11 +39,11 @@ GENERIC: (compile) ( parser -- quot )
   dup compiled-parsers get at [
     nip
   ] [
-    dup (compile) define-temp 
+    dup (compile) [ run-parser ] curry define-temp 
     [ swap compiled-parsers get set-at ] keep
   ] if* ;
 
-MEMO: compile ( parser -- word )
+: compile ( parser -- word )
   H{ } clone compiled-parsers [ 
     [ compiled-parser ] with-compilation-unit 
   ] with-variable ;
index 98951b74e34db351aa4a11c7fb9792d5a26553ea..7966f4e206af04edcf8b138e37ff673cf206caad 100755 (executable)
@@ -3,13 +3,14 @@
 USING: arrays ui.gadgets
 ui.gadgets.viewports ui.gadgets.frames ui.gadgets.grids
 ui.gadgets.theme ui.gadgets.sliders ui.gestures kernel math
-namespaces sequences models combinators math.vectors ;
+namespaces sequences models combinators math.vectors
+tuples ;
 IN: ui.gadgets.scrollers
 
 TUPLE: scroller viewport x y follows ;
 
 : find-scroller ( gadget -- scroller/f )
-    [ scroller? ] find-parent ;
+    [ [ scroller? ] is? ] find-parent ;
 
 : scroll-up-page scroller-y -1 swap slide-by-page ;
 
index 75401b3861052aa50b054cec79d2eb58b0e829dc..7db0d63f45da367723fdcb8c622d91c06ca2b159 100755 (executable)
@@ -6,7 +6,8 @@ kernel models namespaces parser quotations sequences ui.commands
 ui.gadgets ui.gadgets.editors ui.gadgets.labelled
 ui.gadgets.panes ui.gadgets.buttons ui.gadgets.scrollers
 ui.gadgets.tracks ui.gestures ui.operations vocabs words
-prettyprint listener debugger threads boxes concurrency.flags ;
+prettyprint listener debugger threads boxes concurrency.flags
+math arrays ;
 IN: ui.tools.listener
 
 TUPLE: listener-gadget input output stack ;
@@ -23,9 +24,19 @@ TUPLE: listener-gadget input output stack ;
 : <listener-input> ( listener -- gadget )
     listener-gadget-output <pane-stream> <interactor> ;
 
+TUPLE: input-scroller ;
+
+: <input-scroller> ( interactor -- scroller )
+    <scroller>
+    input-scroller construct-empty
+    [ set-gadget-delegate ] keep ;
+
+M: input-scroller pref-dim*
+    drop { 0 100 } ;
+
 : listener-input, ( -- )
     g <listener-input> g-> set-listener-gadget-input
-    <scroller> "Input" <labelled-gadget> f track, ;
+    <input-scroller> "Input" <labelled-gadget> f track, ;
 
 : welcome. ( -- )
    "If this is your first time with Factor, please read the " print