GParamSpec: add g_param_spec_get_default_value()

The way of getting the default value out of a GParamSpec is to allocate
a GValue, initialise it, then call g_param_spec_set_default() to set the
default value into that GValue.

This is exactly how we handle setting the default value for all of the
construct properties that were not explicitly passed to g_object_new().

Instead of doing the alloc/init/store on all construct properties on
every call to g_object_new(), we can cache those GValues in the private
data of the GParamSpec itself and reuse them.

This patch does not actually make that change to g_object_new() yet, but
it adds the API to GParamSpec so that a future patch to GObject can make
the change.

https://bugzilla.gnome.org/show_bug.cgi?id=698056
This commit is contained in:
Ryan Lortie
2013-04-23 11:11:20 -04:00
parent c30c0bb34d
commit c18462b580
4 changed files with 81 additions and 1 deletions

View File

@@ -480,6 +480,7 @@ g_param_spec_ref
g_param_spec_unref
g_param_spec_sink
g_param_spec_ref_sink
g_param_spec_get_default_value
g_param_value_set_default
g_param_value_defaults
g_param_value_validate