home *** CD-ROM | disk | FTP | other *** search
/ MACD 4 / MACD4.iso / Emulatory / AROS / intuition / makeclass.c < prev    next >
Encoding:
C/C++ Source or Header  |  1978-03-06  |  4.1 KB  |  150 lines

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