MODULE ObValue_RemVar_v1 EXPORTS ObValue, ObValue_RemVar_v1;
IMPORT Rd, Wr, StubLib, ObValue, Thread, NetObj;
CONST Protocol: StubLib.StubProtocol = 1;
TYPE
Methods = {Set, Get};
ReturnCodes = {OK};
PROCEDURE Surrogate_Get(self: ObValue.RemVar): ObValue.Val
RAISES {NetObj.Error, Thread.Alerted} =
VAR reuse := FALSE;
rep: StubLib.DataRep;
c: StubLib.Conn;
dataPresent: BOOLEAN; <* NOWARN *>
res: ObValue.Val;
BEGIN
TRY
c := StubLib.StartCall(self, Protocol);
TRY
StubLib.OutInt32(c, ORD(Methods.Get));
rep := StubLib.AwaitResult(c);
CASE StubLib.InInt32(c, rep) OF
| ORD(ReturnCodes.OK) =>
res := StubLib.InRef(c, rep, TYPECODE(ObValue.Val));
reuse := TRUE;
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_Get;
PROCEDURE Surrogate_Set(self: ObValue.RemVar; val_arg: ObValue.Val)
RAISES {NetObj.Error, 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.Set));
StubLib.OutRef(c, val_arg);
rep := StubLib.AwaitResult(c);
CASE StubLib.InInt32(c, rep) OF
| ORD(ReturnCodes.OK) =>
reuse := TRUE;
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_Set;
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, ObValue.RemVar);
BEGIN
IF stubProt # Protocol THEN StubLib.RaiseUnmarshalFailure() END;
TRY
CASE StubLib.InInt32(c, rep) OF
| ORD(Methods.Get) => Stub_Get(t, c, rep);
| ORD(Methods.Set) => Stub_Set(t, c, rep);
ELSE
StubLib.RaiseUnmarshalFailure();
END;
EXCEPT
END;
END Invoke;
PROCEDURE Stub_Get(
self: ObValue.RemVar;
c: StubLib.Conn;
<* NOWARN *> rep: StubLib.DataRep) RAISES {NetObj.Error, Rd.Failure,
Wr.Failure, Thread.Alerted}=
VAR res: ObValue.Val;
dataPresent: BOOLEAN <* NOWARN *>;
BEGIN
res := self.Get();
StubLib.StartResult(c);
StubLib.OutInt32(c, ORD(ReturnCodes.OK));
StubLib.OutRef(c, res);
END Stub_Get;
PROCEDURE Stub_Set(
self: ObValue.RemVar;
c: StubLib.Conn;
<* NOWARN *> rep: StubLib.DataRep) RAISES {NetObj.Error, Rd.Failure,
Wr.Failure, Thread.Alerted}=
VAR val_arg: ObValue.Val;
dataPresent: BOOLEAN <* NOWARN *>;
BEGIN
val_arg := StubLib.InRef(c, rep, TYPECODE(ObValue.Val));
self.Set(val_arg);
StubLib.StartResult(c);
StubLib.OutInt32(c, ORD(ReturnCodes.OK));
END Stub_Set;
BEGIN
StubLib.Register(TYPECODE(ObValue.RemVar), 1, TYPECODE(Surrogate_ObValue_RemVar), Invoke);
END ObValue_RemVar_v1.