GGCoreOps.mesa
Copyright Ó 1986, 1992 by Xerox Corporation. All rights reserved.
Last edited by Bier on September 12, 1987 1:30:46 pm PDT
Contents: Utility routines extracted from GGUtility and SVUtility and other places.
DIRECTORY
AtomButtons, GGCoreTypes, Imager, ImagerColor, ImagerTransformation, Rope;
GGCoreOps: CEDAR DEFINITIONS =
BEGIN
EventListt: TYPE = GGCoreTypes.EventListt; -- spelled with two t's for "List and a Tail pointer"
Event: TYPE = GGCoreTypes.Event;
RopeListt: TYPE = GGCoreTypes.RopeListt; -- spelled with two t's for "List and a Tail pointer"
ScalarButton: TYPE = AtomButtons.ScalarButton;
NewEventListt: PROC [] RETURNS [listt: EventListt];
FlushEventListt: PROC [listt: EventListt];
AppendEvent: PROC [event: Event, listt: EventListt];
NoEvents: PROC [listt: EventListt] RETURNS [BOOL];
ForEachEvent: PROC [listt: EventListt, eachEventProc: EachEventProc];
EachEventProc: TYPE = PROC [thisEvent: Event] RETURNS [done: BOOL ¬ FALSE];
NewRopeListt: PROC [] RETURNS [listt: RopeListt];
FlushRopeListt: PROC [listt: RopeListt];
AppendRope: PROC [rope: Rope.ROPE, listt: RopeListt];
NoRopes: PROC [listt: RopeListt] RETURNS [BOOL];
ForEachRope: PROC [listt: RopeListt, eachRopeProc: EachRopeProc];
EachRopeProc: TYPE = PROC [thisRope: Rope.ROPE] RETURNS [done: BOOL ¬ FALSE];
Operations on LIST OF REF ANY
StartList: PROC [] RETURNS [entityList, ptr: LIST OF REF ANY];
AddEntity: PROC [entity: REF ANY, entityList, ptr: LIST OF REF ANY] RETURNS [newList, newPtr: LIST OF REF ANY];
List:
PROC [ref1, ref2, ref3:
REF
ANY ¬
NIL]
RETURNS [
LIST
OF
REF
ANY];
Builds a LIST of up to three things. Used because the built-in LIST function compiles the code in-line making for large BCDs and broken compilers. (see GGMenuImplB.mesa for examples of use).
Operations on LIST OF REAL
StartRealList: PROC [] RETURNS [entityList, ptr: LIST OF REAL];
AddReal: PROC [entity: REAL, entityList, ptr: LIST OF REAL] RETURNS [newList, newPtr: LIST OF REAL];
AppendRealList: PROC [list1, list2: LIST OF REAL] RETURNS [result: LIST OF REAL];
SortRealList:
PROC [list:
LIST
OF
REAL, ascending:
BOOL ¬
TRUE]
RETURNS [sortedList:
LIST
OF
REAL];
Sorts the list of REAL using the MergeSort algorithm from ListImpl.
Operations on LIST OF BOOL
StartBoolList: PROC [] RETURNS [entityList, ptr: LIST OF BOOL];
AddBool: PROC [entity: BOOL, entityList, ptr: LIST OF BOOL] RETURNS [newList, newPtr: LIST OF BOOL];
AppendBoolList: PROC [list1, list2: LIST OF BOOL] RETURNS [result: LIST OF BOOL];
Operations on LIST OF NAT
StartNATList: PROC [] RETURNS [entityList, ptr: LIST OF NAT];
AddNAT: PROC [entity: NAT, entityList, ptr: LIST OF NAT] RETURNS [newList, newPtr: LIST OF NAT];
AppendNATs: PROC [list1, list2: LIST OF NAT] RETURNS [result: LIST OF NAT];
Operations on LIST OF ScalarButton
StartScalarButtonList: PROC [] RETURNS [entityList, ptr: LIST OF ScalarButton];
AddScalarButton: PROC [entity: ScalarButton, entityList, ptr: LIST OF ScalarButton] RETURNS [newList, newPtr: LIST OF ScalarButton];
AppendScalarButtons: PROC [list1, list2: LIST OF ScalarButton] RETURNS [result: LIST OF ScalarButton];
PUChoiceList:
PROC [r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13, r14, r15, r16, r17, r18, r19: AtomButtons.PopUpChoice ¬ [] ]
RETURNS [list: AtomButtons.PopUpChoices];
Builds a list of PopUpChoice. Used because the built-in LIST function compiles the code in-line making for large BCDs and broken compilers. (see GGMenuImplB.mesa for examples of use).
BreakIntervalMOD:
PROC [start, end, mod:
NAT]
RETURNS [s1, e1, s2, e2:
INT];
Given an interval of a circular buffer whose elements are numbered 0 .. mod -1, we break up the interval into one or two pieces, neither of which crosses the mod-1 to 0 boundary.
Examples: BreakIntervalMOD[6, 2, 7] => [6, 6, 0, 2];
BreakIntervalMOD[2, 6, 7] => [2, 6, -1, -1];
BreakIntervalMODLen:
PROC [start, len, mod:
NAT]
RETURNS [s1, len1, s2, len2:
INT];
Lile BreakIntervalMOD except that both the original interval and the results are expressed in the form (start of interval, length of interval) instead of [start..end].
InMODRegion:
PROC [test:
NAT, start, end, mod:
NAT]
RETURNS [
BOOL];
Non-destructive (copies the first list).
ExtractRGB: PROC [color: ImagerColor.ConstantColor] RETURNS [r,g,b: REAL];
EquivalentColors: PROC [color1, color2: Imager.Color] RETURNS [BOOL];
SetColor:
PROC [dc: Imager.Context, color: Imager.Color, m: Imager.Transformation ¬
NIL];
Calls Imager.SetColor, Imager.SetSampledColor, or Imager.SetSampledBlack as appropriate.
TransformColor: PROC [color: Imager.Color, viewView: ImagerTransformation.Transformation] RETURNS [newColor: Imager.Color];
CopyColor: PROC [color: Imager.Color] RETURNS [copy: Imager.Color];
BoolToRope:
PROC [bool:
BOOL]
RETURNS [rope: Rope.
ROPE];
Returns "T" or "F".
RopeToBool:
PROC [rope: Rope.
ROPE]
RETURNS [bool:
BOOL];
Takes "T" or "F". Raises an Error if rope is anything else.
END.