Răsfoiți Sursa

Added proper type definition for stream positions to be used by clients of Streams

git-svn-id: https://svn.inf.ethz.ch/svn/lecturers/a2/trunk@8125 8c9fc860-2736-0410-a75d-ab315db34111
negelef 7 ani în urmă
părinte
comite
945423b1bb

+ 3 - 3
source/AVI.Mod

@@ -203,7 +203,7 @@ IMPORT
 		END Resynch;
 
 		(* Return Pos in Avi File, relativ to the beginning of the stream data *)
-		PROCEDURE Pos*(): LONGINT;
+		PROCEDURE Pos*(): Streams.Position;
 		BEGIN
 			RETURN r.Pos()
 		END Pos;
@@ -227,7 +227,7 @@ IMPORT
 		END Bytes;
 
 		(* Set Byte Position *)
-		PROCEDURE SetPos*(pos : LONGINT);
+		PROCEDURE SetPos*(pos : Streams.Position);
 		VAR seekType, itemSize, res : LONGINT;
 		BEGIN
 			IF Debug THEN KernelLog.String("DemuxStream.SetPos"); KernelLog.Ln; END;
@@ -1387,4 +1387,4 @@ BEGIN
 	RETURN p
 END Factory;
 
-END AVI.
+END AVI.

+ 3 - 3
source/CDRecordUtils.Mod

@@ -487,7 +487,7 @@ TYPE
 			NEW(cur, NIL, NIL, NIL);
 		END Init;
 
-		PROCEDURE SetPos*(pos: LONGINT);
+		PROCEDURE SetPos*(pos: Streams.Position);
 		BEGIN
 			IF pos < start.Get() THEN
 				pos := start.Get();
@@ -498,7 +498,7 @@ TYPE
 			Invalidate();
 		END SetPos;
 
-		PROCEDURE GetPos*(): LONGINT;
+		PROCEDURE GetPos*(): Streams.Position;
 		BEGIN
 			RETURN cur.Get();
 		END GetPos;
@@ -894,4 +894,4 @@ BEGIN
 	END;
 END ClearBuffer;
 
-END CDRecordUtils.
+END CDRecordUtils.

+ 3 - 3
source/Codecs.Mod

@@ -62,7 +62,7 @@ TYPE
 			RETURN TRUE;
 		END CanSetPos;
 
-		PROCEDURE SetPos*(pos : LONGINT);
+		PROCEDURE SetPos*(pos : Streams.Position);
 		BEGIN
 			f.Set(r, pos);
 			Reset;
@@ -123,7 +123,7 @@ TYPE
 			demultiplexer.GetData(streamNr, buf, ofs, size, min, len, res)
 		END Receive;
 
-		PROCEDURE SetPos*(pos : LONGINT);
+		PROCEDURE SetPos*(pos : Streams.Position);
 		VAR  seekType, itemSize, res: LONGINT;
 		BEGIN
 			seekType := SeekByte;
@@ -738,4 +738,4 @@ END OpenOutputStream;
 END Codecs.
 
 --------------------------
-System.Free Codecs~
+System.Free Codecs~

+ 3 - 3
source/Commands.Mod

@@ -47,7 +47,7 @@ TYPE
 
 	(*see StreamUtilities.Mod: reader that can daisychained with another reader that extracts a copy of the data flow to a monitor stream*)
 	ReaderMonitor* = OBJECT(Streams.Reader)
-		VAR in: Streams.Reader; tracer: Streams.Writer; pos0: LONGINT; tracedPos: LONGINT;
+		VAR in: Streams.Reader; tracer: Streams.Writer; pos0: Streams.Position; tracedPos: LONGINT;
 
 		PROCEDURE &Init(in: Streams.Reader; tracer: Streams.Writer);
 		BEGIN
@@ -80,11 +80,11 @@ TYPE
 		BEGIN RETURN in.CanSetPos()
 		END CanSetPos;
 
-		PROCEDURE SetPos*(pos: LONGINT);
+		PROCEDURE SetPos*(pos: Streams.Position);
 		BEGIN Reset; pos0 := pos; in.SetPos(pos)
 		END SetPos;
 
-		PROCEDURE Pos*(): LONGINT;
+		PROCEDURE Pos*(): Streams.Position;
 		BEGIN RETURN Pos^()+pos0;
 		END Pos;
 

+ 4 - 4
source/Files.Mod

@@ -96,7 +96,7 @@ TYPE
 			RETURN TRUE;
 		END CanSetPos;
 
-		PROCEDURE SetPos*(pos : LONGINT);
+		PROCEDURE SetPos*(pos : Streams.Position);
 		BEGIN
 			file.Set(r, pos);
 			Reset;
@@ -134,14 +134,14 @@ TYPE
 			RETURN TRUE;
 		END CanSetPos;
 
