-- File [Ivy]<Nelson>Lupine>LupineTypeTest.mesa.
-- Last edited by BZM on 12-May-82 19:24:14.


DIRECTORY
  Rope USING [ROPE],
  RPC USING [Conversation, ShortSTRING, ShortROPE, ShortATOM],
  Time USING [Unpacked];


LupineTypeTest: DEFINITIONS  =
  BEGIN


-- Types.

  ROPE: TYPE = Rope.ROPE;

  Color: TYPE = {red, green, yellow};
  ColorRange: TYPE = [1..3];
  Intensity: TYPE = [0..127);

  HANDLE: TYPE = PRIVATE HANDLEPtr;  HANDLEPtr: TYPE = POINTER;

  ProcType: TYPE = HANDLEProcType;
  HANDLEProcType: TYPE = PROCEDURE [one: STRING, two: HANDLE]
    RETURNS [more: BOOLEAN];

  ExportObject: TYPE [1];
  ExportHandle: TYPE = POINTER TO ExportObject;

  Zone: TYPE = HANDLEZone;  HANDLEZone: TYPE = ZONE;
  UncountedZone: TYPE = HANDLEUZone;  HANDLEUZone: TYPE = UNCOUNTED ZONE;
  MdsZone: TYPE = HANDLEMDSZone;  HANDLEMDSZone: TYPE = MDSZone;
  
  ComputedVariant: TYPE = RECORD [
	oddPart: SELECT OVERLAID * FROM
	  num  =>  [INTEGER],
	  flags  =>  [SELECT COMPUTED {flags} FROM
			flags => [f: PACKED ARRAY CHARACTER OF BOOLEAN],
			ENDCASE ],
	  ENDCASE ];

  SmallVariant: TYPE = RECORD [
	handle: HANDLE,
	oddPart: SELECT varTag: * FROM
	  test =>  [r: ROPE],
	  empty  =>  [],
	  plain  =>  [c: CARDINAL, r: REAL],
	  ENDCASE ];

  BigVariant: TYPE = RECORD [
	common: INTEGER,
	plain: PACKED ARRAY [1..64] OF CHARACTER,
	variant: SELECT varTag: * FROM
	  list => [l: LIST OF REF TEXT],
	  handle => [h, i, j: HANDLE],
	  empty => [],
	  plain => [c: CARDINAL, r: REAL],
	  small => [fill: BOOLEAN, smallVar: SmallVariant],
	  spectrum => [
	    SELECT color: Color FROM
	      yellow => [contrast: REF READONLY Intensity],
	      red => [desc: LONG DESCRIPTOR FOR READONLY ARRAY OF RECORD [
			colorName: STRING,
			brilliance: Intensity] ],
	      green => [empty: BOOLEAN],
	      ENDCASE ],
	  ENDCASE ];

  Space: TYPE = PACKED ARRAY BOOLEAN OF ARRAY [1..7] OF REF SpaceRecord;
  SpaceRecord: TYPE = RECORD [
	bits: DESCRIPTOR FOR PACKED ARRAY [2000..2010] OF BOOLEAN,
	colors: PACKED SEQUENCE range: ColorRange OF Intensity ];

  ReadonlyString: TYPE = REF READONLY StringBody;
  TestRecord: TYPE = RECORD [
	one: REF ReadonlyString,
	two: RECORD [block: ARRAY [0..4) OF LONG CARDINAL],
	three: LONG DESCRIPTOR FOR PACKED ARRAY OF Intensity  ];

  FiniteSequence: TYPE = RECORD [SEQUENCE range: ColorRange OF REF REAL];

  PublicConv, PrivateConv: TYPE = HANDLEConversation;
  HANDLEConversation: TYPE = RPC.Conversation;

  RNameList: TYPE = LONG POINTER TO READONLY RNameListObject;
  RNameListObject: TYPE = RECORD [
    names: PACKED SEQUENCE length: [0..64] OF LONG RPC.ShortSTRING ];
    
  Group: TYPE = RECORD [owners: RNameList, total: LONG INTEGER];

  Int: TYPE = LONG POINTER TO LONG INTEGER;
  HANDLEInt: TYPE = Int;
  VALUEInt: TYPE = Int;
  VARInt: TYPE = Int;
  RESULTInt: TYPE = Int;

  String: TYPE = STRING;
  HANDLEString: TYPE = String;
  VALUEString: TYPE = String;
  VARString: TYPE = String;
  RESULTString: TYPE = String;

  Buffer: TYPE = LONG DESCRIPTOR FOR ARRAY OF WORD;
  HANDLEBuffer: TYPE = Buffer;
  VALUEBuffer: TYPE = Buffer;
  VARBuffer: TYPE = Buffer;
  RESULTBuffer: TYPE = Buffer;


