small-server-core.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. /* SCANNER TEST */
  2. #ifndef SMALL_TEST_SERVER_PROTOCOL_H
  3. #define SMALL_TEST_SERVER_PROTOCOL_H
  4. #include <stdint.h>
  5. #include <stddef.h>
  6. #include "wayland-server-core.h"
  7. #ifdef __cplusplus
  8. extern "C" {
  9. #endif
  10. struct wl_client;
  11. struct wl_resource;
  12. /**
  13. * @page page_small_test The small_test protocol
  14. * @section page_ifaces_small_test Interfaces
  15. * - @subpage page_iface_intf_A - the thing A
  16. * @section page_copyright_small_test Copyright
  17. * <pre>
  18. *
  19. * Copyright © 2016 Collabora, Ltd.
  20. *
  21. * Permission is hereby granted, free of charge, to any person
  22. * obtaining a copy of this software and associated documentation files
  23. * (the "Software"), to deal in the Software without restriction,
  24. * including without limitation the rights to use, copy, modify, merge,
  25. * publish, distribute, sublicense, and/or sell copies of the Software,
  26. * and to permit persons to whom the Software is furnished to do so,
  27. * subject to the following conditions:
  28. *
  29. * The above copyright notice and this permission notice (including the
  30. * next paragraph) shall be included in all copies or substantial
  31. * portions of the Software.
  32. *
  33. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  34. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  35. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  36. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  37. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  38. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  39. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  40. * SOFTWARE.
  41. * </pre>
  42. */
  43. struct another_intf;
  44. struct intf_A;
  45. struct intf_not_here;
  46. #ifndef INTF_A_INTERFACE
  47. #define INTF_A_INTERFACE
  48. /**
  49. * @page page_iface_intf_A intf_A
  50. * @section page_iface_intf_A_desc Description
  51. *
  52. * A useless example trying to tickle the scanner.
  53. * @section page_iface_intf_A_api API
  54. * See @ref iface_intf_A.
  55. */
  56. /**
  57. * @defgroup iface_intf_A The intf_A interface
  58. *
  59. * A useless example trying to tickle the scanner.
  60. */
  61. extern const struct wl_interface intf_A_interface;
  62. #endif
  63. #ifndef INTF_A_FOO_ENUM
  64. #define INTF_A_FOO_ENUM
  65. enum intf_A_foo {
  66. /**
  67. * this is the first
  68. */
  69. INTF_A_FOO_FIRST = 0,
  70. /**
  71. * this is the second
  72. */
  73. INTF_A_FOO_SECOND = 1,
  74. /**
  75. * this is the third
  76. * @since 2
  77. */
  78. INTF_A_FOO_THIRD = 2,
  79. /**
  80. * this is a negative value
  81. * @since 2
  82. */
  83. INTF_A_FOO_NEGATIVE = -1,
  84. /**
  85. * this is a deprecated value
  86. * @since 2
  87. * @deprecated Deprecated since version 3
  88. */
  89. INTF_A_FOO_DEPRECATED = 3,
  90. };
  91. /**
  92. * @ingroup iface_intf_A
  93. */
  94. #define INTF_A_FOO_THIRD_SINCE_VERSION 2
  95. /**
  96. * @ingroup iface_intf_A
  97. */
  98. #define INTF_A_FOO_NEGATIVE_SINCE_VERSION 2
  99. /**
  100. * @ingroup iface_intf_A
  101. */
  102. #define INTF_A_FOO_DEPRECATED_SINCE_VERSION 2
  103. #endif /* INTF_A_FOO_ENUM */
  104. #ifndef INTF_A_FOO_ENUM_IS_VALID
  105. #define INTF_A_FOO_ENUM_IS_VALID
  106. /**
  107. * @ingroup iface_intf_A
  108. * Validate a intf_A foo value.
  109. *
  110. * @return true on success, false on error.
  111. * @ref intf_A_foo
  112. */
  113. static inline bool
  114. intf_A_foo_is_valid(uint32_t value, uint32_t version) {
  115. switch (value) {
  116. case INTF_A_FOO_FIRST:
  117. return version >= 1;
  118. case INTF_A_FOO_SECOND:
  119. return version >= 1;
  120. case INTF_A_FOO_THIRD:
  121. return version >= 2;
  122. case (uint32_t)INTF_A_FOO_NEGATIVE:
  123. return version >= 2;
  124. case INTF_A_FOO_DEPRECATED:
  125. return version >= 2;
  126. default:
  127. return false;
  128. }
  129. }
  130. #endif /* INTF_A_FOO_ENUM_IS_VALID */
  131. #ifndef INTF_A_BAR_ENUM
  132. #define INTF_A_BAR_ENUM
  133. enum intf_A_bar {
  134. /**
  135. * this is the first
  136. */
  137. INTF_A_BAR_FIRST = 0x01,
  138. /**
  139. * this is the second
  140. */
  141. INTF_A_BAR_SECOND = 0x02,
  142. /**
  143. * this is the third
  144. * @since 2
  145. */
  146. INTF_A_BAR_THIRD = 0x04,
  147. };
  148. /**
  149. * @ingroup iface_intf_A
  150. */
  151. #define INTF_A_BAR_THIRD_SINCE_VERSION 2
  152. #endif /* INTF_A_BAR_ENUM */
  153. #ifndef INTF_A_BAR_ENUM_IS_VALID
  154. #define INTF_A_BAR_ENUM_IS_VALID
  155. /**
  156. * @ingroup iface_intf_A
  157. * Validate a intf_A bar value.
  158. *
  159. * @return true on success, false on error.
  160. * @ref intf_A_bar
  161. */
  162. static inline bool
  163. intf_A_bar_is_valid(uint32_t value, uint32_t version) {
  164. uint32_t valid = 0;
  165. if (version >= 1)
  166. valid |= INTF_A_BAR_FIRST;
  167. if (version >= 1)
  168. valid |= INTF_A_BAR_SECOND;
  169. if (version >= 2)
  170. valid |= INTF_A_BAR_THIRD;
  171. return (value & ~valid) == 0;
  172. }
  173. #endif /* INTF_A_BAR_ENUM_IS_VALID */
  174. /**
  175. * @ingroup iface_intf_A
  176. * @struct intf_A_interface
  177. */
  178. struct intf_A_interface {
  179. /**
  180. * @param interface name of the objects interface
  181. * @param version version of the objects interface
  182. */
  183. void (*rq1)(struct wl_client *client,
  184. struct wl_resource *resource,
  185. const char *interface, uint32_t version, uint32_t untyped_new);
  186. /**
  187. */
  188. void (*rq2)(struct wl_client *client,
  189. struct wl_resource *resource,
  190. uint32_t typed_new,
  191. const char *str,
  192. int32_t i,
  193. uint32_t u,
  194. wl_fixed_t f,
  195. int32_t fd,
  196. struct wl_resource *obj);
  197. /**
  198. */
  199. void (*destroy)(struct wl_client *client,
  200. struct wl_resource *resource);
  201. };
  202. #define INTF_A_HEY 0
  203. #define INTF_A_YO 1
  204. /**
  205. * @ingroup iface_intf_A
  206. */
  207. #define INTF_A_HEY_SINCE_VERSION 1
  208. /**
  209. * @ingroup iface_intf_A
  210. */
  211. #define INTF_A_YO_SINCE_VERSION 2
  212. /**
  213. * @ingroup iface_intf_A
  214. */
  215. #define INTF_A_RQ1_SINCE_VERSION 1
  216. /**
  217. * @ingroup iface_intf_A
  218. */
  219. #define INTF_A_RQ2_SINCE_VERSION 1
  220. /**
  221. * @ingroup iface_intf_A
  222. */
  223. #define INTF_A_DESTROY_SINCE_VERSION 1
  224. /**
  225. * @ingroup iface_intf_A
  226. * Sends an hey event to the client owning the resource.
  227. * @param resource_ The client's resource
  228. */
  229. static inline void
  230. intf_A_send_hey(struct wl_resource *resource_)
  231. {
  232. wl_resource_post_event(resource_, INTF_A_HEY);
  233. }
  234. /**
  235. * @ingroup iface_intf_A
  236. * Sends an yo event to the client owning the resource.
  237. * @param resource_ The client's resource
  238. */
  239. static inline void
  240. intf_A_send_yo(struct wl_resource *resource_)
  241. {
  242. wl_resource_post_event(resource_, INTF_A_YO);
  243. }
  244. #ifdef __cplusplus
  245. }
  246. #endif
  247. #endif