Commit 00db6c06 authored by Morten Welinder's avatar Morten Welinder

Try!

parent 7d0e34fe
......@@ -81,9 +81,9 @@ val_to_base (FunctionEvalInfo *ei,
value_new_error_VALUE (ei->pos));
/* func.c ought to take care of this. */
if (VALUE_TYPE (value) == VALUE_BOOLEAN)
if (VALUE_IS_BOOLEAN (value))
return value_new_error_VALUE (ei->pos);
if (aplaces && VALUE_TYPE (aplaces) == VALUE_BOOLEAN)
if (aplaces && VALUE_IS_BOOLEAN (aplaces))
return value_new_error_VALUE (ei->pos);
switch (VALUE_TYPE (value)) {
......@@ -96,7 +96,7 @@ val_to_base (FunctionEvalInfo *ei,
(value_peek_string (value), NULL,
workbook_date_conv (ei->pos->sheet->workbook));
if (!vstring ||
VALUE_TYPE (vstring) == VALUE_BOOLEAN ||
VALUE_IS_BOOLEAN (vstring) ||
!VALUE_IS_NUMBER (vstring)) {
if (vstring)
value_release (vstring);
......
......@@ -1393,7 +1393,7 @@ static GnmFuncHelp const help_iserror[] = {
static GnmValue *
gnumeric_iserror (FunctionEvalInfo *ei, GnmValue const * const *argv)
{
return value_new_bool (argv[0]->type == VALUE_ERROR);
return value_new_bool (VALUE_IS_ERROR (argv[0]));
}
/***************************************************************************/
......@@ -1447,7 +1447,7 @@ static GnmFuncHelp const help_iserr[] = {
static GnmValue *
gnumeric_iserr (FunctionEvalInfo *ei, GnmValue const * const *argv)
{
return value_new_bool (argv[0]->type == VALUE_ERROR &&
return value_new_bool (VALUE_IS_ERROR (argv[0]) &&
value_error_classify (argv[0]) != GNM_ERROR_NA);
}
......@@ -1618,7 +1618,7 @@ static GnmFuncHelp const help_islogical[] = {
static GnmValue *
gnumeric_islogical (FunctionEvalInfo *ei, GnmValue const * const *argv)
{
return value_new_bool (argv[0]->type == VALUE_BOOLEAN);
return value_new_bool (VALUE_IS_BOOLEAN (argv[0]));
}
/***************************************************************************/
......@@ -1669,7 +1669,7 @@ static GnmValue *
gnumeric_isnumber (FunctionEvalInfo *ei, GnmValue const * const *argv)
{
return value_new_bool (argv[0] != NULL &&
argv[0]->type != VALUE_BOOLEAN &&
!VALUE_IS_STRING (argv[0]) &&
VALUE_IS_NUMBER (argv[0]));
}
......
......@@ -454,7 +454,7 @@ gnumeric_areas (FunctionEvalInfo *ei, int argc, const GnmExprConstPtr *argv)
restart:
switch (GNM_EXPR_GET_OPER (expr)) {
case GNM_EXPR_OP_CONSTANT:
if (expr->constant.value->type == VALUE_ERROR)
if (VALUE_IS_ERROR (expr->constant.value))
return value_dup (expr->constant.value);
if (expr->constant.value->type != VALUE_CELLRANGE)
break;
......@@ -536,7 +536,7 @@ gnumeric_choose (FunctionEvalInfo *ei, int argc, const GnmExprConstPtr *argv)
if (!v)
return NULL;
if (v->type == VALUE_BOOLEAN || !VALUE_IS_NUMBER (v)) {
if (VALUE_IS_BOOLEAN (v) || !VALUE_IS_NUMBER (v)) {
value_release (v);
return value_new_error_VALUE (ei->pos);
}
......
......@@ -64,7 +64,7 @@ callback_function_sumxy (Sheet *sheet, int col, int row,
mm->num++;
return NULL;
} else if (cell->value->type == VALUE_ERROR)
} else if (VALUE_IS_ERROR (cell->value))
return VALUE_TERMINATE; /* FIXME: This is probably wrong. */
else
return NULL;
......
......@@ -836,7 +836,7 @@ callback_function_count (GnmEvalPos const *ep, GnmValue const *value, void *clos
{
GnmValue *result = (GnmValue *) closure;
if (value && VALUE_IS_NUMBER (value) && value->type != VALUE_BOOLEAN)
if (value && VALUE_IS_NUMBER (value) && !VALUE_IS_BOOLEAN (value))
result->v_int.val++;
return NULL;
}
......@@ -5357,7 +5357,7 @@ gnumeric_subtotal (FunctionEvalInfo *ei, int argc, const GnmExprConstPtr *argv)
return value_new_error_NUM (ei->pos);
val = gnm_expr_eval (expr, ei->pos, GNM_EXPR_EVAL_SCALAR_NON_EMPTY);
if (val->type == VALUE_ERROR)
if (VALUE_IS_ERROR (val))
return val;
fun_nbr = value_get_as_int (val);
value_release (val);
......
......@@ -462,7 +462,7 @@ cell_is_error (GnmCell const * cell)
g_return_val_if_fail (cell != NULL, NULL);
g_return_val_if_fail (cell->value != NULL, NULL);
if (cell->value->type == VALUE_ERROR)
if (VALUE_IS_ERROR (cell->value))
return cell->value;
return NULL;
}
......
......@@ -79,7 +79,7 @@ callback_function_collect (GnmEvalPos const *ep, GnmValue const *value,
GnmValue *vc = format_match_number (value_peek_string (value),
NULL,
cl->date_conv);
gboolean bad = !vc || VALUE_TYPE(vc) == VALUE_BOOLEAN;
gboolean bad = !vc || VALUE_IS_BOOLEAN (vc);
if (vc) {
x = value_get_as_float (vc);
value_release (vc);
......@@ -184,7 +184,7 @@ collect_floats (int argc, const GnmExprConstPtr *argv,
TRUE, iter_flags);
if (err) {
g_assert (err->type == VALUE_ERROR);
g_assert (VALUE_IS_ERROR (err));
g_free (cl.data);
g_slist_free (cl.info);
*error = err;
......@@ -517,7 +517,7 @@ collect_strings (int argc, const GnmExprConstPtr *argv,
TRUE, (flags & COLLECT_IGNORE_BLANKS) ? CELL_ITER_IGNORE_BLANK : CELL_ITER_ALL);
if (err) {
g_assert (err->type == VALUE_ERROR);
g_assert (VALUE_IS_ERROR (err));
g_slist_foreach (cl.data, (GFunc)g_free, NULL);
g_slist_free (cl.data);
*error = err;
......
......@@ -152,7 +152,7 @@ search_get_value (gint row, gint column, gpointer _dd, GValue *value)
type = _("Expression");
else if (is_value && VALUE_IS_STRING (v))
type = _("String");
else if (is_value && VALUE_IS_NUMBER (v) && v->type != VALUE_BOOLEAN)
else if (is_value && VALUE_IS_NUMBER (v) && !VALUE_IS_BOOLEAN (v))
type = _("Number");
else
type = _("Other value");
......
......@@ -771,9 +771,9 @@ static GnmValue *
cb_bin_cmp (GnmEvalPos const *ep, GnmValue const *a, GnmValue const *b,
GnmExpr const *expr)
{
if (a != NULL && a->type == VALUE_ERROR)
if (a != NULL && VALUE_IS_ERROR (a))
return value_dup (a);
if (b != NULL && b->type == VALUE_ERROR)
if (b != NULL && VALUE_IS_ERROR (b))
return value_dup (b);
return bin_cmp (GNM_EXPR_GET_OPER (expr), value_compare (a, b, FALSE), ep);
}
......@@ -784,9 +784,9 @@ cb_bin_arith (GnmEvalPos const *ep, GnmValue const *a, GnmValue const *b,
{
GnmValue *res, *va, *vb;
if (a != NULL && a->type == VALUE_ERROR)
if (a != NULL && VALUE_IS_ERROR (a))
return value_dup (a);
if (b != NULL && b->type == VALUE_ERROR)
if (b != NULL && VALUE_IS_ERROR (b))
return value_dup (b);
if (VALUE_IS_EMPTY (a))
a = va = (GnmValue *)value_zero;
......@@ -828,9 +828,9 @@ static GnmValue *
cb_bin_cat (GnmEvalPos const *ep, GnmValue const *a, GnmValue const *b,
GnmExpr const *expr)
{
if (a != NULL && a->type == VALUE_ERROR)
if (a != NULL && VALUE_IS_ERROR (a))
return value_dup (a);
if (b != NULL && b->type == VALUE_ERROR)
if (b != NULL && VALUE_IS_ERROR (b))
return value_dup (b);
if (a == NULL) {
if (b != NULL)
......@@ -889,7 +889,7 @@ bin_array_op (GnmEvalPos const *ep, const GnmValue *sizer,
{
BinOpImplicitIteratorState iter_info;
if (sizer != a || b == NULL || b->type != VALUE_ERROR) {
if (sizer != a || b == NULL || !VALUE_IS_ERROR (b)) {
iter_info.func = func;
iter_info.user_data = user_data;
iter_info.a = a;
......@@ -936,7 +936,7 @@ cb_iter_unary_neg (GnmValue const *v, GnmEvalPos const *ep,
if (VALUE_IS_EMPTY (v))
tmp = value_new_int (0);
else if (v->type == VALUE_ERROR)
else if (VALUE_IS_ERROR (v))
tmp = value_dup (v);
else if (VALUE_IS_STRING (v)) {
GnmValue *conv = format_match_number
......@@ -966,7 +966,7 @@ cb_iter_percentage (GnmValue const *v, GnmEvalPos const *ep,
if (VALUE_IS_EMPTY (v))
tmp = value_new_int (0);
else if (v->type == VALUE_ERROR)
else if (VALUE_IS_ERROR (v))
tmp = value_dup (v);
else {
GnmValue *conv = NULL;
......@@ -1052,7 +1052,7 @@ gnm_expr_eval (GnmExpr const *expr, GnmEvalPos const *pos,
a = gnm_expr_eval (expr->binary.value_a, pos, flags);
if (a != NULL) {
if (a->type == VALUE_ERROR)
if (VALUE_IS_ERROR (a))
return a;
if (a->type == VALUE_CELLRANGE || a->type == VALUE_ARRAY)
return bin_array_op (pos, a, a,
......@@ -1063,7 +1063,7 @@ gnm_expr_eval (GnmExpr const *expr, GnmEvalPos const *pos,
b = gnm_expr_eval (expr->binary.value_b, pos, flags);
if (b != NULL) {
if (b->type == VALUE_ERROR) {
if (VALUE_IS_ERROR (b)) {
if (a != NULL)
value_release (a);
return b;
......@@ -1100,7 +1100,7 @@ gnm_expr_eval (GnmExpr const *expr, GnmEvalPos const *pos,
/* 1) Error from A */
a = gnm_expr_eval (expr->binary.value_a, pos, flags);
if (a->type == VALUE_ERROR)
if (VALUE_IS_ERROR (a))
return value_error_set_pos (&a->v_err, pos);
/* 2) #!VALUE error if A is not a number */
......@@ -1130,7 +1130,7 @@ gnm_expr_eval (GnmExpr const *expr, GnmEvalPos const *pos,
/* 3) Error from B */
b = gnm_expr_eval (expr->binary.value_b, pos, flags);
if (b->type == VALUE_ERROR) {
if (VALUE_IS_ERROR (b)) {
value_release (a);
return value_error_set_pos (&b->v_err, pos);
}
......@@ -1168,7 +1168,7 @@ gnm_expr_eval (GnmExpr const *expr, GnmEvalPos const *pos,
flags &= ~GNM_EXPR_EVAL_PERMIT_EMPTY;
a = gnm_expr_eval (expr->unary.value, pos, flags);
if (a->type == VALUE_ERROR)
if (VALUE_IS_ERROR (a))
return a;
if (GNM_EXPR_GET_OPER (expr) == GNM_EXPR_OP_UNARY_PLUS)
return a;
......@@ -1209,7 +1209,7 @@ gnm_expr_eval (GnmExpr const *expr, GnmEvalPos const *pos,
flags |= GNM_EXPR_EVAL_PERMIT_EMPTY;
a = gnm_expr_eval (expr->binary.value_a, pos, flags);
if (a != NULL) {
if (a->type == VALUE_ERROR)
if (VALUE_IS_ERROR (a))
return a;
if (a->type == VALUE_CELLRANGE || a->type == VALUE_ARRAY)
return bin_array_op (pos, a, a,
......@@ -1219,7 +1219,7 @@ gnm_expr_eval (GnmExpr const *expr, GnmEvalPos const *pos,
}
b = gnm_expr_eval (expr->binary.value_b, pos, flags);
if (b != NULL) {
if (b->type == VALUE_ERROR) {
if (VALUE_IS_ERROR (b)) {
if (a != NULL)
value_release (a);
return b;
......
......@@ -1151,7 +1151,7 @@ function_call_with_exprs (FunctionEvalInfo *ei,
}
value_release (args [i]);
args[i] = tmp;
} else if (tmp->type == VALUE_ERROR) {
} else if (VALUE_IS_ERROR (tmp)) {
free_values (args, i);
return tmp;
} else if (VALUE_IS_EMPTY (tmp)) {
......@@ -1165,7 +1165,7 @@ function_call_with_exprs (FunctionEvalInfo *ei,
case 's':
case 'S':
if (tmp->type == VALUE_ERROR) {
if (VALUE_IS_ERROR (tmp)) {
free_values (args, i);
return tmp;
}
......@@ -1213,7 +1213,7 @@ function_call_with_exprs (FunctionEvalInfo *ei,
continue;
} else
break;
} else if (elem->type == VALUE_ERROR) {
} else if (VALUE_IS_ERROR (elem)) {
err = elem;
break;
} else if (!VALUE_IS_NUMBER (elem))
......@@ -1222,7 +1222,7 @@ function_call_with_exprs (FunctionEvalInfo *ei,
if (VALUE_IS_EMPTY (elem)) {
args [iter_item[i]] = iter_args [i] = value_new_string ("");
continue;
} else if (elem->type == VALUE_ERROR) {
} else if (VALUE_IS_ERROR (elem)) {
err = elem;
break;
} else if (!VALUE_IS_STRING (tmp))
......@@ -1501,7 +1501,7 @@ function_iterate_argument_values (GnmEvalPos const *ep,
if (val == NULL)
continue;
if (strict && val->type == VALUE_ERROR) {
if (strict && VALUE_IS_ERROR (val)) {
/* Be careful not to make VALUE_TERMINATE into a real value */
/* FIXME : Make the new position of the error here */
return val;
......
......@@ -161,7 +161,7 @@ rendered_value_render (GString *str,
col_width,
sheet ? workbook_date_conv (sheet->workbook) : NULL);
if (VALUE_IS_NUMBER (cell->value) &&
cell->value->type != VALUE_BOOLEAN &&
!VALUE_IS_BOOLEAN (cell->value) &&
value_get_as_float (cell->value) < 1.0) {
gsize i;
for (i = 0; i < str->len; i++)
......
......@@ -139,7 +139,7 @@ afa_teach_cell (AutoFiller *af, const GnmCell *cell, int n)
if (value == NULL ||
cell_has_expr (cell) ||
!VALUE_IS_NUMBER (value) ||
VALUE_TYPE (value) == VALUE_BOOLEAN) {
VALUE_IS_BOOLEAN (value)) {
af->status = AFS_ERROR;
return;
}
......
......@@ -716,7 +716,7 @@ cb_adjustment_value_changed (GtkAdjustment *adjustment,
int new_val = gnm_fake_round (swa->adjustment->value);
if (cell->value != NULL &&
VALUE_IS_NUMBER (cell->value) &&
cell->value->type != VALUE_BOOLEAN &&
!VALUE_IS_BOOLEAN (cell->value) &&
value_get_as_float (cell->value) == new_val)
return;
......
......@@ -211,7 +211,7 @@ GnmValue *
value_error_set_pos (GnmValueErr *err, GnmEvalPos const *pos)
{
g_return_val_if_fail (err != NULL, NULL);
g_return_val_if_fail (err->type == VALUE_ERROR, NULL);
g_return_val_if_fail (VALUE_IS_ERROR (err), NULL);
err->src = *pos;
return (GnmValue *)err;
......@@ -224,7 +224,7 @@ value_error_classify (GnmValue const *v)
g_return_val_if_fail (v != NULL, GNM_ERROR_UNKNOWN);
if (v->type != VALUE_ERROR)
if (!VALUE_IS_ERROR (v))
return GNM_ERROR_UNKNOWN;
for (i = 0; i < G_N_ELEMENTS (standard_errors); i++)
......@@ -997,7 +997,7 @@ value_peek_string (GnmValue const *v)
if (VALUE_IS_STRING (v))
return v->v_str.val->str;
else if (v->type == VALUE_ERROR)
else if (VALUE_IS_ERROR (v))
return v->v_err.mesg->str;
else {
static char *cache[2] = { NULL, NULL };
......@@ -1123,7 +1123,7 @@ value_coerce_to_number (GnmValue *v, gboolean *valid, GnmEvalPos const *ep)
if (tmp == NULL)
return value_new_error_VALUE (ep);
v = tmp;
} else if (v->type == VALUE_ERROR)
} else if (VALUE_IS_ERROR (v))
return v;
if (!VALUE_IS_NUMBER (v)) {
......
......@@ -65,7 +65,6 @@ struct _GnmValueArray {
GnmValue ***vals; /* Array [x][y] */
};
/* FIXME */
union _GnmValue {
GnmValueType const type;
GnmValueAny v_any;
......@@ -83,6 +82,8 @@ union _GnmValue {
#define VALUE_IS_EMPTY(v) (((v) == NULL) || ((v)->type == VALUE_EMPTY))
#define VALUE_IS_EMPTY_OR_ERROR(v) (VALUE_IS_EMPTY(v) || (v)->type == VALUE_ERROR)
#define VALUE_IS_STRING(v) ((v)->type == VALUE_STRING)
#define VALUE_IS_BOOLEAN(v) ((v)->type == VALUE_BOOLEAN)
#define VALUE_IS_ERROR(v) ((v)->type == VALUE_ERROR)
#define VALUE_IS_NUMBER(v) (((v)->type == VALUE_INTEGER) || \
((v)->type == VALUE_FLOAT) || \
((v)->type == VALUE_BOOLEAN))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment