CDEvents.mesa a ChipNDale module
Copyright © 1983, 1985 by Xerox Corporation. All rights reserved.
Created by Christian Jacobi, September 16, 1983 2:11 pm
Last edited by: Christian Jacobi, September 19, 1986 11:13:50 am PDT
DIRECTORY CD;
CDEvents: CEDAR DEFINITIONS =
BEGIN
Events are like interrupts. Some procedure might raise an event, which will cause all the registered handlers to be called. To prevent uncontrolled calling of an event, an implementor can hide the EventRegistration.
--Client level
EventProc: TYPE = PROC [event: REF, design: CD.Design, x: REF] RETURNS [dont: BOOL FALSE];
--The type for an event proc
--dont: will abort (some) events and (sometimes) the remaining EventProcs
--event is the event which caused the call
--design: onto which event happened; can be NIL
--x: parameter passed through from ProcessEvent, event-specific
--Eventprocs must not be fast; ChipNDale calls events on time critical places
RegisterEventProc: PROC [event: REF, proc: EventProc, filter: CD.Technology ← NIL];
--Registers a procedure which is called each time a specific event occurs.
--The procedure might stop certain events with the dont result.
--If filter#NIL, proc is only called if event occurs on design of technology=filter.
--event must have been previously registered with RegisterEventType
--Implementor level
EventRegistration: TYPE = REF EventRegistrationRep;
EventRegistrationRep: TYPE;
RegisterEventType: PROC [event: REF, reverse: BOOLFALSE, continueOnAbort: BOOLTRUE] RETURNS [EventRegistration];
--Registration of an event where event procs are called.
--even: Identity of event; if atoms are used, the atom should be entered
-- manually in the appropriate documentation file.
--reverse: ProcessEvent calls events in reversed order of registration.
--continueOnAbort: Protection of critical places from flaky clients.
--The returned EventRegistration is the key to call ProcessEvent
--May raise CD.Error[doubleRegistration] and others.
ProcessEvent: PROC [eventRegistration: EventRegistration, design: CD.Design, x: REF NIL, listenToDont: BOOL FALSE] RETURNS [dont: BOOL];
--Calls all registered events
--eventRegistration: EventRegistration as returned from RegisterEventType
--design, x: passed through to event handlers
--listenToDont: stops calling further event handlers if any one returs dont=TRUE
--dont: if any one handler returns dont=TRUE
END.