QTYPE_NONE,
QTYPE_QINT,
QTYPE_QSTRING,
+ QTYPE_QDICT,
+ QTYPE_QLIST,
+ QTYPE_QFLOAT,
+ QTYPE_QBOOL,
+ QTYPE_QERROR,
} qtype_code;
struct QObject;
QObject base
/* Get the 'base' part of an object */
-#define QOBJECT(obj) (&obj->base)
+#define QOBJECT(obj) (&(obj)->base)
/* High-level interface for qobject_incref() */
#define QINCREF(obj) \
- assert(obj != NULL); \
qobject_incref(QOBJECT(obj))
/* High-level interface for qobject_decref() */
#define QDECREF(obj) \
- assert(obj != NULL); \
qobject_decref(QOBJECT(obj))
/* Initialize an object to default values */
*/
static inline void qobject_incref(QObject *obj)
{
- obj->refcnt++;
+ if (obj)
+ obj->refcnt++;
}
/**
*/
static inline void qobject_decref(QObject *obj)
{
- if (--obj->refcnt == 0) {
+ if (obj && --obj->refcnt == 0) {
assert(obj->type != NULL);
assert(obj->type->destroy != NULL);
obj->type->destroy(obj);