mirror of
https://gitlab.freedesktop.org/libinput/libei.git
synced 2026-02-19 08:50:38 +01:00
utils: Rename OBJECT_DECLARE... to OBJECT_IMPLEMENT
More technically correct since that's what all these crazy macros do. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
6610319832
commit
718beb926e
8 changed files with 57 additions and 57 deletions
|
|
@ -36,12 +36,12 @@ ei_device_destroy(struct ei_device *device)
|
|||
}
|
||||
|
||||
_public_
|
||||
OBJECT_DECLARE_REF(ei_device);
|
||||
OBJECT_IMPLEMENT_REF(ei_device);
|
||||
_public_
|
||||
OBJECT_DECLARE_UNREF(ei_device);
|
||||
OBJECT_DECLARE_CREATE(ei_device);
|
||||
OBJECT_IMPLEMENT_UNREF(ei_device);
|
||||
OBJECT_IMPLEMENT_CREATE(ei_device);
|
||||
static
|
||||
OBJECT_DECLARE_PARENT(ei_device, ei);
|
||||
OBJECT_IMPLEMENT_PARENT(ei_device, ei);
|
||||
|
||||
_public_ struct ei*
|
||||
ei_device_get_context(struct ei_device *device)
|
||||
|
|
|
|||
20
src/libei.c
20
src/libei.c
|
|
@ -101,15 +101,15 @@ ei_event_destroy(struct ei_event *event)
|
|||
}
|
||||
|
||||
static
|
||||
OBJECT_DECLARE_INIT(ei_event);
|
||||
OBJECT_IMPLEMENT_INIT(ei_event);
|
||||
/* this one is not public */
|
||||
OBJECT_DECLARE_REF(ei_event);
|
||||
OBJECT_IMPLEMENT_REF(ei_event);
|
||||
_public_
|
||||
OBJECT_DECLARE_UNREF(ei_event);
|
||||
OBJECT_IMPLEMENT_UNREF(ei_event);
|
||||
_public_
|
||||
OBJECT_DECLARE_GETTER(ei_event, type, enum ei_event_type);
|
||||
OBJECT_IMPLEMENT_GETTER(ei_event, type, enum ei_event_type);
|
||||
_public_
|
||||
OBJECT_DECLARE_GETTER(ei_event, device, struct ei_device*);
|
||||
OBJECT_IMPLEMENT_GETTER(ei_event, device, struct ei_device*);
|
||||
|
||||
static void
|
||||
ei_destroy(struct ei *ei)
|
||||
|
|
@ -121,15 +121,15 @@ ei_destroy(struct ei *ei)
|
|||
free(ei->name);
|
||||
}
|
||||
|
||||
OBJECT_DECLARE_INIT(ei);
|
||||
OBJECT_IMPLEMENT_INIT(ei);
|
||||
_public_
|
||||
OBJECT_DECLARE_REF(ei);
|
||||
OBJECT_IMPLEMENT_REF(ei);
|
||||
_public_
|
||||
OBJECT_DECLARE_UNREF(ei);
|
||||
OBJECT_IMPLEMENT_UNREF(ei);
|
||||
#define _cleanup_ei_ _cleanup_(ei_cleanup)
|
||||
_public_
|
||||
OBJECT_DECLARE_SETTER(ei, user_data, void *);
|
||||
OBJECT_DECLARE_GETTER(ei, user_data, void *);
|
||||
OBJECT_IMPLEMENT_SETTER(ei, user_data, void *);
|
||||
OBJECT_IMPLEMENT_GETTER(ei, user_data, void *);
|
||||
|
||||
int
|
||||
ei_init(struct ei *ei)
|
||||
|
|
|
|||
|
|
@ -96,18 +96,18 @@ eis_client_destroy(struct eis_client *client)
|
|||
list_remove(&client->link);
|
||||
}
|
||||
|
||||
OBJECT_DECLARE_CREATE(eis_client);
|
||||
OBJECT_IMPLEMENT_CREATE(eis_client);
|
||||
static
|
||||
OBJECT_DECLARE_PARENT(eis_client, eis);
|
||||
OBJECT_IMPLEMENT_PARENT(eis_client, eis);
|
||||
|
||||
_public_
|
||||
OBJECT_DECLARE_REF(eis_client);
|
||||
OBJECT_IMPLEMENT_REF(eis_client);
|
||||
|
||||
_public_
|
||||
OBJECT_DECLARE_UNREF(eis_client);
|
||||
OBJECT_IMPLEMENT_UNREF(eis_client);
|
||||
|
||||
_public_
|
||||
OBJECT_DECLARE_GETTER(eis_client, name, const char*);
|
||||
OBJECT_IMPLEMENT_GETTER(eis_client, name, const char*);
|
||||
|
||||
_public_ struct eis*
|
||||
eis_client_get_context(struct eis_client *client)
|
||||
|
|
|
|||
|
|
@ -35,11 +35,11 @@ eis_device_destroy(struct eis_device *device)
|
|||
{
|
||||
}
|
||||
|
||||
OBJECT_DECLARE_REF(eis_device);
|
||||
OBJECT_DECLARE_UNREF(eis_device);
|
||||
OBJECT_DECLARE_CREATE(eis_device);
|
||||
OBJECT_IMPLEMENT_REF(eis_device);
|
||||
OBJECT_IMPLEMENT_UNREF(eis_device);
|
||||
OBJECT_IMPLEMENT_CREATE(eis_device);
|
||||
static
|
||||
OBJECT_DECLARE_PARENT(eis_device, eis_client);
|
||||
OBJECT_IMPLEMENT_PARENT(eis_device, eis_client);
|
||||
|
||||
_public_ struct eis_client *
|
||||
eis_device_get_client(struct eis_device *device)
|
||||
|
|
|
|||
26
src/libeis.c
26
src/libeis.c
|
|
@ -56,24 +56,24 @@ eis_event_destroy(struct eis_event *event)
|
|||
}
|
||||
|
||||
static
|
||||
OBJECT_DECLARE_INIT(eis_event);
|
||||
OBJECT_IMPLEMENT_INIT(eis_event);
|
||||
|
||||
/* this one is not public */
|
||||
OBJECT_DECLARE_REF(eis_event);
|
||||
OBJECT_IMPLEMENT_REF(eis_event);
|
||||
_public_
|
||||
OBJECT_DECLARE_UNREF(eis_event);
|
||||
OBJECT_IMPLEMENT_UNREF(eis_event);
|
||||
_public_
|
||||
OBJECT_DECLARE_GETTER(eis_event, type, enum eis_event_type);
|
||||
OBJECT_IMPLEMENT_GETTER(eis_event, type, enum eis_event_type);
|
||||
_public_
|
||||
OBJECT_DECLARE_GETTER(eis_event, client, struct eis_client*);
|
||||
OBJECT_IMPLEMENT_GETTER(eis_event, client, struct eis_client*);
|
||||
_public_
|
||||
OBJECT_DECLARE_GETTER(eis_event, device, struct eis_device*);
|
||||
OBJECT_IMPLEMENT_GETTER(eis_event, device, struct eis_device*);
|
||||
|
||||
/* FIXME: these should contain error checks but for now this will do */
|
||||
_public_
|
||||
OBJECT_DECLARE_GETTER(eis_event_pointer, x, int);
|
||||
OBJECT_IMPLEMENT_GETTER(eis_event_pointer, x, int);
|
||||
_public_
|
||||
OBJECT_DECLARE_GETTER(eis_event_pointer, y, int);
|
||||
OBJECT_IMPLEMENT_GETTER(eis_event_pointer, y, int);
|
||||
|
||||
_public_ struct eis_event_pointer *
|
||||
eis_event_get_pointer_event(struct eis_event *e)
|
||||
|
|
@ -111,15 +111,15 @@ eis_destroy(struct eis *eis)
|
|||
sink_unref(eis->sink);
|
||||
}
|
||||
|
||||
OBJECT_DECLARE_INIT(eis);
|
||||
OBJECT_IMPLEMENT_INIT(eis);
|
||||
_public_
|
||||
OBJECT_DECLARE_REF(eis);
|
||||
OBJECT_IMPLEMENT_REF(eis);
|
||||
_public_
|
||||
OBJECT_DECLARE_UNREF(eis);
|
||||
OBJECT_IMPLEMENT_UNREF(eis);
|
||||
#define _cleanup_eis_ _cleanup_(eis_cleanup)
|
||||
_public_
|
||||
OBJECT_DECLARE_SETTER(eis, userdata, void *);
|
||||
OBJECT_DECLARE_GETTER(eis, userdata, void *);
|
||||
OBJECT_IMPLEMENT_SETTER(eis, userdata, void *);
|
||||
OBJECT_IMPLEMENT_GETTER(eis, userdata, void *);
|
||||
|
||||
int
|
||||
eis_init(struct eis *eis)
|
||||
|
|
|
|||
|
|
@ -84,13 +84,13 @@ logger_destroy(struct logger* logger)
|
|||
/* nothing to do */
|
||||
}
|
||||
|
||||
OBJECT_DECLARE_CREATE(logger);
|
||||
OBJECT_DECLARE_UNREF(logger);
|
||||
OBJECT_DECLARE_SETTER(logger, priority, enum logger_priority);
|
||||
OBJECT_DECLARE_GETTER(logger, priority, enum logger_priority);
|
||||
OBJECT_DECLARE_SETTER(logger, user_data, void *);
|
||||
OBJECT_DECLARE_GETTER(logger, user_data, void *);
|
||||
OBJECT_DECLARE_SETTER(logger, handler, logger_log_func_t);
|
||||
OBJECT_IMPLEMENT_CREATE(logger);
|
||||
OBJECT_IMPLEMENT_UNREF(logger);
|
||||
OBJECT_IMPLEMENT_SETTER(logger, priority, enum logger_priority);
|
||||
OBJECT_IMPLEMENT_GETTER(logger, priority, enum logger_priority);
|
||||
OBJECT_IMPLEMENT_SETTER(logger, user_data, void *);
|
||||
OBJECT_IMPLEMENT_GETTER(logger, user_data, void *);
|
||||
OBJECT_IMPLEMENT_SETTER(logger, handler, logger_log_func_t);
|
||||
|
||||
struct logger *
|
||||
logger_new(void *user_data)
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ object_unref(struct object *object)
|
|||
* For a type of "foo", generate
|
||||
* struct foo *foo_ref(struct foo *f);
|
||||
*/
|
||||
#define OBJECT_DECLARE_REF(type_) \
|
||||
#define OBJECT_IMPLEMENT_REF(type_) \
|
||||
struct type_ * type_##_ref(struct type_ *obj) { \
|
||||
object_ref(&obj->object); \
|
||||
return obj; \
|
||||
|
|
@ -111,7 +111,7 @@ struct type_ * type_##_ref(struct type_ *obj) { \
|
|||
* This macro also defines a cleanup function, use with
|
||||
* __attribute__((cleanup(foo_cleanup))
|
||||
*/
|
||||
#define OBJECT_DECLARE_UNREF(type_) \
|
||||
#define OBJECT_IMPLEMENT_UNREF(type_) \
|
||||
struct type_ * type_##_unref(struct type_ *obj) { \
|
||||
if (!obj) return NULL; \
|
||||
return object_unref(&obj->object); \
|
||||
|
|
@ -127,7 +127,7 @@ struct __useless_struct_to_allow_trailing_semicolon__
|
|||
* which sets up the *object* part of the foo struct. Use this where
|
||||
* allocation through foo_create isn't suitable.
|
||||
*/
|
||||
#define OBJECT_DECLARE_INIT(type_) \
|
||||
#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); \
|
||||
|
|
@ -138,7 +138,7 @@ void type_##_init_object(struct type_ *t, struct object *parent) { \
|
|||
* struct foo *foo_create(struct object *parent)
|
||||
* which returns an callocated and initialized foo struct.
|
||||
*/
|
||||
#define OBJECT_DECLARE_CREATE(type_) \
|
||||
#define OBJECT_IMPLEMENT_CREATE(type_) \
|
||||
static inline 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"); \
|
||||
|
|
@ -151,7 +151,7 @@ static inline struct type_ * type_##_create(struct object *parent) { \
|
|||
* For a type "foo" with parent type "bar", generate
|
||||
* struct bar* foo_parent(struct foo *foo)
|
||||
*/
|
||||
#define OBJECT_DECLARE_PARENT(type_, parent_type_) \
|
||||
#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); \
|
||||
}
|
||||
|
|
@ -160,7 +160,7 @@ struct parent_type_ * type_##_parent(struct type_ *o) { \
|
|||
* Generate a simple getter function for the given type, field and return
|
||||
* type.
|
||||
*/
|
||||
#define OBJECT_DECLARE_GETTER(type_, field_, rtype_) \
|
||||
#define OBJECT_IMPLEMENT_GETTER(type_, field_, rtype_) \
|
||||
rtype_ type_##_get_##field_(struct type_ *obj) { \
|
||||
return obj->field_; \
|
||||
}
|
||||
|
|
@ -169,7 +169,7 @@ rtype_ type_##_get_##field_(struct type_ *obj) { \
|
|||
* Generate a simple setter function for the given type, field and return
|
||||
* type.
|
||||
*/
|
||||
#define OBJECT_DECLARE_SETTER(type_, field_, rtype_) \
|
||||
#define OBJECT_IMPLEMENT_SETTER(type_, field_, rtype_) \
|
||||
void type_##_set_##field_(struct type_ *obj, rtype_ val_) { \
|
||||
obj->field_ = (val_); \
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,10 +55,10 @@ struct source {
|
|||
int fd;
|
||||
};
|
||||
|
||||
OBJECT_DECLARE_UNREF(source);
|
||||
OBJECT_DECLARE_GETTER(source, fd, int);
|
||||
OBJECT_DECLARE_GETTER(source, user_data, void*);
|
||||
OBJECT_DECLARE_SETTER(source, user_data, void*);
|
||||
OBJECT_IMPLEMENT_UNREF(source);
|
||||
OBJECT_IMPLEMENT_GETTER(source, fd, int);
|
||||
OBJECT_IMPLEMENT_GETTER(source, user_data, void*);
|
||||
OBJECT_IMPLEMENT_SETTER(source, user_data, void*);
|
||||
|
||||
/**
|
||||
* Remove the source, closing the fd. The source is tagged as removed and
|
||||
|
|
@ -87,7 +87,7 @@ source_destroy(struct source *source)
|
|||
}
|
||||
}
|
||||
|
||||
OBJECT_DECLARE_CREATE(source);
|
||||
OBJECT_IMPLEMENT_CREATE(source);
|
||||
|
||||
static inline struct source *
|
||||
source_add(struct sink *sink, int sourcefd,
|
||||
|
|
@ -139,8 +139,8 @@ sink_destroy(struct sink *sink)
|
|||
xclose(sink->epollfd);
|
||||
}
|
||||
|
||||
OBJECT_DECLARE_UNREF(sink);
|
||||
OBJECT_DECLARE_CREATE(sink);
|
||||
OBJECT_IMPLEMENT_UNREF(sink);
|
||||
OBJECT_IMPLEMENT_CREATE(sink);
|
||||
|
||||
int
|
||||
sink_get_fd(struct sink *sink)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue