for unknown foreign fundamental types, collect an argument of the type

Sat Oct  3 17:54:48 1998  Tim Janik  <timj@gtk.org>

        * gtk/gtkargcollector.c (GTK_ARG_COLLECT_VALUE): for unknown foreign
        fundamental types, collect an argument of the type returned from
        gtk_type_get_varargs_type(). removed the first macro argument which
        was just the same as the fundamental type of the *arg passed to
        the macro.
        * gtk/gtkarg.c (gtk_args_collect):
        * gtk/gtksignal.c (gtk_signal_collect_params): changed callers.

        * gtk/gtktypeutils.h:
        * gtk/gtktypeutils.c: new functions gtk_type_set_varargs_type() and
        gtk_type_get_varargs_type() to set and query the varargs collect
        type used for a fundamental type, registered outside of Gtk.

        * gtk/gtkmisc.c (gtk_misc_class_init): changed object arguments
        GtkMisc::xalign and GtkMisc::yalign from GTK_TYPE_DOUBLE to
        GTK_TYPE_FLOAT.

        * gtk/gtkframe.c (gtk_frame_class_init): changed object arguments
        GtkFrame::label_xalign and GtkFrame::label_yalign from GTK_TYPE_DOUBLE
        to GTK_TYPE_FLOAT.
This commit is contained in:
Tim Janik 1998-10-03 17:04:41 +00:00 committed by Tim Janik
parent 879683b674
commit c62ab96bcc
14 changed files with 255 additions and 21 deletions

View File

@ -1,3 +1,26 @@
Sat Oct 3 17:54:48 1998 Tim Janik <timj@gtk.org>
* gtk/gtkargcollector.c (GTK_ARG_COLLECT_VALUE): for unknown foreign
fundamental types, collect an argument of the type returned from
gtk_type_get_varargs_type(). removed the first macro argument which
was just the same as the fundamental type of the *arg passed to
the macro.
* gtk/gtkarg.c (gtk_args_collect):
* gtk/gtksignal.c (gtk_signal_collect_params): changed callers.
* gtk/gtktypeutils.h:
* gtk/gtktypeutils.c: new functions gtk_type_set_varargs_type() and
gtk_type_get_varargs_type() to set and query the varargs collect
type used for a fundamental type, registered outside of Gtk.
* gtk/gtkmisc.c (gtk_misc_class_init): changed object arguments
GtkMisc::xalign and GtkMisc::yalign from GTK_TYPE_DOUBLE to
GTK_TYPE_FLOAT.
* gtk/gtkframe.c (gtk_frame_class_init): changed object arguments
GtkFrame::label_xalign and GtkFrame::label_yalign from GTK_TYPE_DOUBLE
to GTK_TYPE_FLOAT.
Sat Oct 3 01:25:24 1998 Lars Hamann <lars@gtk.org>
* gtk/gtkctree.c (gtk_ctree_insert_gnode) (real_tree_collapse)

View File

@ -1,3 +1,26 @@
Sat Oct 3 17:54:48 1998 Tim Janik <timj@gtk.org>
* gtk/gtkargcollector.c (GTK_ARG_COLLECT_VALUE): for unknown foreign
fundamental types, collect an argument of the type returned from
gtk_type_get_varargs_type(). removed the first macro argument which
was just the same as the fundamental type of the *arg passed to
the macro.
* gtk/gtkarg.c (gtk_args_collect):
* gtk/gtksignal.c (gtk_signal_collect_params): changed callers.
* gtk/gtktypeutils.h:
* gtk/gtktypeutils.c: new functions gtk_type_set_varargs_type() and
gtk_type_get_varargs_type() to set and query the varargs collect
type used for a fundamental type, registered outside of Gtk.
* gtk/gtkmisc.c (gtk_misc_class_init): changed object arguments
GtkMisc::xalign and GtkMisc::yalign from GTK_TYPE_DOUBLE to
GTK_TYPE_FLOAT.
* gtk/gtkframe.c (gtk_frame_class_init): changed object arguments
GtkFrame::label_xalign and GtkFrame::label_yalign from GTK_TYPE_DOUBLE
to GTK_TYPE_FLOAT.
Sat Oct 3 01:25:24 1998 Lars Hamann <lars@gtk.org>
* gtk/gtkctree.c (gtk_ctree_insert_gnode) (real_tree_collapse)

