Make Rainmeter a singleton class

This change is part of making the Libray project more testable. The old g_Rainmeter global pointer has been replaced with a GetRainmeter() function to guarantee that the object exists in some state.
This commit is contained in:
Birunthan Mohanathas
2013-06-13 17:20:27 +03:00
parent a80c905be9
commit 04090b232a
26 changed files with 272 additions and 314 deletions

View File

@ -22,8 +22,6 @@
#include "../../MeterWindow.h"
#include "../../MeterString.h"
extern Rainmeter* g_Rainmeter;
#define DECLARE_SELF(L) \
void* selfData = lua_touserdata(L, 1); \
if (!selfData) return 0; \
@ -40,7 +38,7 @@ static int Bang(lua_State* L)
if (top == 2) // 1 argument
{
parser.ReplaceVariables(bang);
g_Rainmeter->ExecuteCommand(bang.c_str(), self);
GetRainmeter().ExecuteCommand(bang.c_str(), self);
}
else
{
@ -56,7 +54,7 @@ static int Bang(lua_State* L)
args.push_back(tmpSz);
}
g_Rainmeter->ExecuteBang(bangSz, args, self);
GetRainmeter().ExecuteBang(bangSz, args, self);
}
}