[gnumeric] Various cleanups.



commit be4528eefce79c5754221effe816fe1eb413ba37
Author: Morten Welinder <terra gnome org>
Date:   Sun May 27 13:45:00 2018 -0400

    Various cleanups.
    
    Namespace, introspection, etc.

 plugins/fn-math/functions.c |  2 +-
 src/application.c           | 12 ++++++------
 src/application.h           |  2 +-
 src/dialogs/dialog-view.c   |  2 +-
 src/expr-deriv.c            |  2 +-
 src/expr-deriv.h            |  2 +-
 src/expr.c                  |  8 ++++----
 src/expr.h                  |  4 ++--
 src/func-builtin.c          | 16 ++++++++++++----
 src/func-builtin.h          |  5 ++---
 src/func.c                  | 23 ++++++++++++++---------
 src/func.h                  |  4 ++--
 src/hlink.c                 |  4 ++--
 src/hlink.h                 |  2 +-
 src/libgnumeric.c           | 12 ++++++------
 src/mathfunc.c              |  4 ++--
 src/mathfunc.h              |  2 +-
 src/wbc-gtk.c               |  2 +-
 18 files changed, 60 insertions(+), 48 deletions(-)
---
diff --git a/plugins/fn-math/functions.c b/plugins/fn-math/functions.c
index 7a7c7e311..b26a6e130 100644
--- a/plugins/fn-math/functions.c
+++ b/plugins/fn-math/functions.c
@@ -597,7 +597,7 @@ gnumeric_agm (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
        gnm_float a = value_get_as_float (argv[0]);
        gnm_float b = value_get_as_float (argv[1]);
 
-       return value_new_float (agm (a, b));
+       return value_new_float (gnm_agm (a, b));
 }
 
 /***************************************************************************/
diff --git a/src/application.c b/src/application.c
index 4a9f4fa7f..1231a55a0 100644
--- a/src/application.c
+++ b/src/application.c
@@ -119,8 +119,8 @@ gnm_app_workbook_list_add (Workbook *wb)
        app->workbook_list = g_list_prepend (app->workbook_list, wb);
        g_signal_connect (G_OBJECT (wb),
                "notify::uri",
-               G_CALLBACK (_gnm_app_flag_windows_changed), NULL);
-       _gnm_app_flag_windows_changed ();
+               G_CALLBACK (gnm_app_flag_windows_changed_), NULL);
+       gnm_app_flag_windows_changed_ ();
        g_signal_emit (G_OBJECT (app), signals[WORKBOOK_ADDED], 0, wb);
 }
 
@@ -138,8 +138,8 @@ gnm_app_workbook_list_remove (Workbook *wb)
 
        app->workbook_list = g_list_remove (app->workbook_list, wb);
        g_signal_handlers_disconnect_by_func (G_OBJECT (wb),
-               G_CALLBACK (_gnm_app_flag_windows_changed), NULL);
-       _gnm_app_flag_windows_changed ();
+               G_CALLBACK (gnm_app_flag_windows_changed_), NULL);
+       gnm_app_flag_windows_changed_ ();
        g_signal_emit (G_OBJECT (app), signals[WORKBOOK_REMOVED], 0, wb);
 }
 
@@ -1074,12 +1074,12 @@ cb_flag_windows_changed (void)
 }
 
 /**
- * _gnm_app_flag_windows_changed:
+ * gnm_app_flag_windows_changed_:
  *
  * An internal utility routine to flag a regeneration of the window lists
  **/
 void
