summaryrefslogtreecommitdiff
path: root/plugins/MirLua/src/mlua.h
blob: 28fcff5b45218d5c7f3a1d79e0dedb2cb78c588f (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
44
45
#ifndef _LUA_CORE_H_
#define _LUA_CORE_H_

struct HandleRefParam
{
	HANDLE h;
	int ref;
	lua_State *L;
	HandleRefParam(HANDLE h) : L(NULL), h(h), ref(0) { }
	HandleRefParam(lua_State *L, HANDLE h, int ref = 0) : L(L), h(h), ref(ref) { }
};

class CMLua
{
private:
	lua_State *L;
	HANDLE hLoadedEvent;
	HANDLE hUnloadEvent;

	static void KillModuleEventHooks();
	static void KillModuleServices();

	void Load();
	void Unload();

public:
	static LIST<void> Hooks;
	static LIST<void> Events;
	static LIST<void> Services;
	static LIST<void> HookRefs;
	static LIST<void> ServiceRefs;

	CMLua();
	~CMLua();

	void Reload();
	void Reload(const TCHAR* path);

	static int OnScriptLoaded(lua_State *L);
	static int OnScriptUnload(lua_State *L);

	static int HookEventObjParam(void *obj, WPARAM wParam, LPARAM lParam, LPARAM param);
};

#endif //_LUA_CORE_H_