mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-22 22:31:28 +02:00
MINOR: lua: identify userdata objects
This patch adds lua primitives for identifying lua class associated with userdata.
This commit is contained in:
parent
a7b536b53b
commit
d2a3dcc8bd
49
src/hlua.c
49
src/hlua.c
@ -254,6 +254,13 @@ __LJMP static inline void hlua_class_function(lua_State *L, const char *name,
|
|||||||
lua_settable(L, -3);
|
lua_settable(L, -3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
__LJMP static int hlua_dump_object(struct lua_State *L)
|
||||||
|
{
|
||||||
|
const char *name = (const char *)lua_tostring(L, lua_upvalueindex(1));
|
||||||
|
lua_pushfstring(L, "HAProxy class %s", name);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
/* This function check the number of arguments available in the
|
/* This function check the number of arguments available in the
|
||||||
* stack. If the number of arguments available is not the same
|
* stack. If the number of arguments available is not the same
|
||||||
* then <nb> an error is throwed.
|
* then <nb> an error is throwed.
|
||||||
@ -4917,6 +4924,12 @@ void hlua_init(void)
|
|||||||
/* Create and fill the metatable. */
|
/* Create and fill the metatable. */
|
||||||
lua_newtable(gL.T);
|
lua_newtable(gL.T);
|
||||||
|
|
||||||
|
/* Create the __tostring identifier */
|
||||||
|
lua_pushstring(gL.T, "__tostring");
|
||||||
|
lua_pushstring(gL.T, CLASS_MAP);
|
||||||
|
lua_pushcclosure(gL.T, hlua_dump_object, 1);
|
||||||
|
lua_rawset(gL.T, -3);
|
||||||
|
|
||||||
/* Create and fille the __index entry. */
|
/* Create and fille the __index entry. */
|
||||||
lua_pushstring(gL.T, "__index");
|
lua_pushstring(gL.T, "__index");
|
||||||
lua_newtable(gL.T);
|
lua_newtable(gL.T);
|
||||||
@ -4948,6 +4961,12 @@ void hlua_init(void)
|
|||||||
/* Create and fill the metatable. */
|
/* Create and fill the metatable. */
|
||||||
lua_newtable(gL.T);
|
lua_newtable(gL.T);
|
||||||
|
|
||||||
|
/* Create the __tostring identifier */
|
||||||
|
lua_pushstring(gL.T, "__tostring");
|
||||||
|
lua_pushstring(gL.T, CLASS_CHANNEL);
|
||||||
|
lua_pushcclosure(gL.T, hlua_dump_object, 1);
|
||||||
|
lua_rawset(gL.T, -3);
|
||||||
|
|
||||||
/* Create and fille the __index entry. */
|
/* Create and fille the __index entry. */
|
||||||
lua_pushstring(gL.T, "__index");
|
lua_pushstring(gL.T, "__index");
|
||||||
lua_newtable(gL.T);
|
lua_newtable(gL.T);
|
||||||
@ -4979,6 +4998,12 @@ void hlua_init(void)
|
|||||||
/* Create and fill the metatable. */
|
/* Create and fill the metatable. */
|
||||||
lua_newtable(gL.T);
|
lua_newtable(gL.T);
|
||||||
|
|
||||||
|
/* Create the __tostring identifier */
|
||||||
|
lua_pushstring(gL.T, "__tostring");
|
||||||
|
lua_pushstring(gL.T, CLASS_FETCHES);
|
||||||
|
lua_pushcclosure(gL.T, hlua_dump_object, 1);
|
||||||
|
lua_rawset(gL.T, -3);
|
||||||
|
|
||||||
/* Create and fille the __index entry. */
|
/* Create and fille the __index entry. */
|
||||||
lua_pushstring(gL.T, "__index");
|
lua_pushstring(gL.T, "__index");
|
||||||
lua_newtable(gL.T);
|
lua_newtable(gL.T);
|
||||||
@ -5029,6 +5054,12 @@ void hlua_init(void)
|
|||||||
/* Create and fill the metatable. */
|
/* Create and fill the metatable. */
|
||||||
lua_newtable(gL.T);
|
lua_newtable(gL.T);
|
||||||
|
|
||||||
|
/* Create the __tostring identifier */
|
||||||
|
lua_pushstring(gL.T, "__tostring");
|
||||||
|
lua_pushstring(gL.T, CLASS_CONVERTERS);
|
||||||
|
lua_pushcclosure(gL.T, hlua_dump_object, 1);
|
||||||
|
lua_rawset(gL.T, -3);
|
||||||
|
|
||||||
/* Create and fill the __index entry. */
|
/* Create and fill the __index entry. */
|
||||||
lua_pushstring(gL.T, "__index");
|
lua_pushstring(gL.T, "__index");
|
||||||
lua_newtable(gL.T);
|
lua_newtable(gL.T);
|
||||||
@ -5076,6 +5107,12 @@ void hlua_init(void)
|
|||||||
/* Create and fill the metatable. */
|
/* Create and fill the metatable. */
|
||||||
lua_newtable(gL.T);
|
lua_newtable(gL.T);
|
||||||
|
|
||||||
|
/* Create the __tostring identifier */
|
||||||
|
lua_pushstring(gL.T, "__tostring");
|
||||||
|
lua_pushstring(gL.T, CLASS_HTTP);
|
||||||
|
lua_pushcclosure(gL.T, hlua_dump_object, 1);
|
||||||
|
lua_rawset(gL.T, -3);
|
||||||
|
|
||||||
/* Create and fille the __index entry. */
|
/* Create and fille the __index entry. */
|
||||||
lua_pushstring(gL.T, "__index");
|
lua_pushstring(gL.T, "__index");
|
||||||
lua_newtable(gL.T);
|
lua_newtable(gL.T);
|
||||||
@ -5116,6 +5153,12 @@ void hlua_init(void)
|
|||||||
/* Create and fill the metatable. */
|
/* Create and fill the metatable. */
|
||||||
lua_newtable(gL.T);
|
lua_newtable(gL.T);
|
||||||
|
|
||||||
|
/* Create the __tostring identifier */
|
||||||
|
lua_pushstring(gL.T, "__tostring");
|
||||||
|
lua_pushstring(gL.T, CLASS_TXN);
|
||||||
|
lua_pushcclosure(gL.T, hlua_dump_object, 1);
|
||||||
|
lua_rawset(gL.T, -3);
|
||||||
|
|
||||||
/* Create and fille the __index entry. */
|
/* Create and fille the __index entry. */
|
||||||
lua_pushstring(gL.T, "__index");
|
lua_pushstring(gL.T, "__index");
|
||||||
lua_newtable(gL.T);
|
lua_newtable(gL.T);
|
||||||
@ -5152,6 +5195,12 @@ void hlua_init(void)
|
|||||||
/* Create and fill the metatable. */
|
/* Create and fill the metatable. */
|
||||||
lua_newtable(gL.T);
|
lua_newtable(gL.T);
|
||||||
|
|
||||||
|
/* Create the __tostring identifier */
|
||||||
|
lua_pushstring(gL.T, "__tostring");
|
||||||
|
lua_pushstring(gL.T, CLASS_SOCKET);
|
||||||
|
lua_pushcclosure(gL.T, hlua_dump_object, 1);
|
||||||
|
lua_rawset(gL.T, -3);
|
||||||
|
|
||||||
/* Create and fille the __index entry. */
|
/* Create and fille the __index entry. */
|
||||||
lua_pushstring(gL.T, "__index");
|
lua_pushstring(gL.T, "__index");
|
||||||
lua_newtable(gL.T);
|
lua_newtable(gL.T);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user