g{u}int{8|16|32} patch (again)



hi all,

I must have been in a weird state the other day: I fucked up my patch.
Here is a working patch which does not include g{u}int64 support (I can
produce this on demand. just ask for it.)

In case anyone wants to know why I want this to get in, it is because,
without this patch, it would be impossible to have signals or object
properties to use these types. Many people will ask me why in hell I
cannot use gint and guint for the 8, 16 and 32 quantities. The first
reason is simply that I am not sure gint will always fit a 32 bit
quantity (is there a way to be sure about this ?) and the second reason
is that doing so would weaken my API: it would make it less precise.

I hope that this patch will be considered for inclusion quickly: please,
owen or tim, could you comment on it  and tell me why you won't want it
?

regards,
Mathieu

? glib-patch
Index: glib-genmarshal.c
===================================================================
RCS file: /cvs/gnome/glib/gobject/glib-genmarshal.c,v
retrieving revision 1.9
diff -u -r1.9 glib-genmarshal.c
--- glib-genmarshal.c	2001/07/26 10:36:01	1.9
+++ glib-genmarshal.c	2001/08/22 09:36:30
@@ -153,9 +153,16 @@
     { "BOXED",		"BOXED",	"gpointer",	"g_value_get_boxed",	},
     { "POINTER",	"POINTER",	"gpointer",	"g_value_get_pointer",	},
     { "OBJECT",		"OBJECT",	"gpointer",	"g_value_get_object",	},
+    { "INT8",		"INT8",		"gint8",	"g_value_get_int8",	},
+    { "UINT8",		"UINT8",	"guint8",	"g_value_get_uint8",	},
+    { "INT16",		"INT16",	"gint16",       "g_value_get_int16",	},
+    { "UINT16",		"UINT16",	"guint16",	"g_value_get_uint16",	},
+    { "INT32",		"INT32",	"gint32",       "g_value_get_int32",	},
+    { "UINT32",		"UINT32",	"guint32",	"g_value_get_uint32",	},
     /* deprecated: */
     { "NONE",		"VOID",		"void",		NULL,			},
     { "BOOL",		"BOOLEAN",	"gboolean",	"g_value_get_boolean",	},
+
   };
   const guint n_args = sizeof (args) / sizeof (args[0]);
   guint i;
@@ -196,6 +203,12 @@
     { "BOXED",		"BOXED",	"gpointer",	"g_value_set_boxed_take_ownership", NULL,	NULL          },
     { "POINTER",	"POINTER",	"gpointer",	"g_value_set_pointer",	NULL,			NULL          },
     { "OBJECT",		"OBJECT",	"GObject*",	"g_value_set_object",	"g_object_unref",	"NULL !="     },
+    { "INT8",		"INT8",		"gint8",	"g_value_set_int8",	NULL,			NULL          },
+    { "UINT8",		"UINT8",	"guint8",	"g_value_set_uint8",	NULL,			NULL          },
+    { "INT16",		"INT16",	"gint16",	"g_value_set_int16",	NULL,			NULL          },
+    { "UINT16",		"UINT16",	"guint16",	"g_value_set_uint16",	NULL,			NULL          },
+    { "INT32",		"INT32",	"gint32",	"g_value_set_int32",	NULL,			NULL          },
+    { "UINT32",		"UINT32",	"guint32",	"g_value_set_uint32",	NULL,			NULL          },
     /* deprecated: */
     { "NONE",		"VOID",		"void",		NULL,			NULL,			NULL          },
     { "BOOL",		"BOOLEAN",	"gboolean",	"g_value_set_boolean",	NULL,			NULL          }
Index: gparamspecs.c
===================================================================
RCS file: /cvs/gnome/glib/gobject/gparamspecs.c,v
retrieving revision 1.16
diff -u -r1.16 gparamspecs.c
--- gparamspecs.c	2001/05/10 13:58:40	1.16
+++ gparamspecs.c	2001/08/22 09:36:31
@@ -190,6 +190,246 @@
 }
 
 static void
