DIRECTORY Asserting, Atom, IO, List, RoseEvents, RoseTypes; RoseEventsImpl: CEDAR PROGRAM IMPORTS Asserting, Atom, IO, List, RoseTypes EXPORTS RoseEvents = BEGIN OPEN RoseTypes; all: PUBLIC REF ANY _ NEW [ROPE _ "All watcheds"]; watchersKey: ATOM _ Atom.MakeAtom["Spreitzer January 6, 1984 8:07 pm"]; ForWatchers: PROC [event: ATOM, watched: REF ANY, do: PROC [WatcherList] RETURNS [WatcherList], replace: BOOL] = { wll: List.AList; wl: WatcherList; IF watched # NIL THEN WITH watched SELECT FROM node: Node => { SELECT event FROM $ChangeEarly => node.watchers[high] _ do[node.watchers[high]]; $ChangeLate => node.watchers[ordinary] _ do[node.watchers[ordinary]]; ENDCASE => BEGIN wl _ NARROW[Asserting.FnVal[fn: event, from: node.other]]; wl _ do[wl]; IF replace THEN node.other _ Asserting.AssertFn1[fn: event, val: wl, inAdditionTo: node.other]; END; RETURN}; cell: Cell => { SELECT event FROM $Schedule => {IF cell.substantiality = Shadow THEN ERROR Error[IO.PutFR["Cell %g not Real", IO.rope[cell.name]]]; cell.realCellStuff.schedWatchers _ do[cell.realCellStuff.schedWatchers]}; $Eval => {IF cell.substantiality = Shadow THEN ERROR Error[IO.PutFR["Cell %g not Real", IO.rope[cell.name]]]; cell.realCellStuff.evalWatchers _ do[cell.realCellStuff.evalWatchers]}; ENDCASE => BEGIN wl _ NARROW[Asserting.FnVal[fn: event, from: cell.other]]; wl _ do[wl]; IF replace THEN cell.other _ Asserting.AssertFn1[fn: event, val: wl, inAdditionTo: cell.other]; END; RETURN}; ENDCASE; wll _ NARROW[Atom.GetProp[atom: event, prop: watchersKey]]; wl _ NARROW[List.Assoc[key: watched, aList: wll]]; wl _ do[wl]; IF replace THEN { wll _ List.PutAssoc[key: watched, val: wl, aList: wll]; Atom.PutProp[atom: event, prop: watchersKey, val: wll]; }; }; AddWatcher: PUBLIC PROC [event: ATOM, watcher: Watcher, watched: REF ANY _ NIL] = BEGIN Addit: PROC [ohne: WatcherList] RETURNS [mit: WatcherList] = {mit _ CONS[watcher, ohne]}; ForWatchers[event, watched, Addit, TRUE]; END; RemoveWatcher: PUBLIC PROC [event: ATOM, watcher: Watcher, watched: REF ANY _ NIL] = BEGIN RemoveIt: PROC [watchers: WatcherList] RETURNS [ohne: WatcherList] = { cur, prev: WatcherList _ NIL; ohne _ watchers; FOR cur _ watchers, cur.rest WHILE cur # NIL DO IF cur.first = watcher THEN {IF prev = NIL THEN ohne _ cur.rest ELSE prev.rest _ cur.rest; RETURN}; prev _ cur; ENDLOOP; }; ForWatchers[event, watched, RemoveIt, TRUE]; END; Notify: PUBLIC PROC [event: ATOM, watched: REF ANY _ NIL, handleAborted: BOOL, arg: REF ANY _ NIL] = BEGIN abort: BOOLEAN _ FALSE; abortedWatchers: WatcherList _ NIL; NotifyEm: PROC [wl: WatcherList] RETURNS [same: WatcherList] = { same _ wl; FOR wl _ wl, wl.rest WHILE wl # NIL DO wl.first.Notify[ event: event, watched: watched, watcherData: wl.first.watcherData, arg: arg !ABORTED => IF handleAborted THEN { abort _ TRUE; abortedWatchers _ CONS[wl.first, abortedWatchers]; CONTINUE}]; ENDLOOP; }; IF watched = all THEN ERROR; ForWatchers[event, watched, NotifyEm, FALSE]; ForWatchers[event, all, NotifyEm, FALSE]; IF abort THEN ERROR ABORTED; END; END. r[Indigo]r>Rosemary.DF=>RoseEventsImpl.Mesa Last Edited by: Spreitzer, May 1, 1985 7:44:21 pm PDT สn– "cedar" style˜Jšœฯmœ!™4J™5J˜Jšฯk œ2˜;J˜codešะbxœžœž˜Kšžœ%˜,Kšžœ ˜—K˜Kšžœžœ ˜K˜Kš œžœžœžœžœžœ˜2K˜Kšœ žœ6˜GK˜šฯn œžœ žœ žœžœžœžœžœ˜rKšœ˜Kšœ˜š žœ žœžœžœ žœž˜.˜šžœž˜Kšœ>˜>KšœE˜Ešžœž˜Kšœžœ/˜:Kšœ ˜ Kšžœ žœP˜_Kšžœ˜——Kšžœ˜—˜šžœž˜š œžœžœžœžœžœ˜qKšœI˜I—š œ žœžœžœžœžœ˜mKšœG˜G—šžœž˜Kšœžœ/˜:Kšœ ˜ Kšžœ žœP˜_Kšžœ˜——Kšžœ˜—Kšžœ˜—Kšœžœ/˜;Kšœžœ'˜2Kšœ ˜ šžœ žœ˜Kšœ7˜7K˜7K˜—K˜—K˜š  œžœžœ žœžœžœžœ˜QKšž˜š œžœžœ˜Kšžœ˜—K˜ Kšžœ˜—K˜—Kšœ&žœ˜,Kšžœ˜—K˜š œžœžœ žœ žœžœžœžœžœžœžœ˜dKšž˜Kšœžœžœ˜Kšœžœ˜#š œžœžœ˜@K˜ šžœžœžœž˜&šœ˜Kšœ ˜ Kšœ˜Kšœ"˜"K˜šœžœžœžœ˜#Kšœžœ˜ Kšœžœ˜2Kšžœ˜ ——Kšžœ˜—K˜—Kšžœžœžœ˜Kšœ&žœ˜-Kšœ"žœ˜)Kšžœžœžœžœ˜Kšžœ˜—K˜Kšžœ˜—…— ๒า