48 lines
956 B
C++
48 lines
956 B
C++
#pragma once
|
|
#include <map>
|
|
#include <set>
|
|
#include <vector>
|
|
#include <string>
|
|
|
|
typedef int (*luaFunction) (struct lua_State *L);
|
|
|
|
class LuaVM
|
|
{
|
|
public:
|
|
bool Init();
|
|
bool DeInit();
|
|
|
|
bool InitThread();
|
|
bool DeInitThread();
|
|
|
|
void BindLogOutputFunction( void (*fp)( const char* ) );
|
|
void Log( const char *szString );
|
|
void LogPrintf( const char *szString, ... );
|
|
|
|
bool LoadScript( const char* szFileName );
|
|
bool RunFile( const char* szFileName );
|
|
bool RunString( const char* szString );
|
|
bool RunFunction( const char* szFunctionName, ... );
|
|
bool RegisterFunction( const char* szFunctionName, luaFunction fp );
|
|
|
|
static LuaVM* Inst();
|
|
|
|
private:
|
|
LuaVM();
|
|
~LuaVM();
|
|
|
|
struct _LOG_FUNC* m_pLogFunc;
|
|
|
|
struct LUA_INFO * getLuaInfo();
|
|
|
|
std::vector< struct LUA_INFO * > m_vStateList;
|
|
std::map< std::string, luaFunction > m_mapFuncList;
|
|
std::set< std::string > m_setScriptList;
|
|
|
|
bool m_bInit;
|
|
};
|
|
|
|
inline LuaVM* LUA()
|
|
{
|
|
return LuaVM::Inst();
|
|
} |