[SPAM] Re: property API vs fields



On Thu, 2006-08-17 at 11:25 +0200, Murray Cumming wrote:
> On Sun, 6 Aug 2006, Steph Fox wrote:
>
>> Hi GTK people,
>>
>> The PHP-GTK doc team have hit a point of confusion over the property >> API
>> in
>> GTK 2, mostly because publicly accessible fields hanging over from GTK >> 1
>> are
>> still publicly accessible. We don't know whether to promote the use of
>> *_get_|set_property() or not, and to some extent that depends on >> whether
>> it
>> will eventually be enforced by the GTK+ team.

I mean to reply to this earlier.

GTK+ is very unlikely to change those struct fields, even if they could do
so while keeping the struct size the same. It would just be too risky
because someone's hack probably depends on the non-public API. The
situation is avoided with new code by using the GObject "private" data.

Do use the property API wherever it exists. It does more than just
setting/getting a struct field.

However, some of those struct fields really are public. I forget exactly
what the rule is, and I can't find the email where this was stated. It's
either
- They are public unless marked private.
or
- They are private unless marked public.

Whatever the rule is, it's probably not followed perfectly. A list of
structs where this isn't clear would probably help people to improve the
documentation.

The rule is:

Object instance structures: private unless marked public. (public
  fields are read-only)
Normal structures: public unless marked private.

However, there are supposed to be *no* places in the GTK+ API where
you have to read an object instance structure field, even if it
is marked public; the intention there is 100% coverage with getters.

If I find any when we switch to a more recent version of GTK+ I'll check CVS and bug it.

Thanks all of you for your responses!

- Steph



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]