-- fourtwoGetPutImpl.mesa
-- Please do not edit this file.
-- It was generated using CedarRPCGen.

DIRECTORY
  Rope,
  SunRPC,
  fourtwo,
  fourtwoGetPut;

fourtwoGetPutImpl: CEDAR PROGRAM
  IMPORTS SunRPC  EXPORTS fourtwo, fourtwoGetPut =
BEGIN
Handle: TYPE = SunRPC.Handle;

ROPE: TYPE = Rope.ROPE;

GetanswerRec: PUBLIC PROC[h: Handle] RETURNS [res: fourtwo.answerRec] = {
    res.theAnswer ← SunRPC.GetInt32[h];
    res.aDifferentAnswer ← SunRPC.GetRope[h];
    res.anotherAnswer ← SunRPC.GetRefText[h];
    IF SunRPC.GetInt32[h] # 0 THEN {
      res.anotherDifferentAnswer ← NEW[INT32];
      res.anotherDifferentAnswer↑ ← SunRPC.GetInt32[h];
      }
    ELSE
      res.anotherDifferentAnswer ← NIL;
  };

PutanswerRec: PUBLIC PROC[h: Handle, in: fourtwo.answerRec] = {
    SunRPC.PutInt32[h, in.theAnswer];
    SunRPC.PutRope[h, in.aDifferentAnswer];
    SunRPC.PutRefText[h, in.anotherAnswer];
    IF in.anotherDifferentAnswer = NIL THEN {
      SunRPC.PutInt32[h, 0];
    }
    ELSE {
      SunRPC.PutInt32[h, 1];
      SunRPC.PutInt32[h, in.anotherDifferentAnswer↑];
    };
  };

GetquestionRec: PUBLIC PROC[h: Handle] RETURNS [res: fourtwo.questionRec] = {
    res.theQuestion ← SunRPC.GetRope[h];
    res.aRandomNumber ← SunRPC.GetCard32[h];
    res.anotherQuestion ← SunRPC.GetRefText[h];
  };

PutquestionRec: PUBLIC PROC[h: Handle, in: fourtwo.questionRec] = {
    SunRPC.PutRope[h, in.theQuestion];
    SunRPC.PutCard32[h, in.aRandomNumber];
    SunRPC.PutRefText[h, in.anotherQuestion];
  };

GetFoo: PUBLIC PROC[h: Handle] RETURNS [res: fourtwo.Foo] = {
    FOR i: INT IN [0..fourtwo.ANSWERSIZE) DO
      [] ← SunRPC.GetByte[h];
      [] ← SunRPC.GetByte[h];
      [] ← SunRPC.GetByte[h];
      res.bytes[i] ← SunRPC.GetByte[h];
      ENDLOOP;
  };

PutFoo: PUBLIC PROC[h: Handle, in: fourtwo.Foo] = {
    FOR i: INT IN [0..fourtwo.ANSWERSIZE) DO
      SunRPC.PutInt32[h, in.bytes[i]];
      ENDLOOP;
  };

END.