[gnumeric] Func: we keep a usage count, not a ref_count.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Func: we keep a usage count, not a ref_count.
- Date: Thu, 26 Jul 2012 03:05:27 +0000 (UTC)
commit a6801ab76bc71fbdba9e05835c5ce87b2584ebda
Author: Morten Welinder <terra gnome org>
Date: Wed Jul 25 23:04:25 2012 -0400
Func: we keep a usage count, not a ref_count.
In particular, nothing really happens when we go to zero.
ChangeLog | 2 +
src/dialogs/dialog-function-select.c | 2 +-
src/func.c | 42 ++++++++++++++++++---------------
src/func.h | 10 ++++----
src/ssgrep.c | 2 +-
5 files changed, 32 insertions(+), 26 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 99428de..6366c0a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
2012-07-25 Morten Welinder <terra gnome org>
+ * src/func.h (GnmFunc): Use "usage" instead of "ref_count".
+
* src/mathfunc.c (mmult): Use GnmAccumulator for extra accuracy.
2012-07-25 Andreas J. Guelzow <aguelzow pyrshep ca>
diff --git a/src/dialogs/dialog-function-select.c b/src/dialogs/dialog-function-select.c
index f43b889..3e3dd75 100644
--- a/src/dialogs/dialog-function-select.c
+++ b/src/dialogs/dialog-function-select.c
@@ -1154,7 +1154,7 @@ dialog_function_select_load_tree (FunctionSelectState *state)
FUNCTION_CAT, func->fn_group,
FUNCTION_VISIBLE, TRUE,
FUNCTION_RECENT, FALSE,
- FUNCTION_USED, (func->ref_count > 1),
+ FUNCTION_USED, (func->usage_count > 1),
-1);
g_free (desc);
pango_attr_list_unref (pal);
diff --git a/src/func.c b/src/func.c
index d90c774..f78dff8 100644
--- a/src/func.c
+++ b/src/func.c
@@ -54,11 +54,11 @@ functions_shutdown (void)
{
while (unknown_cat != NULL && unknown_cat->functions != NULL) {
GnmFunc *func = unknown_cat->functions->data;
- if (func->ref_count > 0) {
- g_warning ("Function %s still has %d refs.\n",
+ if (func->usage_count > 0) {
+ g_warning ("Function %s still has %d users.\n",
gnm_func_get_name (func, FALSE),
- func->ref_count);
- func->ref_count = 0;
+ func->usage_count);
+ func->usage_count = 0;
}
gnm_func_free (func);
}
@@ -122,8 +122,8 @@ cb_dump_usage (gpointer key, Symbol *sym, FILE *out)
{
if (sym != NULL) {
GnmFunc const *fd = sym->data;
- if (fd != NULL && fd->ref_count > 0)
- fprintf (out, "%d,%s\n", fd->ref_count, fd->name);
+ if (fd != NULL && fd->usage_count > 0)
+ fprintf (out, "%d,%s\n", fd->usage_count, fd->name);
}
}
@@ -945,7 +945,7 @@ gnm_func_free (GnmFunc *func)
GnmFuncGroup *group;
g_return_if_fail (func != NULL);
- g_return_if_fail (func->ref_count == 0);
+ g_return_if_fail (func->usage_count == 0);
group = func->fn_group;
if (group != NULL) {
@@ -985,20 +985,20 @@ gnm_func_ref (GnmFunc *func)
{
g_return_if_fail (func != NULL);
- func->ref_count++;
- if (func->ref_count == 1 && func->ref_notify != NULL)
- func->ref_notify (func, 1);
+ func->usage_count++;
+ if (func->usage_count == 1 && func->usage_notify != NULL)
+ func->usage_notify (func, 1);
}
void
gnm_func_unref (GnmFunc *func)
{
g_return_if_fail (func != NULL);
- g_return_if_fail (func->ref_count > 0);
+ g_return_if_fail (func->usage_count > 0);
- func->ref_count--;
- if (func->ref_count == 0 && func->ref_notify != NULL)
- func->ref_notify (func, 0);
+ func->usage_count--;
+ if (func->usage_count == 0 && func->usage_notify != NULL)
+ func->usage_notify (func, 0);
}
/**
@@ -1043,14 +1043,16 @@ gnm_func_add (GnmFuncGroup *fn_group,
func->help = desc->help ? desc->help : NULL;
func->textdomain = go_string_new (textdomain);
func->linker = desc->linker;
- func->ref_notify = desc->ref_notify;
+ func->usage_notify = desc->usage_notify;
+ if (func->usage_notify)
+ g_printerr ("A: %s\n", func->name);
func->flags = desc->flags;
func->impl_status = desc->impl_status;
func->test_status = desc->test_status;
func->localized_name = NULL;
func->user_data = NULL;
- func->ref_count = 0;
+ func->usage_count = 0;
if (desc->fn_args != NULL) {
/* Check those arguments */
@@ -1101,7 +1103,7 @@ gnm_func_add_stub (GnmFuncGroup *fn_group,
const char *name,
const char *textdomain,
GnmFuncLoadDesc load_desc,
- GnmFuncRefNotify opt_ref_notify)
+ GnmFuncUsageNotify opt_usage_notify)
{
GnmFunc *func = g_new0 (GnmFunc, 1);
@@ -1109,7 +1111,9 @@ gnm_func_add_stub (GnmFuncGroup *fn_group,
textdomain = GETTEXT_PACKAGE;
func->name = name;
- func->ref_notify = opt_ref_notify;
+ func->usage_notify = opt_usage_notify;
+ if (func->usage_notify)
+ g_printerr ("B: %s\n", name);
func->fn_type = GNM_FUNC_TYPE_STUB;
func->fn.load_desc = load_desc;
func->textdomain = go_string_new (textdomain);
@@ -1152,7 +1156,7 @@ gnm_func_add_placeholder (Workbook *scope,
desc.fn_args = NULL;
desc.fn_nodes = &unknownFunctionHandler;
desc.linker = NULL;
- desc.ref_notify = NULL;
+ desc.usage_notify = NULL;
desc.flags = GNM_FUNC_IS_PLACEHOLDER | (copy_name ? GNM_FUNC_FREE_NAME : 0);
desc.impl_status = GNM_FUNC_IMPL_STATUS_EXISTS;
desc.test_status = GNM_FUNC_TEST_STATUS_UNKNOWN;
diff --git a/src/func.h b/src/func.h
index 59583ba..57582a6 100644
--- a/src/func.h
+++ b/src/func.h
@@ -128,7 +128,7 @@ typedef GnmValue *(*GnmFuncNodes) (GnmFuncEvalInfo *ei,
int argc, GnmExprConstPtr const *argv);
typedef GnmDependentFlags (*GnmFuncLink) (GnmFuncEvalInfo *ei, gboolean qlink);
-typedef void (*GnmFuncRefNotify) (GnmFunc *f, int refcount);
+typedef void (*GnmFuncUsageNotify) (GnmFunc *f, int refcount);
typedef gboolean (*GnmFuncLoadDesc) (GnmFunc const *f, GnmFuncDescriptor *fd);
typedef enum {
@@ -180,7 +180,7 @@ struct _GnmFuncDescriptor {
GnmFuncArgs fn_args;
GnmFuncNodes fn_nodes;
GnmFuncLink linker;
- GnmFuncRefNotify ref_notify;
+ GnmFuncUsageNotify usage_notify;
GnmFuncFlags flags;
GnmFuncImplStatus impl_status;
GnmFuncTestStatus test_status;
@@ -205,12 +205,12 @@ struct _GnmFunc {
} fn;
GnmFuncGroup *fn_group; /* most recent it was assigned to */
GnmFuncLink linker;
- GnmFuncRefNotify ref_notify;
+ GnmFuncUsageNotify usage_notify;
GnmFuncImplStatus impl_status;
GnmFuncTestStatus test_status;
GnmFuncFlags flags;
- gint ref_count;
+ gint usage_count;
gpointer user_data;
};
@@ -237,7 +237,7 @@ GnmFunc *gnm_func_add_stub (GnmFuncGroup *group,
const char *name,
const char *textdomain,
GnmFuncLoadDesc load_desc,
- GnmFuncRefNotify opt_ref_notify);
+ GnmFuncUsageNotify opt_usage_notify);
GnmFunc *gnm_func_add_placeholder (Workbook *optional_scope, /* change scope one day */
char const *name,
char const *type,
diff --git a/src/ssgrep.c b/src/ssgrep.c
index 0a06c6f..a972c3c 100644
--- a/src/ssgrep.c
+++ b/src/ssgrep.c
@@ -213,7 +213,7 @@ cb_check_func (gpointer clean, gpointer orig, gpointer user_data)
StringTableSearch *state = user_data;
GnmFunc *func = gnm_func_lookup (clean, state->wb);
if (NULL != func)
- add_result (state, clean, func->ref_count);
+ add_result (state, clean, func->usage_count);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]