Add support for G_TYPE_INT64 and storing it in GValue (Patch from Mathieu

Wed Oct  3 16:02:24 2001  Owen Taylor  <otaylor@redhat.com>

	* glib-genmarshal.c gparamspecs.[ch] gvalue.h
        gobject/gvaluetypes.[ch]: Add support for G_TYPE_INT64
	and storing it in GValue (Patch from Mathieu Lacage, #59254.)
This commit is contained in:
Owen Taylor 2001-10-03 20:14:21 +00:00 committed by Owen Taylor
parent 00f672eac5
commit 791bfecb79
8 changed files with 162 additions and 2 deletions

View File

@ -1,3 +1,9 @@
Wed Oct 3 16:02:24 2001 Owen Taylor <otaylor@redhat.com>
* glib-genmarshal.c gparamspecs.[ch] gvalue.h
gobject/gvaluetypes.[ch]: Add support for G_TYPE_INT64
and storing it in GValue (Patch from Mathieu Lacage, #59254.)
2001-10-03 jacob berkman <jacob@ximian.com>
* gtype.c (type_iface_retrieve_holder_info_Wm):

View File

@ -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 }

View File

@ -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 */

View File

@ -90,6 +90,11 @@ 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
{
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,
@ -333,6 +355,20 @@ GParamSpec* g_param_spec_object (const gchar *name,
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);
G_END_DECLS

View File

@ -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;

View File

@ -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;

View File

@ -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"

View File

@ -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 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 */