summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@samsung.com>2014-12-11 15:48:18 +0000
committerDaniel Kolesa <d.kolesa@samsung.com>2014-12-11 15:48:18 +0000
commit3b343878a840d6b33e65dab573fadad0dee54fd4 (patch)
treef47d26c40ced1564ad3a5e3b940f57224ba19f61 /src/lib
parent2f6f06d7a1490263d58d41405278e7220f6833e9 (diff)
elua: add initial pieces of the library
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/elua/Elua.h3
-rw-r--r--src/lib/elua/elua.c64
-rw-r--r--src/lib/elua/elua_private.h26
3 files changed, 93 insertions, 0 deletions
diff --git a/src/lib/elua/Elua.h b/src/lib/elua/Elua.h
index c037f327c6..3a284ca7bf 100644
--- a/src/lib/elua/Elua.h
+++ b/src/lib/elua/Elua.h
@@ -54,6 +54,9 @@ extern "C" {
54 54
55#ifdef EFL_BETA_API_SUPPORT 55#ifdef EFL_BETA_API_SUPPORT
56 56
57EAPI int elua_init(void);
58EAPI int elua_shutdown(void);
59
57#endif 60#endif
58 61
59#ifdef __cplusplus 62#ifdef __cplusplus
diff --git a/src/lib/elua/elua.c b/src/lib/elua/elua.c
index fc4b894f9c..5e987599b9 100644
--- a/src/lib/elua/elua.c
+++ b/src/lib/elua/elua.c
@@ -1 +1,65 @@
1#include <Eina.h>
2
1#include "Elua.h" 3#include "Elua.h"
4#include "elua_private.h"
5
6static Eina_Prefix *_elua_pfx = NULL;
7
8static int _elua_init_counter = 0;
9int _elua_log_dom = -1;
10
11EAPI int
12elua_init(void)
13{
14 const char *dom = "elua";
15 if (_elua_init_counter > 0) return ++_elua_init_counter;
16
17 eina_init();
18 _elua_log_dom = eina_log_domain_register(dom, EINA_COLOR_LIGHTBLUE);
19 if (_elua_log_dom < 0)
20 {
21 EINA_LOG_ERR("Could not register log domain: %s", dom);
22 return EINA_FALSE;
23 }
24
25 eina_log_timing(_elua_log_dom, EINA_LOG_STATE_STOP, EINA_LOG_STATE_INIT);
26 INF("elua init");
27
28 _elua_pfx = eina_prefix_new(NULL, elua_init, "ELUA", "elua", NULL,
29 PACKAGE_BIN_DIR, "", PACKAGE_DATA_DIR,
30 LOCALE_DIR);
31
32 if (!_elua_pfx)
33 {
34 ERR("coul not find elua prefix");
35 return EINA_FALSE;
36 }
37
38 return ++_elua_init_counter;
39}
40
41EAPI int
42elua_shutdown(void)
43{
44 if (_elua_init_counter <= 0)
45 {
46 EINA_LOG_ERR("Init count not greater than 0 in shutdown.");
47 return EINA_FALSE;
48 }
49 --_elua_init_counter;
50
51 if (_elua_init_counter > 0)
52 return _elua_init_counter;
53
54 INF("shutdown");
55 eina_log_timing(_elua_log_dom, EINA_LOG_STATE_START, EINA_LOG_STATE_SHUTDOWN);
56
57 eina_prefix_free(_elua_pfx);
58 _elua_pfx = NULL;
59
60 eina_log_domain_unregister(_elua_log_dom);
61 _elua_log_dom = -1;
62
63 eina_shutdown();
64 return _elua_init_counter;
65}
diff --git a/src/lib/elua/elua_private.h b/src/lib/elua/elua_private.h
new file mode 100644
index 0000000000..a4be6fbfff
--- /dev/null
+++ b/src/lib/elua/elua_private.h
@@ -0,0 +1,26 @@
1#ifndef _ELUA_PRIVATE_H
2#define _ELUA_PRIVATE_H
3
4#include <stdio.h>
5#include <stdlib.h>
6
7#include <Eina.h>
8#include <Ecore.h>
9
10#ifdef HAVE_EVIL
11#include <Evil.h>
12#endif
13
14#include <lua.h>
15#include <lualib.h>
16#include <lauxlib.h>
17
18extern int _elua_log_dom;
19
20#define DBG(...) EINA_LOG_DOM_DBG(_elua_log_dom, __VA_ARGS__)
21#define INF(...) EINA_LOG_DOM_INFO(_elua_log_dom, __VA_ARGS__)
22#define WRN(...) EINA_LOG_DOM_WARN(_elua_log_dom, __VA_ARGS__)
23#define ERR(...) EINA_LOG_DOM_ERR(_elua_log_dom, __VA_ARGS__)
24#define CRT(...) EINA_LOG_DOM_CRITICAL(_elua_log_dom, __VA_ARGS__)
25
26#endif