8 Commits

Author SHA1 Message Date
Emmanuele Bassi
a2a6cb2058 Drop an unnecessary argument from G_DEFINE_PROPERTIES
By renaming the variable holding the properties array (which can also
conflict with existing code) we can avoid the lowercase type name.
2013-07-05 18:14:59 +01:00
Emmanuele Bassi
55941c1e1a property: Remove implicit notify with explicit setters
If the user passes an explicit setter function when creating a
GProperty, we assume that a notify signal will be emitted. For direct
access to a structure field, we can emit an implicit notification
ourselves, since we know that if the value has changed.

This changes the signature of the explicit setter functions.
2013-07-05 18:13:55 +01:00
Emmanuele Bassi
e783b3883e property: Use the field offset everywhere
Do not implicitly grab the private data offset inside GProperty: we
allow passing any offset when creating a new GProperty, and let the
user decide where the property is stored, by giving us the correct
offset — either from the instance structure, or from the private
structure.

https://bugzilla.gnome.org/show_bug.cgi?id=648526
2013-07-05 18:13:55 +01:00
Emmanuele Bassi
f8900df2cf property: Add macros for defining properties
Alongside the macros for defining accessors we may want to use simple
macros for defining properties to install on a GObject class.

https://bugzilla.gnome.org/show_bug.cgi?id=648526
2013-07-05 18:13:55 +01:00
Emmanuele Bassi
91a35e96e3 property: Add autogeneration of accessors
We can use macros to autogenerate accessor methods for GObject classes
using GProperty.

https://bugzilla.gnome.org/show_bug.cgi?id=648526
2013-07-05 18:12:55 +01:00
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