Re: Fake inheritance in GDK



On Thu, 2001-10-11 at 17:27, Murray Cumming wrote:
> On Thu, 2001-10-11 at 17:05, Owen Taylor wrote:
> > 
> > murrayc t-online de (Murray Cumming) writes:
> > 
> > > I'm auto-generating C++ wrappers for GDK 2, and I've discovered some
> > > small difficulties:
> > > 
> > > GdkVisualClass is declared as this, in gdkvisual.h:
> > > 
> > > typedef struct _GdkVisualClass    GdkVisualClass;
> > > 
> > > But _GdkVisualClass is not defined anywhere. I think that it should, at
> > > least, be defined as 
> > > typedef struct _GdkDrawableClass    GdkVisualClass
> > > as has been done for GdkPixmap and GdkBitmap in gdktypes.h
> > 
> > GdkVisual is not a GdkDrawable:
> 
> Sorry, I mean it should be
> 
> typedef struct _GObjectClass    GdkVisualClass;

Sorry, I've just realised that _GdkVisualClass is defined differently in
X11, linux-fb, etc. I guess that I'll have to find another way around
this.

We just won't be able to derive from GdkVisual just as you can't in C.
I've no idea whether anyone would even want to. And there are no signals
so we don't really need our own derived GClass.

>  
> > 
> >  http://developer.gnome.org/doc/API/2.0/gdk/gdk-visuals.html
> >  
> > explains what a GdkVisual is.
> > 
> > > Actually, I'd like to change all of these pretend derivations to real
> > > derivations. The C++ compiler can't tell the difference between
> > > GdkDrawable*, GdkBitmap*, GdkPixmap*, and GdkVisual* because they are
> > > all simple typedefs of each other. Would you accept a patch to do that?
> > 
> > No. Breaking every GTK+ program out there not allowed. :-)
> 
> I didn't think the there would be any source breakage, and possibly not
> even any binary breakage, because
> 
> struct GdkBitmapClass
> {
>   GObjectClass
> }
> 
> might look just like
> 
> typdef struct _GdkDrawableClass GdkBitmapClass
> 
> Of course I was only guessing.
> 
> > 
> > (They actually are real derivations, in the GObject sense, we just
> > use the same typedef for all of the objects.)
> 
> I can see that there isn't much advantage for C coders, but surely it's
> not 'real derivation' unless you register a new GType. There is no
> GDK_BITMAP_TYPE or gdk_bitmap_get_type().
> 
> Aren't you glad that the whining from the gtk-- developers has already
> started again?
> 
> -- 
> Murray Cumming
> murrayc usa net
> www.murrayc.com
-- 
Murray Cumming
murrayc usa net
www.murrayc.com





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