+param_int8_init (GParamSpec *pspec)
+{
+  GParamSpecInt8 *ispec = G_PARAM_SPEC_INT8 (pspec);
+  
+  ispec->minimum = 0x81;
+  ispec->maximum = 0x7f;
+  ispec->default_value = 0;
+}
+
+static void
+param_int8_set_default (GParamSpec *pspec,
+			GValue     *value)
+{
+  value->data[0].v_int8 = G_PARAM_SPEC_INT8 (pspec)->default_value;
+}
+
+static gboolean
+param_int8_validate (GParamSpec *pspec,
+		     GValue     *value)
+{
+  GParamSpecInt8 *ispec = G_PARAM_SPEC_INT8 (pspec);
+  gint8 oval = value->data[0].v_int8;
+  
+  value->data[0].v_int8 = CLAMP (value->data[0].v_int8, ispec->minimum, ispec->maximum);
+  
+  return value->data[0].v_int8 != oval;
+}
+
+static gint
+param_int8_values_cmp (GParamSpec   *pspec,
+		       const GValue *value1,
+		       const GValue *value2)
+{
+  if (value1->data[0].v_int8 < value2->data[0].v_int8)
+    return -1;
+  else
+    return value1->data[0].v_int8 > value2->data[0].v_int8;
+}
+
+static void
+param_uint8_init (GParamSpec *pspec)
+{
+  GParamSpecUInt8 *uspec = G_PARAM_SPEC_UINT8 (pspec);
+  
+  uspec->minimum = 0;
+  uspec->maximum = 0xff;
+  uspec->default_value = 0;
+}
+
+static void
+param_uint8_set_default (GParamSpec *pspec,
+			 GValue     *value)
+{
+  value->data[0].v_uint8 = G_PARAM_SPEC_UINT8 (pspec)->default_value;
+}
+
+static gboolean
+param_uint8_validate (GParamSpec *pspec,
+		      GValue     *value)
+{
+  GParamSpecUInt8 *uspec = G_PARAM_SPEC_UINT8 (pspec);
+  guint8 oval = value->data[0].v_uint8;
+  
+  value->data[0].v_uint8 = CLAMP (value->data[0].v_uint8, uspec->minimum, uspec->maximum);
+  
+  return value->data[0].v_uint8 != oval;
+}
+
+static gint
+param_uint8_values_cmp (GParamSpec   *pspec,
+			const GValue *value1,
+			const GValue *value2)
+{
+  if (value1->data[0].v_uint8 < value2->data[0].v_uint8)
+    return -1;
+  else
+    return value1->data[0].v_uint8 > value2->data[0].v_uint8;
+}
+
+static void
+param_int16_init (GParamSpec *pspec)
+{
+  GParamSpecInt16 *ispec = G_PARAM_SPEC_INT16 (pspec);
+  
+  ispec->minimum = 0x8001;
+  ispec->maximum = 0x7fff;
+  ispec->default_value = 0;
+}
+
+static void
+param_int16_set_default (GParamSpec *pspec,
+			GValue     *value)
+{
+  value->data[0].v_int16 = G_PARAM_SPEC_INT16 (pspec)->default_value;
+}
+
+static gboolean
+param_int16_validate (GParamSpec *pspec,
+		     GValue     *value)
+{
+  GParamSpecInt16 *ispec = G_PARAM_SPEC_INT16 (pspec);
+  gint16 oval = value->data[0].v_int16;
+  
+  value->data[0].v_int16 = CLAMP (value->data[0].v_int16, ispec->minimum, ispec->maximum);
+  
+  return value->data[0].v_int16 != oval;
+}
+
+static gint
+param_int16_values_cmp (GParamSpec   *pspec,
+		       const GValue *value1,
+		       const GValue *value2)
+{
+  if (value1->data[0].v_int16 < value2->data[0].v_int16)
+    return -1;
+  else
+    return value1->data[0].v_int16 > value2->data[0].v_int16;
+}
+
+static void
+param_uint16_init (GParamSpec *pspec)
+{
+  GParamSpecUInt16 *uspec = G_PARAM_SPEC_UINT16 (pspec);
+  
+  uspec->minimum = 0;
+  uspec->maximum = 0xffff;
+  uspec->default_value = 0;
+}
+
+static void
+param_uint16_set_default (GParamSpec *pspec,
+			 GValue     *value)
+{
+  value->data[0].v_uint16 = G_PARAM_SPEC_UINT16 (pspec)->default_value;
+}
+
+static gboolean
+param_uint16_validate (GParamSpec *pspec,
+		      GValue     *value)
+{
+  GParamSpecUInt16 *uspec = G_PARAM_SPEC_UINT16 (pspec);
+  guint16 oval = value->data[0].v_uint16;
+  
+  value->data[0].v_uint16 = CLAMP (value->data[0].v_uint16, uspec->minimum, uspec->maximum);
+  
+  return value->data[0].v_uint16 != oval;
+}
+
+static gint
+param_uint16_values_cmp (GParamSpec   *pspec,
+			const GValue *value1,
+			const GValue *value2)
+{
+  if (value1->data[0].v_uint16 < value2->data[0].v_uint16)
+    return -1;
+  else
+    return value1->data[0].v_uint16 > value2->data[0].v_uint16;
+}
+
+static void
+param_int32_init (GParamSpec *pspec)
+{
+  GParamSpecInt32 *ispec = G_PARAM_SPEC_INT32 (pspec);
+  
+  ispec->minimum = 0x80000001;
+  ispec->maximum = 0x7fffffff;
+  ispec->default_value = 0;
+}
+
+static void
+param_int32_set_default (GParamSpec *pspec,
+			GValue     *value)
+{
+  value->data[0].v_int32 = G_PARAM_SPEC_INT32 (pspec)->default_value;
+}
+
+static gboolean
+param_int32_validate (GParamSpec *pspec,
+		     GValue     *value)
+{
+  GParamSpecInt32 *ispec = G_PARAM_SPEC_INT32 (pspec);
+  gint32 oval = value->data[0].v_int32;
+  
+  value->data[0].v_int32 = CLAMP (value->data[0].v_int32, ispec->minimum, ispec->maximum);
+  
+  return value->data[0].v_int32 != oval;
+}
+
+static gint
+param_int32_values_cmp (GParamSpec   *pspec,
+		       const GValue *value1,
+		       const GValue *value2)
+{
+  if (value1->data[0].v_int32 < value2->data[0].v_int32)
+    return -1;
+  else
+    return value1->data[0].v_int32 > value2->data[0].v_int32;
+}
+
+static void
+param_uint32_init (GParamSpec *pspec)
+{
+  GParamSpecUInt32 *uspec = G_PARAM_SPEC_UINT32 (pspec);
+  
+  uspec->minimum = 0;
+  uspec->maximum = 0xffffffff;
+  uspec->default_value = 0;
+}
+
+static void
+param_uint32_set_default (GParamSpec *pspec,
+			 GValue     *value)
+{
+  value->data[0].v_uint32 = G_PARAM_SPEC_UINT32 (pspec)->default_value;
+}
+
+static gboolean
+param_uint32_validate (GParamSpec *pspec,
+		      GValue     *value)
+{
+  GParamSpecUInt32 *uspec = G_PARAM_SPEC_UINT32 (pspec);
+  guint32 oval = value->data[0].v_uint32;
+  
+  value->data[0].v_uint32 = CLAMP (value->data[0].v_uint32, uspec->minimum, uspec->maximum);
+  
+  return value->data[0].v_uint32 != oval;
+}
+
+static gint
+param_uint32_values_cmp (GParamSpec   *pspec,
+			const GValue *value1,
+			const GValue *value2)
+{
+  if (value1->data[0].v_uint32 < value2->data[0].v_uint32)
+    return -1;
+  else
+    return value1->data[0].v_uint32 > value2->data[0].v_uint32;
+}
+
+static void
 param_long_init (GParamSpec *pspec)
 {
   GParamSpecLong *lspec = G_PARAM_SPEC_LONG (pspec);
@@ -917,6 +1157,7 @@
 }
 