View File

@ -1,3 +1,26 @@
Sat Oct 3 17:54:48 1998 Tim Janik <timj@gtk.org>
* gtk/gtkargcollector.c (GTK_ARG_COLLECT_VALUE): for unknown foreign
fundamental types, collect an argument of the type returned from
gtk_type_get_varargs_type(). removed the first macro argument which
was just the same as the fundamental type of the *arg passed to
the macro.
* gtk/gtkarg.c (gtk_args_collect):
* gtk/gtksignal.c (gtk_signal_collect_params): changed callers.
* gtk/gtktypeutils.h:
* gtk/gtktypeutils.c: new functions gtk_type_set_varargs_type() and
gtk_type_get_varargs_type() to set and query the varargs collect
type used for a fundamental type, registered outside of Gtk.
* gtk/gtkmisc.c (gtk_misc_class_init): changed object arguments
GtkMisc::xalign and GtkMisc::yalign from GTK_TYPE_DOUBLE to
GTK_TYPE_FLOAT.
* gtk/gtkframe.c (gtk_frame_class_init): changed object arguments
GtkFrame::label_xalign and GtkFrame::label_yalign from GTK_TYPE_DOUBLE
to GTK_TYPE_FLOAT.
Sat Oct 3 01:25:24 1998 Lars Hamann <lars@gtk.org>
* gtk/gtkctree.c (gtk_ctree_insert_gnode) (real_tree_collapse)

View File

@ -1,3 +1,26 @@
Sat Oct 3 17:54:48 1998 Tim Janik <timj@gtk.org>
* gtk/gtkargcollector.c (GTK_ARG_COLLECT_VALUE): for unknown foreign
fundamental types, collect an argument of the type returned from
gtk_type_get_varargs_type(). removed the first macro argument which
was just the same as the fundamental type of the *arg passed to
the macro.
* gtk/gtkarg.c (gtk_args_collect):
* gtk/gtksignal.c (gtk_signal_collect_params): changed callers.
* gtk/gtktypeutils.h:
* gtk/gtktypeutils.c: new functions gtk_type_set_varargs_type() and
gtk_type_get_varargs_type() to set and query the varargs collect
type used for a fundamental type, registered outside of Gtk.
* gtk/gtkmisc.c (gtk_misc_class_init): changed object arguments
GtkMisc::xalign and GtkMisc::yalign from GTK_TYPE_DOUBLE to
GTK_TYPE_FLOAT.
* gtk/gtkframe.c (gtk_frame_class_init): changed object arguments
GtkFrame::label_xalign and GtkFrame::label_yalign from GTK_TYPE_DOUBLE
to GTK_TYPE_FLOAT.
Sat Oct 3 01:25:24 1998 Lars Hamann <lars@gtk.org>
* gtk/gtkctree.c (gtk_ctree_insert_gnode) (real_tree_collapse)

View File

@ -1,3 +1,26 @@
Sat Oct 3 17:54:48 1998 Tim Janik <timj@gtk.org>
* gtk/gtkargcollector.c (GTK_ARG_COLLECT_VALUE): for unknown foreign
fundamental types, collect an argument of the type returned from
gtk_type_get_varargs_type(). removed the first macro argument which
was just the same as the fundamental type of the *arg passed to
the macro.
* gtk/gtkarg.c (gtk_args_collect):
* gtk/gtksignal.c (gtk_signal_collect_params): changed callers.
* gtk/gtktypeutils.h:
* gtk/gtktypeutils.c: new functions gtk_type_set_varargs_type() and
gtk_type_get_varargs_type() to set and query the varargs collect
type used for a fundamental type, registered outside of Gtk.
* gtk/gtkmisc.c (gtk_misc_class_init): changed object arguments
GtkMisc::xalign and GtkMisc::yalign from GTK_TYPE_DOUBLE to
GTK_TYPE_FLOAT.
* gtk/gtkframe.c (gtk_frame_class_init): changed object arguments
GtkFrame::label_xalign and GtkFrame::label_yalign from GTK_TYPE_DOUBLE
to GTK_TYPE_FLOAT.
Sat Oct 3 01:25:24 1998 Lars Hamann <lars@gtk.org>
* gtk/gtkctree.c (gtk_ctree_insert_gnode) (real_tree_collapse)

