]> gitweb.factorcode.org Git - factor.git/commitdiff
stream word renaming
authorSlava Pestov <slava@factorcode.org>
Tue, 15 Feb 2005 03:15:02 +0000 (03:15 +0000)
committerSlava Pestov <slava@factorcode.org>
Tue, 15 Feb 2005 03:15:02 +0000 (03:15 +0000)
25 files changed:
TODO.FACTOR.txt
library/httpd/html.factor
library/httpd/http-common.factor
library/httpd/httpd.factor
library/httpd/quit-responder.factor
library/io/ansi.factor
library/io/io-internals.factor
library/io/logging.factor
library/io/network.factor
library/io/presentation.factor
library/io/stdio.factor
library/io/stream-impl.factor
library/io/stream.factor
library/io/win32-io-internals.factor
library/io/win32-server.factor
library/io/win32-stream.factor
library/syntax/parse-stream.factor
library/test/io/io.factor
library/test/memory.factor [new file with mode: 0644]
library/test/test.factor
library/tools/jedit-wire.factor
library/tools/jedit.factor
library/tools/listener.factor
library/tools/telnetd.factor
library/ui/console.factor

index 74401e2fade43aebde2e8f160acb836dec7e67c4..6ada5d8e5e7f9dd828c1558548ef9393d3695a1a 100644 (file)
@@ -19,7 +19,6 @@
 - alignment of gadgets inside their bounding boxes needs thought\r
 - faster completion\r
 - ppc register decls\r
-- rename f* words to stream-*\r
 \r
 - port leak\r
 - references primitive\r
index 6ad7e251f097915ed3613fefa07a7589b33a9a37..9072c4d359c87cde3e26fae5f7ad8d89002f59f5 100644 (file)
@@ -102,7 +102,7 @@ url-encoding presentation generic ;
 
 TUPLE: html-stream delegate ;
 
