elua: add initial pieces of the library
This commit is contained in:
parent
2f6f06d7a1
commit
3b343878a8
|
@ -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
|
||||
|
|
|
@ -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 */
|
||||
}
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
#include <Evil.h>
|
||||
#endif
|
||||
|
||||
#include "Elua.h"
|
||||
|
||||
#include <lua.h>
|
||||
#include <lualib.h>
|
||||
#include <lauxlib.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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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
|
Loading…
Reference in New Issue