q66 pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=3b343878a840d6b33e65dab573fadad0dee54fd4

commit 3b343878a840d6b33e65dab573fadad0dee54fd4
Author: Daniel Kolesa <[email protected]>
Date:   Thu Dec 11 15:48:18 2014 +0000

    elua: add initial pieces of the library
---
 src/Makefile_Elua.am        |  7 ++++-
 src/bin/elua/main.c         | 12 ++++-----
 src/bin/elua/main.h         |  2 ++
 src/lib/elua/Elua.h         |  3 +++
 src/lib/elua/elua.c         | 64 +++++++++++++++++++++++++++++++++++++++++++++
 src/lib/elua/elua_private.h | 26 ++++++++++++++++++
 6 files changed, 107 insertions(+), 7 deletions(-)

diff --git a/src/Makefile_Elua.am b/src/Makefile_Elua.am
index 0856d23..63942f5 100644
--- a/src/Makefile_Elua.am
+++ b/src/Makefile_Elua.am
@@ -9,7 +9,12 @@ lib/elua/Elua.h
 lib_elua_libelua_la_SOURCES = \
 lib/elua/elua.c
 
-lib_elua_libelua_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl @ELUA_CFLAGS@
+lib_elua_libelua_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl @ELUA_CFLAGS@ \
+       -DLOCALE_DIR=\"@LOCALE_DIR@\" \
+       -DPACKAGE_SRC_DIR=\"$(abs_top_srcdir)\" \
+       -DPACKAGE_BIN_DIR=\"$(bindir)\" \
+       -DPACKAGE_DATA_DIR=\"$(datadir)/elua\"
+
 if HAVE_WIN32
 lib_elua_libelua_la_LIBADD = -L$(top_builddir)/src/lib/evil @ELUA_LIBS@
 else
diff --git a/src/bin/elua/main.c b/src/bin/elua/main.c
index 424d5b9..1edf98f 100644
--- a/src/bin/elua/main.c
+++ b/src/bin/elua/main.c
@@ -1,4 +1,4 @@
-#include "config.h" 
+#include "config.h"
 
 /* The Lua runtime component of the EFL */
 
@@ -265,7 +265,7 @@ elua_doscript(lua_State *L, int argc, char **argv, int n, 
int *quit)
 }
 
 void
-elua_shutdown(lua_State *L, int c)
+elua_bin_shutdown(lua_State *L, int c)
 {
    void *data;
    INF("elua shutdown");
@@ -281,7 +281,7 @@ elua_shutdown(lua_State *L, int c)
    if (L) lua_close(L);
    if (el_log_domain != EINA_LOG_DOMAIN_GLOBAL)
      eina_log_domain_unregister(el_log_domain);
-   eina_shutdown();
+   elua_shutdown();
    exit(c);
 }
 
@@ -584,7 +584,7 @@ main(int argc, char **argv)
    textdomain(PACKAGE);
 #endif
 
-   eina_init();
+   elua_init();
 
    if (!(el_log_domain = eina_log_domain_register("elua", EINA_COLOR_ORANGE)))
      {
@@ -598,7 +598,7 @@ main(int argc, char **argv)
    if (!(L = luaL_newstate()))
      {
         ERR("could not initialize elua state.");
-        elua_shutdown(L, 1);
+        elua_bin_shutdown(L, 1);
      }
 
    elua_state = L;
@@ -609,7 +609,7 @@ main(int argc, char **argv)
    m.argv   = argv;
    m.status = 0;
 
-   elua_shutdown(L, !!(lua_cpcall(L, elua_main, &m) || m.status));
+   elua_bin_shutdown(L, !!(lua_cpcall(L, elua_main, &m) || m.status));
 
    return 0; /* never gets here */
 }
diff --git a/src/bin/elua/main.h b/src/bin/elua/main.h
index 15c7490..c66b3d6 100644
--- a/src/bin/elua/main.h
+++ b/src/bin/elua/main.h
@@ -23,6 +23,8 @@
 #include <Evil.h>
 #endif
 
+#include "Elua.h"
+
 #include <lua.h>
 #include <lualib.h>
 #include <lauxlib.h>
diff --git a/src/lib/elua/Elua.h b/src/lib/elua/Elua.h
index c037f32..3a284ca 100644
--- a/src/lib/elua/Elua.h
+++ b/src/lib/elua/Elua.h
@@ -54,6 +54,9 @@ extern "C" {
 
 #ifdef EFL_BETA_API_SUPPORT
 
+EAPI int elua_init(void);
+EAPI int elua_shutdown(void);
+
 #endif
 
 #ifdef __cplusplus
diff --git a/src/lib/elua/elua.c b/src/lib/elua/elua.c
index fc4b894..5e98759 100644
--- a/src/lib/elua/elua.c
+++ b/src/lib/elua/elua.c
@@ -1 +1,65 @@
+#include <Eina.h>
+
 #include "Elua.h"
+#include "elua_private.h"
+
+static Eina_Prefix *_elua_pfx = NULL;
+
+static int _elua_init_counter = 0;
+int _elua_log_dom = -1;
+
+EAPI int
+elua_init(void)
+{
+   const char *dom = "elua";
+   if (_elua_init_counter > 0) return ++_elua_init_counter;
+
+   eina_init();
+   _elua_log_dom = eina_log_domain_register(dom, EINA_COLOR_LIGHTBLUE);
+   if (_elua_log_dom < 0)
+     {
+        EINA_LOG_ERR("Could not register log domain: %s", dom);
+        return EINA_FALSE;
+     }
+
+   eina_log_timing(_elua_log_dom, EINA_LOG_STATE_STOP, EINA_LOG_STATE_INIT);
+   INF("elua init");
+
+   _elua_pfx = eina_prefix_new(NULL, elua_init, "ELUA", "elua", NULL,
+                               PACKAGE_BIN_DIR, "", PACKAGE_DATA_DIR,
+                               LOCALE_DIR);
+
+   if (!_elua_pfx)
+     {
+        ERR("coul not find elua prefix");
+        return EINA_FALSE;
+     }
+
+   return ++_elua_init_counter;
+}
+
+EAPI int
+elua_shutdown(void)
+{
+   if (_elua_init_counter <= 0)
+     {
+        EINA_LOG_ERR("Init count not greater than 0 in shutdown.");
+        return EINA_FALSE;
+     }
+   --_elua_init_counter;
+
+   if (_elua_init_counter > 0)
+     return _elua_init_counter;
+
+   INF("shutdown");
+   eina_log_timing(_elua_log_dom, EINA_LOG_STATE_START, 
EINA_LOG_STATE_SHUTDOWN);
+
+   eina_prefix_free(_elua_pfx);
+   _elua_pfx = NULL;
+
+   eina_log_domain_unregister(_elua_log_dom);
+   _elua_log_dom = -1;
+
+   eina_shutdown();
+   return _elua_init_counter;
+}
diff --git a/src/lib/elua/elua_private.h b/src/lib/elua/elua_private.h
new file mode 100644
index 0000000..a4be6fb
--- /dev/null
+++ b/src/lib/elua/elua_private.h
@@ -0,0 +1,26 @@
+#ifndef _ELUA_PRIVATE_H
+#define _ELUA_PRIVATE_H
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <Eina.h>
+#include <Ecore.h>
+
+#ifdef HAVE_EVIL
+#include <Evil.h>
+#endif
+
+#include <lua.h>
+#include <lualib.h>
+#include <lauxlib.h>
+
+extern int _elua_log_dom;
+
+#define DBG(...) EINA_LOG_DOM_DBG(_elua_log_dom, __VA_ARGS__)
+#define INF(...) EINA_LOG_DOM_INFO(_elua_log_dom, __VA_ARGS__)
+#define WRN(...) EINA_LOG_DOM_WARN(_elua_log_dom, __VA_ARGS__)
+#define ERR(...) EINA_LOG_DOM_ERR(_elua_log_dom, __VA_ARGS__)
+#define CRT(...) EINA_LOG_DOM_CRITICAL(_elua_log_dom, __VA_ARGS__)
+
+#endif

-- 


Reply via email to