summaryrefslogtreecommitdiff
path: root/gobject/gvaluetypes.c
diff options
context:
space:
mode:
authorJoshua N Pritikin <vishnu@src.gnome.org>2001-10-11 02:43:04 +0000
committerJoshua N Pritikin <vishnu@src.gnome.org>2001-10-11 02:43:04 +0000
commitd23c9a8ba863e88dd3404461302a97e559af494f (patch)
tree1dd2fb3d38f266ebd1edbadc7712c49e65b55040 /gobject/gvaluetypes.c
parent5c0d84b7e40882540b6d8c6d7d43d34958a24264 (diff)
Fill in missing support for gint64 & guint64 (#59254).
* glib-genmarshal.c gparamspecs.[ch] gtype.[ch] gvalue.h gvaluecollector.h gvaluetypes.[ch]: Fill in missing support for gint64 & guint64 (#59254). * Unconditionalize same (compile with or without G_HAVE_INT64).
Diffstat (limited to 'gobject/gvaluetypes.c')
-rw-r--r--gobject/gvaluetypes.c130
1 files changed, 94 insertions, 36 deletions
diff --git a/gobject/gvaluetypes.c b/gobject/gvaluetypes.c
index cdbcc070e..042dea2ba 100644
--- a/gobject/gvaluetypes.c
+++ b/gobject/gvaluetypes.c
@@ -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 gtype.c */
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)
{
@@ -711,42 +805,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"
#include "gparam.h"