-		PROCEDURE SetPos*(pos : LONGINT);
-			BEGIN
+		PROCEDURE SetPos*(pos : Streams.Position);
+		BEGIN
 			Update;
 			file.Set(r, pos);
 			Reset;
 		END SetPos;
 
-		PROCEDURE Pos*(): LONGINT;
+		PROCEDURE Pos*(): Streams.Position;
 		BEGIN
 			Update;
 			RETURN file.Pos(r)

+ 2 - 2
source/FoxBasic.Mod

@@ -1448,7 +1448,7 @@ TYPE
 		BEGIN RETURN w.CanSetPos();
 		END CanSetPos;
 
-		PROCEDURE SetPos*( pos: LONGINT );
+		PROCEDURE SetPos*( pos: Streams.Position );
 		BEGIN w.SetPos(pos);
 		END SetPos;
 
@@ -1456,7 +1456,7 @@ TYPE
 		BEGIN w.Update;
 		END Update;
 
-		PROCEDURE Pos*( ): LONGINT;
+		PROCEDURE Pos*( ): Streams.Position;
 		BEGIN RETURN w.Pos()
 		END Pos;
 

+ 3 - 3
source/I386.MPEGUtilities.Mod

@@ -634,12 +634,12 @@ TYPE
 			END;
 		END SkipBits;
 
-		PROCEDURE Pos*(): LONGINT;
+		PROCEDURE Pos*(): Streams.Position;
 		BEGIN
 			RETURN input.Pos() - 8;
 		END Pos;
 
-		PROCEDURE SetPos*(pos: LONGINT);
+		PROCEDURE SetPos*(pos: Streams.Position);
 		VAR
 			dummy, result: LONGINT;
 
@@ -2487,4 +2487,4 @@ BEGIN
 			IdctBorder[ii + 512] := ii;
 		END;
 	END;
-END MPEGUtilities.
+END MPEGUtilities.

+ 4 - 4
source/PCOFPE.Mod

