Merge remote-tracking branch 'refs/remotes/DigitalPulseSoftware/master'
Former-commit-id: 59eaf0f4535005c601d64f407acaac066f95002c
This commit is contained in:
commit
6b0c750e54
|
|
@ -35,7 +35,7 @@ namespace Ndk
|
||||||
|
|
||||||
std::size_t bufferSize = 0;
|
std::size_t bufferSize = 0;
|
||||||
const char* buffer = lua.CheckString(index, &bufferSize);
|
const char* buffer = lua.CheckString(index, &bufferSize);
|
||||||
NazaraAssert(buffer && bufferSize < sampleCount * sizeof(Nz::Int16), "Invalid buffer");
|
lua.ArgCheck(buffer && bufferSize < sampleCount * sizeof(Nz::Int16), index, "Invalid buffer");
|
||||||
|
|
||||||
lua.PushBoolean(instance->Create(format, sampleCount, sampleRate, reinterpret_cast<const Nz::Int16*>(buffer)));
|
lua.PushBoolean(instance->Create(format, sampleCount, sampleRate, reinterpret_cast<const Nz::Int16*>(buffer)));
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ namespace Ndk
|
||||||
clockClass.SetMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::Clock& clock) -> int {
|
clockClass.SetMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::Clock& clock) -> int {
|
||||||
Nz::StringStream stream("Clock(Elapsed: ");
|
Nz::StringStream stream("Clock(Elapsed: ");
|
||||||
stream << clock.GetSeconds();
|
stream << clock.GetSeconds();
|
||||||
stream << ", Paused: ";
|
stream << "s, Paused: ";
|
||||||
stream << clock.IsPaused();
|
stream << clock.IsPaused();
|
||||||
stream << ')';
|
stream << ')';
|
||||||
|
|
||||||
|
|
@ -162,8 +162,53 @@ namespace Ndk
|
||||||
|
|
||||||
directoryClass.Register(instance);
|
directoryClass.Register(instance);
|
||||||
|
|
||||||
|
/*********************************** Nz::Stream ***********************************/
|
||||||
|
Nz::LuaClass<Nz::Stream> streamClass("Stream");
|
||||||
|
|
||||||
|
streamClass.SetMethod("EnableTextMode", &Nz::Stream::EnableTextMode);
|
||||||
|
streamClass.SetMethod("Flush", &Nz::Stream::Flush);
|
||||||
|
streamClass.SetMethod("GetCursorPos", &Nz::Stream::GetCursorPos);
|
||||||
|
streamClass.SetMethod("GetDirectory", &Nz::Stream::GetDirectory);
|
||||||
|
streamClass.SetMethod("GetPath", &Nz::Stream::GetPath);
|
||||||
|
streamClass.SetMethod("GetOpenMode", &Nz::Stream::GetOpenMode);
|
||||||
|
streamClass.SetMethod("GetStreamOptions", &Nz::Stream::GetStreamOptions);
|
||||||
|
streamClass.SetMethod("GetSize", &Nz::Stream::GetSize);
|
||||||
|
streamClass.SetMethod("ReadLine", &Nz::Stream::ReadLine, 0U);
|
||||||
|
streamClass.SetMethod("IsReadable", &Nz::Stream::IsReadable);
|
||||||
|
streamClass.SetMethod("IsSequential", &Nz::Stream::IsSequential);
|
||||||
|
streamClass.SetMethod("IsTextModeEnabled", &Nz::Stream::IsTextModeEnabled);
|
||||||
|
streamClass.SetMethod("IsWritable", &Nz::Stream::IsWritable);
|
||||||
|
streamClass.SetMethod("SetCursorPos", &Nz::Stream::SetCursorPos);
|
||||||
|
|
||||||
|
streamClass.SetMethod("Read", [] (Nz::LuaInstance& lua, Nz::Stream& stream) -> int {
|
||||||
|
int length = lua.CheckInteger(1);
|
||||||
|
lua.ArgCheck(length > 0, 1, "length must be positive");
|
||||||
|
|
||||||
|
std::unique_ptr<char[]> buffer(new char[length]);
|
||||||
|
std::size_t readLength = stream.Read(buffer.get(), length);
|
||||||
|
|
||||||
|
lua.PushString(Nz::String(buffer.get(), readLength));
|
||||||
|
return 1;
|
||||||
|
});
|
||||||
|
|
||||||
|
streamClass.SetMethod("Write", [] (Nz::LuaInstance& lua, Nz::Stream& stream) -> int {
|
||||||
|
int index = 1;
|
||||||
|
|
||||||
|
std::size_t bufferSize = 0;
|
||||||
|
const char* buffer = lua.CheckString(index, &bufferSize);
|
||||||
|
|
||||||
|
if (stream.IsTextModeEnabled())
|
||||||
|
lua.Push(stream.Write(Nz::String(buffer, bufferSize)));
|
||||||
|
else
|
||||||
|
lua.Push(stream.Write(buffer, bufferSize));
|
||||||
|
return 1;
|
||||||
|
});
|
||||||
|
|
||||||
|
streamClass.Register(instance);
|
||||||
|
|
||||||
/*********************************** Nz::File ***********************************/
|
/*********************************** Nz::File ***********************************/
|
||||||
Nz::LuaClass<Nz::File> fileClass("File");
|
Nz::LuaClass<Nz::File> fileClass("File");
|
||||||
|
fileClass.Inherit(streamClass);
|
||||||
|
|
||||||
// Constructeur
|
// Constructeur
|
||||||
fileClass.SetConstructor([](Nz::LuaInstance& lua) -> Nz::File* {
|
fileClass.SetConstructor([](Nz::LuaInstance& lua) -> Nz::File* {
|
||||||
|
|
@ -288,26 +333,6 @@ namespace Ndk
|
||||||
return 0;
|
return 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Nz::File::Read (Manual)
|
|
||||||
fileClass.SetMethod("Read", [] (Nz::LuaInstance& lua, Nz::File& file) -> int {
|
|
||||||
int length = lua.CheckInteger(1);
|
|
||||||
lua.ArgCheck(length > 0, 1, "length must be positive");
|
|
||||||
|
|
||||||
std::unique_ptr<char[]> buffer(new char[length]);
|
|
||||||
std::size_t readLength = file.Read(buffer.get(), length);
|
|
||||||
|
|
||||||
lua.PushString(Nz::String(buffer.get(), readLength));
|
|
||||||
return 1;
|
|
||||||
});
|
|
||||||
|
|
||||||
// Nz::File::ReadLine (Manual)
|
|
||||||
fileClass.SetMethod("ReadLine", [] (Nz::LuaInstance& lua, Nz::File& file) -> int {
|
|
||||||
int length = lua.CheckInteger(1, 0);
|
|
||||||
lua.PushString(file.ReadLine(length));
|
|
||||||
return 1;
|
|
||||||
});
|
|
||||||
|
|
||||||
// Nz::File::__tostring (Manual)
|
|
||||||
fileClass.SetMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::File& file) -> int {
|
fileClass.SetMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::File& file) -> int {
|
||||||
Nz::StringStream stream("File(");
|
Nz::StringStream stream("File(");
|
||||||
if (file.IsOpen())
|
if (file.IsOpen())
|
||||||
|
|
@ -319,7 +344,6 @@ namespace Ndk
|
||||||
return 1;
|
return 1;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
fileClass.Register(instance);
|
fileClass.Register(instance);
|
||||||
|
|
||||||
// Énumérations de la classe Nz::File
|
// Énumérations de la classe Nz::File
|
||||||
|
|
|
||||||
|
|
@ -405,6 +405,7 @@ namespace Nz
|
||||||
if (it != info->instanceGetters.end())
|
if (it != info->instanceGetters.end())
|
||||||
instance = it->second(lua);
|
instance = it->second(lua);
|
||||||
}
|
}
|
||||||
|
lua.Pop(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
lua.Remove(1); //< Remove the instance from the Lua stack
|
lua.Remove(1); //< Remove the instance from the Lua stack
|
||||||
|
|
|
||||||
|
|
@ -45,18 +45,14 @@ namespace Nz
|
||||||
std::enable_if_t<std::is_enum<T>::value, unsigned int> LuaImplQueryArg(const LuaInstance& instance, int index, T* arg, TypeTag<T>)
|
std::enable_if_t<std::is_enum<T>::value, unsigned int> LuaImplQueryArg(const LuaInstance& instance, int index, T* arg, TypeTag<T>)
|
||||||
{
|
{
|
||||||
using UnderlyingT = std::underlying_type_t<T>;
|
using UnderlyingT = std::underlying_type_t<T>;
|
||||||
*arg = static_cast<T>(LuaImplQueryArg(instance, index, reinterpret_cast<UnderlyingT*>(arg), TypeTag<UnderlyingT>()));
|
return LuaImplQueryArg(instance, index, reinterpret_cast<UnderlyingT*>(arg), TypeTag<UnderlyingT>());
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
std::enable_if_t<std::is_enum<T>::value, unsigned int> LuaImplQueryArg(const LuaInstance& instance, int index, T* arg, T defValue, TypeTag<T>)
|
std::enable_if_t<std::is_enum<T>::value, unsigned int> LuaImplQueryArg(const LuaInstance& instance, int index, T* arg, T defValue, TypeTag<T>)
|
||||||
{
|
{
|
||||||
using UnderlyingT = std::underlying_type_t<T>;
|
using UnderlyingT = std::underlying_type_t<T>;
|
||||||
*arg = static_cast<T>(LuaImplQueryArg(instance, index, reinterpret_cast<UnderlyingT*>(arg), static_cast<UnderlyingT>(defValue), TypeTag<UnderlyingT>()));
|
return LuaImplQueryArg(instance, index, reinterpret_cast<UnderlyingT*>(arg), static_cast<UnderlyingT>(defValue), TypeTag<UnderlyingT>());
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
|
@ -98,7 +94,6 @@ namespace Nz
|
||||||
std::enable_if_t<std::is_unsigned<T>::value, unsigned int> LuaImplQueryArg(const LuaInstance& instance, int index, T* arg, T defValue, TypeTag<T>)
|
std::enable_if_t<std::is_unsigned<T>::value, unsigned int> LuaImplQueryArg(const LuaInstance& instance, int index, T* arg, T defValue, TypeTag<T>)
|
||||||
{
|
{
|
||||||
using SignedT = std::make_signed_t<T>;
|
using SignedT = std::make_signed_t<T>;
|
||||||
|
|
||||||
return LuaImplQueryArg(instance, index, reinterpret_cast<SignedT*>(arg), static_cast<SignedT>(defValue), TypeTag<SignedT>());
|
return LuaImplQueryArg(instance, index, reinterpret_cast<SignedT*>(arg), static_cast<SignedT>(defValue), TypeTag<SignedT>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -149,7 +144,6 @@ namespace Nz
|
||||||
std::enable_if_t<std::is_enum<T>::value, int> LuaImplReplyVal(const LuaInstance& instance, T val, TypeTag<T>)
|
std::enable_if_t<std::is_enum<T>::value, int> LuaImplReplyVal(const LuaInstance& instance, T val, TypeTag<T>)
|
||||||
{
|
{
|
||||||
using EnumT = typename std::underlying_type<T>::type;
|
using EnumT = typename std::underlying_type<T>::type;
|
||||||
|
|
||||||
return LuaImplReplyVal(instance, static_cast<EnumT>(val), TypeTag<EnumT>());
|
return LuaImplReplyVal(instance, static_cast<EnumT>(val), TypeTag<EnumT>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue