Some fixes.
[cake.git] / rom / boopsi / rootclass.c
blob8408b59baaa82a9c3f6b57a9d5273b10ea068892
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: BOOPSI rootclass
6 Lang: english
7 */
9 #include <exec/lists.h>
10 #include <exec/memory.h>
11 #include <proto/exec.h>
12 #include <proto/alib.h>
13 #include <proto/arossupport.h>
14 #ifndef INTUITION_CLASSES_H
15 # include <intuition/classes.h>
16 #endif
17 #ifndef UTILITY_HOOKS_H
18 # include <utility/hooks.h>
19 #endif
20 #include <utility/utility.h>
21 #include <aros/asmcall.h>
22 #include "intern.h"
24 AROS_UFP3S(ULONG, rootDispatcher,
25 AROS_UFPA(Class *, cl, A0),
26 AROS_UFPA(Object *, obj, A2),
27 AROS_UFPA(Msg, msg, A1)
30 Class rootclass =
32 { { NULL, NULL }, rootDispatcher, NULL, NULL },
33 0, /* reserved */
34 NULL, /* No superclass */
35 (ClassID)ROOTCLASS, /* ClassID */
37 0, 0, /* No offset and size */
39 0, /* UserData */
40 0, /* SubClassCount */
41 0, /* ObjectCount */
42 0, /* Flags */
46 #define BOOPSIBase (GetBBase(cl->cl_UserData))
48 /*****i************************************************************************
50 NAME */
51 AROS_UFH3S(IPTR, rootDispatcher,
53 /* SYNOPSIS */
54 AROS_UFHA(Class *, cl, A0),
55 AROS_UFHA(Object *, o, A2),
56 AROS_UFHA(Msg, msg, A1))
58 /* FUNCTION
59 internal !
61 Processes all messages sent to the RootClass. Unknown messages are
62 silently ignored.
64 INPUTS
65 cl - Pointer to the RootClass
66 o - This object was the destination for the message in the first
67 place
68 msg - This is the message.
70 RESULT
71 Processes the message. The meaning of the result depends on the
72 type of the message.
74 NOTES
75 This is a good place to debug BOOPSI objects since every message
76 should eventually show up here.
78 EXAMPLE
80 BUGS
82 SEE ALSO
84 HISTORY
85 14.09.93 ada created
87 ******************************************************************************/
89 AROS_USERFUNC_INIT
90 IPTR retval = 0;
91 Class *objcl;
93 switch (msg->MethodID)
95 case OM_NEW: {
96 objcl = (Class *)o;
98 /* Get memory. The objects shows how much is needed.
99 (The object is not an object, it is a class pointer!) */
100 o = (Object *) AllocVec (objcl->cl_InstOffset
101 + objcl->cl_InstSize
102 + sizeof (struct _Object)
103 , MEMF_ANY|MEMF_CLEAR
106 ((struct _Object *)o)->o_Class = objcl;
107 retval = (IPTR) BASEOBJECT(o);
108 break; }
110 case OM_DISPOSE:
111 /* Free memory. Caller is responsible that everything else
112 is already cleared! */
113 FreeVec (_OBJECT(o));
114 break;
116 case OM_ADDTAIL:
117 /* Add <o> to list. */
118 AddTail (((struct opAddTail *)msg)->opat_List,
119 (struct Node *) _OBJECT(o));
120 break;
122 case OM_REMOVE:
123 /* Remove object from list. */
124 Remove ((struct Node *) _OBJECT(o));
125 break;
127 case OM_SET:
128 case OM_GET:
129 case OM_UPDATE:
130 case OM_NOTIFY:
131 case OM_ADDMEMBER:
132 case OM_REMMEMBER:
133 default:
134 /* Ignore */
135 break;
137 } /* switch */
139 return (retval);
140 AROS_USERFUNC_EXIT
141 } /* rootDispatcher */