]> Pileus Git - ~andy/gtk/blob - gtk/gtkargcollector.c
Proxy out to _gtk_tree_row_reference_deleted. (inserted_callback): Proxy
[~andy/gtk] / gtk / gtkargcollector.c
1 /* GTK - The GIMP Toolkit
2  * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 /*
21  * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
22  * file for a list of people on the GTK+ Team.  See the ChangeLog
23  * files for a list of changes.  These files are distributed with
24  * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
25  */
26
27 /* collect a single argument value from a va_list.
28  * this is implemented as a huge macro <shrug>, because we can't
29  * pass va_list variables by reference on some systems.
30  * the corresponding prototype would be:
31  * static inline gchar*
32  * gtk_arg_collect_value (GtkArg  *arg,
33  *                        va_list  var_args);
34  */
35 #define GTK_ARG_COLLECT_VALUE(arg, var_args, _error)    \
36 G_STMT_START { \
37   gchar *error_msg; \
38   GtkType fundamental_type; \
39   \
40   fundamental_type = GTK_FUNDAMENTAL_TYPE (arg->type); \
41   \
42   error_msg = NULL; \
43   switch (fundamental_type) \
44     { \
45     case GTK_TYPE_INVALID: \
46       error_msg = g_strdup ("invalid untyped argument"); \
47       break; \
48  \
49     case GTK_TYPE_NONE: \
50       /* we just ignore this type, since it arithmetically just requires \
51        * us to not move the var_args pointer any further. callers need to \
52        * check for the validity of GTK_TYPE_NONE themselves. \
53        * \
54        * error_msg = g_strdup ("invalid argument type `void'"); \
55        */ \
56       break; \
57  \
58       /* everything smaller than an int is guarranteed to be \
59        * passed as an int \
60        */ \
61     case GTK_TYPE_CHAR: \
62       GTK_VALUE_CHAR (*arg) = va_arg (var_args, gint); \
63       break; \
64     case GTK_TYPE_UCHAR: \
65       GTK_VALUE_UCHAR (*arg) = va_arg (var_args, guint); \
66       break; \
67     case GTK_TYPE_BOOL: \
68       GTK_VALUE_BOOL (*arg) = va_arg (var_args, gint); \
69       break; \
70     case GTK_TYPE_INT: \
71       GTK_VALUE_INT (*arg) = va_arg (var_args, gint); \
72       break; \
73     case GTK_TYPE_UINT: \
74       GTK_VALUE_UINT (*arg) = va_arg (var_args, guint); \
75       break; \
76     case GTK_TYPE_ENUM: \
77       GTK_VALUE_ENUM (*arg) = va_arg (var_args, gint); \
78       break; \
79     case GTK_TYPE_FLAGS: \
80       GTK_VALUE_FLAGS (*arg) = va_arg (var_args, guint); \
81       break; \
82  \
83       /* we collect longs as glongs since they differ in size with \
84        * integers on some platforms \
85        */ \
86     case GTK_TYPE_LONG: \
87       GTK_VALUE_LONG (*arg) = va_arg (var_args, glong); \
88       break; \
89     case GTK_TYPE_ULONG: \
90       GTK_VALUE_ULONG (*arg) = va_arg (var_args, gulong); \
91       break; \
92  \
93       /* floats are always passed as doubles \
94        */ \
95     case GTK_TYPE_FLOAT: \
96       /* GTK_VALUE_FLOAT (*arg) = va_arg (var_args, gfloat); */ \
97       GTK_VALUE_FLOAT (*arg) = va_arg (var_args, gdouble); \
98       break; \
99     case GTK_TYPE_DOUBLE: \
100       GTK_VALUE_DOUBLE (*arg) = va_arg (var_args, gdouble); \
101       break; \
102  \
103       /* collect pointer values \
104        */ \
105     case GTK_TYPE_STRING: \
106       GTK_VALUE_STRING (*arg) = va_arg (var_args, gchar*); \
107       break; \
108     case GTK_TYPE_POINTER: \
109       GTK_VALUE_POINTER (*arg) = va_arg (var_args, gpointer); \
110       break; \
111     case GTK_TYPE_BOXED: \
112       GTK_VALUE_BOXED (*arg) = va_arg (var_args, gpointer); \
113       break; \
114  \
115       /* structured types \
116        */ \
117     case GTK_TYPE_SIGNAL: \
118       GTK_VALUE_SIGNAL (*arg).f = va_arg (var_args, GtkSignalFunc); \
119       GTK_VALUE_SIGNAL (*arg).d = va_arg (var_args, gpointer); \
120       break; \
121  \
122       /* we do some extra sanity checking when collecting objects, \
123        * i.e. if the object pointer is not NULL, we check whether we \
124        * actually got an object pointer within the desired class branch. \
125        */ \
126     case G_TYPE_OBJECT: \
127       GTK_VALUE_OBJECT (*arg) = va_arg (var_args, GtkObject*); \
128       if (GTK_VALUE_OBJECT (*arg) != NULL) \
129         { \
130           register GtkObject *object = GTK_VALUE_OBJECT (*arg); \
131            \
132           if (((GTypeInstance*) object)->g_class == NULL) \
133             error_msg = g_strconcat ("invalid unclassed object pointer for argument type `", \
134                                      gtk_type_name (arg->type), \
135                                      "'", \
136                                      NULL); \
137           else if (!gtk_type_is_a (GTK_OBJECT_TYPE (object), arg->type)) \
138             error_msg = g_strconcat ("invalid object `", \
139                                      gtk_type_name (G_OBJECT_TYPE (object)), \
140                                      "' for argument type `", \
141                                      gtk_type_name (arg->type), \
142                                      "'", \
143                                      NULL); \
144         } \
145       break; \
146  \
147     default: \
148       error_msg = g_strconcat ("unsupported argument type `", \
149                                gtk_type_name (arg->type), \
150                                "'", \
151                                NULL); \
152       break; \
153     } \
154    \
155   _error = error_msg; /* return error_msg; */ \
156 } G_STMT_END