Merge remote-tracking branch 'refs/remotes/DigitalPulseSoftware/master'
Former-commit-id: e13918db0bc7a95763cffd3bb9360faa7662c1dc
This commit is contained in:
commit
7dec6e10a6
|
|
@ -0,0 +1,33 @@
|
|||
// Copyright (C) 2015 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NDK_LUAINTERFACE_HPP
|
||||
#define NDK_LUAINTERFACE_HPP
|
||||
|
||||
#include <NDK/Prerequesites.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class LuaInstance;
|
||||
}
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
class NDK_API LuaAPI
|
||||
{
|
||||
public:
|
||||
LuaAPI() = delete;
|
||||
~LuaAPI() = delete;
|
||||
|
||||
static void Register_Audio(Nz::LuaInstance& instance);
|
||||
static void Register_Core(Nz::LuaInstance& instance);
|
||||
static void Register_Math(Nz::LuaInstance& instance);
|
||||
};
|
||||
}
|
||||
|
||||
#include <NDK/LuaAPI.inl>
|
||||
|
||||
#endif // NDK_LUAINTERFACE_HPP
|
||||
|
|
@ -0,0 +1,68 @@
|
|||
// Copyright (C) 2015 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||
|
||||
#include <Nazara/Audio/SoundBuffer.hpp>
|
||||
#include <Nazara/Lua/LuaInstance.hpp>
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
#include <algorithm>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, SoundBufferParams* params, TypeTag<SoundBufferParams>)
|
||||
{
|
||||
instance.CheckType(index, Nz::LuaType_Table);
|
||||
|
||||
params->forceMono = instance.CheckField<bool>("ForceMono", params->forceMono);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline unsigned int LuaImplQueryArg(const LuaInstance& lua, int index, Vector3d* vec, TypeTag<Vector3d>)
|
||||
{
|
||||
switch (lua.GetType(index))
|
||||
{
|
||||
case Nz::LuaType_Number:
|
||||
if (index < 0 && index > -3)
|
||||
lua.Error("Vector3 expected, three numbers are required to convert it");
|
||||
|
||||
vec->Set(lua.CheckNumber(index), lua.CheckNumber(index + 1), lua.CheckNumber(index + 2));
|
||||
return 3;
|
||||
|
||||
case Nz::LuaType_Table:
|
||||
vec->Set(lua.CheckField<double>("x", index), lua.CheckField<double>("y", index), lua.CheckField<double>("z", index));
|
||||
return 3;
|
||||
|
||||
default:
|
||||
vec->Set(*(*static_cast<Vector3d**>(lua.CheckUserdata(index, "Vector3"))));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
inline unsigned int LuaImplQueryArg(const LuaInstance& lua, int index, Vector3f* vec, TypeTag<Vector3f>)
|
||||
{
|
||||
Vector3d vecDouble;
|
||||
unsigned int ret = LuaImplQueryArg(lua, index, &vecDouble, TypeTag<Vector3d>());
|
||||
|
||||
vec->Set(vecDouble);
|
||||
return ret;
|
||||
}
|
||||
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, const SoundBuffer* val, TypeTag<const SoundBuffer*>)
|
||||
{
|
||||
instance.PushInstance<SoundBufferConstRef>("SoundBuffer", val);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, Vector3d val, TypeTag<Vector3d>)
|
||||
{
|
||||
instance.PushInstance<Vector3d>("Vector3", val);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, Vector3f val, TypeTag<Vector3f>)
|
||||
{
|
||||
instance.PushInstance<Vector3d>("Vector3", val);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,125 @@
|
|||
// This file was automatically generated on 26 May 2014 at 01:05:31
|
||||
|
||||
#include <NDK/LuaAPI.hpp>
|
||||
#include <Nazara/Audio.hpp>
|
||||
#include <Nazara/Lua/LuaClass.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
void LuaAPI::Register_Audio(Nz::LuaInstance& instance)
|
||||
{
|
||||
/*********************************** Nz::SoundBuffer **********************************/
|
||||
Nz::LuaClass<Nz::SoundBufferRef> soundBuffer("SoundBuffer");
|
||||
|
||||
soundBuffer.SetConstructor([] (Nz::LuaInstance& lua) -> Nz::SoundBufferRef* {
|
||||
return new Nz::SoundBufferRef(new Nz::SoundBuffer);
|
||||
});
|
||||
|
||||
soundBuffer.SetMethod("Destroy", &Nz::SoundBuffer::Destroy);
|
||||
soundBuffer.SetMethod("GetDuration", &Nz::SoundBuffer::GetDuration);
|
||||
soundBuffer.SetMethod("GetFormat", &Nz::SoundBuffer::GetFormat);
|
||||
soundBuffer.SetMethod("GetSampleCount", &Nz::SoundBuffer::GetSampleCount);
|
||||
soundBuffer.SetMethod("GetSampleRate", &Nz::SoundBuffer::GetSampleRate);
|
||||
soundBuffer.SetMethod("IsValid", &Nz::SoundBuffer::IsValid);
|
||||
soundBuffer.SetMethod("LoadFromFile", &Nz::SoundBuffer::LoadFromFile, Nz::SoundBufferParams());
|
||||
|
||||
soundBuffer.SetStaticMethod("IsFormatSupported", &Nz::SoundBuffer::IsFormatSupported);
|
||||
|
||||
// Manual
|
||||
soundBuffer.SetMethod("Create", [] (Nz::LuaInstance& lua, Nz::SoundBufferRef& instance) -> int
|
||||
{
|
||||
int index = 1;
|
||||
Nz::AudioFormat format = lua.Check<Nz::AudioFormat>(&index);
|
||||
unsigned int sampleCount = lua.Check<unsigned int>(&index);
|
||||
unsigned int sampleRate = lua.Check<unsigned int>(&index);
|
||||
|
||||
std::size_t bufferSize = 0;
|
||||
const char* buffer = lua.CheckString(index, &bufferSize);
|
||||
NazaraAssert(buffer && bufferSize < sampleCount * sizeof(Nz::Int16), "Invalid buffer");
|
||||
|
||||
lua.PushBoolean(instance->Create(format, sampleCount, sampleRate, reinterpret_cast<const Nz::Int16*>(buffer)));
|
||||
return 1;
|
||||
});
|
||||
|
||||
soundBuffer.SetMethod("GetSamples", [] (Nz::LuaInstance& lua, Nz::SoundBufferRef& instance) -> int
|
||||
{
|
||||
lua.PushString(reinterpret_cast<const char*>(instance->GetSamples()), instance->GetSampleCount() * sizeof(Nz::Int16));
|
||||
return 1;
|
||||
});
|
||||
|
||||
soundBuffer.SetMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::SoundBufferRef& soundBuffer) -> int {
|
||||
Nz::StringStream stream("SoundBuffer(");
|
||||
if (soundBuffer->IsValid())
|
||||
{
|
||||
Nz::String filePath = soundBuffer->GetFilePath();
|
||||
if (!filePath.IsEmpty())
|
||||
stream << "File: " << filePath << ", ";
|
||||
|
||||
stream << "Duration: " << soundBuffer->GetDuration() / 1000.f << "s";
|
||||
}
|
||||
stream << ')';
|
||||
|
||||
lua.PushString(stream);
|
||||
return 1;
|
||||
});
|
||||
|
||||
soundBuffer.Register(instance);
|
||||
|
||||
/*********************************** Nz::SoundEmitter **********************************/
|
||||
Nz::LuaClass<Nz::SoundEmitter> soundEmitter("SoundEmitter");
|
||||
|
||||
soundEmitter.SetMethod("EnableLooping", &Nz::SoundEmitter::EnableLooping);
|
||||
soundEmitter.SetMethod("EnableSpatialization", &Nz::SoundEmitter::EnableSpatialization);
|
||||
soundEmitter.SetMethod("GetAttenuation", &Nz::SoundEmitter::GetAttenuation);
|
||||
soundEmitter.SetMethod("GetDuration", &Nz::SoundEmitter::GetDuration);
|
||||
soundEmitter.SetMethod("GetMinDistance", &Nz::SoundEmitter::GetMinDistance);
|
||||
soundEmitter.SetMethod("GetPitch", &Nz::SoundEmitter::GetPitch);
|
||||
soundEmitter.SetMethod("GetPlayingOffset", &Nz::SoundEmitter::GetPlayingOffset);
|
||||
soundEmitter.SetMethod("GetPosition", &Nz::Sound::GetPosition);
|
||||
soundEmitter.SetMethod("GetStatus", &Nz::SoundEmitter::GetStatus);
|
||||
soundEmitter.SetMethod("GetVelocity", &Nz::Sound::GetVelocity);
|
||||
soundEmitter.SetMethod("GetVolume", &Nz::SoundEmitter::GetVolume);
|
||||
soundEmitter.SetMethod("IsLooping", &Nz::SoundEmitter::IsLooping);
|
||||
soundEmitter.SetMethod("IsSpatialized", &Nz::SoundEmitter::IsSpatialized);
|
||||
soundEmitter.SetMethod("Pause", &Nz::SoundEmitter::Pause);
|
||||
soundEmitter.SetMethod("Play", &Nz::SoundEmitter::Play);
|
||||
soundEmitter.SetMethod("SetAttenuation", &Nz::SoundEmitter::SetAttenuation);
|
||||
soundEmitter.SetMethod("SetMinDistance", &Nz::SoundEmitter::SetMinDistance);
|
||||
soundEmitter.SetMethod("SetPitch", &Nz::SoundEmitter::SetPitch);
|
||||
soundEmitter.SetMethod("SetPosition", (void(Nz::SoundEmitter::*)(const Nz::Vector3f&)) &Nz::SoundEmitter::SetPosition);
|
||||
soundEmitter.SetMethod("SetVelocity", (void(Nz::SoundEmitter::*)(const Nz::Vector3f&)) &Nz::SoundEmitter::SetVelocity);
|
||||
soundEmitter.SetMethod("SetVolume", &Nz::SoundEmitter::SetVolume);
|
||||
soundEmitter.SetMethod("Stop", &Nz::SoundEmitter::Stop);
|
||||
|
||||
soundEmitter.Register(instance);
|
||||
|
||||
/*********************************** Nz::Sound **********************************/
|
||||
Nz::LuaClass<Nz::Sound> soundClass("Sound");
|
||||
soundClass.Inherit(soundEmitter);
|
||||
|
||||
// Constructeur
|
||||
soundClass.SetConstructor([] (Nz::LuaInstance& lua) -> Nz::Sound* {
|
||||
return new Nz::Sound;
|
||||
});
|
||||
|
||||
soundClass.SetMethod("GetBuffer", &Nz::Sound::GetBuffer);
|
||||
soundClass.SetMethod("IsPlayable", &Nz::Sound::IsPlayable);
|
||||
soundClass.SetMethod("IsPlaying", &Nz::Sound::IsPlaying);
|
||||
soundClass.SetMethod("LoadFromFile", &Nz::Sound::LoadFromFile, Nz::SoundBufferParams());
|
||||
soundClass.SetMethod("SetPlayingOffset", &Nz::Sound::SetPlayingOffset);
|
||||
|
||||
// Nz::Clock::__tostring (Manual)
|
||||
soundClass.SetMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::Sound& sound) -> int {
|
||||
Nz::StringStream stream("Sound(");
|
||||
if (const Nz::SoundBuffer* buffer = sound.GetBuffer())
|
||||
stream << buffer;
|
||||
|
||||
stream << ')';
|
||||
|
||||
lua.PushString(stream);
|
||||
return 1;
|
||||
});
|
||||
|
||||
soundClass.Register(instance);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,280 @@
|
|||
// This file was automatically generated on 26 May 2014 at 01:05:31
|
||||
|
||||
#include <NDK/LuaAPI.hpp>
|
||||
#include <Nazara/Core.hpp>
|
||||
#include <Nazara/Lua/LuaClass.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
void LuaAPI::Register_Core(Nz::LuaInstance& instance)
|
||||
{
|
||||
/*********************************** Nz::Clock **********************************/
|
||||
Nz::LuaClass<Nz::Clock> clockClass("Clock");
|
||||
|
||||
// Constructeur
|
||||
clockClass.SetConstructor([](Nz::LuaInstance& lua) -> Nz::Clock* {
|
||||
int index = 1;
|
||||
return new Nz::Clock(lua.Check<Nz::Int64>(&index, 0), lua.Check<bool>(&index, false));
|
||||
});
|
||||
|
||||
clockClass.SetMethod("GetMicroseconds", &Nz::Clock::GetMicroseconds);
|
||||
clockClass.SetMethod("GetMilliseconds", &Nz::Clock::GetMilliseconds);
|
||||
clockClass.SetMethod("GetSeconds", &Nz::Clock::GetSeconds);
|
||||
clockClass.SetMethod("IsPaused", &Nz::Clock::IsPaused);
|
||||
clockClass.SetMethod("Pause", &Nz::Clock::Pause);
|
||||
clockClass.SetMethod("Restart", &Nz::Clock::Restart);
|
||||
clockClass.SetMethod("Unpause", &Nz::Clock::Unpause);
|
||||
|
||||
// Nz::Clock::__tostring (Manual)
|
||||
clockClass.SetMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::Clock& clock) -> int {
|
||||
Nz::StringStream stream("Clock(Elapsed: ");
|
||||
stream << clock.GetSeconds();
|
||||
stream << ", Paused: ";
|
||||
stream << clock.IsPaused();
|
||||
stream << ')';
|
||||
|
||||
lua.PushString(stream);
|
||||
return 1;
|
||||
});
|
||||
|
||||
|
||||
clockClass.Register(instance);
|
||||
|
||||
/********************************* Nz::Directory ********************************/
|
||||
Nz::LuaClass<Nz::Directory> directoryClass("Directory");
|
||||
|
||||
// Constructeur
|
||||
directoryClass.SetConstructor([](Nz::LuaInstance& lua) -> Nz::Directory* {
|
||||
unsigned int argCount = std::min(lua.GetStackTop(), 1U);
|
||||
switch (argCount)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
return new Nz::Directory;
|
||||
}
|
||||
|
||||
case 1:
|
||||
{
|
||||
int index = 1;
|
||||
return new Nz::Directory(lua.Check<Nz::String>(&index));
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
});
|
||||
|
||||
directoryClass.SetMethod("Close", &Nz::Directory::Close);
|
||||
directoryClass.SetMethod("Exists", &Nz::Directory::Exists);
|
||||
directoryClass.SetMethod("GetPath", &Nz::Directory::GetPath);
|
||||
directoryClass.SetMethod("GetPattern", &Nz::Directory::GetPattern);
|
||||
directoryClass.SetMethod("GetResultName", &Nz::Directory::GetResultName);
|
||||
directoryClass.SetMethod("GetResultPath", &Nz::Directory::GetResultPath);
|
||||
directoryClass.SetMethod("GetResultSize", &Nz::Directory::GetResultSize);
|
||||
directoryClass.SetMethod("IsOpen", &Nz::Directory::IsOpen);
|
||||
directoryClass.SetMethod("IsResultDirectory", &Nz::Directory::IsResultDirectory);
|
||||
directoryClass.SetMethod("NextResult", &Nz::Directory::NextResult, true);
|
||||
directoryClass.SetMethod("Open", &Nz::Directory::Open);
|
||||
directoryClass.SetMethod("SetPath", &Nz::Directory::SetPath);
|
||||
directoryClass.SetMethod("SetPattern", &Nz::Directory::SetPattern);
|
||||
|
||||
directoryClass.SetStaticMethod("Copy", Nz::Directory::Copy);
|
||||
directoryClass.SetStaticMethod("Create", Nz::Directory::Create);
|
||||
directoryClass.SetStaticMethod("Exists", Nz::Directory::Exists);
|
||||
directoryClass.SetStaticMethod("GetCurrent", Nz::Directory::GetCurrent);
|
||||
directoryClass.SetStaticMethod("Remove", Nz::Directory::Remove);
|
||||
directoryClass.SetStaticMethod("SetCurrent", Nz::Directory::SetCurrent);
|
||||
|
||||
// Nz::Directory::__tostring (Manual)
|
||||
directoryClass.SetMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::Directory& directory) -> int {
|
||||
Nz::StringStream stream("Directory(");
|
||||
stream << directory.GetPath();
|
||||
stream << ')';
|
||||
|
||||
lua.PushString(stream);
|
||||
return 1;
|
||||
});
|
||||
|
||||
|
||||
directoryClass.Register(instance);
|
||||
|
||||
/*********************************** Nz::File ***********************************/
|
||||
Nz::LuaClass<Nz::File> fileClass("File");
|
||||
|
||||
// Constructeur
|
||||
fileClass.SetConstructor([](Nz::LuaInstance& lua) -> Nz::File* {
|
||||
unsigned int argCount = std::min(lua.GetStackTop(), 2U);
|
||||
switch (argCount)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
return new Nz::File;
|
||||
}
|
||||
|
||||
case 1:
|
||||
{
|
||||
Nz::String filePath(lua.CheckString(1));
|
||||
|
||||
return new Nz::File(filePath);
|
||||
}
|
||||
|
||||
case 2:
|
||||
{
|
||||
Nz::String filePath(lua.CheckString(1));
|
||||
unsigned long openMode(lua.CheckInteger(2));
|
||||
|
||||
return new Nz::File(filePath, openMode);
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
});
|
||||
|
||||
fileClass.SetMethod("Close", &Nz::File::Close);
|
||||
fileClass.SetMethod("Copy", &Nz::File::Copy);
|
||||
fileClass.SetMethod("Delete", &Nz::File::Delete);
|
||||
fileClass.SetMethod("EndOfFile", &Nz::File::EndOfFile);
|
||||
fileClass.SetMethod("Exists", &Nz::File::Exists);
|
||||
fileClass.SetMethod("GetCreationTime", &Nz::File::GetCreationTime);
|
||||
fileClass.SetMethod("GetFileName", &Nz::File::GetFileName);
|
||||
fileClass.SetMethod("GetLastAccessTime", &Nz::File::GetLastAccessTime);
|
||||
fileClass.SetMethod("GetLastWriteTime", &Nz::File::GetLastWriteTime);
|
||||
fileClass.SetMethod("IsOpen", &Nz::File::IsOpen);
|
||||
fileClass.SetMethod("Rename", &Nz::File::GetLastWriteTime);
|
||||
fileClass.SetMethod("GetLastWriteTime", &Nz::File::GetLastWriteTime);
|
||||
fileClass.SetMethod("SetFile", &Nz::File::GetLastWriteTime);
|
||||
|
||||
fileClass.SetMethod("Open", [] (Nz::LuaInstance& lua, Nz::File& file) -> int {
|
||||
unsigned int argCount = std::min(lua.GetStackTop(), 2U);
|
||||
switch (argCount)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
bool _ret = file.Open();
|
||||
|
||||
lua.PushBoolean(_ret);
|
||||
return 1;
|
||||
}
|
||||
|
||||
case 1:
|
||||
{
|
||||
if (lua.IsOfType(1, Nz::LuaType_Number))
|
||||
{
|
||||
unsigned long openMode(lua.ToInteger(1));
|
||||
|
||||
bool _ret = file.Open(openMode);
|
||||
|
||||
lua.PushBoolean(_ret);
|
||||
return 1;
|
||||
}
|
||||
else if (lua.IsOfType(1, Nz::LuaType_String))
|
||||
{
|
||||
Nz::String filePath(lua.ToString(1));
|
||||
|
||||
bool _ret = file.Open(filePath);
|
||||
|
||||
lua.PushBoolean(_ret);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
case 2:
|
||||
{
|
||||
Nz::String filePath(lua.CheckString(1));
|
||||
unsigned long openMode(lua.CheckInteger(2));
|
||||
|
||||
bool _ret = file.Open(filePath, openMode);
|
||||
|
||||
lua.PushBoolean(_ret);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
lua.Error("No matching overload for method Open");
|
||||
return 0;
|
||||
});
|
||||
|
||||
fileClass.SetMethod("SetCursorPos", [] (Nz::LuaInstance& lua, Nz::File& file) -> int {
|
||||
unsigned int argCount = std::min(lua.GetStackTop(), 2U);
|
||||
switch (argCount)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
Nz::UInt64 offset(lua.CheckInteger(1));
|
||||
|
||||
bool _ret = file.SetCursorPos(offset);
|
||||
|
||||
lua.PushBoolean(_ret);
|
||||
return 1;
|
||||
}
|
||||
|
||||
case 2:
|
||||
{
|
||||
Nz::CursorPosition pos(static_cast<Nz::CursorPosition>(lua.CheckInteger(1)));
|
||||
Nz::Int64 offset(lua.CheckInteger(2));
|
||||
|
||||
bool _ret = file.SetCursorPos(pos, offset);
|
||||
|
||||
lua.PushBoolean(_ret);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
lua.Error("No matching overload for method SetCursorPos");
|
||||
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 {
|
||||
Nz::StringStream stream("File(");
|
||||
if (file.IsOpen())
|
||||
stream << "Path: " << file.GetPath();
|
||||
|
||||
stream << ')';
|
||||
|
||||
lua.PushString(stream);
|
||||
return 1;
|
||||
});
|
||||
|
||||
|
||||
fileClass.Register(instance);
|
||||
|
||||
// Énumérations de la classe Nz::File
|
||||
fileClass.PushGlobalTable(instance);
|
||||
|
||||
// Nz::File::CursorPosition
|
||||
instance.SetField("AtBegin", Nz::CursorPosition_AtBegin);
|
||||
instance.SetField("AtCurrent", Nz::CursorPosition_AtCurrent);
|
||||
instance.SetField("AtEnd", Nz::CursorPosition_AtEnd);
|
||||
|
||||
// Nz::File::OpenMode
|
||||
instance.SetField("Append", Nz::OpenMode_Append);
|
||||
instance.SetField("NotOpen", Nz::OpenMode_NotOpen);
|
||||
instance.SetField("Lock", Nz::OpenMode_Lock);
|
||||
instance.SetField("ReadOnly", Nz::OpenMode_ReadOnly);
|
||||
instance.SetField("ReadWrite", Nz::OpenMode_ReadWrite);
|
||||
instance.SetField("Text", Nz::OpenMode_Text);
|
||||
instance.SetField("Truncate", Nz::OpenMode_Truncate);
|
||||
instance.SetField("WriteOnly", Nz::OpenMode_WriteOnly);
|
||||
|
||||
instance.Pop();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,135 @@
|
|||
// This file was automatically generated on 26 May 2014 at 01:05:31
|
||||
|
||||
#include <NDK/LuaAPI.hpp>
|
||||
#include <Nazara/Math.hpp>
|
||||
#include <Nazara/Lua/LuaClass.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
void LuaAPI::Register_Math(Nz::LuaInstance& instance)
|
||||
{
|
||||
/*********************************** Nz::Vector3 **********************************/
|
||||
Nz::LuaClass<Nz::Vector3d> vectorClass("Vector3");
|
||||
|
||||
vectorClass.SetConstructor([] (Nz::LuaInstance& lua) -> Nz::Vector3d* {
|
||||
unsigned int argCount = std::min(lua.GetStackTop(), 3U);
|
||||
switch (argCount)
|
||||
{
|
||||
case 0:
|
||||
case 3:
|
||||
return new Nz::Vector3d(lua.CheckNumber(1, 0.0), lua.CheckNumber(2, 0.0), lua.CheckNumber(3, 0.0));
|
||||
|
||||
case 1:
|
||||
{
|
||||
if (lua.IsOfType(1, Nz::LuaType_Number))
|
||||
return new Nz::Vector3d(lua.CheckNumber(1), *static_cast<Nz::Vector2d*>(lua.ToUserdata(1)));
|
||||
else if (lua.IsOfType(1, "Vector2"))
|
||||
return new Nz::Vector3d(*(*static_cast<Nz::Vector2d*>(lua.ToUserdata(1))));
|
||||
else if (lua.IsOfType(1, "Vector3"))
|
||||
return new Nz::Vector3d(*(*static_cast<Nz::Vector3d*>(lua.ToUserdata(1))));
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 2:
|
||||
{
|
||||
if (lua.IsOfType(1, Nz::LuaType_Number))
|
||||
return new Nz::Vector3d(lua.CheckNumber(1), *static_cast<Nz::Vector2d*>(lua.CheckUserdata(1, "Vector2")));
|
||||
else if (lua.IsOfType(1, "Vector2"))
|
||||
return new Nz::Vector3d(*(*static_cast<Nz::Vector2d**>(lua.ToUserdata(1))), lua.CheckNumber(2));
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
lua.Error("No matching overload for constructor");
|
||||
return nullptr;
|
||||
});
|
||||
|
||||
vectorClass.SetMethod("__tostring", &Nz::Vector3d::ToString);
|
||||
|
||||
vectorClass.SetGetter([] (Nz::LuaInstance& lua, Nz::Vector3d& instance)
|
||||
{
|
||||
switch (lua.GetType(1))
|
||||
{
|
||||
case Nz::LuaType_Number:
|
||||
lua.Push(instance[lua.CheckInteger(1)]);
|
||||
return true;
|
||||
|
||||
case Nz::LuaType_String:
|
||||
{
|
||||
std::size_t length;
|
||||
const char* xyz = lua.CheckString(1, &length);
|
||||
|
||||
if (length != 1)
|
||||
break;
|
||||
|
||||
switch (xyz[0])
|
||||
{
|
||||
case 'x':
|
||||
lua.Push(instance.x);
|
||||
return true;
|
||||
|
||||
case 'y':
|
||||
lua.Push(instance.y);
|
||||
return true;
|
||||
|
||||
case 'z':
|
||||
lua.Push(instance.z);
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
vectorClass.SetSetter([] (Nz::LuaInstance& lua, Nz::Vector3d& instance)
|
||||
{
|
||||
switch (lua.GetType(1))
|
||||
{
|
||||
case Nz::LuaType_Number:
|
||||
{
|
||||
long long index = lua.CheckInteger(1);
|
||||
if (index < 1 || index > 3)
|
||||
return false;
|
||||
|
||||
instance[index] = lua.CheckNumber(2);
|
||||
return true;
|
||||
}
|
||||
|
||||
case Nz::LuaType_String:
|
||||
{
|
||||
std::size_t length;
|
||||
const char* xyz = lua.CheckString(1, &length);
|
||||
|
||||
if (length != 1)
|
||||
break;
|
||||
|
||||
double value = lua.CheckNumber(2);
|
||||
|
||||
switch (xyz[0])
|
||||
{
|
||||
case 'x':
|
||||
instance.x = value;
|
||||
return true;
|
||||
|
||||
case 'y':
|
||||
instance.y = value;
|
||||
return true;
|
||||
|
||||
case 'z':
|
||||
instance.z = value;
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
vectorClass.Register(instance);
|
||||
}
|
||||
}
|
||||
|
|
@ -23,12 +23,14 @@ TOOL.Files = {
|
|||
-- Exlude client-only files
|
||||
TOOL.FilesExclusion = {
|
||||
"../SDK/**/CameraComponent.*",
|
||||
"../SDK/**/Console.*",
|
||||
"../SDK/**/GraphicsComponent.*",
|
||||
"../SDK/**/LightComponent.*",
|
||||
"../SDK/**/ListenerComponent.*",
|
||||
"../SDK/**/ListenerSystem.*",
|
||||
"../SDK/**/RenderSystem.*",
|
||||
"../SDK/**/LuaInterface_Audio.*"
|
||||
"../SDK/**/LuaAPI_Audio.*",
|
||||
"../SDK/**/LuaAPI_Graphics.*",
|
||||
}
|
||||
|
||||
TOOL.Libraries = {
|
||||
|
|
|
|||
Loading…
Reference in New Issue