elm_code: remove unneeded init code.

Move elm_code init to the main elementary as that's where it lives
This commit is contained in:
Andy Williams 2017-01-01 20:10:07 +00:00
parent 8b12c7d5d7
commit 9bdaf07d6e
6 changed files with 2 additions and 105 deletions

View File

@ -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)
{

View File

@ -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
*

View File

@ -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 */

View File

@ -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;
}

View File

@ -49,6 +49,7 @@
#include "elm_widget.h"
#include "elm_access.eo.h"
#include "elm_code_private.h"
#ifdef HAVE_LANGINFO_H
# include <langinfo.h>

View File

@ -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