]> gitweb.factorcode.org Git - factor.git/commitdiff
move null streams to core and make them not depend on io.styles and io.timeouts,...
authorDoug Coleman <doug.coleman@gmail.com>
Fri, 30 Jan 2009 00:33:19 +0000 (18:33 -0600)
committerDoug Coleman <doug.coleman@gmail.com>
Fri, 30 Jan 2009 00:33:19 +0000 (18:33 -0600)
12 files changed:
basis/io/backend/windows/nt/nt.factor
basis/io/streams/null/authors.txt [deleted file]
basis/io/streams/null/null-docs.factor [deleted file]
basis/io/streams/null/null-tests.factor [deleted file]
basis/io/streams/null/null.factor [deleted file]
basis/io/timeouts/timeouts.factor [changed mode: 0644->0755]
core/io/backend/backend.factor
core/io/streams/c/c.factor
core/io/streams/null/authors.txt [new file with mode: 0755]
core/io/streams/null/null-docs.factor [new file with mode: 0644]
core/io/streams/null/null-tests.factor [new file with mode: 0644]
core/io/streams/null/null.factor [new file with mode: 0644]

index 493a735f7f27d081c4141d871d2dc150bf18449d..b114cefdc0f7e75515e3da12bfb8c9a2912abc1d 100755 (executable)
@@ -120,6 +120,9 @@ M: winnt (wait-to-read) ( port -- )
         tri
     ] with-destructors ;
 
-M: winnt (init-stdio) init-c-stdio ;
+: console-app? ( -- ? ) GetConsoleWindow ;
+
+M: winnt (init-stdio)
+    console-app? [ f f f f ] [ init-c-stdio t ] if ;
 
 winnt set-io-backend
diff --git a/basis/io/streams/null/authors.txt b/basis/io/streams/null/authors.txt
deleted file mode 100755 (executable)
index 1901f27..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Slava Pestov
diff --git a/basis/io/streams/null/null-docs.factor b/basis/io/streams/null/null-docs.factor
deleted file mode 100644 (file)
index 19bf825..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-USING: io help.markup help.syntax quotations ;
-IN: io.streams.null
-
-HELP: null-reader
-{ $class-description "Singleton class of null reader streams." } ;
-
-HELP: null-writer
-{ $class-description "Singleton class of null writer streams." } ;
-
-HELP: with-null-reader
-{ $values { "quot" quotation } }
-{ $description "Calls the quotation with " { $link input-stream } " rebound to a " { $link null-reader } " which always produces EOF." } ;
-
-HELP: with-null-writer
-{ $values { "quot" quotation } }
-{ $description "Calls the quotation with " { $link output-stream } " rebound to a " { $link null-writer } " which ignores all output." } ;
-
-ARTICLE: "io.streams.null" "Null streams"
-"The " { $vocab-link "io.streams.null" } " vocabulary implements a pair of streams which are useful for testing. The null reader always yields EOF and the null writer ignores all output. Conceptually, they are similar to " { $snippet "/dev/null" } " on a Unix system."
-$nl
-"Null readers:"
-{ $subsection null-reader }
-{ $subsection with-null-writer }
-"Null writers:"
-{ $subsection null-writer }
-{ $subsection with-null-reader } ;
-
-ABOUT: "io.streams.null"
\ No newline at end of file
diff --git a/basis/io/streams/null/null-tests.factor b/basis/io/streams/null/null-tests.factor
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/basis/io/streams/null/null.factor b/basis/io/streams/null/null.factor
deleted file mode 100644 (file)
index a2224ef..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-! Copyright (C) 2007, 2009 Slava Pestov.
-! See http://factorcode.org/license.txt for BSD license.
-USING: kernel io io.timeouts io.styles destructors ;
-IN: io.streams.null
-
-SINGLETONS: null-reader null-writer ;
-UNION: null-stream null-reader null-writer ;
-
-M: null-stream dispose drop ;
-M: null-stream set-timeout 2drop ;
-
-M: null-reader stream-readln drop f ;
-M: null-reader stream-read1 drop f ;
-M: null-reader stream-read-until 2drop f f ;
-M: null-reader stream-read 2drop f ;
-
-M: null-writer stream-write1 2drop ;
-M: null-writer stream-write 2drop ;
-M: null-writer stream-nl drop ;
-M: null-writer stream-flush drop ;
-M: null-writer stream-format 3drop ;
-M: null-writer make-span-stream nip ;
-M: null-writer make-block-stream nip ;
-M: null-writer make-cell-stream nip ;
-M: null-writer stream-write-table 3drop ;
-
-: with-null-reader ( quot -- )
-    null-reader swap with-input-stream* ; inline
-
-: with-null-writer ( quot -- )
-    null-writer swap with-output-stream* ; inline
\ No newline at end of file
old mode 100644 (file)
new mode 100755 (executable)
index fd1b14d..8e69983
@@ -1,7 +1,7 @@
 ! Copyright (C) 2008 Slava Pestov, Doug Coleman\r
 ! See http://factorcode.org/license.txt for BSD license.\r
 USING: kernel calendar alarms io io.encodings accessors\r
-namespaces fry ;\r
+namespaces fry io.streams.null ;\r
 IN: io.timeouts\r
 \r
 GENERIC: timeout ( obj -- dt/f )\r
