-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommon.h
55 lines (49 loc) · 2.22 KB
/
common.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#ifndef COMMON_H
#define COMMON_H
#include <stdint.h>
uint32_t nextSerial();
template<auto Func>
class Deleter
{
public:
template<typename T>
void operator()(T *ptr) const
{
if (ptr) {
Func(ptr);
}
}
};
#define INIT_FUNCS_DEF \
void init(struct ::wl_client *client, uint32_t id); \
void init(struct ::wl_display *display); \
void init(struct ::wl_resource *resource); \
\
void add(struct ::wl_client *client); \
void add(struct ::wl_client *client, uint32_t id);
#define INIT_FUNCS(CLASSNAME) \
void CLASSNAME::init(struct ::wl_client *client, uint32_t id) \
{ \
d->init(client, id, CLASSNAME##Private::interfaceVersion()); \
} \
\
void CLASSNAME::init(struct ::wl_display *display) \
{ \
d->init(display, CLASSNAME##Private::interfaceVersion()); \
} \
\
void CLASSNAME::init(struct ::wl_resource *resource) \
{ \
d->init(resource); \
} \
\
void CLASSNAME::add(struct ::wl_client *client) \
{ \
d->add(client, CLASSNAME##Private::interfaceVersion()); \
} \
\
void CLASSNAME::add(struct ::wl_client *client, uint32_t id) \
{ \
d->add(client, id, CLASSNAME##Private::interfaceVersion()); \
}
#endif // !COMMON_H