Minor fixes to comments.
[AROS.git] / rom / intuition / newobjecta.c
blob90d00838f328f0ab86615bfd2b8ca0227cdc8024
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 Copyright © 2001-2003, The MorphOS Development Team. All Rights Reserved.
4 $Id$
6 Create a new BOOPSI object.
7 */
9 #include <exec/lists.h>
10 #include <intuition/classes.h>
11 #include <proto/exec.h>
12 #include <proto/alib.h>
13 #include <proto/utility.h>
14 #include "intuition_intern.h"
16 /*****************************************************************************
18 NAME */
19 #include <intuition/classusr.h>
20 #include <proto/intuition.h>
22 AROS_LH3(APTR, NewObjectA,
24 /* SYNOPSIS */
25 AROS_LHA(struct IClass *, classPtr, A0),
26 AROS_LHA(UBYTE *, classID, A1),
27 AROS_LHA(struct TagItem *, tagList, A2),
29 /* LOCATION */
30 struct IntuitionBase *, IntuitionBase, 106, Intuition)
32 /* FUNCTION
33 Use this function to create BOOPSI objects (BOOPSI stands for
34 "Basic Object Oriented Programming System for Intuition).
36 You may specify a class either by it's name (if it's a public class)
37 or by a pointer to its definition (if it's a private class). If
38 classPtr is NULL, classID is used.
40 INPUTS
41 classPtr - Pointer to a private class (or a public class if you
42 happen to have a pointer to it)
43 classID - Name of a public class
44 tagList - Initial attributes. Read the documentation of the class
45 carefully to find out which attributes must be specified
46 here and which can.
48 RESULT
49 A BOOPSI object which can be manipulated with general functions and
50 which must be disposed with DisposeObject() later.
52 NOTES
53 This functions send OM_NEW to the dispatcher of the class.
55 EXAMPLE
57 BUGS
59 SEE ALSO
60 DisposeObject(), SetAttrsA(), GetAttr(), MakeClass(),
61 "Basic Object-Oriented Programming System for Intuition" and
62 "boopsi Class Reference" Dokument.
64 *****************************************************************************/
66 AROS_LIBFUNC_INIT
68 Object *object;
69 struct opSet method;
71 DEBUG_NEWOBJECT(dprintf("NewObject[%x]: Class 0x%lx <%s> TagList 0x%lx\n",
72 &method, /* some unique id to see matching debug info */
73 classPtr,
74 classID ? classID : (classPtr->cl_ID ? classPtr->cl_ID : "NULL"),
75 tagList));
77 EnterFunc(bug("intuition::NewObjectA()\n"));
79 #if 1
80 if (tagList)
82 DEBUG_NEWOBJECT(
83 APTR state = tagList;
84 struct TagItem *tag;
86 while (tag = NextTagItem(&state))
88 dprintf("\t%08lx %08lx\n", tag->ti_Tag, tag->ti_Data);
92 #endif
94 ObtainSemaphoreShared (&GetPrivIBase(IntuitionBase)->ClassListLock);
96 /* No classPtr ? */
97 if (!classPtr)
98 classPtr = FindClass (classID);
100 /* Make sure the class doesn't go away while we create the object */
101 if (classPtr)
103 AROS_ATOMIC_INC(classPtr->cl_ObjectCount);
106 ReleaseSemaphore (&GetPrivIBase(IntuitionBase)->ClassListLock);
108 if (!classPtr)
109 return (NULL); /* Nothing found */
111 D(bug("classPtr: %p\n", classPtr));
113 /* Try to create a new object */
114 method.MethodID = OM_NEW;
115 method.ops_AttrList = tagList;
116 method.ops_GInfo = NULL;
117 object = (Object *) CoerceMethodA (classPtr, (Object *)classPtr, (Msg)&method);
119 /* Release the lock on the class. Rootclass also has increased this count. */
120 AROS_ATOMIC_DEC(classPtr->cl_ObjectCount);
122 DEBUG_NEWOBJECT(dprintf("NewObject[%x]: return 0x%lx\n", &method, object));
124 ReturnPtr("intuition::NewObjectA()", Object *, object);
126 AROS_LIBFUNC_EXIT
127 } /* NewObjectA() */