Selaa lähdekoodia

Made TStream SuperStrict.

woollybah 8 vuotta sitten
vanhempi
commit
76c8c01026

+ 14 - 11
endianstream.mod/endianstream.bmx

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

+ 12 - 10
socketstream.mod/socketstream.bmx

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

+ 1 - 1
standardio.mod/standardio.bmx

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

+ 53 - 49
stream.mod/stream.bmx

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

+ 45 - 43
textstream.mod/textstream.bmx

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