Merge remote-tracking branch 'refs/remotes/origin/master' into enet_wip_nothing_to_see_here

This commit is contained in:
Jérôme Leclercq 2017-05-29 18:01:44 +02:00
commit 7cce74afb7
4 changed files with 65 additions and 0 deletions

View File

@ -27,6 +27,9 @@ namespace Nz
void Clear();
inline void ForEach(const std::function<bool(const ParameterList& list, const String& name)>& callback);
inline void ForEach(const std::function<void(const ParameterList& list, const String& name)>& callback) const;
bool GetBooleanParameter(const String& name, bool* value) const;
bool GetColorParameter(const String& name, Color* value) const;
bool GetFloatParameter(const String& name, float* value) const;
@ -102,4 +105,6 @@ namespace Nz
std::ostream& operator<<(std::ostream& out, const Nz::ParameterList& parameterList);
#include <Nazara/Core/ParameterList.inl>
#endif // NAZARA_PARAMETERLIST_HPP

View File

@ -0,0 +1,42 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Core/ParameterList.hpp>
#include <Nazara/Core/Debug.hpp>
namespace Nz
{
/*!
* \brief Iterates over every value of the parameter list
*
* \param callback Callback function called with every parameter contained in the list, which can return true to remove the key (or false to keep it)
*
* \remark Changing the ParameterList while iterating on it may cause bugs, but querying data is safe.
*/
inline void ParameterList::ForEach(const std::function<bool(const ParameterList& list, const String& name)>& callback)
{
for (auto it = m_parameters.begin(); it != m_parameters.end();)
{
if (callback(*this, it->first))
it = m_parameters.erase(it);
else
++it;
}
}
/*!
* \brief Iterates over every value of the parameter list
*
* \param callback Callback function called with every parameter contained in the list
*
* \remark Changing the ParameterList while iterating on it may cause bugs, but querying data is safe.
*/
inline void ParameterList::ForEach(const std::function<void(const ParameterList& list, const String& name)>& callback) const
{
for (auto& pair : m_parameters)
callback(*this, pair.first);
}
}
#include <Nazara/Core/DebugOff.hpp>

View File

@ -101,6 +101,7 @@ namespace Nz
bool GetMetatable(int index) const;
unsigned int GetStackTop() const;
LuaType GetTable(int index = -2) const;
LuaType GetTableRaw(int index = -2) const;
inline UInt32 GetTimeLimit() const;
LuaType GetType(int index) const;
const char* GetTypeName(LuaType type) const;
@ -113,6 +114,7 @@ namespace Nz
bool IsValid(int index) const;
long long Length(int index) const;
std::size_t LengthRaw(int index) const;
void MoveTo(LuaInstance* instance, int n) const;
@ -161,6 +163,7 @@ namespace Nz
void SetMetatable(int index) const;
void SetMemoryLimit(std::size_t memoryLimit);
void SetTable(int index = -3) const;
void SetTableRaw(int index = -3) const;
void SetTimeLimit(UInt32 timeLimit);
bool ToBoolean(int index) const;

View File

@ -503,6 +503,11 @@ namespace Nz
return FromLuaType(lua_gettable(m_state, index));
}
LuaType LuaInstance::GetTableRaw(int index) const
{
return FromLuaType(lua_rawget(m_state, index));
}
LuaType LuaInstance::GetType(int index) const
{
return FromLuaType(lua_type(m_state, index));
@ -586,6 +591,11 @@ namespace Nz
return luaL_len(m_state, index);
}
std::size_t LuaInstance::LengthRaw(int index) const
{
return lua_rawlen(m_state, index);
}
void LuaInstance::MoveTo(LuaInstance* instance, int n) const
{
lua_xmove(m_state, instance->m_state, n);
@ -750,6 +760,11 @@ namespace Nz
lua_settable(m_state, index);
}
void LuaInstance::SetTableRaw(int index) const
{
lua_rawset(m_state, index);
}
void LuaInstance::SetTimeLimit(UInt32 timeLimit)
{
if (m_timeLimit != timeLimit)