add a new param spec to handle interfaces.

Mon Mar  5 15:26:30 2001  Jonathan Blandford  <jrb@redhat.com>

	* gparamspecs.c (g_param_spec_interface): add a new param spec to
	handle interfaces.
This commit is contained in:
Jonathan Blandford 2001-03-06 00:29:46 +00:00 committed by Jonathan Blandford
parent 0504a005eb
commit df417ac379
4 changed files with 91 additions and 1 deletions

View File

@ -1,3 +1,8 @@
Mon Mar 5 15:26:30 2001 Jonathan Blandford <jrb@redhat.com>
* gparamspecs.c (g_param_spec_interface): add a new param spec to
handle interfaces.
Wed Feb 21 18:31:46 2001 Jonathan Blandford <jrb@redhat.com>
* gsignal.h (g_signal_connect): Add g_signal_connect define to

View File

@ -679,6 +679,12 @@ param_spec_object_init (GParamSpec *pspec)
/* GParamSpecObject *ospec = G_PARAM_SPEC_OBJECT (pspec); */
}
static void
param_spec_interface_init (GParamSpec *pspec)
{
/* GParamSpecObject *ospec = G_PARAM_SPEC_OBJECT (pspec); */
}
static void
param_object_set_default (GParamSpec *pspec,
GValue *value)
@ -712,6 +718,33 @@ param_object_values_cmp (GParamSpec *pspec,
return value1->data[0].v_pointer != value2->data[0].v_pointer;
}
static void
param_interface_set_default (GParamSpec *pspec,
GValue *value)
{
value->data[0].v_pointer = NULL;
}
static gboolean
param_interface_validate (GParamSpec *pspec,
GValue *value)
{
guint changed = 0;
if (value->data[0].v_pointer == NULL)
changed++;
return changed;
}
static gint
param_interface_values_cmp (GParamSpec *pspec,
const GValue *value1,
const GValue *value2)
{
return value1->data[0].v_pointer != value2->data[0].v_pointer;
}
static void
value_exch_memcpy (GValue *value1,
GValue *value2)
@ -1134,6 +1167,23 @@ g_param_spec_types_init (void) /* sync with gtype.c */
type = g_param_type_register_static ("GParamObject", &pspec_info);
g_assert (type == G_TYPE_PARAM_OBJECT);
}
/* G_TYPE_PARAM_INTERFACE
*/
{
static const GParamSpecTypeInfo pspec_info = {
sizeof (GParamSpecInterface), /* instance_size */
4, /* n_preallocs */
param_spec_interface_init, /* instance_init */
G_TYPE_INTERFACE, /* value_type */
NULL, /* finalize */
param_interface_set_default, /* value_set_default */
param_interface_validate, /* value_validate */
param_interface_values_cmp, /* values_cmp */
};
type = g_param_type_register_static ("GParamInterface", &pspec_info);
g_assert (type == G_TYPE_PARAM_INTERFACE);
}
g_value_register_exchange_func (G_TYPE_CHAR, G_TYPE_UCHAR, value_exch_memcpy);
g_value_register_exchange_func (G_TYPE_CHAR, G_TYPE_BOOLEAN, value_exch_memcpy);
@ -1576,3 +1626,25 @@ g_param_spec_object (const gchar *name,
return G_PARAM_SPEC (ospec);
}
GParamSpec*
g_param_spec_interface (const gchar *name,
const gchar *nick,
const gchar *blurb,
GType interface_type,
GParamFlags flags)
{
GParamSpecInterface *ispec;
g_return_val_if_fail (G_TYPE_IS_INTERFACE (interface_type), NULL);
ispec = g_param_spec_internal (G_TYPE_PARAM_INTERFACE,
name,
nick,
blurb,
flags);
G_PARAM_SPEC (ispec)->value_type = interface_type;
return G_PARAM_SPEC (ispec);
}

View File

@ -68,6 +68,8 @@ extern "C" {
#define G_PARAM_SPEC_BOXED(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_BOXED, GParamSpecBoxed))
#define G_IS_PARAM_SPEC_OBJECT(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_OBJECT))
#define G_PARAM_SPEC_OBJECT(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_OBJECT, GParamSpecObject))
#define G_IS_PARAM_SPEC_INTERFACE(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_INTERFACE))
#define G_PARAM_SPEC_INTERFACE(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_INTERFACE, GParamSpecInterface))
/* --- typedefs & structures --- */
@ -88,6 +90,7 @@ typedef struct _GParamSpecPointer GParamSpecPointer;
typedef struct _GParamSpecCCallback GParamSpecCCallback;
typedef struct _GParamSpecBoxed GParamSpecBoxed;
typedef struct _GParamSpecObject GParamSpecObject;
typedef struct _GParamSpecInterface GParamSpecInterface;
struct _GParamSpecChar
{
GParamSpec parent_instance;
@ -205,6 +208,10 @@ struct _GParamSpecObject
{
GParamSpec parent_instance;
};
struct _GParamSpecInterface
{
GParamSpec parent_instance;
};
/* --- GParamSpec prototypes --- */
@ -314,6 +321,11 @@ GParamSpec* g_param_spec_object (const gchar *name,
const gchar *blurb,
GType object_type,
GParamFlags flags);
GParamSpec* g_param_spec_interface (const gchar *name,
const gchar *nick,
const gchar *blurb,
GType object_type,
GParamFlags flags);
#ifdef __cplusplus

View File

@ -96,7 +96,8 @@ typedef enum /*< skip >*/
G_TYPE_PARAM_POINTER = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 14),
G_TYPE_PARAM_CCALLBACK = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 15),
G_TYPE_PARAM_BOXED = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 16),
G_TYPE_PARAM_OBJECT = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 17)
G_TYPE_PARAM_OBJECT = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 17),
G_TYPE_PARAM_INTERFACE = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 18)
} GTypeFundamentals;