1.1 --- a/epoc32/include/stdapis/glib-2.0/gobject/gvaluecollector.h Tue Nov 24 13:55:44 2009 +0000
1.2 +++ b/epoc32/include/stdapis/glib-2.0/gobject/gvaluecollector.h Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -1,1 +1,160 @@
1.4 -gvaluecollector.h
1.5 +/* GObject - GLib Type, Object, Parameter and Signal Library
1.6 + * Copyright (C) 1998-1999, 2000-2001 Tim Janik and Red Hat, Inc.
1.7 + *
1.8 + * This library is free software; you can redistribute it and/or
1.9 + * modify it under the terms of the GNU Lesser General Public
1.10 + * License as published by the Free Software Foundation; either
1.11 + * version 2 of the License, or (at your option) any later version.
1.12 + *
1.13 + * This library is distributed in the hope that it will be useful,
1.14 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.15 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1.16 + * Lesser General Public License for more details.
1.17 + *
1.18 + * You should have received a copy of the GNU Lesser General
1.19 + * Public License along with this library; if not, write to the
1.20 + * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
1.21 + * Boston, MA 02111-1307, USA.
1.22 + *
1.23 + * gvaluecollector.h: GValue varargs stubs
1.24 + */
1.25 +#ifndef __G_VALUE_COLLECTOR_H__
1.26 +#define __G_VALUE_COLLECTOR_H__
1.27 +
1.28 +#include <glib-object.h>
1.29 +
1.30 +G_BEGIN_DECLS
1.31 +
1.32 +/* we may want to add aggregate types here some day, if requested
1.33 + * by users. the basic C types are covered already, everything
1.34 + * smaller than an int is promoted to an integer and floats are
1.35 + * always promoted to doubles for varargs call constructions.
1.36 + */
1.37 +enum /*< skip >*/
1.38 +{
1.39 + G_VALUE_COLLECT_INT = 'i',
1.40 + G_VALUE_COLLECT_LONG = 'l',
1.41 + G_VALUE_COLLECT_INT64 = 'q',
1.42 + G_VALUE_COLLECT_DOUBLE = 'd',
1.43 + G_VALUE_COLLECT_POINTER = 'p'
1.44 +};
1.45 +
1.46 +
1.47 +/* vararg union holding actuall values collected
1.48 + */
1.49 +union _GTypeCValue
1.50 +{
1.51 + gint v_int;
1.52 + glong v_long;
1.53 + gint64 v_int64;
1.54 + gdouble v_double;
1.55 + gpointer v_pointer;
1.56 +};
1.57 +
1.58 +
1.59 +/* G_VALUE_COLLECT() collects a variable argument value
1.60 + * from a va_list. we have to implement the varargs collection as a
1.61 + * macro, because on some systems va_list variables cannot be passed
1.62 + * by reference.
1.63 + * value is supposed to be initialized according to the value
1.64 + * type to be collected.
1.65 + * var_args is the va_list variable and may be evaluated multiple times.
1.66 + * __error is a gchar** variable that will be modified to hold a g_new()
1.67 + * allocated error messages if something fails.
1.68 + */
1.69 +#define G_VALUE_COLLECT(value, var_args, flags, __error) \
1.70 +G_STMT_START { \
1.71 + GValue *_value = (value); \
1.72 + guint _flags = (flags); \
1.73 + GType _value_type = G_VALUE_TYPE (_value); \
1.74 + GTypeValueTable *_vtable = g_type_value_table_peek (_value_type); \
1.75 + gchar *_collect_format = _vtable->collect_format; \
1.76 + GTypeCValue _cvalues[G_VALUE_COLLECT_FORMAT_MAX_LENGTH] = { { 0, }, }; \
1.77 + guint _n_values = 0; \
1.78 + \
1.79 + if (_vtable->value_free) \
1.80 + _vtable->value_free (_value); \
1.81 + _value->g_type = _value_type; /* value_meminit() from gvalue.c */ \
1.82 + memset (_value->data, 0, sizeof (_value->data)); \
1.83 + while (*_collect_format) \
1.84 + { \
1.85 + GTypeCValue *_cvalue = _cvalues + _n_values++; \
1.86 + \
1.87 + switch (*_collect_format++) \
1.88 + { \
1.89 + case G_VALUE_COLLECT_INT: \
1.90 + _cvalue->v_int = va_arg ((var_args), gint); \
1.91 + break; \
1.92 + case G_VALUE_COLLECT_LONG: \
1.93 + _cvalue->v_long = va_arg ((var_args), glong); \
1.94 + break; \
1.95 + case G_VALUE_COLLECT_INT64: \
1.96 + _cvalue->v_int64 = va_arg ((var_args), gint64); \
1.97 + break; \
1.98 + case G_VALUE_COLLECT_DOUBLE: \
1.99 + _cvalue->v_double = va_arg ((var_args), gdouble); \
1.100 + break; \
1.101 + case G_VALUE_COLLECT_POINTER: \
1.102 + _cvalue->v_pointer = va_arg ((var_args), gpointer); \
1.103 + break; \
1.104 + default: \
1.105 + g_assert_not_reached (); \
1.106 + } \
1.107 + } \
1.108 + *(__error) = _vtable->collect_value (_value, \
1.109 + _n_values, \
1.110 + _cvalues, \
1.111 + _flags); \
1.112 +} G_STMT_END
1.113 +
1.114 +
1.115 +/* G_VALUE_LCOPY() collects a value's variable argument
1.116 + * locations from a va_list. usage is analogous to G_VALUE_COLLECT().
1.117 + */
1.118 +#define G_VALUE_LCOPY(value, var_args, flags, __error) \
1.119 +G_STMT_START { \
1.120 + const GValue *_value = (value); \
1.121 + guint _flags = (flags); \
1.122 + GType _value_type = G_VALUE_TYPE (_value); \
1.123 + GTypeValueTable *_vtable = g_type_value_table_peek (_value_type); \
1.124 + gchar *_lcopy_format = _vtable->lcopy_format; \
1.125 + GTypeCValue _cvalues[G_VALUE_COLLECT_FORMAT_MAX_LENGTH] = { { 0, }, }; \
1.126 + guint _n_values = 0; \
1.127 + \
1.128 + while (*_lcopy_format) \
1.129 + { \
1.130 + GTypeCValue *_cvalue = _cvalues + _n_values++; \
1.131 + \
1.132 + switch (*_lcopy_format++) \
1.133 + { \
1.134 + case G_VALUE_COLLECT_INT: \
1.135 + _cvalue->v_int = va_arg ((var_args), gint); \
1.136 + break; \
1.137 + case G_VALUE_COLLECT_LONG: \
1.138 + _cvalue->v_long = va_arg ((var_args), glong); \
1.139 + break; \
1.140 + case G_VALUE_COLLECT_INT64: \
1.141 + _cvalue->v_int64 = va_arg ((var_args), gint64); \
1.142 + break; \
1.143 + case G_VALUE_COLLECT_DOUBLE: \
1.144 + _cvalue->v_double = va_arg ((var_args), gdouble); \
1.145 + break; \
1.146 + case G_VALUE_COLLECT_POINTER: \
1.147 + _cvalue->v_pointer = va_arg ((var_args), gpointer); \
1.148 + break; \
1.149 + default: \
1.150 + g_assert_not_reached (); \
1.151 + } \
1.152 + } \
1.153 + *(__error) = _vtable->lcopy_value (_value, \
1.154 + _n_values, \
1.155 + _cvalues, \
1.156 + _flags); \
1.157 +} G_STMT_END
1.158 +
1.159 +
1.160 +#define G_VALUE_COLLECT_FORMAT_MAX_LENGTH (8)
1.161 +
1.162 +G_END_DECLS
1.163 +
1.164 +#endif /* __G_VALUE_COLLECTOR_H__ */