Merge branch 'master' into vulkan

Former-commit-id: 8e5cf8f5c93203818a1939df269593f8556019f0
This commit is contained in:
Lynix
2016-04-23 22:57:14 +02:00
15 changed files with 252 additions and 127 deletions

View File

@@ -125,8 +125,12 @@ namespace Nz
template<typename T> int Push(T arg) const;
void PushBoolean(bool value) const;
void PushCFunction(LuaCFunction func, unsigned int upvalueCount = 0) const;
template<typename T> void PushField(const char* name, T&& arg, int tableIndex = -2) const;
template<typename T> void PushField(const String& name, T&& arg, int tableIndex = -2) const;
void PushFunction(LuaFunction func) const;
template<typename R, typename... Args, typename... DefArgs> void PushFunction(R(*func)(Args...), DefArgs&&... defArgs) const;
template<typename T> void PushGlobal(const char* name, T&& arg);
template<typename T> void PushGlobal(const String& name, T&& arg);
template<typename T> void PushInstance(const char* tname, T* instance) const;
template<typename T, typename... Args> void PushInstance(const char* tname, Args&&... args) const;
void PushInteger(long long value) const;
@@ -146,12 +150,8 @@ namespace Nz
void Remove(int index) const;
void Replace(int index) const;
template<typename T> void SetField(const char* name, T&& arg, int tableIndex = -2);
template<typename T> void SetField(const String& name, T&& arg, int tableIndex = -2);
void SetField(const char* name, int tableIndex = -2);
void SetField(const String& name, int tableIndex = -2);
template<typename T> void SetGlobal(const char* name, T&& arg);
template<typename T> void SetGlobal(const String& name, T&& arg);
void SetField(const char* name, int tableIndex = -2) const;
void SetField(const String& name, int tableIndex = -2) const;
void SetGlobal(const char* name);
void SetGlobal(const String& name);
void SetMetatable(const char* tname) const;

View File

@@ -144,6 +144,18 @@ namespace Nz
return 1;
}
template<typename T>
std::enable_if_t<std::is_arithmetic<T>::value || std::is_enum<T>::value, int> LuaImplReplyVal(const LuaInstance& instance, T val, TypeTag<T&>)
{
return LuaImplReplyVal(instance, val, TypeTag<T>());
}
template<typename T>
std::enable_if_t<std::is_arithmetic<T>::value || std::is_enum<T>::value, int> LuaImplReplyVal(const LuaInstance& instance, T val, TypeTag<const T&>)
{
return LuaImplReplyVal(instance, val, TypeTag<T>());
}
inline int LuaImplReplyVal(const LuaInstance& instance, std::string val, TypeTag<std::string>)
{
instance.PushString(val.c_str(), val.size());
@@ -541,6 +553,19 @@ namespace Nz
return LuaImplReplyVal(*this, std::move(arg), TypeTag<T>());
}
template<typename T>
void LuaInstance::PushField(const char* name, T&& arg, int tableIndex) const
{
Push<T>(std::forward<T>(arg));
SetField(name, tableIndex);
}
template<typename T>
void LuaInstance::PushField(const String& name, T&& arg, int tableIndex) const
{
PushField(name.GetConstBuffer(), std::forward<T>(arg), tableIndex);
}
template<typename R, typename... Args, typename... DefArgs>
void LuaInstance::PushFunction(R(*func)(Args...), DefArgs&&... defArgs) const
{
@@ -554,6 +579,19 @@ namespace Nz
});
}
template<typename T>
void LuaInstance::PushGlobal(const char* name, T&& arg)
{
Push<T>(std::forward<T>(arg));
SetGlobal(name);
}
template<typename T>
void LuaInstance::PushGlobal(const String& name, T&& arg)
{
PushGlobal(name.GetConstBuffer(), std::forward<T>(arg));
}
template<typename T>
void LuaInstance::PushInstance(const char* tname, T* instance) const
{
@@ -568,32 +606,6 @@ namespace Nz
PushInstance(tname, new T(std::forward<Args>(args)...));
}
template<typename T>
void LuaInstance::SetField(const char* name, T&& arg, int tableIndex)
{
Push<T>(std::forward<T>(arg));
SetField(name, tableIndex);
}
template<typename T>
void LuaInstance::SetField(const String& name, T&& arg, int tableIndex)
{
SetField(name.GetConstBuffer(), std::forward<T>(arg), tableIndex);
}
template<typename T>
void LuaInstance::SetGlobal(const char* name, T&& arg)
{
Push<T>(std::forward<T>(arg));
SetGlobal(name);
}
template<typename T>
void LuaInstance::SetGlobal(const String& name, T&& arg)
{
SetGlobal(name.GetConstBuffer(), std::forward<T>(arg));
}
template<typename T>
T LuaInstance::CheckBounds(int index, long long value) const
{

View File

@@ -89,7 +89,7 @@ namespace Nz
Font& operator=(Font&&) = delete;
static std::shared_ptr<AbstractAtlas> GetDefaultAtlas();
static Font* GetDefault();
static const FontRef& GetDefault();
static unsigned int GetDefaultGlyphBorder();
static unsigned int GetDefaultMinimumStepSize();