mentor/derived/StringSearchIE.m3


 Copyright (C) 1995, Digital Equipment Corporation.       
 All rights reserved.                                     
 See the file COPYRIGHT for a full description.           
                                                          
 Last modified on Thu Feb  9 08:50:48 PST 1995 by kalsow  
      modified on Sun Jun  5 21:59:57 PDT 1994 by mhb     
      modified on Wed Feb 17 16:46:47 PST 1993 by johnh   

********************************************************************

      *  NOTE: This file is generated automatically from the event
      *        definition file StringSearch.evt.
      ********************************************************************


<* PRAGMA LL *>

MODULE StringSearchIE;

<*NOWARN*> IMPORT ZeusClass, Zeus, Algorithm, View, Thread;
<*NOWARN*> IMPORT AlgorithmClass, StringSearchViewClass;
<*NOWARN*> IMPORT StringSearchAlgClass;

<* FATAL Zeus.Error, Zeus.Locked *>
If you get either of these errors, contact a Zeus implementor.

TYPE
  SetupArgs = BRANDED REF RECORD
    p: TEXT;
    s: TEXT;
  END;

  ProbeArgs = BRANDED REF RECORD
    i: CARDINAL;
    j: CARDINAL;
  END;

  ResultArgs = BRANDED REF RECORD
    res: BOOLEAN;
  END;

  PartialMatchArgs = BRANDED REF RECORD
    i: CARDINAL;
    j: CARDINAL;
    len: CARDINAL;
  END;

  PartialMatchClearArgs = BRANDED REF RECORD
  END;

  CompleteMatchArgs = BRANDED REF RECORD
    j: CARDINAL;
  END;

  SlideToArgs = BRANDED REF RECORD
    j: CARDINAL;
  END;

  KMPSetupArgs = BRANDED REF RECORD
    p: TEXT;
  END;

  AddEdgeArgs = BRANDED REF RECORD
    f: CARDINAL;
    t: CARDINAL;
  END;
Zeus calls the following to invoke vbt v's event handler:

