util: indent the object.h code by tabs

Signed-off-by:	Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer 2021-07-20 11:50:01 +10:00
parent 7e7a3e1b16
commit 11e3fc7709

View file

@ -47,9 +47,9 @@ typedef void (*object_destroy_func_t)(struct object *object);
/* internal implementation, do not use directly */
struct object {
struct object *parent; /* may be NULL */
uint32_t refcount;
object_destroy_func_t destroy;
struct object *parent; /* may be NULL */
uint32_t refcount;
object_destroy_func_t destroy;
};
/* internal implementation, do not call directly */
@ -58,37 +58,37 @@ object_init(struct object *object,
struct object *parent,
object_destroy_func_t destroy)
{
object->refcount = 1;
object->destroy = destroy;
object->parent = parent;
object->refcount = 1;
object->destroy = destroy;
object->parent = parent;
}
/* internal implementation, do not call directly */
static inline void
object_destroy(struct object *object)
{
if (object->destroy)
object->destroy(object);
free(object);
if (object->destroy)
object->destroy(object);
free(object);
}
/* internal implementation, do not call directly */
static inline void *
object_ref(struct object *object)
{
assert(object->refcount >= 1);
++object->refcount;
return object;
assert(object->refcount >= 1);
++object->refcount;
return object;
}
/* internal implementation, do not call directly */
static inline void *
object_unref(struct object *object)
{
assert(object->refcount >= 1);
if (--object->refcount == 0)
object_destroy(object);
return NULL;
assert(object->refcount >= 1);
if (--object->refcount == 0)
object_destroy(object);
return NULL;
}
@ -98,8 +98,8 @@ object_unref(struct object *object)
*/
#define OBJECT_IMPLEMENT_REF(type_) \
struct type_ * type_##_ref(struct type_ *obj) { \
object_ref(&obj->object); \
return obj; \
object_ref(&obj->object); \
return obj; \
}
/**
@ -113,8 +113,8 @@ struct type_ * type_##_ref(struct type_ *obj) { \
*/
#define OBJECT_IMPLEMENT_UNREF(type_) \
struct type_ * type_##_unref(struct type_ *obj) { \
if (!obj) return NULL; \
return object_unref(&obj->object); \
if (!obj) return NULL; \
return object_unref(&obj->object); \
} \
static inline void type_##_unrefp(struct type_ **p_) { \
if (*p_) type_##_unref(*p_); \
@ -130,7 +130,7 @@ struct __useless_struct_to_allow_trailing_semicolon__
#define OBJECT_IMPLEMENT_INIT(type_) \
void type_##_init_object(struct type_ *t, struct object *parent) { \
assert((intptr_t)t == (intptr_t)&t->object && "field 'object' must be first one in the struct"); \
object_init(&t->object, parent, (object_destroy_func_t)type_##_destroy); \
object_init(&t->object, parent, (object_destroy_func_t)type_##_destroy); \
}
/**
@ -140,11 +140,11 @@ void type_##_init_object(struct type_ *t, struct object *parent) { \
*/
#define OBJECT_IMPLEMENT_CREATE(type_) \
struct type_ * type_##_create(struct object *parent) { \
struct type_ *t = calloc(1, sizeof *t); \
assert((intptr_t)t == (intptr_t)&t->object && "field 'object' must be first one in the struct"); \
assert(t != NULL); \
object_init(&t->object, parent, (object_destroy_func_t)type_##_destroy); \
return t; \
struct type_ *t = calloc(1, sizeof *t); \
assert((intptr_t)t == (intptr_t)&t->object && "field 'object' must be first one in the struct"); \
assert(t != NULL); \
object_init(&t->object, parent, (object_destroy_func_t)type_##_destroy); \
return t; \
}
/**
@ -162,7 +162,7 @@ struct parent_type_ * type_##_parent(struct type_ *o) { \
*/
#define OBJECT_IMPLEMENT_GETTER(type_, field_, rtype_) \
rtype_ type_##_get_##field_(struct type_ *obj) { \
return obj->field_; \
return obj->field_; \
}
/**
@ -171,5 +171,5 @@ rtype_ type_##_get_##field_(struct type_ *obj) { \
*/
#define OBJECT_IMPLEMENT_SETTER(type_, field_, rtype_) \
void type_##_set_##field_(struct type_ *obj, rtype_ val_) { \
obj->field_ = (val_); \
obj->field_ = (val_); \
}