mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-22 22:31:28 +02:00
MINOR: replace the Core object by a simple model.
The core entry is just a collection of function, it doesn't depends on special variable. This patch just converts an object contained in a metatable in object contained in a normal table.
This commit is contained in:
parent
59551663e5
commit
a2d8c650c1
23
src/hlua.c
23
src/hlua.c
@ -68,7 +68,6 @@ struct list hlua_init_functions = LIST_HEAD_INIT(hlua_init_functions);
|
|||||||
* Lua classes. These references are useful for identify metadata
|
* Lua classes. These references are useful for identify metadata
|
||||||
* associated with an object.
|
* associated with an object.
|
||||||
*/
|
*/
|
||||||
static int class_core_ref;
|
|
||||||
static int class_txn_ref;
|
static int class_txn_ref;
|
||||||
static int class_socket_ref;
|
static int class_socket_ref;
|
||||||
static int class_channel_ref;
|
static int class_channel_ref;
|
||||||
@ -3685,14 +3684,7 @@ void hlua_init(void)
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* This integer entry is just used as base value for the object "core". */
|
/* This table entry is the object "core" base. */
|
||||||
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);
|
lua_newtable(gL.T);
|
||||||
|
|
||||||
/* Push the loglevel constants. */
|
/* Push the loglevel constants. */
|
||||||
@ -3714,19 +3706,6 @@ void hlua_init(void)
|
|||||||
hlua_class_function(gL.T, "del_map", hlua_del_map);
|
hlua_class_function(gL.T, "del_map", hlua_del_map);
|
||||||
hlua_class_function(gL.T, "tcp", hlua_socket_new);
|
hlua_class_function(gL.T, "tcp", hlua_socket_new);
|
||||||
|
|
||||||
/* Store the table __index in the metable. */
|
|
||||||
lua_settable(gL.T, -3);
|
|
||||||
|
|
||||||
/* Register previous table in the registry with named entry. */
|
|
||||||
lua_pushvalue(gL.T, -1); /* Copy the -1 entry and push it on the stack. */
|
|
||||||
lua_setfield(gL.T, LUA_REGISTRYINDEX, CLASS_CORE); /* register class session. */
|
|
||||||
|
|
||||||
/* Register previous table in the registry with reference. */
|
|
||||||
lua_pushvalue(gL.T, -1); /* Copy the -1 entry and push it on the stack. */
|
|
||||||
class_core_ref = luaL_ref(gL.T, LUA_REGISTRYINDEX); /* reference class session. */
|
|
||||||
|
|
||||||
/* Create new object with class Core. */
|
|
||||||
lua_setmetatable(gL.T, -2);
|
|
||||||
lua_setglobal(gL.T, "core");
|
lua_setglobal(gL.T, "core");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user