+
 /* --- type initialization --- */
 void
 g_param_spec_types_init (void)	/* sync with gtype.c */
@@ -1245,6 +1486,105 @@
     type = g_param_type_register_static ("GParamObject", &pspec_info);
     g_assert (type == G_TYPE_PARAM_OBJECT);
   }
+  /* G_TYPE_PARAM_INT8
+   */
+  {
+    static const GParamSpecTypeInfo pspec_info = {
+      sizeof (GParamSpecInt8),   /* instance_size */
+      16,                       /* n_preallocs */
+      param_int8_init,           /* instance_init */
+      G_TYPE_INT8,		/* value_type */
+      NULL,			/* finalize */
+      param_int8_set_default,	/* value_set_default */
+      param_int8_validate,	/* value_validate */
+      param_int8_values_cmp,	/* values_cmp */
+    };
+    type = g_param_type_register_static ("GParamInt8", &pspec_info);
+    g_assert (type == G_TYPE_PARAM_INT8);
+  }
+  
+  /* G_TYPE_PARAM_UINT8
+   */
+  {
+    static const GParamSpecTypeInfo pspec_info = {
+      sizeof (GParamSpecUInt8),  /* instance_size */
+      16,                       /* n_preallocs */
+      param_uint8_init,          /* instance_init */
+      G_TYPE_UINT8,		/* value_type */
+      NULL,			/* finalize */
+      param_uint8_set_default,	/* value_set_default */
+      param_uint8_validate,	/* value_validate */
+      param_uint8_values_cmp,	/* values_cmp */
+    };
+    type = g_param_type_register_static ("GParamUInt8", &pspec_info);
+    g_assert (type == G_TYPE_PARAM_UINT8);
+  }
+  /* G_TYPE_PARAM_INT16
+   */
+  {
+    static const GParamSpecTypeInfo pspec_info = {
+      sizeof (GParamSpecInt16),   /* instance_size */
+      16,                       /* n_preallocs */
+      param_int16_init,           /* instance_init */
+      G_TYPE_INT16,		/* value_type */
+      NULL,			/* finalize */
+      param_int16_set_default,	/* value_set_default */
+      param_int16_validate,	/* value_validate */
+      param_int16_values_cmp,	/* values_cmp */
+    };
+    type = g_param_type_register_static ("GParamInt16", &pspec_info);
+    g_assert (type == G_TYPE_PARAM_INT16);
+  }
+  
+  /* G_TYPE_PARAM_UINT16
+   */
+  {
+    static const GParamSpecTypeInfo pspec_info = {
+      sizeof (GParamSpecUInt16),  /* instance_size */
+      16,                       /* n_preallocs */
+      param_uint16_init,          /* instance_init */
+      G_TYPE_UINT16,		/* value_type */
+      NULL,			/* finalize */
+      param_uint16_set_default,	/* value_set_default */
+      param_uint16_validate,	/* value_validate */
+      param_uint16_values_cmp,	/* values_cmp */
+    };
+    type = g_param_type_register_static ("GParamUInt16", &pspec_info);
+    g_assert (type == G_TYPE_PARAM_UINT16);
+  }
+  /* G_TYPE_PARAM_INT32
+   */
+  {
+    static const GParamSpecTypeInfo pspec_info = {
+      sizeof (GParamSpecInt32),   /* instance_size */
+      16,                       /* n_preallocs */
+      param_int32_init,           /* instance_init */
+      G_TYPE_INT32,		/* value_type */
+      NULL,			/* finalize */
+      param_int32_set_default,	/* value_set_default */
+      param_int32_validate,	/* value_validate */
+      param_int32_values_cmp,	/* values_cmp */
+    };
+    type = g_param_type_register_static ("GParamInt32", &pspec_info);
+    g_assert (type == G_TYPE_PARAM_INT32);
+  }
+  
+  /* G_TYPE_PARAM_UINT32
+   */
+  {
+    static const GParamSpecTypeInfo pspec_info = {
+      sizeof (GParamSpecUInt32),  /* instance_size */
+      16,                       /* n_preallocs */
+      param_uint32_init,          /* instance_init */
+      G_TYPE_UINT32,		/* value_type */
+      NULL,			/* finalize */
+      param_uint32_set_default,	/* value_set_default */
+      param_uint32_validate,	/* value_validate */
+      param_uint32_values_cmp,	/* values_cmp */
+    };
+    type = g_param_type_register_static ("GParamUInt32", &pspec_info);
+    g_assert (type == G_TYPE_PARAM_UINT32);
+  }
 }
 