-M: html-stream fwrite-attr ( str style stream -- )
+M: html-stream stream-write-attr ( str style stream -- )
     wrapper-stream-scope [
         [
             [
index ebeef31687e2cef73c53dda869be1e412fa1d025..3e1cd1d588a04f269c0296f3609d928c5fb2be80 100644 (file)
@@ -86,7 +86,7 @@ USE: url-encoding
     ": " split1 dup [ cons swons ] [ 2drop ] ifte ;
 
 : (read-header) ( alist -- alist )
-    read dup
+    read-line dup
     f-or-"" [ drop ] [ header-line (read-header) ] ifte ;
 
 : read-header ( -- alist )
@@ -105,7 +105,7 @@ USE: url-encoding
     ] when ;
 
 : read-post-request ( header -- alist )
-    content-length dup [ read# query>alist ] when ;
+    content-length dup [ read query>alist ] when ;
 
 : log-user-agent ( alist -- )
     "User-Agent" swap assoc* [
index 2f2921a1b35170aba728685ac5f1ed00e1e3da45..e1d2f709187e679825053726ce930efb2c9c8616 100644 (file)
@@ -56,7 +56,7 @@ stdio streams strings threads url-encoding ;
 : httpd-client ( socket -- )
     [
         [
-            stdio get log-client read [ parse-request ] when*
+            stdio get log-client read-line [ parse-request ] when*
         ] with-stream
     ] try ;
 
@@ -70,7 +70,7 @@ stdio streams strings threads url-encoding ;
     <server> "http-server" set [
         httpd-loop
     ] [
-        "http-server" get fclose rethrow
+        "http-server" get stream-close rethrow
     ] catch ;
 
 : httpd ( port -- )
index 5d99f77b39bf725aa4e391a08c8d54aad3f90e15..9644ebae78653a1f5cb178e87027e3293f3a638d 100644 (file)
@@ -42,5 +42,5 @@ USE: streams
     "quit-prohibited" get [
         quit-prohibited
     ] [
-        "http-server" get fclose
+        "http-server" get stream-close
     ] ifte ;
index ff7c68a8f832e61b08ed25f0826b6265681cba1c..7068adafdec53205dc0719a5c4253a8286e7462a 100644 (file)
@@ -50,9 +50,9 @@ presentation generic ;
 
 TUPLE: ansi-stream delegate ;
 
-M: ansi-stream fwrite-attr ( string style stream -- )
+M: ansi-stream stream-write-attr ( string style stream -- )
     >r [ default-style ] unless* ansi-attr-string r>
-    ansi-stream-delegate fwrite ;
+    ansi-stream-delegate stream-write ;
 
 IN: shells
 
index b0e55c2f8341812b6048c1e63cdf1e0a30ca14c3..a5d17f494bf61e06d10e4cda8492456b8aa56ed4 100644 (file)
@@ -58,14 +58,14 @@ BUILTIN: port 14
 : blocking-read-line ( port -- line )
     dup wait-to-read-line read-line-fd-8 dup [ sbuf>str ] when ;
 
-: fill-fd# ( count port -- )
+: fill-fd ( count port -- )
     [ add-read-count-io-task (yield) ] callcc0 2drop ;
 
-: wait-to-read# ( count port -- )
-    2dup can-read-count? [ 2drop ] [ fill-fd# ] ifte ;
+: wait-to-read ( count port -- )
+    2dup can-read-count? [ 2drop ] [ fill-fd ] ifte ;
 
-: blocking-read# ( count port -- str )
-    2dup wait-to-read# read-count-fd-8 dup [ sbuf>str ] when ;
+: blocking-read ( count port -- str )
+    2dup wait-to-read read-count-fd-8 dup [ sbuf>str ] when ;
 
 : wait-to-accept ( socket -- )
     [ add-accept-io-task (yield) ] callcc0 drop ;
index 79e4a3881f91b195b3861129162727bffdf80d6a..0c59236e982376436d1c3aedd27fe1ef9aff9281 100644 (file)
@@ -36,7 +36,7 @@ USE: strings
 USE: unparser
 
 : log ( msg -- )
-    "log" get dup [ tuck fprint fflush ] [ 2drop ] ifte ;
+    "log" get dup [ tuck stream-print stream-flush ] [ 2drop ] ifte ;
 
 : log-error ( error -- )
     "Error: " swap cat2 log ;
index cbca2aab53bf2fd9fcab64c2c6334c4880402d8b..634d8679e5fb3eed80b8e3e208a3ad2c5854277c 100644 (file)
@@ -7,22 +7,22 @@ namespaces unparser generic ;
 TUPLE: server port ;
 GENERIC: accept
 
-M: server fclose ( stream -- )
+M: server stream-close ( stream -- )
     server-port close-port ;
 
 C: server ( port -- stream )
     #! Starts listening on localhost:port. Returns a stream that
-    #! you can close with fclose, and accept connections from
+    #! you can close with stream-close, and accept connections from
     #! with accept. No other stream operations are supported.
     [ >r server-socket r> set-server-port ] keep ;
 
 TUPLE: client-stream delegate host ;
 
 C: client-stream ( host port in out -- stream )
-    #! fflush yields until connection is established.
+    #! stream-flush yields until connection is established.
     [ >r <fd-stream> r> set-client-stream-delegate ] keep
     [ >r ":" swap unparse cat3 r> set-client-stream-host ] keep
-    dup fflush ;
+    dup stream-flush ;
 
 : <client> ( host port -- stream )
     2dup client-socket <client-stream> ;
index 98783ac19a5f2dae76328d82613a8e8c1063e6d3..f37abe0392c60983c0f4879a5e80ea25d265f52a 100644 (file)
@@ -39,7 +39,7 @@ USE: unparser
     [ uncons >r over " " r> cat3 cons ] map nip ;
 
 ! A style is an alist whose key/value pairs hold
-! significance to the 'fwrite-attr' word when applied to a
+! significance to the 'stream-write-attr' word when applied to a
 ! stream that supports attributed string output.
 
 : (style) ( name -- style ) "styles" get hash ;
index 2e6e1c6b82e86997d028dd289986d2dd004f4ea8..a00ce67de9598c545bbe96e256e33b4f49247b49 100644 (file)
@@ -5,15 +5,15 @@ USING: errors kernel lists namespaces streams generic strings ;
 
 SYMBOL: stdio
 
-: flush      ( -- )              stdio get fflush ;
-: read       ( -- string )       stdio get freadln ;
-: read1      ( count -- string ) stdio get fread1 ;
-: read#      ( count -- string ) stdio get fread# ;
-: write      ( string -- )       stdio get fwrite ;
-: write-attr ( string style -- ) stdio get fwrite-attr ;
-: print      ( string -- )       stdio get fprint ;
+: flush      ( -- )              stdio get stream-flush ;
+: read-line  ( -- string )       stdio get stream-readln ;
+: read1      ( -- char )         stdio get stream-read1 ;
+: read       ( count -- string ) stdio get stream-read ;
+: write      ( string -- )       stdio get stream-write ;
+: write-attr ( string style -- ) stdio get stream-write-attr ;
+: print      ( string -- )       stdio get stream-print ;
 : terpri     ( -- )              "\n" write ;
-: close      ( -- )              stdio get fclose ;
+: close      ( -- )              stdio get stream-close ;
 
 : write-icon ( resource -- )
     #! Write an icon. Eg, /library/icons/File.png
@@ -31,8 +31,8 @@ SYMBOL: stdio
 
 TUPLE: stdio-stream delegate ;
 
-M: stdio-stream fauto-flush ( -- )
-    stdio-stream-delegate fflush ;
+M: stdio-stream stream-auto-flush ( -- )
+    stdio-stream-delegate stream-flush ;
 
-M: stdio-stream fclose ( -- )
+M: stdio-stream stream-close ( -- )
     drop ;
index 57bf996b5f4bafc1dc349694cbee3893f693d3a0..26984a81fa90d43928cb979e88808f4067853bd5 100644 (file)
@@ -16,22 +16,22 @@ IN: streams
 
 TUPLE: fd-stream in out ;
 
-M: fd-stream fwrite-attr ( str style stream -- )
+M: fd-stream stream-write-attr ( str style stream -- )
     nip fd-stream-out blocking-write ;
 
-M: fd-stream freadln ( stream -- str )
+M: fd-stream stream-readln ( stream -- str )
     fd-stream-in dup [ blocking-read-line ] when ;
 
-M: fd-stream fread# ( count stream -- str )
-    fd-stream-in dup [ blocking-read# ] [ nip ] ifte ;
+M: fd-stream stream-read ( count stream -- str )
+    fd-stream-in dup [ blocking-read ] [ nip ] ifte ;
 
-M: fd-stream fflush ( stream -- )
+M: fd-stream stream-flush ( stream -- )
     fd-stream-out [ blocking-flush ] when* ;
 
-M: fd-stream fauto-flush ( stream -- )
+M: fd-stream stream-auto-flush ( stream -- )
     drop ;
 
-M: fd-stream fclose ( stream -- )
+M: fd-stream stream-close ( stream -- )
     dup fd-stream-out [ dup blocking-flush close-port ] when*
     fd-stream-in [ close-port ] when* ;
 
@@ -53,7 +53,7 @@ M: fd-stream fclose ( stream -- )
 : fcopy ( from to -- )
     #! Copy the contents of the fd-stream 'from' to the
     #! fd-stream 'to'.
-    [ 2dup (fcopy) ] [ -rot fclose fclose rethrow ] catch ;
+    [ 2dup (fcopy) ] [ -rot stream-close stream-close rethrow ] catch ;
 
 : resource-path ( -- path )
     "resource-path" get [ "." ] unless* ;
index 834accfbeb3856ec52b2ee416d8044c71244cc1d..45277f1b61f0107d1c7ba23c3c94d7a2c6a0ea94 100644 (file)
@@ -5,34 +5,34 @@ DEFER: stdio
 IN: streams
 USING: errors kernel namespaces strings generic lists ;
 
-GENERIC: fflush      ( stream -- )
-GENERIC: fauto-flush ( stream -- )
-GENERIC: freadln     ( stream -- string )
-GENERIC: fread#      ( count stream -- string )
-GENERIC: fwrite-attr ( string style stream -- )
-GENERIC: fclose      ( stream -- )
-
-: fread1 ( stream -- char/f )
-    1 swap fread#
+GENERIC: stream-flush      ( stream -- )
+GENERIC: stream-auto-flush ( stream -- )
+GENERIC: stream-readln     ( stream -- string )
+GENERIC: stream-read       ( count stream -- string )
+GENERIC: stream-write-attr ( string style stream -- )
+GENERIC: stream-close      ( stream -- )
+
+: stream-read1 ( stream -- char/f )
+    1 swap stream-read
     dup f-or-"" [ drop f ] [ 0 swap str-nth ] ifte ;
 
-: fwrite ( string stream -- )
-    f swap fwrite-attr ;
+: stream-write ( string stream -- )
+    f swap stream-write-attr ;
 
-: fprint ( string stream -- )
-    [ fwrite ] keep
-    [ "\n" swap fwrite ] keep
-    fauto-flush ;
+: stream-print ( string stream -- )
+    [ stream-write ] keep
+    [ "\n" swap stream-write ] keep
+    stream-auto-flush ;
 
 ! A stream that builds a string of all text written to it.
 TUPLE: string-output buf ;
 
-M: string-output fwrite-attr ( string style stream -- )
+M: string-output stream-write-attr ( string style stream -- )
     nip string-output-buf sbuf-append ;
 
-M: string-output fclose ( stream -- ) drop ;
-M: string-output fflush ( stream -- ) drop ;
-M: string-output fauto-flush ( stream -- ) drop ;
+M: string-output stream-close ( stream -- ) drop ;
+M: string-output stream-flush ( stream -- ) drop ;
+M: string-output stream-auto-flush ( stream -- ) drop ;
 
 : stream>str ( stream -- string )
     #! Returns the string written to the given string output
index 8d2a730faac3d1d779047a4e895a3da4b2997a5a..5319d134d7c72e24dd7ee1cd096251508186d2b7 100644 (file)
@@ -139,12 +139,12 @@ END-STRUCT
     win32-io-thread ;
 
 TUPLE: null-stream ;
-M: null-stream fflush drop ;
-M: null-stream fauto-flush drop ;
-M: null-stream fread# 2drop f ;
-M: null-stream freadln drop f ;
-M: null-stream fwrite-attr 3drop ;
-M: null-stream fclose drop ;
+M: null-stream stream-flush drop ;
+M: null-stream stream-auto-flush drop ;
+M: null-stream stream-read 2drop f ;
+M: null-stream stream-readln drop f ;
+M: null-stream stream-write-attr 3drop ;
+M: null-stream stream-close drop ;
 
 : win32-init-stdio ( -- )
     INVALID_HANDLE_VALUE NULL NULL 1 CreateIoCompletionPort
index 31f02bd97b1dc1eeb213c722f2a40311fb0c27f7..d20d5b18edb0a38e733c26a0c98a34b473936ee8 100644 (file)
@@ -95,7 +95,7 @@ C: win32-server ( port -- server )
         socket set
     ] extend over set-win32-server-this ;
 
-M: win32-server fclose ( server -- )
+M: win32-server stream-close ( server -- )
     win32-server-this [ socket get CloseHandle drop ] bind ;
 
 M: win32-server accept ( server -- client )
index fc855d973c53630cb59b8b4b0298369fca1a26c8..79f5b5332302569d2c265e0f37556b1949e03ff2 100644 (file)
@@ -142,22 +142,22 @@ M: string do-write ( str -- )
         ] ifte
     ] ifte ;
 
-M: win32-stream fwrite-attr ( str style stream -- )
+M: win32-stream stream-write-attr ( str style stream -- )
     win32-stream-this nip [ do-write ] bind ;
 
-M: win32-stream freadln ( stream -- str )
+M: win32-stream stream-readln ( stream -- str )
     win32-stream-this [ 80 <sbuf> do-read-line ] bind ;
 
-M: win32-stream fread# ( count stream -- str )
+M: win32-stream stream-read ( count stream -- str )
     win32-stream-this [ dup <sbuf> swap do-read-count ] bind ;
 
-M: win32-stream fflush ( stream -- )
+M: win32-stream stream-flush ( stream -- )
     win32-stream-this [ maybe-flush-output ] bind ;
 
-M: win32-stream fauto-flush ( stream -- )
+M: win32-stream stream-auto-flush ( stream -- )
     drop ;
 
-M: win32-stream fclose ( stream -- )
+M: win32-stream stream-close ( stream -- )
     win32-stream-this [
         maybe-flush-output
         handle get CloseHandle drop 
index 61411844723aae081fcc8a17e5c19e35250b80fb..a9e7115075a22d94be183767e363d3400b0d0296 100644 (file)
@@ -41,7 +41,7 @@ USE: strings
 ! parse-stream
 
 : next-line ( -- str )
-    "parse-stream" get freadln
+    "parse-stream" get stream-readln
     "line-number" [ 1 + ] change ;
 
 : (read-lines) ( quot -- )
@@ -57,7 +57,7 @@ USE: strings
     swap [
         "parse-stream" set 0 "line-number" set (read-lines)
     ] [
-        "parse-stream" get fclose rethrow
+        "parse-stream" get stream-close rethrow
     ] catch ;
 
 : file-vocabs ( -- )
index 0d02dba5b3a31c154d2d85bf750e1fdd689ab69d..b7e20607d439909bbafbb6fa9f5b7682634fe516 100644 (file)
@@ -9,7 +9,7 @@ USE: math
 [ 4 ] [ "/library/test/io/no-trailing-eol.factor" run-resource ] unit-test
 
 : lines-test ( stream -- line1 line2 )
-    [ read read ] with-stream ;
+    [ read-line read-line ] with-stream ;
 
 [
     "This is a line."
@@ -29,7 +29,7 @@ USE: math
     "This is a line.\rThis is another line.\r"
 ] [
     "/library/test/io/mac-os-eol.txt" <resource-stream>
-    [ 500 read# ] with-stream
+    [ 500 read ] with-stream
 ] unit-test
 
 [
@@ -42,4 +42,4 @@ USE: math
 ! Make sure we use correct to_c_string form when writing
 [ ] [ "\0" write ] unit-test
 
-[ -1 read# ] unit-test-fails
+[ -1 read ] unit-test-fails
diff --git a/library/test/memory.factor b/library/test/memory.factor
new file mode 100644 (file)
index 0000000..8fea613
--- /dev/null
@@ -0,0 +1,14 @@
+IN: scratchpad
+USE: kernel
+USE: math
+USE: memory
+USE: generic
+USE: lists
+
+num-types [
+    [
+        instances [
+            class drop
+        ] each
+    ] keep
+] repeat
index d3fb0f9d9d6cdfe4a5823bc4f83d793444f3ee4d..992934a8e19dfc22ef4b960ff3b5b3c6e3aa1a75 100644 (file)
@@ -94,6 +94,7 @@ prettyprint stdio strings words vectors unparser ;
         "alien"
         "line-editor"
         "gadgets"
+        "memory"
     ] [
         test
     ] each
index 160dc595533be83a758aa7f1a978038a4ef6467a..343342a386b1e0ec0e92ed69ccc4d75a78c891dd 100644 (file)
@@ -52,7 +52,7 @@ USE: listener
     dup str-length write-big-endian-32 write flush ;
 
 : read-packet ( -- string )
-    read-big-endian-32 read# ;
+    read-big-endian-32 read ;
 
 : wire-server ( -- )
     #! Repeatedly read jEdit requests and execute them. Return
@@ -80,15 +80,15 @@ USE: listener
 
 TUPLE: jedit-stream delegate ;
 
-M: jedit-stream freadln ( stream -- str )
+M: jedit-stream stream-readln ( stream -- str )
     wrapper-stream-scope
-    [ CHAR: r write flush read-big-endian-32 read# ] bind ;
+    [ CHAR: r write flush read-big-endian-32 read ] bind ;
 
-M: jedit-stream fwrite-attr ( str style stream -- )
+M: jedit-stream stream-write-attr ( str style stream -- )
     wrapper-stream-scope
     [ [ default-style ] unless* jedit-write-attr ] bind ;
 
-M: jedit-stream fflush ( stream -- )
+M: jedit-stream stream-flush ( stream -- )
     wrapper-stream-scope
     [ CHAR: f write flush ] bind ;
 
index b8dd959ed203d402a6a0a8c6890305e53347489f..8697365de0f1e20cfed3e0a3af31693f2f9b9e76 100644 (file)
@@ -10,9 +10,9 @@ strings unparser words ;
 
 : jedit-server-info ( -- port auth )
     jedit-server-file <file-reader> [
-        read drop
-        read parse-number
-        read parse-number
+        read-line drop
+        read-line parse-number
+        read-line parse-number
     ] with-stream ;
 
 : make-jedit-request ( files params -- code )
index f44508395c80d79ed7e121562e755a7865f69119..765031928d48b420f7eddce49f32553453704015 100644 (file)
@@ -26,7 +26,7 @@ global [
 
 : (read-multiline) ( quot depth -- quot ? )
     #! Flag indicates EOF.
-    >r read dup [
+    >r read-line dup [
         (parse) depth r> dup >r <= [
             ( we're done ) r> drop t
         ] [
index b6432640dec6fdde1f9e028f17081c67bf47205d..e7dfbe016f2f493433d633d9cbbfd4a8197282f9 100644 (file)
@@ -15,7 +15,7 @@ threads parser ;
 
 : telnetd ( port -- )
     [
-        <server> [ telnetd-loop ] [ swap fclose rethrow ] catch
+        <server> [ telnetd-loop ] [ swap stream-close rethrow ] catch
     ] with-logging ;
 
 IN: shells
index bd1c9e88573c8ef6e36df86ffacbbcddfe4d1c84..e07ce5438c139e4fffb994f1c80de2caa3b99b4b 100644 (file)
@@ -201,18 +201,18 @@ SYMBOL: redraw-console
 ! The console stream
 
 ! Restoring this continuation with a string on the stack returns
-! to the caller of freadln.
+! to the caller of stream-readln.
 SYMBOL: input-continuation
 
 TUPLE: console-stream console redraw-continuation ;
 
-M: console-stream fflush ( stream -- )
-    fauto-flush ;
+M: console-stream stream-flush ( stream -- )
+    stream-auto-flush ;
 
-M: console-stream fauto-flush ( stream -- )
+M: console-stream stream-auto-flush ( stream -- )
     console-stream-console [ redraw-console on ] bind ;
 
-M: console-stream freadln ( stream -- line )
+M: console-stream stream-readln ( stream -- line )
     [
         swap [
             console-stream-console
@@ -225,10 +225,10 @@ M: console-stream freadln ( stream -- line )
         ] ifte
     ] callcc1 nip ;
 
-M: console-stream fwrite-attr ( string style stream -- )
+M: console-stream stream-write-attr ( string style stream -- )
     nip console-stream-console [ console-write ] bind ;
 
-M: console-stream fclose ( stream -- ) drop ;
+M: console-stream stream-close ( stream -- ) drop ;
 
 ! Event handling
 SYMBOL: event