diff options
Diffstat (limited to 'plugins/MirLua/src/mlua.cpp')
| -rw-r--r-- | plugins/MirLua/src/mlua.cpp | 62 | 
1 files changed, 62 insertions, 0 deletions
diff --git a/plugins/MirLua/src/mlua.cpp b/plugins/MirLua/src/mlua.cpp index 2b9ea1fd92..e731c151a8 100644 --- a/plugins/MirLua/src/mlua.cpp +++ b/plugins/MirLua/src/mlua.cpp @@ -18,6 +18,7 @@ CMLua::CMLua()  	Preload(MLUA_DATABASE, luaopen_m_database);
  	Preload(MLUA_ICOLIB, luaopen_m_icolib);
  	Preload(MLUA_GENMENU, luaopen_m_genmenu);
 +	Preload(MLUA_TOPTOOLBAR, luaopen_m_toptoolbar);
  }
  CMLua::~CMLua()
 @@ -48,4 +49,65 @@ void CMLua::Preload(const char *name, lua_CFunction loader)  	lua_pushcfunction(L, loader);
  	lua_setfield(L, -2, name);
  	lua_pop(L, 1);
 +}
 +
 +WPARAM CMLua::GetWParam(lua_State *L, int idx)
 +{
 +	WPARAM wParam = NULL;
 +	switch (lua_type(L, idx))
 +	{
 +	case LUA_TBOOLEAN:
 +		wParam = lua_toboolean(L, idx);
 +		break;
 +	case LUA_TNUMBER:
 +		wParam = lua_tonumber(L, idx);
 +		break;
 +	case LUA_TSTRING:
 +		wParam = (WPARAM)lua_tostring(L, idx);
 +		break;
 +	case LUA_TUSERDATA:
 +		wParam = (WPARAM)lua_touserdata(L, idx);
 +		break;
 +	}
 +	return wParam;
 +}
 +
 +LPARAM CMLua::GetLParam(lua_State *L, int idx)
 +{
 +	LPARAM lParam = NULL;
 +	switch (lua_type(L, idx))
 +	{
 +	case LUA_TBOOLEAN:
 +		lParam = lua_toboolean(L, idx);
 +		break;
 +	case LUA_TNUMBER:
 +		lParam = lua_tonumber(L, idx);
 +		break;
 +	case LUA_TSTRING:
 +		lParam = (LPARAM)lua_tostring(L, idx);
 +		break;
 +	case LUA_TUSERDATA:
 +		lParam = (LPARAM)lua_touserdata(L, idx);
 +		break;
 +	}
 +	return lParam;
 +}
 +
 +int CMLua::HookEventObjParam(void *obj, WPARAM wParam, LPARAM lParam, LPARAM param)
 +{
 +	lua_State *L = (lua_State*)obj;
 +
 +	int ref = param;
 +	lua_rawgeti(L, LUA_REGISTRYINDEX, ref);
 +
 +	lua_pushnumber(L, wParam);
 +	lua_pushnumber(L, lParam);
 +	if (lua_pcall(L, 2, 1, 0))
 +		printf("%s\n", lua_tostring(L, -1));
 +
 +	int res = (int)lua_tointeger(L, 1);
 +
 +	//luaL_unref(L, LUA_REGISTRYINDEX, ref);
 +
 +	return res;
  }
\ No newline at end of file  | 