@@ -1698,3 +2038,154 @@
   
   return G_PARAM_SPEC (ospec);
 }
+GParamSpec*
+g_param_spec_int8 (const gchar *name,
+		   const gchar *nick,
+		   const gchar *blurb,
+		   gint8        minimum,
+		   gint8	maximum,
+		   gint8	default_value,
+		   GParamFlags	flags)
+{
+  GParamSpecInt8 *ispec;
+
+  g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL);
+
+  ispec = g_param_spec_internal (G_TYPE_PARAM_INT8,
+				 name,
+				 nick,
+				 blurb,
+				 flags);
+  
+  ispec->minimum = minimum;
+  ispec->maximum = maximum;
+  ispec->default_value = default_value;
+  
+  return G_PARAM_SPEC (ispec);
+}
+GParamSpec*
+g_param_spec_uint8 (const gchar *name,
+		   const gchar *nick,
+		   const gchar *blurb,
+		   guint8        minimum,
+		   guint8	maximum,
+		   guint8	default_value,
+		   GParamFlags	flags)
+{
+  GParamSpecUInt8 *ispec;
+
+  g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL);
+
+  ispec = g_param_spec_internal (G_TYPE_PARAM_UINT8,
+				 name,
+				 nick,
+				 blurb,
+				 flags);
+  
+  ispec->minimum = minimum;
+  ispec->maximum = maximum;
+  ispec->default_value = default_value;
+  
+  return G_PARAM_SPEC (ispec);
+}
+GParamSpec*
+g_param_spec_int16 (const gchar *name,
+		   const gchar *nick,
+		   const gchar *blurb,
+		   gint16        minimum,
+		   gint16	maximum,
+		   gint16	default_value,
+		   GParamFlags	flags)
+{
+  GParamSpecInt16 *ispec;
+
+  g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL);
+
+  ispec = g_param_spec_internal (G_TYPE_PARAM_INT16,
+				 name,
+				 nick,
+				 blurb,
+				 flags);
+  
+  ispec->minimum = minimum;
+  ispec->maximum = maximum;
+  ispec->default_value = default_value;
+  
+  return G_PARAM_SPEC (ispec);
+}
+GParamSpec*
+g_param_spec_uint16 (const gchar *name,
+		   const gchar *nick,
+		   const gchar *blurb,
+		   guint16        minimum,
+		   guint16	maximum,
+		   guint16	default_value,
+		   GParamFlags	flags)
+{
+  GParamSpecUInt16 *ispec;
+
+  g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL);
+
+  ispec = g_param_spec_internal (G_TYPE_PARAM_UINT16,
+				 name,
+				 nick,
+				 blurb,
+				 flags);
+  
+  ispec->minimum = minimum;
+  ispec->maximum = maximum;
+  ispec->default_value = default_value;
+  
+  return G_PARAM_SPEC (ispec);
+}
+GParamSpec*
+g_param_spec_int32 (const gchar *name,
+		   const gchar *nick,
+		   const gchar *blurb,
+		   gint32        minimum,
+		   gint32	maximum,
+		   gint32	default_value,
+		   GParamFlags	flags)
+{
+  GParamSpecInt32 *ispec;
+
+  g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL);
+
+  ispec = g_param_spec_internal (G_TYPE_PARAM_INT32,
+				 name,
+				 nick,
+				 blurb,
+				 flags);
+  
+  ispec->minimum = minimum;
+  ispec->maximum = maximum;
+  ispec->default_value = default_value;
+  
+  return G_PARAM_SPEC (ispec);
+}
+GParamSpec*
+g_param_spec_uint32 (const gchar *name,
+		     const gchar *nick,
+		     const gchar *blurb,
+		     guint32        minimum,
+		     guint32	maximum,
+		     guint32	default_value,
+		     GParamFlags	flags)
+{
+  GParamSpecUInt32 *ispec;
+
+  g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL);
+
+  ispec = g_param_spec_internal (G_TYPE_PARAM_UINT32,
+				 name,
+				 nick,
+				 blurb,
+				 flags);
+  
+  ispec->minimum = minimum;
+  ispec->maximum = maximum;
+  ispec->default_value = default_value;
+  
+  return G_PARAM_SPEC (ispec);
+}
+
Index: gparamspecs.h
===================================================================
RCS file: /cvs/gnome/glib/gobject/gparamspecs.h,v
retrieving revision 1.12
diff -u -r1.12 gparamspecs.h
--- gparamspecs.h	2001/06/21 00:41:55	1.12
+++ gparamspecs.h	2001/08/22 09:36:31
@@ -69,7 +69,20 @@
 #define G_IS_PARAM_SPEC_OBJECT(pspec)      (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_OBJECT))
 #define G_PARAM_SPEC_OBJECT(pspec)         (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_OBJECT, GParamSpecObject))
 
