obliqrt/derived/ObValueCB.m3


********************************************************************
 * ObValueCB.m3
 * DO NOT EDIT --> generated by /home/wagner/work/cm3/m3-comm/sharedobjgen/AMD64_LINUX/shobjcodegen
 *                 Wed Apr  8 01:18:30 CEST 2009
 ********************************************************************

MODULE ObValueCB EXPORTS ObValueCB, ObValueCBProxy;
IMPORT WeakerRef, WeakRefListFuncs, SharedObjRep, WeakRefList, ObValueRep,
       ObValue, SharedObjStubLib, WeakRef;

REVEAL
  ReplObjStd = PublicReplObjStd BRANDED OBJECT
    obj: ObValue.ReplObjStd;
    wref: WeakerRef.T;
  OVERRIDES
    init := Init_ReplObjStd;
    cancel := Cancel_ReplObjStd;
    pre_anyChange := Pre_anyChange_ReplObjStd;
    post_anyChange := Post_anyChange_ReplObjStd;
    pre_InvokeUpdate := Pre_InvokeUpdate_ReplObjStd;
    post_InvokeUpdate := Post_InvokeUpdate_ReplObjStd;
    pre_init := Pre_init_ReplObjStd;
    post_init := Post_init_ReplObjStd;
    pre_Update := Pre_Update_ReplObjStd;
    post_Update := Post_Update_ReplObjStd;
  END;

PROCEDURE Init_ReplObjStd (self: ReplObjStd;
                           obj: ObValue.ReplObjStd): ReplObjStd =
  VAR
    wref := NEW(WeakerRef.T,
                weakRef := WeakRef.FromRef(self, Cleanup_ReplObjStd_CB),
                ready := TRUE);
  BEGIN
    self.obj := obj;
    self.wref := wref;
    IF MkProxyReplObjStdCB # NIL AND self.proxy = NIL THEN
      MkProxyReplObjStdCB (self);
    END;
    SharedObjStubLib.AcquireWriteLock(obj);
    TRY
      obj.callbacks := WeakRefList.Cons(wref, obj.callbacks);
    FINALLY
      SharedObjStubLib.ReleaseWriteLock(obj);
    END;
    RETURN self;
  END Init_ReplObjStd;

PROCEDURE Cancel_ReplObjStd (self: ReplObjStd) =
  BEGIN
    SharedObjStubLib.AcquireWriteLock(self.obj);
    TRY
      EVAL WeakRefListFuncs.DeleteD(self.obj.callbacks, self.wref);
    FINALLY
      SharedObjStubLib.ReleaseWriteLock(self.obj);
    END;
  END Cancel_ReplObjStd;

PROCEDURE Cleanup_ReplObjStd_CB (READONLY wref: WeakRef.T; ref: REFANY) =
  VAR
    cb := NARROW(ref, ReplObjStd);
    weakerRef := NEW(WeakerRef.T, weakRef := wref);
  BEGIN
    SharedObjStubLib.AcquireWriteLock(cb.obj);
    TRY
      (* Callback is gone, so delete it *)
      EVAL WeakRefListFuncs.DeleteD(cb.obj.callbacks, weakerRef);
    FINALLY
      SharedObjStubLib.ReleaseWriteLock(cb.obj);
    END;
  END Cleanup_ReplObjStd_CB;

PROCEDURE Pre_anyChange_ReplObjStd (self: ReplObjStd; READONLY obj: ObValue.ReplObjStd) =
  BEGIN
    (* Default calls proxy or does nothing. *)
    IF self.proxy # NIL THEN
      NARROW (self.proxy, CBProxyReplObjStd).pre_anyChange (obj);
    END;
  END Pre_anyChange_ReplObjStd;

PROCEDURE Post_anyChange_ReplObjStd (self: ReplObjStd; READONLY obj: ObValue.ReplObjStd) =
  BEGIN
    (* Default calls proxy or does nothing. *)
    IF self.proxy # NIL THEN
      NARROW (self.proxy, CBProxyReplObjStd).post_anyChange (obj);
    END;
  END Post_anyChange_ReplObjStd;

