2 Copyright © 1995-2006, The AROS Development Team. All rights reserved.
5 Support functions for MUI classes. Part of genmodule.
8 #include "boopsisupport.h"
10 void writemuiincludes(FILE *out
)
15 "#include <proto/muimaster.h>\n"
20 void writemccinit(struct config
*cfg
, FILE *out
, int inclass
, struct classinfo
*cl
)
22 struct functionhead
*methlistit
;
23 struct functionarg
*arglistit
;
29 "/* Initialisation routines of a MUI class */\n"
30 "/* =======================================*/\n"
34 if (cl
->classdatatype
== NULL
)
35 fprintf(out
, "# define %s_DATA_SIZE (0)\n", cl
->basename
);
40 "# define %s_DATA_SIZE (sizeof(%s))\n",
41 cl
->basename
, cl
->classdatatype
44 writeboopsidispatcher(cfg
, out
, cl
);
51 "/*** Library startup and shutdown *******************************************/\n"
52 "static int MCC_%s_Startup(LIBBASETYPEPTR LIBBASE)\n"
57 /* When classid is specified MakeClass will be used to make the class
58 * otherwise MUI_CreateCustomClass. The former use is only needed for internal
59 * muimaster use. Other use is deprecated.
61 if (cl
->classid
== NULL
)
63 char *base
, disp
[256];
65 /* Has the class a provided dispatcher function ? */
66 if (cl
->dispatcher
== NULL
)
67 snprintf(disp
, 256, "%s_Dispatcher", cl
->basename
);
69 strncpy(disp
, cl
->dispatcher
, 256);
71 /* Is this class the main class then pass the libbase to MUI_CreateCustomClass
75 base
= "(struct Library *)LIBBASE";
79 if (cl
->superclass
!= NULL
)
83 " %s_CLASSPTR_FIELD(LIBBASE) = MUI_CreateCustomClass(%s, %s, NULL, %s_DATA_SIZE, %s);\n",
84 cl
->basename
, base
, cl
->superclass
, cl
->basename
, disp
86 else if (cl
->superclass_field
!= NULL
)
90 " %s_CLASSPTR_FIELD(LIBBASE) = MUI_CreateCustomClass(%s, NULL, LIBBASE->%s, %s_DATA_SIZE, %s);\n",
91 cl
->basename
, base
, cl
->superclass_field
, cl
->basename
, disp
95 fprintf(out
, "Internal error: both superclass and superclass_field are NULL\n");
103 /* Has the class a provided dispatcher function ? */
104 if (cl
->dispatcher
== NULL
)
105 snprintf(disp
, 256, "%s_Dispatcher", cl
->basename
);
107 strncpy(disp
, cl
->dispatcher
, 256);
109 if (cl
->superclass
!= NULL
)
113 " Class *superclass = MUI_GetClass(%s),\n",
116 else if (cl
->superclass_field
!= NULL
)
120 " Class *superclass = LIBBASE->%s,\n",
125 fprintf(stderr
, "Internal error: both superclass and superclass_field are NULL\n");
135 " cl = MakeClass(%s, NULL, superclass, %s_DATA_SIZE, 0);\n"
137 " cl->cl_Dispatcher.h_Entry = %s;\n"
138 " %s_CLASSPTR_FIELD(LIBBASE) = cl;\n",
139 cl
->classid
, cl
->basename
,
149 " return %s_CLASSPTR_FIELD(LIBBASE) != NULL;\n"
152 "static void MCC_%s_Shutdown(LIBBASETYPEPTR LIBBASE)\n"
157 if (cl
->classid
== NULL
)
162 " MUI_DeleteCustomClass(%s_CLASSPTR_FIELD(LIBBASE));\n",
171 " Class *cl = %s_CLASSPTR_FIELD(LIBBASE);\n"
175 " MUI_FreeClass(cl->cl_Super);\n"
187 "ADD2INITCLASSES(MCC_%s_Startup, %d);\n"
188 "ADD2EXPUNGECLASSES(MCC_%s_Shutdown, %d);\n",
189 cl
->basename
, -cl
->initpri
,
190 cl
->basename
, -cl
->initpri
194 void writemccquery(FILE *out
, struct config
*cfg
)
200 "/* MCC_Query function */\n"
201 "/* ================== */\n"
203 "#include <libraries/mui.h>\n"
204 "#include <aros/libcall.h>\n"
206 "#define MCC_CLASS 0\n"
207 "#define MCC_PREFS_CLASS 1\n"
209 "AROS_LH1(IPTR, MCC_Query,\n"
210 " AROS_LHA(LONG, what, D0),\n"
211 " LIBBASETYPEPTR, LIBBASE, 5, %s\n"
214 " AROS_LIBFUNC_INIT\n"
225 fprintf(out
, " case MCC_CLASS: return (IPTR)GM_CLASSPTR_FIELD(LIBBASE);\n");
228 fprintf(out
, " case MCC_PREFS_CLASS: return (IPTR)GM_CLASSPTR_FIELD(LIBBASE);\n");
232 /* FIXME: handle MCC_PREFS_IMAGE somehow */
233 /* FIXME: handle "ONLY_GLOBAL" ?? */
242 " AROS_LIBFUNC_EXIT\n"