Browse Source

Made TStream SuperStrict.

woollybah 8 years ago
parent
commit
76c8c01026

+ 14 - 11
endianstream.mod/endianstream.bmx

@@ -1,61 +1,64 @@
 
-Strict
+SuperStrict
 
 Rem
 bbdoc: Streams/Endian streams
 End Rem
 Module BRL.EndianStream
 
-ModuleInfo "Version: 1.01"
+ModuleInfo "Version: 1.02"
 ModuleInfo "Author: Mark Sibly"
 ModuleInfo "License: zlib/libpng"
 ModuleInfo "Copyright: Blitz Research Ltd"
 ModuleInfo "Modserver: BRL"
 
+ModuleInfo "History: 1.02"
+ModuleInfo "History: Module is now SuperStrict"
+
 Import BRL.Stream
 
 Type TXEndianStream Extends TStreamWrapper
 
 	Method Swap2( buf:Byte Ptr )
-		Local t
+		Local t:Int
 		t=buf[0];buf[0]=buf[1];buf[1]=t
 	End Method
 
 	Method Swap4( buf:Byte Ptr )
-		Local t
+		Local t:Int
 		t=buf[0];buf[0]=buf[3];buf[3]=t
 		t=buf[1];buf[1]=buf[2];buf[2]=t
 	End Method
 
 	Method Swap8( buf:Byte Ptr )
-		Local t
+		Local t:Int
 		t=buf[0];buf[0]=buf[7];buf[7]=t
 		t=buf[1];buf[1]=buf[6];buf[6]=t
 		t=buf[2];buf[2]=buf[5];buf[5]=t
 		t=buf[3];buf[3]=buf[4];buf[4]=t
 	End Method
 
-	Method ReadShort()
+	Method ReadShort:Int()
 		Local q:Short
 		ReadBytes Varptr q,2
 		Swap2 Varptr q
 		Return q
 	End Method
 
-	Method WriteShort( n )
+	Method WriteShort( n:Int )
 		Local q:Short=n
 		Swap2 Varptr q
 		WriteBytes Varptr q,2
 	End Method
 
-	Method ReadInt()
+	Method ReadInt:Int()
 		Local q:Int
 		ReadBytes Varptr q,4
 		Swap4 Varptr q
 		Return q
 	End Method
 
-	Method WriteInt( n )
+	Method WriteInt( n:Int )
 		Local q:Int=n
 		Swap4 Varptr q
 		WriteBytes Varptr q,4
@@ -101,7 +104,7 @@ Type TXEndianStream Extends TStreamWrapper
 	End Method
 
 	Function Create:TStream( stream:TStream )
-		If Not stream Return
+		If Not stream Return Null
 		Local t:TXEndianStream=New TXEndianStream
 		t.SetStream( stream )
 		Return t
@@ -142,7 +145,7 @@ Function LittleEndianStream:TStream( stream:TStream )
 End Function
 
 Type TXEndianStreamFactory Extends TStreamFactory
-	Method CreateStream:TStream( url:Object,proto$,path$,readable,writeable )
+	Method CreateStream:TStream( url:Object,proto$,path$,readable:Int,writeable:Int )
 		Select proto$
 		Case "bigendian"
 			Return TXEndianStream.BigEndian( OpenStream(path,readable,writeable) )

+ 12 - 10
socketstream.mod/socketstream.bmx

@@ -1,17 +1,19 @@
 
-Strict
+SuperStrict
 
 Rem
 bbdoc: Streams/Socket streams
 End Rem
 Module BRL.SocketStream
 
-ModuleInfo "Version: 1.05"
+ModuleInfo "Version: 1.06"
 ModuleInfo "Author: Mark Sibly"
 ModuleInfo "License: zlib/libpng"
 ModuleInfo "Copyright: Blitz Research Ltd"
 ModuleInfo "Modserver: BRL"
 
+ModuleInfo "History: 1.06"
+ModuleInfo "History: Module is now SuperStrict"
 ModuleInfo "History: 1.05 Release"
 ModuleInfo "History: CreateStream port handling fix documented"
 ModuleInfo "History: 1.04 Release"
@@ -30,7 +32,7 @@ Type TSocketStream Extends TStream
 		Return _socket.Send( buf,Size_T(count) )
 	End Method
 
-	Method Eof()
+	Method Eof:Int()
 		If Not _socket Return True
 		If _socket.Connected() Return False
 		Close
