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:
parent
4766da1c53
commit
4a7ef7508f
@ -35,7 +35,7 @@ CMeasureScript::CMeasureScript(CMeterWindow* meterWindow, const WCHAR* name) : C
|
|||||||
m_HasGetStringFunction(false),
|
m_HasGetStringFunction(false),
|
||||||
m_ValueType(LUA_TNIL)
|
m_ValueType(LUA_TNIL)
|
||||||
{
|
{
|
||||||
LuaManager::Init();
|
LuaManager::Initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -45,7 +45,7 @@ CMeasureScript::CMeasureScript(CMeterWindow* meterWindow, const WCHAR* name) : C
|
|||||||
CMeasureScript::~CMeasureScript()
|
CMeasureScript::~CMeasureScript()
|
||||||
{
|
{
|
||||||
DeleteLuaScript();
|
DeleteLuaScript();
|
||||||
LuaManager::CleanUp();
|
LuaManager::Finalize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMeasureScript::DeleteLuaScript()
|
void CMeasureScript::DeleteLuaScript()
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
int LuaManager::c_RefCount = 0;
|
int LuaManager::c_RefCount = 0;
|
||||||
lua_State* LuaManager::c_State = 0;
|
lua_State* LuaManager::c_State = 0;
|
||||||
|
|
||||||
void LuaManager::Init()
|
void LuaManager::Initialize()
|
||||||
{
|
{
|
||||||
if (c_State == NULL)
|
if (c_State == NULL)
|
||||||
{
|
{
|
||||||
@ -51,7 +51,7 @@ void LuaManager::Init()
|
|||||||
++c_RefCount;
|
++c_RefCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LuaManager::CleanUp()
|
void LuaManager::Finalize()
|
||||||
{
|
{
|
||||||
if (c_RefCount > 0)
|
if (c_RefCount > 0)
|
||||||
{
|
{
|
||||||
@ -84,31 +84,6 @@ void LuaManager::ReportErrors(lua_State* L)
|
|||||||
Log(LOG_ERROR, str.c_str());
|
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)
|
void LuaManager::PushWide(lua_State* L, const WCHAR* str)
|
||||||
{
|
{
|
||||||
lua_pushstring(L, ConvertToAscii(str).c_str());
|
lua_pushstring(L, ConvertToAscii(str).c_str());
|
||||||
|
@ -25,13 +25,12 @@
|
|||||||
class LuaManager
|
class LuaManager
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static void Init();
|
static void Initialize();
|
||||||
static void CleanUp();
|
static void Finalize();
|
||||||
|
|
||||||
static lua_State* GetState() { return c_State; }
|
static lua_State* GetState() { return c_State; }
|
||||||
|
|
||||||
static void ReportErrors(lua_State* L);
|
static void ReportErrors(lua_State* L);
|
||||||
static void LuaLog(int nLevel, const char* format, ... );
|
|
||||||
|
|
||||||
static void PushWide(lua_State* L, const WCHAR* str);
|
static void PushWide(lua_State* L, const WCHAR* str);
|
||||||
static std::wstring ToWide(lua_State* L, int narg);
|
static std::wstring ToWide(lua_State* L, int narg);
|
||||||
|
@ -53,7 +53,7 @@ static int Global_Log(lua_State* L)
|
|||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
LuaManager::LuaLog(LOG_DEBUG, message.c_str());
|
Log(LOG_DEBUG, ConvertToWide(message.c_str()).c_str());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user