14.9 RepetitionObject Interface

ORIGIN '~beta/basiclib/betaenv';
LIB_DEF 'sysutilsrepobj' '../lib';
(* 
 * $RCSfile: RepetitionObject.bet,v $ $Revision: 1.9 $ $Date: 2000/01/11 15:32:35 $
 *
 * COPYRIGHT
 *       Copyright Mjolner Informatics, 1992-94
 *       All rights reserved.
 *)

BODY 'private/RepetitionObjectBody';

--- lib:attributes ---
memcpy: external
  (# adrTarget: @Integer;
     adrSource: @Integer;
     byteCount: @Integer;
     out: @Integer;
  enter (adrTarget, adrSource, byteCount)
  exit out
  #);

RepetitionObject:
  (* Used to pass serialized objects around.
   * Can also be used to pass simple datastructures through sockets.
   *)
  (# r: [InitialRange]@Integer;
     initialRange:< (# value: @Integer; 
       do 10 -> value; INNER
       exit value
       #);
     
     <<SLOT RepetitionObjectAttributes:attributes>>;
     
     size: @ (# enter r[1] exit r[1] #);
     (* Index of last used entry in r. (Not the same as r.range *)
     
     pos: @(# enter r[2] exit r[2] #);
     (* next position to get or put *)
     
     get: @(# do r[2] + 1 -> r[2] exit r[r[2] - 1] #);
     
     getLong: @ (* Get a long, byteswapping it, if on little-endian. *)
       (# l: @Integer;
       ...
       exit l
       #);
                  
     (* Like Get, except it does not update position *)
     Peek: @(# exit r[r[2]] #);
     
     PeekLong: @ 
       (# l: @Integer;
       ...  
       exit l
       #);
     
     put: @
       (# enter r[r[2]]
       ...  
       #);
     
     (* Put a long, byteswapping it on little-endian machines. *)
     putLong: @
       (# enter r[r[2]]
          ...
       #);
     
     (* The user of cheapPut must ensure that space is available 
      * (using makeSpace) and that size is updated (using checkSize). *)
     cheapPut: @ (# enter r[r[2]] do r[2]+1 -> r[2] #);
     
     (* Put a long, byteswapping it on little-endian machines.
      * Comment on cheapPut applies, as they share the allocated space. *)
     cheapPutLong: @ 
       (# l: @Integer;
       enter l
       ... 
       #);
     
     makeSpace: @
       (# nlongs: @Integer;
       enter nlongs
       ...
       #);
     
     checkSize: @(# ... #);
     
     getText: @
       (# t: ^Text; len, wsize: @Integer;
       ...  
       exit t[]
       #);   
     
     putText: @
       (# t: ^Text;
          len, wsize: @Integer;
       enter t[]
       ... 
       #);
     
     firstPos: (# exit 3 #);
     initialSize: (# exit 2 #);
     reset: @(# ... #);
              
     init: @(# ... #);
     
     (* Safety checking procedures.
      * As the operations above do NO parameter checking at all,
      * the following functions may be used when the origin of
      * a repetitionObject is uncertain.  
      * They are also quite usefull to catch programming errors.
      *)
     
     checkGet: BooleanValue
       (# ... #);
     
     checkGetText: BooleanValue
       (# maxLen: @Integer;
       enter maxLen
       ...
       #);
  #)


14.9 RepetitionObject Interface
© 1994-2004 Mjølner Informatics
[Modified: Tuesday January 11th 2000 at 16:32]