summaryrefslogtreecommitdiff
path: root/tests/tolua/test1.cpp
blob: 4ee26ff71ab2e4a17fa0edb3d4b5cffec61b2d57 (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
#include "Logger.hpp"
#include "LuaVM.hpp"
#include "ModuleLoader.hpp"
#include "Base.hpp"

#include <stdexcept>
#include <vector>
#include <iostream>

using namespace std;

int main( int /* argc */, char *argv[] )
{
	try {
		Logger::instance( ).openConsoleLog( logDEBUG );

		LuaVM luaVm;

		vector<string> modules;
#ifndef _WIN32
		modules.push_back( "./libtest1/mod_test.so" );
#else
		modules.push_back( ".\\libtest1\\mod_test.dll" );
#endif		
		ModuleLoader<Base> loader( modules, CLOSE_DEFERRED, (void *)&luaVm );

		luaVm.loadSource( argv[1] );
		luaVm.executeMain( );

	} catch( exception &e ) {
		LOG( logFATAL ) << "ERROR: " << e.what( );
		return 1;
	} catch( ... ) {
		LOG( logFATAL ) << "ERROR: unknown exception!";
		return 1;
	}
		
	return 0;
}