NM coding style regarding private gobject data



Hi,


in NM code, we tend to have gobject (duhh) with private data.
We almost always define a macro NM_TYPE_NAME_GET_PRIVATE() as accessor.



I think this long name is quite cumbersome to write. It's a bit redeemed
as we often cache that pointer in a @priv member, but you still have to
add
   NMTypeNamePrivate *priv = NM_TYPE_NAME_GET_PRIVATE (self);
to almost all methods.




What do you think about registering an opaque "priv" pointer in the
public struct instead?


Something like


/* nm-device.h */

struct _NMDevicePrivate;

typedef struct {
    GObject parent;
    struct _NMDevicePrivate *priv;
} NMDevice;



/* nm-device.c */

typedef struct _NMDevicePrivate NMDevicePrivate;
struct _NMDevicePrivate {
    /*members*/
};
#define NM_DEVICE_GET_PRIVATE(self) (self->priv)


so, we can still continue to use NM_DEVICE_GET_PRIVATE(self), but a IMO
nicer way would be just "self->priv".




It even has better runtime performance (but consumes one pointer more
memory).



Any opinions?


Thomas


Attachment: signature.asc
Description: This is a digitally signed message part



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