DIRECTORY IO, PropList, Rope, SharedCell, SlatePrivateTypes, Slate; SlateCommonImpl: CEDAR MONITOR IMPORTS IO, SharedCell, PropList EXPORTS Slate ~ BEGIN OPEN Slate; SessionPrivateRec: PUBLIC TYPE = SlatePrivateTypes.SessionPrivateRec; InstancePrivateRec: PUBLIC TYPE = SlatePrivateTypes.InstancePrivateRec; CallbackList: TYPE = SlatePrivateTypes.CallbackList; CallbackRec: TYPE = SlatePrivateTypes.CallbackRec; ClosureList: TYPE = SlatePrivateTypes.ClosureList; ClosureRec: TYPE = SlatePrivateTypes.ClosureRec; globalProperties: PUBLIC PropList.List ¬ PropList.NewPropList[]; globalCallbacks: CallbackList ¬ NIL; GetCallback: PROC [callbacks: CallbackList, event: REF ANY] RETURNS [CallbackList ¬ NIL] = { WHILE callbacks#NIL DO IF callbacks.first.event=event THEN RETURN [callbacks]; callbacks ¬ callbacks.rest; ENDLOOP }; CallCallbackList: PROC [callbacks: CallbackList, instance: Instance, session: Session, event: REF, callData: REF] = { cbl: CallbackList ¬ GetCallback[callbacks, event]; IF cbl#NIL THEN { closures: ClosureList ¬ cbl.first.closures; WHILE closures#NIL DO closures.first.proc[instance: instance, session: session, callData: callData, registerData: closures.first.registerData, event: event]; closures ¬ closures.rest; ENDLOOP; }; }; CallGlobalEvent: PUBLIC PROC [instance: Instance, session: Session, event: REF, callData: REF ¬ NIL] = { CallCallbackList[globalCallbacks, instance, session, event, callData]; }; CallSessionEvent: PUBLIC PROC [instance: Instance, session: Session, event: REF, callData: REF ¬ NIL] = { spr: REF SessionPrivateRec; IF session=NIL THEN session ¬ instance.session; spr ¬ session.private; CallCallbackList[spr.callbacks, instance, session, event, callData]; }; CallInstanceEvent: PUBLIC PROC [instance: Instance, session: Session, event: REF, callData: REF ¬ NIL] = { ipr: REF InstancePrivateRec ¬ instance.private; CallCallbackList[ipr.callbacks, instance, session, event, callData]; }; RegisterClosure: ENTRY PROC [cbl: CallbackList, proc: EventProc, registerData: REF] = { cbl.first.closures ¬ CONS[[proc, registerData], cbl.first.closures] }; RegisterGlobalEventProc: PUBLIC PROC [event: REF, proc: EventProc, registerData: REF] = { GetOrCreateCallback: ENTRY PROC [event: REF] RETURNS [cbl: CallbackList] = { cbl ¬ GetCallback[globalCallbacks, event]; IF cbl=NIL THEN globalCallbacks ¬ cbl ¬ CONS[[event: event, closures: NIL], globalCallbacks]; }; p: EventProc ¬ proc; IF p#NIL THEN { cbl: CallbackList ¬ GetOrCreateCallback[event]; RegisterClosure[cbl, p, registerData]; }; }; RegisterSessionEventProc: PUBLIC PROC [session: Session, event: REF, proc: EventProc, registerData: REF] = { GetOrCreateCallback: ENTRY PROC [spr: REF SessionPrivateRec, event: REF] RETURNS [cbl: CallbackList] = { cbl ¬ GetCallback[spr.callbacks, event]; IF cbl=NIL THEN spr.callbacks ¬ cbl ¬ CONS[[event: event, closures: NIL], spr.callbacks]; }; p: EventProc ¬ proc; spr: REF SessionPrivateRec ¬ session.private; IF spr#NIL AND p#NIL THEN { cbl: CallbackList ¬ GetOrCreateCallback[spr, event]; RegisterClosure[cbl, p, registerData]; }; }; RegisterInstanceEventProc: PUBLIC PROC [instance: Instance, event: REF, proc: EventProc, registerData: REF] = { GetOrCreateCallback: ENTRY PROC [ipr: REF InstancePrivateRec, event: REF] RETURNS [cbl: CallbackList] = { cbl ¬ GetCallback[ipr.callbacks, event]; IF cbl=NIL THEN ipr.callbacks ¬ cbl ¬ CONS[[event: event, closures: NIL], ipr.callbacks]; }; p: EventProc ¬ proc; ipr: REF InstancePrivateRec ¬ instance.private; IF ipr#NIL AND p#NIL THEN { cbl: CallbackList ¬ GetOrCreateCallback[ipr, event]; RegisterClosure[cbl, p, registerData]; }; }; SetSessionName: PUBLIC PROC [session: Session, name: Rope.ROPE] = { SharedCell.SetContents[session.nameCell, name]; CallGlobalEvent[instance: NIL, session: session, event: $SessionRenamed0, callData: name ! UNCAUGHT => {--catch uncaught because there is an uncaught error in SlateJoinAppImpl (July 2, 1993) IO.PutRope[session.debugLog, "uncaught error while renaming session\n"]; CONTINUE }]; }; SessionName: PUBLIC PROC [session: Session] RETURNS [Rope.ROPE] = { WITH SharedCell.GetContents[session.nameCell] SELECT FROM r: Rope.ROPE => RETURN [r]; ENDCASE => RETURN [NIL]; }; END. Κ SlateCommonImpl.mesa Copyright Σ 1992, 1993 by Xerox Corporation. All rights reserved. Created by Christian Jacobi, November 2, 1990 1:04:32 pm PST Christian Jacobi, July 3, 1993 9:58 am PDT ΚΟ•NewlineDelimiter ™™J™BIcodešœ=™=J™*J™—šΟk ˜ K˜K˜ K˜K˜ K˜K˜—J˜šΟnœœ˜Jšœ˜ Jšœ˜—Kšœœ˜K˜Kšœœœ'˜EKšœœœ(˜GK˜Kšœœœ ˜4Kšœ œœ ˜2Kšœ œœ ˜2Kšœ œœ ˜0K˜Kšœœ(˜@Kšœ œ˜$K˜š ž œœ"œœœœ˜\šœ œ˜Jšœœœ ˜7J˜Jš˜—K˜—J˜šžœœHœ œ˜uJ˜2šœœœ˜J˜+šœ œ˜K˜‡J˜Jšœ˜—J˜—K˜K˜—š žœœœ/œ œœ˜hK˜FK˜—K˜š žœœœ/œ œœ˜iKšœœ˜Kšœ œœ˜/K˜K˜DK˜—K˜š žœœœ/œ œœ˜jKšœœ'˜/K˜DK˜—K˜šžœœœ4œ˜WKšœœ*˜CK˜—K˜š žœœœ œ!œ˜Yš žœœœ œœ˜LK˜*šœœœ˜Kšœœœ˜M—K˜—K˜šœœœ˜K˜/K˜&K˜—K˜—K˜š žœœœœ!œ˜lš žœœœœœœ˜hK˜(šœœœ˜Kšœœœ˜I—K˜—K˜Kšœœ%˜-š œœœœœ˜K˜4K˜&K˜—K˜—K˜š žœœœœ!œ˜oš žœœœœœœ˜iK˜(šœœœ˜Kšœœœ˜I—K˜—K˜Kšœœ'˜/š œœœœœ˜K˜4K˜&K˜—K˜—K˜šžœœœœ˜CK˜/šœœ<˜YšœœΟcV˜eKšœF˜HKš˜—K˜—K˜K˜—šž œ œœœ˜Cšœ*œ˜9Kšœœœ˜Kšœœœ˜—K˜—K˜Kšœ˜K˜K˜—…—ˆ!