diff options
author | MikalaiR <nikolay.romanovich@narod.ru> | 2016-01-16 18:38:10 +0000 |
---|---|---|
committer | MikalaiR <nikolay.romanovich@narod.ru> | 2016-01-16 18:38:10 +0000 |
commit | 6935797e95452a23874692a5b7a79aa5cf8e6ca8 (patch) | |
tree | 19dabfcb3ea0b6fe0c9ff21f11179a270f516d24 /plugins/MirLua | |
parent | 3cbf206e7f84dad11b224b8e01e8f9f1a20f4989 (diff) |
MirLua: database consts
git-svn-id: http://svn.miranda-ng.org/main/trunk@16102 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/MirLua')
-rw-r--r-- | plugins/MirLua/src/m_database.cpp | 12 | ||||
-rw-r--r-- | plugins/MirLua/src/stdafx.h | 16 |
2 files changed, 27 insertions, 1 deletions
diff --git a/plugins/MirLua/src/m_database.cpp b/plugins/MirLua/src/m_database.cpp index 8ac3d99a35..262b338722 100644 --- a/plugins/MirLua/src/m_database.cpp +++ b/plugins/MirLua/src/m_database.cpp @@ -456,6 +456,16 @@ static int SettingsChangedHookEventObjParam(void *obj, WPARAM wParam, LPARAM lPa return res;
}
+static luaM_const consts[] =
+{
+ { "DBVT_BYTE", DBVT_BYTE },
+ { "DBVT_WORD", DBVT_WORD },
+ { "DBVT_DWORD", DBVT_DWORD },
+ { "DBVT_ASCIIZ", DBVT_ASCIIZ },
+ { "DBVT_UTF8", DBVT_UTF8 },
+ { "DBVT_WCHAR", DBVT_WCHAR }
+};
+
static luaL_Reg databaseApi[] =
{
{ "FindFirstContact", lua_FindFirstContact },
@@ -661,7 +671,7 @@ static int ci__index(lua_State *L) LUAMOD_API int luaopen_m_database(lua_State *L)
{
luaL_newlib(L, databaseApi);
-
+ luaM_loadConsts(L, consts);
MT<DBCONTACTWRITESETTING>(L, MT_DBCONTACTWRITESETTING)
//.Field(LFUNC(DBCONTACTWRITESETTING, [](DBCONTACTWRITESETTING *p) { return p->szModule; }), "Module", LUA_TSTRINGA)
//.Field(LFUNC(DBCONTACTWRITESETTING, [](DBCONTACTWRITESETTING *p) { return p->szSetting; }), "Setting", LUA_TSTRINGA)
diff --git a/plugins/MirLua/src/stdafx.h b/plugins/MirLua/src/stdafx.h index 109e91c1e4..5f4b58a781 100644 --- a/plugins/MirLua/src/stdafx.h +++ b/plugins/MirLua/src/stdafx.h @@ -41,6 +41,12 @@ class CMLuaScript;
+struct luaM_const
+{
+ char *name;
+ intptr_t value;
+};
+
#include "mlua.h"
#include "mlua_script.h"
#include "mlua_module_loader.h"
@@ -103,6 +109,16 @@ LUAMOD_API int (luaopen_m_variables)(lua_State *L); /* utils */
+__forceinline void luaM_loadConsts(lua_State *L, luaM_const consts[])
+{
+ for (size_t i = 0; consts[i].name != NULL; i++)
+ {
+ lua_pushstring(L, consts[i].name);
+ lua_pushnumber(L, consts[i].value);
+ lua_settable(L, -3);
+ }
+}
+
extern HANDLE hNetlib;
void Log(const char *format, ...);
void Log(const wchar_t *format, ...);
|