@@ -47,18 +49,18 @@ Type TSocketStream Extends TStream
 		Return _socket
 	End Method
 	
-	Function Create:TSocketStream( socket:TSocket,autoClose=True )
+	Function Create:TSocketStream( socket:TSocket,autoClose:Int=True )
 		Local t:TSocketStream=New TSocketStream
 		t._socket=socket
 		t._autoClose=autoClose
 		Return t
 	End Function
 	
-	Function CreateClient:TSocketStream( remoteHost$,remotePort, family:Int = AF_INET_ )
+	Function CreateClient:TSocketStream( remoteHost$,remotePort:Int, family:Int = AF_INET_ )
 		Local addrInfo:TAddrInfo[] = AddrInfo(remoteHost, family)
 		'Local remoteIp:String=HostIp( remoteHost, family )
 		'If Not remoteIp Return
-		If Not addrInfo Return
+		If Not addrInfo Return Null
 		
 		Local socket:TSocket=TSocket.CreateTCP()
 		If socket
@@ -70,14 +72,14 @@ Type TSocketStream Extends TStream
 
 	End Function
 	
-	Field _socket:TSocket,_autoClose
+	Field _socket:TSocket,_autoClose:Int
 	
 End Type
 
 Type TSocketStreamFactory Extends TStreamFactory
-	Method CreateStream:TSocketStream( url:Object,proto$,path$,readable,writeable )
+	Method CreateStream:TSocketStream( url:Object,proto$,path$,readable:Int,writeable:Int )
 		If proto$="tcp"
-			Local i=path.Find( ":",0 ),server$,port
+			Local i:Int=path.Find( ":",0 ),server$,port:Int
 			If i>=0 Return TSocketStream.CreateClient( path[..i],Int(path[i+1..]) )
 			Return TSocketStream.CreateClient( path,80 )
 		EndIf
@@ -96,7 +98,7 @@ If @autoClose is true, @socket will be automatically closed when the socket
 stream is closed. Otherwise, it is up to you to somehow close @socket at
 a later time.
 End Rem
-Function CreateSocketStream:TSocketStream( socket:TSocket,autoClose=True )
+Function CreateSocketStream:TSocketStream( socket:TSocket,autoClose:Int=True )
 	Return TSocketStream.Create( socket,autoClose )
 End Function
 

+ 1 - 1
standardio.mod/standardio.bmx

@@ -28,7 +28,7 @@ Type TCStandardIO Extends TStream
 		Return feof_( stdin_ )
 	End Method
 	
-	Method Flush:Int()
+	Method Flush()
 		fflush_ stdout_
 	End Method
 

+ 53 - 49
stream.mod/stream.bmx

@@ -1,17 +1,19 @@
 
-Strict
+SuperStrict
 
 Rem
 bbdoc: Streams/Streams
 End Rem
 Module BRL.Stream
 
-ModuleInfo "Version: 1.09"
+ModuleInfo "Version: 1.10"
 ModuleInfo "Author: Mark Sibly"
 ModuleInfo "License: zlib/libpng"
 ModuleInfo "Copyright: Blitz Research Ltd"
 ModuleInfo "Modserver: BRL"
 
+ModuleInfo "History: 1.10"
+ModuleInfo "History: Module is now SuperStrict"
 ModuleInfo "History: 1.09 Release"
 ModuleInfo "History: Fixed 'excpetion' typos"
 ModuleInfo "History: 1.08 Release"
@@ -87,7 +89,7 @@ Type TIO
 	has been shut down for some reason - either locally or by the remote host. In this case,
 	no more bytes can be read from or written to the stream.
 	End Rem
-	Method Eof()
+	Method Eof:Int()
 		Return Pos()=Size()
 	End Method
 
@@ -240,7 +242,7 @@ Type TStream Extends TIO
 	about:
 	If a value could not be read (possibly due to end of file), a #TStreamReadException is thrown.
 	End Rem
-	Method ReadByte()
+	Method ReadByte:Int()
 		Local n:Byte
 		ReadBytes Varptr n,1
 		Return n
@@ -251,7 +253,7 @@ Type TStream Extends TIO
 	about:
 	If the value could not be written (possibly due to end of file), a #TStreamWriteException is thrown.
 	End Rem
