summaryrefslogtreecommitdiff
path: root/plugins/ExternalAPI/m_lua.h
blob: 6bf0ccc051960d94f1bb68098c91a0feaf89edb8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#ifndef _M_LUA_H_
#define _M_LUA_H_

#include <lua.hpp>

static __inline WPARAM luaM_towparam(lua_State *L, int idx)
{
	switch (lua_type(L, idx))
	{
	case LUA_TBOOLEAN:
		return lua_toboolean(L, idx);
	case LUA_TNUMBER:
		return lua_tonumber(L, idx);
	case LUA_TSTRING:
		return (WPARAM)lua_tostring(L, idx);
		break;
	case LUA_TUSERDATA:
	case LUA_TLIGHTUSERDATA:
		return (WPARAM)lua_touserdata(L, idx);
	default:
		return NULL;
	}
}

static __inline LPARAM luaM_tolparam(lua_State *L, int idx)
{
	switch (lua_type(L, idx))
	{
	case LUA_TBOOLEAN:
		return lua_toboolean(L, idx);
	case LUA_TNUMBER:
		return lua_tonumber(L, idx);
	case LUA_TSTRING:
		return (LPARAM)lua_tostring(L, idx);
	case LUA_TUSERDATA:
	case LUA_TLIGHTUSERDATA:
		return (LPARAM)lua_touserdata(L, idx);
	default:
		return NULL;
	}
}

#endif //_M_LUA_H_