Files
SourMesen ad0a1b9849 Lua: Misc. fixes & improvements (#250)
-Fixed getAccessCounters documentation (swapped param order)
-Fixed file watcher not being disabled properly when closing the script window, causing the script to run if changed on the disk, even if the script window is closed
-Prevent file watcher from triggering from writes done by the script window itself (which caused the script to be reloaded 2 or 3 times in a row)
-Fixed UI freezes when using emu.log() on a large table
-Fixed crash when 100k character limit (in the last 500 lines) for script log was reached (out of bounds read/write)
-Added "fps" value to "getState"
-Slightly improved getAccessCounters/getCdlData performance
-Added a new drawPixels API to improve performance when a script needs to draw a lot of individual pixels
2026-08-10 22:42:34 +09:00

46 lines
931 B
C++

#pragma once
#include "pch.h"
#include "Lua/lua.hpp"
template<typename T>
struct Nullable
{
bool HasValue = false;
T Value = {};
};
class LuaCallHelper
{
private:
int _stackSize = 0;
int _paramCount = 0;
int _returnCount = 0;
lua_State* _lua;
public:
LuaCallHelper(lua_State* lua);
void ForceParamCount(int paramCount);
bool CheckParamCount(int minParamCount = -1);
bool CheckSpecificParamCount(int count, int minParamCount = -1);
void SkipParam() { _paramCount++; }
double ReadDouble();
bool ReadBool(bool defaultValue = false);
uint32_t ReadInteger(uint32_t defaultValue = 0);
uint32_t ReadIntegerFromIndex(int32_t index);
string ReadString();
int GetReference();
Nullable<bool> ReadOptionalBool();
Nullable<int32_t> ReadOptionalInteger();
void Return(bool value);
void Return(int value);
void Return(uint32_t value);
void Return(uint64_t value);
void Return(string value);
int ReturnCount();
};