-	Method WriteByte( n )
+	Method WriteByte( n:Int )
 		Local q:Byte=n
 		WriteBytes Varptr q,1
 	End Method
@@ -262,7 +264,7 @@ Type TStream Extends TIO
 	about:
 	If a value could not be read (possibly due to end of file), a #TStreamReadException is thrown.
 	End Rem
-	Method ReadShort()
+	Method ReadShort:Int()
 		Local n:Short
 		ReadBytes Varptr n,2
 		Return n
@@ -273,7 +275,7 @@ Type TStream Extends TIO
 	about:
 	If the value could not be written (possibly due to end of file), a #TStreamWriteException is thrown.
 	End Rem
-	Method WriteShort( n )
+	Method WriteShort( n:Int )
 		Local q:Short=n
 		WriteBytes Varptr q,2
 	End Method
@@ -284,8 +286,8 @@ Type TStream Extends TIO
 	about:
 	If a value could not be read (possibly due to end of file), a #TStreamReadException is thrown.
 	End Rem
-	Method ReadInt()
-		Local n
+	Method ReadInt:Int()
+		Local n:Int
 		ReadBytes Varptr n,4
 		Return n
 	End Method
@@ -295,7 +297,7 @@ Type TStream Extends TIO
 	about:
 	If the value could not be written (possibly due to end of file), a #TStreamWriteException is thrown.
 	End Rem
-	Method WriteInt( n )
+	Method WriteInt( n:Int )
 		Local q:Int=n
 		WriteBytes Varptr q,4
 	End Method
@@ -378,7 +380,7 @@ Type TStream Extends TIO
 	or null character.
 	End Rem
 	Method ReadLine$()
-		Local buf:Byte[1024],sz
+		Local buf:Byte[1024],sz:Int
 		Repeat
 			Local ch:Byte
 			If Read( Varptr ch,1 )<>1 Or ch=0 Or ch=10 Exit
@@ -396,9 +398,9 @@ Type TStream Extends TIO
 	about: A sequence of bytes is written to the stream (one for each character in @str)
 	followed by the line terminating sequence "~r~n".
 	End Rem
-	Method WriteLine( str$ )
+	Method WriteLine:Int( str$ )
 		Local buf:Byte Ptr=str.ToCString()
-		Local ok=Write( buf,str.length )=str.length And Write( [13:Byte,10:Byte],2 )=2
+		Local ok:Int=Write( buf,str.length )=str.length And Write( [13:Byte,10:Byte],2 )=2
 		MemFree buf
 		Return ok
 	End Method
@@ -409,7 +411,7 @@ Type TStream Extends TIO
 	about:
 	A #TStreamReadException is thrown if not all bytes could be read.
 	End Rem
-	Method ReadString$( length )
+	Method ReadString$( length:Int )
 		Assert length>=0 Else "Illegal String length"
 		Local buf:Byte[length]
 		Readbytes buf,length
@@ -462,7 +464,7 @@ Type TStreamWrapper Extends TStream
 		_stream=stream
 	End Method
 
-	Method Eof()
+	Method Eof:Int()
 		Return _stream.Eof()
 	End Method
 
@@ -494,27 +496,27 @@ Type TStreamWrapper Extends TStream
 		Return _stream.Write( buf,count )
 	End Method
 	
-	Method ReadByte()
+	Method ReadByte:Int()
 		Return _stream.ReadByte()
 	End Method
 	
-	Method WriteByte( n )
+	Method WriteByte( n:Int )
 		_stream.WriteByte n
 	End Method
 	
-	Method ReadShort()
+	Method ReadShort:Int()
 		Return _stream.ReadShort()
 	End Method
 	
-	Method WriteShort( n )
+	Method WriteShort( n:Int )
 		_stream.WriteShort n
 	End Method
 	
-	Method ReadInt()
+	Method ReadInt:Int()
 		Return _stream.ReadInt()
 	End Method
 	
-	Method WriteInt( n )
+	Method WriteInt( n:Int )
 		_stream.WriteInt n
 	End Method
 	
@@ -538,11 +540,11 @@ Type TStreamWrapper Extends TStream
 		Return _stream.ReadLine()
 	End Method
 	
-	Method WriteLine( t$ )
+	Method WriteLine:Int( t$ )
 		Return _stream.WriteLine( t )
 	End Method
 	
-	Method ReadString$( n )
+	Method ReadString$( n:Int )
 		Return _stream.ReadString( n )
 	End Method
 	
