Re: boxed types and copies
- From: Tim Janik <timj gtk org>
- To: Havoc Pennington <hp redhat com>
- Cc: Gtk+ Developers <gtk-devel-list gnome org>
- Subject: Re: boxed types and copies
- Date: Wed, 13 Dec 2000 02:14:38 +0100 (CET)
On 12 Dec 2000, Havoc Pennington wrote:
>
> Tim Janik <timj gtk org> writes:
> > hm, i'm kinda two folded on that issue.
> >
> > on the one hand, the easy thing to do is to restore gtk_signal_emit(),
> > but then, your signals that use these boxed types are really only
> > usable with gtk_signal_emit() (not g_signal_emit()).
> > beyond that, code that deals with your boxed values will get things wrong,
> > since you copy the structure while you actually want it passed by
> > reference.
> > i think owen has a similar thing with selection data or something...
> > basically, boxed values that aren't usefully copyable, must be reference
> > counted so they can be passed by reference.
> > the reference counting doesn't need to be exposed, you can have static
> > ref/unref and pass that in to g_boxed_type_register_static().
> >
> > owen, what do you say? boxed types need to be either copy-able or
> > reference counted, otherwise LBs or editors can't pass them around
> > and store them away anyways. doing that static hack for gtk_signal_emit()
> > just defers the problem and makes things work for just this moment in our
> > limited testgtk universe.
> >
>
> Pass by value or reference is a property of a function, not a property
> of the type. That is why C and C++ have notation such as Foo* and Foo&
> in addition to plain Foo.
> Whether you _can_ copy or ref/unref a value is the property of the
> value's type. But whether you _do_ copy/ref when passing to a function
> is a property of the function.
>
> So there is no way to get a logical "answer" for boxed types. They
> _can_ be copied because they are boxed, but GBoxed should not say
> anything about whether they _are_ copied in any particular situation.
>
> Whether they are copied should be a property of either the GValue or
> the signal.
fine, following that reasoning, g_signal_emit() does copying unless you
come up with a proposal of extending g_signal_new() to support
pass-by-reference for boxed types that copy itself.
but that is besides the point, what good are your boxed-copying
stubs for, if that doesn't actually work for LBs?
>
> Havoc
>
---
ciaoTJ
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]