SDK/Lua: Rework LuaBinding classes to try to improve compile time and binary size
This commit is contained in:
parent
057de1544b
commit
7f143e41f8
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#ifndef NDK_SERVER
|
||||
#ifndef NDK_CONSOLE_HPP
|
||||
#define NDK_CONSOLE_HPP
|
||||
|
||||
|
|
@ -99,3 +100,4 @@ namespace Ndk
|
|||
#include <NDK/Console.inl>
|
||||
|
||||
#endif // NDK_CONSOLE_HPP
|
||||
#endif // NDK_SERVER
|
||||
|
|
|
|||
|
|
@ -7,28 +7,17 @@
|
|||
#ifndef NDK_LUABINDING_HPP
|
||||
#define NDK_LUABINDING_HPP
|
||||
|
||||
#include <Nazara/Core.hpp>
|
||||
#include <Nazara/Lua.hpp>
|
||||
#include <Nazara/Math.hpp>
|
||||
#include <Nazara/Network.hpp>
|
||||
#include <Nazara/Utility.hpp>
|
||||
#include <NDK/Application.hpp>
|
||||
#include <NDK/Components.hpp>
|
||||
#include <NDK/BaseComponent.hpp>
|
||||
#include <NDK/Entity.hpp>
|
||||
#include <NDK/Systems.hpp>
|
||||
#include <NDK/World.hpp>
|
||||
|
||||
#ifndef NDK_SERVER
|
||||
#include <Nazara/Audio.hpp>
|
||||
#include <Nazara/Graphics.hpp>
|
||||
#include <Nazara/Renderer.hpp>
|
||||
#include <NDK/Console.hpp>
|
||||
#endif
|
||||
#include <NDK/LuaBinding_Base.hpp>
|
||||
#include <memory>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
class NDK_API LuaBinding
|
||||
{
|
||||
friend class LuaBinding_SDK;
|
||||
|
||||
public:
|
||||
LuaBinding();
|
||||
~LuaBinding() = default;
|
||||
|
|
@ -37,86 +26,24 @@ namespace Ndk
|
|||
|
||||
void RegisterClasses(Nz::LuaInstance& instance);
|
||||
|
||||
// Core
|
||||
Nz::LuaClass<Nz::Clock> clock;
|
||||
Nz::LuaClass<Nz::Directory> directory;
|
||||
Nz::LuaClass<Nz::File> file;
|
||||
Nz::LuaClass<Nz::Stream> stream;
|
||||
|
||||
// Math
|
||||
Nz::LuaClass<Nz::EulerAnglesd> eulerAngles;
|
||||
Nz::LuaClass<Nz::Matrix4d> matrix4d;
|
||||
Nz::LuaClass<Nz::Quaterniond> quaternion;
|
||||
Nz::LuaClass<Nz::Rectd> rect;
|
||||
Nz::LuaClass<Nz::Vector2d> vector2d;
|
||||
Nz::LuaClass<Nz::Vector3d> vector3d;
|
||||
|
||||
// Network
|
||||
Nz::LuaClass<Nz::AbstractSocket> abstractSocket;
|
||||
Nz::LuaClass<Nz::IpAddress> ipAddress;
|
||||
|
||||
// Utility
|
||||
Nz::LuaClass<Nz::AbstractImageRef> abstractImage;
|
||||
Nz::LuaClass<Nz::FontRef> font;
|
||||
Nz::LuaClass<Nz::Keyboard> keyboard;
|
||||
Nz::LuaClass<Nz::Node> node;
|
||||
|
||||
// SDK
|
||||
Nz::LuaClass<Application*> application;
|
||||
Nz::LuaClass<EntityHandle> entity;
|
||||
Nz::LuaClass<NodeComponentHandle> nodeComponent;
|
||||
Nz::LuaClass<VelocityComponentHandle> velocityComponent;
|
||||
Nz::LuaClass<WorldHandle> world;
|
||||
std::unique_ptr<LuaBinding_Base> core;
|
||||
std::unique_ptr<LuaBinding_Base> math;
|
||||
std::unique_ptr<LuaBinding_Base> network;
|
||||
std::unique_ptr<LuaBinding_Base> sdk;
|
||||
std::unique_ptr<LuaBinding_Base> utility;
|
||||
|
||||
#ifndef NDK_SERVER
|
||||
// Audio
|
||||
Nz::LuaClass<Nz::Music> music;
|
||||
Nz::LuaClass<Nz::Sound> sound;
|
||||
Nz::LuaClass<Nz::SoundBufferRef> soundBuffer;
|
||||
Nz::LuaClass<Nz::SoundEmitter> soundEmitter;
|
||||
|
||||
// Graphics
|
||||
Nz::LuaClass<Nz::AbstractViewer> abstractViewer;
|
||||
Nz::LuaClass<Nz::InstancedRenderableRef> instancedRenderable;
|
||||
Nz::LuaClass<Nz::MaterialRef> material;
|
||||
Nz::LuaClass<Nz::ModelRef> model;
|
||||
Nz::LuaClass<Nz::SpriteRef> sprite;
|
||||
Nz::LuaClass<Nz::SpriteLibrary> spriteLibrary;
|
||||
Nz::LuaClass<Nz::TextureLibrary> textureLibrary;
|
||||
Nz::LuaClass<Nz::TextureManager> textureManager;
|
||||
|
||||
// Renderer
|
||||
Nz::LuaClass<Nz::TextureRef> texture;
|
||||
|
||||
// SDK
|
||||
Nz::LuaClass<CameraComponentHandle> cameraComponent;
|
||||
Nz::LuaClass<ConsoleHandle> console;
|
||||
Nz::LuaClass<GraphicsComponentHandle> graphicsComponent;
|
||||
std::unique_ptr<LuaBinding_Base> audio;
|
||||
std::unique_ptr<LuaBinding_Base> graphics;
|
||||
std::unique_ptr<LuaBinding_Base> renderer;
|
||||
#endif
|
||||
|
||||
private:
|
||||
void BindCore();
|
||||
void BindMath();
|
||||
void BindNetwork();
|
||||
void BindSDK();
|
||||
void BindUtility();
|
||||
|
||||
void RegisterCore(Nz::LuaInstance& instance);
|
||||
void RegisterMath(Nz::LuaInstance& instance);
|
||||
void RegisterNetwork(Nz::LuaInstance& instance);
|
||||
void RegisterSDK(Nz::LuaInstance& instance);
|
||||
void RegisterUtility(Nz::LuaInstance& instance);
|
||||
|
||||
#ifndef NDK_SERVER
|
||||
void BindAudio();
|
||||
void BindGraphics();
|
||||
void BindRenderer();
|
||||
|
||||
void RegisterAudio(Nz::LuaInstance& instance);
|
||||
void RegisterGraphics(Nz::LuaInstance& instance);
|
||||
void RegisterRenderer(Nz::LuaInstance& instance);
|
||||
#endif
|
||||
template<typename T>
|
||||
static int AddComponentOfType(Nz::LuaInstance& lua, EntityHandle& handle);
|
||||
|
||||
template<typename T>
|
||||
static int PushComponentOfType(Nz::LuaInstance& lua, BaseComponent& component);
|
||||
|
||||
using AddComponentFunc = int(*)(Nz::LuaInstance&, EntityHandle&);
|
||||
using GetComponentFunc = int(*)(Nz::LuaInstance&, BaseComponent&);
|
||||
|
|
@ -134,12 +61,6 @@ namespace Ndk
|
|||
std::vector<ComponentBinding> m_componentBinding;
|
||||
std::unordered_map<Nz::String, ComponentIndex> m_componentBindingByName;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
int AddComponentOfType(Nz::LuaInstance& lua, EntityHandle& handle);
|
||||
|
||||
template<typename T>
|
||||
int PushComponentOfType(Nz::LuaInstance& lua, BaseComponent& component);
|
||||
}
|
||||
|
||||
#include <NDK/LuaBinding.inl>
|
||||
|
|
|
|||
|
|
@ -32,18 +32,8 @@ namespace Ndk
|
|||
m_componentBindingByName[name] = T::componentIndex;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Adds a component to an entity
|
||||
* \return 1 in case of success
|
||||
*
|
||||
* \param instance Lua instance that will interact with the component
|
||||
* \param handle Entity which component will be added to
|
||||
*
|
||||
* \remark T must be a subtype of BaseComponent
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
int AddComponentOfType(Nz::LuaInstance& lua, EntityHandle& handle)
|
||||
int LuaBinding::AddComponentOfType(Nz::LuaInstance& lua, EntityHandle& handle)
|
||||
{
|
||||
static_assert(std::is_base_of<BaseComponent, T>::value, "ComponentType must inherit BaseComponent");
|
||||
|
||||
|
|
@ -52,18 +42,8 @@ namespace Ndk
|
|||
return 1;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Pushes a component
|
||||
* \return 1 in case of success
|
||||
*
|
||||
* \param instance Lua instance that will interact with the component
|
||||
* \param component Component that will be pushed
|
||||
*
|
||||
* \remark T must be a subtype of BaseComponent
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
int PushComponentOfType(Nz::LuaInstance& lua, BaseComponent& component)
|
||||
int LuaBinding::PushComponentOfType(Nz::LuaInstance& lua, BaseComponent& component)
|
||||
{
|
||||
static_assert(std::is_base_of<BaseComponent, T>::value, "ComponentType must inherit BaseComponent");
|
||||
|
||||
|
|
|
|||
|
|
@ -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_LUABINDING_AUDIO_HPP
|
||||
#define NDK_LUABINDING_AUDIO_HPP
|
||||
|
||||
#include <Nazara/Audio/Music.hpp>
|
||||
#include <Nazara/Audio/Sound.hpp>
|
||||
#include <Nazara/Audio/SoundBuffer.hpp>
|
||||
#include <Nazara/Audio/SoundEmitter.hpp>
|
||||
#include <NDK/LuaBinding_Base.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
class NDK_API LuaBinding_Audio : public LuaBinding_Base
|
||||
{
|
||||
public:
|
||||
LuaBinding_Audio(LuaBinding& binding);
|
||||
~LuaBinding_Audio() = default;
|
||||
|
||||
void Register(Nz::LuaInstance& instance) override;
|
||||
|
||||
Nz::LuaClass<Nz::Music> music;
|
||||
Nz::LuaClass<Nz::Sound> sound;
|
||||
Nz::LuaClass<Nz::SoundBufferRef> soundBuffer;
|
||||
Nz::LuaClass<Nz::SoundEmitter> soundEmitter;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NDK_LUABINDING_CORE_HPP
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
// 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_LUABINDING_BASE_HPP
|
||||
#define NDK_LUABINDING_BASE_HPP
|
||||
|
||||
#include <Nazara/Lua/LuaClass.hpp>
|
||||
#include <Nazara/Lua/LuaInstance.hpp>
|
||||
#include <NDK/Prerequesites.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
class LuaBinding;
|
||||
|
||||
class LuaBinding_Audio;
|
||||
class LuaBinding_Core;
|
||||
class LuaBinding_Graphics;
|
||||
class LuaBinding_Math;
|
||||
class LuaBinding_Network;
|
||||
class LuaBinding_Renderer;
|
||||
class LuaBinding_SDK;
|
||||
class LuaBinding_Utility;
|
||||
|
||||
class NDK_API LuaBinding_Base
|
||||
{
|
||||
public:
|
||||
LuaBinding_Base(LuaBinding& binding);
|
||||
virtual ~LuaBinding_Base();
|
||||
|
||||
virtual void Register(Nz::LuaInstance& instance) = 0;
|
||||
|
||||
// Implementation lies in the respective .cpp files (still searching for a cleaner way..)
|
||||
static std::unique_ptr<LuaBinding_Base> BindCore(LuaBinding& binding);
|
||||
static std::unique_ptr<LuaBinding_Base> BindMath(LuaBinding& binding);
|
||||
static std::unique_ptr<LuaBinding_Base> BindNetwork(LuaBinding& binding);
|
||||
static std::unique_ptr<LuaBinding_Base> BindSDK(LuaBinding& binding);
|
||||
static std::unique_ptr<LuaBinding_Base> BindUtility(LuaBinding& binding);
|
||||
|
||||
#ifndef NDK_SERVER
|
||||
static std::unique_ptr<LuaBinding_Base> BindAudio(LuaBinding& binding);
|
||||
static std::unique_ptr<LuaBinding_Base> BindGraphics(LuaBinding& binding);
|
||||
static std::unique_ptr<LuaBinding_Base> BindRenderer(LuaBinding& binding);
|
||||
#endif
|
||||
|
||||
protected:
|
||||
LuaBinding& m_binding;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NDK_LUABINDING_BASE_HPP
|
||||
|
|
@ -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_LUABINDING_CORE_HPP
|
||||
#define NDK_LUABINDING_CORE_HPP
|
||||
|
||||
#include <Nazara/Core/Clock.hpp>
|
||||
#include <Nazara/Core/Directory.hpp>
|
||||
#include <Nazara/Core/File.hpp>
|
||||
#include <Nazara/Core/Stream.hpp>
|
||||
#include <NDK/LuaBinding_Base.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
class NDK_API LuaBinding_Core : public LuaBinding_Base
|
||||
{
|
||||
public:
|
||||
LuaBinding_Core(LuaBinding& binding);
|
||||
~LuaBinding_Core() = default;
|
||||
|
||||
void Register(Nz::LuaInstance& instance) override;
|
||||
|
||||
Nz::LuaClass<Nz::Clock> clock;
|
||||
Nz::LuaClass<Nz::Directory> directory;
|
||||
Nz::LuaClass<Nz::File> file;
|
||||
Nz::LuaClass<Nz::Stream> stream;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NDK_LUABINDING_CORE_HPP
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
// 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_LUABINDING_GRAPHICS_HPP
|
||||
#define NDK_LUABINDING_GRAPHICS_HPP
|
||||
|
||||
#include <Nazara/Graphics/AbstractViewer.hpp>
|
||||
#include <Nazara/Graphics/InstancedRenderable.hpp>
|
||||
#include <Nazara/Graphics/Material.hpp>
|
||||
#include <Nazara/Graphics/Model.hpp>
|
||||
#include <Nazara/Graphics/Sprite.hpp>
|
||||
#include <NDK/LuaBinding_Base.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
class NDK_API LuaBinding_Graphics : public LuaBinding_Base
|
||||
{
|
||||
public:
|
||||
LuaBinding_Graphics(LuaBinding& binding);
|
||||
~LuaBinding_Graphics() = default;
|
||||
|
||||
void Register(Nz::LuaInstance& instance) override;
|
||||
|
||||
Nz::LuaClass<Nz::AbstractViewer> abstractViewer;
|
||||
Nz::LuaClass<Nz::InstancedRenderableRef> instancedRenderable;
|
||||
Nz::LuaClass<Nz::MaterialRef> material;
|
||||
Nz::LuaClass<Nz::ModelRef> model;
|
||||
Nz::LuaClass<Nz::SpriteRef> sprite;
|
||||
Nz::LuaClass<Nz::SpriteLibrary> spriteLibrary;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NDK_LUABINDING_GRAPHICS_HPP
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
// 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_LUABINDING_MATH_HPP
|
||||
#define NDK_LUABINDING_MATH_HPP
|
||||
|
||||
#include <Nazara/Math/EulerAngles.hpp>
|
||||
#include <Nazara/Math/Matrix4.hpp>
|
||||
#include <Nazara/Math/Quaternion.hpp>
|
||||
#include <Nazara/Math/Rect.hpp>
|
||||
#include <Nazara/Math/Vector2.hpp>
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
#include <NDK/LuaBinding_Base.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
class NDK_API LuaBinding_Math : public LuaBinding_Base
|
||||
{
|
||||
public:
|
||||
LuaBinding_Math(LuaBinding& binding);
|
||||
~LuaBinding_Math() = default;
|
||||
|
||||
void Register(Nz::LuaInstance& instance) override;
|
||||
|
||||
Nz::LuaClass<Nz::EulerAnglesd> eulerAngles;
|
||||
Nz::LuaClass<Nz::Matrix4d> matrix4d;
|
||||
Nz::LuaClass<Nz::Quaterniond> quaternion;
|
||||
Nz::LuaClass<Nz::Rectd> rect;
|
||||
Nz::LuaClass<Nz::Vector2d> vector2d;
|
||||
Nz::LuaClass<Nz::Vector3d> vector3d;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NDK_LUABINDING_MATH_HPP
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
// 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_LUABINDING_NETWORK_HPP
|
||||
#define NDK_LUABINDING_NETWORK_HPP
|
||||
|
||||
#include <Nazara/Network/AbstractSocket.hpp>
|
||||
#include <Nazara/Network/IpAddress.hpp>
|
||||
#include <NDK/LuaBinding_Base.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
class NDK_API LuaBinding_Network : public LuaBinding_Base
|
||||
{
|
||||
public:
|
||||
LuaBinding_Network(LuaBinding& binding);
|
||||
~LuaBinding_Network() = default;
|
||||
|
||||
void Register(Nz::LuaInstance& instance) override;
|
||||
|
||||
Nz::LuaClass<Nz::AbstractSocket> abstractSocket;
|
||||
Nz::LuaClass<Nz::IpAddress> ipAddress;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NDK_LUABINDING_NETWORK_HPP
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
// 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_LUABINDING_RENDERER_HPP
|
||||
#define NDK_LUABINDING_RENDERER_HPP
|
||||
|
||||
#include <Nazara/Renderer/Texture.hpp>
|
||||
#include <NDK/LuaBinding_Base.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
class NDK_API LuaBinding_Renderer : public LuaBinding_Base
|
||||
{
|
||||
public:
|
||||
LuaBinding_Renderer(LuaBinding& binding);
|
||||
~LuaBinding_Renderer() = default;
|
||||
|
||||
void Register(Nz::LuaInstance& instance) override;
|
||||
|
||||
Nz::LuaClass<Nz::TextureRef> texture;
|
||||
Nz::LuaClass<Nz::TextureLibrary> textureLibrary;
|
||||
Nz::LuaClass<Nz::TextureManager> textureManager;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NDK_LUABINDING_RENDERER_HPP
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
// 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_LUABINDING_SDK_HPP
|
||||
#define NDK_LUABINDING_SDK_HPP
|
||||
|
||||
#include <NDK/LuaBinding_Base.hpp>
|
||||
#include <NDK/Components.hpp>
|
||||
#include <NDK/Console.hpp>
|
||||
#include <NDK/Entity.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
class Application;
|
||||
|
||||
class NDK_API LuaBinding_SDK : public LuaBinding_Base
|
||||
{
|
||||
public:
|
||||
LuaBinding_SDK(LuaBinding& binding);
|
||||
~LuaBinding_SDK() = default;
|
||||
|
||||
void Register(Nz::LuaInstance& instance) override;
|
||||
|
||||
Nz::LuaClass<Application*> application;
|
||||
Nz::LuaClass<EntityHandle> entity;
|
||||
Nz::LuaClass<NodeComponentHandle> nodeComponent;
|
||||
Nz::LuaClass<VelocityComponentHandle> velocityComponent;
|
||||
Nz::LuaClass<WorldHandle> world;
|
||||
|
||||
#ifndef NDK_SERVER
|
||||
Nz::LuaClass<CameraComponentHandle> cameraComponent;
|
||||
Nz::LuaClass<ConsoleHandle> console;
|
||||
Nz::LuaClass<GraphicsComponentHandle> graphicsComponent;
|
||||
#endif
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NDK_LUABINDING_SDK_HPP
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
// 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_LUABINDING_UTILITY_HPP
|
||||
#define NDK_LUABINDING_UTILITY_HPP
|
||||
|
||||
#include <Nazara/Utility/AbstractImage.hpp>
|
||||
#include <Nazara/Utility/Font.hpp>
|
||||
#include <Nazara/Utility/Keyboard.hpp>
|
||||
#include <Nazara/Utility/Node.hpp>
|
||||
#include <NDK/LuaBinding_Base.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
class NDK_API LuaBinding_Utility : public LuaBinding_Base
|
||||
{
|
||||
public:
|
||||
LuaBinding_Utility(LuaBinding& binding);
|
||||
~LuaBinding_Utility() = default;
|
||||
|
||||
void Register(Nz::LuaInstance& instance) override;
|
||||
|
||||
// Utility
|
||||
Nz::LuaClass<Nz::AbstractImageRef> abstractImage;
|
||||
Nz::LuaClass<Nz::FontRef> font;
|
||||
Nz::LuaClass<Nz::Keyboard> keyboard;
|
||||
Nz::LuaClass<Nz::Node> node;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NDK_LUABINDING_UTILITY_HPP
|
||||
|
|
@ -14,76 +14,18 @@ namespace Ndk
|
|||
* \brief Binds modules to Lua
|
||||
*/
|
||||
|
||||
LuaBinding::LuaBinding() :
|
||||
// Core
|
||||
clock("Clock"),
|
||||
directory("Directory"),
|
||||
file("File"),
|
||||
stream("Stream"),
|
||||
|
||||
// Math
|
||||
eulerAngles("EulerAngles"),
|
||||
matrix4d("Matrix4"),
|
||||
quaternion("Quaternion"),
|
||||
rect("Rect"),
|
||||
vector2d("Vector2"),
|
||||
vector3d("Vector3"),
|
||||
|
||||
// Network
|
||||
abstractSocket("AbstractSocket"),
|
||||
ipAddress("IpAddress"),
|
||||
|
||||
// Utility
|
||||
abstractImage("AbstractImage"),
|
||||
font("Font"),
|
||||
keyboard("Keyboard"),
|
||||
node("Node"),
|
||||
|
||||
// SDK
|
||||
application("Application"),
|
||||
entity("Entity"),
|
||||
nodeComponent("NodeComponent"),
|
||||
velocityComponent("VelocityComponent"),
|
||||
world("World")
|
||||
|
||||
#ifndef NDK_SERVER
|
||||
,
|
||||
|
||||
// Audio
|
||||
music("Music"),
|
||||
sound("Sound"),
|
||||
soundBuffer("SoundBuffer"),
|
||||
soundEmitter("SoundEmitter"),
|
||||
|
||||
// Graphics
|
||||
abstractViewer("AbstractViewer"),
|
||||
instancedRenderable("InstancedRenderable"),
|
||||
material("Material"),
|
||||
model("Model"),
|
||||
sprite("Sprite"),
|
||||
spriteLibrary("SpriteLibrary"),
|
||||
textureLibrary("TextureLibrary"),
|
||||
textureManager("TextureManager"),
|
||||
|
||||
// Renderer
|
||||
texture("Texture"),
|
||||
|
||||
// SDK
|
||||
cameraComponent("CameraComponent"),
|
||||
console("Console"),
|
||||
graphicsComponent("GraphicsComponent")
|
||||
#endif
|
||||
LuaBinding::LuaBinding()
|
||||
{
|
||||
BindCore();
|
||||
BindMath();
|
||||
BindNetwork();
|
||||
BindSDK();
|
||||
BindUtility();
|
||||
core = LuaBinding_Base::BindCore(*this);
|
||||
math = LuaBinding_Base::BindMath(*this);
|
||||
network = LuaBinding_Base::BindNetwork(*this);
|
||||
sdk = LuaBinding_Base::BindSDK(*this);
|
||||
utility = LuaBinding_Base::BindUtility(*this);
|
||||
|
||||
#ifndef NDK_SERVER
|
||||
BindAudio();
|
||||
BindGraphics();
|
||||
BindRenderer();
|
||||
audio = LuaBinding_Base::BindAudio(*this);
|
||||
graphics = LuaBinding_Base::BindGraphics(*this);
|
||||
renderer = LuaBinding_Base::BindRenderer(*this);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -95,16 +37,29 @@ namespace Ndk
|
|||
|
||||
void LuaBinding::RegisterClasses(Nz::LuaInstance& instance)
|
||||
{
|
||||
RegisterCore(instance);
|
||||
RegisterMath(instance);
|
||||
RegisterNetwork(instance);
|
||||
RegisterSDK(instance);
|
||||
RegisterUtility(instance);
|
||||
core->Register(instance);
|
||||
math->Register(instance);
|
||||
network->Register(instance);
|
||||
sdk->Register(instance);
|
||||
utility->Register(instance);
|
||||
|
||||
#ifndef NDK_SERVER
|
||||
RegisterAudio(instance);
|
||||
RegisterGraphics(instance);
|
||||
RegisterRenderer(instance);
|
||||
audio->Register(instance);
|
||||
graphics->Register(instance);
|
||||
renderer->Register(instance);
|
||||
#endif
|
||||
|
||||
// ComponentType (fake enumeration to expose component indexes)
|
||||
instance.PushTable(0, m_componentBinding.size());
|
||||
{
|
||||
for (const ComponentBinding& entry : m_componentBinding)
|
||||
{
|
||||
if (entry.name.IsEmpty())
|
||||
continue;
|
||||
|
||||
instance.PushField(entry.name, entry.index);
|
||||
}
|
||||
}
|
||||
instance.SetGlobal("ComponentType");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,18 +1,22 @@
|
|||
// This file was automatically generated on 26 May 2014 at 01:05:31
|
||||
|
||||
#include <NDK/LuaBinding.hpp>
|
||||
#include <NDK/LuaBinding_Audio.hpp>
|
||||
#include <Nazara/Core/MemoryHelper.hpp>
|
||||
#include <NDK/LuaAPI.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
/*!
|
||||
* \brief Binds Audio module to Lua
|
||||
*/
|
||||
std::unique_ptr<LuaBinding_Base> LuaBinding_Base::BindAudio(LuaBinding& binding)
|
||||
{
|
||||
return std::make_unique<LuaBinding_Audio>(binding);
|
||||
}
|
||||
|
||||
void LuaBinding::BindAudio()
|
||||
LuaBinding_Audio::LuaBinding_Audio(LuaBinding& binding) :
|
||||
LuaBinding_Base(binding)
|
||||
{
|
||||
/*********************************** Nz::Music **********************************/
|
||||
music.Reset("Music");
|
||||
{
|
||||
music.Inherit(soundEmitter);
|
||||
|
||||
music.BindDefaultConstructor();
|
||||
|
|
@ -49,8 +53,11 @@ namespace Ndk
|
|||
lua.PushString(ss);
|
||||
return 1;
|
||||
});
|
||||
}
|
||||
|
||||
/*********************************** Nz::Sound **********************************/
|
||||
sound.Reset("Sound");
|
||||
{
|
||||
sound.Inherit(soundEmitter);
|
||||
|
||||
sound.BindDefaultConstructor();
|
||||
|
|
@ -76,8 +83,11 @@ namespace Ndk
|
|||
lua.PushString(ss);
|
||||
return 1;
|
||||
});
|
||||
}
|
||||
|
||||
/*********************************** Nz::SoundBuffer **********************************/
|
||||
soundBuffer.Reset("SoundBuffer");
|
||||
{
|
||||
soundBuffer.SetConstructor([] (Nz::LuaInstance& lua, Nz::SoundBufferRef* instance, std::size_t argumentCount)
|
||||
{
|
||||
NazaraUnused(lua);
|
||||
|
|
@ -138,8 +148,11 @@ namespace Ndk
|
|||
lua.PushString(ss);
|
||||
return 1;
|
||||
});
|
||||
}
|
||||
|
||||
/*********************************** Nz::SoundEmitter **********************************/
|
||||
soundEmitter.Reset("SoundEmitter");
|
||||
{
|
||||
soundEmitter.BindMethod("EnableLooping", &Nz::SoundEmitter::EnableLooping);
|
||||
soundEmitter.BindMethod("EnableSpatialization", &Nz::SoundEmitter::EnableSpatialization);
|
||||
|
||||
|
|
@ -168,14 +181,14 @@ namespace Ndk
|
|||
|
||||
soundEmitter.BindMethod("Stop", &Nz::SoundEmitter::Stop);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Registers the classes that will be used by the Lua instance
|
||||
*
|
||||
* \param instance Lua instance that will interact with the Audio classes
|
||||
*/
|
||||
|
||||
void LuaBinding::RegisterAudio(Nz::LuaInstance& instance)
|
||||
void LuaBinding_Audio::Register(Nz::LuaInstance& instance)
|
||||
{
|
||||
music.Register(instance);
|
||||
sound.Register(instance);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,13 @@
|
|||
// This file was automatically generated on 26 May 2014 at 01:05:31
|
||||
|
||||
#include <NDK/LuaBinding_Base.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
LuaBinding_Base::LuaBinding_Base(LuaBinding& binding) :
|
||||
m_binding(binding)
|
||||
{
|
||||
}
|
||||
|
||||
LuaBinding_Base::~LuaBinding_Base() = default;
|
||||
}
|
||||
|
|
@ -1,18 +1,22 @@
|
|||
// This file was automatically generated on 26 May 2014 at 01:05:31
|
||||
|
||||
#include <NDK/LuaBinding.hpp>
|
||||
#include <NDK/LuaBinding_Core.hpp>
|
||||
#include <Nazara/Core/MemoryHelper.hpp>
|
||||
#include <NDK/LuaAPI.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
/*!
|
||||
* \brief Binds Core module to Lua
|
||||
*/
|
||||
std::unique_ptr<LuaBinding_Base> LuaBinding_Base::BindCore(LuaBinding& binding)
|
||||
{
|
||||
return std::make_unique<LuaBinding_Core>(binding);
|
||||
}
|
||||
|
||||
void LuaBinding::BindCore()
|
||||
LuaBinding_Core::LuaBinding_Core(LuaBinding& binding) :
|
||||
LuaBinding_Base(binding)
|
||||
{
|
||||
/*********************************** Nz::Clock **********************************/
|
||||
clock.Reset("Clock");
|
||||
{
|
||||
clock.SetConstructor([] (Nz::LuaInstance& lua, Nz::Clock* instance, std::size_t argumentCount)
|
||||
{
|
||||
std::size_t argCount = std::min<std::size_t>(argumentCount, 2U);
|
||||
|
|
@ -65,8 +69,11 @@ namespace Ndk
|
|||
lua.PushString(ss);
|
||||
return 1;
|
||||
});
|
||||
}
|
||||
|
||||
/********************************* Nz::Directory ********************************/
|
||||
directory.Reset("Directory");
|
||||
{
|
||||
directory.SetConstructor([] (Nz::LuaInstance& lua, Nz::Directory* instance, std::size_t argumentCount)
|
||||
{
|
||||
std::size_t argCount = std::min<std::size_t>(argumentCount, 1U);
|
||||
|
|
@ -116,49 +123,11 @@ namespace Ndk
|
|||
lua.PushString(ss);
|
||||
return 1;
|
||||
});
|
||||
|
||||
/*********************************** Nz::Stream ***********************************/
|
||||
stream.BindMethod("EnableTextMode", &Nz::Stream::EnableTextMode);
|
||||
stream.BindMethod("Flush", &Nz::Stream::Flush);
|
||||
stream.BindMethod("GetCursorPos", &Nz::Stream::GetCursorPos);
|
||||
stream.BindMethod("GetDirectory", &Nz::Stream::GetDirectory);
|
||||
stream.BindMethod("GetPath", &Nz::Stream::GetPath);
|
||||
stream.BindMethod("GetOpenMode", &Nz::Stream::GetOpenMode);
|
||||
stream.BindMethod("GetStreamOptions", &Nz::Stream::GetStreamOptions);
|
||||
stream.BindMethod("GetSize", &Nz::Stream::GetSize);
|
||||
stream.BindMethod("ReadLine", &Nz::Stream::ReadLine, 0U);
|
||||
stream.BindMethod("IsReadable", &Nz::Stream::IsReadable);
|
||||
stream.BindMethod("IsSequential", &Nz::Stream::IsSequential);
|
||||
stream.BindMethod("IsTextModeEnabled", &Nz::Stream::IsTextModeEnabled);
|
||||
stream.BindMethod("IsWritable", &Nz::Stream::IsWritable);
|
||||
stream.BindMethod("SetCursorPos", &Nz::Stream::SetCursorPos);
|
||||
|
||||
stream.BindMethod("Read", [] (Nz::LuaInstance& lua, Nz::Stream& instance, std::size_t /*argumentCount*/) -> int {
|
||||
int argIndex = 2;
|
||||
|
||||
std::size_t length = lua.Check<std::size_t>(&argIndex);
|
||||
|
||||
std::unique_ptr<char[]> buffer(new char[length]);
|
||||
std::size_t readLength = instance.Read(buffer.get(), length);
|
||||
|
||||
lua.PushString(Nz::String(buffer.get(), readLength));
|
||||
return 1;
|
||||
});
|
||||
|
||||
stream.BindMethod("Write", [] (Nz::LuaInstance& lua, Nz::Stream& instance, std::size_t /*argumentCount*/) -> int {
|
||||
int argIndex = 2;
|
||||
|
||||
std::size_t bufferSize = 0;
|
||||
const char* buffer = lua.CheckString(argIndex, &bufferSize);
|
||||
|
||||
if (instance.IsTextModeEnabled())
|
||||
lua.Push(instance.Write(Nz::String(buffer, bufferSize)));
|
||||
else
|
||||
lua.Push(instance.Write(buffer, bufferSize));
|
||||
return 1;
|
||||
});
|
||||
}
|
||||
|
||||
/*********************************** Nz::File ***********************************/
|
||||
file.Reset("Stream");
|
||||
{
|
||||
file.Inherit(stream);
|
||||
|
||||
file.SetConstructor([] (Nz::LuaInstance& lua, Nz::File* instance, std::size_t argumentCount)
|
||||
|
|
@ -281,13 +250,57 @@ namespace Ndk
|
|||
});
|
||||
}
|
||||
|
||||
/*********************************** Nz::Stream ***********************************/
|
||||
stream.Reset("Stream");
|
||||
{
|
||||
stream.BindMethod("EnableTextMode", &Nz::Stream::EnableTextMode);
|
||||
stream.BindMethod("Flush", &Nz::Stream::Flush);
|
||||
stream.BindMethod("GetCursorPos", &Nz::Stream::GetCursorPos);
|
||||
stream.BindMethod("GetDirectory", &Nz::Stream::GetDirectory);
|
||||
stream.BindMethod("GetPath", &Nz::Stream::GetPath);
|
||||
stream.BindMethod("GetOpenMode", &Nz::Stream::GetOpenMode);
|
||||
stream.BindMethod("GetStreamOptions", &Nz::Stream::GetStreamOptions);
|
||||
stream.BindMethod("GetSize", &Nz::Stream::GetSize);
|
||||
stream.BindMethod("ReadLine", &Nz::Stream::ReadLine, 0U);
|
||||
stream.BindMethod("IsReadable", &Nz::Stream::IsReadable);
|
||||
stream.BindMethod("IsSequential", &Nz::Stream::IsSequential);
|
||||
stream.BindMethod("IsTextModeEnabled", &Nz::Stream::IsTextModeEnabled);
|
||||
stream.BindMethod("IsWritable", &Nz::Stream::IsWritable);
|
||||
stream.BindMethod("SetCursorPos", &Nz::Stream::SetCursorPos);
|
||||
|
||||
stream.BindMethod("Read", [] (Nz::LuaInstance& lua, Nz::Stream& instance, std::size_t /*argumentCount*/) -> int {
|
||||
int argIndex = 2;
|
||||
|
||||
std::size_t length = lua.Check<std::size_t>(&argIndex);
|
||||
|
||||
std::unique_ptr<char[]> buffer(new char[length]);
|
||||
std::size_t readLength = instance.Read(buffer.get(), length);
|
||||
|
||||
lua.PushString(Nz::String(buffer.get(), readLength));
|
||||
return 1;
|
||||
});
|
||||
|
||||
stream.BindMethod("Write", [] (Nz::LuaInstance& lua, Nz::Stream& instance, std::size_t /*argumentCount*/) -> int {
|
||||
int argIndex = 2;
|
||||
|
||||
std::size_t bufferSize = 0;
|
||||
const char* buffer = lua.CheckString(argIndex, &bufferSize);
|
||||
|
||||
if (instance.IsTextModeEnabled())
|
||||
lua.Push(instance.Write(Nz::String(buffer, bufferSize)));
|
||||
else
|
||||
lua.Push(instance.Write(buffer, bufferSize));
|
||||
return 1;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Registers the classes that will be used by the Lua instance
|
||||
*
|
||||
* \param instance Lua instance that will interact with the Core classes
|
||||
*/
|
||||
|
||||
void LuaBinding::RegisterCore(Nz::LuaInstance& instance)
|
||||
void LuaBinding_Core::Register(Nz::LuaInstance& instance)
|
||||
{
|
||||
// Classes
|
||||
clock.Register(instance);
|
||||
|
|
|
|||
|
|
@ -1,18 +1,22 @@
|
|||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||
|
||||
#include <NDK/LuaBinding.hpp>
|
||||
#include <NDK/LuaBinding_Graphics.hpp>
|
||||
#include <NDK/LuaAPI.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
/*!
|
||||
* \brief Binds Graphics module to Lua
|
||||
*/
|
||||
std::unique_ptr<LuaBinding_Base> LuaBinding_Base::BindGraphics(LuaBinding& binding)
|
||||
{
|
||||
return std::make_unique<LuaBinding_Graphics>(binding);
|
||||
}
|
||||
|
||||
void LuaBinding::BindGraphics()
|
||||
LuaBinding_Graphics::LuaBinding_Graphics(LuaBinding& binding) :
|
||||
LuaBinding_Base(binding)
|
||||
{
|
||||
/*********************************** Nz::AbstractViewer ***********************************/
|
||||
abstractViewer.Reset("AbstractViewer");
|
||||
{
|
||||
abstractViewer.BindMethod("GetAspectRatio", &Nz::AbstractViewer::GetAspectRatio);
|
||||
abstractViewer.BindMethod("GetEyePosition", &Nz::AbstractViewer::GetEyePosition);
|
||||
abstractViewer.BindMethod("GetForward", &Nz::AbstractViewer::GetForward);
|
||||
|
|
@ -23,10 +27,16 @@ namespace Ndk
|
|||
abstractViewer.BindMethod("GetViewport", &Nz::AbstractViewer::GetViewport);
|
||||
abstractViewer.BindMethod("GetZFar", &Nz::AbstractViewer::GetZFar);
|
||||
abstractViewer.BindMethod("GetZNear", &Nz::AbstractViewer::GetZNear);
|
||||
}
|
||||
|
||||
/*********************************** Nz::InstancedRenderable ***********************************/
|
||||
instancedRenderable.Reset("InstancedRenderable");
|
||||
{
|
||||
}
|
||||
|
||||
/*********************************** Nz::Material ***********************************/
|
||||
material.Reset("Material");
|
||||
{
|
||||
material.SetConstructor([] (Nz::LuaInstance& lua, Nz::MaterialRef* instance, std::size_t argumentCount)
|
||||
{
|
||||
switch (argumentCount)
|
||||
|
|
@ -241,8 +251,11 @@ namespace Ndk
|
|||
else
|
||||
return lua.Push(instance->SetSpecularMap(lua.Check<Nz::String>(&argIndex)));
|
||||
});
|
||||
}
|
||||
|
||||
/*********************************** Nz::Model ***********************************/
|
||||
model.Reset("Model");
|
||||
{
|
||||
model.Inherit<Nz::InstancedRenderableRef>(instancedRenderable, [] (Nz::ModelRef* modelRef) -> Nz::InstancedRenderableRef*
|
||||
{
|
||||
return reinterpret_cast<Nz::InstancedRenderableRef*>(modelRef); //TODO: Make a ObjectRefCast
|
||||
|
|
@ -270,8 +283,11 @@ namespace Ndk
|
|||
//modelClass.SetMethod("SetSequence", &Nz::Model::SetSequence);
|
||||
model.BindMethod("SetSkin", &Nz::Model::SetSkin);
|
||||
model.BindMethod("SetSkinCount", &Nz::Model::SetSkinCount);
|
||||
}
|
||||
|
||||
/*********************************** Nz::Sprite ***********************************/
|
||||
sprite.Reset("Sprite");
|
||||
{
|
||||
sprite.Inherit<Nz::InstancedRenderableRef>(instancedRenderable, [] (Nz::SpriteRef* spriteRef) -> Nz::InstancedRenderableRef*
|
||||
{
|
||||
return reinterpret_cast<Nz::InstancedRenderableRef*>(spriteRef); //TODO: Make a ObjectRefCast
|
||||
|
|
@ -323,32 +339,17 @@ namespace Ndk
|
|||
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
|
||||
/*********************************** Nz::SpriteLibrary ***********************************/
|
||||
|
||||
spriteLibrary.Reset("SpriteLibrary");
|
||||
{
|
||||
spriteLibrary.BindStaticMethod("Get", &Nz::SpriteLibrary::Get);
|
||||
spriteLibrary.BindStaticMethod("Has", &Nz::SpriteLibrary::Has);
|
||||
spriteLibrary.BindStaticMethod("Register", &Nz::SpriteLibrary::Register);
|
||||
spriteLibrary.BindStaticMethod("Query", &Nz::SpriteLibrary::Query);
|
||||
spriteLibrary.BindStaticMethod("Unregister", &Nz::SpriteLibrary::Unregister);
|
||||
|
||||
/*********************************** Nz::TextureLibrary ***********************************/
|
||||
|
||||
textureLibrary.BindStaticMethod("Get", &Nz::TextureLibrary::Get);
|
||||
textureLibrary.BindStaticMethod("Has", &Nz::TextureLibrary::Has);
|
||||
textureLibrary.BindStaticMethod("Register", &Nz::TextureLibrary::Register);
|
||||
textureLibrary.BindStaticMethod("Query", &Nz::TextureLibrary::Query);
|
||||
textureLibrary.BindStaticMethod("Unregister", &Nz::TextureLibrary::Unregister);
|
||||
|
||||
/*********************************** Nz::TextureManager ***********************************/
|
||||
|
||||
textureManager.BindStaticMethod("Clear", &Nz::TextureManager::Clear);
|
||||
textureManager.BindStaticMethod("Get", &Nz::TextureManager::Get);
|
||||
textureManager.BindStaticMethod("GetDefaultParameters", &Nz::TextureManager::GetDefaultParameters);
|
||||
textureManager.BindStaticMethod("Purge", &Nz::TextureManager::Purge);
|
||||
textureManager.BindStaticMethod("Register", &Nz::TextureManager::Register);
|
||||
textureManager.BindStaticMethod("SetDefaultParameters", &Nz::TextureManager::SetDefaultParameters);
|
||||
textureManager.BindStaticMethod("Unregister", &Nz::TextureManager::Unregister);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
@ -357,7 +358,7 @@ namespace Ndk
|
|||
* \param instance Lua instance that will interact with the Graphics classes
|
||||
*/
|
||||
|
||||
void LuaBinding::RegisterGraphics(Nz::LuaInstance& instance)
|
||||
void LuaBinding_Graphics::Register(Nz::LuaInstance& instance)
|
||||
{
|
||||
abstractViewer.Register(instance);
|
||||
instancedRenderable.Register(instance);
|
||||
|
|
@ -365,7 +366,5 @@ namespace Ndk
|
|||
model.Register(instance);
|
||||
sprite.Register(instance);
|
||||
spriteLibrary.Register(instance);
|
||||
textureLibrary.Register(instance);
|
||||
textureManager.Register(instance);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,19 +1,23 @@
|
|||
// This file was automatically generated on 26 May 2014 at 01:05:31
|
||||
|
||||
#include <NDK/LuaBinding.hpp>
|
||||
#include <NDK/LuaBinding_Math.hpp>
|
||||
#include <Nazara/Core/MemoryHelper.hpp>
|
||||
#include <NDK/LuaAPI.hpp>
|
||||
#include <cstring>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
/*!
|
||||
* \brief Binds Math module to Lua
|
||||
*/
|
||||
std::unique_ptr<LuaBinding_Base> LuaBinding_Base::BindMath(LuaBinding& binding)
|
||||
{
|
||||
return std::make_unique<LuaBinding_Math>(binding);
|
||||
}
|
||||
|
||||
void LuaBinding::BindMath()
|
||||
LuaBinding_Math::LuaBinding_Math(LuaBinding& binding) :
|
||||
LuaBinding_Base(binding)
|
||||
{
|
||||
/*********************************** Nz::EulerAngles **********************************/
|
||||
eulerAngles.Reset("EulerAngles");
|
||||
{
|
||||
eulerAngles.SetConstructor([] (Nz::LuaInstance& lua, Nz::EulerAnglesd* instance, std::size_t argumentCount)
|
||||
{
|
||||
std::size_t argCount = std::min<std::size_t>(argumentCount, 1U);
|
||||
|
|
@ -156,9 +160,11 @@ namespace Ndk
|
|||
|
||||
return false;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/*********************************** Nz::Matrix4 **********************************/
|
||||
matrix4d.Reset("Matrix4");
|
||||
{
|
||||
matrix4d.SetConstructor([] (Nz::LuaInstance& lua, Nz::Matrix4d* matrix, std::size_t argumentCount)
|
||||
{
|
||||
std::size_t argCount = std::min<std::size_t>(argumentCount, 3U);
|
||||
|
|
@ -361,8 +367,11 @@ namespace Ndk
|
|||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
/*********************************** Nz::Rect **********************************/
|
||||
rect.Reset("Rect");
|
||||
{
|
||||
rect.SetConstructor([] (Nz::LuaInstance& lua, Nz::Rectd* instance, std::size_t argumentCount)
|
||||
{
|
||||
std::size_t argCount = std::min<std::size_t>(argumentCount, 4U);
|
||||
|
|
@ -517,8 +526,11 @@ namespace Ndk
|
|||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
/*********************************** Nz::Quaternion **********************************/
|
||||
quaternion.Reset("Quaternion");
|
||||
{
|
||||
quaternion.SetConstructor([] (Nz::LuaInstance& lua, Nz::Quaterniond* instance, std::size_t argumentCount)
|
||||
{
|
||||
std::size_t argCount = std::min<std::size_t>(argumentCount, 4U);
|
||||
|
|
@ -673,8 +685,11 @@ namespace Ndk
|
|||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
/*********************************** Nz::Vector2 **********************************/
|
||||
vector2d.Reset("Vector2");
|
||||
{
|
||||
vector2d.SetConstructor([] (Nz::LuaInstance& lua, Nz::Vector2d* vector, std::size_t argumentCount)
|
||||
{
|
||||
std::size_t argCount = std::min<std::size_t>(argumentCount, 2U);
|
||||
|
|
@ -796,8 +811,11 @@ namespace Ndk
|
|||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
/*********************************** Nz::Vector3 **********************************/
|
||||
vector3d.Reset("Vector3");
|
||||
{
|
||||
vector3d.SetConstructor([] (Nz::LuaInstance& lua, Nz::Vector3d* vector, std::size_t argumentCount)
|
||||
{
|
||||
std::size_t argCount = std::min<std::size_t>(argumentCount, 3U);
|
||||
|
|
@ -942,14 +960,14 @@ namespace Ndk
|
|||
return false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Registers the classes that will be used by the Lua instance
|
||||
*
|
||||
* \param instance Lua instance that will interact with the Math classes
|
||||
*/
|
||||
|
||||
void LuaBinding::RegisterMath(Nz::LuaInstance& instance)
|
||||
void LuaBinding_Math::Register(Nz::LuaInstance& instance)
|
||||
{
|
||||
eulerAngles.Register(instance);
|
||||
matrix4d.Register(instance);
|
||||
|
|
|
|||
|
|
@ -1,17 +1,21 @@
|
|||
// This file was automatically generated on 26 May 2014 at 01:05:31
|
||||
|
||||
#include <NDK/LuaBinding.hpp>
|
||||
#include <NDK/LuaBinding_Network.hpp>
|
||||
#include <NDK/LuaAPI.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
/*!
|
||||
* \brief Binds Network module to Lua
|
||||
*/
|
||||
std::unique_ptr<LuaBinding_Base> LuaBinding_Base::BindNetwork(LuaBinding& binding)
|
||||
{
|
||||
return std::make_unique<LuaBinding_Network>(binding);
|
||||
}
|
||||
|
||||
void LuaBinding::BindNetwork()
|
||||
LuaBinding_Network::LuaBinding_Network(LuaBinding& binding) :
|
||||
LuaBinding_Base(binding)
|
||||
{
|
||||
/*********************************** Nz::AbstractSocket **********************************/
|
||||
abstractSocket.Reset("AbstractSocket");
|
||||
{
|
||||
abstractSocket.BindMethod("Close", &Nz::AbstractSocket::Close);
|
||||
abstractSocket.BindMethod("EnableBlocking", &Nz::AbstractSocket::EnableBlocking);
|
||||
abstractSocket.BindMethod("GetLastError", &Nz::AbstractSocket::GetLastError);
|
||||
|
|
@ -19,8 +23,11 @@ namespace Ndk
|
|||
abstractSocket.BindMethod("GetType", &Nz::AbstractSocket::GetType);
|
||||
abstractSocket.BindMethod("IsBlockingEnabled", &Nz::AbstractSocket::IsBlockingEnabled);
|
||||
abstractSocket.BindMethod("QueryAvailableBytes", &Nz::AbstractSocket::QueryAvailableBytes);
|
||||
}
|
||||
|
||||
/*********************************** Nz::IpAddress **********************************/
|
||||
ipAddress.Reset("IpAddress");
|
||||
{
|
||||
ipAddress.SetConstructor([] (Nz::LuaInstance& lua, Nz::IpAddress* instance, std::size_t argumentCount)
|
||||
{
|
||||
std::size_t argCount = std::min<std::size_t>(argumentCount, 9U);
|
||||
|
|
@ -135,14 +142,14 @@ namespace Ndk
|
|||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Registers the classes that will be used by the Lua instance
|
||||
*
|
||||
* \param instance Lua instance that will interact with the Network classes
|
||||
*/
|
||||
|
||||
void LuaBinding::RegisterNetwork(Nz::LuaInstance& instance)
|
||||
void LuaBinding_Network::Register(Nz::LuaInstance& instance)
|
||||
{
|
||||
// Classes
|
||||
abstractSocket.Register(instance);
|
||||
|
|
|
|||
|
|
@ -1,19 +1,28 @@
|
|||
// Copyright (C) 2016 Jérôme Leclercq, Arnaud Cadot
|
||||
// Copyright (C) 2016 Jérôme Leclercq, Arnaud Cadot
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||
|
||||
#include <NDK/LuaBinding.hpp>
|
||||
#include <NDK/LuaBinding_Renderer.hpp>
|
||||
#include <NDK/LuaAPI.hpp>
|
||||
#include <NDK/LuaBinding.hpp>
|
||||
#include <NDK/LuaBinding_Utility.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
/*!
|
||||
* \brief Binds Renderer module to Lua
|
||||
*/
|
||||
void LuaBinding::BindRenderer()
|
||||
std::unique_ptr<LuaBinding_Base> LuaBinding_Base::BindRenderer(LuaBinding& binding)
|
||||
{
|
||||
return std::make_unique<LuaBinding_Renderer>(binding);
|
||||
}
|
||||
|
||||
LuaBinding_Renderer::LuaBinding_Renderer(LuaBinding& binding) :
|
||||
LuaBinding_Base(binding)
|
||||
{
|
||||
LuaBinding_Utility& utility = static_cast<LuaBinding_Utility&>(*m_binding.utility);
|
||||
|
||||
/*********************************** Nz::Texture ***********************************/
|
||||
texture.Inherit<Nz::AbstractImageRef>(abstractImage, [] (Nz::TextureRef* textureRef) -> Nz::AbstractImageRef*
|
||||
texture.Reset("Texture");
|
||||
{
|
||||
texture.Inherit<Nz::AbstractImageRef>(utility.abstractImage, [] (Nz::TextureRef* textureRef) -> Nz::AbstractImageRef*
|
||||
{
|
||||
return reinterpret_cast<Nz::AbstractImageRef*>(textureRef); //TODO: Make a ObjectRefCast
|
||||
});
|
||||
|
|
@ -64,13 +73,38 @@ namespace Ndk
|
|||
texture.BindStaticMethod("IsTypeSupported", &Nz::Texture::IsTypeSupported);
|
||||
}
|
||||
|
||||
/*********************************** Nz::TextureLibrary ***********************************/
|
||||
textureLibrary.Reset("TextureLibrary");
|
||||
{
|
||||
textureLibrary.BindStaticMethod("Get", &Nz::TextureLibrary::Get);
|
||||
textureLibrary.BindStaticMethod("Has", &Nz::TextureLibrary::Has);
|
||||
textureLibrary.BindStaticMethod("Register", &Nz::TextureLibrary::Register);
|
||||
textureLibrary.BindStaticMethod("Query", &Nz::TextureLibrary::Query);
|
||||
textureLibrary.BindStaticMethod("Unregister", &Nz::TextureLibrary::Unregister);
|
||||
}
|
||||
|
||||
/*********************************** Nz::TextureManager ***********************************/
|
||||
textureManager.Reset("textureManager");
|
||||
{
|
||||
textureManager.BindStaticMethod("Clear", &Nz::TextureManager::Clear);
|
||||
textureManager.BindStaticMethod("Get", &Nz::TextureManager::Get);
|
||||
textureManager.BindStaticMethod("GetDefaultParameters", &Nz::TextureManager::GetDefaultParameters);
|
||||
textureManager.BindStaticMethod("Purge", &Nz::TextureManager::Purge);
|
||||
textureManager.BindStaticMethod("Register", &Nz::TextureManager::Register);
|
||||
textureManager.BindStaticMethod("SetDefaultParameters", &Nz::TextureManager::SetDefaultParameters);
|
||||
textureManager.BindStaticMethod("Unregister", &Nz::TextureManager::Unregister);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Registers the classes that will be used by the Lua instance
|
||||
*
|
||||
* \param instance Lua instance that will interact with the Renderer classes
|
||||
*/
|
||||
void LuaBinding::RegisterRenderer(Nz::LuaInstance& instance)
|
||||
void LuaBinding_Renderer::Register(Nz::LuaInstance& instance)
|
||||
{
|
||||
texture.Register(instance);
|
||||
textureLibrary.Register(instance);
|
||||
textureManager.Register(instance);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,19 +2,34 @@
|
|||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||
|
||||
#include <NDK/LuaBinding.hpp>
|
||||
#include <NDK/LuaBinding_SDK.hpp>
|
||||
#include <NDK/LuaAPI.hpp>
|
||||
#include <NDK/LuaBinding.hpp>
|
||||
#include <NDK/LuaBinding_Utility.hpp>
|
||||
|
||||
#ifndef NDK_SERVER
|
||||
#include <NDK/LuaBinding_Graphics.hpp>
|
||||
#endif
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
/*!
|
||||
* \brief Binds SDK module to Lua
|
||||
*/
|
||||
|
||||
void LuaBinding::BindSDK()
|
||||
std::unique_ptr<LuaBinding_Base> LuaBinding_Base::BindSDK(LuaBinding& binding)
|
||||
{
|
||||
/*********************************** Ndk::Application **********************************/
|
||||
return std::make_unique<LuaBinding_SDK>(binding);
|
||||
}
|
||||
|
||||
LuaBinding_SDK::LuaBinding_SDK(LuaBinding& binding) :
|
||||
LuaBinding_Base(binding)
|
||||
{
|
||||
#ifndef NDK_SERVER
|
||||
LuaBinding_Graphics& graphics = static_cast<LuaBinding_Graphics&>(*m_binding.graphics);
|
||||
#endif
|
||||
|
||||
LuaBinding_Utility& utility = static_cast<LuaBinding_Utility&>(*m_binding.utility);
|
||||
|
||||
/*********************************** Ndk::Application **********************************/
|
||||
application.Reset("Application");
|
||||
{
|
||||
#ifndef NDK_SERVER
|
||||
//application.SetMethod("AddWindow", &Application::AddWindow);
|
||||
|
||||
|
|
@ -33,10 +48,13 @@ namespace Ndk
|
|||
|
||||
application.BindMethod("GetUpdateTime", &Application::GetUpdateTime);
|
||||
application.BindMethod("Quit", &Application::Quit);
|
||||
}
|
||||
|
||||
/*********************************** Ndk::Console **********************************/
|
||||
#ifndef NDK_SERVER
|
||||
console.Inherit<Nz::Node>(node, [] (ConsoleHandle* handle) -> Nz::Node*
|
||||
console.Reset("Console");
|
||||
{
|
||||
console.Inherit<Nz::Node>(utility.node, [] (ConsoleHandle* handle) -> Nz::Node*
|
||||
{
|
||||
return handle->GetObject();
|
||||
});
|
||||
|
|
@ -61,9 +79,12 @@ namespace Ndk
|
|||
console.BindMethod("SetTextFont", &Console::SetTextFont);
|
||||
|
||||
console.BindMethod("Show", &Console::Show, true);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*********************************** Ndk::Entity **********************************/
|
||||
entity.Reset("Entity");
|
||||
{
|
||||
entity.BindMethod("Enable", &Entity::Enable, true);
|
||||
entity.BindMethod("GetId", &Entity::GetId);
|
||||
entity.BindMethod("GetWorld", &Entity::GetWorld);
|
||||
|
|
@ -75,33 +96,39 @@ namespace Ndk
|
|||
|
||||
entity.BindMethod("AddComponent", [this] (Nz::LuaInstance& instance, EntityHandle& handle, std::size_t /*argumentCount*/) -> int
|
||||
{
|
||||
ComponentBinding* binding = QueryComponentIndex(instance);
|
||||
LuaBinding::ComponentBinding* binding = m_binding.QueryComponentIndex(instance);
|
||||
|
||||
return binding->adder(instance, handle);
|
||||
});
|
||||
|
||||
entity.BindMethod("GetComponent", [this] (Nz::LuaInstance& instance, EntityHandle& handle, std::size_t /*argumentCount*/) -> int
|
||||
{
|
||||
ComponentBinding* binding = QueryComponentIndex(instance);
|
||||
LuaBinding::ComponentBinding* binding = m_binding.QueryComponentIndex(instance);
|
||||
|
||||
return binding->getter(instance, handle->GetComponent(binding->index));
|
||||
});
|
||||
|
||||
entity.BindMethod("RemoveComponent", [this] (Nz::LuaInstance& instance, EntityHandle& handle, std::size_t /*argumentCount*/) -> int
|
||||
{
|
||||
ComponentBinding* binding = QueryComponentIndex(instance);
|
||||
LuaBinding::ComponentBinding* binding = m_binding.QueryComponentIndex(instance);
|
||||
|
||||
handle->RemoveComponent(binding->index);
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
|
||||
/*********************************** Ndk::NodeComponent **********************************/
|
||||
nodeComponent.Inherit<Nz::Node>(node, [] (NodeComponentHandle* handle) -> Nz::Node*
|
||||
nodeComponent.Reset("NodeComponent");
|
||||
{
|
||||
nodeComponent.Inherit<Nz::Node>(utility.node, [] (NodeComponentHandle* handle) -> Nz::Node*
|
||||
{
|
||||
return handle->GetObject();
|
||||
});
|
||||
}
|
||||
|
||||
/*********************************** Ndk::VelocityComponent **********************************/
|
||||
velocityComponent.Reset("VelocityComponent");
|
||||
{
|
||||
velocityComponent.SetGetter([] (Nz::LuaInstance& lua, VelocityComponentHandle& instance)
|
||||
{
|
||||
std::size_t length;
|
||||
|
|
@ -130,16 +157,21 @@ namespace Ndk
|
|||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
/*********************************** Ndk::World **********************************/
|
||||
world.Reset("World");
|
||||
{
|
||||
world.BindMethod("CreateEntity", &World::CreateEntity);
|
||||
world.BindMethod("CreateEntities", &World::CreateEntities);
|
||||
world.BindMethod("Clear", &World::Clear);
|
||||
|
||||
}
|
||||
|
||||
#ifndef NDK_SERVER
|
||||
/*********************************** Ndk::CameraComponent **********************************/
|
||||
cameraComponent.Inherit<Nz::AbstractViewer>(abstractViewer, [] (CameraComponentHandle* handle) -> Nz::AbstractViewer*
|
||||
cameraComponent.Reset("CameraComponent");
|
||||
{
|
||||
cameraComponent.Inherit<Nz::AbstractViewer>(graphics.abstractViewer, [] (CameraComponentHandle* handle) -> Nz::AbstractViewer*
|
||||
{
|
||||
return handle->GetObject();
|
||||
});
|
||||
|
|
@ -156,8 +188,11 @@ namespace Ndk
|
|||
cameraComponent.BindMethod("SetViewport", &Ndk::CameraComponent::SetViewport);
|
||||
cameraComponent.BindMethod("SetZFar", &Ndk::CameraComponent::SetZFar);
|
||||
cameraComponent.BindMethod("SetZNear", &Ndk::CameraComponent::SetZNear);
|
||||
}
|
||||
|
||||
/*********************************** Ndk::GraphicsComponent **********************************/
|
||||
graphicsComponent.Reset("GraphicsComponent");
|
||||
{
|
||||
graphicsComponent.BindMethod("Attach", [] (Nz::LuaInstance& lua, Ndk::GraphicsComponent* instance, std::size_t argumentCount) -> int
|
||||
{
|
||||
/*
|
||||
|
|
@ -214,18 +249,16 @@ namespace Ndk
|
|||
lua.Error("No matching overload for method GetMemoryUsage");
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// Components functions
|
||||
m_componentBinding.resize(BaseComponent::GetMaxComponentIndex());
|
||||
|
||||
BindComponent<NodeComponent>("Node");
|
||||
BindComponent<VelocityComponent>("Velocity");
|
||||
m_binding.BindComponent<NodeComponent>("Node");
|
||||
m_binding.BindComponent<VelocityComponent>("Velocity");
|
||||
|
||||
#ifndef NDK_SERVER
|
||||
BindComponent<CameraComponent>("Camera");
|
||||
BindComponent<GraphicsComponent>("Graphics");
|
||||
m_binding.BindComponent<CameraComponent>("Camera");
|
||||
m_binding.BindComponent<GraphicsComponent>("Graphics");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -234,8 +267,7 @@ namespace Ndk
|
|||
*
|
||||
* \param instance Lua instance that will interact with the SDK classes
|
||||
*/
|
||||
|
||||
void LuaBinding::RegisterSDK(Nz::LuaInstance& instance)
|
||||
void LuaBinding_SDK::Register(Nz::LuaInstance& instance)
|
||||
{
|
||||
// Classes
|
||||
application.Register(instance);
|
||||
|
|
@ -251,19 +283,6 @@ namespace Ndk
|
|||
#endif
|
||||
|
||||
// Enums
|
||||
|
||||
// ComponentType (fake enumeration to expose component indexes)
|
||||
instance.PushTable(0, m_componentBinding.size());
|
||||
{
|
||||
for (const ComponentBinding& entry : m_componentBinding)
|
||||
{
|
||||
if (entry.name.IsEmpty())
|
||||
continue;
|
||||
|
||||
instance.PushField(entry.name, entry.index);
|
||||
}
|
||||
}
|
||||
instance.SetGlobal("ComponentType");
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
@ -273,7 +292,6 @@ namespace Ndk
|
|||
* \param instance Lua instance that will interact with the component
|
||||
* \param argIndex Index of the component
|
||||
*/
|
||||
|
||||
LuaBinding::ComponentBinding* LuaBinding::QueryComponentIndex(Nz::LuaInstance& instance, int argIndex)
|
||||
{
|
||||
switch (instance.GetType(argIndex))
|
||||
|
|
|
|||
|
|
@ -1,16 +1,18 @@
|
|||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||
|
||||
#include <NDK/LuaBinding.hpp>
|
||||
#include <NDK/LuaBinding_Utility.hpp>
|
||||
#include <NDK/LuaAPI.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
/*!
|
||||
* \brief Binds Utility module to Lua
|
||||
*/
|
||||
std::unique_ptr<LuaBinding_Base> LuaBinding_Base::BindUtility(LuaBinding& binding)
|
||||
{
|
||||
return std::make_unique<LuaBinding_Utility>(binding);
|
||||
}
|
||||
|
||||
void LuaBinding::BindUtility()
|
||||
LuaBinding_Utility::LuaBinding_Utility(LuaBinding& binding) :
|
||||
LuaBinding_Base(binding)
|
||||
{
|
||||
/*********************************** Nz::AbstractImage **********************************/
|
||||
abstractImage.BindMethod("GetBytesPerPixel", &Nz::AbstractImage::GetBytesPerPixel);
|
||||
|
|
@ -321,8 +323,7 @@ namespace Ndk
|
|||
*
|
||||
* \param instance Lua instance that will interact with the Utility classes
|
||||
*/
|
||||
|
||||
void LuaBinding::RegisterUtility(Nz::LuaInstance& instance)
|
||||
void LuaBinding_Utility::Register(Nz::LuaInstance& instance)
|
||||
{
|
||||
abstractImage.Register(instance);
|
||||
font.Register(instance);
|
||||
|
|
|
|||
Loading…
Reference in New Issue