G_TYPE_INT64
- From: Owen Taylor <otaylor redhat com>
- To: gtk-devel-list gnome org
- Cc: timj gtk org
- Subject: G_TYPE_INT64
- Date: 01 Oct 2001 17:04:54 -0400
I'd like to commit the following patch to add G_TYPE_INT64 and
resolve bug #59254.
- I've gone with int64 as a name, because:
- I think it is the right thing to do. (See my earlier mails.)
- There were no decent names proposed as an alternative.
(G_TYPE_LONGLONG would only make sense if we had glonglong,
most of the rest were worse.)
- The support is conditionlized on the idea that if you don't have int64
support, there is nothing you can do about it, so we might as
well allow you to build the parts of GLib you can.
(This is different from something like iconv() or gettext() where
you can install an additional library to get the functionality.)
- The unconditionized parts are intentionally left unconditionalized
so that enum values don't depend on whether you have int64 support
or not.
I'd like to commit within the next day or two, so please get back
to me quickly if you have problems with the change or the
patch.
(The patch is Mathieu's, conditionalized with G_HAVE_GINT64, and
with int8/16/32 support removed.)
Regards,
Owen
Index: glib-genmarshal.c
===================================================================
RCS file: /cvs/gnome/glib/gobject/glib-genmarshal.c,v
retrieving revision 1.9
diff -u -p -r1.9 glib-genmarshal.c
--- glib-genmarshal.c 2001/07/26 10:36:01 1.9
+++ glib-genmarshal.c 2001/10/01 21:03:56
@@ -153,6 +153,10 @@ 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", },
@@ -196,6 +200,10 @@ 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: gparamspecs.c
===================================================================
RCS file: /cvs/gnome/glib/gobject/gparamspecs.c,v
retrieving revision 1.16
diff -u -p -r1.16 gparamspecs.c
--- gparamspecs.c 2001/05/10 13:58:40 1.16
+++ gparamspecs.c 2001/10/01 21:03:56
@@ -1698,3 +1698,59 @@ 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: gparamspecs.h
===================================================================
RCS file: /cvs/gnome/glib/gobject/gparamspecs.h,v
retrieving revision 1.12
diff -u -p -r1.12 gparamspecs.h
--- gparamspecs.h 2001/06/21 00:41:55 1.12
+++ gparamspecs.h 2001/10/01 21:03:56
@@ -90,6 +90,11 @@ 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
{
GParamSpec parent_instance;
@@ -219,7 +224,24 @@ 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,
@@ -332,6 +354,20 @@ GParamSpec* g_param_spec_object (const
const gchar *nick,
const gchar *blurb,
GType object_type,
+ 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);
Index: gtype.h
===================================================================
RCS file: /cvs/gnome/glib/gobject/gtype.h,v
retrieving revision 1.31
diff -u -p -r1.31 gtype.h
--- gtype.h 2001/09/10 18:03:31 1.31
+++ gtype.h 2001/10/01 21:03:56
@@ -50,6 +50,8 @@ typedef enum /*< skip >*/
G_TYPE_UINT,
G_TYPE_LONG,
G_TYPE_ULONG,
+ G_TYPE_INT64,
+ G_TYPE_UINT64,
G_TYPE_ENUM,
G_TYPE_FLAGS,
G_TYPE_FLOAT,
@@ -90,7 +92,10 @@ typedef enum /*< skip >*/
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_INT64 = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 20),
+ G_TYPE_PARAM_UINT64 = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 21)
+
} GTypeFundamentals;
Index: gvalue.h
===================================================================
RCS file: /cvs/gnome/glib/gobject/gvalue.h,v
retrieving revision 1.10
diff -u -p -r1.10 gvalue.h
--- gvalue.h 2001/03/09 21:39:51 1.10
+++ gvalue.h 2001/10/01 21:03:56
@@ -50,6 +50,10 @@ 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: gvaluetypes.c
===================================================================
RCS file: /cvs/gnome/glib/gobject/gvaluetypes.c,v
retrieving revision 1.11
diff -u -p -r1.11 gvaluetypes.c
--- gvaluetypes.c 2001/03/18 04:44:38 1.11
+++ gvaluetypes.c 2001/10/01 21:03:56
@@ -711,6 +711,41 @@ 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: gvaluetypes.h
===================================================================
RCS file: /cvs/gnome/glib/gobject/gvaluetypes.h,v
retrieving revision 1.10
diff -u -p -r1.10 gvaluetypes.h
--- gvaluetypes.h 2001/03/18 04:44:38 1.10
+++ gvaluetypes.h 2001/10/01 21:03:56
@@ -38,6 +38,8 @@ G_BEGIN_DECLS
#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 --- */
@@ -77,6 +79,14 @@ 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]