-_gnm_app_flag_windows_changed (void)
+gnm_app_flag_windows_changed_ (void)
 {
        if (windows_update_timer == 0)
                windows_update_timer = g_timeout_add (100,
diff --git a/src/application.h b/src/application.h
index 61622cb8c..15d51ba13 100644
--- a/src/application.h
+++ b/src/application.h
@@ -104,7 +104,7 @@ void           gnm_app_foreach_extra_ui (GFunc func, gpointer data);
 /**********************************************************************/
 
 /* internal implementation util */
-void _gnm_app_flag_windows_changed (void);
+void gnm_app_flag_windows_changed_ (void);
 
 G_END_DECLS
 
diff --git a/src/dialogs/dialog-view.c b/src/dialogs/dialog-view.c
index 2bae29333..15e1710de 100644
--- a/src/dialogs/dialog-view.c
+++ b/src/dialogs/dialog-view.c
@@ -105,7 +105,7 @@ cb_view_ok_clicked (G_GNUC_UNUSED GtkWidget *button,
                /* What else would it be?  */
                WBCGtk *new_wbcg = WBC_GTK (new_wbc);
                wbcg_copy_toolbar_visibility (new_wbcg, wbcg);
-               _gnm_app_flag_windows_changed ();
+               gnm_app_flag_windows_changed_ ();
        }
 }
 
diff --git a/src/expr-deriv.c b/src/expr-deriv.c
index 1dcb68f2f..a46af5edb 100644
--- a/src/expr-deriv.c
+++ b/src/expr-deriv.c
@@ -796,7 +796,7 @@ gnm_expr_deriv_chain (GnmExpr const *expr,
 /* ------------------------------------------------------------------------- */
 
 void
-_gnm_expr_deriv_shutdown (void)
+gnm_expr_deriv_shutdown_ (void)
 {
 }
 
diff --git a/src/expr-deriv.h b/src/expr-deriv.h
index 5e30826a8..dace0575e 100644
--- a/src/expr-deriv.h
+++ b/src/expr-deriv.h
@@ -43,7 +43,7 @@ GnmExprList *gnm_expr_deriv_collect (GnmExpr const *expr,
 
 /* ------------------------------------------------------------------------- */
 
-void _gnm_expr_deriv_shutdown (void);
+void gnm_expr_deriv_shutdown_ (void);
 
 /* ------------------------------------------------------------------------- */
 
diff --git a/src/expr.c b/src/expr.c
index 76e7a866d..75273409c 100644
--- a/src/expr.c
+++ b/src/expr.c
@@ -3471,10 +3471,10 @@ typedef union {
 #endif
 
 /**
- * _gnm_expr_init: (skip)
+ * gnm_expr_init_: (skip)
  */
 void
-_gnm_expr_init (void)
+gnm_expr_init_ (void)
 {
 #if 0
        GnmExpr e;
@@ -3524,10 +3524,10 @@ cb_expression_pool_leak (gpointer data, G_GNUC_UNUSED gpointer user)
 #endif
 
 /**
- * _gnm_expr_shutdown: (skip)
+ * gnm_expr_shutdown_: (skip)
  */
 void
-_gnm_expr_shutdown (void)
+gnm_expr_shutdown_ (void)
 {
 #if USE_EXPR_POOLS
        go_mem_chunk_foreach_leak (expression_pool_small, cb_expression_pool_leak, NULL);
diff --git a/src/expr.h b/src/expr.h
index 7deb1163d..f066e1670 100644
--- a/src/expr.h
+++ b/src/expr.h
@@ -226,8 +226,8 @@ void              gnm_expr_sharer_report (GnmExprSharer *es);
 
 /*****************************************************************************/
 
-void _gnm_expr_init (void);
-void _gnm_expr_shutdown (void);
+void gnm_expr_init_ (void);
+void gnm_expr_shutdown_ (void);
 
 G_END_DECLS
 
diff --git a/src/func-builtin.c b/src/func-builtin.c
index 3b2c89304..06b671ac5 100644
--- a/src/func-builtin.c
+++ b/src/func-builtin.c
@@ -353,7 +353,7 @@ static GnmFuncHelp const help_if[] = {
        { GNM_FUNC_HELP_END }
 };
 
-GnmValue *
+static GnmValue *
 gnumeric_if (GnmFuncEvalInfo *ei, GnmValue const * const *args)
 {
        gboolean err;
@@ -370,7 +370,9 @@ gnumeric_if (GnmFuncEvalInfo *ei, GnmValue const * const *args)
                return value_new_int (0);
 }
 
-
+/**
+ * gnumeric_if2: (skip)
+ */
 GnmValue *
 gnumeric_if2 (GnmFuncEvalInfo *ei, int argc, GnmExprConstPtr const *argv,
              GnmExprEvalFlags flags)
@@ -534,8 +536,11 @@ static GnmFuncDescriptor const builtins [] = {
        { NULL }
 };
 
+/**
+ * gnm_func_builtin_init: (skip)
+ */
 void
-func_builtin_init (void)
+gnm_func_builtin_init (void)
 {
        const char *gname;
        const char *tdomain = GETTEXT_PACKAGE;
@@ -567,8 +572,11 @@ func_builtin_init (void)
                          "derivative", G_CALLBACK (gnumeric_sum_deriv), NULL);
 }
 
+/**
+ * gnm_func_builtin_shutdown: (skip)
+ */
 void
-func_builtin_shutdown (void)
+gnm_func_builtin_shutdown (void)
 {
        int i;
 
diff --git a/src/func-builtin.h b/src/func-builtin.h
index b43ccfe94..5f2974b7c 100644
--- a/src/func-builtin.h
+++ b/src/func-builtin.h
@@ -5,11 +5,10 @@
 
 G_BEGIN_DECLS
 
-GnmValue *gnumeric_if      (GnmFuncEvalInfo *ei, GnmValue const * const *args);
 GnmValue *gnumeric_if2     (GnmFuncEvalInfo *ei, int argc, GnmExprConstPtr const *argv, GnmExprEvalFlags 
flags);
 
-void func_builtin_init (void);
-void func_builtin_shutdown (void);
+void gnm_func_builtin_init (void);
+void gnm_func_builtin_shutdown (void);
 
 G_END_DECLS
 
diff --git a/src/func.c b/src/func.c
index f2d07b92a..bcd3f31b6 100644
--- a/src/func.c
+++ b/src/func.c
@@ -60,11 +60,13 @@ static GnmFuncGroup *unknown_cat;
 static GHashTable *functions_by_name;
 static GHashTable *functions_by_localized_name;
 
+static GnmFunc    *fn_if;
+
 /**
- * functions_init: (skip)
+ * gnm_func_init_: (skip)
  */
 void
-functions_init (void)
+gnm_func_init_ (void)
 {
        functions_by_name =
                g_hash_table_new (go_ascii_strcase_hash, go_ascii_strcase_equal);
@@ -73,15 +75,19 @@ functions_init (void)
        functions_by_localized_name =
                g_hash_table_new (go_ascii_strcase_hash, go_ascii_strcase_equal);
 
-       func_builtin_init ();
+       gnm_func_builtin_init ();
+
+       fn_if = gnm_func_lookup ("if", NULL);
 }
 
 /**
- * functions_shutdown: (skip)
+ * gnm_func_shutdown_: (skip)
  */
 void
-functions_shutdown (void)
+gnm_func_shutdown_ (void)
 {
+       fn_if = NULL;
+
        while (unknown_cat != NULL && unknown_cat->functions != NULL) {
                GnmFunc *func = unknown_cat->functions->data;
                if (func->usage_count > 0) {
@@ -92,7 +98,7 @@ functions_shutdown (void)
                }
                g_object_unref (func);
        }
-       func_builtin_shutdown ();
+       gnm_func_builtin_shutdown ();
 
        g_hash_table_destroy (functions_by_name);
        functions_by_name = NULL;
@@ -340,7 +346,7 @@ gnm_func_set_stub (GnmFunc *func)
  * gnm_func_set_varargs: (skip)
  * @func: #GnmFunc
  * @fn: evaluation function
- * @spec: (optional): argument type specification
+ * @spec: (nullable): argument type specification
  */
 void
 gnm_func_set_varargs (GnmFunc *func, GnmFuncNodes fn, const char *spec)
@@ -1271,8 +1277,7 @@ function_call_with_exprs (GnmFuncEvalInfo *ei)
                ? 0 : -1;
 
        /* Optimization for IF when implicit iteration is not used.  */
-       if (ei->func_call->func->args_func == gnumeric_if &&
-           iter_count == -1)
+       if (ei->func_call->func == fn_if && iter_count == -1)
                return gnumeric_if2 (ei, argc, argv, flags);
 
        pass_flags = (flags &
diff --git a/src/func.h b/src/func.h
index d1f33b9ec..29b8dfdc9 100644
--- a/src/func.h
+++ b/src/func.h
@@ -7,8 +7,8 @@
 G_BEGIN_DECLS
 
 /* Setup of the symbol table */
-void functions_init     (void);
-void functions_shutdown (void);
+void gnm_func_init_     (void);
+void gnm_func_shutdown_ (void);
 
 GPtrArray *gnm_func_enumerate (void);
 
diff --git a/src/hlink.c b/src/hlink.c
index 6decc353d..582fa4641 100644
--- a/src/hlink.c
+++ b/src/hlink.c
@@ -579,10 +579,10 @@ GSF_CLASS (GnmHLinkExternal, gnm_hlink_external,
           GNM_HLINK_TYPE)
 
 /**
- * _gnm_hlink_init: (skip)
+ * gnm_hlink_init_: (skip)
  */
 void
-_gnm_hlink_init (void)
+gnm_hlink_init_ (void)
 {
        /* make sure that all hlink types are registered */
        gnm_hlink_cur_wb_get_type ();
diff --git a/src/hlink.h b/src/hlink.h
index e83d0b7ec..e4c495d9c 100644
--- a/src/hlink.h
+++ b/src/hlink.h
@@ -45,7 +45,7 @@ gboolean gnm_hlink_get_range_target (GnmHLink const *lnk, GnmSheetRange *sr);
 GnmExprTop const *gnm_hlink_get_target_expr (GnmHLink const *lnk);
 
 /* Protected. */
-void _gnm_hlink_init (void);
+void gnm_hlink_init_ (void);
 
 G_END_DECLS
 
diff --git a/src/libgnumeric.c b/src/libgnumeric.c
index 98ad276f0..051d96d1e 100644
--- a/src/libgnumeric.c
+++ b/src/libgnumeric.c
@@ -308,17 +308,17 @@ gnm_init (void)
 
        value_init ();
        parse_util_init ();
-       _gnm_expr_init ();
+       gnm_expr_init_ ();
        gnm_sheet_cell_init ();
        clipboard_init ();
        gui_clipboard_init ();
        dependent_types_init ();
        gnm_rendered_value_init ();
-       functions_init ();
+       gnm_func_init_ ();
        print_init ();
        gnm_autofill_init ();
        sheet_objects_init ();
-       _gnm_hlink_init ();
+       gnm_hlink_init_ ();
 
        /* The statically linked in file formats */
        gnm_xml_sax_read_init ();
@@ -350,15 +350,15 @@ gnm_shutdown (void)
 
        gnm_autofill_shutdown ();
        print_shutdown ();
-       functions_shutdown ();
+       gnm_func_shutdown_ ();
 
        gnm_rendered_value_shutdown ();
        dependent_types_shutdown ();
        gui_clipboard_shutdown ();
        clipboard_shutdown ();
        gnm_sheet_cell_shutdown ();
-       _gnm_expr_deriv_shutdown ();
-       _gnm_expr_shutdown ();
+       gnm_expr_deriv_shutdown_ ();
+       gnm_expr_shutdown_ ();
        parse_util_shutdown ();
        value_shutdown ();
 
diff --git a/src/mathfunc.c b/src/mathfunc.c
index 75f5a5e60..0c4e6735b 100644
--- a/src/mathfunc.c
+++ b/src/mathfunc.c
@@ -4974,14 +4974,14 @@ expmx2h (gnm_float x)
 /* ------------------------------------------------------------------------- */
 
 /**
- * agm:
+ * gnm_agm:
  * @a: a number
  * @b: a number
  *
  * Returns: The arithmetic-geometric mean of @a and @b.
  */
 gnm_float
-agm (gnm_float a, gnm_float b)
+gnm_agm (gnm_float a, gnm_float b)
 {
        gnm_float ab = a * b;
        gnm_float scale = 1;
diff --git a/src/mathfunc.h b/src/mathfunc.h
index 98d8887c3..32a68ab8a 100644
--- a/src/mathfunc.h
+++ b/src/mathfunc.h
@@ -37,7 +37,7 @@ gnm_float logspace_sub (gnm_float logx, gnm_float logy);
 gnm_float gnm_owent (gnm_float h, gnm_float a);
 gnm_float gnm_logcf (gnm_float x, gnm_float i, gnm_float d);
 gnm_float expmx2h (gnm_float x);
-gnm_float agm(gnm_float a, gnm_float b);
+gnm_float gnm_agm(gnm_float a, gnm_float b);
 
 /* "d": density.  */
 /* "p": distribution function.  */
diff --git a/src/wbc-gtk.c b/src/wbc-gtk.c
index 14bbaa7cd..9ebc88064 100644
--- a/src/wbc-gtk.c
+++ b/src/wbc-gtk.c
@@ -1917,7 +1917,7 @@ wbc_gtk_close (WBCGtk *wbcg)
        } else
                g_object_unref (wbcg);
 
-       _gnm_app_flag_windows_changed ();
+       gnm_app_flag_windows_changed_ ();
 
        return FALSE;
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]