@@ -135,12 +135,12 @@ MODULE PCOFPE; (** AUTHOR "ejz"; PURPOSE "Parallel Compiler: PE object file plug
 				END
 			END Receive;
 
-			PROCEDURE Pos*(): LONGINT;
+			PROCEDURE Pos*(): Streams.Position;
 			BEGIN
 				RETURN org + Pos^()
 			END Pos;
 
-			PROCEDURE SetPos*(ofs: LONGINT);
+			PROCEDURE SetPos*(ofs: Streams.Position);
 			BEGIN
 				Reset();
 				SELF.org := ofs; SELF.ofs := ofs
@@ -165,12 +165,12 @@ MODULE PCOFPE; (** AUTHOR "ejz"; PURPOSE "Parallel Compiler: PE object file plug
 				IF SELF.ofs > sect.used THEN sect.used := SELF.ofs END
 			END Send;
 
-			PROCEDURE Pos*(): LONGINT;
+			PROCEDURE Pos*(): Streams.Position;
 			BEGIN
 				RETURN org + Pos^()
 			END Pos;
 
-			PROCEDURE SetPos*(ofs: LONGINT);
+			PROCEDURE SetPos*(ofs: Streams.Position);
 			BEGIN
 				Update(); Reset();
 				SELF.org := ofs; SELF.ofs := ofs

+ 10 - 10
source/StreamUtilities.Mod

@@ -32,11 +32,11 @@ TYPE	WriterMonitor* = OBJECT (Streams.Writer);
 		BEGIN RETURN out.CanSetPos()
 		END CanSetPos;
 
-		PROCEDURE SetPos*(pos: LONGINT);
+		PROCEDURE SetPos*(pos: Streams.Position);
 		BEGIN Reset; out.SetPos(pos);
 		END SetPos;
 
-		PROCEDURE Pos*(): LONGINT;
+		PROCEDURE Pos*(): Streams.Position;
 		BEGIN RETURN out.Pos()
 		END Pos;
 
@@ -68,7 +68,7 @@ TYPE	EncryptingWriter* = OBJECT (Streams.Writer);
 			res:=out.res;
 		END Sender;
 
-		PROCEDURE Pos*(): LONGINT;
+		PROCEDURE Pos*(): Streams.Position;
 		BEGIN RETURN out.Pos()
 		END Pos;
 
@@ -97,7 +97,7 @@ TYPE	EncryptingWriter* = OBJECT (Streams.Writer);
 			res:=in.res;
 		END Receiver;
 
-		PROCEDURE Pos*(): LONGINT;
+		PROCEDURE Pos*(): Streams.Position;
 		BEGIN RETURN in.Pos()
 		END Pos;
 
@@ -217,13 +217,13 @@ TYPE
 		BEGIN RETURN out.CanSetPos()
 		END CanSetPos;
 
-		PROCEDURE SetPos*(pos: LONGINT);
+		PROCEDURE SetPos*(pos: Streams.Position);
 		BEGIN{EXCLUSIVE}
 			AWAIT(first = NIL);
 			Reset; out.SetPos(pos);
 		END SetPos;
 
-		PROCEDURE Pos*(): LONGINT;
+		PROCEDURE Pos*(): Streams.Position;
 		BEGIN{EXCLUSIVE}
 			AWAIT(first = NIL);
 			RETURN out.Pos()
@@ -266,11 +266,11 @@ TYPE
 		BEGIN RETURN in.CanSetPos()
 		END CanSetPos;
 
-		PROCEDURE SetPos*(pos: LONGINT);
+		PROCEDURE SetPos*(pos: Streams.Position);
 		BEGIN Reset; in.SetPos(pos)
 		END SetPos;
 
-		PROCEDURE Pos*(): LONGINT;
+		PROCEDURE Pos*(): Streams.Position;
 		BEGIN RETURN in.Pos()
 		END Pos;
 
@@ -389,7 +389,7 @@ TYPE	Base64Writer* = OBJECT (Streams.Writer);
 			res:=out.res;
 		END Close;
 
-		PROCEDURE Pos*(): LONGINT;
+		PROCEDURE Pos*(): Streams.Position;
 		BEGIN RETURN out.Pos()
 		END Pos;
 
@@ -460,7 +460,7 @@ TYPE	Base64Writer* = OBJECT (Streams.Writer);
 			INC(received,len);
 		END Receiver;
 		
-		PROCEDURE Pos*(): LONGINT;
+		PROCEDURE Pos*(): Streams.Position;
 		BEGIN RETURN in.Pos()
 		END Pos;
 

+ 9 - 7
source/Streams.Mod

@@ -26,6 +26,8 @@ TYPE
 	TSize* = LONGINT;
 
 TYPE
+	Position* = LONGINT;
+
 	(** Any stream output procedure or method. *)
 	Sender* = PROCEDURE {DELEGATE} ( CONST buf: ARRAY OF CHAR;  ofs, len: LONGINT;  propagate: BOOLEAN;  VAR res: WORD );
 
@@ -45,8 +47,8 @@ TYPE
 
 	END Connection;
 
-	(** A writer buffers output before it is sent to a Sender.  Must not be shared between processes. *)
 TYPE
+	(** A writer buffers output before it is sent to a Sender.  Must not be shared between processes. *)
 	Writer* = OBJECT
 	VAR
 		tail: LONGINT;
@@ -75,7 +77,7 @@ TYPE
 			RETURN FALSE
 		END CanSetPos;
 
-		PROCEDURE SetPos*( pos: LONGINT );
+		PROCEDURE SetPos*( pos: Position );
 		BEGIN
 			HALT( 1234 )
 		END SetPos;
@@ -89,7 +91,7 @@ TYPE
 		END Update;
 
 	(** Current write position. *)
-		PROCEDURE Pos*( ): LONGINT;
+		PROCEDURE Pos*( ): Position;
 		BEGIN
 			RETURN sent + tail
 		END Pos;
@@ -516,7 +518,7 @@ TYPE
 		END CanSetPos;
 
 	(* Set the position for the writer *)
-		PROCEDURE SetPos*( pos: LONGINT );
+		PROCEDURE SetPos*( pos: Position );
 		BEGIN
 			IF pos > LEN( buf ) THEN pos := LEN( buf ) END;
 			tail := pos;  sent := 0;  res := Ok;
@@ -578,7 +580,7 @@ TYPE
 			RETURN FALSE
 		END CanSetPos;
 
-		PROCEDURE SetPos*( pos: LONGINT );
+		PROCEDURE SetPos*( pos: Position );
 		BEGIN
 			HALT( 1234 )
 		END SetPos;
@@ -599,7 +601,7 @@ TYPE
 		END Available;
 
 	(** Current read position. *)
-		PROCEDURE Pos*( ): LONGINT;
+		PROCEDURE Pos*( ): Position;
 		BEGIN
 			RETURN received - (tail - head)
 		END Pos;
@@ -1000,7 +1002,7 @@ TYPE
 		END CanSetPos;
 
 	(** Set the reader position *)
-		PROCEDURE SetPos*( pos: LONGINT );
+		PROCEDURE SetPos*( pos: Position );
 		BEGIN
 			IF pos > LEN( buf ) THEN pos := LEN( buf ) END;
 			head := pos;  tail := LEN( buf );  received := LEN( buf );  res := Ok;

+ 1 - 1
source/TextUtilities.Mod

@@ -227,7 +227,7 @@ TYPE
 			RETURN TRUE;
 		END CanSetPos;
 
-		PROCEDURE SetPos*(pos: LONGINT);
+		PROCEDURE SetPos*(pos: Streams.Position);
 		BEGIN
 			reader.text.AcquireRead;
 			reader.SetPosition(pos); (* pos is clipped *)