3 Commits

Author SHA1 Message Date
Emmanuele Bassi
b47e898e5c gobject: Initialize GProperties at instance creation
Using their default value. This removes the need to manually calling
g_property_init_default(), which means we can make it private.

https://bugzilla.gnome.org/show_bug.cgi?id=648526
2013-07-05 18:12:55 +01:00
Emmanuele Bassi
8c134ac8a4 gproperty: Add default values
GProperty should store the default value (if any) of a property, as well
as the eventual overrides coming from the sub-classes of the class that
defined the property.

https://bugzilla.gnome.org/show_bug.cgi?id=648526
2013-07-05 18:12:55 +01:00
Emmanuele Bassi
959940f896 gobject: Add GProperty
Dealing with GParamSpec is tedious and less efficient than necessary.
GParamSpec is a data type meant to be used to validate GValue, and only
incidentally provides us with the facilities to implement properties on
GObject. GObject itself requires us to provide accessors functions and
then call them from within a huge switch() inside two virtual functions.

Property definitions should be able to either directly access a struct
field or specify the accessors pair that control a property. On top of
that, most of the property and accessor definition can be autogenerated
from simple pre-processor directives.

So, here's to you GProperty.

GProperty is a GParamSpec sub-class that encapsulates all the C
fundamental types inside a single, opaque structure (to avoid leaking
out implementation details); a GProperty can access the structure member
holding the value of the property, or invoke the accessor functions
passed to its constructor. Type safety is enforced at compile time
through the C type system, and at run time through the GType system.
GProperty will try *very* hard to avoid boxing and unboxing fundamental
type values into GValues.

GObject will recognize whether a GParamSpec used to set or get a
property is really a GProperty, and thus will shortcircuit most of the
GValue-based marshalled code, preferring the direct C function and
direct argument collection instead of boxing/unboxing of GValues.

https://bugzilla.gnome.org/show_bug.cgi?id=648526
2013-07-05 18:12:55 +01:00