util: add more useless structs to avoid semicolon issues

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

View file

@ -131,7 +131,8 @@ struct __useless_struct_to_allow_trailing_semicolon__
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); \
}
} \
struct __useless_struct_to_allow_trailing_semicolon__
/**
* For a type for "foo", generate
@ -145,7 +146,9 @@ struct type_ * type_##_create(struct object *parent) { \
assert(t != NULL); \
object_init(&t->object, parent, (object_destroy_func_t)type_##_destroy); \
return t; \
}
} \
struct __useless_struct_to_allow_trailing_semicolon__
/**
* For a type "foo" with parent type "bar", generate
@ -154,7 +157,9 @@ struct type_ * type_##_create(struct object *parent) { \
#define OBJECT_IMPLEMENT_PARENT(type_, parent_type_) \
struct parent_type_ * type_##_parent(struct type_ *o) { \
return container_of(o->object.parent, struct parent_type_, object); \
}
} \
struct __useless_struct_to_allow_trailing_semicolon__
/**
* Generate a simple getter function for the given type, field and return
@ -163,7 +168,9 @@ 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_; \
}
} \
struct __useless_struct_to_allow_trailing_semicolon__
/**
* Generate a simple setter function for the given type, field and return
@ -172,4 +179,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_); \
}
} \
struct __useless_struct_to_allow_trailing_semicolon__