home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD2.bin / bbs / dev / oberon-a-1.4ß.lha / Oberon-A / source / amigautil / BoopsiUtil.mod < prev    next >
Text File  |  1994-08-08  |  4KB  |  138 lines

  1. (*************************************************************************
  2.  
  3.      $RCSfile: BoopsiUtil.mod $
  4.   Description: BOOPSI support routines.
  5.      Requires: ClassFace.obj must be explicitly linked with the program.
  6.  
  7.    Created by: fjc (Frank Copeland)
  8.     $Revision: 3.2 $
  9.       $Author: fjc $
  10.         $Date: 1994/08/08 16:10:45 $
  11.  
  12.   Copyright © 1994, Frank Copeland.
  13.   This file is part of the Oberon-A Library.
  14.   See Oberon-A.doc for conditions of use and distribution.
  15.  
  16. *************************************************************************)
  17.  
  18. MODULE BoopsiUtil;
  19.  
  20. (*
  21. ** $C- CaseChk       $I- IndexChk  $L+ LongAdr   $N- NilChk
  22. ** $P- PortableCode  $R- RangeChk  $S- StackChk  $T- TypeChk
  23. ** $V- OvflChk       $Z- ZeroVars
  24. *)
  25.  
  26. IMPORT E := Exec, U := Utility, I := Intuition, SYS := SYSTEM;
  27.  
  28. (*
  29. ** These procedures are duplicates of the ones found in Module Intuition.
  30. ** They are repeated here so that this module can be used in place of
  31. ** AmigaOberon's Classface.mod.
  32. *)
  33.  
  34. (*------------------------------------*)
  35. PROCEDURE InstData* (cl : I.IClassPtr; o : I.ObjectPtr) : E.APTR;
  36. BEGIN
  37.   RETURN SYS.VAL (E.APTR, (SYS.VAL(LONGINT,o) + LONG(cl.instOffset)));
  38. END InstData;
  39.  
  40. (*------------------------------------*)
  41. PROCEDURE SizeOfInstance* (cl : I.IClassPtr) : LONGINT;
  42. BEGIN
  43.   RETURN cl.instOffset + cl.instSize + SIZE(I.Object);
  44. END SizeOfInstance;
  45.  
  46. (*------------------------------------*)
  47. PROCEDURE OClass* (o : I.ObjectPtr) : I.IClassPtr;
  48. BEGIN
  49.   o := SYS.VAL (I.ObjectPtr, SYS.VAL (LONGINT, o) - SIZE (I.Object));
  50.   RETURN o.class
  51. END OClass;
  52.  
  53. (*
  54. ** The following declarations are interfaces to procedures in
  55. ** ClassFace.obj, created by assembling ClassFace.asm. ClassFace.obj
  56. ** must be explicitly linked with the program in order to call these
  57. ** procedures. See the "Foreign Code" section in OC.doc.
  58. **
  59. ** These procedures are replacements for those in Commodore's
  60. ** amiga.lib and small.lib.
  61. **
  62. ** Thanks to Albert Weinert for providing the assembly source code.
  63. *)
  64.  
  65. (*
  66. ** DoMethod( o, method_id, param1, param2, ... )
  67. ** Invoke upon an object the method function defined by an object's class.
  68. ** This function is the only one that you should use unless you are
  69. ** implementing a class.
  70. *)
  71.  
  72. PROCEDURE DoMethodA * ["_a_DoMethodA"]
  73.   ( obj    [10] : I.ObjectPtr;
  74.     VAR msg [9] : I.Msg )
  75.   : E.APTR;
  76.  
  77. PROCEDURE DoMethod * ["_a_DoMethodA"]
  78.   ( obj [10]  : I.ObjectPtr;
  79.     msg  [9]..: SYS.LONGWORD )
  80.   : E.APTR;
  81.  
  82. (*
  83. ** DoSuperMethod( cl, o, method_id, param1, param2, ... )
  84. ** Invoke upon an object the method defined for the superclass
  85. ** of the class specified.  In a class implementation, you
  86. ** are passed a pointer to the class you are implementing, which
  87. ** you pass to this function to send a message to the object
  88. ** considered as a member of your superclass.
  89. *)
  90.  
  91. PROCEDURE DoSuperMethodA * ["_a_DoSuperMethodA"]
  92.   ( cl      [8] : I.IClassPtr;
  93.     obj    [10] : I.ObjectPtr;
  94.     VAR msg [9] : I.Msg )
  95.   : E.APTR;
  96.  
  97. PROCEDURE DoSuperMethod * ["_a_DoSuperMethodA"]
  98.   ( cl   [8]  : I.IClassPtr;
  99.     obj [10]  : I.ObjectPtr;
  100.     msg  [9]..: SYS.LONGWORD )
  101.   : E.APTR;
  102.  
  103. (*
  104. ** CoerceMethod( cl, o, method_id, param1, param2, ... );
  105. ** Invoke upon the given object a method function for whatever
  106. ** specified class.  This is sort of the primitive basis behind
  107. ** DoMethod and DoSuperMethod.
  108. *)
  109.  
  110. PROCEDURE CoerceMethodA * ["_a_CoerceMethodA"]
  111.   ( cl      [8] : I.IClassPtr;
  112.     obj    [10] : I.ObjectPtr;
  113.     VAR msg [9] : I.Msg );
  114.  
  115. PROCEDURE CoerceMethod * ["_a_CoerceMethodA"]
  116.   ( cl   [8]  : I.IClassPtr;
  117.     obj [10]  : I.ObjectPtr;
  118.     msg  [9]..: SYS.LONGWORD );
  119.  
  120. (*
  121. ** SetSuperAttrs( cl, o, tag1, data1, ..., TAG_END );
  122. ** A useful varargs conversion to the proper OM_SET method.
  123. *)
  124.  
  125. PROCEDURE SetSuperAttrsA * ["_a_SetSuperAttrs"]
  126.   ( cl   [8] : I.IClassPtr;
  127.     obj [10] : I.ObjectPtr;
  128.     tags [9] : ARRAY OF U.TagItem )
  129.   : E.APTR;
  130.  
  131. PROCEDURE SetSuperAttrs * ["_a_SetSuperAttrs"]
  132.   ( cl   [8]  : I.IClassPtr;
  133.     obj [10]  : I.ObjectPtr;
  134.     tags [9]..: U.Tag )
  135.   : E.APTR;
  136.  
  137. END BoopsiUtil.
  138.