mirror of
				https://github.com/chibicitiberiu/rainmeter-studio.git
				synced 2024-02-24 04:33:31 +00:00 
			
		
		
		
	Minor tweaks and cosmetics.
This commit is contained in:
		@@ -35,7 +35,7 @@ CMeasureScript::CMeasureScript(CMeterWindow* meterWindow, const WCHAR* name) : C
 | 
			
		||||
	m_HasGetStringFunction(false),
 | 
			
		||||
	m_ValueType(LUA_TNIL)
 | 
			
		||||
{
 | 
			
		||||
	LuaManager::Init();
 | 
			
		||||
	LuaManager::Initialize();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
@@ -45,7 +45,7 @@ CMeasureScript::CMeasureScript(CMeterWindow* meterWindow, const WCHAR* name) : C
 | 
			
		||||
CMeasureScript::~CMeasureScript()
 | 
			
		||||
{
 | 
			
		||||
	DeleteLuaScript();
 | 
			
		||||
	LuaManager::CleanUp();
 | 
			
		||||
	LuaManager::Finalize();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CMeasureScript::DeleteLuaScript()
 | 
			
		||||
 
 | 
			
		||||
@@ -23,7 +23,7 @@
 | 
			
		||||
int LuaManager::c_RefCount = 0;
 | 
			
		||||
lua_State* LuaManager::c_State = 0;
 | 
			
		||||
 | 
			
		||||
void LuaManager::Init()
 | 
			
		||||
void LuaManager::Initialize()
 | 
			
		||||
{
 | 
			
		||||
	if (c_State == NULL)
 | 
			
		||||
	{
 | 
			
		||||
@@ -51,7 +51,7 @@ void LuaManager::Init()
 | 
			
		||||
	++c_RefCount;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void LuaManager::CleanUp()
 | 
			
		||||
void LuaManager::Finalize()
 | 
			
		||||
{
 | 
			
		||||
	if (c_RefCount > 0)
 | 
			
		||||
	{
 | 
			
		||||
@@ -84,31 +84,6 @@ void LuaManager::ReportErrors(lua_State* L)
 | 
			
		||||
	Log(LOG_ERROR, str.c_str());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void LuaManager::LuaLog(int nLevel, const char* format, ... )
 | 
			
		||||
{
 | 
			
		||||
	char* buffer = new char[4096];
 | 
			
		||||
	va_list args;
 | 
			
		||||
	va_start( args, format );
 | 
			
		||||
 | 
			
		||||
	_invalid_parameter_handler oldHandler = _set_invalid_parameter_handler(RmNullCRTInvalidParameterHandler);
 | 
			
		||||
	_CrtSetReportMode(_CRT_ASSERT, 0);
 | 
			
		||||
 | 
			
		||||
	errno = 0;
 | 
			
		||||
	_vsnprintf_s( buffer, 4096, _TRUNCATE, format, args );
 | 
			
		||||
	if (errno != 0)
 | 
			
		||||
	{
 | 
			
		||||
		_snprintf_s(buffer, 4096, _TRUNCATE, "Script: LuaLog internal error: %s", format);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	_set_invalid_parameter_handler(oldHandler);
 | 
			
		||||
 | 
			
		||||
	std::wstring str = ConvertToWide(buffer);
 | 
			
		||||
	Log(nLevel, str.c_str());
 | 
			
		||||
	va_end(args);
 | 
			
		||||
 | 
			
		||||
	delete [] buffer;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void LuaManager::PushWide(lua_State* L, const WCHAR* str)
 | 
			
		||||
{
 | 
			
		||||
	lua_pushstring(L, ConvertToAscii(str).c_str());
 | 
			
		||||
 
 | 
			
		||||
@@ -25,13 +25,12 @@
 | 
			
		||||
class LuaManager
 | 
			
		||||
{
 | 
			
		||||
public:
 | 
			
		||||
	static void Init();
 | 
			
		||||
	static void CleanUp();
 | 
			
		||||
	static void Initialize();
 | 
			
		||||
	static void Finalize();
 | 
			
		||||
 | 
			
		||||
	static lua_State* GetState() { return c_State; }
 | 
			
		||||
 | 
			
		||||
	static void ReportErrors(lua_State* L);
 | 
			
		||||
	static void LuaLog(int nLevel, const char* format, ... );
 | 
			
		||||
 | 
			
		||||
	static void PushWide(lua_State* L, const WCHAR* str);
 | 
			
		||||
	static std::wstring ToWide(lua_State* L, int narg);
 | 
			
		||||
 
 | 
			
		||||
@@ -53,7 +53,7 @@ static int Global_Log(lua_State* L)
 | 
			
		||||
		lua_pop(L, 1);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	LuaManager::LuaLog(LOG_DEBUG, message.c_str());
 | 
			
		||||
	Log(LOG_DEBUG, ConvertToWide(message.c_str()).c_str());
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user