Lua/LuaInstance: Improve code
Former-commit-id: a93c9c2db6b0bca2fa236cc2d9c6be8b0ff15211 [formerly 986c24bc675da874d11ad85cd5026dfafd923dda] [formerly b071ccaef50f97de0fc29060b74e8fb55e4eb566 [formerly 82021bb41c9dd57c9244fd4fd8efea694d51f7d4]] Former-commit-id: 5acb7d0fe7365613dfb4edf02f955d5a829ec831 [formerly cd88f46679a1bec5682d6ae2c4aed5f504ec49e2] Former-commit-id: a6fac707a49d379a90327879cee0fc2beddd6efe
This commit is contained in:
parent
ffe938d422
commit
c5ece59597
|
|
@ -92,16 +92,16 @@ namespace Nz
|
|||
LuaType GetField(const String& fieldName, int tableIndex = -1) const;
|
||||
LuaType GetGlobal(const char* name) const;
|
||||
LuaType GetGlobal(const String& name) const;
|
||||
lua_State* GetInternalState() const;
|
||||
String GetLastError() const;
|
||||
UInt32 GetMemoryLimit() const;
|
||||
UInt32 GetMemoryUsage() const;
|
||||
inline lua_State* GetInternalState() const;
|
||||
inline String GetLastError() const;
|
||||
inline std::size_t GetMemoryLimit() const;
|
||||
inline std::size_t GetMemoryUsage() const;
|
||||
LuaType GetMetatable(const char* tname) const;
|
||||
LuaType GetMetatable(const String& tname) const;
|
||||
bool GetMetatable(int index) const;
|
||||
unsigned int GetStackTop() const;
|
||||
LuaType GetTable(int index = -2) const;
|
||||
UInt32 GetTimeLimit() const;
|
||||
inline UInt32 GetTimeLimit() const;
|
||||
LuaType GetType(int index) const;
|
||||
const char* GetTypeName(LuaType type) const;
|
||||
|
||||
|
|
@ -144,7 +144,7 @@ namespace Nz
|
|||
void PushString(const char* str) const;
|
||||
void PushString(const char* str, std::size_t size) const;
|
||||
void PushString(const String& str) const;
|
||||
void PushTable(unsigned int sequenceElementCount = 0, unsigned int arrayElementCount = 0) const;
|
||||
void PushTable(std::size_t sequenceElementCount = 0, std::size_t arrayElementCount = 0) const;
|
||||
void* PushUserdata(std::size_t size) const;
|
||||
void PushValue(int index) const;
|
||||
|
||||
|
|
|
|||
|
|
@ -25,6 +25,31 @@ namespace Nz
|
|||
instance.m_state = nullptr;
|
||||
}
|
||||
|
||||
inline lua_State* LuaInstance::GetInternalState() const
|
||||
{
|
||||
return m_state;
|
||||
}
|
||||
|
||||
inline String LuaInstance::GetLastError() const
|
||||
{
|
||||
return m_lastError;
|
||||
}
|
||||
|
||||
inline std::size_t LuaInstance::GetMemoryLimit() const
|
||||
{
|
||||
return m_memoryLimit;
|
||||
}
|
||||
|
||||
inline std::size_t LuaInstance::GetMemoryUsage() const
|
||||
{
|
||||
return m_memoryUsage;
|
||||
}
|
||||
|
||||
inline UInt32 LuaInstance::GetTimeLimit() const
|
||||
{
|
||||
return m_timeLimit;
|
||||
}
|
||||
|
||||
inline LuaInstance& LuaInstance::operator=(LuaInstance&& instance) noexcept
|
||||
{
|
||||
m_clock = std::move(m_clock);
|
||||
|
|
|
|||
|
|
@ -464,26 +464,6 @@ namespace Nz
|
|||
return FromLuaType(lua_getglobal(m_state, name.GetConstBuffer()));
|
||||
}
|
||||
|
||||
lua_State* LuaInstance::GetInternalState() const
|
||||
{
|
||||
return m_state;
|
||||
}
|
||||
|
||||
String LuaInstance::GetLastError() const
|
||||
{
|
||||
return m_lastError;
|
||||
}
|
||||
|
||||
UInt32 LuaInstance::GetMemoryLimit() const
|
||||
{
|
||||
return m_memoryLimit;
|
||||
}
|
||||
|
||||
UInt32 LuaInstance::GetMemoryUsage() const
|
||||
{
|
||||
return m_memoryUsage;
|
||||
}
|
||||
|
||||
LuaType LuaInstance::GetMetatable(const char* tname) const
|
||||
{
|
||||
return FromLuaType(luaL_getmetatable(m_state, tname));
|
||||
|
|
@ -501,7 +481,7 @@ namespace Nz
|
|||
|
||||
unsigned int LuaInstance::GetStackTop() const
|
||||
{
|
||||
return lua_gettop(m_state);
|
||||
return static_cast<int>(lua_gettop(m_state));
|
||||
}
|
||||
|
||||
LuaType LuaInstance::GetTable(int index) const
|
||||
|
|
@ -509,11 +489,6 @@ namespace Nz
|
|||
return FromLuaType(lua_gettable(m_state, index));
|
||||
}
|
||||
|
||||
UInt32 LuaInstance::GetTimeLimit() const
|
||||
{
|
||||
return m_timeLimit;
|
||||
}
|
||||
|
||||
LuaType LuaInstance::GetType(int index) const
|
||||
{
|
||||
return FromLuaType(lua_type(m_state, index));
|
||||
|
|
@ -690,9 +665,10 @@ namespace Nz
|
|||
lua_pushlstring(m_state, str.GetConstBuffer(), str.GetSize());
|
||||
}
|
||||
|
||||
void LuaInstance::PushTable(unsigned int sequenceElementCount, unsigned int arrayElementCount) const
|
||||
void LuaInstance::PushTable(std::size_t sequenceElementCount, std::size_t arrayElementCount) const
|
||||
{
|
||||
lua_createtable(m_state, sequenceElementCount, arrayElementCount);
|
||||
constexpr std::size_t maxInt = std::numeric_limits<int>::max();
|
||||
lua_createtable(m_state, static_cast<int>(std::min(sequenceElementCount, maxInt)), static_cast<int>(std::min(arrayElementCount, maxInt)));
|
||||
}
|
||||
|
||||
void* LuaInstance::PushUserdata(std::size_t size) const
|
||||
|
|
|
|||
Loading…
Reference in New Issue