summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2016-02-22 22:29:21 +0000
committerAlexander Lantsev <aunsane@gmail.com>2016-02-22 22:29:21 +0000
commit4c73ded51e3d25b836fad3a8dfaf35ab1615a281 (patch)
tree17f9792e70ad4b5f6a54842970a047bd86d731d2
parent0b82b879821c7e73b86f189be747c5634c8b46b7 (diff)
MirLua: fixed metatable constructor function
git-svn-id: http://svn.miranda-ng.org/main/trunk@16327 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--plugins/MirLua/Modules/m_msg_buttonsbar/src/main.cpp15
-rw-r--r--plugins/MirLua/src/mlua_metatable.h6
2 files changed, 7 insertions, 14 deletions
diff --git a/plugins/MirLua/Modules/m_msg_buttonsbar/src/main.cpp b/plugins/MirLua/Modules/m_msg_buttonsbar/src/main.cpp
index a52338d9ad..de2fbdc021 100644
--- a/plugins/MirLua/Modules/m_msg_buttonsbar/src/main.cpp
+++ b/plugins/MirLua/Modules/m_msg_buttonsbar/src/main.cpp
@@ -95,7 +95,7 @@ static luaL_Reg msgbuttinsbarApi[] =
#define MT_CUSTOMBUTTONCLICKDATA "CustomButtonClickData"
-static int bcd__call(lua_State *L)
+static int bcd_new(lua_State *L)
{
CustomButtonClickData *bcd = (CustomButtonClickData*)lua_touserdata(L, 1);
if (bcd == NULL)
@@ -131,22 +131,17 @@ static int bcd__index(lua_State *L)
return 1;
}
-static luaL_Reg bcdMeta[] =
-{
- { "__call", bcd__call },
- { "__index", bcd__index },
-
- { NULL, NULL }
-};
-
/***********************************************/
extern "C" LUAMOD_API int luaopen_m_msg_buttonsbar(lua_State *L)
{
luaL_newlib(L, msgbuttinsbarApi);
+ lua_register(L, MT_CUSTOMBUTTONCLICKDATA, bcd_new);
+
luaL_newmetatable(L, MT_CUSTOMBUTTONCLICKDATA);
- luaL_setfuncs(L, bcdMeta, 0);
+ lua_pushcfunction(L, bcd__index);
+ lua_setfield(L, -2, "__index");
lua_pop(L, 1);
return 1;
diff --git a/plugins/MirLua/src/mlua_metatable.h b/plugins/MirLua/src/mlua_metatable.h
index 39bc63149c..5262b6f50c 100644
--- a/plugins/MirLua/src/mlua_metatable.h
+++ b/plugins/MirLua/src/mlua_metatable.h
@@ -68,7 +68,7 @@ private:
*obj = NULL;
}
- static int lua__new(lua_State *L)
+ static int lua_new(lua_State *L)
{
T *udata = (T*)lua_newuserdata(L, sizeof(T));
memset(udata, 0, sizeof(T));
@@ -139,11 +139,9 @@ public:
{
MT::name = tname;
- lua_register(L, MT::name, lua__new);
+ lua_register(L, MT::name, lua_new);
luaL_newmetatable(L, MT::name);
- lua_pushcfunction(L, lua__new);
- lua_setfield(L, -2, "__call");
lua_pushcfunction(L, lua__index);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, lua__gc);