Commit 0c2226ff authored by Morten Welinder's avatar Morten Welinder

GnmFunc: more cleanup.

This clarifies ownership for all GnmFunc members except "help" which is in sight.
parent f0514e58
......@@ -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);
......
......@@ -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 */
......
......@@ -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:
......
......@@ -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);
......
......@@ -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;
}
......
This diff is collapsed.
......@@ -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,
......
......@@ -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");
}
......
......@@ -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;
}
......
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