commit 673246c909bfd92e09f85cbe47a0d3ef4f77cc17
parent 3d4639592558f2fba0079e051155535e94536ae9
Author: Michael Forney <mforney@mforney.org>
Date: Thu, 24 Oct 2013 00:13:34 -0700
Rename swc_container_of -> CONTAINER_OF
It is a macro so follow the convention of all caps.
Diffstat:
11 files changed, 49 insertions(+), 48 deletions(-)
diff --git a/libswc/compositor.c b/libswc/compositor.c
@@ -151,8 +151,8 @@ static bool handle_key(struct swc_keyboard * keyboard, uint32_t time,
struct swc_compositor * compositor;
char keysym_name[64];
- seat = swc_container_of(keyboard, typeof(*seat), keyboard);
- compositor = swc_container_of(seat, typeof(*compositor), seat);
+ seat = CONTAINER_OF(keyboard, typeof(*seat), keyboard);
+ compositor = CONTAINER_OF(seat, typeof(*compositor), seat);
if (state == WL_KEYBOARD_KEY_STATE_PRESSED)
{
@@ -205,8 +205,8 @@ static void handle_focus(struct swc_pointer * pointer)
struct swc_surface * surface;
int32_t x, y;
- seat = swc_container_of(pointer, typeof(*seat), pointer);
- compositor = swc_container_of(seat, typeof(*compositor), seat);
+ seat = CONTAINER_OF(pointer, typeof(*seat), pointer);
+ compositor = CONTAINER_OF(seat, typeof(*compositor), seat);
wl_list_for_each(surface, &compositor->surfaces, link)
{
@@ -237,8 +237,8 @@ static bool handle_motion(struct swc_pointer * pointer, uint32_t time)
struct swc_seat * seat;
struct swc_compositor * compositor;
- seat = swc_container_of(pointer, typeof(*seat), pointer);
- compositor = swc_container_of(seat, typeof(*compositor), seat);
+ seat = CONTAINER_OF(pointer, typeof(*seat), pointer);
+ compositor = CONTAINER_OF(seat, typeof(*compositor), seat);
return false;
}
@@ -253,7 +253,7 @@ static void handle_drm_event(struct wl_listener * listener, void * data)
struct swc_event * event = data;
struct swc_compositor * compositor;
- compositor = swc_container_of(listener, typeof(*compositor), drm_listener);
+ compositor = CONTAINER_OF(listener, typeof(*compositor), drm_listener);
switch (event->type)
{
@@ -286,8 +286,7 @@ static void handle_pointer_event(struct wl_listener * listener, void * data)
struct swc_pointer_event_data * event_data = event->data;
struct swc_compositor * compositor;
- compositor = swc_container_of(listener, typeof(*compositor),
- pointer_listener);
+ compositor = CONTAINER_OF(listener, typeof(*compositor), pointer_listener);
switch (event->type)
{
@@ -324,7 +323,7 @@ static void create_surface(struct wl_client * client,
printf("compositor.create_surface\n");
- output = swc_container_of(compositor->outputs.next, typeof(*output), link);
+ output = CONTAINER_OF(compositor->outputs.next, typeof(*output), link);
/* Initialize surface. */
surface = swc_surface_new(client, wl_resource_get_version(resource), id);
diff --git a/libswc/compositor_surface.c b/libswc/compositor_surface.c
@@ -48,7 +48,7 @@ const struct swc_surface_class_interface swc_compositor_class_implementation = {
*/
static void damage_below_surface(struct swc_surface * surface)
{
- struct swc_compositor * compositor = swc_container_of
+ struct swc_compositor * compositor = CONTAINER_OF
(surface->class, typeof(*compositor), compositor_class);
struct swc_compositor_surface_state * state = surface->class_state;
pixman_region32_t damage_below;
@@ -92,7 +92,7 @@ static void update_extents(struct swc_surface * surface)
static void update_outputs(struct swc_surface * surface)
{
- struct swc_compositor * compositor = swc_container_of
+ struct swc_compositor * compositor = CONTAINER_OF
(surface->class, typeof(*compositor), compositor_class);
struct swc_compositor_surface_state * state = surface->class_state;
uint32_t old_outputs = surface->outputs, new_outputs = 0,
@@ -140,7 +140,7 @@ static void update_outputs(struct swc_surface * surface)
static void handle_surface_event(struct wl_listener * listener, void * data)
{
struct swc_compositor_surface_state * state
- = swc_container_of(listener, typeof(*state), event_listener);
+ = CONTAINER_OF(listener, typeof(*state), event_listener);
struct swc_event * event = data;
struct swc_surface_event_data * event_data = event->data;
struct swc_surface * surface = event_data->surface;
@@ -161,7 +161,7 @@ static void handle_surface_event(struct wl_listener * listener, void * data)
/* Compositor class */
bool add(struct swc_surface * surface)
{
- struct swc_compositor * compositor = swc_container_of
+ struct swc_compositor * compositor = CONTAINER_OF
(surface->class, typeof(*compositor), compositor_class);
struct swc_compositor_surface_state * state;
@@ -192,7 +192,7 @@ bool add(struct swc_surface * surface)
void remove_(struct swc_surface * surface)
{
- struct swc_compositor * compositor = swc_container_of
+ struct swc_compositor * compositor = CONTAINER_OF
(surface->class, typeof(*compositor), compositor_class);
struct swc_compositor_surface_state * state = surface->class_state;
@@ -206,7 +206,7 @@ void remove_(struct swc_surface * surface)
void attach(struct swc_surface * surface, struct wl_resource * resource)
{
- struct swc_compositor * compositor = swc_container_of
+ struct swc_compositor * compositor = CONTAINER_OF
(surface->class, typeof(*compositor), compositor_class);
swc_renderer_attach(&compositor->renderer, surface, resource);
@@ -214,7 +214,7 @@ void attach(struct swc_surface * surface, struct wl_resource * resource)
void update(struct swc_surface * surface)
{
- struct swc_compositor * compositor = swc_container_of
+ struct swc_compositor * compositor = CONTAINER_OF
(surface->class, typeof(*compositor), compositor_class);
struct swc_compositor_surface_state * state = surface->class_state;
struct swc_output * output;
@@ -231,7 +231,7 @@ void update(struct swc_surface * surface)
void move(struct swc_surface * surface, int32_t x, int32_t y)
{
- struct swc_compositor * compositor = swc_container_of
+ struct swc_compositor * compositor = CONTAINER_OF
(surface->class, typeof(*compositor), compositor_class);
struct swc_compositor_surface_state * state = surface->class_state;
@@ -261,7 +261,7 @@ void move(struct swc_surface * surface, int32_t x, int32_t y)
void swc_compositor_surface_show(struct swc_surface * surface)
{
- struct swc_compositor * compositor = swc_container_of
+ struct swc_compositor * compositor = CONTAINER_OF
(surface->class, typeof(*compositor), compositor_class);
struct swc_compositor_surface_state * state = surface->class_state;
@@ -287,7 +287,7 @@ void swc_compositor_surface_show(struct swc_surface * surface)
void swc_compositor_surface_hide(struct swc_surface * surface)
{
- struct swc_compositor * compositor = swc_container_of
+ struct swc_compositor * compositor = CONTAINER_OF
(surface->class, typeof(*compositor), compositor_class);
struct swc_compositor_surface_state * state = surface->class_state;
diff --git a/libswc/cursor_surface.c b/libswc/cursor_surface.c
@@ -41,7 +41,7 @@ static void update_plane(struct swc_plane * plane, void * data)
static void attach(struct swc_surface * surface,
struct wl_resource * resource)
{
- struct swc_compositor * compositor = swc_container_of
+ struct swc_compositor * compositor = CONTAINER_OF
(surface->class, typeof(*compositor), cursor_class);
if (pixman_region32_not_empty(&surface->state.damage))
@@ -86,7 +86,7 @@ static void update(struct swc_surface * surface)
static void move(struct swc_surface * surface, int32_t x, int32_t y)
{
- struct swc_compositor * compositor = swc_container_of
+ struct swc_compositor * compositor = CONTAINER_OF
(surface->class, typeof(*compositor), cursor_class);
struct swc_output * output;
diff --git a/libswc/data_device.c b/libswc/data_device.c
@@ -68,7 +68,7 @@ struct wl_data_device_interface data_device_implementation = {
static void handle_selection_destroy(struct wl_listener * listener, void * data)
{
- struct swc_data_device * data_device = swc_container_of
+ struct swc_data_device * data_device = CONTAINER_OF
(listener, typeof(*data_device), selection_destroy_listener);
data_device->selection = NULL;
diff --git a/libswc/input_focus.c b/libswc/input_focus.c
@@ -58,7 +58,7 @@ static inline void unfocus(struct swc_input_focus * input_focus)
static void handle_focus_surface_destroy(struct wl_listener * listener,
void * data)
{
- struct swc_input_focus * input_focus = swc_container_of
+ struct swc_input_focus * input_focus = CONTAINER_OF
(listener, typeof(*input_focus), surface_destroy_listener);
input_focus->surface = NULL;
diff --git a/libswc/keyboard.c b/libswc/keyboard.c
@@ -12,7 +12,7 @@ static void enter(struct swc_input_focus_handler * handler,
struct wl_display * display;
uint32_t serial;
- keyboard = swc_container_of(handler, typeof(*keyboard), focus_handler);
+ keyboard = CONTAINER_OF(handler, typeof(*keyboard), focus_handler);
client = wl_resource_get_client(resource);
display = wl_client_get_display(client);
serial = wl_display_next_serial(display);
diff --git a/libswc/pointer.c b/libswc/pointer.c
@@ -14,7 +14,7 @@ static void enter(struct swc_input_focus_handler * handler,
uint32_t serial;
wl_fixed_t surface_x, surface_y;
- pointer = swc_container_of(handler, typeof(*pointer), focus_handler);
+ pointer = CONTAINER_OF(handler, typeof(*pointer), focus_handler);
client = wl_resource_get_client(resource);
display = wl_client_get_display(client);
serial = wl_display_next_serial(display);
@@ -45,8 +45,8 @@ static void leave(struct swc_input_focus_handler * handler,
static void handle_cursor_surface_destroy(struct wl_listener * listener,
void * data)
{
- struct swc_pointer * pointer = swc_container_of(listener, typeof(*pointer),
- cursor.destroy_listener);
+ struct swc_pointer * pointer = CONTAINER_OF(listener, typeof(*pointer),
+ cursor.destroy_listener);
pointer->cursor.surface = NULL;
}
diff --git a/libswc/renderer.c b/libswc/renderer.c
@@ -45,7 +45,7 @@ static inline uint32_t wld_format(uint32_t format)
static void handle_buffer_destroy(struct wl_listener * listener, void * data)
{
struct buffer_state * state
- = swc_container_of(listener, typeof(*state), destroy_listener);
+ = CONTAINER_OF(listener, typeof(*state), destroy_listener);
wld_destroy_drawable(state->drawable);
if (state->dst)
@@ -60,8 +60,8 @@ static inline struct buffer_state * buffer_state(struct wl_resource * resource)
struct wl_listener * listener
= wl_resource_get_destroy_listener(resource, &handle_buffer_destroy);
- return listener ? swc_container_of(listener, struct buffer_state,
- destroy_listener)
+ return listener ? CONTAINER_OF(listener, struct buffer_state,
+ destroy_listener)
: NULL;
}
diff --git a/libswc/seat.c b/libswc/seat.c
@@ -13,8 +13,8 @@
static void handle_key(const struct swc_evdev_device_handler * handler,
uint32_t time, uint32_t key, uint32_t state)
{
- struct swc_seat * seat = swc_container_of(handler, typeof(*seat),
- evdev_handler);
+ struct swc_seat * seat = CONTAINER_OF(handler, typeof(*seat),
+ evdev_handler);
swc_keyboard_handle_key(&seat->keyboard, time, key, state);
}
@@ -22,8 +22,8 @@ static void handle_key(const struct swc_evdev_device_handler * handler,
static void handle_button(const struct swc_evdev_device_handler * handler,
uint32_t time, uint32_t button, uint32_t state)
{
- struct swc_seat * seat = swc_container_of(handler, typeof(*seat),
- evdev_handler);
+ struct swc_seat * seat = CONTAINER_OF(handler, typeof(*seat),
+ evdev_handler);
swc_pointer_handle_button(&seat->pointer, time, button, state);
}
@@ -31,8 +31,8 @@ static void handle_button(const struct swc_evdev_device_handler * handler,
static void handle_axis(const struct swc_evdev_device_handler * handler,
uint32_t time, uint32_t axis, wl_fixed_t amount)
{
- struct swc_seat * seat = swc_container_of(handler, typeof(*seat),
- evdev_handler);
+ struct swc_seat * seat = CONTAINER_OF(handler, typeof(*seat),
+ evdev_handler);
swc_pointer_handle_axis(&seat->pointer, time, axis, amount);
}
@@ -41,8 +41,8 @@ static void handle_relative_motion
(const struct swc_evdev_device_handler * handler,
uint32_t time, wl_fixed_t dx, wl_fixed_t dy)
{
- struct swc_seat * seat = swc_container_of(handler, typeof(*seat),
- evdev_handler);
+ struct swc_seat * seat = CONTAINER_OF(handler, typeof(*seat),
+ evdev_handler);
swc_pointer_handle_relative_motion(&seat->pointer, time, dx, dy);
}
@@ -50,8 +50,8 @@ static void handle_relative_motion
static void handle_keyboard_focus_event(struct wl_listener * listener,
void * data)
{
- struct swc_seat * seat = swc_container_of
- (listener, typeof(*seat), keyboard_focus_listener);
+ struct swc_seat * seat = CONTAINER_OF(listener, typeof(*seat),
+ keyboard_focus_listener);
struct swc_event * event = data;
struct swc_input_focus_event_data * event_data = event->data;
@@ -72,8 +72,8 @@ static void handle_keyboard_focus_event(struct wl_listener * listener,
static void handle_data_device_event(struct wl_listener * listener, void * data)
{
- struct swc_seat * seat = swc_container_of
- (listener, typeof(*seat), data_device_listener);
+ struct swc_seat * seat = CONTAINER_OF(listener, typeof(*seat),
+ data_device_listener);
struct swc_event * event = data;
switch (event->type)
diff --git a/libswc/surface.c b/libswc/surface.c
@@ -43,7 +43,7 @@ static void handle_buffer_destroy(struct wl_listener * listener, void * data)
{
struct swc_surface_state * state;
- state = swc_container_of(listener, typeof(*state), buffer_destroy_listener);
+ state = CONTAINER_OF(listener, typeof(*state), buffer_destroy_listener);
state->buffer = NULL;
}
diff --git a/libswc/util.h b/libswc/util.h
@@ -6,13 +6,15 @@
#include <sys/param.h>
#include <pixman.h>
-#ifndef offsetof
-# define offsetof __builtin_offsetof
+#ifdef offsetof
+# define OFFSET_OF offsetof
+#else
+# define OFFSET_OF __builtin_offsetof
#endif
-#define swc_container_of(ptr, type, member) ({ \
+#define CONTAINER_OF(ptr, type, member) ({ \
const typeof(((type *) 0)->member) *__mptr = (ptr); \
- ((type *) ((uintptr_t) __mptr - offsetof(type, member))); \
+ ((type *) ((uintptr_t) __mptr - OFFSET_OF(type, member))); \
})
struct wl_resource;