@@ -580,10 +582,10 @@ about:
 End Rem
 Type TCStream Extends TStream
 
-	Const MODE_READ=1
-	Const MODE_WRITE=2
+	Const MODE_READ:Int=1
+	Const MODE_WRITE:Int=2
 	
-	Field _pos:Long,_size:Long,_mode
+	Field _pos:Long,_size:Long,_mode:Int
 	Field _cstream:Byte Ptr
 
 	Method Pos:Long()
@@ -638,8 +640,8 @@ Type TCStream Extends TStream
 	Rem
 	bbdoc: Create a TCStream from a 'C' filename
 	End Rem
-	Function OpenFile:TCStream( path$,readable,writeable )
-		Local Mode$,_mode
+	Function OpenFile:TCStream( path$,readable:Int,writeable:Int )
+		Local Mode$,_mode:Int
 		If readable And writeable
 			Mode="r+b"
 			_mode=MODE_READ|MODE_WRITE
@@ -664,7 +666,7 @@ Type TCStream Extends TStream
 	Rem
 	bbdoc: Create a TCStream from a 'C' stream handle
 	end rem
-	Function CreateWithCStream:TCStream( cstream:Byte Ptr,Mode )
+	Function CreateWithCStream:TCStream( cstream:Byte Ptr,Mode:Int )
 		Local stream:TCStream=New TCStream
 		stream._cstream=cstream
 		stream._pos=ftell_( cstream )
@@ -719,7 +721,7 @@ Type TStreamFactory
 	
 	If @url is not a string, both @proto and @path will be Null.
 	End Rem
-	Method CreateStream:TStream( url:Object,proto$,path$,readable,writeable ) Abstract
+	Method CreateStream:TStream( url:Object,proto$,path$,readable:Int,writeable:Int ) Abstract
 
 End Type
 
@@ -729,7 +731,7 @@ returns: A stream object
 about: All streams created by #OpenStream, #ReadStream or #WriteStream should eventually be
 closed using #CloseStream.
 End Rem
-Function OpenStream:TStream( url:Object,readable=True,writeable=True )
+Function OpenStream:TStream( url:Object,readable:Int=True,writeable:Int=True )
 
 	Local stream:TStream=TStream( url )
 	If stream
@@ -738,7 +740,7 @@ Function OpenStream:TStream( url:Object,readable=True,writeable=True )
 
 	Local str$=String( url ),proto$,path$
 	If str
-		Local i=str.Find( "::",0 )
+		Local i:Int=str.Find( "::",0 )
 		If i=-1 Return TCStream.OpenFile( str,readable,writeable )
 		proto$=str[..i].ToLower()
 		path$=str[i+2..]
@@ -777,7 +779,7 @@ Rem
 bbdoc: Get stream end of file status
 returns: True If stream is at end of file
 End Rem
-Function Eof( stream:TStream )
+Function Eof:Int( stream:TStream )
 	Return stream.Eof()
 End Function
 
@@ -829,7 +831,7 @@ returns: A Byte value
 about: #ReadByte reads a single Byte from @stream.
 A TStreamReadException is thrown If there is not enough data available.
 End Rem
-Function ReadByte( stream:TStream )
+Function ReadByte:Int( stream:TStream )
 	Return stream.ReadByte()
 End Function
 
@@ -839,7 +841,7 @@ returns: A Short value
 about: #ReadShort reads 2 bytes from @stream.
 A TStreamReadException is thrown If there is not enough data available.
 End Rem
-Function ReadShort( stream:TStream )
+Function ReadShort:Int( stream:TStream )
 	Return stream.ReadShort()
 End Function
 
@@ -849,7 +851,7 @@ returns: An Int value
 about: #ReadInt reads 4 bytes from @stream.
 A TStreamReadException is thrown If there is not enough data available.
 End Rem
-Function ReadInt( stream:TStream )
+Function ReadInt:Int( stream:TStream )
 	Return stream.ReadInt()
 End Function
 
@@ -888,7 +890,7 @@ bbdoc: Write a Byte to a stream
 about: #WriteByte writes a single Byte to @stream.
 A TStreamWriteException is thrown If the Byte could Not be written
 End Rem
-Function WriteByte( stream:TStream,n )
+Function WriteByte( stream:TStream,n:Int )
 	stream.WriteByte n
 End Function
 
