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

Re: [libvirt] [PATCH 1/7] Allow for multi-level inheritance of virObject classes



On Fri, Jan 11, 2013 at 04:17:20PM -0700, Eric Blake wrote:
> On 01/11/2013 05:13 AM, Daniel P. Berrange wrote:
> > From: "Daniel P. Berrange" <berrange redhat com>
> > 
> > Currently all classes must directly inherit from virObject.
> > This allows for arbitrarily deep hierarchy. There's not much
> > too this aside from chaining up the 'dispose' handlers from
> 
> s/too/to/
> 
> > each class & providing APIs to check types.
> > ---
> 
> > -virClassPtr virClassNew(const char *name,
> > +virClassPtr virClassNew(virClassPtr parent,
> > +                        const char *name,
> >                          size_t objectSize,
> >                          virObjectDisposeCallback dispose)
> >  {
> >      virClassPtr klass;
> >  
> > +    if (parent == NULL &&
> > +        STRNEQ(name, "virObject")) {
> > +        virReportInvalidNonNullArg(parent);
> > +        return NULL;
> 
> Would it have been any easier to let callers pass NULL when they want to
> have virObject as the default parent, instead of making all callers have
> to use virClassForObject()?  Then again, you've already touched
> everyone, so don't change the bikeshed color again.

Well 'NULL' needs to mean 'no parent' so we can initialize virObject,
so it felt wrong to also have it mean 'virObject as a parent' for every
other callers.

Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|


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