Sinkability: usefull in language bindings ? [was: Re: Sinkability considered harmful]



muppet wrote:
Tristan Van Berkom said:

muppet,
    GtkObject is a special case, it means that in your
binding you have to distinguish it from a GObject and treat
it differently, if there were no floating flag; you wouln't
need to do this.


This is indeed the situation -- the binding treats GtkObjects differently from
GObjects.  What i was trying to say was that the floating reference allowed us
to treat all GtkObject returns identically, while we must pay very close
attention to non-GtkObject returns to get ownership correct.

I am curious as to how that is; for example:

    gtk_range_get_adjustment() returns a private pointer
    to an adjustment, one would have to ref it if one wanted
    to keep it around after.

    g_object_new (GTK_TYPE_ADJUSTEMENT, NULL) returns a
    floating GtkAdjustment.

The bottom line is that, making the assumption that functions
returning "already sunk" GtkObjects will never give you an extra
reference, or that functions returning "floating" GtkObjects
will always have a reference count of 1 is wrong and dangerous.

It may "work" and be the case right now, but its not
something that GTK+ can garauntee (I for one wouldn't
advocate such a garauntee).

Maybe I'm missing something fundamental... I've never written
any language bindings...

Cheers,
                        -Tristan



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