View File

@ -1,3 +1,26 @@
Sat Oct 3 17:54:48 1998 Tim Janik <timj@gtk.org>
* gtk/gtkargcollector.c (GTK_ARG_COLLECT_VALUE): for unknown foreign
fundamental types, collect an argument of the type returned from
gtk_type_get_varargs_type(). removed the first macro argument which
was just the same as the fundamental type of the *arg passed to
the macro.
* gtk/gtkarg.c (gtk_args_collect):
* gtk/gtksignal.c (gtk_signal_collect_params): changed callers.
* gtk/gtktypeutils.h:
* gtk/gtktypeutils.c: new functions gtk_type_set_varargs_type() and
gtk_type_get_varargs_type() to set and query the varargs collect
type used for a fundamental type, registered outside of Gtk.
* gtk/gtkmisc.c (gtk_misc_class_init): changed object arguments
GtkMisc::xalign and GtkMisc::yalign from GTK_TYPE_DOUBLE to
GTK_TYPE_FLOAT.
* gtk/gtkframe.c (gtk_frame_class_init): changed object arguments
GtkFrame::label_xalign and GtkFrame::label_yalign from GTK_TYPE_DOUBLE
to GTK_TYPE_FLOAT.
Sat Oct 3 01:25:24 1998 Lars Hamann <lars@gtk.org>
* gtk/gtkctree.c (gtk_ctree_insert_gnode) (real_tree_collapse)

View File

@ -1,3 +1,26 @@
Sat Oct 3 17:54:48 1998 Tim Janik <timj@gtk.org>
* gtk/gtkargcollector.c (GTK_ARG_COLLECT_VALUE): for unknown foreign
fundamental types, collect an argument of the type returned from
gtk_type_get_varargs_type(). removed the first macro argument which
was just the same as the fundamental type of the *arg passed to
the macro.
* gtk/gtkarg.c (gtk_args_collect):
* gtk/gtksignal.c (gtk_signal_collect_params): changed callers.
* gtk/gtktypeutils.h:
* gtk/gtktypeutils.c: new functions gtk_type_set_varargs_type() and
gtk_type_get_varargs_type() to set and query the varargs collect
type used for a fundamental type, registered outside of Gtk.
* gtk/gtkmisc.c (gtk_misc_class_init): changed object arguments
GtkMisc::xalign and GtkMisc::yalign from GTK_TYPE_DOUBLE to
GTK_TYPE_FLOAT.
* gtk/gtkframe.c (gtk_frame_class_init): changed object arguments
GtkFrame::label_xalign and GtkFrame::label_yalign from GTK_TYPE_DOUBLE
to GTK_TYPE_FLOAT.
Sat Oct 3 01:25:24 1998 Lars Hamann <lars@gtk.org>
* gtk/gtkctree.c (gtk_ctree_insert_gnode) (real_tree_collapse)

View File

@ -263,7 +263,7 @@ gtk_args_collect (GtkType object_type,
arg = gtk_arg_new (info->type);
arg->name = (gchar*) arg_name;
GTK_ARG_COLLECT_VALUE (GTK_FUNDAMENTAL_TYPE (arg->type), arg, var_args, error);
GTK_ARG_COLLECT_VALUE (arg, var_args, error);
arg_list = g_slist_prepend (arg_list, arg);
}
if (error)

View File

