va_lists in glib/gtk and set/get(...) functions

hey all,

several people have recently encountered problems with the current
implementation of varargs functions (...) in glib/gtk.

Havoc Pennington wants to implement c++ equivalents to e.g.

void gnome_canvas_item_set (GnomeCanvasItem *item, ...);

which basically translates into

GnomeCanvasItem::set (...);

for c++, no parameter to start the va_list from.
what he needs is:

void gnome_canvas_item_set (GnomeCanvasItem *item,
                            const gchar     *arg_name,
and then:
GnomeCanvasItem::set (const gchar *first_arg_name, ...);

so he can issue va_start (args, first_arg_name); but this requires changes
to the underlying arg mechanisms in gtk.

also passing va_lists by reference is a problem on platforms that define va_list
as some kind of array.

i'll therefore go through gtk and glib and change the
void func ([some args], va_list *args1, va_list *args2)
prototypes to
void func ([some args], va_list args1)
  va_list arg2 = args1;
also, most of the object/child argument functions (plus the gtk internals)
will be changed to feature the const gchar *first_arg_name variable, so
Havoc's problem will be solved as well.

functions that will be changed in a source compatible manner are:
gtk_object_set, gtk_widget_new, gtk_widget_set and gtk_arg_collect_value
from gtkargcollector.c (this will probably be moved into a public *.h file
that is installed but not included by default for gtk).

source incompatible changes are standing out for

void            g_logv                  (const gchar    *log_domain,
                                         GLogLevelFlags  log_level,
                                         const gchar    *format,
                                         va_list         args1);
gint    g_vsnprintf             (gchar       *string,
                                 gulong       n,
                                 gchar const *format,
                                 va_list      args1);
and the non-public
extern gchar* g_vsprintf (const gchar *fmt, va_list args);


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