commit 673246c

Michael Forney  ·  2013-10-24 07:13:34 +0000 UTC
parent 3d46395
Rename swc_container_of -> CONTAINER_OF

It is a macro so follow the convention of all caps.
11 files changed,  +49, -48
+9, -10
 1@@ -151,8 +151,8 @@ static bool handle_key(struct swc_keyboard * keyboard, uint32_t time,
 2     struct swc_compositor * compositor;
 3     char keysym_name[64];
 4 
 5-    seat = swc_container_of(keyboard, typeof(*seat), keyboard);
 6-    compositor = swc_container_of(seat, typeof(*compositor), seat);
 7+    seat = CONTAINER_OF(keyboard, typeof(*seat), keyboard);
 8+    compositor = CONTAINER_OF(seat, typeof(*compositor), seat);
 9 
10     if (state == WL_KEYBOARD_KEY_STATE_PRESSED)
11     {
12@@ -205,8 +205,8 @@ static void handle_focus(struct swc_pointer * pointer)
13     struct swc_surface * surface;
14     int32_t x, y;
15 
16-    seat = swc_container_of(pointer, typeof(*seat), pointer);
17-    compositor = swc_container_of(seat, typeof(*compositor), seat);
18+    seat = CONTAINER_OF(pointer, typeof(*seat), pointer);
19+    compositor = CONTAINER_OF(seat, typeof(*compositor), seat);
20 
21     wl_list_for_each(surface, &compositor->surfaces, link)
22     {
23@@ -237,8 +237,8 @@ static bool handle_motion(struct swc_pointer * pointer, uint32_t time)
24     struct swc_seat * seat;
25     struct swc_compositor * compositor;
26 
27-    seat = swc_container_of(pointer, typeof(*seat), pointer);
28-    compositor = swc_container_of(seat, typeof(*compositor), seat);
29+    seat = CONTAINER_OF(pointer, typeof(*seat), pointer);
30+    compositor = CONTAINER_OF(seat, typeof(*compositor), seat);
31 
32     return false;
33 }
34@@ -253,7 +253,7 @@ static void handle_drm_event(struct wl_listener * listener, void * data)
35     struct swc_event * event = data;
36     struct swc_compositor * compositor;
37 
38-    compositor = swc_container_of(listener, typeof(*compositor), drm_listener);
39+    compositor = CONTAINER_OF(listener, typeof(*compositor), drm_listener);
40 
41     switch (event->type)
42     {
43@@ -286,8 +286,7 @@ static void handle_pointer_event(struct wl_listener * listener, void * data)
44     struct swc_pointer_event_data * event_data = event->data;
45     struct swc_compositor * compositor;
46 
47-    compositor = swc_container_of(listener, typeof(*compositor),
48-                                  pointer_listener);
49+    compositor = CONTAINER_OF(listener, typeof(*compositor), pointer_listener);
50 
51     switch (event->type)
52     {
53@@ -324,7 +323,7 @@ static void create_surface(struct wl_client * client,
54 
55     printf("compositor.create_surface\n");
56 
57-    output = swc_container_of(compositor->outputs.next, typeof(*output), link);
58+    output = CONTAINER_OF(compositor->outputs.next, typeof(*output), link);
59 
60     /* Initialize surface. */
61     surface = swc_surface_new(client, wl_resource_get_version(resource), id);
+10, -10
 1@@ -48,7 +48,7 @@ const struct swc_surface_class_interface swc_compositor_class_implementation = {
 2  */
 3 static void damage_below_surface(struct swc_surface * surface)
 4 {
 5-    struct swc_compositor * compositor = swc_container_of
 6+    struct swc_compositor * compositor = CONTAINER_OF
 7         (surface->class, typeof(*compositor), compositor_class);
 8     struct swc_compositor_surface_state * state = surface->class_state;
 9     pixman_region32_t damage_below;
10@@ -92,7 +92,7 @@ static void update_extents(struct swc_surface * surface)
11 
12 static void update_outputs(struct swc_surface * surface)
13 {
14-    struct swc_compositor * compositor = swc_container_of
15+    struct swc_compositor * compositor = CONTAINER_OF
16         (surface->class, typeof(*compositor), compositor_class);
17     struct swc_compositor_surface_state * state = surface->class_state;
18     uint32_t old_outputs = surface->outputs, new_outputs = 0,
19@@ -140,7 +140,7 @@ static void update_outputs(struct swc_surface * surface)
20 static void handle_surface_event(struct wl_listener * listener, void * data)
21 {
22     struct swc_compositor_surface_state * state
23-        = swc_container_of(listener, typeof(*state), event_listener);
24+        = CONTAINER_OF(listener, typeof(*state), event_listener);
25     struct swc_event * event = data;
26     struct swc_surface_event_data * event_data = event->data;
27     struct swc_surface * surface = event_data->surface;
28@@ -161,7 +161,7 @@ static void handle_surface_event(struct wl_listener * listener, void * data)
29 /* Compositor class */
30 bool add(struct swc_surface * surface)
31 {
32-    struct swc_compositor * compositor = swc_container_of
33+    struct swc_compositor * compositor = CONTAINER_OF
34         (surface->class, typeof(*compositor), compositor_class);
35     struct swc_compositor_surface_state * state;
36 
37@@ -192,7 +192,7 @@ bool add(struct swc_surface * surface)
38 
39 void remove_(struct swc_surface * surface)
40 {
41-    struct swc_compositor * compositor = swc_container_of
42+    struct swc_compositor * compositor = CONTAINER_OF
43         (surface->class, typeof(*compositor), compositor_class);
44     struct swc_compositor_surface_state * state = surface->class_state;
45 
46@@ -206,7 +206,7 @@ void remove_(struct swc_surface * surface)
47 
48 void attach(struct swc_surface * surface, struct wl_resource * resource)
49 {
50-    struct swc_compositor * compositor = swc_container_of
51+    struct swc_compositor * compositor = CONTAINER_OF
52         (surface->class, typeof(*compositor), compositor_class);
53 
54     swc_renderer_attach(&compositor->renderer, surface, resource);
55@@ -214,7 +214,7 @@ void attach(struct swc_surface * surface, struct wl_resource * resource)
56 
57 void update(struct swc_surface * surface)
58 {
59-    struct swc_compositor * compositor = swc_container_of
60+    struct swc_compositor * compositor = CONTAINER_OF
61         (surface->class, typeof(*compositor), compositor_class);
62     struct swc_compositor_surface_state * state = surface->class_state;
63     struct swc_output * output;
64@@ -231,7 +231,7 @@ void update(struct swc_surface * surface)
65 
66 void move(struct swc_surface * surface, int32_t x, int32_t y)
67 {
68-    struct swc_compositor * compositor = swc_container_of
69+    struct swc_compositor * compositor = CONTAINER_OF
70         (surface->class, typeof(*compositor), compositor_class);
71     struct swc_compositor_surface_state * state = surface->class_state;
72 
73@@ -261,7 +261,7 @@ void move(struct swc_surface * surface, int32_t x, int32_t y)
74 
75 void swc_compositor_surface_show(struct swc_surface * surface)
76 {
77-    struct swc_compositor * compositor = swc_container_of
78+    struct swc_compositor * compositor = CONTAINER_OF
79         (surface->class, typeof(*compositor), compositor_class);
80     struct swc_compositor_surface_state * state = surface->class_state;
81 
82@@ -287,7 +287,7 @@ void swc_compositor_surface_show(struct swc_surface * surface)
83 
84 void swc_compositor_surface_hide(struct swc_surface * surface)
85 {
86-    struct swc_compositor * compositor = swc_container_of
87+    struct swc_compositor * compositor = CONTAINER_OF
88         (surface->class, typeof(*compositor), compositor_class);
89     struct swc_compositor_surface_state * state = surface->class_state;
90 
+2, -2
 1@@ -41,7 +41,7 @@ static void update_plane(struct swc_plane * plane, void * data)
 2 static void attach(struct swc_surface * surface,
 3                    struct wl_resource * resource)
 4 {
 5-    struct swc_compositor * compositor = swc_container_of
 6+    struct swc_compositor * compositor = CONTAINER_OF
 7         (surface->class, typeof(*compositor), cursor_class);
 8 
 9     if (pixman_region32_not_empty(&surface->state.damage))
10@@ -86,7 +86,7 @@ static void update(struct swc_surface * surface)
11 
12 static void move(struct swc_surface * surface, int32_t x, int32_t y)
13 {
14-    struct swc_compositor * compositor = swc_container_of
15+    struct swc_compositor * compositor = CONTAINER_OF
16         (surface->class, typeof(*compositor), cursor_class);
17     struct swc_output * output;
18 
+1, -1
1@@ -68,7 +68,7 @@ struct wl_data_device_interface data_device_implementation = {
2 
3 static void handle_selection_destroy(struct wl_listener * listener, void * data)
4 {
5-    struct swc_data_device * data_device = swc_container_of
6+    struct swc_data_device * data_device = CONTAINER_OF
7         (listener, typeof(*data_device), selection_destroy_listener);
8 
9     data_device->selection = NULL;
+1, -1
1@@ -58,7 +58,7 @@ static inline void unfocus(struct swc_input_focus * input_focus)
2 static void handle_focus_surface_destroy(struct wl_listener * listener,
3                                          void * data)
4 {
5-    struct swc_input_focus * input_focus = swc_container_of
6+    struct swc_input_focus * input_focus = CONTAINER_OF
7         (listener, typeof(*input_focus), surface_destroy_listener);
8 
9     input_focus->surface = NULL;
+1, -1
1@@ -12,7 +12,7 @@ static void enter(struct swc_input_focus_handler * handler,
2     struct wl_display * display;
3     uint32_t serial;
4 
5-    keyboard = swc_container_of(handler, typeof(*keyboard), focus_handler);
6+    keyboard = CONTAINER_OF(handler, typeof(*keyboard), focus_handler);
7     client = wl_resource_get_client(resource);
8     display = wl_client_get_display(client);
9     serial = wl_display_next_serial(display);
+3, -3
 1@@ -14,7 +14,7 @@ static void enter(struct swc_input_focus_handler * handler,
 2     uint32_t serial;
 3     wl_fixed_t surface_x, surface_y;
 4 
 5-    pointer = swc_container_of(handler, typeof(*pointer), focus_handler);
 6+    pointer = CONTAINER_OF(handler, typeof(*pointer), focus_handler);
 7     client = wl_resource_get_client(resource);
 8     display = wl_client_get_display(client);
 9     serial = wl_display_next_serial(display);
10@@ -45,8 +45,8 @@ static void leave(struct swc_input_focus_handler * handler,
11 static void handle_cursor_surface_destroy(struct wl_listener * listener,
12                                           void * data)
13 {
14-    struct swc_pointer * pointer = swc_container_of(listener, typeof(*pointer),
15-                                                    cursor.destroy_listener);
16+    struct swc_pointer * pointer = CONTAINER_OF(listener, typeof(*pointer),
17+                                                cursor.destroy_listener);
18 
19     pointer->cursor.surface = NULL;
20 }
+3, -3
 1@@ -45,7 +45,7 @@ static inline uint32_t wld_format(uint32_t format)
 2 static void handle_buffer_destroy(struct wl_listener * listener, void * data)
 3 {
 4     struct buffer_state * state
 5-        = swc_container_of(listener, typeof(*state), destroy_listener);
 6+        = CONTAINER_OF(listener, typeof(*state), destroy_listener);
 7 
 8     wld_destroy_drawable(state->drawable);
 9     if (state->dst)
10@@ -60,8 +60,8 @@ static inline struct buffer_state * buffer_state(struct wl_resource * resource)
11     struct wl_listener * listener
12         = wl_resource_get_destroy_listener(resource, &handle_buffer_destroy);
13 
14-    return listener ? swc_container_of(listener, struct buffer_state,
15-                                       destroy_listener)
16+    return listener ? CONTAINER_OF(listener, struct buffer_state,
17+                                   destroy_listener)
18                     : NULL;
19 }
20 
+12, -12
 1@@ -13,8 +13,8 @@
 2 static void handle_key(const struct swc_evdev_device_handler * handler,
 3                        uint32_t time, uint32_t key, uint32_t state)
 4 {
 5-    struct swc_seat * seat = swc_container_of(handler, typeof(*seat),
 6-                                              evdev_handler);
 7+    struct swc_seat * seat = CONTAINER_OF(handler, typeof(*seat),
 8+                                          evdev_handler);
 9 
10     swc_keyboard_handle_key(&seat->keyboard, time, key, state);
11 }
12@@ -22,8 +22,8 @@ static void handle_key(const struct swc_evdev_device_handler * handler,
13 static void handle_button(const struct swc_evdev_device_handler * handler,
14                           uint32_t time, uint32_t button, uint32_t state)
15 {
16-    struct swc_seat * seat = swc_container_of(handler, typeof(*seat),
17-                                              evdev_handler);
18+    struct swc_seat * seat = CONTAINER_OF(handler, typeof(*seat),
19+                                          evdev_handler);
20 
21     swc_pointer_handle_button(&seat->pointer, time, button, state);
22 }
23@@ -31,8 +31,8 @@ static void handle_button(const struct swc_evdev_device_handler * handler,
24 static void handle_axis(const struct swc_evdev_device_handler * handler,
25                         uint32_t time, uint32_t axis, wl_fixed_t amount)
26 {
27-    struct swc_seat * seat = swc_container_of(handler, typeof(*seat),
28-                                              evdev_handler);
29+    struct swc_seat * seat = CONTAINER_OF(handler, typeof(*seat),
30+                                          evdev_handler);
31 
32     swc_pointer_handle_axis(&seat->pointer, time, axis, amount);
33 }
34@@ -41,8 +41,8 @@ static void handle_relative_motion
35     (const struct swc_evdev_device_handler * handler,
36      uint32_t time, wl_fixed_t dx, wl_fixed_t dy)
37 {
38-    struct swc_seat * seat = swc_container_of(handler, typeof(*seat),
39-                                              evdev_handler);
40+    struct swc_seat * seat = CONTAINER_OF(handler, typeof(*seat),
41+                                          evdev_handler);
42 
43     swc_pointer_handle_relative_motion(&seat->pointer, time, dx, dy);
44 }
45@@ -50,8 +50,8 @@ static void handle_relative_motion
46 static void handle_keyboard_focus_event(struct wl_listener * listener,
47                                         void * data)
48 {
49-    struct swc_seat * seat = swc_container_of
50-        (listener, typeof(*seat), keyboard_focus_listener);
51+    struct swc_seat * seat = CONTAINER_OF(listener, typeof(*seat),
52+                                          keyboard_focus_listener);
53     struct swc_event * event = data;
54     struct swc_input_focus_event_data * event_data = event->data;
55 
56@@ -72,8 +72,8 @@ static void handle_keyboard_focus_event(struct wl_listener * listener,
57 
58 static void handle_data_device_event(struct wl_listener * listener, void * data)
59 {
60-    struct swc_seat * seat = swc_container_of
61-        (listener, typeof(*seat), data_device_listener);
62+    struct swc_seat * seat = CONTAINER_OF(listener, typeof(*seat),
63+                                          data_device_listener);
64     struct swc_event * event = data;
65 
66     switch (event->type)
+1, -1
1@@ -43,7 +43,7 @@ static void handle_buffer_destroy(struct wl_listener * listener, void * data)
2 {
3     struct swc_surface_state * state;
4 
5-    state = swc_container_of(listener, typeof(*state), buffer_destroy_listener);
6+    state = CONTAINER_OF(listener, typeof(*state), buffer_destroy_listener);
7     state->buffer = NULL;
8 }
9 
+6, -4
 1@@ -6,13 +6,15 @@
 2 #include <sys/param.h>
 3 #include <pixman.h>
 4 
 5-#ifndef offsetof
 6-#   define offsetof __builtin_offsetof
 7+#ifdef offsetof
 8+# define OFFSET_OF offsetof
 9+#else
10+# define OFFSET_OF __builtin_offsetof
11 #endif
12 
13-#define swc_container_of(ptr, type, member) ({                              \
14+#define CONTAINER_OF(ptr, type, member) ({                                  \
15     const typeof(((type *) 0)->member) *__mptr = (ptr);                     \
16-    ((type *) ((uintptr_t) __mptr - offsetof(type, member)));               \
17+    ((type *) ((uintptr_t) __mptr - OFFSET_OF(type, member)));              \
18 })
19 
20 struct wl_resource;