<*NOWARN*> PROCEDURE OEDispatcher(v: ZeusClass.T; evt: REFANY) RAISES {Thread.Alerted} =
  <* LL <= VBT.mu *>
  (* LL = {} if event style is output, LL = VBT.mu if event style is update. *)
  BEGIN
    TYPECASE v OF
    | StringSearchViewClass.T (view) => <*NOWARN*>
      TYPECASE evt OF
      | SetupArgs(varSetupArgs) => <*NOWARN*>
          view.oeSetup (
              varSetupArgs.p
                ,
              varSetupArgs.s
              )
      | ProbeArgs(varProbeArgs) => <*NOWARN*>
          view.oeProbe (
              varProbeArgs.i
                ,
              varProbeArgs.j
              )
      | ResultArgs(varResultArgs) => <*NOWARN*>
          view.oeResult (
              varResultArgs.res
              )
      | PartialMatchArgs(varPartialMatchArgs) => <*NOWARN*>
          view.oePartialMatch (
              varPartialMatchArgs.i
                ,
              varPartialMatchArgs.j
                ,
              varPartialMatchArgs.len
              )
      | PartialMatchClearArgs(varPartialMatchClearArgs) => <*NOWARN*>
          view.oePartialMatchClear (
              )
      | CompleteMatchArgs(varCompleteMatchArgs) => <*NOWARN*>
          view.oeCompleteMatch (
              varCompleteMatchArgs.j
              )
      | SlideToArgs(varSlideToArgs) => <*NOWARN*>
          view.oeSlideTo (
              varSlideToArgs.j
              )
      | KMPSetupArgs(varKMPSetupArgs) => <*NOWARN*>
          view.oeKMPSetup (
              varKMPSetupArgs.p
              )
      | AddEdgeArgs(varAddEdgeArgs) => <*NOWARN*>
          view.oeAddEdge (
              varAddEdgeArgs.f
                ,
              varAddEdgeArgs.t
              )
      ELSE <* ASSERT FALSE *>
      END;
    ELSE (* this view isn't a StringSearchViewClass, so just ignore *)
    END
  END OEDispatcher;

<*NOWARN*> PROCEDURE FEDispatcher(v: ZeusClass.T; evt: REFANY) =
  <* LL = VBT.mu *>
  BEGIN
    TYPECASE v OF
    | StringSearchAlgClass.T (alg) => <*NOWARN*>
      TYPECASE evt OF
      ELSE <* ASSERT FALSE *>
      END;
    ELSE (* this alg isn't a StringSearchAlgClass, so just ignore *)
    END
  END FEDispatcher;

PROCEDURE Setup (
      initiator: Algorithm.T;
       p, s: TEXT
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(SetupArgs
               , p := p
               , s := s
      );
      alg := NARROW(initiator, StringSearchAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfSetup);
      alg.stopAtEvent := alg.eventDataRec.stopAtSetup;
      alg.waitAtEvent := alg.eventDataRec.waitAtSetup;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "Setup", OEDispatcher, zumeArgRec);
    END;
  END Setup;

PROCEDURE Probe (
      initiator: Algorithm.T;
       i, j: CARDINAL
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(ProbeArgs
               , i := i
               , j := j
      );
      alg := NARROW(initiator, StringSearchAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfProbe);
      alg.stopAtEvent := alg.eventDataRec.stopAtProbe;
      alg.waitAtEvent := alg.eventDataRec.waitAtProbe;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "Probe", OEDispatcher, zumeArgRec);
    END;
  END Probe;

PROCEDURE Result (
      initiator: Algorithm.T;
       res: BOOLEAN
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(ResultArgs
               , res := res
      );
      alg := NARROW(initiator, StringSearchAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfResult);
      alg.stopAtEvent := alg.eventDataRec.stopAtResult;
      alg.waitAtEvent := alg.eventDataRec.waitAtResult;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "Result", OEDispatcher, zumeArgRec);
    END;
  END Result;

PROCEDURE PartialMatch (
      initiator: Algorithm.T;
       i, j, len: CARDINAL
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(PartialMatchArgs
               , i := i
               , j := j
               , len := len
      );
      alg := NARROW(initiator, StringSearchAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfPartialMatch);
      alg.stopAtEvent := alg.eventDataRec.stopAtPartialMatch;
      alg.waitAtEvent := alg.eventDataRec.waitAtPartialMatch;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "PartialMatch", OEDispatcher, zumeArgRec);
    END;
  END PartialMatch;

PROCEDURE PartialMatchClear (
      initiator: Algorithm.T;

    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(PartialMatchClearArgs
      );
      alg := NARROW(initiator, StringSearchAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfPartialMatchClear);
      alg.stopAtEvent := alg.eventDataRec.stopAtPartialMatchClear;
      alg.waitAtEvent := alg.eventDataRec.waitAtPartialMatchClear;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "PartialMatchClear", OEDispatcher, zumeArgRec);
    END;
  END PartialMatchClear;

PROCEDURE CompleteMatch (
      initiator: Algorithm.T;
       j: CARDINAL
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(CompleteMatchArgs
               , j := j
      );
      alg := NARROW(initiator, StringSearchAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfCompleteMatch);
      alg.stopAtEvent := alg.eventDataRec.stopAtCompleteMatch;
      alg.waitAtEvent := alg.eventDataRec.waitAtCompleteMatch;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "CompleteMatch", OEDispatcher, zumeArgRec);
    END;
  END CompleteMatch;

PROCEDURE SlideTo (
      initiator: Algorithm.T;
       j: CARDINAL
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(SlideToArgs
               , j := j
      );
      alg := NARROW(initiator, StringSearchAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfSlideTo);
      alg.stopAtEvent := alg.eventDataRec.stopAtSlideTo;
      alg.waitAtEvent := alg.eventDataRec.waitAtSlideTo;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "SlideTo", OEDispatcher, zumeArgRec);
    END;
  END SlideTo;

PROCEDURE KMPSetup (
      initiator: Algorithm.T;
       p: TEXT
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(KMPSetupArgs
               , p := p
      );
      alg := NARROW(initiator, StringSearchAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfKMPSetup);
      alg.stopAtEvent := alg.eventDataRec.stopAtKMPSetup;
      alg.waitAtEvent := alg.eventDataRec.waitAtKMPSetup;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "KMPSetup", OEDispatcher, zumeArgRec);
    END;
  END KMPSetup;

PROCEDURE AddEdge (
      initiator: Algorithm.T;
       f, t: CARDINAL
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(AddEdgeArgs
               , f := f
               , t := t
      );
      alg := NARROW(initiator, StringSearchAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfAddEdge);
      alg.stopAtEvent := alg.eventDataRec.stopAtAddEdge;
      alg.waitAtEvent := alg.eventDataRec.waitAtAddEdge;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "AddEdge", OEDispatcher, zumeArgRec);
    END;
  END AddEdge;

BEGIN
END StringSearchIE.

interface View is in: