rsrcservice/derived/RsrcService_T_v1.m3


MODULE RsrcService_T_v1 EXPORTS RsrcService, RsrcService_T_v1;

IMPORT TextSeq, Rd, Wr, StubLib, TextTextTbl, Thread, RsrcService, NetObj;
CONST Protocol: StubLib.StubProtocol = 1;

TYPE
      Methods = {getRsrcAsText, getRsrcReader, getRsrcPath, setRsrcPath,
        readConfig};
      ReturnCodes = {OK, RsrcService_E};

  PROCEDURE Surrogate_readConfig(self: RsrcService.T; fn_arg: TEXT)
       RAISES {NetObj.Error, RsrcService.E, Thread.Alerted} =

    VAR reuse := FALSE;
        rep: StubLib.DataRep;
        c: StubLib.Conn;
        dataPresent: BOOLEAN; <* NOWARN *>

    BEGIN
      TRY
        c := StubLib.StartCall(self, Protocol);
        TRY
          StubLib.OutInt32(c, ORD(Methods.readConfig));
          StubLib.OutRef(c, fn_arg);
          rep := StubLib.AwaitResult(c);
          CASE StubLib.InInt32(c, rep) OF
          | ORD(ReturnCodes.OK) =>
            reuse := TRUE;
          | ORD(ReturnCodes.RsrcService_E) =>
            VAR arg: TEXT;
            BEGIN
              arg := StubLib.InRef(c, rep, -1);
              reuse := TRUE;
              RAISE RsrcService.E(arg);

            END;
          ELSE
            StubLib.RaiseUnmarshalFailure();
          END
        FINALLY
          StubLib.EndCall(c, reuse);
        END;

      EXCEPT
      | Rd.Failure(ec) => StubLib.RaiseCommFailure(ec);
      | Wr.Failure(ec) => StubLib.RaiseCommFailure(ec);
      END;
    END Surrogate_readConfig;

  PROCEDURE Surrogate_setRsrcPath(
      self: RsrcService.T;
      name_arg: TEXT;
      rp_arg: TextSeq.T) RAISES {NetObj.Error, RsrcService.E,
      Thread.Alerted} =

    VAR reuse := FALSE;
        rep: StubLib.DataRep;
        c: StubLib.Conn;
        dataPresent: BOOLEAN; <* NOWARN *>

    BEGIN
      TRY
        c := StubLib.StartCall(self, Protocol);
        TRY
          StubLib.OutInt32(c, ORD(Methods.setRsrcPath));
          StubLib.OutRef(c, name_arg);
          StubLib.OutRef(c, rp_arg);
          rep := StubLib.AwaitResult(c);
          CASE StubLib.InInt32(c, rep) OF
          | ORD(ReturnCodes.OK) =>
            reuse := TRUE;
          | ORD(ReturnCodes.RsrcService_E) =>
            VAR arg: TEXT;
            BEGIN
              arg := StubLib.InRef(c, rep, -1);
              reuse := TRUE;
              RAISE RsrcService.E(arg);

            END;
          ELSE
            StubLib.RaiseUnmarshalFailure();
          END
        FINALLY
          StubLib.EndCall(c, reuse);
        END;

      EXCEPT
      | Rd.Failure(ec) => StubLib.RaiseCommFailure(ec);
      | Wr.Failure(ec) => StubLib.RaiseCommFailure(ec);
      END;
    END Surrogate_setRsrcPath;

  PROCEDURE Surrogate_getRsrcPath(self: RsrcService.T; name_arg: TEXT)
      : TextSeq.T RAISES {NetObj.Error, RsrcService.E, Thread.Alerted} =

    VAR reuse := FALSE;
        rep: StubLib.DataRep;
        c: StubLib.Conn;
        dataPresent: BOOLEAN; <* NOWARN *>
        res: TextSeq.T;

    BEGIN
      TRY
        c := StubLib.StartCall(self, Protocol);
        TRY
          StubLib.OutInt32(c, ORD(Methods.getRsrcPath));
          StubLib.OutRef(c, name_arg);
          rep := StubLib.AwaitResult(c);
          CASE StubLib.InInt32(c, rep) OF
          | ORD(ReturnCodes.OK) =>
            res := StubLib.InRef(c, rep, TYPECODE(TextSeq.T));
            reuse := TRUE;
          | ORD(ReturnCodes.RsrcService_E) =>
            VAR arg: TEXT;
            BEGIN
              arg := StubLib.InRef(c, rep, -1);
              reuse := TRUE;
              RAISE RsrcService.E(arg);

            END;
          ELSE
            StubLib.RaiseUnmarshalFailure();
          END
        FINALLY
          StubLib.EndCall(c, reuse);
        END;

      EXCEPT
      | Rd.Failure(ec) => StubLib.RaiseCommFailure(ec);
      | Wr.Failure(ec) => StubLib.RaiseCommFailure(ec);
      END;
      RETURN res;
    END Surrogate_getRsrcPath;

  PROCEDURE Surrogate_getRsrcReader(
      self: RsrcService.T;
      name_arg: TEXT;
      env_arg: TextTextTbl.T): Rd.T RAISES {NetObj.Error, RsrcService.E,
      Thread.Alerted} =

    VAR reuse := FALSE;
        rep: StubLib.DataRep;
        c: StubLib.Conn;
        dataPresent: BOOLEAN; <* NOWARN *>
        res: Rd.T;

    BEGIN
      TRY
        c := StubLib.StartCall(self, Protocol);
        TRY
          StubLib.OutInt32(c, ORD(Methods.getRsrcReader));
          StubLib.OutRef(c, name_arg);
          StubLib.OutRef(c, env_arg);
          rep := StubLib.AwaitResult(c);
          CASE StubLib.InInt32(c, rep) OF
          | ORD(ReturnCodes.OK) =>
            res := StubLib.InRef(c, rep, TYPECODE(Rd.T));
            reuse := TRUE;
          | ORD(ReturnCodes.RsrcService_E) =>
            VAR arg: TEXT;
            BEGIN
              arg := StubLib.InRef(c, rep, -1);
              reuse := TRUE;
              RAISE RsrcService.E(arg);

            END;
          ELSE
            StubLib.RaiseUnmarshalFailure();
          END
        FINALLY
          StubLib.EndCall(c, reuse);
        END;

      EXCEPT
      | Rd.Failure(ec) => StubLib.RaiseCommFailure(ec);
      | Wr.Failure(ec) => StubLib.RaiseCommFailure(ec);
      END;
      RETURN res;
    END Surrogate_getRsrcReader;

  PROCEDURE Surrogate_getRsrcAsText(
      self: RsrcService.T;
      name_arg: TEXT;
      env_arg: TextTextTbl.T): TEXT RAISES {NetObj.Error, RsrcService.E,
      Thread.Alerted} =

    VAR reuse := FALSE;
        rep: StubLib.DataRep;
        c: StubLib.Conn;
        dataPresent: BOOLEAN; <* NOWARN *>
        res: TEXT;

    BEGIN
      TRY
        c := StubLib.StartCall(self, Protocol);
        TRY
          StubLib.OutInt32(c, ORD(Methods.getRsrcAsText));
          StubLib.OutRef(c, name_arg);
          StubLib.OutRef(c, env_arg);
          rep := StubLib.AwaitResult(c);
          CASE StubLib.InInt32(c, rep) OF
          | ORD(ReturnCodes.OK) =>
            res := StubLib.InRef(c, rep, -1);
            reuse := TRUE;
          | ORD(ReturnCodes.RsrcService_E) =>
            VAR arg: TEXT;
            BEGIN
              arg := StubLib.InRef(c, rep, -1);
              reuse := TRUE;
              RAISE RsrcService.E(arg);

            END;
          ELSE
            StubLib.RaiseUnmarshalFailure();
          END
        FINALLY
          StubLib.EndCall(c, reuse);
        END;

      EXCEPT
      | Rd.Failure(ec) => StubLib.RaiseCommFailure(ec);
      | Wr.Failure(ec) => StubLib.RaiseCommFailure(ec);
      END;
      RETURN res;
    END Surrogate_getRsrcAsText;

PROCEDURE Invoke(
    c: StubLib.Conn;
    obj: NetObj.T;
    rep: StubLib.DataRep;
    stubProt: StubLib.StubProtocol)
    RAISES {NetObj.Error, Rd.Failure,
            Wr.Failure, Thread.Alerted} =
  VAR t := NARROW(obj, RsrcService.T);
  BEGIN
    IF stubProt # Protocol THEN StubLib.RaiseUnmarshalFailure() END;
    TRY
      CASE StubLib.InInt32(c, rep) OF
      | ORD(Methods.readConfig) => Stub_readConfig(t, c, rep);
      | ORD(Methods.setRsrcPath) => Stub_setRsrcPath(t, c, rep);
      | ORD(Methods.getRsrcPath) => Stub_getRsrcPath(t, c, rep);
      | ORD(Methods.getRsrcReader) => Stub_getRsrcReader(t, c, rep);
      | ORD(Methods.getRsrcAsText) => Stub_getRsrcAsText(t, c, rep);
      ELSE
        StubLib.RaiseUnmarshalFailure();
      END;
    EXCEPT
    | RsrcService.E(arg) =>
        StubLib.StartResult(c);
        StubLib.OutInt32(c, ORD(ReturnCodes.RsrcService_E));
        StubLib.OutRef(c, arg);
    END;
  END Invoke;

PROCEDURE Stub_readConfig(
    self: RsrcService.T;
    c: StubLib.Conn;
    <* NOWARN *> rep: StubLib.DataRep) RAISES {NetObj.Error, Rd.Failure,
    Wr.Failure, Thread.Alerted, RsrcService.E}=
  VAR fn_arg: TEXT;
      dataPresent: BOOLEAN <* NOWARN *>;

  BEGIN
    fn_arg := StubLib.InRef(c, rep, -1);
    self.readConfig(fn_arg);
    StubLib.StartResult(c);
    StubLib.OutInt32(c, ORD(ReturnCodes.OK));

  END Stub_readConfig;

PROCEDURE Stub_setRsrcPath(
    self: RsrcService.T;
    c: StubLib.Conn;
    <* NOWARN *> rep: StubLib.DataRep) RAISES {NetObj.Error, Rd.Failure,
    Wr.Failure, Thread.Alerted, RsrcService.E}=
  VAR name_arg: TEXT;
      rp_arg: TextSeq.T;
      dataPresent: BOOLEAN <* NOWARN *>;

  BEGIN
    name_arg := StubLib.InRef(c, rep, -1);
    rp_arg := StubLib.InRef(c, rep, TYPECODE(TextSeq.T));
    self.setRsrcPath(name_arg, rp_arg);
    StubLib.StartResult(c);
    StubLib.OutInt32(c, ORD(ReturnCodes.OK));

  END Stub_setRsrcPath;

PROCEDURE Stub_getRsrcPath(
    self: RsrcService.T;
    c: StubLib.Conn;
    <* NOWARN *> rep: StubLib.DataRep) RAISES {NetObj.Error, Rd.Failure,
    Wr.Failure, Thread.Alerted, RsrcService.E}=
  VAR name_arg: TEXT;
      res: TextSeq.T;
      dataPresent: BOOLEAN <* NOWARN *>;

  BEGIN
    name_arg := StubLib.InRef(c, rep, -1);
    res := self.getRsrcPath(name_arg);
    StubLib.StartResult(c);
    StubLib.OutInt32(c, ORD(ReturnCodes.OK));
    StubLib.OutRef(c, res);

  END Stub_getRsrcPath;

PROCEDURE Stub_getRsrcReader(
    self: RsrcService.T;
    c: StubLib.Conn;
    <* NOWARN *> rep: StubLib.DataRep) RAISES {NetObj.Error, Rd.Failure,
    Wr.Failure, Thread.Alerted, RsrcService.E}=
  VAR name_arg: TEXT;
      env_arg: TextTextTbl.T;
      res: Rd.T;
      dataPresent: BOOLEAN <* NOWARN *>;

  BEGIN
    name_arg := StubLib.InRef(c, rep, -1);
    env_arg := StubLib.InRef(c, rep, TYPECODE(TextTextTbl.T));
    res := self.getRsrcReader(name_arg, env_arg);
    StubLib.StartResult(c);
    StubLib.OutInt32(c, ORD(ReturnCodes.OK));
    StubLib.OutRef(c, res);

  END Stub_getRsrcReader;

PROCEDURE Stub_getRsrcAsText(
    self: RsrcService.T;
    c: StubLib.Conn;
    <* NOWARN *> rep: StubLib.DataRep) RAISES {NetObj.Error, Rd.Failure,
    Wr.Failure, Thread.Alerted, RsrcService.E}=
  VAR name_arg: TEXT;
      env_arg: TextTextTbl.T;
      res: TEXT;
      dataPresent: BOOLEAN <* NOWARN *>;

  BEGIN
    name_arg := StubLib.InRef(c, rep, -1);
    env_arg := StubLib.InRef(c, rep, TYPECODE(TextTextTbl.T));
    res := self.getRsrcAsText(name_arg, env_arg);
    StubLib.StartResult(c);
    StubLib.OutInt32(c, ORD(ReturnCodes.OK));
    StubLib.OutRef(c, res);

  END Stub_getRsrcAsText;

BEGIN
  StubLib.Register(TYPECODE(RsrcService.T), 1, TYPECODE(Surrogate_RsrcService_T), Invoke);
END RsrcService_T_v1.