home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / misc / emu / AROSdev.lha / AROS / rom / intuition / makeclass.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-27  |  4.2 KB  |  156 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: makeclass.c,v 1.6 1997/01/27 00:36:40 ldp Exp $
  4.     $Log: makeclass.c,v $
  5.     Revision 1.6  1997/01/27 00:36:40  ldp
  6.     Polish
  7.  
  8.     Revision 1.5  1996/12/10 14:00:05  aros
  9.     Moved #include into first column to allow makedepend to see it.
  10.  
  11.     Revision 1.4  1996/11/08 11:28:03  aros
  12.     All OS function use now Amiga types
  13.  
  14.     Moved intuition-driver protos to intuition_intern.h
  15.  
  16.     Revision 1.3  1996/10/24 15:51:22  aros
  17.     Use the official AROS macros over the __AROS versions.
  18.  
  19.     Revision 1.2  1996/10/23 16:30:09  aros
  20.     Ooops.. PublicClassList is a MinNode list :-)
  21.  
  22.     Revision 1.1  1996/08/28 17:55:35  digulla
  23.     Proportional gadgets
  24.     BOOPSI
  25.  
  26.  
  27.     Desc:
  28.     Lang: english
  29. */
  30. #define AROS_ALMOST_COMPATIBLE
  31. #include <exec/lists.h>
  32. #include <exec/memory.h>
  33. #include <proto/exec.h>
  34. #include "intuition_intern.h"
  35.  
  36. /*****************************************************************************
  37.  
  38.     NAME */
  39. #include <intuition/classes.h>
  40. #include <proto/intuition.h>
  41.  
  42.     AROS_LH5(struct IClass *, MakeClass,
  43.  
  44. /*  SYNOPSIS */
  45.     AROS_LHA(UBYTE         *, classID, A0),
  46.     AROS_LHA(UBYTE         *, superClassID, A1),
  47.     AROS_LHA(struct IClass *, superClassPtr, A2),
  48.     AROS_LHA(ULONG          , instanceSize, D0),
  49.     AROS_LHA(ULONG          , flags, D1),
  50.  
  51. /*  LOCATION */
  52.     struct IntuitionBase *, IntuitionBase, 113, Intuition)
  53.  
  54. /*  FUNCTION
  55.     Only for class implementators.
  56.  
  57.     This function creates a new public BOOPSI class. The SuperClass
  58.     should be another BOOPSI class; all BOOPSI classes are subclasses
  59.     of the ROOTCLASS.
  60.  
  61.     SuperClasses can by private or publiec. You can specify aname/ID
  62.     for the class if you want it to become a public class. For public
  63.     classes, you must call AddClass() afterwards to make it public
  64.     accessible.
  65.  
  66.     The returnvalue contains a pointer to the IClass structure of your
  67.     class. You must specify your dispatcher in cl_Dispatcher. You can
  68.     also store shared data in cl_UserData.
  69.  
  70.     To get rid of the class, you must call FreeClass().
  71.  
  72.     INPUTS
  73.     classID - NULL for private classes otherwise the name/ID of the
  74.         public class.
  75.     superClassID - Name/ID of a public SuperClass. NULL is you don't
  76.         want to use a public SuperClass or if you have the pointer
  77.         your SuperClass.
  78.     superClassPtr - Pointer to the SuperClass. If this is non-NULL,
  79.         then superClassID is ignored.
  80.     instanceSize - The amount of memory which your objects need (in
  81.         addition to the memory which is needed by the SuperClass(es))
  82.     flags - For future extensions. To maintain comaptibility, use 0
  83.         for now.
  84.  
  85.     RESULT
  86.     Pointer to the new class or NULL if
  87.     - There wasn't enough memory
  88.     - The superclass couldn't be found
  89.     - There already is a class with the same name/ID.
  90.  
  91.     NOTES
  92.     No copy is made of classID. So make sure the lifetime of the contents
  93.     of classID is at least the same as the lifetime of the class itself.
  94.  
  95.     EXAMPLE
  96.  
  97.     BUGS
  98.  
  99.     SEE ALSO
  100.  
  101.     INTERNALS
  102.  
  103.     HISTORY
  104.     29-10-95    digulla automatically created from
  105.                 intuition_lib.fd and clib/intuition_protos.h
  106.  
  107. *****************************************************************************/
  108. {
  109.     AROS_LIBFUNC_INIT
  110.     AROS_LIBBASE_EXT_DECL(struct IntuitionBase *,IntuitionBase)
  111.     Class * iclass;
  112.  
  113.     /* trust the user ;-) */
  114.     if (!superClassID && !superClassPtr)
  115.     return (NULL);
  116.  
  117.     /* Does this class already exist ? */
  118.     if (FindName (PublicClassList, classID))
  119.     return (NULL);
  120.  
  121.     /* Has the user specified a classPtr ? */
  122.     if (!superClassPtr)
  123.     {
  124.     /* Search for the class ... */
  125.     for (superClassPtr=GetHead(PublicClassList);
  126.         superClassPtr;
  127.         superClassPtr=GetSucc(superClassPtr)
  128.     )
  129.     {
  130.         if (!strcmp(superClassPtr->cl_ID, superClassID))
  131.         break;
  132.     }
  133.  
  134.     if (!superClassPtr)
  135.         return (NULL);  /* nothing found */
  136.     }
  137.  
  138.     /* Get some memory */
  139.     if ((iclass = (Class *) AllocMem (sizeof (Class), MEMF_PUBLIC|MEMF_CLEAR)))
  140.     {
  141.     /* Felder init */
  142.     iclass->cl_Super      = superClassPtr;
  143.     iclass->cl_ID          = classID;
  144.     iclass->cl_InstOffset = superClassPtr->cl_InstOffset +
  145.                 superClassPtr->cl_InstSize;
  146.     iclass->cl_InstSize   = instanceSize;
  147.     iclass->cl_Flags      = flags;
  148.  
  149.     /* SuperClass is used one more time now */
  150.     superClassPtr->cl_SubclassCount ++;
  151.     }
  152.  
  153.     return (iclass);
  154.     AROS_LIBFUNC_EXIT
  155. } /* MakeClass */
  156.