revert between 56095 -> 55830 in arch
[AROS.git] / rom / intuition / rootclass.c
blob3006c14639eae34ae7f9ae3f0670d79277c2c095
1 /*
2 Copyright © 1995-2013, 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 function!
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 The meaning of the result depends on the type of the message.
54 NOTES
55 This is a good place to debug BOOPSI objects since every message
56 should eventually show up here.
58 EXAMPLE
60 BUGS
62 SEE ALSO
64 ******************************************************************************/
66 AROS_USERFUNC_INIT
68 IPTR retval = 0;
69 Class *iclass;
71 switch (msg->MethodID)
73 case OM_NEW:
74 iclass = (Class *) o;
76 /*
77 Get memory for the instance data. The class knows how much is
78 needed. NOTE: The object argument is actually the class!
81 o = (Object *) alloc
83 iclass->cl_MemoryPool, iclass->cl_ObjectSize
86 if (o)
88 _OBJ(o)->o_Class = iclass;
90 AROS_ATOMIC_INC(iclass->cl_ObjectCount);
92 retval = (IPTR) BASEOBJECT(o);
94 break;
96 case OM_DISPOSE:
97 /*
98 Free memory. Caller is responsible that everything else
99 is already cleared!
101 iclass = OCLASS(o);
103 free
105 iclass->cl_MemoryPool, _OBJECT(o), iclass->cl_ObjectSize
108 AROS_ATOMIC_DEC(iclass->cl_ObjectCount);
109 break;
111 case OM_ADDTAIL:
112 /* Add <o> to list. */
113 AddTail (((struct opAddTail *)msg)->opat_List, (struct Node *) _OBJECT(o));
114 retval = TRUE;
115 break;
117 case OM_REMOVE:
118 /* Remove object from list. */
119 Remove ((struct Node *) _OBJECT(o));
120 retval = TRUE;
121 break;
123 case OM_SET:
124 case OM_GET:
125 case OM_UPDATE:
126 case OM_NOTIFY:
127 case OM_ADDMEMBER:
128 case OM_REMMEMBER:
130 default:
131 /* Ignore */
132 break;
134 } /* switch */
136 return (retval);
138 AROS_USERFUNC_EXIT
140 } /* rootDispatcher */