@ -20,16 +20,23 @@
/* collect a single argument value from a va_list.
* this is implemented as a huge macro <shrug>, because we can't
* pass va_list variables by reference on some systems.
* the former prototype was:
* the corresponding prototype would be:
* static inline gchar*
* gtk_arg_collect_value (GtkType fundamental_type,
* GtkArg *arg,
* gtk_arg_collect_value (GtkArg *arg,
* va_list var_args);
*/
#define GTK_ARG_COLLECT_VALUE(_ft, arg, var_args, _error) \
#define GTK_ARG_COLLECT_VALUE(arg, var_args, _error) \
G_STMT_START { \
GtkType fundamental_type = _ft; \
gchar *error_msg; \
GtkType fundamental_type; \
\
fundamental_type = GTK_FUNDAMENTAL_TYPE (arg->type); \
if (fundamental_type > GTK_TYPE_FUNDAMENTAL_LAST) \
{ \
fundamental_type = gtk_type_get_varargs_type (fundamental_type); \
if (!fundamental_type) \
fundamental_type = GTK_FUNDAMENTAL_TYPE (arg->type); \
} \
\
error_msg = NULL; \
switch (fundamental_type) \

View File

@ -91,8 +91,8 @@ gtk_frame_class_init (GtkFrameClass *class)
parent_class = gtk_type_class (gtk_bin_get_type ());
gtk_object_add_arg_type ("GtkFrame::label", GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_LABEL);
gtk_object_add_arg_type ("GtkFrame::label_xalign", GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, ARG_LABEL_XALIGN);
gtk_object_add_arg_type ("GtkFrame::label_yalign", GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, ARG_LABEL_YALIGN);
gtk_object_add_arg_type ("GtkFrame::label_xalign", GTK_TYPE_FLOAT, GTK_ARG_READWRITE, ARG_LABEL_XALIGN);
gtk_object_add_arg_type ("GtkFrame::label_yalign", GTK_TYPE_FLOAT, GTK_ARG_READWRITE, ARG_LABEL_YALIGN);
gtk_object_add_arg_type ("GtkFrame::shadow", GTK_TYPE_SHADOW_TYPE, GTK_ARG_READWRITE, ARG_SHADOW);
object_class->set_arg = gtk_frame_set_arg;
@ -134,10 +134,10 @@ gtk_frame_set_arg (GtkObject *object,
gtk_frame_set_label (frame, GTK_VALUE_STRING (*arg));
break;
case ARG_LABEL_XALIGN:
gtk_frame_set_label_align (frame, GTK_VALUE_DOUBLE (*arg), frame->label_yalign);
gtk_frame_set_label_align (frame, GTK_VALUE_FLOAT (*arg), frame->label_yalign);
break;
case ARG_LABEL_YALIGN:
gtk_frame_set_label_align (frame, frame->label_xalign, GTK_VALUE_DOUBLE (*arg));
gtk_frame_set_label_align (frame, frame->label_xalign, GTK_VALUE_FLOAT (*arg));
break;
case ARG_SHADOW:
gtk_frame_set_shadow_type (frame, GTK_VALUE_ENUM (*arg));
@ -162,10 +162,10 @@ gtk_frame_get_arg (GtkObject *object,
GTK_VALUE_STRING (*arg) = g_strdup (frame->label);
break;
case ARG_LABEL_XALIGN:
GTK_VALUE_DOUBLE (*arg) = frame->label_xalign;
GTK_VALUE_FLOAT (*arg) = frame->label_xalign;
break;
case ARG_LABEL_YALIGN:
GTK_VALUE_DOUBLE (*arg) = frame->label_yalign;
GTK_VALUE_FLOAT (*arg) = frame->label_yalign;
break;
case ARG_SHADOW:
GTK_VALUE_ENUM (*arg) = frame->shadow_type;

View File

@ -73,8 +73,8 @@ gtk_misc_class_init (GtkMiscClass *class)
object_class = (GtkObjectClass*) class;
widget_class = (GtkWidgetClass*) class;
gtk_object_add_arg_type ("GtkMisc::xalign", GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, ARG_XALIGN);
gtk_object_add_arg_type ("GtkMisc::yalign", GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, ARG_YALIGN);
gtk_object_add_arg_type ("GtkMisc::xalign", GTK_TYPE_FLOAT, GTK_ARG_READWRITE, ARG_XALIGN);
gtk_object_add_arg_type ("GtkMisc::yalign", GTK_TYPE_FLOAT, GTK_ARG_READWRITE, ARG_YALIGN);
gtk_object_add_arg_type ("GtkMisc::xpad", GTK_TYPE_INT, GTK_ARG_READWRITE, ARG_XPAD);
gtk_object_add_arg_type ("GtkMisc::ypad", GTK_TYPE_INT, GTK_ARG_READWRITE, ARG_YPAD);
@ -107,10 +107,10 @@ gtk_misc_set_arg (GtkObject *object,
switch (arg_id)
{
case ARG_XALIGN:
gtk_misc_set_alignment (misc, GTK_VALUE_DOUBLE (*arg), misc->yalign);
gtk_misc_set_alignment (misc, GTK_VALUE_FLOAT (*arg), misc->yalign);
break;
case ARG_YALIGN:
gtk_misc_set_alignment (misc, misc->xalign, GTK_VALUE_DOUBLE (*arg));
gtk_misc_set_alignment (misc, misc->xalign, GTK_VALUE_FLOAT (*arg));
break;
case ARG_XPAD:
gtk_misc_set_padding (misc, GTK_VALUE_INT (*arg), misc->ypad);
@ -135,10 +135,10 @@ gtk_misc_get_arg (GtkObject *object,
switch (arg_id)
{
case ARG_XALIGN:
GTK_VALUE_DOUBLE (*arg) = misc->xalign;
GTK_VALUE_FLOAT (*arg) = misc->xalign;
break;
case ARG_YALIGN:
GTK_VALUE_DOUBLE (*arg) = misc->yalign;
GTK_VALUE_FLOAT (*arg) = misc->yalign;
break;
case ARG_XPAD:
GTK_VALUE_INT (*arg) = misc->xpad;

View File

@ -1778,10 +1778,9 @@ gtk_signal_collect_params (GtkArg *params,
{
register gchar *error;
params->type = *(param_types++);
params->name = NULL;
GTK_ARG_COLLECT_VALUE (GTK_FUNDAMENTAL_TYPE (params->type),
params,
params->type = *(param_types++);
GTK_ARG_COLLECT_VALUE (params,
var_args,
error);
if (error)

View File

@ -708,6 +708,65 @@ gtk_type_flags_find_value (GtkType flag_type,
return gtk_type_enum_find_value (flag_type, value_name);
}
typedef struct _GtkTypeVarargType GtkTypeVarargType;
struct _GtkTypeVarargType
{
GtkType foreign_type;
GtkType varargs_type;
};
static GtkTypeVarargType *vararg_types = NULL;
static guint n_vararg_types = 0;
void
gtk_type_set_varargs_type (GtkType foreign_type,
GtkType varargs_type)
{
g_return_if_fail (foreign_type == GTK_FUNDAMENTAL_TYPE (foreign_type));
g_return_if_fail (foreign_type > GTK_TYPE_FUNDAMENTAL_LAST);
if (!((varargs_type >= GTK_TYPE_STRUCTURED_FIRST &&
varargs_type <= GTK_TYPE_STRUCTURED_LAST) ||
(varargs_type >= GTK_TYPE_FLAT_FIRST &&
varargs_type <= GTK_TYPE_FLAT_LAST) ||
varargs_type == GTK_TYPE_NONE))
{
g_warning ("invalid varargs type `%s' for fundamental type `%s'",
gtk_type_name (varargs_type),
gtk_type_name (foreign_type));
return;
}
if (gtk_type_get_varargs_type (foreign_type))
{
g_warning ("varargs type is already registered for fundamental type `%s'",
gtk_type_name (foreign_type));
return;
}
n_vararg_types++;
vararg_types = g_realloc (vararg_types, sizeof (GtkTypeVarargType) * n_vararg_types);
vararg_types[n_vararg_types - 1].foreign_type = foreign_type;
vararg_types[n_vararg_types - 1].varargs_type = varargs_type;
}
GtkType
gtk_type_get_varargs_type (GtkType foreign_type)
{
GtkType type;
guint i;
type = GTK_FUNDAMENTAL_TYPE (foreign_type);
if (type <= GTK_TYPE_FUNDAMENTAL_LAST)
return type;
for (i = 0; i < n_vararg_types; i++)
if (vararg_types[i].foreign_type == type)
return vararg_types[i].varargs_type;
return 0;
}
static inline GtkType
gtk_type_register_intern (gchar *name,
GtkType parent,

View File

@ -342,6 +342,14 @@ GtkEnumValue* gtk_type_enum_find_value (GtkType enum_type,
const gchar *value_name);
GtkFlagValue* gtk_type_flags_find_value (GtkType flag_type,
const gchar *value_name);
/* set the argument collector alias for foreign fundamentals */
void gtk_type_set_varargs_type (GtkType foreign_type,
GtkType varargs_type);
GtkType gtk_type_get_varargs_type (GtkType foreign_type);
#ifdef __cplusplus
}