@@ -897,7 +899,7 @@ bbdoc: Write a Short to a stream
 about: #WriteShort writes 2 bytes to @stream.
 A TStreamWriteException is thrown if not all bytes could be written
 End Rem
-Function WriteShort( stream:TStream,n )
+Function WriteShort( stream:TStream,n:Int )
 	stream.WriteShort n
 End Function
 
@@ -906,7 +908,7 @@ bbdoc: Write an Int to a stream
 about: #WriteInt writes 4 bytes to @stream.
 A TStreamWriteException is thrown if not all bytes could be written
 End Rem
-Function WriteInt( stream:TStream,n )
+Function WriteInt( stream:TStream,n:Int )
 	stream.WriteInt n
 End Function
 
@@ -943,7 +945,7 @@ returns: A String of length @length
 about:
 A #TStreamReadException is thrown if not all bytes could be read.
 end rem
-Function ReadString$( stream:TStream,length )
+Function ReadString$( stream:TStream,length:Int )
 	Return stream.ReadString( length )
 End Function
 
@@ -981,7 +983,7 @@ about:
 A sequence of bytes is written to the stream (one for each character in @str)
 followed by the line terminating sequence "~r~n".
 End Rem
-Function WriteLine( stream:TStream,str$ )
+Function WriteLine:Int( stream:TStream,str$ )
 	Return stream.WriteLine( str )
 End Function
 
@@ -1041,7 +1043,7 @@ End Rem
 Function LoadByteArray:Byte[]( url:Object )
 	Local stream:TStream=ReadStream( url )
 	If Not stream Throw New TStreamReadException
-	Local data:Byte[1024],size
+	Local data:Byte[1024],size:Int
 	While Not stream.Eof()
 		If size=data.length data=data[..size*3/2]
 		size:+stream.Read( (Byte Ptr data)+size,data.length-size )
@@ -1073,7 +1075,7 @@ of file.
 
 A #TStreamWriteException is thrown if not all bytes could be written.
 End Rem
-Function CopyStream( fromStream:TStream,toStream:TStream,bufSize=4096 )
+Function CopyStream( fromStream:TStream,toStream:TStream,bufSize:Int=4096 )
 	Assert bufSize>0
 	Local buf:Byte[bufSize]
 	While Not fromStream.Eof()
@@ -1089,11 +1091,11 @@ about:
 A #TStreamReadException is thrown if not all bytes could be read, and a
 #TStreamWriteException is thrown if not all bytes could be written.
 End Rem
-Function CopyBytes( fromStream:TStream,toStream:TStream,count,bufSize=4096 )
+Function CopyBytes( fromStream:TStream,toStream:TStream,count:Int,bufSize:Int=4096 )
 	Assert count>=0 And bufSize>0
 	Local buf:Byte[bufSize]
 	While count
-		Local n=Min(count,bufSize)
+		Local n:Int=Min(count,bufSize)
 		fromStream.ReadBytes buf,n
 		toStream.WriteBytes buf,n
 		count:-n
@@ -1105,8 +1107,8 @@ bbdoc: Returns a case sensitive filename if it exists from a case insensitive fi
 End Rem
 Function CasedFileName$(path$)
 	Local	dir:Byte Ptr
-	Local   sub$,s$,f$,folder$,p
-	Local	Mode,size:Long,mtime,ctime
+	Local   sub$,s$,f$,folder$,p:Int
+	Local	Mode:Int,size:Long,mtime:Int,ctime:Int
         
 	If stat_( path,Mode,size,mtime,ctime )=0
 		Mode:&S_IFMT_
@@ -1118,8 +1120,10 @@ Function CasedFileName$(path$)
 	Next
 	If p>0
 		sub=path[0..p]
-		sub$=CasedFileName(sub$)
-		If Not sub$ Return
+		sub=CasedFileName(sub)
+		If Not sub Then
+			Return Null
+		End If
 		path=path$[Len(sub)+1..]
 		folder$=sub
 	EndIf

+ 45 - 43
textstream.mod/textstream.bmx

@@ -1,5 +1,5 @@
 
-Strict
+SuperStrict
 
 Rem
 bbdoc: Streams/Text streams
@@ -16,12 +16,14 @@ many text processing applications are unable to handle UTF8 and UTF16 files.
 End Rem
 Module BRL.TextStream
 
