Home | History | Annotate | Download | only in gobject

Lines Matching full:pspec

58 #define PSPEC_APPLIES_TO_VALUE(pspec, value)	(G_TYPE_CHECK_VALUE_TYPE ((value), G_PARAM_SPEC_VALUE_TYPE (pspec)))
68 static void g_param_spec_init (GParamSpec *pspec,
70 static void g_param_spec_finalize (GParamSpec *pspec);
157 g_param_spec_init (GParamSpec *pspec,
160 pspec->name = NULL;
161 pspec->_nick = NULL;
162 pspec->_blurb = NULL;
163 pspec->flags = 0;
164 pspec->value_type = class->value_type;
165 pspec->owner_type = 0;
166 pspec->qdata = NULL;
167 g_datalist_init (&pspec->qdata);
168 g_datalist_set_flags (&pspec->qdata, PARAM_FLOATING_FLAG);
169 pspec->ref_count = 1;
170 pspec->param_id = 0;
174 g_param_spec_finalize (GParamSpec *pspec)
176 g_datalist_clear (&pspec->qdata);
178 if (!(pspec->flags & G_PARAM_STATIC_NAME))
179 g_free (pspec->name);
181 if (!(pspec->flags & G_PARAM_STATIC_NICK))
182 g_free (pspec->_nick);
184 if (!(pspec->flags & G_PARAM_STATIC_BLURB))
185 g_free (pspec->_blurb);
187 g_type_free_instance ((GTypeInstance*) pspec);
192 * @pspec: a valid #GParamSpec
194 * Increments the reference count of @pspec.
199 g_param_spec_ref (GParamSpec *pspec)
201 g_return_val_if_fail (G_IS_PARAM_SPEC (pspec), NULL);
202 g_return_val_if_fail (pspec->ref_count > 0, NULL);
204 g_atomic_int_inc ((int *)&pspec->ref_count);
206 return pspec;
211 * @pspec: a valid #GParamSpec
213 * Decrements the reference count of a @pspec.
216 g_param_spec_unref (GParamSpec *pspec)
220 g_return_if_fail (G_IS_PARAM_SPEC (pspec));
221 g_return_if_fail (pspec->ref_count > 0);
223 is_zero = g_atomic_int_dec_and_test ((int *)&pspec->ref_count);
227 G_PARAM_SPEC_GET_CLASS (pspec)->finalize (pspec);
233 * @pspec: a valid #GParamSpec
238 * someone calls <literal>g_param_spec_ref (pspec); g_param_spec_sink
239 * (pspec);</literal> in sequence on it, taking over the initial
240 * reference count (thus ending up with a @pspec that has a reference
244 g_param_spec_sink (GParamSpec *pspec)
247 g_return_if_fail (G_IS_PARAM_SPEC (pspec));
248 g_return_if_fail (pspec->ref_count > 0);
251 oldvalue = g_atomic_pointer_get (&pspec->qdata);
252 while (!g_atomic_pointer_compare_and_exchange ((void**) &pspec->qdata, oldvalue,
255 g_param_spec_unref (pspec);
260 * @pspec: a valid #GParamSpec
268 g_param_spec_ref_sink (GParamSpec *pspec)
270 g_return_val_if_fail (G_IS_PARAM_SPEC (pspec), NULL);
271 g_return_val_if_fail (pspec->ref_count > 0, NULL);
273 g_param_spec_ref (pspec);
274 g_param_spec_sink (pspec);
275 return pspec;
280 * @pspec: a valid #GParamSpec
284 * Returns: the name of @pspec.
287 g_param_spec_get_name (GParamSpec *pspec)
289 g_return_val_if_fail (G_IS_PARAM_SPEC (pspec), NULL);
291 return pspec->name;
296 * @pspec: a valid #GParamSpec
300 * Returns: the nickname of @pspec.
303 g_param_spec_get_nick (GParamSpec *pspec)
305 g_return_val_if_fail (G_IS_PARAM_SPEC (pspec), NULL);
307 if (pspec->_nick)
308 return pspec->_nick;
313 redirect_target = g_param_spec_get_redirect_target (pspec);
318 return pspec->name;
323 * @pspec: a valid #GParamSpec
327 * Returns: the short description of @pspec.
330 g_param_spec_get_blurb (GParamSpec *pspec)
332 g_return_val_if_fail (G_IS_PARAM_SPEC (pspec), NULL);
334 if (pspec->_blurb)
335 return pspec->_blurb;
340 redirect_target = g_param_spec_get_redirect_target (pspec);
419 GParamSpec *pspec;
426 pspec = (gpointer) g_type_create_instance (param_type);
430 pspec->name = g_intern_static_string (name);
431 if (!is_canonical (pspec->name))
432 g_warning ("G_PARAM_STATIC_NAME used with non-canonical pspec name: %s", pspec->name);
436 pspec->name = g_strdup (name);
437 canonicalize_key (pspec->name);
438 g_intern_string (pspec->name);
442 pspec->_nick = (gchar*) nick;
444 pspec->_nick = g_strdup (nick);
447 pspec->_blurb = (gchar*) blurb;
449 pspec->_blurb = g_strdup (blurb);
451 pspec->flags = (flags & G_PARAM_USER_MASK) | (flags & G_PARAM_MASK);
453 return pspec;
458 * @pspec: a valid #GParamSpec
466 g_param_spec_get_qdata (GParamSpec *pspec,
469 g_return_val_if_fail (G_IS_PARAM_SPEC (pspec), NULL);
471 return quark ? g_datalist_id_get_data (&pspec->qdata, quark) : NULL;
476 * @pspec: the #GParamSpec to set store a user data pointer
483 * from the @pspec with g_param_spec_get_qdata(). Setting a
488 g_param_spec_set_qdata (GParamSpec *pspec,
492 g_return_if_fail (G_IS_PARAM_SPEC (pspec));
495 g_datalist_id_set_data (&pspec->qdata, quark, data);
500 * @pspec: the #GParamSpec to set store a user data pointer
508 * specified which is called with @data as argument when the @pspec is
513 g_param_spec_set_qdata_full (GParamSpec *pspec,
518 g_return_if_fail (G_IS_PARAM_SPEC (pspec));
521 g_datalist_id_set_data_full (&pspec->qdata, quark, data, data ? destroy : (GDestroyNotify) NULL);
526 * @pspec: the #GParamSpec to get a stored user data pointer from
530 * and removes the @data from @pspec without invoking its destroy()
537 g_param_spec_steal_qdata (GParamSpec *pspec,
540 g_return_val_if_fail (G_IS_PARAM_SPEC (pspec), NULL);
543 return g_datalist_id_remove_no_notify (&pspec->qdata, quark);
548 * @pspec: a #GParamSpec
564 pspec)
566 g_return_val_if_fail (G_IS_PARAM_SPEC (pspec), NULL);
568 if (G_IS_PARAM_SPEC_OVERRIDE (pspec))
570 GParamSpecOverride *ospec = G_PARAM_SPEC_OVERRIDE (pspec);
580 * @pspec: a valid #GParamSpec
581 * @value: a #GValue of correct type for @pspec
583 * Sets @value to its default value as specified in @pspec.
586 g_param_value_set_default (GParamSpec *pspec,
589 g_return_if_fail (G_IS_PARAM_SPEC (pspec));
591 g_return_if_fail (PSPEC_APPLIES_TO_VALUE (pspec, value));
594 G_PARAM_SPEC_GET_CLASS (pspec)->value_set_default (pspec, value);
599 * @pspec: a valid #GParamSpec
600 * @value: a #GValue of correct type for @pspec
602 * Checks whether @value contains the default value as specified in @pspec.
604 * Returns: whether @value contains the canonical default for this @pspec
607 g_param_value_defaults (GParamSpec *pspec,
613 g_return_val_if_fail (G_IS_PARAM_SPEC (pspec), FALSE);
615 g_return_val_if_fail (PSPEC_APPLIES_TO_VALUE (pspec, value), FALSE);
617 g_value_init (&dflt_value, G_PARAM_SPEC_VALUE_TYPE (pspec));
618 G_PARAM_SPEC_GET_CLASS (pspec)->value_set_default (pspec, &dflt_value);
619 defaults = G_PARAM_SPEC_GET_CLASS (pspec)->values_cmp (pspec, value, &dflt_value) == 0;
627 * @pspec: a valid #GParamSpec
628 * @value: a #GValue of correct type for @pspec
631 * set out by @pspec. For example, a #GParamSpecInt might require
640 g_param_value_validate (GParamSpec *pspec,
643 g_return_val_if_fail (G_IS_PARAM_SPEC (pspec), FALSE);
645 g_return_val_if_fail (PSPEC_APPLIES_TO_VALUE (pspec, value), FALSE);
647 if (G_PARAM_SPEC_GET_CLASS (pspec)->value_validate)
651 if (G_PARAM_SPEC_GET_CLASS (pspec)->value_validate (pspec, value) ||
661 * @pspec: a valid #GParamSpec
663 * @dest_value: destination #GValue of correct type for @pspec
664 * @strict_validation: %TRUE requires @dest_value to conform to @pspec
668 * validates @dest_value, in order for it to conform to @pspec. If
670 * transformed @dest_value complied to @pspec without modifications.
679 g_param_value_convert (GParamSpec *pspec,
686 g_return_val_if_fail (G_IS_PARAM_SPEC (pspec), FALSE);
689 g_return_val_if_fail (PSPEC_APPLIES_TO_VALUE (pspec, dest_value), FALSE);
695 (!g_param_value_validate (pspec, &tmp_value) || !strict_validation))
714 * @pspec: a valid #GParamSpec
715 * @value1: a #GValue of correct type for @pspec
716 * @value2: a #GValue of correct type for @pspec
718 * Compares @value1 with @value2 according to @pspec, and return -1, 0 or +1,
725 g_param_values_cmp (GParamSpec *pspec,
737 g_return_val_if_fail (G_IS_PARAM_SPEC (pspec), 0);
740 g_return_val_if_fail (PSPEC_APPLIES_TO_VALUE (pspec, value1), 0);
741 g_return_val_if_fail (PSPEC_APPLIES_TO_VALUE (pspec, value2), 0);
743 cmp = G_PARAM_SPEC_GET_CLASS (pspec)->values_cmp (pspec, value1, value2);
909 * @pspec: the #GParamSpec to insert
910 * @owner_type: a #GType identifying the owner of @pspec
916 GParamSpec *pspec,
921 if (pool && pspec && owner_type > 0 && pspec->owner_type == 0)
924 for (p = pspec->name; *p; p++)
928 g_warning (G_STRLOC ": pspec name \"%s\" contains invalid characters", pspec->name);
934 pspec->owner_type = owner_type;
935 g_param_spec_ref (pspec);
936 g_hash_table_insert (pool->hash_table, pspec, pspec);
942 g_return_if_fail (pspec);
944 g_return_if_fail (pspec->owner_type == 0);
951 * @pspec: the #GParamSpec to remove
957 GParamSpec *pspec)
959 if (pool && pspec)
962 if (g_hash_table_remove (pool->hash_table, pspec))
963 g_param_spec_unref (pspec);
965 g_warning (G_STRLOC ": attempt to remove unknown pspec `%s' from pool", pspec->name);
971 g_return_if_fail (pspec);
981 GParamSpec key, *pspec;
988 pspec = g_hash_table_lookup (hash_table, &key);
989 if (pspec)
990 return pspec;
995 pspec = g_hash_table_lookup (hash_table, &key);
997 if (!pspec && !is_canonical (param_name))
1007 pspec = g_hash_table_lookup (hash_table, &key);
1008 if (pspec)
1011 return pspec;
1017 pspec = g_hash_table_lookup (hash_table, &key);
1021 return pspec;
1042 GParamSpec *pspec;
1058 pspec = param_spec_ht_lookup (pool->hash_table, param_name, owner_type, walk_ancestors);
1061 return pspec;
1087 pspec = param_spec_ht_lookup (pool->hash_table, param_name, owner_type, walk_ancestors);
1090 return pspec;
1105 GParamSpec *pspec = value;
1109 if (owner_type == pspec->owner_type)
1110 data[0] = g_list_prepend (data[0], pspec);
1162 GParamSpec *pspec = plist->data;
1171 if (g_param_spec_get_redirect_target (pspec))
1175 found = param_spec_ht_lookup (ht, pspec->name, owner_type, TRUE);
1176 if (found != pspec)
1179 if (redirect != pspec)
1204 GParamSpec *pspec = value;
1209 if (g_type_is_a (owner_type, pspec->owner_type))
1211 if (G_TYPE_IS_INTERFACE (pspec->owner_type))
1213 slists[0] = g_slist_prepend (slists[0], pspec);
1217 guint d = g_type_depth (pspec->owner_type);
1219 slists[d - 1] = g_slist_prepend (slists[d - 1], pspec);
1238 GParamSpec *pspec = value;
1243 if (pspec->owner_type == owner_type)
1244 slists[0] = g_slist_prepend (slists[0], pspec);
1310 void (*finalize) (GParamSpec *pspec);
1311 void (*value_set_default) (GParamSpec *pspec,
1313 gboolean (*value_validate) (GParamSpec *pspec,
1315 gint (*values_cmp) (GParamSpec *pspec,
1338 default_value_set_default (GParamSpec *pspec,
1345 default_values_cmp (GParamSpec *pspec,