Re: NM coding style regarding private gobject data



On Wed, 2015-04-29 at 16:33 +0200, Aleksander Morgado wrote:
On Wed, Apr 29, 2015 at 2:49 PM, Thomas Haller <thaller redhat com> wrote:
It's my personal annoyance with the verboseness of:


  NM_TYPE_NAME_GET_PRIVATE (self)->my_field
  nm_type_name_get_instance_private (self)->my_field

  vs.

  self->priv->my_field



Bonus point: it's easier in gdb/debugger.

I personally also prefer to waste a pointer per object and have
self->priv, truth be told, even if the new get_instance_private ()
macros are pointer arithmetic only.

I'm personally fine with self->priv, but ISTR the last time this came up
Pavel had some objections to it based around type-safety I think?
GET_PRIVATE() does type-checking, while of course direct pointer access
doesn't.  Or something like that.  But of course if GET_PRIVATE()
returns NULL and we dereference that to get the private data anyway,
it'll still crash just like self->priv on a bogus pointer.

In any case, I'm fine with moving in that direction, but we should dig
up what Pavel's objection was just for reference.

Dan



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