MobConnection.mx
Copyright Ó 1989, 1991 by Xerox Corporation. All rights reserved.
Created by Michael Plass, May 2, 1989
Michael Plass, December 2, 1991 2:02 pm PST
Cedar Primitives
(cedar-imports "MobConnection")
(cedar-directory "Rope")
(cedar-require "Require Cedar MobConnection MobConnection")
(release-as "Cedar" "MobConnection")
(define-ref-type "Scheme" "Symbol")
(define-enum-type "MobConnection" "FilterItem"
(versions directory using imports imported-items exports type-exports exported-items modules configurations))
(primitive-enable
MobConnection.Error => Complain[culprit, msg];
)
Appender: TYPE = RECORD [head, last: Pair];
(define-proc (decode-mob filename (filter))
"Extract useful information from a mob file"
stack: LIST OF Appender ← NIL;
Begin: PROC [id: Symbol] = {
head: Pair = Cons[id, NIL];
stack ← CONS[[head, head], stack];
};
End: PROC = {
a: Any ← stack.first.head;
stack ← stack.rest;
IF stack = NIL THEN result ← a ELSE Put[a];
};
Put: PROC [a: Any] = {
stack.first.last ← stack.first.last.cdr ← Cons[a, NIL]
};
PutATOM: PROC [a: Symbol] = {Put[a]};
PutROPE: PROC [a: Rope.ROPE] = {Put[StringFromRope[a]]};
PutINT: PROC [a: INT] = {Put[MakeFixnum[a]]};
PutBOOL: PROC [a: BOOL] = {Put[IF a THEN true ELSE false]};
PutModuleID: PROC [a: MobConnection.ModuleID] = {
Begin[$id]; PutATOM[a.identifier]; PutATOM[a.version]; End[]
};
f: MobConnection.Filter ← ALL[FALSE];
IF filter = undefined
THEN f ← ALL[TRUE]
ELSE {
FOR tail: Any ← filter, Cdr[tail] UNTIL tail = NIL DO
f[TheFilterItem[Car[tail]]] ← TRUE;
ENDLOOP;
};
MobConnection.DecodeMob[fileName: RopeFromString[TheString[filename]], begin: Begin, end: End, putATOM: PutATOM, putROPE: PutROPE, putINT: PutINT, putBOOL: PutBOOL, putModuleID: PutModuleID, filter: f];
IF stack # NIL THEN ERROR;
)
(define mob-all '(versions directory using imports imported-items exports type-exports exported-items modules configurations))