2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 Copyright © 2001-2003, The MorphOS Development Team. All Rights Reserved.
6 Create a new BOOPSI object.
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 /*****************************************************************************
19 #include <intuition/classusr.h>
20 #include <proto/intuition.h>
22 AROS_LH3(APTR
, NewObjectA
,
25 AROS_LHA(struct IClass
*, classPtr
, A0
),
26 AROS_LHA(UBYTE
*, classID
, A1
),
27 AROS_LHA(struct TagItem
*, tagList
, A2
),
30 struct IntuitionBase
*, IntuitionBase
, 106, Intuition
)
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.
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
49 A BOOPSI object which can be manipulated with general functions and
50 which must be disposed with DisposeObject() later.
53 This functions send OM_NEW to the dispatcher of the class.
60 DisposeObject(), SetAttrsA(), GetAttr(), MakeClass(),
61 "Basic Object-Oriented Programming System for Intuition" and
62 "boopsi Class Reference" Dokument.
64 *****************************************************************************/
71 DEBUG_NEWOBJECT(dprintf("NewObject[%x]: Class 0x%lx <%s> TagList 0x%lx\n",
72 &method
, /* some unique id to see matching debug info */
74 classID
? classID
: (classPtr
->cl_ID
? classPtr
->cl_ID
: "NULL"),
77 EnterFunc(bug("intuition::NewObjectA()\n"));
86 while (tag
= NextTagItem(&state
))
88 dprintf("\t%08lx %08lx\n", tag
->ti_Tag
, tag
->ti_Data
);
94 ObtainSemaphoreShared (&GetPrivIBase(IntuitionBase
)->ClassListLock
);
98 classPtr
= FindClass (classID
);
100 /* Make sure the class doesn't go away while we create the object */
103 AROS_ATOMIC_INC(classPtr
->cl_ObjectCount
);
106 ReleaseSemaphore (&GetPrivIBase(IntuitionBase
)->ClassListLock
);
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
);