summaryrefslogtreecommitdiff
path: root/include/luaglue/LuaVM.hpp
blob: 6055fd462f25ead3e3ffc79df9459f83a55116a3 (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
46
47
#ifndef __LUA_VM_H
#define __LUA_VM_H

#include "LuaGlueExportable.hpp"

#include "lua.hpp"

#include <vector>
#include <string>

class LuaVM
{
	public:
		LUAGLUE_DLL_VISIBLE LuaVM( );
		LUAGLUE_DLL_VISIBLE ~LuaVM( );
		
		LUAGLUE_DLL_VISIBLE void loadSource( const char *sourceFilename );

		LUAGLUE_DLL_VISIBLE void executeMain( );
		LUAGLUE_DLL_VISIBLE void executeFunction( const std::string &f );

		LUAGLUE_DLL_VISIBLE void dumpState( );
		LUAGLUE_DLL_VISIBLE void dumpGlobals( );
		LUAGLUE_DLL_VISIBLE void dumpStack( );
		
		LUAGLUE_DLL_VISIBLE void fullGarbageCollect( );
		
		LUAGLUE_DLL_VISIBLE std::string getString( const std::string &key );
		LUAGLUE_DLL_VISIBLE std::vector<std::string> getStringArray( const std::string &key );
		LUAGLUE_DLL_VISIBLE int getInt( const std::string &key );
		LUAGLUE_DLL_VISIBLE bool getBoolean( const std::string &key );

		LUAGLUE_DLL_VISIBLE lua_State *handle( );
		
	private:
		void initialize( );

		int findValue( const std::string &key );
		
		void dumpStackElement( lua_State *l, int i, int indent = 0 );

	private:
		lua_State *m_lua;
		std::string m_sourceFilename;
};

#endif