]>
Commit | Line | Data |
---|---|---|
29ddb38f LP |
1 | #ifndef foosdbusvtablehfoo |
2 | #define foosdbusvtablehfoo | |
3 | ||
4 | /*** | |
5 | This file is part of systemd. | |
6 | ||
7 | Copyright 2013 Lennart Poettering | |
8 | ||
9 | systemd is free software; you can redistribute it and/or modify it | |
10 | under the terms of the GNU Lesser General Public License as published by | |
11 | the Free Software Foundation; either version 2.1 of the License, or | |
12 | (at your option) any later version. | |
13 | ||
14 | systemd is distributed in the hope that it will be useful, but | |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
17 | Lesser General Public License for more details. | |
18 | ||
19 | You should have received a copy of the GNU Lesser General Public License | |
20 | along with systemd; If not, see <http://www.gnu.org/licenses/>. | |
21 | ***/ | |
22 | ||
0095c454 LP |
23 | #include "_sd-common.h" |
24 | ||
25 | _SD_BEGIN_DECLARATIONS; | |
6695ed7a | 26 | |
29ddb38f LP |
27 | typedef struct sd_bus_vtable sd_bus_vtable; |
28 | ||
29 | #include "sd-bus.h" | |
30 | ||
31 | enum { | |
adacb957 LP |
32 | _SD_BUS_VTABLE_START = '<', |
33 | _SD_BUS_VTABLE_END = '>', | |
34 | _SD_BUS_VTABLE_METHOD = 'M', | |
35 | _SD_BUS_VTABLE_SIGNAL = 'S', | |
36 | _SD_BUS_VTABLE_PROPERTY = 'P', | |
e0c0b07d | 37 | _SD_BUS_VTABLE_WRITABLE_PROPERTY = 'W' |
29ddb38f LP |
38 | }; |
39 | ||
40 | enum { | |
df98a87b LP |
41 | SD_BUS_VTABLE_DEPRECATED = 1ULL << 0, |
42 | SD_BUS_VTABLE_HIDDEN = 1ULL << 1, | |
43 | SD_BUS_VTABLE_UNPRIVILEGED = 1ULL << 2, | |
44 | SD_BUS_VTABLE_METHOD_NO_REPLY = 1ULL << 3, | |
45 | SD_BUS_VTABLE_PROPERTY_CONST = 1ULL << 4, | |
46 | SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE = 1ULL << 5, | |
47 | SD_BUS_VTABLE_PROPERTY_EMITS_INVALIDATION = 1ULL << 6, | |
33702051 | 48 | SD_BUS_VTABLE_PROPERTY_EXPLICIT = 1ULL << 7, |
df98a87b | 49 | _SD_BUS_VTABLE_CAPABILITY_MASK = 0xFFFFULL << 40 |
29ddb38f LP |
50 | }; |
51 | ||
adacb957 LP |
52 | #define SD_BUS_VTABLE_CAPABILITY(x) ((uint64_t) (((x)+1) & 0xFFFF) << 40) |
53 | ||
29ddb38f LP |
54 | struct sd_bus_vtable { |
55 | /* Please do not initialize this structure directly, use the | |
56 | * macros below instead */ | |
57 | ||
adacb957 LP |
58 | uint8_t type:8; |
59 | uint64_t flags:56; | |
29ddb38f LP |
60 | union { |
61 | struct { | |
62 | size_t element_size; | |
63 | } start; | |
64 | struct { | |
65 | const char *member; | |
66 | const char *signature; | |
67 | const char *result; | |
68 | sd_bus_message_handler_t handler; | |
09c8a7c6 | 69 | size_t offset; |
29ddb38f LP |
70 | } method; |
71 | struct { | |
72 | const char *member; | |
73 | const char *signature; | |
74 | } signal; | |
75 | struct { | |
76 | const char *member; | |
77 | const char *signature; | |
78 | sd_bus_property_get_t get; | |
79 | sd_bus_property_set_t set; | |
80 | size_t offset; | |
81 | } property; | |
77a874a3 | 82 | } x; |
29ddb38f LP |
83 | }; |
84 | ||
85 | #define SD_BUS_VTABLE_START(_flags) \ | |
86 | { \ | |
87 | .type = _SD_BUS_VTABLE_START, \ | |
88 | .flags = _flags, \ | |
aa328850 KK |
89 | .x = { \ |
90 | .start = { \ | |
91 | .element_size = sizeof(sd_bus_vtable) \ | |
92 | }, \ | |
93 | }, \ | |
29ddb38f LP |
94 | } |
95 | ||
29ddae7b | 96 | #define SD_BUS_METHOD_WITH_OFFSET(_member, _signature, _result, _handler, _offset, _flags) \ |
29ddb38f LP |
97 | { \ |
98 | .type = _SD_BUS_VTABLE_METHOD, \ | |
99 | .flags = _flags, \ | |
aa328850 KK |
100 | .x = { \ |
101 | .method = { \ | |
102 | .member = _member, \ | |
103 | .signature = _signature, \ | |
104 | .result = _result, \ | |
105 | .handler = _handler, \ | |
106 | .offset = _offset, \ | |
107 | }, \ | |
108 | }, \ | |
29ddb38f | 109 | } |
09c8a7c6 | 110 | #define SD_BUS_METHOD(_member, _signature, _result, _handler, _flags) \ |
29ddae7b | 111 | SD_BUS_METHOD_WITH_OFFSET(_member, _signature, _result, _handler, 0, _flags) |
29ddb38f LP |
112 | |
113 | #define SD_BUS_SIGNAL(_member, _signature, _flags) \ | |
114 | { \ | |
115 | .type = _SD_BUS_VTABLE_SIGNAL, \ | |
116 | .flags = _flags, \ | |
aa328850 KK |
117 | .x = { \ |
118 | .signal = { \ | |
119 | .member = _member, \ | |
120 | .signature = _signature, \ | |
121 | }, \ | |
122 | }, \ | |
29ddb38f LP |
123 | } |
124 | ||
77a874a3 | 125 | #define SD_BUS_PROPERTY(_member, _signature, _get, _offset, _flags) \ |
29ddb38f LP |
126 | { \ |
127 | .type = _SD_BUS_VTABLE_PROPERTY, \ | |
128 | .flags = _flags, \ | |
aa328850 KK |
129 | .x = { \ |
130 | .property = { \ | |
131 | .member = _member, \ | |
132 | .signature = _signature, \ | |
133 | .get = _get, \ | |
134 | .offset = _offset, \ | |
135 | }, \ | |
136 | }, \ | |
29ddb38f LP |
137 | } |
138 | ||
139 | #define SD_BUS_WRITABLE_PROPERTY(_member, _signature, _get, _set, _offset, _flags) \ | |
140 | { \ | |
141 | .type = _SD_BUS_VTABLE_WRITABLE_PROPERTY, \ | |
142 | .flags = _flags, \ | |
aa328850 KK |
143 | .x = { \ |
144 | .property = { \ | |
145 | .member = _member, \ | |
146 | .signature = _signature, \ | |
147 | .get = _get, \ | |
148 | .set = _set, \ | |
149 | .offset = _offset, \ | |
150 | }, \ | |
151 | }, \ | |
29ddb38f LP |
152 | } |
153 | ||
154 | #define SD_BUS_VTABLE_END \ | |
155 | { \ | |
156 | .type = _SD_BUS_VTABLE_END, \ | |
157 | } | |
158 | ||
0095c454 | 159 | _SD_END_DECLARATIONS; |
6695ed7a | 160 | |
29ddb38f | 161 | #endif |