-- Interface Exceptions. 

  PlainError: ERROR;

  ArgError: ERROR [type: Color, position: CARDINAL];

  PlainSignal: SIGNAL;

  ArgSignal: SIGNAL [bogus: Color];

  ResultSignal: SIGNAL RETURNS [resume: BOOLEAN];
  
  AnonSignal: SIGNAL [now, later: BOOLEAN, text: POINTER TO READONLY TEXT]
    RETURNS [BOOLEAN, BOOLEAN, POINTER TO READONLY TEXT];

  FullSignal: SIGNAL [check: ProcType] RETURNS [use: Color];

  ComplexSignal: SIGNAL [
	nat: NAT,
	refTime: REF Time.Unpacked ]
      RETURNS [
	atom: ATOM,
	list: LIST OF ATOM ];



-- Interface Procedures. 

  InlineCheck: PROCEDURE = INLINE {};

  MachineCheck: PROCEDURE = MACHINE CODE {};

  PlainProc: PROCEDURE;

  ArgProc: PROCEDURE [number: CARDINAL, string: STRING];

  ResProc: PROCEDURE RETURNS [block: ARRAY [0..4) OF INTEGER];

  FullProc: PROCEDURE [input: BOOLEAN] RETURNS [output: CHARACTER];

  BigProc: PROCEDURE [
	firstOne: BOOLEAN,
	ptr: LONG POINTER TO INTEGER,
	tooBig: ARRAY [0..300) OF BOOLEAN,
	willFit: ARRAY [0..200) OF BOOLEAN,
	str1: STRING,
	fitsToo: ARRAY [0..40) OF BOOLEAN,
	noDice: ARRAY [0..40) OF BOOLEAN,
	yep: BOOLEAN,
	fillsItUp: ARRAY [0..13) OF BOOLEAN,
	-- These next three don't fit into the overlay and should
	-- be copied, uninterpreted, into the second packet.
	stringHandle: HANDLEString,
	intHandle: HANDLEInt,
	descHandle: HANDLEBuffer,
	str2: STRING ];

  CedarProc: PROC [
	nat: NAT,
	refInt: REF INTEGER,
	refAny: REF ]
     RETURNS [
	body: REF StringBody,
	rope: REF READONLY TEXT,
	shortRope: RPC.ShortROPE,
	zone: Zone,
	list: LIST OF ARRAY Color OF LIST OF ATOM,
	finiteSeq: REF FiniteSequence ];
		
  AnonProc: PROCEDURE [INTEGER, ProcType, HANDLE, Time.Unpacked]
    RETURNS [LONG INTEGER, LIST OF ZONE];

  ZoneCheck: PROCEDURE [cedar: Zone, heap: UncountedZone] RETURNS [mds: MdsZone];

  Test: PROCEDURE [input: BOOLEAN, array: ARRAY [0..10] OF TestRecord]
    RETURNS [char: CHARACTER];

  ConversationTest: PROCEDURE [doThis: PublicConv, skipThis: PrivateConv]
    RETURNS [skipThisToo: PublicConv];


  ProcParam: PROCEDURE [proc: ProcType];

  ExportTest: PROCEDURE [object: ExportObject]
    RETURNS [approved: ExportHandle, notApproved: HANDLE];

  Array: PROC [ok: LONG CARDINAL, space: REF Space] RETURNS [real: REF REAL];


  VarInt: PROCEDURE [
    var: VARInt, val: VALUEInt, res: RESULTInt, han: HANDLEInt ];

  VarString: PROCEDURE [
    var: VARString, val: VALUEString, res: RESULTString, han: HANDLEString ];

  VarBuffer: PROCEDURE [
    var: VARBuffer, val: VALUEBuffer, res: RESULTBuffer, han: HANDLEBuffer ];


END.  -- LupineTypeTest.

        
  StringConvert: PROCEDURE [
      StoR, RtoA, AtoS: BOOLEAN,
      string: RPC.ShortSTRING,
      rope: RPC.ShortROPE,
      atom: RPC.ShortATOM ]
    RETURNS [
      longString: LONG STRING,
      longRope: ROPE,
      longAtom: ATOM ];
  
  MakeList: PROCEDURE [individuals: LIST OF RPC.ShortROPE] RETURNS [RNameList];
  
  CheckName: PROCEDURE [name: RPC.ShortSTRING, group: Group] RETURNS [BOOLEAN]; 

  TestVariants: PROCEDURE [
	smallone: DESCRIPTOR FOR ARRAY OF SmallVariant,
	two: LONG CARDINAL ]
    RETURNS [
	char: CHARACTER,
	big: REF BigVariant ];

  TestVariants: PROCEDURE [
	smallone: DESCRIPTOR FOR READONLY ARRAY OF SmallVariant,
	two: LONG CARDINAL ]
    RETURNS [
	char: CHARACTER
      --big: REF BigVariant-- ];