summaryrefslogtreecommitdiff
path: root/plugins/MirLua/src/environment.h
blob: 52b42e7722322926e6137fa76227fe0ded2c535e (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
#pragma once

class CMLuaEnvironment : public CMPluginBase, public MZeroedObject
{
private:
	CMPluginBase *m_plugin;

	std::map<HANDLE, int> m_hookRefs;
	std::map<HANDLE, int> m_serviceRefs;

protected:
	void CreateEnvironmentTable();

	wchar_t* Error();

public:
	lua_State *L;

	CMLuaEnvironment(lua_State *L);

	int Unload() override;

	static CMLuaEnvironment* GetEnvironment(lua_State *L);
	static HPLUGIN GetEnvironmentId(lua_State *L);

	HANDLE HookEvent(const char *name, int ref);
	int UnhookEvent(HANDLE hHook);

	HANDLE CreateServiceFunction(const char *name, int ref);
	void DestroyServiceFunction(HANDLE hService);

	wchar_t* Call();
	wchar_t* Eval(const wchar_t *script);
	wchar_t* Exec(const wchar_t *path);
};