os/graphics/graphicscomposition/openwfcompositionengine/common/include/owfobject.h
Update contrib.
1 /* Copyright (c) 2009 The Khronos Group Inc.
3 * Permission is hereby granted, free of charge, to any person obtaining a
4 * copy of this software and/or associated documentation files (the
5 * "Materials"), to deal in the Materials without restriction, including
6 * without limitation the rights to use, copy, modify, merge, publish,
7 * distribute, sublicense, and/or sell copies of the Materials, and to
8 * permit persons to whom the Materials are furnished to do so, subject to
9 * the following conditions:
11 * The above copyright notice and this permission notice shall be included
12 * in all copies or substantial portions of the Materials.
14 * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20 * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
38 typedef void (*DESTRUCTOR)(void*);
39 typedef void (*CONSTRUCTOR)(void*);
43 DESTRUCTOR destructor;
44 OWFuint32 referenceCount;
48 #define TYPE(x) "" # x "_type"
50 /*! returns field offset within structure */
51 #define FOFF(x,y) ((OWFuint32) &(((x*) 0x1000)->y) - 0x1000)
53 /*! returns pointer to wrapper object which holds object x */
54 #define _O(x) ((OWF_OBJECT*) ((OWFuint32)(x) -\
55 FOFF(OWF_OBJECT,payload)))
57 /*! create new object instance */
58 #define CREATE(x) (x*) OWF_Object_Construct(sizeof(x), TYPE(x), \
59 & x##_Ctor, & x##_Dtor)
61 #define REFCOUNT(x) ((x) ? _O(x)->referenceCount : 0xFFFFFFFF)
63 /*! get the type of the contained object */
64 #define TYPEOF(x) (_O(x)->type)
66 /*! increment object reference count */
69 _O(y)->referenceCount++; \
70 DPRINT(("ADDREF: ref count of %s(%p) is now %d\n", TYPEOF(y), y, \
75 /*! decrement object reference count, call destructor if count reaches zero */
78 --_O(x)->referenceCount; \
79 DPRINT(("REMREF: ref count of %s(%p) is now %d\n", TYPEOF(x), x, \
81 if (0 == _O(x)->referenceCount) {\
82 if (_O(x)->destructor) {\
83 _O(x)->destructor(x);\
95 OWF_Object_Construct(size_t size,
106 #endif /* OWFOBJECT_H_ */