io.encodings.private io.encodings.utf8 io.timeouts kernel libc
locals math math.order namespaces sequences specialized-arrays
specialized-arrays.instances.alien.c-types.uchar splitting
-strings summary system typed io.files ;
+strings summary system io.files kernel.private ;
IN: io.ports
SYMBOL: default-buffer-size
dup check-disposed
dup wait-to-read [ drop f ] [ buffer>> buffer-pop ] if ; inline
-TYPED: read-step ( count: fixnum port: input-port -- count: fixnum ptr/f: c-ptr )
+! TYPED: read-step ( count: fixnum port: input-port -- count: fixnum ptr/f: c-ptr )
+: (read-step) ( count: fixnum port: input-port -- count: fixnum ptr/f: c-ptr )
{
{ [ over 0 = ] [ 2drop 0 f ] }
{ [ dup wait-to-read ] [ 2drop 0 f ] }
[ buffer>> buffer-read-unsafe ]
} cond ;
+: read-step ( count port -- count ptr/f )
+ (read-step) { fixnum c-ptr } declare ; inline
: prepare-read ( count stream -- count stream )
dup check-disposed [ 0 max >fixnum ] dip ; inline
[ swap ] dip prepare-read read-step
[ swap [ memcpy ] keep ] [ 2drop 0 ] if* ;
-HINTS: M\ input-port stream-read-unsafe
- { fixnum byte-array input-port }
- { fixnum string input-port } ;
-
:: read-loop ( n-remaining n-read port dst -- n-total )
n-remaining 0 > [
n-remaining port read-step :> ( n-buffered ptr )
] if
] [ 0 ] if ;
-HINTS: M\ input-port stream-read-unsafe
- { fixnum byte-array input-port }
- { fixnum string input-port } ;
-
: read-until-step ( separators port -- string/f separator/f )
dup wait-to-read [ 2drop f f ] [ buffer>> buffer-until ] if ;
HINTS: decoder-read-until { string input-port utf8 } { string input-port ascii } ;
HINTS: decoder-readln { input-port utf8 } { input-port ascii } ;
+
+HINTS: M\ input-port stream-read-partial-unsafe
+ { fixnum byte-array input-port }
+ { fixnum string input-port } ;
+
+HINTS: M\ input-port stream-read-unsafe
+ { fixnum byte-array input-port }
+ { fixnum string input-port } ;
+