-ModuleInfo "Version: 1.03 "
+ModuleInfo "Version: 1.04"
 ModuleInfo "Author: Mark Sibly"
 ModuleInfo "License: zlib/libpng"
 ModuleInfo "Copyright: Blitz Research Ltd"
 ModuleInfo "Modserver: BRL"
 
+ModuleInfo "History: 1.04"
+ModuleInfo "History: Module is now SuperStrict"
 ModuleInfo "History: 1.03 Release"
 ModuleInfo "History: Modified LoadText to handle stream URLs"
 ModuleInfo "History: 1.02 Release"
@@ -37,16 +39,16 @@ Type TTextStream Extends TStreamWrapper
 
 	'***** PUBLIC *****
 
-	Const LATIN1=1
-	Const UTF8=2
-	Const UTF16BE=3
-	Const UTF16LE=4
+	Const LATIN1:Int=1
+	Const UTF8:Int=2
+	Const UTF16BE:Int=3
+	Const UTF16LE:Int=4
 
 	Method Read:Long( buf:Byte Ptr,count:Long )
 		For Local i:Long=0 Until count
 			If _bufcount=32 _FlushRead
-			Local hi=_ReadByte()
-			Local lo=_ReadByte()
+			Local hi:Int=_ReadByte()
+			Local lo:Int=_ReadByte()
 			hi:-48;If hi>9 hi:-7
 			lo:-48;If lo>9 lo:-7
 			buf[i]=hi Shl 4 | lo
@@ -57,8 +59,8 @@ Type TTextStream Extends TStreamWrapper
 	
 	Method Write:Long( buf:Byte Ptr,count:Long )
 		For Local i:Long=0 Until count
-			Local hi=buf[i] Shr 4
-			Local lo=buf[i] & $f
+			Local hi:Int=buf[i] Shr 4
+			Local lo:Int=buf[i] & $f
 			hi:+48;If hi>57 hi:+7
 			lo:+48;If lo>57 lo:+7
 			_WriteByte hi
@@ -69,32 +71,32 @@ Type TTextStream Extends TStreamWrapper
 		Return count
 	End Method
 	
-	Method ReadByte()
+	Method ReadByte:Int()
 		_FlushRead
 		Return Int( ReadLine() )
 	End Method
 	
-	Method WriteByte( n )
+	Method WriteByte( n:Int )
 		_FlushWrite
 		WriteLine n
 	End Method
 	
-	Method ReadShort()
+	Method ReadShort:Int()
 		_FlushRead
 		Return Int( ReadLine() )
 	End Method
 	
-	Method WriteShort( n )
+	Method WriteShort( n:Int )
 		_FlushWrite
 		WriteLine n
 	End Method
 	
-	Method ReadInt()
+	Method ReadInt:Int()
 		_FlushRead
 		Return Int( ReadLine() )
 	End Method
 	
-	Method WriteInt( n )
+	Method WriteInt( n:Int )
 		_FlushWrite
 		WriteLine n
 	End Method
@@ -131,9 +133,9 @@ Type TTextStream Extends TStreamWrapper
 	
 	Method ReadLine$()
 		_FlushRead
-		Local buf:Short[1024],i
+		Local buf:Short[1024],i:Int
 		While Not Eof()
-			Local n=ReadChar()
+			Local n:Int=ReadChar()
 			If n=0 Exit
 			If n=10 Exit
 			If n=13 Continue
@@ -146,9 +148,9 @@ Type TTextStream Extends TStreamWrapper
 	
 	Method ReadFile$()
 		_FlushRead
-		Local buf:Short[1024],i
+		Local buf:Short[1024],i:Int
 		While Not Eof()
-			Local n=ReadChar()
+			Local n:Int=ReadChar()
 			If buf.length=i buf=buf[..i+1024]
 			buf[i]=n
 			i:+1
@@ -156,16 +158,16 @@ Type TTextStream Extends TStreamWrapper
 		Return String.FromShorts( buf,i )
 	End Method
 	
-	Method WriteLine( str$ )
+	Method WriteLine:Int( str$ )
 		_FlushWrite
 		WriteString str
 		WriteString "~r~n"
 	End Method
 	
-	Method ReadString$( length )
+	Method ReadString$( length:Int )
 		_FlushRead
 		Local buf:Short[length]
-		For Local i=0 Until length
+		For Local i:Int=0 Until length
 			buf[i]=ReadChar()
 		Next
 		Return String.FromShorts(buf,length)
