From bb3b1f898e5530e22fa8f48f786fca300cdd36d2 Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Wed, 15 Jun 2016 08:13:23 +0000 Subject: MirLua: DBEVENTINFO.Blob should be table git-svn-id: http://svn.miranda-ng.org/main/trunk@16975 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/MirLua/src/m_database.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/plugins/MirLua/src/m_database.cpp b/plugins/MirLua/src/m_database.cpp index 588e27af82..f37182e210 100644 --- a/plugins/MirLua/src/m_database.cpp +++ b/plugins/MirLua/src/m_database.cpp @@ -651,6 +651,21 @@ void MT::Init(lua_State *L, DBEVENTINFO **dbei) db_event_get((MEVENT)hDbEvent, (*dbei)); } +int MT::Index(lua_State *L, DBEVENTINFO *dbei) +{ + const char *key = luaL_checkstring(L, 2); + + if (mir_strcmpi(key, "Blob") == 0) + { + lua_createtable(L, dbei->cbBlob, 0); + for (int i = 0; i < dbei->cbBlob; i++) + { + lua_pushinteger(L, dbei->pBlob[i]); + lua_rawseti(L, -2, i + 1); + } + } +} + void MT::Free(lua_State*, DBEVENTINFO **dbei) { mir_free((*dbei)->pBlob); @@ -684,9 +699,7 @@ LUAMOD_API int luaopen_m_database(lua_State *L) .Field(&DBEVENTINFO::szModule, "Module", LUA_TSTRINGA) .Field(&DBEVENTINFO::timestamp, "Timestamp", LUA_TINTEGER) .Field(&DBEVENTINFO::eventType, "Type", LUA_TINTEGER) - .Field(&DBEVENTINFO::flags, "Flags", LUA_TINTEGER) - .Field(&DBEVENTINFO::cbBlob, "Length", LUA_TINTEGER) - .Field(&DBEVENTINFO::pBlob, "Blob", LUA_TLIGHTUSERDATA); + .Field(&DBEVENTINFO::flags, "Flags", LUA_TINTEGER); return 1; } -- cgit v1.2.3