[PATCH weston] sdk: be C++ friendly

Kristian Høgsberg hoegsberg at gmail.com
Thu Mar 28 11:04:25 PDT 2013


On Thu, Mar 28, 2013 at 06:02:42PM +0100, Giulio Camuffo wrote:
> This renames the weston_surface's private member to configure_private
> and externs "C" the headers of the SDK.
> ---
>  shared/config-parser.h |  8 ++++++++
>  shared/matrix.h        |  8 ++++++++
>  src/compositor.c       |  6 +++---
>  src/compositor.h       | 10 +++++++++-
>  src/shell.c            | 28 ++++++++++++++--------------
>  tests/weston-test.c    |  8 ++++----
>  6 files changed, 46 insertions(+), 22 deletions(-)

Thanks, applied.

Kristian

> diff --git a/shared/config-parser.h b/shared/config-parser.h
> index 314057a..1d0ee3f 100644
> --- a/shared/config-parser.h
> +++ b/shared/config-parser.h
> @@ -23,6 +23,10 @@
>  #ifndef CONFIGPARSER_H
>  #define CONFIGPARSER_H
>  
> +#ifdef  __cplusplus
> +extern "C" {
> +#endif
> +
>  enum config_key_type {
>  	CONFIG_KEY_INTEGER,		/* typeof data = int */
>  	CONFIG_KEY_UNSIGNED_INTEGER,	/* typeof data = unsigned int */
> @@ -69,5 +73,9 @@ int
>  parse_options(const struct weston_option *options,
>  	      int count, int *argc, char *argv[]);
>  
> +#ifdef  __cplusplus
> +}
> +#endif
> +
>  #endif /* CONFIGPARSER_H */
>  
> diff --git a/shared/matrix.h b/shared/matrix.h
> index 47354f6..e5cf636 100644
> --- a/shared/matrix.h
> +++ b/shared/matrix.h
> @@ -24,6 +24,10 @@
>  #ifndef WESTON_MATRIX_H
>  #define WESTON_MATRIX_H
>  
> +#ifdef  __cplusplus
> +extern "C" {
> +#endif
> +
>  enum weston_matrix_transform_type {
>  	WESTON_MATRIX_TRANSFORM_TRANSLATE	= (1 << 0),
>  	WESTON_MATRIX_TRANSFORM_SCALE		= (1 << 1),
> @@ -71,4 +75,8 @@ inverse_transform(const double *LU, const unsigned *p, float *v);
>  #  define MATRIX_TEST_EXPORT static
>  #endif
>  
> +#ifdef  __cplusplus
> +}
> +#endif
> +
>  #endif /* WESTON_MATRIX_H */
> diff --git a/src/compositor.c b/src/compositor.c
> index eb8d473..52d6f90 100644
> --- a/src/compositor.c
> +++ b/src/compositor.c
> @@ -2271,7 +2271,7 @@ static void
>  pointer_cursor_surface_configure(struct weston_surface *es,
>  				 int32_t dx, int32_t dy, int32_t width, int32_t height)
>  {
> -	struct weston_seat *seat = es->private;
> +	struct weston_seat *seat = es->configure_private;
>  	int x, y;
>  
>  	if (width == 0)
> @@ -2305,7 +2305,7 @@ pointer_unmap_sprite(struct weston_seat *seat)
>  
>  	wl_list_remove(&seat->sprite_destroy_listener.link);
>  	seat->sprite->configure = NULL;
> -	seat->sprite->private = NULL;
> +	seat->sprite->configure_private = NULL;
>  	seat->sprite = NULL;
>  }
>  
> @@ -2347,7 +2347,7 @@ pointer_set_cursor(struct wl_client *client, struct wl_resource *resource,
>  		      &seat->sprite_destroy_listener);
>  
>  	surface->configure = pointer_cursor_surface_configure;
> -	surface->private = seat;
> +	surface->configure_private = seat;
>  	seat->sprite = surface;
>  	seat->hotspot_x = x;
>  	seat->hotspot_y = y;
> diff --git a/src/compositor.h b/src/compositor.h
> index dc03aeb..0ad60ef 100644
> --- a/src/compositor.h
> +++ b/src/compositor.h
> @@ -24,6 +24,10 @@
>  #ifndef _WAYLAND_SYSTEM_COMPOSITOR_H_
>  #define _WAYLAND_SYSTEM_COMPOSITOR_H_
>  
> +#ifdef  __cplusplus
> +extern "C" {
> +#endif
> +
>  #include <pixman.h>
>  #include <xkbcommon/xkbcommon.h>
>  #include <wayland-server.h>
> @@ -496,7 +500,7 @@ struct weston_surface {
>  	 * are the sx and sy paramerters supplied to surface::attach .
>  	 */
>  	void (*configure)(struct weston_surface *es, int32_t sx, int32_t sy, int32_t width, int32_t height);
> -	void *private;
> +	void *configure_private;
>  };
>  
>  enum weston_key_state_update {
> @@ -880,4 +884,8 @@ weston_transformed_rect(int width, int height,
>  			enum wl_output_transform transform,
>  			pixman_box32_t rect);
>  
> +#ifdef  __cplusplus
> +}
> +#endif
> +
>  #endif
> diff --git a/src/shell.c b/src/shell.c
> index c6ff300..de5d6f6 100644
> --- a/src/shell.c
> +++ b/src/shell.c
> @@ -1676,7 +1676,7 @@ create_black_surface(struct weston_compositor *ec,
>  	}
>  
>  	surface->configure = black_surface_configure;
> -	surface->private = fs_surface;
> +	surface->configure_private = fs_surface;
>  	weston_surface_configure(surface, x, y, w, h);
>  	weston_surface_set_color(surface, 0.0, 0.0, 0.0, 1);
>  	pixman_region32_fini(&surface->opaque);
> @@ -2142,7 +2142,7 @@ static struct shell_surface *
>  get_shell_surface(struct weston_surface *surface)
>  {
>  	if (surface->configure == shell_surface_configure)
> -		return surface->private;
> +		return surface->configure_private;
>  	else
>  		return NULL;
>  }
> @@ -2165,7 +2165,7 @@ create_shell_surface(void *shell, struct weston_surface *surface,
>  	}
>  
>  	surface->configure = shell_surface_configure;
> -	surface->private = shsurf;
> +	surface->configure_private = shsurf;
>  
>  	shsurf->shell = (struct desktop_shell *) shell;
>  	shsurf->unresponsive = 0;
> @@ -2322,7 +2322,7 @@ configure_static_surface(struct weston_surface *es, struct weston_layer *layer,
>  static void
>  background_configure(struct weston_surface *es, int32_t sx, int32_t sy, int32_t width, int32_t height)
>  {
> -	struct desktop_shell *shell = es->private;
> +	struct desktop_shell *shell = es->configure_private;
>  
>  	configure_static_surface(es, &shell->background_layer, width, height);
>  }
> @@ -2344,7 +2344,7 @@ desktop_shell_set_background(struct wl_client *client,
>  	}
>  
>  	surface->configure = background_configure;
> -	surface->private = shell;
> +	surface->configure_private = shell;
>  	surface->output = output_resource->data;
>  	desktop_shell_send_configure(resource, 0,
>  				     surface_resource,
> @@ -2355,7 +2355,7 @@ desktop_shell_set_background(struct wl_client *client,
>  static void
>  panel_configure(struct weston_surface *es, int32_t sx, int32_t sy, int32_t width, int32_t height)
>  {
> -	struct desktop_shell *shell = es->private;
> +	struct desktop_shell *shell = es->configure_private;
>  
>  	configure_static_surface(es, &shell->panel_layer, width, height);
>  }
> @@ -2377,7 +2377,7 @@ desktop_shell_set_panel(struct wl_client *client,
>  	}
>  
>  	surface->configure = panel_configure;
> -	surface->private = shell;
> +	surface->configure_private = shell;
>  	surface->output = output_resource->data;
>  	desktop_shell_send_configure(resource, 0,
>  				     surface_resource,
> @@ -2388,7 +2388,7 @@ desktop_shell_set_panel(struct wl_client *client,
>  static void
>  lock_surface_configure(struct weston_surface *surface, int32_t sx, int32_t sy, int32_t width, int32_t height)
>  {
> -	struct desktop_shell *shell = surface->private;
> +	struct desktop_shell *shell = surface->configure_private;
>  
>  	if (width == 0)
>  		return;
> @@ -2433,7 +2433,7 @@ desktop_shell_set_lock_surface(struct wl_client *client,
>  		      &shell->lock_surface_listener);
>  
>  	surface->configure = lock_surface_configure;
> -	surface->private = shell;
> +	surface->configure_private = shell;
>  }
>  
>  static void
> @@ -2858,7 +2858,7 @@ is_black_surface (struct weston_surface *es, struct weston_surface **fs_surface)
>  {
>  	if (es->configure == black_surface_configure) {
>  		if (fs_surface)
> -			*fs_surface = (struct weston_surface *)es->private;
> +			*fs_surface = (struct weston_surface *)es->configure_private;
>  		return true;
>  	}
>  	return false;
> @@ -3413,7 +3413,7 @@ bind_desktop_shell(struct wl_client *client,
>  static void
>  screensaver_configure(struct weston_surface *surface, int32_t sx, int32_t sy, int32_t width, int32_t height)
>  {
> -	struct desktop_shell *shell = surface->private;
> +	struct desktop_shell *shell = surface->configure_private;
>  
>  	if (width == 0)
>  		return;
> @@ -3445,7 +3445,7 @@ screensaver_set_surface(struct wl_client *client,
>  	struct weston_output *output = output_resource->data;
>  
>  	surface->configure = screensaver_configure;
> -	surface->private = shell;
> +	surface->configure_private = shell;
>  	surface->output = output;
>  }
>  
> @@ -3524,7 +3524,7 @@ static struct input_panel_surface *
>  get_input_panel_surface(struct weston_surface *surface)
>  {
>  	if (surface->configure == input_panel_configure) {
> -		return surface->private;
> +		return surface->configure_private;
>  	} else {
>  		return NULL;
>  	}
> @@ -3556,7 +3556,7 @@ create_input_panel_surface(struct desktop_shell *shell,
>  		return NULL;
>  
>  	surface->configure = input_panel_configure;
> -	surface->private = input_panel_surface;
> +	surface->configure_private = input_panel_surface;
>  
>  	input_panel_surface->shell = shell;
>  
> diff --git a/tests/weston-test.c b/tests/weston-test.c
> index 4dc2e5c..55c5da4 100644
> --- a/tests/weston-test.c
> +++ b/tests/weston-test.c
> @@ -76,7 +76,7 @@ notify_pointer_position(struct weston_test *test, struct wl_resource *resource)
>  static void
>  test_surface_configure(struct weston_surface *surface, int32_t sx, int32_t sy, int32_t width, int32_t height)
>  {
> -	struct weston_test_surface *test_surface = surface->private;
> +	struct weston_test_surface *test_surface = surface->configure_private;
>  	struct weston_test *test = test_surface->test;
>  
>  	if (wl_list_empty(&surface->layer_link))
> @@ -99,9 +99,9 @@ move_surface(struct wl_client *client, struct wl_resource *resource,
>  	struct weston_test_surface *test_surface;
>  
>  	surface->configure = test_surface_configure;
> -	if (surface->private == NULL)
> -		surface->private = malloc(sizeof *test_surface);
> -	test_surface = surface->private;
> +	if (surface->configure_private == NULL)
> +		surface->configure_private = malloc(sizeof *test_surface);
> +	test_surface = surface->configure_private;
>  	if (test_surface == NULL) {
>  		wl_resource_post_no_memory(resource);
>  		return;
> -- 
> 1.8.2
> 
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel


More information about the wayland-devel mailing list