@@ -27,3 +27,5 @@ GENERIC: cancel-operation ( obj -- )
 : timeouts ( dt -- )\r
     [ input-stream get set-timeout ]\r
     [ output-stream get set-timeout ] bi ;\r
+\r
+M: null-stream set-timeout 2drop ;\r
index 322a6031446efb172e7959c71a0d7a336563c66d..fd5567cfa2300450f6a9750f97a49ebb5b1b4a02 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2007, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: init kernel system namespaces io io.encodings
-io.encodings.utf8 init assocs splitting alien ;
+io.encodings.utf8 init assocs splitting alien io.streams.null ;
 IN: io.backend
 
 SYMBOL: io-backend
@@ -12,13 +12,22 @@ io-backend global [ c-io-backend or ] change-at
 
 HOOK: init-io io-backend ( -- )
 
-HOOK: (init-stdio) io-backend ( -- stdin stdout stderr )
+HOOK: (init-stdio) io-backend ( -- stdin stdout stderr ? )
+
+: set-stdio ( input-handle output-handle error-handle -- )
+    [ input-stream set-global ]
+    [ output-stream set-global ]
+    [ error-stream set-global ] tri* ;
 
 : init-stdio ( -- )
-    (init-stdio)
-    [ utf8 <decoder> input-stream set-global ]
-    [ utf8 <encoder> output-stream set-global ]
-    [ utf8 <encoder> error-stream set-global ] tri* ;
+    (init-stdio) [
+        [ utf8 <decoder> ]
+        [ utf8 <encoder> ]
+        [ utf8 <encoder> ] tri*
+    ] [
+        3drop
+        null-reader null-writer null-writer
+    ] if set-stdio ;
 
 HOOK: io-multiplex io-backend ( us -- )
 
index 71c9ffd7d9a4e097d147bb2fadc1c35775cf9854..a93602533d8dbbc3f81f7ee4e6880def86b3a277 100755 (executable)
@@ -65,7 +65,7 @@ M: c-io-backend init-io ;
     stdout-handle <c-writer>
     stderr-handle <c-writer> ;
 
-M: c-io-backend (init-stdio) init-c-stdio ;
+M: c-io-backend (init-stdio) init-c-stdio ;
 
 M: c-io-backend io-multiplex 60 60 * 1000 * 1000 * or (sleep) ;
 
diff --git a/core/io/streams/null/authors.txt b/core/io/streams/null/authors.txt
new file mode 100755 (executable)
index 0000000..1901f27
--- /dev/null
@@ -0,0 +1 @@
+Slava Pestov
diff --git a/core/io/streams/null/null-docs.factor b/core/io/streams/null/null-docs.factor
new file mode 100644 (file)
index 0000000..19bf825
--- /dev/null
@@ -0,0 +1,28 @@
+USING: io help.markup help.syntax quotations ;
+IN: io.streams.null
+
+HELP: null-reader
+{ $class-description "Singleton class of null reader streams." } ;
+
+HELP: null-writer
+{ $class-description "Singleton class of null writer streams." } ;
+
+HELP: with-null-reader
+{ $values { "quot" quotation } }
+{ $description "Calls the quotation with " { $link input-stream } " rebound to a " { $link null-reader } " which always produces EOF." } ;
+
+HELP: with-null-writer
+{ $values { "quot" quotation } }
+{ $description "Calls the quotation with " { $link output-stream } " rebound to a " { $link null-writer } " which ignores all output." } ;
+
+ARTICLE: "io.streams.null" "Null streams"
+"The " { $vocab-link "io.streams.null" } " vocabulary implements a pair of streams which are useful for testing. The null reader always yields EOF and the null writer ignores all output. Conceptually, they are similar to " { $snippet "/dev/null" } " on a Unix system."
+$nl
+"Null readers:"
+{ $subsection null-reader }
+{ $subsection with-null-writer }
+"Null writers:"
+{ $subsection null-writer }
+{ $subsection with-null-reader } ;
+
+ABOUT: "io.streams.null"
\ No newline at end of file
diff --git a/core/io/streams/null/null-tests.factor b/core/io/streams/null/null-tests.factor
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/core/io/streams/null/null.factor b/core/io/streams/null/null.factor
new file mode 100644 (file)
index 0000000..98729c7
--- /dev/null
@@ -0,0 +1,25 @@
+! Copyright (C) 2007, 2009 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: kernel io destructors io.streams.plain ;
+IN: io.streams.null
+
+SINGLETONS: null-reader null-writer ;
+UNION: null-stream null-reader null-writer ;
+INSTANCE: null-writer plain-writer
+
+M: null-stream dispose drop ;
+
+M: null-reader stream-readln drop f ;
+M: null-reader stream-read1 drop f ;
+M: null-reader stream-read-until 2drop f f ;
+M: null-reader stream-read 2drop f ;
+
+M: null-writer stream-write1 2drop ;
+M: null-writer stream-write 2drop ;
+M: null-writer stream-flush drop ;
+
+: with-null-reader ( quot -- )
+    null-reader swap with-input-stream* ; inline
+
+: with-null-writer ( quot -- )
+    null-writer swap with-output-stream* ; inline