-- JaMStorage.mesa
-- Last edit by Doug Wyatt,  7-Oct-81 16:40:17

JaMStorage: DEFINITIONS = {

Zone: PROC RETURNS[UNCOUNTED ZONE];

Prune: PROC;

-- Expanding text operations

TextObject: TYPE = PRIVATE RECORD[text,cache: LONG STRING, len,max,lim: CARDINAL];

TextNew: PROC[s: LONG STRING, lim: CARDINAL ← LAST[NAT]] RETURNS[TextObject] = INLINE {
  RETURN[[text: s, cache: s, len: 0, max: s.maxlength, lim: lim]] };

TextPut: PROC[t: POINTER TO TextObject, c: CHARACTER] = INLINE {
  i: CARDINAL = t.len; IF i<t.max THEN { t.text[i] ← c; t.len ← i + 1 }
  ELSE PrivateTextPut[t,c] };

TextRead: PROC[t: POINTER TO TextObject] RETURNS[LONG STRING] = INLINE {
  s: LONG STRING ← t.text; s.length ← t.len; RETURN[s] };

TextLen: PROC[t: POINTER TO TextObject] RETURNS[CARDINAL] = INLINE { RETURN[t.len] };

TextReset: PROC[t: POINTER TO TextObject] = INLINE { t.len ← 0 };

TextFree: PROC[t: POINTER TO TextObject] = INLINE {
  IF t.text#t.cache THEN PrivateTextFree[t]; t.max ← t.lim ← 0 };

PrivateTextPut: PRIVATE PROC[t: POINTER TO TextObject, c: CHARACTER];
PrivateTextFree: PRIVATE PROC[t: POINTER TO TextObject];

}.