diff --git a/include/types/hlua.h b/include/types/hlua.h index cfeb767a80..b2c3997e55 100644 --- a/include/types/hlua.h +++ b/include/types/hlua.h @@ -3,6 +3,8 @@ #include +#define CLASS_CORE "Core" + enum hlua_state { HLUA_STOP = 0, HLUA_RUN, diff --git a/include/types/log.h b/include/types/log.h index c680663f34..345a09f198 100644 --- a/include/types/log.h +++ b/include/types/log.h @@ -33,6 +33,8 @@ #define SYSLOG_PORT 514 #define UNIQUEID_LEN 128 +/* The array containing the names of the log levels. */ +extern const char *log_levels[]; /* lists of fields that can be logged */ enum { diff --git a/src/hlua.c b/src/hlua.c index dd037845fc..00b88cad30 100644 --- a/src/hlua.c +++ b/src/hlua.c @@ -36,6 +36,12 @@ struct pool_head *pool2_hlua_com; */ struct eb_root hlua_ctx = EB_ROOT_UNIQUE; +/* The following variables contains the reference of the different + * Lua classes. These references are useful for identify metadata + * associated with an object. + */ +static int class_core_ref; + /* Used to check an Lua function type in the stack. It creates and * returns a reference of the function. This function throws an * error if the rgument is not a "function". @@ -490,6 +496,8 @@ static struct cfg_kw_list cfg_kws = {{ },{ void hlua_init(void) { + int i; + /* Initialise com signals pool session. */ pool2_hlua_com = create_pool("hlua_com", sizeof(struct hlua_com), MEM_F_SHARED); @@ -507,4 +515,39 @@ void hlua_init(void) /* Initialise lua. */ luaL_openlibs(gL.T); + + /* + * + * Create "core" object. + * + */ + + /* This integer entry is just used as base value for the object "core". */ + lua_pushinteger(gL.T, 0); + + /* Create and fill the metatable. */ + lua_newtable(gL.T); + + /* Create and fill the __index entry. */ + lua_pushstring(gL.T, "__index"); + lua_newtable(gL.T); + + /* Push the loglevel constants. */ + for (i=0; i