forked from AuroraMiddleware/gtk
347efc33b8
Fri Jul 10 00:02:04 1998 Tim Janik <timj@gtk.org> * gtk/gtkcontainer.h: * gtk/gtkcontainer.c: deleted most of the argument handling code, since that is now implemented in gtkarg.c. similar to gtk_object_args_collect, we now export a new function gtk_container_child_args_collect(). for consistency with the object arguments, a few functions got renamed: gtk_container_child_arg_get -> gtk_container_child_get, gtk_container_child_arg_set -> gtk_container_child_set, gtk_container_child_arg_getv -> gtk_container_child_getv, gtk_container_child_arg_setv -> gtk_container_child_setv, gtk_container_add_with_argv -> gtk_container_addv. note, gtk_container_add_with_args() remained, because its equivalent would be gtk_container_add(,, ...) which would break all existing code. (gtk_container_add_child_arg_type): similar to gtk_object_add_arg_type, we expect the `arg_name' argument to be a const static string now. (gtk_container_get_child_arg_type): function removed. Thu Jul 9 07:03:04 1998 Tim Janik <timj@gtk.org> * gtk/gtkargcollector.c: new file which holds gtk_arg_collect_value(). this is a static inline function that collects command line arguments from a va_list. this file can just be included in all places that need this functionality. * gtk/gtkarg.h: * gtk/gtkarg.c: new files which implement most of the argument handling stuff from gtkobject.c. also collected a few more gtk_arg_* utility functions from else places. * gtk/gtkobject.h: * gtk/gtkobject.c: moved most of the argument handling code into gtkarg.c. we now export gtk_object_args_collect() as a non-public method with a blind va_list pointer. (gtk_object_add_arg_type): the `arg_name' argument is required to be a const static string now. (gtk_object_get_arg_type): function got removed. * gtk/gtkwidget.c: (gtk_widget_set): (gtk_widget_new): adaptions for gtk_object_args_collect(). * gtk/gtktypeutils.c (gtk_type_init_builtin_types): changed the internal fundamental type name so as to have a valid prefix, e.g. "bool"-> "gboolean", "string"->"GtkString" and somesuch, left "void" as is, though that should probably be something like GtkNone since the type itself is called GTK_TYPE_NONE. even the internal type names need to avoid name clashes and must live in their own namespace, several code portions rely on that. we should relly have typedefs such as typedef gchar* GtkString; so the fundamental type names can be used for code dumpers just like with all the Gtk/Gdk types.
124 lines
4.1 KiB
C
124 lines
4.1 KiB
C
/* GTK - The GIMP Toolkit
|
|
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
|
*
|
|
* This library is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Library General Public
|
|
* License as published by the Free Software Foundation; either
|
|
* version 2 of the License, or (at your option) any later version.
|
|
*
|
|
* This library is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* Library General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Library General Public
|
|
* License along with this library; if not, write to the
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
* Boston, MA 02111-1307, USA.
|
|
*/
|
|
|
|
/* collect a single argument value from a va_list
|
|
*/
|
|
static inline gchar*
|
|
gtk_arg_collect_value (GtkType fundamental_type,
|
|
GtkArg *arg,
|
|
va_list *var_args)
|
|
{
|
|
gchar *error_msg;
|
|
|
|
error_msg = NULL;
|
|
switch (fundamental_type)
|
|
{
|
|
case GTK_TYPE_INVALID:
|
|
error_msg = g_strdup ("invalid untyped argument");
|
|
break;
|
|
case GTK_TYPE_NONE:
|
|
error_msg = g_strdup ("invalid argument type `void'");
|
|
break;
|
|
case GTK_TYPE_CHAR:
|
|
GTK_VALUE_CHAR (*arg) = va_arg (*var_args, gchar);
|
|
break;
|
|
case GTK_TYPE_BOOL:
|
|
GTK_VALUE_BOOL (*arg) = va_arg (*var_args, gboolean);
|
|
break;
|
|
case GTK_TYPE_INT:
|
|
GTK_VALUE_INT (*arg) = va_arg (*var_args, gint);
|
|
break;
|
|
case GTK_TYPE_UINT:
|
|
GTK_VALUE_UINT (*arg) = va_arg (*var_args, guint);
|
|
break;
|
|
case GTK_TYPE_ENUM:
|
|
GTK_VALUE_ENUM (*arg) = va_arg (*var_args, gint);
|
|
break;
|
|
case GTK_TYPE_FLAGS:
|
|
GTK_VALUE_FLAGS (*arg) = va_arg (*var_args, gint);
|
|
break;
|
|
case GTK_TYPE_LONG:
|
|
GTK_VALUE_LONG (*arg) = va_arg (*var_args, glong);
|
|
break;
|
|
case GTK_TYPE_ULONG:
|
|
GTK_VALUE_ULONG (*arg) = va_arg (*var_args, gulong);
|
|
break;
|
|
case GTK_TYPE_FLOAT:
|
|
GTK_VALUE_FLOAT (*arg) = va_arg (*var_args, gfloat);
|
|
break;
|
|
case GTK_TYPE_DOUBLE:
|
|
GTK_VALUE_DOUBLE (*arg) = va_arg (*var_args, gdouble);
|
|
break;
|
|
case GTK_TYPE_STRING:
|
|
GTK_VALUE_STRING (*arg) = va_arg (*var_args, gchar*);
|
|
break;
|
|
case GTK_TYPE_POINTER:
|
|
GTK_VALUE_POINTER (*arg) = va_arg (*var_args, gpointer);
|
|
break;
|
|
case GTK_TYPE_BOXED:
|
|
GTK_VALUE_BOXED (*arg) = va_arg (*var_args, gpointer);
|
|
break;
|
|
case GTK_TYPE_SIGNAL:
|
|
GTK_VALUE_SIGNAL (*arg).f = va_arg (*var_args, GtkFunction);
|
|
GTK_VALUE_SIGNAL (*arg).d = va_arg (*var_args, gpointer);
|
|
break;
|
|
case GTK_TYPE_FOREIGN:
|
|
GTK_VALUE_FOREIGN (*arg).data = va_arg (*var_args, gpointer);
|
|
GTK_VALUE_FOREIGN (*arg).notify = va_arg (*var_args, GtkDestroyNotify);
|
|
break;
|
|
case GTK_TYPE_CALLBACK:
|
|
GTK_VALUE_CALLBACK (*arg).marshal = va_arg (*var_args, GtkCallbackMarshal);
|
|
GTK_VALUE_CALLBACK (*arg).data = va_arg (*var_args, gpointer);
|
|
GTK_VALUE_CALLBACK (*arg).notify = va_arg (*var_args, GtkDestroyNotify);
|
|
break;
|
|
case GTK_TYPE_C_CALLBACK:
|
|
GTK_VALUE_C_CALLBACK (*arg).func = va_arg (*var_args, GtkFunction);
|
|
GTK_VALUE_C_CALLBACK (*arg).func_data = va_arg (*var_args, gpointer);
|
|
break;
|
|
case GTK_TYPE_ARGS:
|
|
GTK_VALUE_ARGS (*arg).n_args = va_arg (*var_args, gint);
|
|
GTK_VALUE_ARGS (*arg).args = va_arg (*var_args, GtkArg*);
|
|
break;
|
|
case GTK_TYPE_OBJECT:
|
|
GTK_VALUE_OBJECT (*arg) = va_arg (*var_args, GtkObject*);
|
|
if (GTK_VALUE_OBJECT (*arg) != NULL)
|
|
{
|
|
register GtkObject *object = GTK_VALUE_OBJECT (*arg);
|
|
|
|
if (object->klass == NULL ||
|
|
!gtk_type_is_a (GTK_OBJECT_TYPE (object), arg->type))
|
|
error_msg = g_strconcat ("invalid object `",
|
|
gtk_type_name (GTK_OBJECT_TYPE (object)),
|
|
"' for argument type `",
|
|
gtk_type_name (arg->type),
|
|
"'",
|
|
NULL);
|
|
}
|
|
break;
|
|
default:
|
|
error_msg = g_strconcat ("unsupported argument type `",
|
|
gtk_type_name (arg->type),
|
|
"'",
|
|
NULL);
|
|
break;
|
|
}
|
|
|
|
return error_msg;
|
|
}
|