[gtk-vnc] Add padding to GObject classes



commit 47275e3cba1c59435746af25d88b159933729669
Author: Daniel P. Berrange <dan berrange com>
Date:   Tue Jun 29 22:43:02 2010 +0100

    Add padding to GObject classes
    
    To allow the class structs to be expanded later without breaking
    ABI it is neccessary to include padding in the structs. If extra
    fields are later added, an equivalent amount padding must be
    remnoved

 src/vncbaseframebuffer.h  |    8 ++++++++
 src/vnccolormap.h         |    4 ++++
 src/vncconnection.h       |   13 +++++++++++--
 src/vnccursor.h           |   10 ++++++++++
 src/vncdisplay.h          |    4 ++++
 src/vncframebuffer.h      |    2 ++
 src/vncgrabsequence.h     |    2 ++
 src/vncimageframebuffer.h |    8 ++++++++
 src/vncpixelformat.h      |    2 ++
 src/vncutil.h             |    6 ++++++
 10 files changed, 57 insertions(+), 2 deletions(-)
---
diff --git a/src/vncbaseframebuffer.h b/src/vncbaseframebuffer.h
index 0113647..d86127a 100644
--- a/src/vncbaseframebuffer.h
+++ b/src/vncbaseframebuffer.h
@@ -25,6 +25,7 @@
 #include <glib-object.h>
 
 #include <vncframebuffer.h>
+#include <vncutil.h>
 
 G_BEGIN_DECLS
 
@@ -45,12 +46,19 @@ struct _VncBaseFramebuffer
 	GObject parent;
 
 	VncBaseFramebufferPrivate *priv;
+
+	/* Do not add fields to this struct */
 };
 
 struct _VncBaseFramebufferClass
 {
 	GObjectClass parent_class;
 
+	/*
+	 * If adding fields to this struct, remove corresponding
+	 * amount of padding to avoid changing overall struct size
+	 */
+	gpointer _vnc_reserved[VNC_PADDING];
 };
 
 
diff --git a/src/vnccolormap.h b/src/vnccolormap.h
index fe1f1d5..debbf97 100644
--- a/src/vnccolormap.h
+++ b/src/vnccolormap.h
@@ -36,12 +36,16 @@ struct _VncColorMap {
 	guint16 offset;
 	guint16 size;
 	VncColorMapEntry *colors;
+
+	/* Do not add fields to this struct */
 };
 
 struct _VncColorMapEntry {
 	guint16 red;
 	guint16 green;
 	guint16 blue;
+
+	/* Do not add fields to this struct */
 };
 
 
diff --git a/src/vncconnection.h b/src/vncconnection.h
index 02262ec..9ddb6f4 100644
--- a/src/vncconnection.h
+++ b/src/vncconnection.h
@@ -24,8 +24,9 @@
 
 #include <glib.h>
 
-#include "vncframebuffer.h"
-#include "vnccursor.h"
+#include <vncframebuffer.h>
+#include <vnccursor.h>
+#include <vncutil.h>
 
 G_BEGIN_DECLS
 
@@ -46,6 +47,8 @@ struct _VncConnection
 	GObject parent;
 
 	VncConnectionPrivate *priv;
+
+	/* Do not add fields to this struct */
 };
 
 struct _VncConnectionClass
@@ -68,6 +71,12 @@ struct _VncConnectionClass
 	void (*vnc_connected)(VncConnection *conn);
 	void (*vnc_initialized)(VncConnection *conn);
 	void (*vnc_disconnected)(VncConnection *conn);
+
+	/*
+	 * If adding fields to this struct, remove corresponding
+	 * amount of padding to avoid changing overall struct size
+	 */
+	gpointer _vnc_reserved[VNC_PADDING_LARGE];
 };
 
 
diff --git a/src/vnccursor.h b/src/vnccursor.h
index bca323a..8e345e6 100644
--- a/src/vnccursor.h
+++ b/src/vnccursor.h
@@ -23,6 +23,8 @@
 
 #include <glib-object.h>
 
+#include <vncutil.h>
+
 G_BEGIN_DECLS
 
 #define VNC_TYPE_CURSOR            (vnc_cursor_get_type())
@@ -42,11 +44,19 @@ struct _VncCursor
 	GObject parent;
 
 	VncCursorPrivate *priv;
+
+	/* Do not add fields to this struct */
 };
 
 struct _VncCursorClass
 {
 	GObjectClass parent_class;
+
+	/*
+	 * If adding fields to this struct, remove corresponding
+	 * amount of padding to avoid changing overall struct size
+	 */
+	gpointer _vnc_reserved[VNC_PADDING];
 };
 
 
diff --git a/src/vncdisplay.h b/src/vncdisplay.h
index 2ed2a6c..76f44d4 100644
--- a/src/vncdisplay.h
+++ b/src/vncdisplay.h
@@ -45,6 +45,8 @@ struct _VncDisplay
 	GtkDrawingArea parent;
 
 	VncDisplayPrivate *priv;
+
+	/* Do not add fields to this struct */
 };
 
 struct _VncDisplayClass
@@ -56,6 +58,8 @@ struct _VncDisplayClass
 	void		(* vnc_initialized)	(VncDisplay *display);
 	void		(* vnc_disconnected)	(VncDisplay *display);
 	void		(* vnc_auth_credential)	(VncDisplay *display, GValueArray *credList);
+
+	/* Do not add fields to this struct */
 };
 
 typedef enum
diff --git a/src/vncframebuffer.h b/src/vncframebuffer.h
index ebef8de..638441f 100644
--- a/src/vncframebuffer.h
+++ b/src/vncframebuffer.h
@@ -72,6 +72,8 @@ struct _VncFramebufferInterface {
 			  guint16 width, guint16 height);
 	void (*set_color_map)(VncFramebuffer *fb,
 			      VncColorMap *map);
+
+	/* Do not add fields to this struct */
 };
 
 GType vnc_framebuffer_get_type(void) G_GNUC_CONST;
diff --git a/src/vncgrabsequence.h b/src/vncgrabsequence.h
index 94007ef..c0b9bd1 100644
--- a/src/vncgrabsequence.h
+++ b/src/vncgrabsequence.h
@@ -34,6 +34,8 @@ typedef struct _VncGrabSequence VncGrabSequence;
 struct _VncGrabSequence {
 	guint nkeysyms;
 	guint *keysyms;
+
+	/* Do not add fields to this struct */
 };
 
 GType vnc_grab_sequence_get_type(void);
diff --git a/src/vncimageframebuffer.h b/src/vncimageframebuffer.h
index 4502431..faef161 100644
--- a/src/vncimageframebuffer.h
+++ b/src/vncimageframebuffer.h
@@ -25,6 +25,7 @@
 #include <gdk/gdk.h>
 
 #include <vncbaseframebuffer.h>
+#include <vncutil.h>
 
 G_BEGIN_DECLS
 
@@ -45,12 +46,19 @@ struct _VncImageFramebuffer
 	VncBaseFramebuffer parent;
 
 	VncImageFramebufferPrivate *priv;
+
+	/* Do not add fields to this struct */
 };
 
 struct _VncImageFramebufferClass
 {
 	VncBaseFramebufferClass parent_class;
 
+	/*
+	 * If adding fields to this struct, remove corresponding
+	 * amount of padding to avoid changing overall struct size
+	 */
+	gpointer _vnc_reserved[VNC_PADDING];
 };
 
 
diff --git a/src/vncpixelformat.h b/src/vncpixelformat.h
index 555c1ea..2382e5d 100644
--- a/src/vncpixelformat.h
+++ b/src/vncpixelformat.h
@@ -42,6 +42,8 @@ struct _VncPixelFormat {
 	guint8 red_shift;
 	guint8 green_shift;
 	guint8 blue_shift;
+
+	/* Do not add fields to this struct */
 };
 
 GType vnc_pixel_format_get_type(void);
diff --git a/src/vncutil.h b/src/vncutil.h
index df41bbf..9c96de8 100644
--- a/src/vncutil.h
+++ b/src/vncutil.h
@@ -34,6 +34,12 @@ gboolean vnc_util_get_debug(void);
 			g_debug(__FILE__ " " fmt, ## __VA_ARGS__);	\
 	} while (0)
 
+/* For normal VncXXXClass structs */
+#define VNC_PADDING 4
+
+/* For very extensible VncXXXClass structs */
+#define VNC_PADDING_LARGE 20
+
 G_END_DECLS
 
 #endif /* VNC_UTIL_H */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]