2 Copyright © 2002-2003, The AROS Development Team. All rights reserved.
9 #include <intuition/classes.h>
10 #include <clib/alib_protos.h>
11 #include <proto/exec.h>
12 #include <proto/intuition.h>
13 #include <proto/utility.h>
14 #include <proto/muimaster.h>
19 #include "support_classes.h"
20 #include "muimaster_intern.h"
25 static const struct __MUIBuiltinClass
* const builtins
[] =
29 &_MUI_Application_desc
,
35 &_MUI_Configdata_desc
,
49 &_MUI_Scrollbutton_desc
,
54 &_MUI_ChunkyImage_desc
,
63 ZUNE_SETTINGSGROUP_DESC
68 ZUNE_ICONLISTVIEW_DESC
72 ZUNE_IMAGEDISPLAY_DESC
77 ZUNE_FRAMEDISPLAY_DESC
82 ZUNE_NUMERICBUTTON_DESC
92 Class
*ZUNE_GetExternalClass(ClassID classname
, struct Library
*MUIMasterBase
)
94 struct Library
*mcclib
= NULL
;
95 struct MUI_CustomClass
*mcc
= NULL
;
96 CONST_STRPTR
const *pathptr
;
99 static CONST_STRPTR
const searchpaths
[] =
107 for (pathptr
= searchpaths
; *pathptr
; pathptr
++)
109 snprintf(s
, 255, *pathptr
, classname
);
111 D(bug("Trying opening of %s\n",s
));
113 if ((mcclib
= OpenLibrary(s
, 0)))
115 D(bug("Calling MCC Query. Librarybase at 0x%lx\n",mcclib
));
118 if (!mcc
) mcc
= MCC_Query(1); /* MCP? */
124 mcc
->mcc_Module
= mcclib
;
125 D(bug("Successfully opened %s as external class\n",classname
));
127 return mcc
->mcc_Class
;
131 CloseLibrary(mcclib
);
135 D(bug("Failed to open external class %s\n",classname
));
139 /**************************************************************************/
140 static Class
*ZUNE_FindBuiltinClass(ClassID classid
, struct Library
*mb
)
142 Class
*cl
= NULL
, *cl2
;
144 ForeachNode(&MUIMB(mb
)->BuiltinClasses
, cl2
)
146 if (!strcmp(cl2
->cl_ID
, classid
))
156 static Class
*ZUNE_MakeBuiltinClass(ClassID classid
, struct Library
*MUIMasterBase
)
160 struct Library
*mb
= NULL
;
162 D(bug("Makeing Builtinclass %s\n",classid
));
164 for (i
= 0; i
< sizeof(builtins
)/sizeof(builtins
[0]); i
++)
166 if (!strcmp(builtins
[i
]->name
, classid
))
171 /* This may seem strange, but opening muimaster.library here is done in order to
172 increase muimaster.library's open count, so that it doesn't get expunged
173 while some of its internal classes are still in use.
174 We don't use muimaster.library directly but the name of the library
175 stored inside the base, because the library can be compiled also as
176 zunemaster.library */
178 mb
= OpenLibrary(MUIMasterBase
->lib_Node
.ln_Name
, 0);
180 /* It can't possibly fail, but well... */
184 if (strcmp(builtins
[i
]->supername
, ROOTCLASS
) == 0)
186 superclid
= ROOTCLASS
;
192 supercl
= MUI_GetClass(builtins
[i
]->supername
);
197 cl
= MakeClass(builtins
[i
]->name
, superclid
, supercl
, builtins
[i
]->datasize
, 0);
200 #if defined(__MAXON__) || defined(__amigaos4__)
201 cl
->cl_Dispatcher
.h_Entry
= builtins
[i
]->dispatcher
;
203 cl
->cl_Dispatcher
.h_Entry
= (HOOKFUNC
)metaDispatcher
;
204 cl
->cl_Dispatcher
.h_SubEntry
= builtins
[i
]->dispatcher
;
206 /* Use this as a reference counter */
207 cl
->cl_Dispatcher
.h_Data
= 0;
220 Class
*ZUNE_GetBuiltinClass(ClassID classid
, struct Library
*mb
)
224 ObtainSemaphore(&MUIMB(MUIMasterBase
)->ZuneSemaphore
);
226 cl
= ZUNE_FindBuiltinClass(classid
, mb
);
230 cl
= ZUNE_MakeBuiltinClass(classid
, mb
);
234 ZUNE_AddBuiltinClass(cl
, mb
);
236 /* Increase the reference counter */
237 cl
->cl_Dispatcher
.h_Data
++;
241 ReleaseSemaphore(&MUIMB(MUIMasterBase
)->ZuneSemaphore
);
247 * metaDispatcher - puts h_Data in A6 and calls real dispatcher
251 AROS_UFH3(IPTR
, metaDispatcher
,
252 AROS_UFHA(struct IClass
*, cl
, A0
),
253 AROS_UFHA(Object
*, obj
, A2
),
254 AROS_UFHA(Msg
, msg
, A1
))
258 return AROS_UFC4(IPTR
, cl
->cl_Dispatcher
.h_SubEntry
,
259 AROS_UFPA(Class
*, cl
, A0
),
260 AROS_UFPA(Object
*, obj
, A2
),
261 AROS_UFPA(Msg
, msg
, A1
),
262 AROS_UFPA(APTR
, cl
->cl_Dispatcher
.h_Data
, A6
)
270 __asm ULONG
metaDispatcher(register __a0
struct IClass
*cl
, register __a2 Object
*obj
, register __a1 Msg msg
)
272 __asm
ULONG (*entry
)(register __a0
struct IClass
*cl
, register __a2 Object
*obj
, register __a1 Msg msg
) =
273 (__asm
ULONG (*)(register __a0
struct IClass
*, register __a2 Object
*, register __a1 Msg
))cl
->cl_Dispatcher
.h_SubEntry
;
275 putreg(REG_A6
,(long)cl
->cl_Dispatcher
.h_Data
);
276 return entry(cl
,obj
,msg
);