IOExtrasImpl.mesa
Copyright © 1986 by Xerox Corporation. All rights reserved.
Hal Murray, March 20, 1986 11:57:22 pm PST
DIRECTORY
Endian USING [bytesPerFWord, bytesPerHWord, FWORD, HWORD],
IO USING [EndOfStream, STREAM, UnsafeGetBlock, UnsafePutBlock],
IOExtras USING [];
Extensions to IO
GetHWord:
PUBLIC
PROC [self:
IO.STREAM]
RETURNS [hword: Endian.
HWORD] =
TRUSTED {
bytes: INT;
bytes ← IO.UnsafeGetBlock[self, [LOOPHOLE[LONG[@hword]], 0, Endian.bytesPerHWord]];
IF bytes # Endian.bytesPerHWord THEN ERROR IO.EndOfStream[self];
};
PutHWord:
PUBLIC
PROC [self:
IO.STREAM, hword: Endian.
HWORD] =
TRUSTED {
IO.UnsafePutBlock[self, [LOOPHOLE[LONG[@hword]], 0, Endian.bytesPerHWord]];
};
GetFWord:
PUBLIC
PROC [self:
IO.STREAM]
RETURNS [fword: Endian.
FWORD] =
TRUSTED {
bytes: INT;
bytes ← IO.UnsafeGetBlock[self, [LOOPHOLE[LONG[@fword]], 0, Endian.bytesPerFWord]];
IF bytes # Endian.bytesPerHWord THEN IO.EndOfStream[self];
};
PutFWord:
PUBLIC
PROC [self:
IO.STREAM, fword: Endian.
FWORD] =
TRUSTED {
IO.UnsafePutBlock[self, [LOOPHOLE[LONG[@fword]], 0, Endian.bytesPerFWord]];
};
}.