[gst-devel] GstStructure mutability question
ds at schleef.org
Mon Feb 11 23:04:48 CET 2008
On Mon, Feb 11, 2008 at 04:07:14PM -0500, José Alburquerque wrote:
> A better example would be what happens with our RefPtr wrapper class (which
> wraps objects and automatically increments/decrements their references) and
> when it is "cast" (see this bug report I filed hoping for some possible
> solution: http://bugzilla.gnome.org/show_bug.cgi?id=510301).
One possible workaround for this is to add a wrapper_refcount field
that is only used for language wrappers. Language wrappers would
increment the wrapper_refcount field to indicate that the refcount
is due to the bindings only, and not to be used as in determining
writablity. (This is only a suggestion. Don't know if it would
work, or even wise. Definitely something we need to address in 0.11.
Actually, we needed to address it in 0.7, but it got dropped because
of more pressing issues.)
> The reason we want to design our Caps::set_simple() method to return a
> "pointer" (in fact it is our RefPtr wrapper class) to the caps is to allow
> the "chain of sets" you see above. Your gst_caps_set_simple() returns
> void, so I don't really see where the danger would be.
The obvious danger is that you waste application developers' time.
Based on my observation of new developers in the past, the thought
process would go something like this:
- Hmm, Caps::set_simple() returns Caps, but the C version doesn't.
- I wonder if the C documentation is correct for the C++ function.
- I wonder if the C++ function is supposed to work like
gst_caps_make_writable(), and I'm supposed to assign it to my
- (looks in the C++ documentation, finds nothing, becuase "it's obvious")
- (asks on IRC, gets no conclusive answer)
Gratuitous differences are completely wasteful, since they require
extra documentation, extra neurons to remember the differences, and
extra bugs because people don't remember (or never knew) the differences.
However, if a C function completely goes against language style, feel
free to change it. The python bindings do this quite frequently,
because otherwise the combination of gstreamer+python would feel like
writing C with python syntax. This is not such a case.
Also, set_simple is variadic for a reason. Setting a single caps field
may take multiple values, for example, when setting fractions.
More information about the gstreamer-devel