@@ -173,32 +175,32 @@ Type TTextStream Extends TStreamWrapper
 	
 	Method WriteString( str$ )
 		_FlushWrite
-		For Local i=0 Until str.length
+		For Local i:Int=0 Until str.length
 			WriteChar str[i]
 		Next
 	End Method
 	
-	Method ReadChar()
-		Local c=_ReadByte()
+	Method ReadChar:Int()
+		Local c:Int=_ReadByte()
 		Select _encoding
 		Case LATIN1
 			Return c
 		Case UTF8
 			If c<128 Return c
-			Local d=_ReadByte()
+			Local d:Int=_ReadByte()
 			If c<224 Return (c-192)*64+(d-128)
-			Local e=_ReadByte()
+			Local e:Int=_ReadByte()
 			If c<240 Return (c-224)*4096+(d-128)*64+(e-128)
 		Case UTF16BE
-			Local d=_ReadByte()
+			Local d:Int=_ReadByte()
 			Return c Shl 8 | d
 		Case UTF16LE
-			Local d=_ReadByte()
+			Local d:Int=_ReadByte()
 			Return d Shl 8 | c
 		End Select
 	End Method
 	
-	Method WriteChar( char )
+	Method WriteChar( char:Int )
 		Assert char>=0 And char<=$ffff
 		Select _encoding
 		Case LATIN1
@@ -223,7 +225,7 @@ Type TTextStream Extends TStreamWrapper
 		End Select
 	End Method
 
-	Function Create:TTextStream( stream:TStream,encoding )
+	Function Create:TTextStream( stream:TStream,encoding:Int )
 		Local t:TTextStream=New TTextStream
 		t._encoding=encoding
 		t.SetStream stream
@@ -232,17 +234,17 @@ Type TTextStream Extends TStreamWrapper
 
 	'***** PRIVATE *****
 	
-	Method _ReadByte()
+	Method _ReadByte:Int()
 		Return Super.ReadByte()
 	End Method
 	
-	Method _WriteByte( n )
+	Method _WriteByte( n:Int )
 		Super.WriteByte n
 	End Method
 	
 	Method _FlushRead()
 		If Not _bufcount Return
-		Local n=_ReadByte()
+		Local n:Int=_ReadByte()
 		If n=13 n=_ReadByte()
 		If n<>10 Throw "Malformed line terminator"
 		_bufcount=0
@@ -255,14 +257,14 @@ Type TTextStream Extends TStreamWrapper
 		_bufcount=0
 	End Method
 	
-	Field _encoding,_bufcount
+	Field _encoding:Int,_bufcount:Int
 	
 End Type
 	
 Type TTextStreamFactory Extends TStreamFactory
 
-	Method CreateStream:TStream( url:Object,proto$,path$,readable,writeable )
-		Local encoding
+	Method CreateStream:TStream( url:Object,proto$,path$,readable:Int,writeable:Int )
+		Local encoding:Int
 		Select proto$
 		Case "latin1"
 			encoding=TTextStream.LATIN1
@@ -273,7 +275,7 @@ Type TTextStreamFactory Extends TStreamFactory
 		Case "utf16le"
 			encoding=TTextStream.UTF16LE
 		End Select
-		If Not encoding Return
+		If Not encoding Return Null
 		Local stream:TStream=OpenStream( path,readable,writeable )
 		If stream Return TTextStream.Create( stream,encoding )
 	End Method
@@ -303,7 +305,7 @@ Function LoadText$( url:Object )
 	Local stream:TStream=ReadStream( url )
 	If Not stream Throw New TStreamReadException
 
-	Local format,size,c,d,e
+	Local format:Int,size:Int,c:Int,d:Int,e:Int
 
 	If Not stream.Eof()
 		c=stream.ReadByte()
@@ -354,10 +356,10 @@ then @str is saved in UTF16 format. Otherwise, @str is saved in LATIN1 format.
 
 A #TStreamWriteException is thrown if not all bytes could be written.
 End Rem
-Function SaveText( str$,url:Object )
+Function SaveText:Int( str$,url:Object )
 
-	Local format
-	For Local i=0 Until str.length
+	Local format:Int
+	For Local i:Int=0 Until str.length
 		If str[i]>255
 ?BigEndian
 			format=TTextStream.UTF16BE