[gnumeric] Array context: simplify code a tiny bit.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Array context: simplify code a tiny bit.
- Date: Tue, 25 Oct 2011 15:38:24 +0000 (UTC)
commit 546da046b1732851d847a853db61e09b00fac15e
Author: Morten Welinder <terra gnome org>
Date: Tue Oct 25 11:38:01 2011 -0400
Array context: simplify code a tiny bit.
ChangeLog | 3 +++
plugins/fn-lookup/functions.c | 2 +-
src/func-builtin.c | 2 +-
src/func.c | 4 ++--
src/position.c | 1 +
src/position.h | 1 +
6 files changed, 9 insertions(+), 4 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index f0b1dfe..e901a79 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -12,6 +12,9 @@
2011-10-24 Morten Welinder <terra gnome org>
+ * src/position.h (eval_pos_is_array_context): New macro so we can
+ easier tell who is using the actual context information.
+
* src/libgnumeric.c (gnm_init): Don't bother initializing
gnome-vfs anymore.
diff --git a/plugins/fn-lookup/functions.c b/plugins/fn-lookup/functions.c
index 5223a34..9fc3993 100644
--- a/plugins/fn-lookup/functions.c
+++ b/plugins/fn-lookup/functions.c
@@ -1369,7 +1369,7 @@ gnumeric_column (GnmFuncEvalInfo *ei, GnmValue const * const *args)
if (ref == NULL) {
col = ei->pos->eval.col + 1; /* user visible counts from 0 */
- if (ei->pos->array != NULL)
+ if (eval_pos_is_array_context (ei->pos))
width = ei->pos->array->cols;
else
return value_new_int (col);
diff --git a/src/func-builtin.c b/src/func-builtin.c
index f24fa2b..48cbfe1 100644
--- a/src/func-builtin.c
+++ b/src/func-builtin.c
@@ -129,7 +129,7 @@ gnumeric_table_link (GnmFuncEvalInfo *ei)
rr.b.col_relative = rr.b.row_relative = FALSE;
rr.a.sheet = rr.b.sheet = dep->sheet;
- g_return_val_if_fail (ei->pos->array != NULL, DEPENDENT_IGNORE_ARGS);
+ g_return_val_if_fail (eval_pos_is_array_context (ei->pos), DEPENDENT_IGNORE_ARGS);
g_return_val_if_fail (ei->pos->eval.col > 0, DEPENDENT_IGNORE_ARGS);
rr.a.col = rr.b.col = ei->pos->eval.col - 1;
diff --git a/src/func.c b/src/func.c
index 0ce3d88..98ebff8 100644
--- a/src/func.c
+++ b/src/func.c
@@ -1540,7 +1540,7 @@ function_call_with_exprs (GnmFuncEvalInfo *ei, GnmExprEvalFlags flags)
return value_new_error_NA (ei->pos);
args = g_alloca (sizeof (GnmValue *) * fn_def->fn.args.max_args);
- iter_count = (ei->pos->array != NULL &&
+ iter_count = (eval_pos_is_array_context (ei->pos) &&
(flags & GNM_EXPR_EVAL_PERMIT_NON_SCALAR))
? 0 : -1;
@@ -1997,7 +1997,7 @@ function_iterate_argument_values (GnmEvalPos const *ep,
* will do implicit intersection in non-array mode */
if (GNM_EXPR_GET_OPER (expr) == GNM_EXPR_OP_CONSTANT)
val = value_dup (expr->constant.value);
- else if (ep->array != NULL ||
+ else if (eval_pos_is_array_context (ep) ||
GNM_EXPR_GET_OPER (expr) == GNM_EXPR_OP_FUNCALL ||
GNM_EXPR_GET_OPER (expr) == GNM_EXPR_OP_RANGE_CTOR ||
GNM_EXPR_GET_OPER (expr) == GNM_EXPR_OP_INTERSECT)
diff --git a/src/position.c b/src/position.c
index a932560..2301d7d 100644
--- a/src/position.c
+++ b/src/position.c
@@ -140,6 +140,7 @@ eval_pos_init_sheet (GnmEvalPos *ep, Sheet const *sheet)
return ep;
}
+
/*
* parse_pos_init :
*
diff --git a/src/position.h b/src/position.h
index fc9fd89..0b6c0c8 100644
--- a/src/position.h
+++ b/src/position.h
@@ -32,6 +32,7 @@ GnmEvalPos *eval_pos_init_dep (GnmEvalPos *ep, GnmDependent const *dep);
GnmEvalPos *eval_pos_init_cell (GnmEvalPos *ep, GnmCell const *cell);
GnmEvalPos *eval_pos_init_editpos (GnmEvalPos *ep, SheetView const *sv);
GnmEvalPos *eval_pos_init_sheet (GnmEvalPos *ep, Sheet const *sheet);
+#define eval_pos_is_array_context(ep) ((ep)->array != NULL)
/* Initialization routines for Parse Positions */
GnmParsePos *parse_pos_init (GnmParsePos *pp, Workbook *wb,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]