PROCEDURE Pre_InvokeUpdate_ReplObjStd (self: ReplObjStd; READONLY obj: ObValue.ReplObjStd;
                                       label: TEXT;
                                       argNo: INTEGER;
                                       READONLY args: ObValue.Vals;
                                       VAR hint: INTEGER): BOOLEAN =
  BEGIN
    (* Default calls proxy or does nothing. *)
    IF self.proxy # NIL THEN
      RETURN NARROW (self.proxy, CBProxyReplObjStd).pre_InvokeUpdate (obj,
                                                                      label,
                                                                      argNo,
                                                                      args,
                                                                      hint);
      END;
    RETURN FALSE;
  END Pre_InvokeUpdate_ReplObjStd;

PROCEDURE Post_InvokeUpdate_ReplObjStd (self: ReplObjStd; READONLY obj: ObValue.ReplObjStd;
                                        label: TEXT;
                                        argNo: INTEGER;
                                        READONLY args: ObValue.Vals;
                                        VAR hint: INTEGER): BOOLEAN =
  BEGIN
    (* Default calls proxy or does nothing. *)
    IF self.proxy # NIL THEN
      RETURN NARROW (self.proxy, CBProxyReplObjStd).post_InvokeUpdate (obj,
                                                                       label,
                                                                       argNo,
                                                                       args,
                                                                       hint);
      END;
    RETURN FALSE;
  END Post_InvokeUpdate_ReplObjStd;

PROCEDURE Pre_init_ReplObjStd (self: ReplObjStd; READONLY obj: ObValue.ReplObjStd): BOOLEAN =
  BEGIN
    (* Default calls proxy or does nothing. *)
    IF self.proxy # NIL THEN
      RETURN NARROW (self.proxy, CBProxyReplObjStd).pre_init (obj);
      END;
    RETURN FALSE;
  END Pre_init_ReplObjStd;

PROCEDURE Post_init_ReplObjStd (self: ReplObjStd; READONLY obj: ObValue.ReplObjStd): BOOLEAN =
  BEGIN
    (* Default calls proxy or does nothing. *)
    IF self.proxy # NIL THEN
      RETURN NARROW (self.proxy, CBProxyReplObjStd).post_init (obj);
      END;
    RETURN FALSE;
  END Post_init_ReplObjStd;

PROCEDURE Pre_Update_ReplObjStd (self: ReplObjStd; READONLY obj: ObValue.ReplObjStd;
                                 label: TEXT;
                                 val: ObValue.Val;
                                 internal: BOOLEAN;
                                 VAR hint: INTEGER): BOOLEAN =
  BEGIN
    (* Default calls proxy or does nothing. *)
    IF self.proxy # NIL THEN
      RETURN NARROW (self.proxy, CBProxyReplObjStd).pre_Update (obj, label,
                                                                val,
                                                                internal,
                                                                hint);
      END;
    RETURN FALSE;
  END Pre_Update_ReplObjStd;

PROCEDURE Post_Update_ReplObjStd (self: ReplObjStd; READONLY obj: ObValue.ReplObjStd;
                                  label: TEXT;
                                  val: ObValue.Val;
                                  internal: BOOLEAN;
                                  VAR hint: INTEGER): BOOLEAN =
  BEGIN
    (* Default calls proxy or does nothing. *)
    IF self.proxy # NIL THEN
      RETURN NARROW (self.proxy, CBProxyReplObjStd).post_Update (obj,
                                                                 label,
                                                                 val,
                                                                 internal,
                                                                 hint);
      END;
    RETURN FALSE;
  END Post_Update_ReplObjStd;

BEGIN
SharedObjStubLib.InhibitTransmission(TYPECODE(ReplObjStd), "default ReplObjStd callback cannot be transmitted/duplicated");
END ObValueCB.