From 9bdaf07d6ec740a92077af17bddbb914898cd315 Mon Sep 17 00:00:00 2001 From: Andy Williams Date: Sun, 1 Jan 2017 20:10:07 +0000 Subject: [PATCH] elm_code: remove unneeded init code. Move elm_code init to the main elementary as that's where it lives --- src/lib/elementary/elm_code.c | 51 ---------------------- src/lib/elementary/elm_code.h | 28 ------------ src/lib/elementary/elm_code_private.h | 23 ---------- src/lib/elementary/elm_main.c | 1 + src/lib/elementary/elm_priv.h | 1 + src/tests/elementary/elm_code_test_parse.c | 3 -- 6 files changed, 2 insertions(+), 105 deletions(-) diff --git a/src/lib/elementary/elm_code.c b/src/lib/elementary/elm_code.c index 5062031cb4..38017b7cfb 100644 --- a/src/lib/elementary/elm_code.c +++ b/src/lib/elementary/elm_code.c @@ -9,63 +9,12 @@ #include "elm_code_private.h" -static int _elm_code_init = 0; -EAPI int _elm_code_lib_log_dom = -1; - EAPI const Efl_Event_Description ELM_CODE_EVENT_LINE_LOAD_DONE = EFL_EVENT_DESCRIPTION("line,load,done"); EAPI const Efl_Event_Description ELM_CODE_EVENT_FILE_LOAD_DONE = EFL_EVENT_DESCRIPTION("file,load,done"); -EAPI int -elm_code_init(void) -{ - _elm_code_init++; - if (_elm_code_init > 1) return _elm_code_init; - - eina_init(); - - _elm_code_lib_log_dom = eina_log_domain_register("elm_code", EINA_COLOR_CYAN); - if (_elm_code_lib_log_dom < 0) - { - EINA_LOG_ERR("Elm Code can not create its log domain."); - goto shutdown_eina; - } - - _elm_code_parse_setup(); - - eina_log_timing(_elm_code_lib_log_dom, EINA_LOG_STATE_STOP, EINA_LOG_STATE_INIT); - - return _elm_code_init; - - shutdown_eina: - eina_shutdown(); - _elm_code_init--; - - return _elm_code_init; -} - -EAPI int -elm_code_shutdown(void) -{ - _elm_code_init--; - if (_elm_code_init != 0) return _elm_code_init; - - eina_log_timing(_elm_code_lib_log_dom, - EINA_LOG_STATE_START, - EINA_LOG_STATE_SHUTDOWN); - - // Put here your shutdown logic - - eina_log_domain_unregister(_elm_code_lib_log_dom); - _elm_code_lib_log_dom = -1; - - eina_shutdown(); - - return _elm_code_init; -} - EAPI Elm_Code * elm_code_create(void) { diff --git a/src/lib/elementary/elm_code.h b/src/lib/elementary/elm_code.h index 545142c0f6..7b96c04f4b 100644 --- a/src/lib/elementary/elm_code.h +++ b/src/lib/elementary/elm_code.h @@ -41,34 +41,6 @@ extern "C" { * */ -/** - * Initialize Elm Code. - * - * Initializes Elm Code, its dependencies and modules. Should be the first - * function of Elm Code to be called. - * - * @return The init counter value. - * - * @see elm_code_shutdown(). - * - * @ingroup Init - */ -EAPI int elm_code_init(void); - -/** - * Shutdown Elm Code - * - * Shutdown Elm Code. If init count reaches 0, all the internal structures will - * be freed. Any Elm Code library call after this point will leads to an error. - * - * @return Elm Code's init counter value. - * - * @see elm_code_init() - * - * @ingroup Init - */ -EAPI int elm_code_shutdown(void); - /** * Create a new Elm Code instance * diff --git a/src/lib/elementary/elm_code_private.h b/src/lib/elementary/elm_code_private.h index e234782994..aae7884ead 100644 --- a/src/lib/elementary/elm_code_private.h +++ b/src/lib/elementary/elm_code_private.h @@ -1,29 +1,6 @@ #ifndef ELM_CODE_PRIVATE_H # define ELM_CODE_PRIVATE_H -extern int _elm_code_lib_log_dom; - -#ifdef ERR -# undef ERR -#endif -#define ERR(...) EINA_LOG_DOM_ERR(_elm_code_lib_log_dom, __VA_ARGS__) -#ifdef INF -# undef INF -#endif -#define INF(...) EINA_LOG_DOM_INFO(_elm_code_lib_log_dom, __VA_ARGS__) -#ifdef WRN -# undef WRN -#endif -#define WRN(...) EINA_LOG_DOM_WARN(_elm_code_lib_log_dom, __VA_ARGS__) -#ifdef CRIT -# undef CRIT -#endif -#define CRIT(...) EINA_LOG_DOM_CRIT(_elm_code_lib_log_dom, __VA_ARGS__) -#ifdef DBG -# undef DBG -#endif -#define DBG(...) EINA_LOG_DOM_DBG(_elm_code_lib_log_dom, __VA_ARGS__) - Eina_Bool _elm_code_text_char_is_whitespace(char c); /* Private parser callbacks */ diff --git a/src/lib/elementary/elm_main.c b/src/lib/elementary/elm_main.c index e21241fb1e..60514bcabd 100644 --- a/src/lib/elementary/elm_main.c +++ b/src/lib/elementary/elm_main.c @@ -347,6 +347,7 @@ elm_init(int argc, char **argv) _elm_config->web_backend = "none"; if (!_elm_web_init(_elm_config->web_backend)) _elm_config->web_backend = "none"; + _elm_code_parse_setup(); return _elm_init_count; } diff --git a/src/lib/elementary/elm_priv.h b/src/lib/elementary/elm_priv.h index 320e775b1d..50fc9062df 100644 --- a/src/lib/elementary/elm_priv.h +++ b/src/lib/elementary/elm_priv.h @@ -49,6 +49,7 @@ #include "elm_widget.h" #include "elm_access.eo.h" +#include "elm_code_private.h" #ifdef HAVE_LANGINFO_H # include diff --git a/src/tests/elementary/elm_code_test_parse.c b/src/tests/elementary/elm_code_test_parse.c index fb097c5ac0..bc2af0f79c 100644 --- a/src/tests/elementary/elm_code_test_parse.c +++ b/src/tests/elementary/elm_code_test_parse.c @@ -74,8 +74,6 @@ START_TEST (elm_code_parse_todo_test) Elm_Code_Line *line; elm_init(1, NULL); - elm_code_init(); - code = elm_code_create(); elm_code_parser_standard_add(code, ELM_CODE_PARSER_STANDARD_TODO); file = elm_code_file_new(code); @@ -89,7 +87,6 @@ START_TEST (elm_code_parse_todo_test) elm_code_line_text_set(line, "TOFIX", 5); ck_assert_int_eq(ELM_CODE_STATUS_TYPE_DEFAULT, line->status); - elm_code_shutdown(); elm_shutdown(); } END_TEST