implemented G_TYPE_GTPYE. applied patch from matthias which implements

Thu Dec 22 14:59:24 2005  Tim Janik  <timj@imendio.com>

        * gvaluetypes.[hc]: implemented G_TYPE_GTPYE. applied patch
        from matthias which implements GType accessors for GValue.

        * gparamspecs.[hc]: applied patch from matthias which
        implements G_TYPE_PARAM_GTYPE.

        * gobject.[hc]:
        GUnowned: introduced a new object type that has an initially
        floating reference.
        g_object_compat_control(): allow setting of a floating flag handler.
This commit is contained in:
Tim Janik
2005-12-22 15:07:03 +00:00
committed by Tim Janik
parent 513be6bbae
commit 6f01d0c34f
8 changed files with 221 additions and 20 deletions

View File

@@ -1016,13 +1016,55 @@ param_override_values_cmp (GParamSpec *pspec,
return g_param_values_cmp (ospec->overridden, value1, value2);
}
static void
param_gtype_init (GParamSpec *pspec)
{
}
static void
param_gtype_set_default (GParamSpec *pspec,
GValue *value)
{
value->data[0].v_long = G_TYPE_NONE;
}
static gboolean
param_gtype_validate (GParamSpec *pspec,
GValue *value)
{
GParamSpecGType *tspec = G_PARAM_SPEC_GTYPE (pspec);
GType gtype = value->data[0].v_long;
guint changed = 0;
if (tspec->is_a_type != G_TYPE_NONE && !g_type_is_a (gtype, tspec->is_a_type))
{
value->data[0].v_long = G_TYPE_NONE;
changed++;
}
return changed;
}
static gint
param_gtype_values_cmp (GParamSpec *pspec,
const GValue *value1,
const GValue *value2)
{
GType p1 = value1->data[0].v_long;
GType p2 = value2->data[0].v_long;
/* not much to compare here, try to at least provide stable lesser/greater result */
return p1 < p2 ? -1 : p1 > p2;
}
/* --- type initialization --- */
GType *g_param_spec_types = NULL;
void
g_param_spec_types_init (void)
{
const guint n_types = 21;
const guint n_types = 22;
GType type, *spec_types, *spec_types_bound;
g_param_spec_types = g_new0 (GType, n_types);
@@ -1408,6 +1450,24 @@ g_param_spec_types_init (void)
g_assert (type == G_TYPE_PARAM_OVERRIDE);
}
/* G_TYPE_PARAM_GTYPE
*/
{
GParamSpecTypeInfo pspec_info = {
sizeof (GParamSpecGType), /* instance_size */
0, /* n_preallocs */
param_gtype_init, /* instance_init */
G_TYPE_GTYPE, /* value_type */
NULL, /* finalize */
param_gtype_set_default, /* value_set_default */
param_gtype_validate, /* value_validate */
param_gtype_values_cmp, /* values_cmp */
};
type = g_param_type_register_static (g_intern_static_string ("GParamGType"), &pspec_info);
*spec_types++ = type;
g_assert (type == G_TYPE_PARAM_GTYPE);
}
g_assert (spec_types == spec_types_bound);
}
@@ -1852,6 +1912,26 @@ g_param_spec_pointer (const gchar *name,
return G_PARAM_SPEC (pspec);
}
GParamSpec*
g_param_spec_gtype (const gchar *name,
const gchar *nick,
const gchar *blurb,
GType is_a_type,
GParamFlags flags)
{
GParamSpecGType *tspec;
tspec = g_param_spec_internal (G_TYPE_PARAM_GTYPE,
name,
nick,
blurb,
flags);
tspec->is_a_type = is_a_type;
return G_PARAM_SPEC (tspec);
}
GParamSpec*
g_param_spec_value_array (const gchar *name,
const gchar *nick,