[gnumeric] GnmFunc: more cleanup.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] GnmFunc: more cleanup.
- Date: Fri, 25 May 2018 18:44:48 +0000 (UTC)
commit 0c2226ff12a36ac710c9189d55fe14698b75bffa
Author: Morten Welinder <terra gnome org>
Date: Fri May 25 14:42:14 2018 -0400
GnmFunc: more cleanup.
This clarifies ownership for all GnmFunc members except "help" which
is in sight.
plugins/excel/ms-formula-write.c | 9 +-
plugins/excel/xlsx-utils.c | 4 +-
src/auto-format.c | 4 +-
src/dialogs/dialog-function-select.c | 2 +-
src/expr.c | 2 +-
src/func.c | 293 +++++++++++++++++------------------
src/func.h | 61 +++++---
src/gnm-plugin.c | 15 +-
src/sstest.c | 25 +--
9 files changed, 213 insertions(+), 202 deletions(-)
---
diff --git a/plugins/excel/ms-formula-write.c b/plugins/excel/ms-formula-write.c
index 0249e908c..b54d775b0 100644
--- a/plugins/excel/ms-formula-write.c
+++ b/plugins/excel/ms-formula-write.c
@@ -79,13 +79,14 @@ cb_excel_write_prep_expr (GnmExpr const *expr, GnmExprWalk *data)
switch (GNM_EXPR_GET_OPER (expr)) {
case GNM_EXPR_OP_FUNCALL: {
GnmFunc *func = expr->func.func;
+ GnmFuncFlags flags = gnm_func_get_flags (func);
ExcelFunc *ef = g_hash_table_lookup (ewb->function_map, func);
if (ef != NULL)
break;
ef = g_new (ExcelFunc, 1);
- ef->efunc = (func->flags & (GNM_FUNC_IS_PLACEHOLDER |
- GNM_FUNC_IS_WORKBOOK_LOCAL))
+ ef->efunc = (flags & (GNM_FUNC_IS_PLACEHOLDER |
+ GNM_FUNC_IS_WORKBOOK_LOCAL))
? NULL
: g_hash_table_lookup (excel_func_by_name,
func->name);
@@ -97,7 +98,7 @@ cb_excel_write_prep_expr (GnmExpr const *expr, GnmExprWalk *data)
} else if (ef->efunc) {
ef->macro_name = NULL;
ef->idx = ef->efunc->idx;
- } else if (func->flags & GNM_FUNC_IS_WORKBOOK_LOCAL) {
+ } else if (flags & GNM_FUNC_IS_WORKBOOK_LOCAL) {
ef->macro_name = g_strdup (func->name);
ef->idx = -1;
} else {
@@ -506,7 +507,7 @@ guess_arg_types (GnmFunc *func)
char *res;
int i, min, max;
- if (!gnm_func_is_fixarg (func))
+ if (!gnm_func_is_fixargs (func))
return NULL;
gnm_func_count_args (func, &min, &max);
diff --git a/plugins/excel/xlsx-utils.c b/plugins/excel/xlsx-utils.c
index cf14cbda4..832da6268 100644
--- a/plugins/excel/xlsx-utils.c
+++ b/plugins/excel/xlsx-utils.c
@@ -169,7 +169,7 @@ static void
xlsx_func_map_out (GnmConventionsOut *out, GnmExprFunction const *func)
{
XLSXExprConventions const *xconv = (XLSXExprConventions const *)(out->convs);
- GnmFunc const *gfunc = gnm_expr_get_func_def ((GnmExpr *)func);
+ GnmFunc *gfunc = gnm_expr_get_func_def ((GnmExpr *)func);
char const *name = gnm_func_get_name (gfunc, FALSE);
gboolean (*handler) (GnmConventionsOut *out, GnmExprFunction const *func);
@@ -182,7 +182,7 @@ xlsx_func_map_out (GnmConventionsOut *out, GnmExprFunction const *func)
if (new_name == NULL) {
char *new_u_name;
new_u_name = g_ascii_strup (name, -1);
- if (gfunc->impl_status ==
+ if (gnm_func_get_impl_status (gfunc) ==
GNM_FUNC_IMPL_STATUS_UNIQUE_TO_GNUMERIC)
g_string_append (target, "_xlfngnumeric.");
/* LO & friends use _xlfnodf */
diff --git a/src/auto-format.c b/src/auto-format.c
index f619eff8f..74da53092 100644
--- a/src/auto-format.c
+++ b/src/auto-format.c
@@ -134,8 +134,8 @@ do_af_suggest (GnmExpr const *expr, GnmEvalPos const *epos, GOFormat const **exp
return do_af_suggest (expr->binary.value_a, epos, explicit);
case GNM_EXPR_OP_FUNCALL: {
- GnmFuncFlags typ =
- (expr->func.func->flags & GNM_FUNC_AUTO_MASK);
+ GnmFuncFlags typ = (gnm_func_get_flags (expr->func.func) &
+ GNM_FUNC_AUTO_MASK);
switch (typ) {
case GNM_FUNC_AUTO_FIRST:
diff --git a/src/dialogs/dialog-function-select.c b/src/dialogs/dialog-function-select.c
index 7429d3798..ae0f8338b 100644
--- a/src/dialogs/dialog-function-select.c
+++ b/src/dialogs/dialog-function-select.c
@@ -1179,7 +1179,7 @@ dialog_function_select_load_tree (FunctionSelectState *state)
for (ptr = funcs; ptr; ptr = ptr->next) {
func = ptr->data;
- if (!(func->flags &
+ if (!(gnm_func_get_flags (func) &
(GNM_FUNC_INTERNAL | GNM_FUNC_IS_PLACEHOLDER))) {
gtk_list_store_append (state->model_functions, &iter);
gnm_func_inc_usage (func);
diff --git a/src/expr.c b/src/expr.c
index cd355c46c..76e7a866d 100644
--- a/src/expr.c
+++ b/src/expr.c
@@ -3072,7 +3072,7 @@ cb_is_volatile (GnmExpr const *expr, GnmExprWalk *data)
{
gboolean *res = data->user;
if (GNM_EXPR_GET_OPER (expr) == GNM_EXPR_OP_FUNCALL &&
- (expr->func.func->flags & GNM_FUNC_VOLATILE)) {
+ (gnm_func_get_flags (expr->func.func) & GNM_FUNC_VOLATILE)) {
*res = TRUE;
data->stop = TRUE;
}
diff --git a/src/func.c b/src/func.c
index 2883a18e8..af4ef7441 100644
--- a/src/func.c
+++ b/src/func.c
@@ -8,17 +8,6 @@
* Jody Goldberg (jody gnome org)
*/
-// Temporary while cleaning out direct access to GnmFunc
-#define XXXusage_count usage_count
-#define XXXlocalized_name localized_name
-#define XXXtdomain tdomain
-#define XXXarg_names_p arg_names_p
-#define XXXfn_group fn_group
-#define XXXmin_args min_args
-#define XXXmax_args max_args
-#define XXXarg_types arg_types
-#define XXXfn_type fn_type
-
#include <gnumeric-config.h>
#include <glib/gi18n-lib.h>
#include <glib/gstdio.h>
@@ -150,8 +139,7 @@ gnm_func_load_stub (GnmFunc *func)
static GnmFuncHelp const no_help[] = { { GNM_FUNC_HELP_END } };
func->help = no_help;
- func->fn.nodes = &error_function_no_full_info;
- gnm_func_set_function_type (func, GNM_FUNC_TYPE_NODES);
+ gnm_func_set_varargs (func, error_function_no_full_info);
}
}
@@ -296,35 +284,6 @@ gnm_func_group_remove_func (GnmFuncGroup *fn_group, GnmFunc *fn_def)
/******************************************************************************/
-static void
-extract_arg_types (GnmFunc *func)
-{
- int i;
-
- gnm_func_count_args (func,
- &func->min_args,
- &func->max_args);
- g_free (func->arg_types);
- func->arg_types = NULL;
-
- if (func->fn_type == GNM_FUNC_TYPE_ARGS) {
- func->arg_types = g_malloc (func->max_args + 1);
- for (i = 0; i < func->max_args; i++)
- func->arg_types[i] = gnm_func_get_arg_type (func, i);
- func->arg_types[i] = 0;
- }
-}
-
-static void
-gnm_func_clear_arg_names (GnmFunc *fd)
-{
- if (fd->arg_names_p) {
- g_ptr_array_foreach (fd->arg_names_p, (GFunc) g_free, NULL);
- g_ptr_array_free (fd->arg_names_p, TRUE);
- fd->arg_names_p = NULL;
- }
-}
-
static void
gnm_func_create_arg_names (GnmFunc *fn_def)
{
@@ -345,37 +304,97 @@ gnm_func_create_arg_names (GnmFunc *fn_def)
(F2(fn_def, fn_def->help[i].text), NULL));
}
- gnm_func_clear_arg_names (fn_def);
- fn_def->arg_names_p = ptr;
+ fn_def->arg_names = ptr;
}
gboolean
-gnm_func_is_vararg (GnmFunc *func)
+gnm_func_is_varargs (GnmFunc *func)
{
gnm_func_load_stub (func);
return func->fn_type == GNM_FUNC_TYPE_NODES;
}
gboolean
-gnm_func_is_fixarg (GnmFunc *func)
+gnm_func_is_fixargs (GnmFunc *func)
{
gnm_func_load_stub (func);
return func->fn_type == GNM_FUNC_TYPE_ARGS;
}
void
-gnm_func_set_function_type (GnmFunc *func, GnmFuncType typ)
+gnm_func_set_stub (GnmFunc *func)
+{
+ func->fn_type = GNM_FUNC_TYPE_STUB;
+
+ g_free (func->arg_spec);
+ func->arg_spec = NULL;
+
+ g_free (func->arg_types);
+ func->arg_types = NULL;
+
+ if (func->arg_names) {
+ g_ptr_array_foreach (func->arg_names, (GFunc)g_free, NULL);
+ g_ptr_array_free (func->arg_names, TRUE);
+ func->arg_names = NULL;
+ }
+
+ func->min_args = func->max_args = 0;
+
+ func->nodes_func = NULL;
+ func->args_func = NULL;
+}
+
+/**
+ * gnm_func_set_varargs: (skip)
+ * @func: #GnmFunc
+ * @fn: evaluation function
+ */
+void
+gnm_func_set_varargs (GnmFunc *func, GnmFuncNodes fn)
{
g_return_if_fail (GNM_IS_FUNC (func));
+ g_return_if_fail (fn != NULL);
- func->fn_type = typ;
- if (typ == GNM_FUNC_TYPE_STUB)
- return;
+ gnm_func_set_stub (func); // Clear out stuff
- extract_arg_types (func);
- gnm_func_create_arg_names (func);
+ func->fn_type = GNM_FUNC_TYPE_NODES;
+ func->nodes_func = fn;
+ func->min_args = 0;
+ func->min_args = G_MAXINT;
}
+/**
+ * gnm_func_set_fixargs: (skip)
+ * @func: #GnmFunc
+ * @fn: evaluation function
+ * @spec: argument type specification
+ */
+void
+gnm_func_set_fixargs (GnmFunc *func, GnmFuncArgs fn, const char *spec)
+{
+ char *p;
+
+ g_return_if_fail (GNM_IS_FUNC (func));
+ g_return_if_fail (fn != NULL);
+ g_return_if_fail (spec != NULL);
+
+ gnm_func_set_stub (func); // Clear out stuff
+
+ func->fn_type = GNM_FUNC_TYPE_ARGS;
+ func->args_func = fn;
+ func->arg_spec = g_strdup (spec);
+
+ func->arg_types = g_strdup (func->arg_spec);
+ p = strchr (func->arg_types, '|');
+ if (p) {
+ func->min_args = p - func->arg_types;
+ memmove (p, p + 1, strlen (p));
+ } else
+ func->min_args = 0;
+ func->max_args = strlen (func->arg_types);
+
+ gnm_func_create_arg_names (func);
+}
static void
gnm_func_set_localized_name (GnmFunc *fd, const char *lname)
@@ -397,7 +416,7 @@ gnm_func_set_localized_name (GnmFunc *fd, const char *lname)
/**
* gnm_func_inc_usage:
- * @func: (transfer none): #GnmFunc
+ * @func: #GnmFunc
*
* This function increments the usage count of @func. A non-zero usage count
* prevents the unloading of the function.
@@ -559,6 +578,50 @@ gnm_func_set_translation_domain (GnmFunc *func, const char *tdomain)
g_object_notify (G_OBJECT (func), "translation-domain");
}
+GnmFuncFlags
+gnm_func_get_flags (GnmFunc *func)
+{
+ g_return_val_if_fail (GNM_IS_FUNC (func), GNM_FUNC_SIMPLE);
+ return func->flags;
+}
+
+void
+gnm_func_set_flags (GnmFunc *func, GnmFuncFlags f)
+{
+ g_return_if_fail (GNM_IS_FUNC (func));
+ func->flags = f;
+}
+
+GnmFuncImplStatus
+gnm_func_get_impl_status (GnmFunc *func)
+{
+ g_return_val_if_fail (GNM_IS_FUNC (func), GNM_FUNC_IMPL_STATUS_UNIMPLEMENTED);
+ return func->impl_status;
+}
+
+void
+gnm_func_set_impl_status (GnmFunc *func, GnmFuncImplStatus st)
+{
+ g_return_if_fail (GNM_IS_FUNC (func));
+ func->impl_status = st;
+}
+
+
+GnmFuncTestStatus
+gnm_func_get_test_status (GnmFunc *func)
+{
+ g_return_val_if_fail (GNM_IS_FUNC (func), GNM_FUNC_TEST_STATUS_UNKNOWN);
+ return func->test_status;
+}
+
+void
+gnm_func_set_test_status (GnmFunc *func, GnmFuncTestStatus st)
+{
+ g_return_if_fail (GNM_IS_FUNC (func));
+ func->test_status = st;
+}
+
+
/**
* gnm_func_get_function_group:
* @func: #GnmFunc
@@ -608,9 +671,8 @@ gnm_func_add (GnmFuncGroup *fn_group,
GnmFuncDescriptor const *desc,
const char *tdomain)
{
- static char const valid_tokens[] = "fsbraAES?|";
+ //static char const valid_tokens[] = "fsbraAES?|";
GnmFunc *func;
- char const *ptr;
g_return_val_if_fail (fn_group != NULL, NULL);
g_return_val_if_fail (desc != NULL, NULL);
@@ -624,28 +686,13 @@ gnm_func_add (GnmFuncGroup *fn_group,
func->flags = desc->flags;
func->impl_status = desc->impl_status;
func->test_status = desc->test_status;
- func->localized_name = NULL;
- func->arg_names_p = NULL;
-
- func->usage_count = 0;
if (desc->fn_args != NULL) {
- /* Check those arguments */
- for (ptr = desc->arg_spec ; *ptr ; ptr++) {
- g_return_val_if_fail (strchr (valid_tokens, *ptr), NULL);
- }
-
- func->fn.args.func = desc->fn_args;
- func->fn.args.arg_spec = desc->arg_spec;
- gnm_func_set_function_type (func, GNM_FUNC_TYPE_ARGS);
+ gnm_func_set_fixargs (func, desc->fn_args, desc->arg_spec);
} else if (desc->fn_nodes != NULL) {
-
- if (desc->arg_spec && *desc->arg_spec) {
+ if (desc->arg_spec && *desc->arg_spec)
g_warning ("Arg spec for node function -- why?");
- }
-
- func->fn.nodes = desc->fn_nodes;
- gnm_func_set_function_type (func, GNM_FUNC_TYPE_NODES);
+ gnm_func_set_varargs (func, desc->fn_nodes);
} else {
g_warning ("Invalid function has neither args nor nodes handler");
g_object_unref (func);
@@ -874,7 +921,7 @@ gnm_func_get_name (GnmFunc const *func, gboolean localized)
*
* Returns: (transfer none): the description of the function
**/
-char const*
+char const *
gnm_func_get_description (GnmFunc const *fn_def)
{
gint i;
@@ -914,83 +961,33 @@ gnm_func_count_args (GnmFunc const *fn_def, int *min, int *max)
gnm_func_load_if_stub ((GnmFunc *)fn_def);
- switch (fn_def->fn_type) {
- case GNM_FUNC_TYPE_NODES:
- *min = 0;
- // Really?
- if (g_ascii_strcasecmp ("INDEX",fn_def->name) == 0)
- *max = 4;
- else
- *max = G_MAXINT;
- return;
-
- case GNM_FUNC_TYPE_ARGS: {
- const char *ptr = fn_def->fn.args.arg_spec;
- int i, vararg;
-
- for (i = vararg = 0; ptr && *ptr; ptr++) {
- if (*ptr == '|') {
- vararg = 1;
- *min = i;
- } else
- i++;
- }
- *max = i;
- if (!vararg)
- *min = i;
- return;
- }
-
- default:
- *min = 0;
- *max = G_MAXINT;
- return;
- }
+ *min = fn_def->min_args;
+ *max = fn_def->max_args;
}
/**
* gnm_func_get_arg_type:
* @fn_def: the fn defintion
- * @arg_idx: zero based argument offset
+ * @arg_idx: zero-based argument offset
*
* Returns: the type of the argument
**/
char
gnm_func_get_arg_type (GnmFunc const *fn_def, int arg_idx)
{
- char const *ptr;
-
- g_return_val_if_fail (arg_idx >= 0, '?');
g_return_val_if_fail (fn_def != NULL, '?');
gnm_func_load_if_stub ((GnmFunc *)fn_def);
- switch (fn_def->fn_type) {
- case GNM_FUNC_TYPE_ARGS:
- for (ptr = fn_def->fn.args.arg_spec; ptr && *ptr; ptr++) {
- if (*ptr == '|')
- continue;
- if (arg_idx-- == 0)
- return *ptr;
- }
- return '?';
-
- case GNM_FUNC_TYPE_NODES:
- return '?'; /* Close enough for now. */
+ g_return_val_if_fail (arg_idx >= 0 && arg_idx < fn_def->max_args, '?');
- case GNM_FUNC_TYPE_STUB:
-#ifndef DEBUG_SWITCH_ENUM
- default:
-#endif
- g_assert_not_reached ();
- return '?';
- }
+ return fn_def->arg_types ? fn_def->arg_types[arg_idx] : '?';
}
/**
* gnm_func_get_arg_type_string:
* @fn_def: the fn defintion
- * @arg_idx: zero based argument offset
+ * @arg_idx: zero-based argument offset
*
* Return value: (transfer none): the type of the argument as a string
**/
@@ -1025,29 +1022,27 @@ gnm_func_get_arg_type_string (GnmFunc const *fn_def,
/**
* gnm_func_get_arg_name:
- * @fn_def: the fn defintion
- * @arg_idx: zero based argument offset
+ * @func: #GnmFunc
+ * @arg_idx: zero-based argument offset
*
- * Returns: (transfer full): the name of the argument
+ * Returns: (transfer full) (nullable): the name of the argument
**/
char *
-gnm_func_get_arg_name (GnmFunc const *fn_def, guint arg_idx)
+gnm_func_get_arg_name (GnmFunc const *func, guint arg_idx)
{
- g_return_val_if_fail (fn_def != NULL, NULL);
+ g_return_val_if_fail (func != NULL, NULL);
- gnm_func_load_if_stub ((GnmFunc *)fn_def);
+ gnm_func_load_if_stub ((GnmFunc *)func);
- if ((fn_def->arg_names_p != NULL)
- && (arg_idx < fn_def->arg_names_p->len))
- return g_strdup (g_ptr_array_index (fn_def->arg_names_p,
- arg_idx));
+ if (func->arg_names && arg_idx < func->arg_names->len)
+ return g_strdup (g_ptr_array_index (func->arg_names, arg_idx));
return NULL;
}
/**
* gnm_func_get_arg_description:
* @fn_def: the fn defintion
- * @arg_idx: zero based argument offset
+ * @arg_idx: zero-based argument offset
*
* Returns: (transfer none): the description of the argument
**/
@@ -1177,7 +1172,7 @@ function_call_with_exprs (GnmFuncEvalInfo *ei)
/* Functions that deal with ExprNodes */
if (fn_def->fn_type == GNM_FUNC_TYPE_NODES)
- return fn_def->fn.nodes (ei, argc, argv);
+ return fn_def->nodes_func (ei, argc, argv);
/* Functions that take pre-computed Values */
if (argc > fn_def->max_args ||
@@ -1190,7 +1185,7 @@ function_call_with_exprs (GnmFuncEvalInfo *ei)
? 0 : -1;
/* Optimization for IF when implicit iteration is not used. */
- if (ei->func_call->func->fn.args.func == gnumeric_if &&
+ if (ei->func_call->func->args_func == gnumeric_if &&
iter_count == -1)
return gnumeric_if2 (ei, argc, argv, flags);
@@ -1387,7 +1382,7 @@ function_call_with_exprs (GnmFuncEvalInfo *ei)
}
res->v_array.vals[x][y] = (i == iter_count)
- ? fn_def->fn.args.func (ei, (GnmValue const * const *)args)
+ ? fn_def->args_func (ei, (GnmValue const * const *)args)
: ((err != NULL) ? value_dup (err)
: value_new_error_VALUE (ei->pos));
free_values (iter_args, i);
@@ -1399,7 +1394,7 @@ function_call_with_exprs (GnmFuncEvalInfo *ei)
tmp = res;
i = fn_def->max_args;
} else
- tmp = fn_def->fn.args.func (ei, (GnmValue const * const *)args);
+ tmp = fn_def->args_func (ei, (GnmValue const * const *)args);
free_values (args, i);
return tmp;
@@ -1453,11 +1448,11 @@ function_def_call_with_values (GnmEvalPos const *ep, GnmFunc const *fn_def,
gnm_expr_constant_init (expr + i, values[i]);
argv[i] = (GnmExprConstPtr)(expr + i);
}
- retval = fn_def->fn.nodes (&fs, argc, argv);
+ retval = fn_def->nodes_func (&fs, argc, argv);
g_free (argv);
g_free (expr);
} else
- retval = fn_def->fn.args.func (&fs, values);
+ retval = fn_def->args_func (&fs, values);
return retval;
}
@@ -1738,6 +1733,8 @@ gnm_func_real_dispose (GObject *obj)
func->name, func->usage_count);
}
+ gnm_func_set_stub (func);
+
if (func->fn_group) {
gnm_func_group_remove_func (func->fn_group, func);
func->fn_group = NULL;
@@ -1749,8 +1746,6 @@ gnm_func_real_dispose (GObject *obj)
g_hash_table_remove (functions_by_name, func->name);
}
- gnm_func_clear_arg_names (func);
-
parent_class->dispose (obj);
}
diff --git a/src/func.h b/src/func.h
index 0bb28ab3b..0a769bcb7 100644
--- a/src/func.h
+++ b/src/func.h
@@ -185,28 +185,30 @@ struct GnmFunc_ {
char const *name;
GnmFuncHelp const *help;
- union {
- GnmFuncNodes nodes;
- struct {
- char const *arg_spec;
- GnmFuncArgs func;
- } args;
- } fn;
- GnmFuncImplStatus impl_status;
- GnmFuncTestStatus test_status;
- GnmFuncFlags flags;
/* <private> */
- GnmFuncType XXXfn_type;
- GnmFuncGroup *XXXfn_group;
- GOString *XXXtdomain;
- char *XXXlocalized_name;
- GPtrArray *XXXarg_names_p;
- gint XXXusage_count;
- int XXXmin_args, XXXmax_args;
+ GnmFuncType fn_type;
+ GnmFuncGroup *fn_group;
+ GnmFuncFlags flags;
+ GnmFuncImplStatus impl_status;
+ GnmFuncTestStatus test_status;
+
+ GOString *tdomain;
+ char *localized_name;
+
+ gint usage_count;
// Meaningful for ARGS only
- char *XXXarg_types;
+ char *arg_spec;
+ GnmFuncArgs args_func;
+
+ // Meaningful for NODES only
+ GnmFuncNodes nodes_func;
+
+ // Derived for quick access
+ GPtrArray *arg_names;
+ int min_args, max_args;
+ char *arg_types;
};
#define GNM_FUNC_TYPE (gnm_func_get_type ())
@@ -225,12 +227,26 @@ char const *gnm_func_get_translation_domain (GnmFunc *func);
void gnm_func_set_translation_domain (GnmFunc *func,
const char *tdomain);
+GnmFuncFlags gnm_func_get_flags (GnmFunc *func);
+void gnm_func_set_flags (GnmFunc *func, GnmFuncFlags f);
+
+
+GnmFuncImplStatus gnm_func_get_impl_status (GnmFunc *func);
+void gnm_func_set_impl_status (GnmFunc *func, GnmFuncImplStatus st);
+
+GnmFuncTestStatus gnm_func_get_test_status (GnmFunc *func);
+void gnm_func_set_test_status (GnmFunc *func, GnmFuncTestStatus st);
+
GnmFuncGroup*gnm_func_get_function_group (GnmFunc *func);
void gnm_func_set_function_group (GnmFunc *func, GnmFuncGroup *group);
-gboolean gnm_func_is_vararg (GnmFunc *func);
-gboolean gnm_func_is_fixarg (GnmFunc *func);
-void gnm_func_set_function_type (GnmFunc *func, GnmFuncType typ);
+gboolean gnm_func_is_varargs (GnmFunc *func);
+gboolean gnm_func_is_fixargs (GnmFunc *func);
+
+void gnm_func_set_stub (GnmFunc *func);
+void gnm_func_set_varargs (GnmFunc *func, GnmFuncNodes fn);
+void gnm_func_set_fixargs (GnmFunc *func, GnmFuncArgs fn,
+ const char *spec);
GnmDependentFlags gnm_func_link_dep (GnmFunc *func, GnmFuncEvalInfo *ei, gboolean qlink);
@@ -257,8 +273,7 @@ char gnm_func_get_arg_type (GnmFunc const *fn_def,
gint arg_idx);
char const *gnm_func_get_arg_type_string (GnmFunc const *fn_def,
gint arg_idx);
-char *gnm_func_get_arg_name (GnmFunc const *fn_def,
- guint arg_idx);
+char *gnm_func_get_arg_name (GnmFunc const *func, guint arg_idx);
char const *gnm_func_get_arg_description (GnmFunc const *fn_def,
guint arg_idx);
char *gnm_func_convert_markup_to_pango (char const *desc,
diff --git a/src/gnm-plugin.c b/src/gnm-plugin.c
index d47c76366..711f1565b 100644
--- a/src/gnm-plugin.c
+++ b/src/gnm-plugin.c
@@ -209,7 +209,7 @@ plugin_service_function_group_activate (GOPluginService *service, GOErrorInfo **
const char *fname = l->data;
GnmFunc *func = gnm_func_lookup_or_add_placeholder (fname);
- gnm_func_set_function_type (func, GNM_FUNC_TYPE_STUB);
+ gnm_func_set_stub (func);
gnm_func_set_translation_domain (func, sfg->tdomain);
gnm_func_set_function_group (func, sfg->func_group);
// Clear localized_name so we can deduce the proper name.
@@ -776,16 +776,13 @@ gnm_plugin_loader_module_func_load_stub (GOPluginService *service,
desc = loader_data->module_fn_info_array + GPOINTER_TO_INT (index_ptr);
func->help = desc->help ? desc->help : NULL;
- func->impl_status = desc->impl_status;
- func->test_status = desc->test_status;
- func->flags = desc->flags;
+ gnm_func_set_impl_status (func, desc->impl_status);
+ gnm_func_set_test_status (func, desc->test_status);
+ gnm_func_set_flags (func, desc->flags);
if (desc->fn_args != NULL) {
- func->fn.args.func = desc->fn_args;
- func->fn.args.arg_spec = desc->arg_spec;
- gnm_func_set_function_type (func, GNM_FUNC_TYPE_ARGS);
+ gnm_func_set_fixargs (func, desc->fn_args, desc->arg_spec);
} else if (desc->fn_nodes != NULL) {
- func->fn.nodes = desc->fn_nodes;
- gnm_func_set_function_type (func, GNM_FUNC_TYPE_NODES);
+ gnm_func_set_varargs (func, desc->fn_nodes);
} else {
g_warning ("Invalid function descriptor with no function");
}
diff --git a/src/sstest.c b/src/sstest.c
index 79da7768f..99a9cc45a 100644
--- a/src/sstest.c
+++ b/src/sstest.c
@@ -344,8 +344,8 @@ function_dump_defs (char const *filename, int dump_type)
if (dump_type == 0) {
int unique = 0;
for (i = 0; i < ordered->len; i++) {
- GnmFunc const *fd = g_ptr_array_index (ordered, i);
- switch (fd->impl_status) {
+ GnmFunc *fd = g_ptr_array_index (ordered, i);
+ switch (gnm_func_get_impl_status (fd)) {
case GNM_FUNC_IMPL_STATUS_UNIQUE_TO_GNUMERIC:
unique++;
break;
@@ -576,6 +576,9 @@ function_dump_defs (char const *filename, int dump_type)
{ "Under development", "imp-devel" },
{ "Unique to Gnumeric", "imp-gnumeric" },
};
+ GnmFuncImplStatus imst = gnm_func_get_impl_status (fd);
+ GnmFuncTestStatus test = gnm_func_get_test_status (fd);
+
if (group != gnm_func_get_function_group (fd)) {
if (group) fprintf (output_file, "</table></div>\n");
group = gnm_func_get_function_group (fd);
@@ -601,14 +604,14 @@ function_dump_defs (char const *filename, int dump_type)
g_free (catname);
fprintf (output_file,
"<td class=\"%s\"><a href=\"mailto:gnumeric-list gnome org?subject=Re: %s
implementation\">%s</a></td>\n",
- implementation[fd->impl_status].klass,
+ implementation[imst].klass,
fd->name,
- implementation[fd->impl_status].name);
+ implementation[imst].name);
fprintf (output_file,
"<td class=\"%s\"><a href=\"mailto:gnumeric-list gnome org?subject=Re: %s
testing\">%s</a></td>\n",
- testing[fd->test_status].klass,
+ testing[test].klass,
fd->name,
- testing[fd->test_status].name);
+ testing[test].name);
fprintf (output_file,"</tr>\n");
}
}
@@ -929,9 +932,9 @@ check_help_expression (const char *text, GnmFunc const *fd)
}
static gboolean
-check_argument_refs (const char *text, GnmFunc const *fd)
+check_argument_refs (const char *text, GnmFunc *fd)
{
- if (!gnm_func_is_fixarg (fd))
+ if (!gnm_func_is_fixargs (fd))
return FALSE;
while (1) {
@@ -966,7 +969,7 @@ check_argument_refs (const char *text, GnmFunc const *fd)
static int
-gnm_func_sanity_check1 (GnmFunc const *fd)
+gnm_func_sanity_check1 (GnmFunc *fd)
{
GnmFuncHelp const *h;
int counts[(int)GNM_FUNC_HELP_ODF + 1];
@@ -1091,7 +1094,7 @@ gnm_func_sanity_check1 (GnmFunc const *fd)
g_hash_table_destroy (allargs);
- if (gnm_func_is_fixarg (fd)) {
+ if (gnm_func_is_fixargs (fd)) {
int n = counts[GNM_FUNC_HELP_ARG];
int min, max;
gnm_func_count_args (fd, &min, &max);
@@ -1141,7 +1144,7 @@ gnm_func_sanity_check (void)
ordered = enumerate_functions (TRUE);
for (ui = 0; ui < ordered->len; ui++) {
- GnmFunc const *fd = g_ptr_array_index (ordered, ui);
+ GnmFunc *fd = g_ptr_array_index (ordered, ui);
if (gnm_func_sanity_check1 (fd))
res = 1;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]