mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-10 03:16:17 +01:00
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).
This commit is contained in:
parent
5c0d84b7e4
commit
d23c9a8ba8
@ -1,3 +1,11 @@
|
||||
Wed Oct 10 17:25:22 2001 Joshua N Pritikin <vishnu@pobox.com>
|
||||
|
||||
* 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).
|
||||
|
||||
Wed Oct 10 15:38:58 2001 Joshua N Pritikin <vishnu@pobox.com>
|
||||
|
||||
* gparamspecs.h (G_IS_PARAM_SPEC_FLAGS): Fix order of
|
||||
|
@ -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 }
|
||||
|
@ -278,6 +278,86 @@ param_ulong_values_cmp (GParamSpec *pspec,
|
||||
return value1->data[0].v_ulong > value2->data[0].v_ulong;
|
||||
}
|
||||
|
||||
static void
|
||||
param_int64_init (GParamSpec *pspec)
|
||||
{
|
||||
GParamSpecInt64 *lspec = G_PARAM_SPEC_INT64 (pspec);
|
||||
|
||||
lspec->minimum = G_MININT64;
|
||||
lspec->maximum = G_MAXINT64;
|
||||
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 = G_MAXUINT64;
|
||||
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)
|
||||
{
|
||||
@ -1042,6 +1122,40 @@ g_param_spec_types_init (void) /* sync with gtype.c */
|
||||
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
|
||||
*/
|
||||
{
|
||||
@ -1427,6 +1541,58 @@ g_param_spec_ulong (const gchar *name,
|
||||
return G_PARAM_SPEC (uspec);
|
||||
}
|
||||
|
||||
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,
|
||||
@ -1698,59 +1864,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 */
|
||||
|
@ -44,6 +44,10 @@ G_BEGIN_DECLS
|
||||
#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_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_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_IS_PARAM_SPEC_ENUM(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_ENUM))
|
||||
@ -78,6 +82,8 @@ typedef struct _GParamSpecInt GParamSpecInt;
|
||||
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 GParamSpecPointer;
|
||||
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 gchar *name,
|
||||
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,
|
||||
@ -356,23 +370,6 @@ GParamSpec* g_param_spec_object (const gchar *name,
|
||||
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
|
||||
|
||||
#endif /* __G_PARAMSPECS_H__ */
|
||||
|
@ -629,8 +629,8 @@ check_collect_format_I (const gchar *collect_format)
|
||||
{
|
||||
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++))
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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; \
|
||||
@ -126,6 +131,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; \
|
||||
|
@ -128,6 +128,46 @@ value_lcopy_long (const GValue *value,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
@ -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
|
||||
*/
|
||||
{
|
||||
@ -606,6 +666,40 @@ g_value_get_ulong (const GValue *value)
|
||||
return value->data[0].v_ulong;
|
||||
}
|
||||
|
||||
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"
|
||||
|
@ -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 GValue *value);
|
||||
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 GValue *value);
|
||||
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 */
|
||||
|
Loading…
Reference in New Issue
Block a user