Removed __startup attribute. It is already present in AROS_SHxx definition, and doubl...
[AROS.git] / rom / intuition / rootclass.c
blob70f38ff75fb284cbc5822a885c1cc56e76ffa36d
1 /*
2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
3 Copyright © 2001-2003, The MorphOS Development Team. All Rights Reserved.
4 $Id$
5 */
7 #include <aros/asmcall.h>
8 #include <aros/atomic.h>
9 #include <exec/lists.h>
10 #include <exec/memory.h>
11 #include <proto/exec.h>
12 #include <proto/alib.h>
13 #include <intuition/classes.h>
14 #include <utility/hooks.h>
15 #include <utility/utility.h>
16 #include "intuition_intern.h"
18 #define ENABLE_MEM_POOL 1
20 #if ENABLE_MEM_POOL
21 # define alloc(a, b) AllocPooled(a, b)
22 # define free(a, b, c) FreePooled(a, b, c)
23 #else
24 # define alloc(a, b) AllocMem(b, MEMF_PUBLIC|MEMF_CLEAR)
25 # define free(a, b, c) FreeMem(b, c)
26 #endif
29 /*****i************************************************************************
31 NAME */
32 AROS_UFH3(IPTR, rootDispatcher,
34 /* SYNOPSIS */
35 AROS_UFHA(Class *, cl, A0),
36 AROS_UFHA(Object *, o, A2),
37 AROS_UFHA(Msg, msg, A1))
39 /* FUNCTION
40 internal !
42 Processes all messages sent to the RootClass. Unknown messages are
43 silently ignored.
45 INPUTS
46 cl - Pointer to the RootClass
47 o - This object was the destination for the message in the first
48 place
49 msg - This is the message.
51 RESULT
52 Processes the message. The meaning of the result depends on the
53 type of the message.
55 NOTES
56 This is a good place to debug BOOPSI objects since every message
57 should eventually show up here.
59 EXAMPLE
61 BUGS
63 SEE ALSO
65 ******************************************************************************/
67 AROS_USERFUNC_INIT
69 IPTR retval = 0;
70 Class *iclass;
72 switch (msg->MethodID)
74 case OM_NEW:
75 iclass = (Class *) o;
77 /*
78 Get memory for the instance data. The class knows how much is
79 needed. NOTE: The object argument is actually the class!
82 o = (Object *) alloc
84 iclass->cl_MemoryPool, iclass->cl_ObjectSize
87 if (o)
89 _OBJ(o)->o_Class = iclass;
91 AROS_ATOMIC_INC(iclass->cl_ObjectCount);
93 retval = (IPTR) BASEOBJECT(o);
95 break;
97 case OM_DISPOSE:
98 /*
99 Free memory. Caller is responsible that everything else
100 is already cleared!
102 iclass = OCLASS(o);
104 free
106 iclass->cl_MemoryPool, _OBJECT(o), iclass->cl_ObjectSize
109 AROS_ATOMIC_DEC(iclass->cl_ObjectCount);
110 break;
112 case OM_ADDTAIL:
113 /* Add <o> to list. */
114 AddTail (((struct opAddTail *)msg)->opat_List, (struct Node *) _OBJECT(o));
115 retval = TRUE;
116 break;
118 case OM_REMOVE:
119 /* Remove object from list. */
120 Remove ((struct Node *) _OBJECT(o));
121 retval = TRUE;
122 break;
124 case OM_SET:
125 case OM_GET:
126 case OM_UPDATE:
127 case OM_NOTIFY:
128 case OM_ADDMEMBER:
129 case OM_REMMEMBER:
131 default:
132 /* Ignore */
133 break;
135 } /* switch */
137 return (retval);
139 AROS_USERFUNC_EXIT
141 } /* rootDispatcher */