Re: G_TYPE_INT64



On Thu, Oct 04, 2001 at 01:19:09AM -0400, Owen Taylor wrote:
> vishnu pobox com writes:
> > On Wed, Oct 03, 2001 at 04:14:44PM -0400, Owen Taylor wrote:
> > > Checked in now; if you are one of the people who have been
> > > asking for it, please test. :-)
> > 
> > Tonight's CVS gives:
> > 
> > GRuntime-WARNING **: cannot create new instance of invalid (non-instantiatable) type `<unknown>'
> 
> Could you prepare a patch that adds the missing parts from your
> patch with the int64 names?
> 
> I'll check it over for basic sanity (unless Tim beats me to it.)

Patch notes:

1) To configure.in, i added:

#define G_MININT64     $glib_mll
#define G_MAXINT64     $glib_Mll
#define G_MAXUINT64    $glib_Mull

On my system, these are aliases to constants defined in
/usr/include/limits.h:

#   define LLONG_MAX	9223372036854775807LL
#   define LLONG_MIN	(-LLONG_MAX - 1LL)
#   define ULLONG_MAX	18446744073709551615ULL

However, there appears to be some temporary confusion between glibc
and gcc because these constants only work if some extra flag is passed
to gcc, like '-std c99'.  Dunno, maybe this is correct behavior.

2) i ordered all the additions consistantly such that int64 comes
between long and unichar.  The G_PARAM_SPEC_* defines were
miss-ordered prior to my changes, so there are some additional edits
there to fix things.

3) i removed G_HAVE_GINT64 conditionalization per Tim's suggestion.

4) i tried to follow the pattern in gvaluecollector.h, but i really
have no idea if i did it correctly.  i don't understand this code and
i'm not sure how to test it.  There is related code in gvaluetypes.c
with which i have the similar reservations.  At least it compiles
cleanly.  :-/

OK to commit?

-- 
Victory to the Divine Mother!!
  http://sahajayoga.org
Index: configure.in
===================================================================
RCS file: /cvs/gnome/glib/configure.in,v
retrieving revision 1.233
diff -u -p -r1.233 configure.in
--- configure.in	2001/09/30 01:08:36	1.233
+++ configure.in	2001/10/04 17:41:54
@@ -1657,6 +1657,9 @@ G_BEGIN_DECLS
 #define G_MINLONG	$glib_ml
 #define G_MAXLONG	$glib_Ml
 #define G_MAXULONG	$glib_Mul
+#define G_MININT64	$glib_mll
+#define G_MAXINT64	$glib_Mll
+#define G_MAXUINT64	$glib_Mull
 
 _______EOF
 
@@ -1915,15 +1918,17 @@ esac
 case xyes in
 x$ac_cv_header_limits_h)
   glib_limits_h=yes
-  glib_ms=SHRT_MIN glib_Ms=SHRT_MAX glib_Mus=USHRT_MAX
-  glib_mi=INT_MIN  glib_Mi=INT_MAX  glib_Mui=UINT_MAX
-  glib_ml=LONG_MIN glib_Ml=LONG_MAX glib_Mul=ULONG_MAX
+  glib_ms=SHRT_MIN    glib_Ms=SHRT_MAX    glib_Mus=USHRT_MAX
+  glib_mi=INT_MIN     glib_Mi=INT_MAX     glib_Mui=UINT_MAX
+  glib_ml=LONG_MIN    glib_Ml=LONG_MAX    glib_Mul=ULONG_MAX
+  glib_mll=LLONG_MIN  glib_Mll=LLONG_MAX  glib_Mull=ULLONG_MAX
   ;;
 x$ac_cv_header_values_h)
   glib_values_h=yes
-  glib_ms=MINSHORT glib_Ms=MAXSHORT glib_Mus="(((gushort)G_MAXSHORT)*2+1)"
-  glib_mi=MININT   glib_Mi=MAXINT   glib_Mui="(((guint)G_MAXINT)*2+1)"
-  glib_ml=MINLONG  glib_Ml=MAXLONG  glib_Mul="(((gulong)G_MAXLONG)*2+1)"
+  glib_ms=MINSHORT   glib_Ms=MAXSHORT   glib_Mus="(((gushort)G_MAXSHORT)*2+1)"
+  glib_mi=MININT     glib_Mi=MAXINT     glib_Mui="(((guint)G_MAXINT)*2+1)"
+  glib_ml=MINLONG    glib_Ml=MAXLONG    glib_Mul="(((gulong)G_MAXLONG)*2+1)"
+  glib_mll=MINLLONG  glib_Mll=MAXLLONG  glib_Mull="(((guint64)G_MAXLLONG)*2+1)"
   ;;
 esac
 
Index: docs/reference/gobject/tmpl/types.sgml
===================================================================
RCS file: /cvs/gnome/glib/docs/reference/gobject/tmpl/types.sgml,v
retrieving revision 1.18
diff -u -p -r1.18 types.sgml
--- docs/reference/gobject/tmpl/types.sgml	2001/08/12 00:56:22	1.18
+++ docs/reference/gobject/tmpl/types.sgml	2001/10/04 17:41:55
@@ -188,6 +188,8 @@ The predefined identifiers of the reserv
 @G_TYPE_UINT: 			Identifier for the built-in type "guint".
 @G_TYPE_LONG: 			Identifier for the built-in type "glong".
 @G_TYPE_ULONG: 			Identifier for the built-in type "gulong".
+ G_TYPE_INT64: 			Identifier for the built-in type "gint64".
+ G_TYPE_UINT64: 			Identifier for the built-in type "guint64".
 @G_TYPE_ENUM: 			Identifier for the "#GEnum" type.
 @G_TYPE_FLAGS: 			Identifier for the "#GFlags" type.
 @G_TYPE_FLOAT: 			Identifier for the built-in type "gfloat".
@@ -211,6 +213,8 @@ The predefined identifiers of the reserv
 @G_TYPE_PARAM_UINT: 		Identifier for the "#GParamSpecUInt" type.
 @G_TYPE_PARAM_LONG: 		Identifier for the "#GParamSpecLong" type.
 @G_TYPE_PARAM_ULONG: 		Identifier for the "#GParamSpecULong" type.
+ G_TYPE_PARAM_INT64: 		Identifier for the "#GParamSpecInt64" type.
+ G_TYPE_PARAM_UINT64: 		Identifier for the "#GParamSpecUInt64" type.
 @G_TYPE_PARAM_UNICHAR: 
 @G_TYPE_PARAM_ENUM: 		Identifier for the "#GParamSpecEnum" type.
 @G_TYPE_PARAM_FLAGS: 		Identifier for the "#GParamSpecFlags" type.
Index: gobject/glib-genmarshal.c
===================================================================
RCS file: /cvs/gnome/glib/gobject/glib-genmarshal.c,v
retrieving revision 1.10
diff -u -p -r1.10 glib-genmarshal.c
--- gobject/glib-genmarshal.c	2001/10/03 20:14:21	1.10
+++ gobject/glib-genmarshal.c	2001/10/04 17:41:55
@@ -144,6 +144,8 @@ complete_in_arg (InArgument *iarg)
     { "UINT",		"UINT",		"guint",	"g_value_get_uint",	},
     { "LONG",		"LONG",		"glong",	"g_value_get_long",	},
     { "ULONG",		"ULONG",	"gulong",	"g_value_get_ulong",	},
+    { "INT64",		"INT64",	"gint64",       "g_value_get_int64",	},
+    { "UINT64",		"UINT64",	"guint64",	"g_value_get_uint64",	},
     { "ENUM",		"ENUM",		"gint",		"g_value_get_enum",	},
     { "FLAGS",		"FLAGS",	"guint",	"g_value_get_flags",	},
     { "FLOAT",		"FLOAT",	"gfloat",	"g_value_get_float",	},
@@ -153,10 +155,6 @@ complete_in_arg (InArgument *iarg)
     { "BOXED",		"BOXED",	"gpointer",	"g_value_get_boxed",	},
     { "POINTER",	"POINTER",	"gpointer",	"g_value_get_pointer",	},
     { "OBJECT",		"OBJECT",	"gpointer",	"g_value_get_object",	},
-#ifdef G_HAVE_GINT64
-    { "INT64",		"INT64",	"gint64",       "g_value_get_int64",	},
-    { "UINT64",		"UINT64",	"guint64",	"g_value_get_uint64",	},
-#endif /* G_HAVE_GINT64 */
     /* deprecated: */
     { "NONE",		"VOID",		"void",		NULL,			},
     { "BOOL",		"BOOLEAN",	"gboolean",	"g_value_get_boolean",	},
@@ -191,6 +189,8 @@ complete_out_arg (OutArgument *oarg)
     { "UINT",		"UINT",		"guint",	"g_value_set_uint",	NULL,			NULL          },
     { "LONG",		"LONG",		"glong",	"g_value_set_long",	NULL,			NULL          },
     { "ULONG",		"ULONG",	"gulong",	"g_value_set_ulong",	NULL,			NULL          },
+    { "INT64",		"INT64",	"gint64",	"g_value_set_int64",	NULL,			NULL          },
+    { "UINT64",		"UINT64",	"guint64",	"g_value_set_uint64",	NULL,			NULL          },
     { "ENUM",		"ENUM",		"gint",		"g_value_set_enum",	NULL,			NULL          },
     { "FLAGS",		"FLAGS",	"guint",	"g_value_set_flags",	NULL,			NULL          },
     { "FLOAT",		"FLOAT",	"gfloat",	"g_value_set_float",	NULL,			NULL          },
@@ -200,10 +200,6 @@ complete_out_arg (OutArgument *oarg)
     { "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 !="     },
-#ifdef G_HAVE_GINT64
-    { "INT64",		"INT64",	"gint64",	"g_value_set_int64",	NULL,			NULL          },
-    { "UINT64",		"UINT64",	"guint64",	"g_value_set_uint64",	NULL,			NULL          },
-#endif /* G_HAVE_GINT64 */
     /* deprecated: */
     { "NONE",		"VOID",		"void",		NULL,			NULL,			NULL          },
     { "BOOL",		"BOOLEAN",	"gboolean",	"g_value_set_boolean",	NULL,			NULL          }
Index: gobject/gparamspecs.c
===================================================================
RCS file: /cvs/gnome/glib/gobject/gparamspecs.c,v
retrieving revision 1.17
diff -u -p -r1.17 gparamspecs.c
--- gobject/gparamspecs.c	2001/10/03 20:14:21	1.17
+++ gobject/gparamspecs.c	2001/10/04 17:41:56
@@ -279,6 +279,91 @@ param_ulong_values_cmp (GParamSpec   *ps
 }
 
 static void
+param_int64_init (GParamSpec *pspec)
+{
+  GParamSpecInt64 *lspec = G_PARAM_SPEC_INT64 (pspec);
+  
+#if SIZEOF_LONG_LONG == 8
+  lspec->minimum = 0x7fffffffffffffff;
+  lspec->maximum = 0x8000000000000000;
+#else /* SIZEOF_LONG_LONG != 8 */
+  lspec->minimum = 0x7fffffff;
+  lspec->maximum = 0x80000000;
+#endif
+  lspec->default_value = 0;
+}
+
+static void
+param_int64_set_default (GParamSpec *pspec,
+			GValue     *value)
+{
+  value->data[0].v_int64 = G_PARAM_SPEC_INT64 (pspec)->default_value;
+}
+
+static gboolean
+param_int64_validate (GParamSpec *pspec,
+		     GValue     *value)
+{
+  GParamSpecInt64 *lspec = G_PARAM_SPEC_INT64 (pspec);
+  gint64 oval = value->data[0].v_int64;
+  
+  value->data[0].v_int64 = CLAMP (value->data[0].v_int64, lspec->minimum, lspec->maximum);
+  
+  return value->data[0].v_int64 != oval;
+}
+
+static gint
+param_int64_values_cmp (GParamSpec   *pspec,
+		       const GValue *value1,
+		       const GValue *value2)
+{
+  if (value1->data[0].v_int64 < value2->data[0].v_int64)
+    return -1;
+  else
+    return value1->data[0].v_int64 > value2->data[0].v_int64;
+}
+
+static void
+param_uint64_init (GParamSpec *pspec)
+{
+  GParamSpecUInt64 *uspec = G_PARAM_SPEC_UINT64 (pspec);
+  
+  uspec->minimum = 0;
+  uspec->maximum = ~0;
+  uspec->default_value = 0;
+}
+
+static void
+param_uint64_set_default (GParamSpec *pspec,
+			 GValue     *value)
+{
+  value->data[0].v_uint64 = G_PARAM_SPEC_UINT64 (pspec)->default_value;
+}
+
+static gboolean
+param_uint64_validate (GParamSpec *pspec,
+		      GValue     *value)
+{
+  GParamSpecUInt64 *uspec = G_PARAM_SPEC_UINT64 (pspec);
+  guint64 oval = value->data[0].v_uint64;
+  
+  value->data[0].v_uint64 = CLAMP (value->data[0].v_uint64, uspec->minimum, uspec->maximum);
+  
+  return value->data[0].v_uint64 != oval;
+}
+
+static gint
+param_uint64_values_cmp (GParamSpec   *pspec,
+			const GValue *value1,
+			const GValue *value2)
+{
+  if (value1->data[0].v_uint64 < value2->data[0].v_uint64)
+    return -1;
+  else
+    return value1->data[0].v_uint64 > value2->data[0].v_uint64;
+}
+
+static void
 param_unichar_init (GParamSpec *pspec)
 {
   GParamSpecUnichar *uspec = G_PARAM_SPEC_UNICHAR (pspec);
@@ -1042,6 +1127,40 @@ g_param_spec_types_init (void)	/* sync w
     g_assert (type == G_TYPE_PARAM_ULONG);
   }
 
+  /* G_TYPE_PARAM_INT64
+   */
+  {
+    static const GParamSpecTypeInfo pspec_info = {
+      sizeof (GParamSpecInt64),  /* instance_size */
+      16,                       /* n_preallocs */
+      param_int64_init,         /* instance_init */
+      G_TYPE_INT64,		/* value_type */
+      NULL,			/* finalize */
+      param_int64_set_default,	/* value_set_default */
+      param_int64_validate,	/* value_validate */
+      param_int64_values_cmp,	/* values_cmp */
+    };
+    type = g_param_type_register_static ("GParamInt64", &pspec_info);
+    g_assert (type == G_TYPE_PARAM_INT64);
+  }
+  
+  /* G_TYPE_PARAM_UINT64
+   */
+  {
+    static const GParamSpecTypeInfo pspec_info = {
+      sizeof (GParamSpecUInt64), /* instance_size */
+      16,                       /* n_preallocs */
+      param_uint64_init,        /* instance_init */
+      G_TYPE_UINT64,		/* value_type */
+      NULL,			/* finalize */
+      param_uint64_set_default,	/* value_set_default */
+      param_uint64_validate,	/* value_validate */
+      param_uint64_values_cmp,	/* values_cmp */
+    };
+    type = g_param_type_register_static ("GParamUInt64", &pspec_info);
+    g_assert (type == G_TYPE_PARAM_UINT64);
+  }
+
   /* G_TYPE_PARAM_UNICHAR
    */
   {
@@ -1428,6 +1547,58 @@ g_param_spec_ulong (const gchar *name,
 }
 
 GParamSpec*
+g_param_spec_int64 (const gchar *name,
+		   const gchar *nick,
+		   const gchar *blurb,
+		   gint64	minimum,
+		   gint64	maximum,
+		   gint64	default_value,
+		   GParamFlags	flags)
+{
+  GParamSpecInt64 *lspec;
+
+  g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL);
+
+  lspec = g_param_spec_internal (G_TYPE_PARAM_INT64,
+				 name,
+				 nick,
+				 blurb,
+				 flags);
+  
+  lspec->minimum = minimum;
+  lspec->maximum = maximum;
+  lspec->default_value = default_value;
+  
+  return G_PARAM_SPEC (lspec);
+}
+
+GParamSpec*
+g_param_spec_uint64 (const gchar *name,
+		    const gchar *nick,
+		    const gchar *blurb,
+		    guint64	 minimum,
+		    guint64	 maximum,
+		    guint64	 default_value,
+		    GParamFlags	 flags)
+{
+  GParamSpecUInt64 *uspec;
+
+  g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL);
+
+  uspec = g_param_spec_internal (G_TYPE_PARAM_UINT64,
+				 name,
+				 nick,
+				 blurb,
+				 flags);
+  
+  uspec->minimum = minimum;
+  uspec->maximum = maximum;
+  uspec->default_value = default_value;
+  
+  return G_PARAM_SPEC (uspec);
+}
+
+GParamSpec*
 g_param_spec_unichar (const gchar *name,
 		      const gchar *nick,
 		      const gchar *blurb,
@@ -1698,59 +1869,3 @@ g_param_spec_object (const gchar *name,
   
   return G_PARAM_SPEC (ospec);
 }
-
-#ifdef G_HAVE_GINT64
-
-GParamSpec*
-g_param_spec_int64 (const gchar *name,
-		   const gchar *nick,
-		   const gchar *blurb,
-		   gint64        minimum,
-		   gint64	maximum,
-		   gint64	default_value,
-		   GParamFlags	flags)
-{
-  GParamSpecInt64 *ispec;
-
-  g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL);
-
-  ispec = g_param_spec_internal (G_TYPE_PARAM_INT64,
-				 name,
-				 nick,
-				 blurb,
-				 flags);
-  
-  ispec->minimum = minimum;
-  ispec->maximum = maximum;
-  ispec->default_value = default_value;
-  
-  return G_PARAM_SPEC (ispec);
-}
-
-GParamSpec*
-g_param_spec_uint64 (const gchar *name,
-		   const gchar *nick,
-		   const gchar *blurb,
-		   guint64        minimum,
-		   guint64	maximum,
-		   guint64	default_value,
-		   GParamFlags	flags)
-{
-  GParamSpecUInt64 *ispec;
-
-  g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL);
-
-  ispec = g_param_spec_internal (G_TYPE_PARAM_UINT64,
-				 name,
-				 nick,
-				 blurb,
-				 flags);
-  
-  ispec->minimum = minimum;
-  ispec->maximum = maximum;
-  ispec->default_value = default_value;
-  
-  return G_PARAM_SPEC (ispec);
-}
-
-#endif /* G_HAVE_GINT64 */
Index: gobject/gparamspecs.h
===================================================================
RCS file: /cvs/gnome/glib/gobject/gparamspecs.h,v
retrieving revision 1.14
diff -u -p -r1.14 gparamspecs.h
--- gobject/gparamspecs.h	2001/10/04 05:13:12	1.14
+++ gobject/gparamspecs.h	2001/10/04 17:41:56
@@ -43,9 +43,13 @@ G_BEGIN_DECLS
 #define G_IS_PARAM_SPEC_LONG(pspec)        (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_LONG))
 #define G_PARAM_SPEC_LONG(pspec)           (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_LONG, GParamSpecLong))
 #define G_IS_PARAM_SPEC_ULONG(pspec)       (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_ULONG))
-#define G_PARAM_SPEC_UNICHAR(pspec)        (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_UNICHAR, GParamSpecUnichar))
-#define G_IS_PARAM_SPEC_UNICHAR(pspec)     (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_UNICHAR))
 #define G_PARAM_SPEC_ULONG(pspec)          (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_ULONG, GParamSpecULong))
+#define G_IS_PARAM_SPEC_INT64(pspec)        (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_INT64))
+#define G_PARAM_SPEC_INT64(pspec)           (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_INT64, GParamSpecInt64))
+#define G_IS_PARAM_SPEC_UINT64(pspec)       (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_UINT64))
+#define G_PARAM_SPEC_UINT64(pspec)          (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_UINT64, GParamSpecUInt64))
+#define G_IS_PARAM_SPEC_UNICHAR(pspec)     (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_UNICHAR))
+#define G_PARAM_SPEC_UNICHAR(pspec)        (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_UNICHAR, GParamSpecUnichar))
 #define G_IS_PARAM_SPEC_ENUM(pspec)        (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_ENUM))
 #define G_PARAM_SPEC_ENUM(pspec)           (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_ENUM, GParamSpecEnum))
 #define G_IS_PARAM_SPEC_FLAGS(pspec)       (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_FLAGS))
@@ -78,6 +82,8 @@ typedef struct _GParamSpecInt        GPa
 typedef struct _GParamSpecUInt       GParamSpecUInt;
 typedef struct _GParamSpecLong       GParamSpecLong;
 typedef struct _GParamSpecULong      GParamSpecULong;
+typedef struct _GParamSpecInt64      GParamSpecInt64;
+typedef struct _GParamSpecUInt64     GParamSpecUInt64;
 typedef struct _GParamSpecUnichar    GParamSpecUnichar;
 typedef struct _GParamSpecEnum       GParamSpecEnum;
 typedef struct _GParamSpecFlags      GParamSpecFlags;
@@ -90,10 +96,6 @@ typedef struct _GParamSpecPointer    GPa
 typedef struct _GParamSpecValueArray GParamSpecValueArray;
 typedef struct _GParamSpecClosure    GParamSpecClosure;
 typedef struct _GParamSpecObject     GParamSpecObject;
-#ifdef G_HAVE_GINT64
-typedef struct _GParamSpecInt64      GParamSpecInt64;
-typedef struct _GParamSpecUInt64     GParamSpecUInt64;
-#endif /* G_HAVE_GINT64 */
 
 struct _GParamSpecChar
 {
@@ -149,6 +151,22 @@ struct _GParamSpecULong
   gulong        maximum;
   gulong        default_value;
 };
+struct _GParamSpecInt64
+{
+  GParamSpec    parent_instance;
+  
+  gint64        minimum;
+  gint64        maximum;
+  gint64        default_value;
+};
+struct _GParamSpecUInt64
+{
+  GParamSpec    parent_instance;
+  
+  guint64       minimum;
+  guint64       maximum;
+  guint64       default_value;
+};
 struct _GParamSpecUnichar
 {
   GParamSpec    parent_instance;
@@ -224,24 +242,6 @@ struct _GParamSpecObject
 {
   GParamSpec    parent_instance;
 };
-#ifdef G_HAVE_GINT64
-struct _GParamSpecInt64
-{
-  GParamSpec    parent_instance;
-  
-  gint64        minimum;
-  gint64        maximum;
-  gint64        default_value;
-};
-struct _GParamSpecUInt64
-{
-  GParamSpec    parent_instance;
-  
-  guint64       minimum;
-  guint64       maximum;
-  guint64       default_value;
-};
-#endif /* G_HAVE_GINT64 */
 
 /* --- GParamSpec prototypes --- */
 GParamSpec*	g_param_spec_char	 (const gchar	 *name,
@@ -291,6 +291,20 @@ GParamSpec*	g_param_spec_ulong	 (const g
 					  gulong	  maximum,
 					  gulong	  default_value,
 					  GParamFlags	  flags);
+GParamSpec*	g_param_spec_int64	 (const gchar	 *name,
+					  const gchar	 *nick,
+					  const gchar	 *blurb,
+					  gint64       	  minimum,
+					  gint64       	  maximum,
+					  gint64       	  default_value,
+					  GParamFlags	  flags);
+GParamSpec*	g_param_spec_uint64	 (const gchar	 *name,
+					  const gchar	 *nick,
+					  const gchar	 *blurb,
+					  guint64	  minimum,
+					  guint64	  maximum,
+					  guint64	  default_value,
+					  GParamFlags	  flags);
 GParamSpec*    g_param_spec_unichar      (const gchar    *name,
 				          const gchar    *nick,
 				          const gchar    *blurb,
@@ -355,23 +369,6 @@ GParamSpec*	g_param_spec_object	 (const 
 					  const gchar	 *blurb,
 					  GType		  object_type,
 					  GParamFlags	  flags);
-
-#ifdef G_HAVE_GINT64
-GParamSpec*	g_param_spec_int64	 (const gchar	 *name,
-					  const gchar	 *nick,
-					  const gchar	 *blurb,
-					  gint64       	  minimum,
-					  gint64       	  maximum,
-					  gint64       	  default_value,
-					  GParamFlags	  flags);
-GParamSpec*	g_param_spec_uint64	 (const gchar	 *name,
-					  const gchar	 *nick,
-					  const gchar	 *blurb,
-					  guint64	  minimum,
-					  guint64	  maximum,
-					  guint64	  default_value,
-					  GParamFlags	  flags);
-#endif /* G_HAVE_GINT64 */
 
 G_END_DECLS
 
Index: gobject/gtype.c
===================================================================
RCS file: /cvs/gnome/glib/gobject/gtype.c,v
retrieving revision 1.34
diff -u -p -r1.34 gtype.c
--- gobject/gtype.c	2001/10/03 19:46:05	1.34
+++ gobject/gtype.c	2001/10/04 17:41:56
@@ -629,8 +629,8 @@ check_collect_format_I (const gchar *col
 {
   const gchar *p = collect_format;
   gchar valid_format[] = { G_VALUE_COLLECT_INT, G_VALUE_COLLECT_LONG,
-			   G_VALUE_COLLECT_DOUBLE, G_VALUE_COLLECT_POINTER,
-			   0 };
+			   G_VALUE_COLLECT_INT64, G_VALUE_COLLECT_DOUBLE,
+			   G_VALUE_COLLECT_POINTER, 0 };
 
   while (*p)
     if (!strchr (valid_format, *p++))
Index: gobject/gtype.h
===================================================================
RCS file: /cvs/gnome/glib/gobject/gtype.h,v
retrieving revision 1.32
diff -u -p -r1.32 gtype.h
--- gobject/gtype.h	2001/10/03 20:14:21	1.32
+++ gobject/gtype.h	2001/10/04 17:41:56
@@ -81,20 +81,20 @@ typedef enum    /*< skip >*/
   G_TYPE_PARAM_UINT		= G_TYPE_DERIVE_ID (G_TYPE_PARAM, 5),
   G_TYPE_PARAM_LONG		= G_TYPE_DERIVE_ID (G_TYPE_PARAM, 6),
   G_TYPE_PARAM_ULONG		= G_TYPE_DERIVE_ID (G_TYPE_PARAM, 7),
-  G_TYPE_PARAM_UNICHAR		= G_TYPE_DERIVE_ID (G_TYPE_PARAM, 8),
-  G_TYPE_PARAM_ENUM		= G_TYPE_DERIVE_ID (G_TYPE_PARAM, 9),
-  G_TYPE_PARAM_FLAGS		= G_TYPE_DERIVE_ID (G_TYPE_PARAM, 10),
-  G_TYPE_PARAM_FLOAT		= G_TYPE_DERIVE_ID (G_TYPE_PARAM, 11),
-  G_TYPE_PARAM_DOUBLE		= G_TYPE_DERIVE_ID (G_TYPE_PARAM, 12),
-  G_TYPE_PARAM_STRING		= G_TYPE_DERIVE_ID (G_TYPE_PARAM, 13),
-  G_TYPE_PARAM_PARAM		= G_TYPE_DERIVE_ID (G_TYPE_PARAM, 14),
-  G_TYPE_PARAM_BOXED		= G_TYPE_DERIVE_ID (G_TYPE_PARAM, 15),
-  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_INT64		= G_TYPE_DERIVE_ID (G_TYPE_PARAM, 20),
-  G_TYPE_PARAM_UINT64		= G_TYPE_DERIVE_ID (G_TYPE_PARAM, 21)
+  G_TYPE_PARAM_INT64		= G_TYPE_DERIVE_ID (G_TYPE_PARAM, 8),
+  G_TYPE_PARAM_UINT64		= G_TYPE_DERIVE_ID (G_TYPE_PARAM, 9),
+  G_TYPE_PARAM_UNICHAR		= G_TYPE_DERIVE_ID (G_TYPE_PARAM, 10),
+  G_TYPE_PARAM_ENUM		= G_TYPE_DERIVE_ID (G_TYPE_PARAM, 11),
+  G_TYPE_PARAM_FLAGS		= G_TYPE_DERIVE_ID (G_TYPE_PARAM, 12),
+  G_TYPE_PARAM_FLOAT		= G_TYPE_DERIVE_ID (G_TYPE_PARAM, 13),
+  G_TYPE_PARAM_DOUBLE		= G_TYPE_DERIVE_ID (G_TYPE_PARAM, 14),
+  G_TYPE_PARAM_STRING		= G_TYPE_DERIVE_ID (G_TYPE_PARAM, 15),
+  G_TYPE_PARAM_PARAM		= G_TYPE_DERIVE_ID (G_TYPE_PARAM, 16),
+  G_TYPE_PARAM_BOXED		= G_TYPE_DERIVE_ID (G_TYPE_PARAM, 17),
+  G_TYPE_PARAM_POINTER		= G_TYPE_DERIVE_ID (G_TYPE_PARAM, 18),
+  G_TYPE_PARAM_VALUE_ARRAY	= G_TYPE_DERIVE_ID (G_TYPE_PARAM, 19),
+  G_TYPE_PARAM_CLOSURE		= G_TYPE_DERIVE_ID (G_TYPE_PARAM, 20),
+  G_TYPE_PARAM_OBJECT		= G_TYPE_DERIVE_ID (G_TYPE_PARAM, 21)
 
 } GTypeFundamentals;
 
Index: gobject/gvalue.h
===================================================================
RCS file: /cvs/gnome/glib/gobject/gvalue.h,v
retrieving revision 1.11
diff -u -p -r1.11 gvalue.h
--- gobject/gvalue.h	2001/10/03 20:14:21	1.11
+++ gobject/gvalue.h	2001/10/04 17:41:56
@@ -50,10 +50,8 @@ struct _GValue
     guint	v_uint;
     glong	v_long;
     gulong	v_ulong;
-#ifdef G_HAVE_GINT64
     gint64      v_int64;
     guint64     v_uint64;
-#endif /* G_HAVE_GINT64 */
     gfloat	v_float;
     gdouble	v_double;
     gpointer	v_pointer;
Index: gobject/gvaluecollector.h
===================================================================
RCS file: /cvs/gnome/glib/gobject/gvaluecollector.h,v
retrieving revision 1.7
diff -u -p -r1.7 gvaluecollector.h
--- gobject/gvaluecollector.h	2001/03/18 04:44:38	1.7
+++ gobject/gvaluecollector.h	2001/10/04 17:41:56
@@ -32,6 +32,7 @@ enum	/*< skip >*/
 {
   G_VALUE_COLLECT_INT		= 'i',
   G_VALUE_COLLECT_LONG		= 'l',
+  G_VALUE_COLLECT_INT64         = 'q',
   G_VALUE_COLLECT_DOUBLE	= 'd',
   G_VALUE_COLLECT_POINTER	= 'p'
 };
@@ -43,6 +44,7 @@ union _GTypeCValue
 {
   gint     v_int;
   glong    v_long;
+  gint64   v_int64;
   gdouble  v_double;
   gpointer v_pointer;
 };
@@ -84,6 +86,9 @@ G_STMT_START {										\
 	case G_VALUE_COLLECT_LONG:							\
 	  _cvalue->v_long = va_arg ((var_args), glong);					\
 	  break;									\
+	case G_VALUE_COLLECT_INT64:							\
+	  _cvalue->v_int64 = va_arg ((var_args), gint64);					\
+	  break;									\
 	case G_VALUE_COLLECT_DOUBLE:							\
 	  _cvalue->v_double = va_arg ((var_args), gdouble);				\
 	  break;									\
@@ -125,6 +130,9 @@ G_STMT_START {										\
 	  break;									\
 	case G_VALUE_COLLECT_LONG:							\
 	  _cvalue->v_long = va_arg ((var_args), glong);					\
+	  break;									\
+	case G_VALUE_COLLECT_INT64:							\
+	  _cvalue->v_int64 = va_arg ((var_args), gint64);					\
 	  break;									\
 	case G_VALUE_COLLECT_DOUBLE:							\
 	  _cvalue->v_double = va_arg ((var_args), gdouble);				\
Index: gobject/gvaluetypes.c
===================================================================
RCS file: /cvs/gnome/glib/gobject/gvaluetypes.c,v
retrieving revision 1.12
diff -u -p -r1.12 gvaluetypes.c
--- gobject/gvaluetypes.c	2001/10/03 20:14:21	1.12
+++ gobject/gvaluetypes.c	2001/10/04 17:41:57
@@ -129,6 +129,46 @@ value_lcopy_long (const GValue *value,
 }
 
 static void
+value_init_int64 (GValue *value)
+{
+  value->data[0].v_int64 = 0;
+}
+
+static void
+value_copy_int64 (const GValue *src_value,
+		 GValue       *dest_value)
+{
+  dest_value->data[0].v_int64 = src_value->data[0].v_int64;
+}
+
+static gchar*
+value_collect_int64 (GValue      *value,
+		    guint        n_collect_values,
+		    GTypeCValue *collect_values,
+		    guint        collect_flags)
+{
+  value->data[0].v_int64 = collect_values[0].v_int64;
+  
+  return NULL;
+}
+
+static gchar*
+value_lcopy_int64 (const GValue *value,
+		  guint         n_collect_values,
+		  GTypeCValue  *collect_values,
+		  guint         collect_flags)
+{
+  gint64 *int64_p = collect_values[0].v_pointer;
+  
+  if (!int64_p)
+    return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
+  
+  *int64_p = value->data[0].v_int64;
+  
+  return NULL;
+}
+
+static void
 value_init_float (GValue *value)
 {
   value->data[0].v_float = 0.0;
@@ -412,6 +452,26 @@ g_value_types_init (void)  /* sync with 
     g_assert (type == G_TYPE_ULONG);
   }
   
+  /* G_TYPE_INT64 / G_TYPE_UINT64
+   */
+  {
+    static const GTypeValueTable value_table = {
+      value_init_int64,		/* value_init */
+      NULL,			/* value_free */
+      value_copy_int64,		/* value_copy */
+      NULL,                     /* value_peek_pointer */
+      "q",			/* collect_format */
+      value_collect_int64,	/* collect_value */
+      "p",			/* lcopy_format */
+      value_lcopy_int64,		/* lcopy_value */
+    };
+    info.value_table = &value_table;
+    type = g_type_register_fundamental (G_TYPE_INT64, "gint64", &info, &finfo, 0);
+    g_assert (type == G_TYPE_INT64);
+    type = g_type_register_fundamental (G_TYPE_UINT64, "guint64", &info, &finfo, 0);
+    g_assert (type == G_TYPE_UINT64);
+  }
+  
   /* G_TYPE_FLOAT
    */
   {
@@ -607,6 +667,40 @@ g_value_get_ulong (const GValue *value)
 }
 
 void
+g_value_set_int64 (GValue *value,
+		  gint64	  v_int64)
+{
+  g_return_if_fail (G_VALUE_HOLDS_INT64 (value));
+  
+  value->data[0].v_int64 = v_int64;
+}
+
+gint64
+g_value_get_int64 (const GValue *value)
+{
+  g_return_val_if_fail (G_VALUE_HOLDS_INT64 (value), 0);
+  
+  return value->data[0].v_int64;
+}
+
+void
+g_value_set_uint64 (GValue *value,
+		   guint64  v_uint64)
+{
+  g_return_if_fail (G_VALUE_HOLDS_UINT64 (value));
+  
+  value->data[0].v_uint64 = v_uint64;
+}
+
+guint64
+g_value_get_uint64 (const GValue *value)
+{
+  g_return_val_if_fail (G_VALUE_HOLDS_UINT64 (value), 0);
+  
+  return value->data[0].v_uint64;
+}
+
+void
 g_value_set_float (GValue *value,
 		   gfloat  v_float)
 {
@@ -710,42 +804,6 @@ g_value_get_pointer (const GValue *value
 
   return value->data[0].v_pointer;
 }
-
-#ifdef G_HAVE_GINT64
-void
-g_value_set_int64 (GValue *value,
-		  gint64 v_int64)
-{
-  g_return_if_fail (G_VALUE_HOLDS_INT64 (value));
-
-  value->data[0].v_int64 = v_int64;
-}
-
-gint64
-g_value_get_int64 (const GValue *value)
-{
-  g_return_val_if_fail (G_VALUE_HOLDS_INT64 (value), 0);
-
-  return value->data[0].v_int64;
-}
-
-void
-g_value_set_uint64 (GValue *value,
-		   guint64 v_uint64)
-{
-  g_return_if_fail (G_VALUE_HOLDS_UINT64 (value));
-
-  value->data[0].v_uint64 = v_uint64;
-}
-
-guint64
-g_value_get_uint64 (const GValue *value)
-{
-  g_return_val_if_fail (G_VALUE_HOLDS_UINT64 (value), 0);
-
-  return value->data[0].v_uint64;
-}
-#endif /* G_HAVE_GINT64 */
 
 /* need extra includes for g_strdup_value_contents() ;( */
 #include "gobject.h"
Index: gobject/gvaluetypes.h
===================================================================
RCS file: /cvs/gnome/glib/gobject/gvaluetypes.h,v
retrieving revision 1.11
diff -u -p -r1.11 gvaluetypes.h
--- gobject/gvaluetypes.h	2001/10/03 20:14:21	1.11
+++ gobject/gvaluetypes.h	2001/10/04 17:41:57
@@ -34,12 +34,12 @@ G_BEGIN_DECLS
 #define G_VALUE_HOLDS_UINT(value)	 (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_UINT))
 #define G_VALUE_HOLDS_LONG(value)	 (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_LONG))
 #define G_VALUE_HOLDS_ULONG(value)	 (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_ULONG))
+#define G_VALUE_HOLDS_INT64(value)	 (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_INT64))
+#define G_VALUE_HOLDS_UINT64(value)	 (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_UINT64))
 #define G_VALUE_HOLDS_FLOAT(value)	 (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_FLOAT))
 #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_INT64(value)	 (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_INT64))
-#define G_VALUE_HOLDS_UINT64(value)	 (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_UINT64))
 
 
 /* --- prototypes --- */
@@ -64,6 +64,12 @@ glong		      g_value_get_long		(const GV
 void		      g_value_set_ulong		(GValue	      *value,
 						 gulong	       v_ulong);
 gulong		      g_value_get_ulong		(const GValue *value);
+void		      g_value_set_int64		(GValue	      *value,
+						 gint64	       v_int64);
+gint64		      g_value_get_int64		(const GValue *value);
+void		      g_value_set_uint64	(GValue	      *value,
+						 guint64      v_uint64);
+guint64		      g_value_get_uint64	(const GValue *value);
 void		      g_value_set_float		(GValue	      *value,
 						 gfloat	       v_float);
 gfloat		      g_value_get_float		(const GValue *value);
@@ -79,14 +85,6 @@ gchar*		      g_value_dup_string	(const 
 void		      g_value_set_pointer	(GValue	      *value,
 						 gpointer      v_pointer);
 gpointer	      g_value_get_pointer	(const GValue *value);
-#ifdef G_HAVE_GINT64
-void		      g_value_set_int64		(GValue	      *value,
-						 gint64	       v_int64);
-gint64		      g_value_get_int64		(const GValue *value);
-void		      g_value_set_uint64	(GValue	      *value,
-						 guint64      v_uint64);
-guint64		      g_value_get_uint64	(const GValue *value);
-#endif /* G_HAVE_GINT64 */
 
 
 /* debugging aid, describe value contents as string */


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