|
From: Kouhei S. <nul...@cl...> - 2014-01-19 07:24:16
|
Kouhei Sutou 2014-01-19 16:23:55 +0900 (Sun, 19 Jan 2014) New Revision: b059a230e0dce72b8f5d6357c844a9e2f8ce47d9 https://github.com/clear-code/cutter/commit/b059a230e0dce72b8f5d6357c844a9e2f8ce47d9 Message: Fix wrong macro names These macros can be used with not only listener but also general modules. Removed files: cutter/cut-listener-utils.h Modified files: cutter/Makefile.am cutter/cut-module.h cutter/cut-report.c cutter/cut-stream.c cutter/cut-ui.c Modified: cutter/Makefile.am (+0 -1) =================================================================== --- cutter/Makefile.am 2014-01-19 16:02:10 +0900 (5e29785) +++ cutter/Makefile.am 2014-01-19 16:23:55 +0900 (40178fa) @@ -39,7 +39,6 @@ libcutter_public_headers = \ cut-factory-builder.h \ cut-file-stream-reader.h \ cut-iterated-test.h \ - cut-listener-utils.h \ cut-listener.h \ cut-main.h \ cut-module-factory-utils.h \ Deleted: cutter/cut-listener-utils.h (+0 -93) 100644 =================================================================== --- cutter/cut-listener-utils.h 2014-01-19 16:02:10 +0900 (527f384) +++ /dev/null @@ -1,93 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * Copyright (C) 2007 Kouhei Sutou <ko...@co...> - * - * This library is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - -#ifndef __CUT_LISTENER_UTILS_H__ -#define __CUT_LISTENER_UTILS_H__ - -#include <glib-object.h> -#include "cut-utils.h" - -G_BEGIN_DECLS - -#ifdef G_OS_WIN32 -# define CUT_DEFINE_ADDITIONAL_LISTENER_VARIABLES(name) \ - static gchar *win32_ ## name ## _module_dir = NULL; -# define CUT_LISTENER_RETURN_DEFAULT_MODULE_DIR(name, NAME) do \ - { \ - if (!win32_ ## name ## _module_dir) \ - win32_ ## name ## _module_dir = \ - cut_win32_build_module_dir_name(#name); \ - return win32_ ## name ## _module_dir; \ - } while (0) -#else -# define CUT_DEFINE_ADDITIONAL_LISTENER_VARIABLES(name) -# define CUT_LISTENER_RETURN_DEFAULT_MODULE_DIR(name, NAME) \ - return NAME ## _MODULE_DIR -#endif - - -#define CUT_DEFINE_LISTENER_MODULE(name, NAME) \ -static GList *name ## s = NULL; \ -static gchar *name ## _module_dir = NULL; \ -CUT_DEFINE_ADDITIONAL_LISTENER_VARIABLES(name) \ - \ -static const gchar * \ -_cut_ ## name ## _module_dir (void) \ -{ \ - const gchar *dir; \ - \ - if (name ## _module_dir) \ - return name ## _module_dir; \ - \ - dir = g_getenv("CUT_" #NAME "_MODULE_DIR"); \ - if (dir) \ - return dir; \ - \ - CUT_LISTENER_RETURN_DEFAULT_MODULE_DIR(name, NAME); \ -} \ - \ -static CutModule * \ -cut_ ## name ## _load_module (const gchar *name) \ -{ \ - CutModule *module; \ - \ - module = cut_module_find(name ## s, name); \ - if (module) \ - return module; \ - \ - module = cut_module_load_module(_cut_ ## name ## _module_dir(), \ - name); \ - if (module) { \ - if (g_type_module_use(G_TYPE_MODULE(module))) { \ - name ## s = g_list_prepend(name ## s, module); \ - g_type_module_unuse(G_TYPE_MODULE(module)); \ - } \ - } \ - \ - return module; \ -} - - -G_END_DECLS - -#endif /* __CUT_LISTENER_UTILS_H__ */ - -/* -vi:ts=4:nowrap:ai:expandtab:sw=4 -*/ Modified: cutter/cut-module.h (+59 -0) =================================================================== --- cutter/cut-module.h 2014-01-19 16:02:10 +0900 (c2d67b2) +++ cutter/cut-module.h 2014-01-19 16:23:55 +0900 (40a3cdd) @@ -24,6 +24,65 @@ G_BEGIN_DECLS +#ifdef G_OS_WIN32 +# define CUT_MODULE_DEFINE_ADDITIONAL_VARIABLES(name) \ + static gchar *win32_ ## name ## _module_dir = NULL; +# define CUT_MODULE_RETURN_DEFAULT_MODULE_DIR(name, NAME) do \ + { \ + if (!win32_ ## name ## _module_dir) \ + win32_ ## name ## _module_dir = \ + cut_win32_build_module_dir_name(#name); \ + return win32_ ## name ## _module_dir; \ + } while (0) +#else +# define CUT_MODULE_DEFINE_ADDITIONAL_VARIABLES(name) +# define CUT_MODULE_RETURN_DEFAULT_MODULE_DIR(name, NAME) \ + return NAME ## _MODULE_DIR +#endif + + +#define CUT_MODULE_DEFINE_INTERNAL_DEFINITIONS(name, NAME) \ +static GList *name ## s = NULL; \ +static gchar *name ## _module_dir = NULL; \ +CUT_MODULE_DEFINE_ADDITIONAL_VARIABLES(name) \ + \ +static const gchar * \ +_cut_ ## name ## _module_dir (void) \ +{ \ + const gchar *dir; \ + \ + if (name ## _module_dir) \ + return name ## _module_dir; \ + \ + dir = g_getenv("CUT_" #NAME "_MODULE_DIR"); \ + if (dir) \ + return dir; \ + \ + CUT_MODULE_RETURN_DEFAULT_MODULE_DIR(name, NAME); \ +} \ + \ +static CutModule * \ +cut_ ## name ## _load_module (const gchar *name) \ +{ \ + CutModule *module; \ + \ + module = cut_module_find(name ## s, name); \ + if (module) \ + return module; \ + \ + module = cut_module_load_module(_cut_ ## name ## _module_dir(), \ + name); \ + if (module) { \ + if (g_type_module_use(G_TYPE_MODULE(module))) { \ + name ## s = g_list_prepend(name ## s, module); \ + g_type_module_unuse(G_TYPE_MODULE(module)); \ + } \ + } \ + \ + return module; \ +} + + #define CUT_TYPE_MODULE (cut_module_get_type ()) #define CUT_MODULE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CUT_TYPE_MODULE, CutModule)) #define CUT_MODULE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CUT_TYPE_MODULE, CutModuleClass)) Modified: cutter/cut-report.c (+2 -3) =================================================================== --- cutter/cut-report.c 2014-01-19 16:02:10 +0900 (fe015cf) +++ cutter/cut-report.c 2014-01-19 16:23:55 +0900 (9c6f89e) @@ -1,7 +1,7 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2008 g新部 Hiroyuki Ikezoe <poi...@ik...> - * Copyright (C) 2009 Kouhei Sutou <ko...@co...> + * Copyright (C) 2009-2014 Kouhei Sutou <ko...@cl...> * * This library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -26,7 +26,6 @@ #include "cut-report.h" #include "cut-module.h" -#include "cut-listener-utils.h" #define CUT_REPORT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), CUT_TYPE_REPORT, CutReportPrivate)) @@ -53,7 +52,7 @@ static void get_property (GObject *object, GParamSpec *pspec); G_DEFINE_ABSTRACT_TYPE (CutReport, cut_report, G_TYPE_OBJECT) -CUT_DEFINE_LISTENER_MODULE(report, REPORT) +CUT_MODULE_DEFINE_INTERNAL_DEFINITIONS(report, REPORT) static void cut_report_class_init (CutReportClass *klass) Modified: cutter/cut-stream.c (+1 -2) =================================================================== --- cutter/cut-stream.c 2014-01-19 16:02:10 +0900 (7a74d2e) +++ cutter/cut-stream.c 2014-01-19 16:23:55 +0900 (345b295) @@ -25,10 +25,9 @@ #include "cut-stream.h" #include "cut-module.h" -#include "cut-listener-utils.h" G_DEFINE_ABSTRACT_TYPE (CutStream, cut_stream, G_TYPE_OBJECT) -CUT_DEFINE_LISTENER_MODULE(stream, STREAM) +CUT_MODULE_DEFINE_INTERNAL_DEFINITIONS(stream, STREAM) static void cut_stream_class_init (CutStreamClass *klass) Modified: cutter/cut-ui.c (+1 -2) =================================================================== --- cutter/cut-ui.c 2014-01-19 16:02:10 +0900 (9eca315) +++ cutter/cut-ui.c 2014-01-19 16:23:55 +0900 (55f0884) @@ -25,9 +25,8 @@ #include "cut-ui.h" #include "cut-module.h" -#include "cut-listener-utils.h" -CUT_DEFINE_LISTENER_MODULE(ui, UI) +CUT_MODULE_DEFINE_INTERNAL_DEFINITIONS(ui, UI) void cut_ui_init (void) |