new Property and Accessor declaration
@ebassi
Submitted by Emmanuele Bassi Link to original bug (#648526)
Description
Created attachment 186534 initial version of the GProperty API contract
the current property definition is a bit on the verbose side; plus, it comes in so many ways, shapes and forms, that creating a parser for introspection boils down to parsing C code.
whilst there's an option for an IDL (of various stages of complexity) we can probably still squeeze something out of the C pre-processor to have a stable and simpler syntax for property/accessor definition.
taking a page from the current GObject, we could add new macros for:
- declaring and installing properties
- declaring and generating accessors
and we can also fix a long-standing issue of having accessor functions decoupled from the properties they expose, instead of being tightly coupled.
I'm attaching a first draft of an API contract for GProperty, a GParamSpec sub-class that takes over all the sub-types of GParamSpec into a single type (with different constructors and "decorators" for type-specific modifiers, e.g. ranges and default values). the API contract also includes macros for defining and installing properties, and for declaring and defining accessor functions - with and without custom code.
the API contract is missing some types, but it should give away the gist of it; I'm also finishing the implementation, but I wanted to get a bug opened for further discussion.
one of the bonus points of the design is that it's based off of the current GParamSpec machinery, thus it is fairly non-intrusive and allows migration without breaking backward compatibility.
Attachment 186534, "initial version of the GProperty API contract":
gproperty.h