2 Copyright © 1995-2003, 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(), SetAttrs(), GetAttr(), MakeClass(),
61 "Basic Object-Oriented Programming System for Intuition" and
62 "boopsi Class Reference" Dokument.
64 *****************************************************************************/
67 AROS_LIBBASE_EXT_DECL(struct IntuitionBase
*,IntuitionBase
)
72 DEBUG_NEWOBJECT(dprintf("NewObject[%x]: Class 0x%lx <%s> TagList 0x%lx\n",
73 &method
, /* some unique id to see matching debug info */
75 classID
? classID
: (classPtr
->cl_ID
? classPtr
->cl_ID
: "NULL"),
78 EnterFunc(bug("intuition::NewObjectA()\n"));
87 while (tag
= NextTagItem(&state
))
89 dprintf("\t%08lx %08lx\n", tag
->ti_Tag
, tag
->ti_Data
);
95 ObtainSemaphoreShared (&GetPrivIBase(IntuitionBase
)->ClassListLock
);
99 classPtr
= FindClass (classID
);
101 /* Make sure the class doesn't go away while we create the object */
104 AROS_ATOMIC_INC(classPtr
->cl_ObjectCount
);
107 ReleaseSemaphore (&GetPrivIBase(IntuitionBase
)->ClassListLock
);
110 return (NULL
); /* Nothing found */
112 D(bug("classPtr: %p\n", classPtr
));
114 /* Try to create a new object */
115 method
.MethodID
= OM_NEW
;
116 method
.ops_AttrList
= tagList
;
117 method
.ops_GInfo
= NULL
;
118 object
= (Object
*) CoerceMethodA (classPtr
, (Object
*)classPtr
, (Msg
)&method
);
120 /* Release the lock on the class. Rootclass also has increased this count. */
121 AROS_ATOMIC_DEC(classPtr
->cl_ObjectCount
);
123 DEBUG_NEWOBJECT(dprintf("NewObject[%x]: return 0x%lx\n", &method
, object
));
125 ReturnPtr("intuition::NewObjectA()", Object
*, object
);