Re: Introspecting functions taking variable arguments



I ended up looking through GTK+ 3 for some examples, of which there
are a few ...v() functions that are introspectable.

The pattern seems to be to copy the function signature, append `v` to
the function name (sometimes with additional words), and replace the
... variable arguments list with two parameters: GValue *args and gint
n_args. Also, in the GTK-Doc comment block for the ...v() variant,
there is a "Rename to: " line.

For example:

void          gtk_tree_store_set              (GtkTreeStore *tree_store,
					       GtkTreeIter  *iter,
					       ...);

/**
 * gtk_tree_store_set_valuesv:
 * ...
 * Rename to: gtk_tree_store_set
 **/
void
gtk_tree_store_set_valuesv (GtkTreeStore *tree_store,
			    GtkTreeIter  *iter,
			    gint         *columns,
			    GValue       *values,
			    gint          n_values);

AFAIK, calling the set() method on a Gtk.TreeStore from a language
binding actually invokes gtk_tree_store_set_valuesv().

In #gedit, Ignacio "nacho" Casal Quinteiro wrote "Usually not
introspectable means [varargs] or wrong annotations ... va_list is
also not introspectable. You need to pass i.e an array."

Daniel Trebbien

On 2012-02-05, Daniel Trebbien <dtrebbien gmail com> wrote:
> On
> <http://live.gnome.org/PyGObject/IntrospectionPorting#Non-introspectable_functions.2BAC8-methods>,
> there is the following note:
>
>> Varargs cannot be handled safely by libgirepository. In these cases there
>> are
>> often alternatives available (such as gtk_cell_area_cell_set_property()).
>> For
>> other cases libraries now often have a ..._v() counterpart which takes a
>> list
>> instead of variable arguments.
>
> What are some good examples of ..._v() counterparts? I thought that
> all I needed to do was use a va_list, but that doesn't work.
>
> What are good ways of making variadic functions introspectable?
>
> Daniel Trebbien
>


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