+#define G_IS_PARAM_SPEC_INT8(pspec)        (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_INT8))
+#define G_PARAM_SPEC_INT8(pspec)           (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_INT8, GParamSpecInt8))
+#define G_IS_PARAM_SPEC_UINT8(pspec)       (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_UINT8))
+#define G_PARAM_SPEC_UINT8(pspec)          (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_UINT8, GParamSpecUInt8))
+#define G_IS_PARAM_SPEC_INT16(pspec)       (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_INT16))
+#define G_PARAM_SPEC_INT16(pspec)          (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_INT16, GParamSpecInt16))
+#define G_IS_PARAM_SPEC_UINT16(pspec)      (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_UINT16))
+#define G_PARAM_SPEC_UINT16(pspec)         (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_UINT16, GParamSpecUInt16))
+#define G_IS_PARAM_SPEC_INT32(pspec)       (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_INT32))
+#define G_PARAM_SPEC_INT32(pspec)          (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_INT32, GParamSpecInt32))
+#define G_IS_PARAM_SPEC_UINT32(pspec)      (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_UINT32))
+#define G_PARAM_SPEC_UINT32(pspec)         (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_UINT32, GParamSpecUInt32))
 
+
 /* --- typedefs & structures --- */
 typedef struct _GParamSpecChar       GParamSpecChar;
 typedef struct _GParamSpecUChar      GParamSpecUChar;
@@ -90,6 +103,14 @@
 typedef struct _GParamSpecValueArray GParamSpecValueArray;
 typedef struct _GParamSpecClosure    GParamSpecClosure;
 typedef struct _GParamSpecObject     GParamSpecObject;
+typedef struct _GParamSpecInt8       GParamSpecInt8;
+typedef struct _GParamSpecUInt8      GParamSpecUInt8;
+typedef struct _GParamSpecInt16      GParamSpecInt16;
+typedef struct _GParamSpecUInt16     GParamSpecUInt16;
+typedef struct _GParamSpecInt32      GParamSpecInt32;
+typedef struct _GParamSpecUInt32     GParamSpecUInt32;
+
+
 struct _GParamSpecChar
 {
   GParamSpec    parent_instance;
@@ -219,6 +240,54 @@
 {
   GParamSpec    parent_instance;
 };
+struct _GParamSpecInt8
+{
+  GParamSpec    parent_instance;
+  
+  gint8         minimum;
+  gint8         maximum;
+  gint8         default_value;
+};
+struct _GParamSpecUInt8
+{
+  GParamSpec    parent_instance;
+  
+  guint8        minimum;
+  guint8        maximum;
+  guint8        default_value;
+};
+struct _GParamSpecInt16
+{
+  GParamSpec    parent_instance;
+  
+  gint16        minimum;
+  gint16        maximum;
+  gint16        default_value;
+};
+struct _GParamSpecUInt16
+{
+  GParamSpec    parent_instance;
+  
+  guint16       minimum;
+  guint16       maximum;
+  guint16       default_value;
+};
+struct _GParamSpecInt32
+{
+  GParamSpec    parent_instance;
+  
+  gint32        minimum;
+  gint32        maximum;
+  gint32        default_value;
+};
+struct _GParamSpecUInt32
+{
+  GParamSpec    parent_instance;
+  
+  guint32       minimum;
+  guint32       maximum;
+  guint32       default_value;
+};
 

 /* --- GParamSpec prototypes --- */
@@ -333,7 +402,48 @@
 					  const gchar	 *blurb,
 					  GType		  object_type,
 					  GParamFlags	  flags);
