RopeEditingBLTImpl.Mesa
written by Bill Paxton, March 1981
Paxton, 10-Feb-82 9:13:35
Maxwell, January 5, 1983 12:11 pm
Russ Atkinson, July 22, 1983 5:55 pm
DIRECTORY
PrincOps,
PrincOpsUtils,
Rope,
RopeEditingBLT;
RopeEditingBLTImpl:
CEDAR PROGRAM
IMPORTS PrincOpsUtils
EXPORTS RopeEditingBLT
= BEGIN OPEN RopeEditingBLT;
ArrayToArrayBlt:
PUBLIC
PROC [
from: REF READONLY CharsArray, fromLoc: NAT,
to: REF CharsArray, toLoc: NAT,
nChars: NAT] = {
nLeft: NAT;
IF nChars=0 THEN RETURN;
nLeft ← nChars-1;
to[toLoc+nLeft] ← from[fromLoc+nLeft]; -- bounds check
MyByteBlt[to:[to,toLoc], from:[from,fromLoc], nBytes:nLeft];
};
ArrayToTextBlt:
PUBLIC
PROC [
from: REF READONLY CharsArray, fromLoc: NAT,
to: Text, toLoc: NAT,
nChars: NAT] = {
nLeft: NAT;
IF nChars=0 THEN RETURN;
nLeft ← nChars-1;
to[toLoc+nLeft] ← from[fromLoc+nLeft]; -- bounds check
MyByteBlt[to:[to,toLoc+TextCharOffset], from:[from,fromLoc], nBytes:nLeft];
ArrayToStringBlt:
PUBLIC
PROC [
from: REF READONLY CharsArray, fromLoc: NAT,
to: String, toLoc: NAT,
nChars: NAT] = {
nLeft: NAT;
IF nChars=0 THEN RETURN;
nLeft ← nChars-1;
to[toLoc+nLeft] ← from[fromLoc+nLeft]; -- bounds check
MyByteBlt[to:[to,toLoc+StringCharOffset], from:[from,fromLoc], nBytes:nLeft];
TextToArrayBlt:
PUBLIC
PROC [
from: Text, fromLoc: NAT,
to: REF CharsArray, toLoc: NAT,
nChars: NAT] = {
nLeft: NAT;
IF nChars=0 THEN RETURN;
nLeft ← nChars-1;
to[toLoc+nLeft] ← from[fromLoc+nLeft]; -- bounds check
MyByteBlt[to:[to,toLoc], from:[from,fromLoc+TextCharOffset], nBytes:nLeft];
StringToArrayBlt:
PUBLIC
PROC [
from: REF READONLY TEXT, fromLoc: NAT,
to: REF CharsArray, toLoc: NAT,
nChars: NAT] = {
nLeft: NAT;
IF nChars=0 THEN RETURN;
nLeft ← nChars-1;
to[toLoc+nLeft] ← from[fromLoc+nLeft]; -- bounds check
MyByteBlt[to:[to,toLoc], from:[from,fromLoc+StringCharOffset], nBytes:nLeft];
TextToTextBlt:
PUBLIC
PROC [
from: Text, fromLoc: NAT,
to: Text, toLoc: NAT,
nChars: NAT] = {
nLeft: NAT;
IF nChars=0 THEN RETURN;
nLeft ← nChars-1;
to[toLoc+nLeft] ← from[fromLoc+nLeft]; -- bounds check
MyByteBlt[to:[to,toLoc+TextCharOffset], from:[from,fromLoc+TextCharOffset], nBytes:nLeft];
TextToStringBlt:
PUBLIC
PROC [
from: Text, fromLoc: NAT,
to: String, toLoc: NAT,
nChars: NAT] = {
nLeft: NAT;
IF nChars=0 THEN RETURN;
nLeft ← nChars-1;
to[toLoc+nLeft] ← from[fromLoc+nLeft]; -- bounds check
MyByteBlt[to:[to,toLoc+StringCharOffset], from:[from,fromLoc+TextCharOffset], nBytes:nLeft];
StringToStringBlt:
PUBLIC
PROC [
from: REF READONLY TEXT, fromLoc: NAT,
to: String, toLoc: NAT,
nChars: NAT] = {
nLeft: NAT;
IF nChars=0 THEN RETURN;
nLeft ← nChars-1;
to[toLoc+nLeft] ← from[fromLoc+nLeft]; -- bounds check
MyByteBlt[to:[to,toLoc+StringCharOffset], from:[from,fromLoc+StringCharOffset], nBytes:nLeft];
ByteBlock: TYPE = RECORD [block: REF ANY, startIndex: NAT];
ROByteBlock: TYPE = RECORD [block: REF READONLY ANY, startIndex: NAT];
StringCharOffset: NAT = SIZE[TEXT[0]]*2;
TextCharOffset: NAT = SIZE[Rope.TextRep[0]]*2;
MyByteBlt:
PROC [to: ByteBlock, from: ROByteBlock, nBytes:
NAT] =
TRUSTED INLINE {
eTo, eFrom: PrincOps.ByteBltBlock;
IF nBytes=0 THEN RETURN;
eTo.blockPointer ← LOOPHOLE[to.block];
eFrom.blockPointer ← LOOPHOLE[from.block];
eTo.startIndex ← to.startIndex;
eFrom.startIndex ← from.startIndex;
eTo.stopIndexPlusOne ← to.startIndex+nBytes;
eFrom.stopIndexPlusOne ← from.startIndex+nBytes;
[] ← PrincOpsUtils.ByteBlt[eTo,eFrom];
};
-- ***** Initialization
Start:
PUBLIC
PROC = {
};
END.