Add love.system.getMemorySize

This commit is contained in:
Lu
2025-09-15 12:06:30 -04:00
parent 5903ad8901
commit afa9f711a8
6 changed files with 25 additions and 0 deletions
+1
View File
@@ -81,6 +81,7 @@ Released: N/A
* Added love.sensorupdated callback.
* Added love.joysticksensorupdated callback.
* Added variant for enet peer:send and host:broadcast which accepts a pointer (light userdata) and a size.
* Added love.system.getMemorySize.
* Changed the default font from Vera size 12 to Noto Sans size 13.
* Changed TrueType and OpenType font handling to have improved kerning and character combining support.
+5
View File
@@ -63,6 +63,11 @@ public:
**/
virtual int getProcessorCount() const = 0;
/**
* Gets the amount of RAM configured in the system in MiB.
**/
virtual int getMemorySize() const = 0;
/**
* Replaces the contents of the system's text clipboard with a string.
* @param text The clipboard text to set.
+5
View File
@@ -45,6 +45,11 @@ int System::getProcessorCount() const
return SDL_GetNumLogicalCPUCores();
}
int System::getMemorySize() const
{
return SDL_GetSystemRAM();
}
bool System::isWindowOpen() const
{
auto window = Module::getInstance<window::Window>(M_WINDOW);
+1
View File
@@ -43,6 +43,7 @@ public:
virtual ~System() {}
int getProcessorCount() const override;
int getMemorySize() const override;
void setClipboardText(const std::string &text) const override;
std::string getClipboardText() const override;
+7
View File
@@ -41,6 +41,12 @@ int w_getProcessorCount(lua_State *L)
return 1;
}
int w_getMemorySize(lua_State *L)
{
lua_pushinteger(L, instance()->getMemorySize());
return 1;
}
int w_setClipboardText(lua_State *L)
{
const char *text = luaL_checkstring(L, 1);
@@ -121,6 +127,7 @@ static const luaL_Reg functions[] =
{
{ "getOS", w_getOS },
{ "getProcessorCount", w_getProcessorCount },
{ "getMemorySize", w_getMemorySize },
{ "setClipboardText", w_setClipboardText },
{ "getClipboardText", w_getClipboardText },
{ "getPowerInfo", w_getPowerInfo },
+6
View File
@@ -59,6 +59,12 @@ love.test.system.getProcessorCount = function(test)
end
-- love.system.getMemorySize
love.test.system.getMemorySize = function(test)
test:assertNotNil(love.system.getMemorySize())
end
-- love.system.hasBackgroundMusic
love.test.system.hasBackgroundMusic = function(test)
test:assertNotNil(love.system.hasBackgroundMusic())