-
+GParamSpec*	g_param_spec_int8	 (const gchar	 *name,
+					  const gchar	 *nick,
+					  const gchar	 *blurb,
+					  gint8		  minimum,
+					  gint8		  maximum,
+					  gint8		  default_value,
+					  GParamFlags	  flags);
+GParamSpec*	g_param_spec_uint8	 (const gchar	 *name,
+					  const gchar	 *nick,
+					  const gchar	 *blurb,
+					  guint8	  minimum,
+					  guint8	  maximum,
+					  guint8	  default_value,
+					  GParamFlags	  flags);
+GParamSpec*	g_param_spec_int16	 (const gchar	 *name,
+					  const gchar	 *nick,
+					  const gchar	 *blurb,
+					  gint16       	  minimum,
+					  gint16       	  maximum,
+					  gint16       	  default_value,
+					  GParamFlags	  flags);
+GParamSpec*	g_param_spec_uint16	 (const gchar	 *name,
+					  const gchar	 *nick,
+					  const gchar	 *blurb,
+					  guint16	  minimum,
+					  guint16	  maximum,
+					  guint16	  default_value,
+					  GParamFlags	  flags);
+GParamSpec*	g_param_spec_int32	 (const gchar	 *name,
+					  const gchar	 *nick,
+					  const gchar	 *blurb,
+					  gint32       	  minimum,
+					  gint32       	  maximum,
+					  gint32       	  default_value,
+					  GParamFlags	  flags);
+GParamSpec*	g_param_spec_uint32	 (const gchar	 *name,
+					  const gchar	 *nick,
+					  const gchar	 *blurb,
+					  guint32	  minimum,
+					  guint32	  maximum,
+					  guint32	  default_value,
+					  GParamFlags	  flags);
 
 G_END_DECLS
 
Index: gtype.h
===================================================================
RCS file: /cvs/gnome/glib/gobject/gtype.h,v
retrieving revision 1.30
diff -u -r1.30 gtype.h
--- gtype.h	2001/08/15 09:19:52	1.30
+++ gtype.h	2001/08/22 09:36:31
@@ -46,6 +46,12 @@
   G_TYPE_CHAR,
   G_TYPE_UCHAR,
   G_TYPE_BOOLEAN,
+  G_TYPE_INT8,
+  G_TYPE_UINT8,
+  G_TYPE_INT16,
+  G_TYPE_UINT16,
+  G_TYPE_INT32,
+  G_TYPE_UINT32,
   G_TYPE_INT,
   G_TYPE_UINT,
   G_TYPE_LONG,
@@ -90,7 +96,14 @@
   G_TYPE_PARAM_POINTER		= G_TYPE_DERIVE_ID (G_TYPE_PARAM, 16),
   G_TYPE_PARAM_VALUE_ARRAY	= G_TYPE_DERIVE_ID (G_TYPE_PARAM, 17),
   G_TYPE_PARAM_CLOSURE		= G_TYPE_DERIVE_ID (G_TYPE_PARAM, 18),
-  G_TYPE_PARAM_OBJECT		= G_TYPE_DERIVE_ID (G_TYPE_PARAM, 19)
+  G_TYPE_PARAM_OBJECT		= G_TYPE_DERIVE_ID (G_TYPE_PARAM, 19),
+  G_TYPE_PARAM_INT8		= G_TYPE_DERIVE_ID (G_TYPE_PARAM, 20),
+  G_TYPE_PARAM_UINT8		= G_TYPE_DERIVE_ID (G_TYPE_PARAM, 21),
+  G_TYPE_PARAM_INT16		= G_TYPE_DERIVE_ID (G_TYPE_PARAM, 22),
+  G_TYPE_PARAM_UINT16		= G_TYPE_DERIVE_ID (G_TYPE_PARAM, 23),
+  G_TYPE_PARAM_INT32		= G_TYPE_DERIVE_ID (G_TYPE_PARAM, 24),
+  G_TYPE_PARAM_UINT32		= G_TYPE_DERIVE_ID (G_TYPE_PARAM, 25),
+
 } GTypeFundamentals;
 

