IPTR DoMethod (Object * obj, IPTR MethodID, ...) { ASSERT_VALID_PTR(obj); if (!obj) return 0L; ASSERT_VALID_PTR(OCLASS(obj)); AROS_SLOWSTACKMETHODS_PRE(MethodID) retval = CALLHOOKPKT((struct Hook *) OCLASS(obj), obj, AROS_SLOWSTACKMETHODS_ARG(MethodID)); AROS_SLOWSTACKMETHODS_POST } /* DoMethod() */
IPTR GTScroller__OM_SET(Class *cl, Object *o, struct opSet *msg) { IPTR retval = scroller_set(cl, o, msg); /* If we have been subclassed, OM_UPDATE should not cause a GM_RENDER * because it would circumvent the subclass from fully overriding it. * The check of cl == OCLASS(o) should fail if we have been * subclassed, and we have gotten here via DoSuperMethodA(). */ if ( retval && ( (msg->MethodID != OM_UPDATE) || (cl == OCLASS(o)) ) ) { struct GadgetInfo *gi = msg->ops_GInfo; if (gi) { struct RastPort *rp = ObtainGIRPort(gi); if (rp) { DoMethod(o, GM_RENDER, (IPTR) gi, (IPTR) rp, GREDRAW_REDRAW); ReleaseGIRPort(rp); } /* if */ } /* if */ } /* if */ return retval; }
IPTR Ascii__OM_SET(Class *cl, Object *o, struct opSet *msg) { IPTR retval; /* Pass the attributes to the text class and force a refresh * if we need it */ if ((retval = DoSuperMethodA (cl, o, (Msg)msg)) && (OCLASS (o) == cl)) { struct RastPort *rp; /* Get a pointer to the rastport */ if ((rp = ObtainGIRPort (msg->ops_GInfo))) { struct gpRender gpr; /* Force a redraw */ gpr.MethodID = GM_RENDER; gpr.gpr_GInfo = msg->ops_GInfo; gpr.gpr_RPort = rp; gpr.gpr_Redraw = GREDRAW_UPDATE; DoMethodA (o, (Msg)&gpr); /* Release the temporary rastport */ ReleaseGIRPort (rp); } retval = 0; } return retval; }
/* * Deletes a 'boopsi' object. */ void DisposeObject (Object *object) { ULONG MethodID = OM_DISPOSE; OCLASS (object)->cl_ObjectCount --; DoMethodA (object, (Msg)&MethodID); } /* DisposeObject */
IPTR DoMethodA ( /* SYNOPSIS */ Object * obj, Msg message) /* FUNCTION Invokes a method on a BOOPSI object. The dispatcher of the class the object is inherited from is called. For more information about methods a class supports, see the class documentation. INPUTS obj - The object on which the method is to be performed. message - The message. The first field is the same for all methods and specifies which method is to be invoked (see <intuition/classusr.h>). RESULT Class and method dependent. See the class documentation. A value of 0 can be a valid return code but can also mean that a method is not supported. NOTES EXAMPLE BUGS SEE ALSO intuition.library/NewObjectA(), intuition.library/SetAttrsA(), intuition.library/GetAttr(), intuition.library/DisposeObject(), CoerceMethodA(), DoSuperMethodA(), <intuition/classusr.h> ******************************************************************************/ { ASSERT_VALID_PTR(obj); if (!obj) return 0L; ASSERT_VALID_PTR(OCLASS(obj)); ASSERT_VALID_PTR(message); return CALLHOOKPKT((struct Hook *) OCLASS(obj), obj, message); } /* DoMethodA */
static ULONG rootDispatcher (Class *cl, Object *o, Msg msg) { ULONG retval = 0; switch (msg->MethodID) { case OM_NEW: /* Called at beginning of constructor, allocate memory for object. */ cl = _OBJECT(o)->o_Class; retval = (ULONG)g_mem_chunk_alloc0(cl->cl_MemChunk); retval = (ULONG) BASEOBJECT(retval); OCLASS(retval) = cl; break; case OM_DISPOSE: /* Speicher freigeben. Aufrufer ist verantwortlich, dass bereits alles andere freigegeben wurde ! */ cl = _OBJECT(o)->o_Class; /* g_print("rootDispatcher: DISPOSE: obj=%p cl=%p %s, clmc=%p\n", o, cl, */ /* cl->cl_ID ? cl->cl_ID : "", cl->cl_MemChunk); */ g_mem_chunk_free(cl->cl_MemChunk, _OBJECT(o)); break; #ifdef REALAROSSTUFF /* unused in Zune */ case OM_ADDTAIL: /* Fuege <o> an Liste an. */ AddTail (((struct opAddTail *)msg)->opat_List, (struct Node *) _OBJECT(o)); break; case OM_REMOVE: /* Entferne Object aus der Liste */ Remove ((struct Node *) _OBJECT(o)); break; #endif default: /* Ignore */ break; } /* switch */ return (retval); }
BOOL GetMethod(Object *o, ULONG methodID, APTR *methodPtrPtr, Class **classPtrPtr) { ULONG idx; struct Bucket *b; Class *cl = OCLASS(o); idx = CalcHash(methodID, cl->HashTableSize); b = cl->HashTable[idx]; while (b) { if (b->MethodID == methodID) { *methodPtrPtr = b->MethodFunc; *classPtrPtr = b->mClass; return (TRUE); } b = b->Next; } return (FALSE); }
IPTR AROSListview__OM_UPDATE(Class *cl, Object *o,struct opSet *msg) { IPTR retval = DoSuperMethodA(cl, o, (Msg)msg); struct LVData *data = INST_DATA(cl, o); retval += (IPTR)_OM_SET(cl, o, (struct opSet *)msg); /* If we have been subclassed, OM_UPDATE should not cause a GM_RENDER * because it would circumvent the subclass from fully overriding it. * The check of cl == OCLASS(o) should fail if we have been * subclassed, and we have gotten here via DoSuperMethodA(). */ if ( retval && (cl == OCLASS(o)) && (data->lvd_NotifyCount) ) { struct GadgetInfo *gi = ((struct opSet *)msg)->ops_GInfo; if (gi) { struct RastPort *rp = ObtainGIRPort(gi); if (rp) { struct IBox ibox; GetGadgetIBox(o, gi, &ibox); data->lvd_DamageOffset = 0; data->lvd_NumDamaged = NumVisible(&ibox, data->lvd_EntryHeight); D(bug("Major rerender: o=%d, n=%d\n", data->lvd_DamageOffset, data->lvd_NumDamaged) ); DoMethod(o, GM_RENDER, (IPTR) gi, (IPTR) rp, GREDRAW_UPDATE); ReleaseGIRPort(rp); } } } return retval; }
/* * Create an object from a class. */ Object * NewObjectA (struct IClass *classPtr, ClassID classID, struct TagItem *tagList) { Object * object; struct _Object carrier; /* No classPtr ? */ if (!classPtr) { /* Search for the class */ if (!(classPtr = GetPublicClass(classID)) ) { /* I used to have a last-resort builtin class creation here, * but I decided nobody should need it, because you * dont have to call this function with a non-public class -dlc */ g_error("NewObjectA: null classPtr, and non public class %s\n" "Perhaps you should try MUI_NewObjectA ?\n", classID); return (NULL); /* Nothing found */ } } /* Put the classPtr in our dummy object */ carrier.o_Class = classPtr; /* Try to create a new object */ if ((object = (Object *) DoMethod (BASEOBJECT(&carrier), OM_NEW, (ULONG)tagList))) { OCLASS(object) = classPtr; /* One more object */ classPtr->cl_ObjectCount ++; } return (object); } /* NewObjectA */
BOOL is_menubarlabelclass_image(struct Image *im, struct GadToolsBase_intern *GadToolsBase) { BOOL is_barlabel = FALSE; DEBUG_FREEMENUS(bug("is_menubarlabelclass_image: im %p\n", im)); if (im) { DEBUG_FREEMENUS(bug("is_menubarlabelclass_image: depth %ld\n", im->Depth)); if (im->Depth == CUSTOMIMAGEDEPTH) { Class *cl; DEBUG_FREEMENUS(bug("is_menubarlabelclass_image: boopsi\n")); cl = OCLASS(im); DEBUG_FREEMENUS(bug("is_menubarlabelclass_image: cl %p\n",cl)); if (cl) { DEBUG_FREEMENUS(bug("is_menubarlabelclass_image: ID %p\n",cl->cl_ID)); if (cl->cl_ID) { if (strcmp(cl->cl_ID, MENUBARLABELCLASS) == 0) { DEBUG_FREEMENUS(bug("is_menubarlabelclass_image: barlabel\n")); is_barlabel = TRUE; } } } } } return is_barlabel; }
IPTR DoMethodA(Object *o, Msg msg) { register Class *cl = OCLASS(o); CallMethod(cl, o, msg); }
/*****i************************************************************************ NAME */ AROS_UFH3(IPTR, rootDispatcher, /* SYNOPSIS */ AROS_UFHA(Class *, cl, A0), AROS_UFHA(Object *, o, A2), AROS_UFHA(Msg, msg, A1)) /* FUNCTION Internal function! Processes all messages sent to the RootClass. Unknown messages are silently ignored. INPUTS cl - Pointer to the RootClass o - This object was the destination for the message in the first place msg - This is the message. RESULT The meaning of the result depends on the type of the message. NOTES This is a good place to debug BOOPSI objects since every message should eventually show up here. EXAMPLE BUGS SEE ALSO ******************************************************************************/ { AROS_USERFUNC_INIT IPTR retval = 0; Class *iclass; switch (msg->MethodID) { case OM_NEW: iclass = (Class *) o; /* Get memory for the instance data. The class knows how much is needed. NOTE: The object argument is actually the class! */ o = (Object *) alloc ( iclass->cl_MemoryPool, iclass->cl_ObjectSize ); if (o) { _OBJ(o)->o_Class = iclass; AROS_ATOMIC_INC(iclass->cl_ObjectCount); retval = (IPTR) BASEOBJECT(o); } break; case OM_DISPOSE: /* Free memory. Caller is responsible that everything else is already cleared! */ iclass = OCLASS(o); free ( iclass->cl_MemoryPool, _OBJECT(o), iclass->cl_ObjectSize ); AROS_ATOMIC_DEC(iclass->cl_ObjectCount); break; case OM_ADDTAIL: /* Add <o> to list. */ AddTail (((struct opAddTail *)msg)->opat_List, (struct Node *) _OBJECT(o)); retval = TRUE; break; case OM_REMOVE: /* Remove object from list. */ Remove ((struct Node *) _OBJECT(o)); retval = TRUE; break; case OM_SET: case OM_GET: case OM_UPDATE: case OM_NOTIFY: case OM_ADDMEMBER: case OM_REMMEMBER: default: /* Ignore */ break; } /* switch */ return (retval); AROS_USERFUNC_EXIT } /* rootDispatcher */
/** * Implementation of MUIM_DragQuery * * @param cl the class * @param obj the object * @param msg the parameter of the method * @return */ STATIC ULONG AddressGroupList_DragQuery(struct IClass *cl, Object *obj, struct MUIP_DragQuery *msg) { if (OCLASS(msg->obj) == CL_AddressEntryList->mcc_Class) return MUIV_DragQuery_Accept; return MUIV_DragQuery_Refuse; }
__asm ULONG ObjStringDispatcher(a0 struct IClass *cl, a2 Object *o, a1 Msg msg) { TagItem *ti; struct ObjStringData *idata = INST_DATA(cl, o); putreg(REG_A6, (long)cl->cl_UserData); geta4(); switch (msg->MethodID) { case OM_NEW: { Object *obj = (Object*)DoSuperMethodA(cl, o, msg); if (obj) { idata = INST_DATA(cl, obj); if (ti = FindTagItem(SWA_ObjString_StrAttr, ((opSet *)msg)->ops_AttrList)) idata->StrAttr = ti->ti_Data; SetAttrs(obj, MUIA_Draggable, TRUE, MUIA_CycleChain, 1, MUIA_String_AdvanceOnCR, TRUE, TAG_DONE); } return (ULONG)obj; } case OM_GET: { if (((struct opGet *)msg)->opg_AttrID == SWA_ObjString_NumVal) { ULONG *Store = ((struct opGet *)msg)->opg_Storage; if (Store) *Store = SWGetUL(o, MUIA_String_Integer); return 1; } break; } case OM_SET: case OM_UPDATE: { ULONG rc; if (ti=FindTagItem(MUIA_String_Contents,((opSet *)msg)->ops_AttrList)) { rc = DoSuperMethodA(cl, o, msg); set(o, SWA_ObjString_NumVal, SWGetUL(o, MUIA_String_Integer)); return rc; } if (ti=FindTagItem(SWA_ObjString_NumVal,((opSet *)msg)->ops_AttrList)) { if (idata->LastVal == ti->ti_Data) { ti->ti_Tag = TAG_IGNORE; rc = DoSuperMethodA(cl, o, msg); ti->ti_Tag = SWA_ObjString_NumVal; return rc; } SetSuperAttrs(cl, o, MUIA_NoNotify, TRUE, MUIA_String_Integer, idata->LastVal = ti->ti_Data, TAG_DONE); } } break; case MUIM_DragQuery: { Object *drag_o = ((struct MUIP_DragQuery *)msg)->obj; if (drag_o == o) return MUIV_DragQuery_Refuse; if (OCLASS(drag_o) == OCLASS(o)) { UBYTE *s1, *s2; get(drag_o, MUIA_String_Accept, &s1); get(o, MUIA_String_Accept, &s2); if (!s1 && !s2) return MUIV_DragQuery_Accept; if (!s1 || !s2) return MUIV_DragQuery_Refuse; return (ULONG)(!strcmp(s1, s2) ? MUIV_DragQuery_Accept : MUIV_DragQuery_Refuse); } if (OCLASS(drag_o) == SWObjListClass()) SWDB_RET(MUIV_DragQuery_Accept); if (!idata->StrAttr) return MUIV_DragQuery_Refuse; if (!(drag_o = (Object *)DoMethod(drag_o, SWM_Root_GetDragObj))) return MUIV_DragQuery_Refuse; return (ULONG)(get(drag_o, idata->StrAttr, NULL) ? MUIV_DragQuery_Accept : MUIV_DragQuery_Refuse); } case MUIM_DragDrop: { Object *drag_o = ((struct MUIP_DragQuery *)msg)->obj; if (OCLASS(drag_o) == OCLASS(o)) { set(o, MUIA_String_Contents, SWGetUL(drag_o, MUIA_String_Contents)); set(o, SWA_ObjString_NumVal, SWGetUL(o, MUIA_String_Integer)); return 0; } // -- if objlist, append its primary attribute ----------------------- if (OCLASS(drag_o) == SWObjListClass()) { UBYTE *c, *val; get(o, MUIA_String_Contents, &c); val = (UBYTE *)DoMethod((Object *)muiUserData(drag_o), SWM_E_Listmgr_StrCopy, c); if (val && c) { set(o, MUIA_String_Contents, val); FreeVec(val); return 0; } } if (!(drag_o = (Object *)DoMethod(drag_o, SWM_Root_GetDragObj))) return MUIV_DragQuery_Refuse; set(o, MUIA_String_Contents, SWGetStr(drag_o, idata->StrAttr)); return 0; } case SWM_ObjString_AppMsg: { UBYTE FSpec[FMSIZE]; struct AppMessage *AMsg = ((struct SWP_AppMsg *)msg)->AMsg; if (AMsg->am_NumArgs > 0) { NameFromLock(AMsg->am_ArgList[0].wa_Lock, FSpec, FMSIZE); AddPart(FSpec, AMsg->am_ArgList[0].wa_Name, FMSIZE); set(o, MUIA_String_Contents, FSpec); } return 0; } } return DoSuperMethodA(cl, o, msg); }
OOP_NewObject() INTERNALS HISTORY 29-10-95 digulla automatically created from intuition_lib.fd and clib/intuition_protos.h *****************************************************************************/ { AROS_LIBFUNC_INIT ULONG mid = OOP_GetMethodID(IID_Root, moRoot_Dispose); EnterFunc(bug("OOP_DisposeObject(classID=%s)\n", OCLASS(obj)->ClassNode.ln_Name)); if (obj == NULL) return; MD(OOP_OCLASS(obj))->objectcount --; OOP_DoMethod(obj, (OOP_Msg)&mid); ReturnVoid("OOP_DisposeObject"); AROS_LIBFUNC_EXIT } /* OOP_DisposeObject */
IPTR GTCheckBox__OM_SET(Class *cl, struct Gadget *g, struct opSet *msg) { struct CheckBoxData *data; struct TagItem *tag; const struct TagItem *taglist = msg->ops_AttrList; struct RastPort *rp; IPTR retval = FALSE; data = INST_DATA(cl, g); if (data->flags & CF_CustomImage) { tag = FindTagItem(GA_Image, taglist); if (tag) { DisposeObject(g->GadgetRender); g->GadgetRender = NULL; data->flags &= ~CF_CustomImage; } } if (msg->MethodID != OM_NEW) retval = DoSuperMethodA(cl, (Object *)g, (Msg)msg); while ((tag = NextTagItem(&taglist))) { switch (tag->ti_Tag) { case GA_Disabled: retval = TRUE; break; case GA_DrawInfo: if (msg->MethodID == OM_NEW) data->dri = (struct DrawInfo *) tag->ti_Data; break; case GA_Image: case GA_SelectRender: retval = TRUE; break; case GA_LabelPlace: if (msg->MethodID == OM_NEW) data->labelplace = (LONG)tag->ti_Data; break; case GTCB_Checked: if (tag->ti_Data) g->Flags |= GFLG_SELECTED; else g->Flags &= ~GFLG_SELECTED; retval = TRUE; break; } /* switch (tag->ti_Tag) */ } /* while ((tag = NextTagItem(&taglist))) */ if (g->Width == 0) g->Width = CHECKBOX_WIDTH; if (g->Height == 0) g->Height = CHECKBOX_HEIGHT; /* Redraw ourself? */ if ((retval) && (msg->MethodID != OM_NEW) && ((msg->MethodID != OM_UPDATE) || (OCLASS(g) == cl))) { rp = ObtainGIRPort(msg->ops_GInfo); if (rp) { DoMethod((Object *)g, GM_RENDER, (IPTR) msg->ops_GInfo, (IPTR) rp, GREDRAW_UPDATE); ReleaseGIRPort(rp); retval = FALSE; } } return retval; }
STATIC IPTR text_set(Class * cl, Object * o, struct opSet * msg) { IPTR retval = 0UL; struct TagItem *tag; const struct TagItem *tstate; struct TextData *data = INST_DATA(cl, o); struct RastPort *rport; EnterFunc(bug("Text::Set()\n")); tstate = msg->ops_AttrList; while ((tag = NextTagItem(&tstate))) { IPTR tidata = tag->ti_Data; switch (tag->ti_Tag) { case GTA_GadgetKind: data->gadgetkind = (WORD)tidata; break; case GTNM_Number: data->toprint = tidata; D(bug("GTNM_Number: %ld\n", tidata)); if (data->dispfunc) { #ifdef __MORPHOS__ REG_A7 -= 8; ((ULONG *)REG_A7)[0] = (ULONG)o; ((ULONG *)REG_A7)[1] = data->toprint; data->toprint = MyEmulHandle->EmulCallDirect68k(data->dispfunc); REG_A7 += 8; #else data->toprint = (ULONG)data->dispfunc((struct Gadget *)o, (WORD)data->toprint); #endif } retval = 1UL; break; case GTTX_Text: /* If the user has GT_SetGadgetAttrs() us to a different text, ** then don't copy it anymore */ if (msg->MethodID != OM_NEW) { if (data->flags & TEXTF_COPYTEXT) { FreeVec((APTR)data->toprint); data->flags &= ~TEXTF_COPYTEXT; } data->toprint = tidata; D(bug("GTTX_Text: %s\n", tidata)); } retval = 1UL; break; case GTTX_Border: /* [I] */ case GTNM_Border: /* [I] */ if (tidata) data->flags |= TEXTF_BORDER; D(bug("Border: %d\n", tidata)); break; /*case GTTX_FrontPen: [IS] */ case GTNM_FrontPen: /* [IS] */ data->frontpen = (UBYTE)tidata; D(bug("FrontPen: %d\n", tidata)); retval = 1UL; break; /* case GTTX_BackPen: [IS] */ case GTNM_BackPen: /* [IS] */ data->backpen = (UBYTE)tidata; D(bug("BackPen: %d\n", tidata)); retval = 1UL; break; /* case GTTX_Justification: [I] */ case GTNM_Justification: /* [I] */ data->justification = (UBYTE)tidata; D(bug("Justification: %d\n", tidata)); break; case GTNM_Format: /* [I] */ case GTA_Text_Format: data->format = (STRPTR)tidata; D(bug("Format: %s\n", tidata)); break; /* case GTTX_Clipped: [I] */ case GTNM_Clipped: if (tidata) data->flags |= TEXTF_CLIPPED; D(bug("Clipped: %d\n", tidata)); break; case GTNM_MaxNumberLen: /* [I] */ data->maxnumberlength = tidata; D(bug("MaxNumberLen: %d\n", tidata)); break; } /* switch() */ } /* while (iterate taglist) */ /* Redraw the gadget, if an attribute was changed and if this is the objects' base-class. */ if ((retval) && (OCLASS(o) == cl)) { rport = ObtainGIRPort(msg->ops_GInfo); if (rport) { DoMethod(o, GM_RENDER, (IPTR) msg->ops_GInfo, (IPTR) rport, GREDRAW_UPDATE); ReleaseGIRPort(rport); retval = FALSE; } } ReturnInt ("Text::Set", IPTR, retval); }