2022-03-06 18:46:04 +01:00
|
|
|
"#iota.isbpl" include
|
2022-03-06 18:13:25 +01:00
|
|
|
|
2022-03-06 18:46:04 +01:00
|
|
|
native stream
|
2022-03-06 18:13:25 +01:00
|
|
|
|
2022-03-06 18:46:04 +01:00
|
|
|
def STREAM_CREATE_FILE_IN riota =STREAM_CREATE_FILE_IN
|
|
|
|
def STREAM_CREATE_FILE_OUT iota =STREAM_CREATE_FILE_OUT
|
|
|
|
def STREAM_CREATE_SOCKET iota =STREAM_CREATE_SOCKET
|
|
|
|
def STREAM_CLOSE iota =STREAM_CLOSE
|
|
|
|
def STREAM_READ iota =STREAM_READ
|
|
|
|
def STREAM_WRITE iota =STREAM_WRITE
|
2022-03-06 18:13:25 +01:00
|
|
|
|
|
|
|
"not implemented:" #
|
2022-03-06 18:46:04 +01:00
|
|
|
"def STREAM_AREAD iota =STREAM_AREAD" #
|
|
|
|
"def STREAM_AWRITE iota =STREAM_AWRITE" #
|
2022-03-06 21:06:44 +01:00
|
|
|
|
|
|
|
func stream.readline {
|
|
|
|
def id =id
|
|
|
|
def byte 0 =byte
|
|
|
|
def array 0 anew =array
|
|
|
|
def tmparray 0 anew =tmparray
|
|
|
|
def i 1 neg =i
|
|
|
|
while { ( i 1 + =i ) ( byte 10 eq not ) } {
|
|
|
|
id STREAM_READ stream =byte
|
|
|
|
array ( ( array alen 1 + anew ) dup =tmparray ) 0 0 ( array alen ) acopy =array
|
|
|
|
array dup alen 1 - byte _char aput
|
|
|
|
}
|
|
|
|
array ( ( array alen 1 - anew ) dup =tmparray 0 0 ) ( tmparray alen ) acopy _string
|
|
|
|
}
|
|
|
|
|
|
|
|
func stream.write {
|
|
|
|
def id =id
|
|
|
|
def str _array =str
|
|
|
|
def i 1 neg =i
|
|
|
|
while { ( i 1 + =i ) ( i str alen lt ) } {
|
|
|
|
str i aget id STREAM_WRITE stream
|
|
|
|
}
|
|
|
|
}
|