Index: gvalue.h
===================================================================
RCS file: /cvs/gnome/glib/gobject/gvalue.h,v
retrieving revision 1.10
diff -u -r1.10 gvalue.h
--- gvalue.h	2001/03/09 21:39:51	1.10
+++ gvalue.h	2001/08/22 09:36:31
@@ -46,6 +46,15 @@
 
   /* public for GTypeValueTable methods */
   union {
+    gint8       v_int8;
+    guint8      v_uint8;
+
+    gint16      v_int16;
+    guint16     v_uint16;
+
+    gint32      v_int32;
+    guint32     v_uint32;
+
     gint	v_int;
     guint	v_uint;
     glong	v_long;
Index: gvaluecollector.h
===================================================================
RCS file: /cvs/gnome/glib/gobject/gvaluecollector.h,v
retrieving revision 1.7
diff -u -r1.7 gvaluecollector.h
--- gvaluecollector.h	2001/03/18 04:44:38	1.7
+++ gvaluecollector.h	2001/08/22 09:36:31
@@ -33,7 +33,7 @@
   G_VALUE_COLLECT_INT		= 'i',
   G_VALUE_COLLECT_LONG		= 'l',
   G_VALUE_COLLECT_DOUBLE	= 'd',
-  G_VALUE_COLLECT_POINTER	= 'p'
+  G_VALUE_COLLECT_POINTER	= 'p',
 };
 

Index: gvaluetypes.c
===================================================================
RCS file: /cvs/gnome/glib/gobject/gvaluetypes.c,v
retrieving revision 1.11
diff -u -r1.11 gvaluetypes.c
--- gvaluetypes.c	2001/03/18 04:44:38	1.11
+++ gvaluetypes.c	2001/08/22 09:36:31
@@ -483,6 +483,63 @@
     type = g_type_register_fundamental (G_TYPE_POINTER, "gpointer", &info, &finfo, 0);
     g_assert (type == G_TYPE_POINTER);
   }
+  /* G_TYPE_INT8 / G_TYPE_UINT8
+   */
+  {
+    static const GTypeValueTable value_table = {
+      value_init_long0,		/* value_init */
+      NULL,			/* value_free */
+      value_copy_long0,		/* value_copy */
+      NULL,                     /* value_peek_pointer */
+      "i",			/* collect_format */
+      value_collect_int,	/* collect_value */
+      "p",			/* lcopy_format */
+      value_lcopy_int,	        /* lcopy_value */
+    };
+    info.value_table = &value_table;
+    type = g_type_register_fundamental (G_TYPE_INT8, "gint8", &info, &finfo, 0);
+    g_assert (type == G_TYPE_INT8);
+    type = g_type_register_fundamental (G_TYPE_UINT8, "guint8", &info, &finfo, 0);
+    g_assert (type == G_TYPE_UINT8);
+  }
+  /* G_TYPE_INT16 / G_TYPE_UINT16
+   */
+  {
+    static const GTypeValueTable value_table = {
+      value_init_long0,		/* value_init */
+      NULL,			/* value_free */
+      value_copy_long0,		/* value_copy */
+      NULL,                     /* value_peek_pointer */
+      "i",			/* collect_format */
+      value_collect_int,	/* collect_value */
+      "p",			/* lcopy_format */
+      value_lcopy_int,	        /* lcopy_value */
+    };
+    info.value_table = &value_table;
+    type = g_type_register_fundamental (G_TYPE_INT16, "gint16", &info, &finfo, 0);
+    g_assert (type == G_TYPE_INT16);
+    type = g_type_register_fundamental (G_TYPE_UINT16, "guint16", &info, &finfo, 0);
+    g_assert (type == G_TYPE_UINT16);
+  }
+  /* G_TYPE_INT32 / G_TYPE_UINT32
+   */
+  {
+    static const GTypeValueTable value_table = {
+      value_init_long0,		/* value_init */
+      NULL,			/* value_free */
+      value_copy_long0,		/* value_copy */
+      NULL,                     /* value_peek_pointer */
+      "i",			/* collect_format */
+      value_collect_int,	/* collect_value */
+      "p",			/* lcopy_format */
+      value_lcopy_int,	        /* lcopy_value */
+    };
+    info.value_table = &value_table;
+    type = g_type_register_fundamental (G_TYPE_INT32, "gint32", &info, &finfo, 0);
+    g_assert (type == G_TYPE_INT32);
+    type = g_type_register_fundamental (G_TYPE_UINT32, "guint32", &info, &finfo, 0);
+    g_assert (type == G_TYPE_UINT32);
+  }
 }
 

@@ -710,6 +767,109 @@
 
   return value->data[0].v_pointer;
 }
