From e3b7c54bd4ebd3853d53b83cd21c91c85d2d234d Mon Sep 17 00:00:00 2001 From: mazze Date: Thu, 16 Aug 2012 21:54:49 +0000 Subject: [PATCH] Trying to mimic our style of writing private Zune classes. git-svn-id: https://svn.aros.org/svn/aros/trunk/contrib@45583 fb15a70f-31f2-0310-bbcc-cdcc74a49acc --- development/gui/chocolatecastle/source/generator.c | 37 +++++ .../gui/chocolatecastle/source/muigenerator.c | 166 +++++++++++++++++++++ 2 files changed, 203 insertions(+) diff --git a/development/gui/chocolatecastle/source/generator.c b/development/gui/chocolatecastle/source/generator.c index daed400a6..03d6c86b9 100644 --- a/development/gui/chocolatecastle/source/generator.c +++ b/development/gui/chocolatecastle/source/generator.c @@ -781,6 +781,41 @@ IPTR GeneratorMethodHeader(UNUSED Class *cl, Object *obj, struct GENP_MethodHead { struct GeneratorData *d = INST_DATA(cl, obj); +#ifdef __AROS__ + + TC("/// %s__"); T(msg->FuncName); T("()\n\n"); + + if (xget(d->DocCheck, MUIA_Selected)) + { + UBYTE line[79]; + STRPTR unit_name; + + unit_name = (STRPTR)xget(obj, GENA_UnitName); + if (msg->ExtClass) unit_name = (STRPTR)xget(findobj(d->LibGroup, OBJ_LIBG_NAME), MUIA_String_Contents); + + T("/************************************************************************************"); + T("\n NAME\n"); + FmtNPut(line, (STRPTR)" %s\n", 79, msg->MethodName); + T(line); + FmtNPut(line, "\n LOCATION\n\n %s\n\n FUNCTION\n\n\n NOTES\n\n\n SEE ALSO\n\n", + 79, unit_name); + T(line); + T("\n******************************************************************************/\n\n\n"); + } + + TC("IPTR %s__"); T(msg->FuncName); T("(Class *cl, Object *obj, "); + if (!(*msg->StructName)) T("Msg msg"); + else { T("struct "); T(msg->StructName); T(" *msg"); } + T(")\n{\n"); + II; + + if (msg->Instance) + { + I; TC("struct %s_DATA *d = INST_DATA(cl, obj);\n"); + } + +#else + TC("/// %s"); T(msg->FuncName); T("()\n\n"); if (xget(d->DocCheck, MUIA_Selected)) @@ -812,6 +847,8 @@ IPTR GeneratorMethodHeader(UNUSED Class *cl, Object *obj, struct GENP_MethodHead I; TC("struct %sData *d = INST_DATA(cl, obj);\n"); } +#endif + return 0; } diff --git a/development/gui/chocolatecastle/source/muigenerator.c b/development/gui/chocolatecastle/source/muigenerator.c index cb6702032..785148dec 100644 --- a/development/gui/chocolatecastle/source/muigenerator.c +++ b/development/gui/chocolatecastle/source/muigenerator.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include "muigenerator.h" @@ -67,6 +68,15 @@ const char* PopularMuiSuperclasses[] = NULL }; +#ifdef __AROS__ +const struct MethodEntry DefaultMethods[] = { + { (STRPTR)"OM_NEW", (STRPTR)"OM_NEW", (STRPTR)"opSet", (STRPTR)"00000101", TRUE }, + { (STRPTR)"OM_DISPOSE", (STRPTR)"OM_DISPOSE", (STRPTR)"", (STRPTR)"00000102", TRUE }, + { (STRPTR)"OM_SET", (STRPTR)"OM_SET", (STRPTR)"opSet", (STRPTR)"00000103", TRUE }, + { (STRPTR)"OM_GET", (STRPTR)"OM_GET", (STRPTR)"opGet", (STRPTR)"00000104", TRUE }, + { NULL, NULL, NULL, NULL, 0 } +}; +#else const struct MethodEntry DefaultMethods[] = { { (STRPTR)"OM_NEW", (STRPTR)"New", (STRPTR)"opSet", (STRPTR)"00000101", TRUE }, { (STRPTR)"OM_DISPOSE", (STRPTR)"Dispose", (STRPTR)"", (STRPTR)"00000102", TRUE }, @@ -74,6 +84,7 @@ const struct MethodEntry DefaultMethods[] = { { (STRPTR)"OM_GET", (STRPTR)"Get", (STRPTR)"opGet", (STRPTR)"00000104", TRUE }, { NULL, NULL, NULL, NULL, 0 } }; +#endif #define SUPERCLASS_TYPE_PRIVATE 0 #define SUPERCLASS_TYPE_PUBLIC 1 @@ -313,6 +324,70 @@ static void generate_get_contents(Object *obj) /// +#ifdef __AROS__ +static void generate_aros_dispatcher(Object *obj, Object *method_list, struct MuiGeneratorData *d) +{ + char *s; + int32_t superclass_type; + ULONG method_count, method_number; + char buffer[10]; + + method_count = xget(method_list, MUIA_List_Entries); + FmtNPut(buffer, "%u", sizeof buffer, method_count); + + T("/*** Setup ************************************************************************/\n"); + T("ZUNE_CUSTOMCLASS_"); + T(buffer); + T("\n(\n"); + II; I; + TC("%s, NULL, "); + + superclass_type = xget(d->SuperclassTypeRadio, MUIA_Radio_Active); + + if (superclass_type == SUPERCLASS_TYPE_PRIVATE) + { + s = (char*)xget(d->SuperclassPointerString, MUIA_String_Contents); + T("NULL, "); T(s); T(","); + } + else + { + s = (char*)xget(d->SuperclassNameString, MUIA_String_Contents); + T("MUIC_"); T(s); T(", NULL,"); + } + + T("\n"); + + for (method_number = 0;; method_number++) + { + struct MethodEntry *me; + + DoMethod(method_list, MUIM_List_GetEntry, method_number, (intptr_t)&me); + if (!me) break; + + I; T(me->Name); T(", "); + + if (*me->Structure) + { + T("struct "); T(me->Structure); T(" *"); + } + else + { + T("Msg"); + } + + if (method_number < method_count - 1) + { + T(","); + } + + T("\n"); + } + + IO; T(");\n\n"); +} +#endif + + /// MuiGeneratorNew() IPTR MuiGeneratorNew(Class *cl, Object *obj, struct opSet *msg) @@ -388,6 +463,50 @@ intptr_t MuiGeneratorGenerate(Class *cl, Object *obj, Msg msg) if (DoMethod(obj, GENM_Setup, (intptr_t)"%s.c")) { + +#ifdef __AROS__ + T("/*\n"); + T(" Copyright © 2012, The AROS Development Team. All rights reserved.\n"); + T(" $Id$\n"); + T("*/\n\n"); + TCS("#include \"%s.h\"\n\n"); + + TC("/// %s_DATA\n\n"); + TC("struct %s_DATA\n{\n"); II; I; T("// Insert object instance data here.\n"); IO; T("};\n\n\n"); + T("///\n"); + + /*------------------------------------------------------------------------*/ + /* methods */ + /*------------------------------------------------------------------------*/ + + for (entry_number = 0;; entry_number++) + { + struct MethodEntry *me; + BOOL return_zero = TRUE; + + DoMethod(d->MethodList, MUIM_List_GetEntry, entry_number, (intptr_t)&me); + if (!me) break; + DoMethod(obj, GENM_MethodHeader, (IPTR)me->Name, (IPTR)me->Function, + (IPTR)me->Structure, (IPTR)me->Identifier, TRUE, FALSE); + + if (strcmp((char*)me->Name, "OM_GET") == 0) + { + generate_get_contents(obj); + return_zero = FALSE; + } + else if (strcmp((char*)me->Name, "OM_SET") == 0) + { + generate_set_contents(obj); + return_zero = FALSE; + } + + DoMethod(obj, GENM_MethodFooter, return_zero); + } + + generate_aros_dispatcher(obj, d->MethodList, d); + +#else + char *s; int32_t superclass_type; @@ -470,6 +589,9 @@ intptr_t MuiGeneratorGenerate(Class *cl, Object *obj, Msg msg) } generate_dispatcher(obj, d->MethodList); + +#endif + } DoMethod(obj, GENM_Cleanup); @@ -477,6 +599,47 @@ intptr_t MuiGeneratorGenerate(Class *cl, Object *obj, Msg msg) if (DoMethod(obj, GENM_Setup, (intptr_t)"%s.h")) { + +#ifdef __AROS__ + + TC("#ifndef %s_H\n"); + TC("#define %s_H\n\n"); + T("/*\n"); + T(" Copyright © 2012, The AROS Development Team. All rights reserved.\n"); + T(" $Id$\n"); + T("*/\n\n"); + T("#include \n"); + T("#include \n\n"); + T("/*** Identifier base ********************************************************/\n"); + TC("#define MUIB_%s (TAG_USER|0x00000000)\n\n"); + + /*----------------*/ + /* custom methods */ + /*----------------*/ + + T("/*** Attributes *************************************************************/\n"); + for (entry_number = 0;; entry_number++) + { + struct MethodEntry *me; + + DoMethod(d->MethodList, MUIM_List_GetEntry, entry_number, (intptr_t)&me); + if (!me) break; + + if (!me->Standard) + { + T("#define "); T(me->Name); TC(" (MUIB_%s | 0x"); T(me->Identifier); T(")\n"); + } + } + T("\n/*** Variables **************************************************************/\n"); + TC("extern struct MUI_CustomClass *%s_CLASS;\n\n"); + + T("/*** Macros *****************************************************************/\n"); + TC("#define %sObject "); + TC("BOOPSIOBJMACRO_START(%s_CLASS->mcc_Class)\n\n"); + T("#endif\n"); + +#else + DoMethod(obj, GENM_Signature); TC("/* %sClass header. */\n\n"); T("#include \n"); @@ -503,6 +666,9 @@ intptr_t MuiGeneratorGenerate(Class *cl, Object *obj, Msg msg) T("#define "); T(me->Name); T(" 0x"); T(me->Identifier); T("\n"); } } + +#endif + } DoMethod(obj, GENM_Cleanup); DoSuperMethodA(cl, obj, msg); // displays info requester -- 2.11.4.GIT