mirror of
https://github.com/brl/mutter.git
synced 2024-12-23 19:42:05 +00:00
model: Clean up ModelIter vfunc wrappers
All ClutterModelIter virtual functions have a default implementation, and G_TYPE_INSTANCE_GET_CLASS cannot return NULL unless in case of a catastrophic event in the type system - which will most likely blow up any application code way before you could call a ModelIter method. Thus, the idiom: klass = CLUTTER_MODEL_ITER_GET_CLASS (instance); if (klass && klass->vfunc) klass->vfunc (instance); is utterly useless complication, and it can be perfectly replaced by: CLUTTER_MODEL_ITER_GET_CLASS (instance)->vfunc (instance); without any loss of safety.
This commit is contained in:
parent
e470fd7d82
commit
473f3817d4
@ -1761,8 +1761,6 @@ struct _ClutterModelIterPrivate
|
||||
ClutterModel *model;
|
||||
|
||||
gint row;
|
||||
|
||||
guint ignore_sort : 1;
|
||||
};
|
||||
|
||||
enum
|
||||
@ -1972,8 +1970,6 @@ clutter_model_iter_init (ClutterModelIter *self)
|
||||
|
||||
priv->model = NULL;
|
||||
priv->row = 0;
|
||||
|
||||
priv->ignore_sort = FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1985,11 +1981,7 @@ clutter_model_iter_set_value_internal (ClutterModelIter *iter,
|
||||
guint column,
|
||||
const GValue *value)
|
||||
{
|
||||
ClutterModelIterClass *klass;
|
||||
|
||||
klass = CLUTTER_MODEL_ITER_GET_CLASS (iter);
|
||||
if (klass && klass->set_value)
|
||||
klass->set_value (iter, column, value);
|
||||
CLUTTER_MODEL_ITER_GET_CLASS (iter)->set_value (iter, column, value);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -2005,9 +1997,6 @@ clutter_model_iter_set_internal_valist (ClutterModelIter *iter,
|
||||
|
||||
column = va_arg (args, gint);
|
||||
|
||||
/* Don't want to sort while setting lots of fields, leave that till the end
|
||||
*/
|
||||
priv->ignore_sort = TRUE;
|
||||
while (column != -1)
|
||||
{
|
||||
GValue value = { 0, };
|
||||
@ -2044,7 +2033,6 @@ clutter_model_iter_set_internal_valist (ClutterModelIter *iter,
|
||||
column = va_arg (args, gint);
|
||||
}
|
||||
|
||||
priv->ignore_sort = FALSE;
|
||||
if (sort)
|
||||
clutter_model_resort (model);
|
||||
}
|
||||
@ -2113,6 +2101,14 @@ clutter_model_iter_get (ClutterModelIter *iter,
|
||||
va_end (args);
|
||||
}
|
||||
|
||||
static inline void
|
||||
clutter_model_iter_get_value_internal (ClutterModelIter *iter,
|
||||
guint column,
|
||||
GValue *value)
|
||||
{
|
||||
CLUTTER_MODEL_ITER_GET_CLASS (iter)->get_value (iter, column, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_model_iter_get_value:
|
||||
* @iter: a #ClutterModelIter
|
||||
@ -2136,11 +2132,10 @@ clutter_model_iter_get_value (ClutterModelIter *iter,
|
||||
|
||||
model = iter->priv->model;
|
||||
|
||||
g_value_init (value, clutter_model_get_column_type (model, column));
|
||||
if (G_VALUE_TYPE (value) == G_TYPE_INVALID)
|
||||
g_value_init (value, clutter_model_get_column_type (model, column));
|
||||
|
||||
klass = CLUTTER_MODEL_ITER_GET_CLASS (iter);
|
||||
if (klass && klass->get_value)
|
||||
klass->get_value (iter, column, value);
|
||||
CLUTTER_MODEL_ITER_GET_CLASS (iter)->get_value (iter, column, value);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2173,6 +2168,7 @@ clutter_model_iter_get_valist (ClutterModelIter *iter,
|
||||
{
|
||||
GValue value = { 0, };
|
||||
gchar *error = NULL;
|
||||
GType col_type;
|
||||
|
||||
if (column < 0 || column >= clutter_model_get_n_columns (model))
|
||||
{
|
||||
@ -2182,10 +2178,10 @@ clutter_model_iter_get_valist (ClutterModelIter *iter,
|
||||
break;
|
||||
}
|
||||
|
||||
/* this one will take care of initialising value to the
|
||||
* correct type
|
||||
*/
|
||||
clutter_model_iter_get_value (iter, column, &value);
|
||||
col_type = clutter_model_get_column_type (model, column);
|
||||
g_value_init (&value, col_type);
|
||||
|
||||
clutter_model_iter_get_value_internal (iter, column, &value);
|
||||
|
||||
G_VALUE_LCOPY (&value, args, 0, &error);
|
||||
if (error)
|
||||
@ -2270,15 +2266,9 @@ clutter_model_iter_set_value (ClutterModelIter *iter,
|
||||
gboolean
|
||||
clutter_model_iter_is_first (ClutterModelIter *iter)
|
||||
{
|
||||
ClutterModelIterClass *klass;
|
||||
|
||||
g_return_val_if_fail (CLUTTER_IS_MODEL_ITER (iter), FALSE);
|
||||
|
||||
klass = CLUTTER_MODEL_ITER_GET_CLASS (iter);
|
||||
if (klass && klass->is_first)
|
||||
return klass->is_first (iter);
|
||||
|
||||
return FALSE;
|
||||
return CLUTTER_MODEL_ITER_GET_CLASS (iter)->is_first (iter);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2295,15 +2285,9 @@ clutter_model_iter_is_first (ClutterModelIter *iter)
|
||||
gboolean
|
||||
clutter_model_iter_is_last (ClutterModelIter *iter)
|
||||
{
|
||||
ClutterModelIterClass *klass;
|
||||
|
||||
g_return_val_if_fail (CLUTTER_IS_MODEL_ITER (iter), FALSE);
|
||||
|
||||
klass = CLUTTER_MODEL_ITER_GET_CLASS (iter);
|
||||
if (klass && klass->is_last)
|
||||
return klass->is_last (iter);
|
||||
|
||||
return FALSE;
|
||||
return CLUTTER_MODEL_ITER_GET_CLASS (iter)->is_last (iter);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2322,15 +2306,9 @@ clutter_model_iter_is_last (ClutterModelIter *iter)
|
||||
ClutterModelIter *
|
||||
clutter_model_iter_next (ClutterModelIter *iter)
|
||||
{
|
||||
ClutterModelIterClass *klass;
|
||||
|
||||
g_return_val_if_fail (CLUTTER_IS_MODEL_ITER (iter), NULL);
|
||||
|
||||
klass = CLUTTER_MODEL_ITER_GET_CLASS (iter);
|
||||
if (klass && klass->next)
|
||||
return klass->next (iter);
|
||||
|
||||
return NULL;
|
||||
return CLUTTER_MODEL_ITER_GET_CLASS (iter)->next (iter);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2349,15 +2327,9 @@ clutter_model_iter_next (ClutterModelIter *iter)
|
||||
ClutterModelIter *
|
||||
clutter_model_iter_prev (ClutterModelIter *iter)
|
||||
{
|
||||
ClutterModelIterClass *klass;
|
||||
|
||||
g_return_val_if_fail (CLUTTER_IS_MODEL_ITER (iter), NULL);
|
||||
|
||||
klass = CLUTTER_MODEL_ITER_GET_CLASS (iter);
|
||||
if (klass && klass->prev)
|
||||
return klass->prev (iter);
|
||||
|
||||
return NULL;
|
||||
return CLUTTER_MODEL_ITER_GET_CLASS (iter)->prev (iter);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2373,15 +2345,9 @@ clutter_model_iter_prev (ClutterModelIter *iter)
|
||||
ClutterModel *
|
||||
clutter_model_iter_get_model (ClutterModelIter *iter)
|
||||
{
|
||||
ClutterModelIterClass *klass;
|
||||
|
||||
g_return_val_if_fail (CLUTTER_IS_MODEL_ITER (iter), NULL);
|
||||
|
||||
klass = CLUTTER_MODEL_ITER_GET_CLASS (iter);
|
||||
if (klass && klass->get_model)
|
||||
return klass->get_model (iter);
|
||||
|
||||
return NULL;
|
||||
return CLUTTER_MODEL_ITER_GET_CLASS (iter)->get_model (iter);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2397,15 +2363,9 @@ clutter_model_iter_get_model (ClutterModelIter *iter)
|
||||
guint
|
||||
clutter_model_iter_get_row (ClutterModelIter *iter)
|
||||
{
|
||||
ClutterModelIterClass *klass;
|
||||
|
||||
g_return_val_if_fail (CLUTTER_IS_MODEL_ITER (iter), 0);
|
||||
|
||||
klass = CLUTTER_MODEL_ITER_GET_CLASS (iter);
|
||||
if (klass && klass->get_row)
|
||||
return klass->get_row (iter);
|
||||
|
||||
return 0;
|
||||
return CLUTTER_MODEL_ITER_GET_CLASS (iter)->get_row (iter);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2421,13 +2381,7 @@ clutter_model_iter_get_row (ClutterModelIter *iter)
|
||||
ClutterModelIter *
|
||||
clutter_model_iter_copy (ClutterModelIter *iter)
|
||||
{
|
||||
ClutterModelIterClass *klass;
|
||||
|
||||
g_return_val_if_fail (CLUTTER_IS_MODEL_ITER (iter), NULL);
|
||||
|
||||
klass = CLUTTER_MODEL_ITER_GET_CLASS (iter);
|
||||
if (klass->copy)
|
||||
return klass->copy (iter);
|
||||
|
||||
return NULL;
|
||||
return CLUTTER_MODEL_ITER_GET_CLASS (iter)->copy (iter);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user