+
+void
+g_value_set_int8 (GValue *value,
+		  gint8	v_int8)
+{
+  g_return_if_fail (G_VALUE_HOLDS_INT8 (value));
+
+  value->data[0].v_int8 = v_int8;
+}
+
+gint8
+g_value_get_int8 (const GValue *value)
+{
+  g_return_val_if_fail (G_VALUE_HOLDS_INT8 (value), 0);
+
+  return value->data[0].v_int8;
+}
+
+void
+g_value_set_uint8 (GValue *value,
+		   guint8 v_uint8)
+{
+  g_return_if_fail (G_VALUE_HOLDS_UINT8 (value));
+
+  value->data[0].v_uint8 = v_uint8;
+}
+
+guint8
+g_value_get_uint8 (const GValue *value)
+{
+  g_return_val_if_fail (G_VALUE_HOLDS_UINT8 (value), 0);
+
+  return value->data[0].v_uint8;
+}
+
+void
+g_value_set_int16 (GValue *value,
+		  gint16 v_int16)
+{
+  g_return_if_fail (G_VALUE_HOLDS_INT16 (value));
+
+  value->data[0].v_int16 = v_int16;
+}
+
+gint16
+g_value_get_int16 (const GValue *value)
+{
+  g_return_val_if_fail (G_VALUE_HOLDS_INT16 (value), 0);
+
+  return value->data[0].v_int16;
+}
+
+void
+g_value_set_uint16 (GValue *value,
+		   guint16 v_uint16)
+{
+  g_return_if_fail (G_VALUE_HOLDS_UINT16 (value));
+
+  value->data[0].v_uint16 = v_uint16;
+}
+
+guint16
+g_value_get_uint16 (const GValue *value)
+{
+  g_return_val_if_fail (G_VALUE_HOLDS_UINT16 (value), 0);
+
+  return value->data[0].v_uint16;
+}
+
+void
+g_value_set_int32 (GValue *value,
+		  gint32 v_int32)
+{
+  g_return_if_fail (G_VALUE_HOLDS_INT32 (value));
+
+  value->data[0].v_int32 = v_int32;
+}
+
+gint32
+g_value_get_int32 (const GValue *value)
+{
+  g_return_val_if_fail (G_VALUE_HOLDS_INT32 (value), 0);
+
+  return value->data[0].v_int32;
+}
+
+void
+g_value_set_uint32 (GValue *value,
+		   guint32 v_uint32)
+{
+  g_return_if_fail (G_VALUE_HOLDS_UINT32 (value));
+
+  value->data[0].v_uint32 = v_uint32;
+}
+
+guint32
+g_value_get_uint32 (const GValue *value)
+{
+  g_return_val_if_fail (G_VALUE_HOLDS_UINT32 (value), 0);
+
+  return value->data[0].v_uint32;
+}
+
 

 /* need extra includes for g_strdup_value_contents() ;( */
Index: gvaluetypes.h
===================================================================
RCS file: /cvs/gnome/glib/gobject/gvaluetypes.h,v
retrieving revision 1.10
diff -u -r1.10 gvaluetypes.h
--- gvaluetypes.h	2001/03/18 04:44:38	1.10
+++ gvaluetypes.h	2001/08/22 09:36:31
@@ -38,8 +38,16 @@
 #define G_VALUE_HOLDS_DOUBLE(value)	 (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_DOUBLE))
 #define G_VALUE_HOLDS_STRING(value)	 (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_STRING))
 #define G_VALUE_HOLDS_POINTER(value)	 (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_POINTER))
+#define G_VALUE_HOLDS_INT8(value)	 (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_INT8))
+#define G_VALUE_HOLDS_UINT8(value)	 (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_UINT8))
+#define G_VALUE_HOLDS_INT16(value)	 (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_INT16))
+#define G_VALUE_HOLDS_UINT16(value)	 (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_UINT16))
+#define G_VALUE_HOLDS_INT32(value)	 (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_INT32))
+#define G_VALUE_HOLDS_UINT32(value)	 (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_UINT32))
 

+
+
 /* --- prototypes --- */
 void		      g_value_set_char		(GValue	      *value,
 						 gchar	       v_char);
@@ -77,6 +85,24 @@
 void		      g_value_set_pointer	(GValue	      *value,
 						 gpointer      v_pointer);
 gpointer	      g_value_get_pointer	(const GValue *value);
+void		      g_value_set_int8		(GValue	      *value,
+						 gint8	       v_int8);
+gint8		      g_value_get_int8		(const GValue *value);
+void		      g_value_set_uint8		(GValue	      *value,
+						 guint8	       v_uint8);
+guint8		      g_value_get_uint8		(const GValue *value);
+void		      g_value_set_int16		(GValue	      *value,
+						 gint16	       v_int16);
+gint16		      g_value_get_int16		(const GValue *value);
+void		      g_value_set_uint16	(GValue	      *value,
+						 guint16      v_uint16);
+guint16		      g_value_get_uint16	(const GValue *value);
+void		      g_value_set_int32		(GValue	      *value,
+						 gint32	       v_int32);
+gint32		      g_value_get_int32		(const GValue *value);
+void		      g_value_set_uint32	(GValue	      *value,
+						 guint32      v_uint32);
+guint32		      g_value_get_uint32	(const GValue *value);
 

 /* debugging aid, describe value contents as string */

-- 
Mathieu Lacage <mathieu gnu org>
Portable: <lacage orange fr>





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