diff options
Diffstat (limited to 'source/modules')
201 files changed, 245 insertions, 9327 deletions
diff --git a/source/modules/asura-box2d/Box2DModule.h b/source/modules/asura-box2d/Box2DModule.h index 1a00608..31a665b 100644 --- a/source/modules/asura-box2d/Box2DModule.h +++ b/source/modules/asura-box2d/Box2DModule.h @@ -1,7 +1,7 @@  #ifndef __ASURA_BOX2D_MODULE_H__  #define __ASURA_BOX2D_MODULE_H__ -#include <asura-utils/Module.h> +#include <asura-base/Module.h>  namespace AsuraEngine  { diff --git a/source/modules/asura-box2d/Physics/Body.h b/source/modules/asura-box2d/Physics/Body.h index ecf5bab..d7e79d5 100644 --- a/source/modules/asura-box2d/Physics/Body.h +++ b/source/modules/asura-box2d/Physics/Body.h @@ -3,8 +3,8 @@  #include <Box2D/Box2D.h> -#include <asura-utils/Classes.h> -#include <asura-utils/Scripting/Portable.hpp> +#include <asura-base/Classes.h> +#include <asura-base/Scripting/Scripting.h>  namespace_begin(AsuraEngine)  namespace_begin(Physics) diff --git a/source/modules/asura-box2d/Physics/ChainShape.h b/source/modules/asura-box2d/Physics/ChainShape.h index 9a88263..2403587 100644 --- a/source/modules/asura-box2d/Physics/ChainShape.h +++ b/source/modules/asura-box2d/Physics/ChainShape.h @@ -3,8 +3,8 @@  #include <Box2D/Collision/Shapes/b2ChainShape.h> -#include <asura-utils/Scripting/Portable.hpp> -#include <asura-utils/Classes.h> +#include <asura-base/Scripting/Scripting.h> +#include <asura-base/Classes.h>  namespace_begin(AsuraEngine)  namespace_begin(Physics) diff --git a/source/modules/asura-box2d/Physics/Fixture.h b/source/modules/asura-box2d/Physics/Fixture.h index a9f0fc7..69f0153 100644 --- a/source/modules/asura-box2d/Physics/Fixture.h +++ b/source/modules/asura-box2d/Physics/Fixture.h @@ -1,7 +1,7 @@  #ifndef _ASRUA_ENGINE_FIXTURE_H_  #define _ASRUA_ENGINE_FIXTURE_H_ -#include <asura-utils/Classes.h> +#include <asura-base/Classes.h>  namespace_begin(AsuraEngine)  namespace_begin(Physics) diff --git a/source/modules/asura-box2d/Physics/World.h b/source/modules/asura-box2d/Physics/World.h index 0419275..a156c79 100644 --- a/source/modules/asura-box2d/Physics/World.h +++ b/source/modules/asura-box2d/Physics/World.h @@ -1,8 +1,8 @@  #ifndef __ASURA_BOX2D_WORLD_H__  #define __ASURA_BOX2D_WORLD_H__ -#include <asura-utils/Classes.h> -#include <asura-utils/Scripting/Portable.hpp> +#include <asura-base/Classes.h> +#include <asura-base/Scripting/Scripting.h>  namespace_begin(AsuraEngine)  namespace_begin(Physics) diff --git a/source/modules/asura-box2d/physics/body.h b/source/modules/asura-box2d/physics/body.h index ecf5bab..d7e79d5 100644 --- a/source/modules/asura-box2d/physics/body.h +++ b/source/modules/asura-box2d/physics/body.h @@ -3,8 +3,8 @@  #include <Box2D/Box2D.h> -#include <asura-utils/Classes.h> -#include <asura-utils/Scripting/Portable.hpp> +#include <asura-base/Classes.h> +#include <asura-base/Scripting/Scripting.h>  namespace_begin(AsuraEngine)  namespace_begin(Physics) diff --git a/source/modules/asura-box2d/physics/fixture.h b/source/modules/asura-box2d/physics/fixture.h index a9f0fc7..69f0153 100644 --- a/source/modules/asura-box2d/physics/fixture.h +++ b/source/modules/asura-box2d/physics/fixture.h @@ -1,7 +1,7 @@  #ifndef _ASRUA_ENGINE_FIXTURE_H_  #define _ASRUA_ENGINE_FIXTURE_H_ -#include <asura-utils/Classes.h> +#include <asura-base/Classes.h>  namespace_begin(AsuraEngine)  namespace_begin(Physics) diff --git a/source/modules/asura-box2d/physics/world.h b/source/modules/asura-box2d/physics/world.h index 0419275..a156c79 100644 --- a/source/modules/asura-box2d/physics/world.h +++ b/source/modules/asura-box2d/physics/world.h @@ -1,8 +1,8 @@  #ifndef __ASURA_BOX2D_WORLD_H__  #define __ASURA_BOX2D_WORLD_H__ -#include <asura-utils/Classes.h> -#include <asura-utils/Scripting/Portable.hpp> +#include <asura-base/Classes.h> +#include <asura-base/Scripting/Scripting.h>  namespace_begin(AsuraEngine)  namespace_begin(Physics) diff --git a/source/modules/asura-core/Application.h b/source/modules/asura-core/Application.h index 696d125..cccd6f7 100644 --- a/source/modules/asura-core/Application.h +++ b/source/modules/asura-core/Application.h @@ -1,9 +1,9 @@  #ifndef _ASURA_ENGINE_APPLICATION_H_  #define _ASURA_ENGINE_APPLICATION_H_ -#include <asura-utils/Scripting/Portable.hpp> -#include <asura-utils/Module.h> -#include <asura-utils/Classes.h> +#include <asura-base/Scripting/Scripting.h> +#include <asura-base/Module.h> +#include <asura-base/Classes.h>  #include <queue>  #include "CoreConfig.h" diff --git a/source/modules/asura-core/CoreModule.h b/source/modules/asura-core/CoreModule.h index 1781885..d592f42 100644 --- a/source/modules/asura-core/CoreModule.h +++ b/source/modules/asura-core/CoreModule.h @@ -1,8 +1,8 @@  #ifndef _ASURA_CORE_MODULE_H_  #define _ASURA_CORE_MODULE_H_ -#include <asura-utils/Module.h> -#include <asura-utils/Classes.h> +#include <asura-base/Module.h> +#include <asura-base/Classes.h>  #include "graphics/image.h"  #include "graphics/texture.h" diff --git a/source/modules/asura-core/Font/String.hpp b/source/modules/asura-core/Font/String.hpp index 13a8b2d..845a1d5 100644 --- a/source/modules/asura-core/Font/String.hpp +++ b/source/modules/asura-core/Font/String.hpp @@ -1,7 +1,7 @@  //#ifndef _ASURA_ENGINE_STRING_H_  //#define _ASURA_ENGINE_STRING_H_  // -//#include <asura-utils/type.h> +//#include <asura-base/type.h>  //  //#include <iterator>  //#include <locale> diff --git a/source/modules/asura-core/Graphics/BlendMode.h b/source/modules/asura-core/Graphics/BlendMode.h index 7a31eed..fb17b45 100644 --- a/source/modules/asura-core/Graphics/BlendMode.h +++ b/source/modules/asura-core/Graphics/BlendMode.h @@ -1,7 +1,7 @@  #ifndef _ASURA_ENGINE_BLEND_MODE_H_  #define _ASURA_ENGINE_BLEND_MODE_H_ -#include <asura-utils/Classes.h> +#include <asura-base/Classes.h>  namespace_begin(AsuraEngine)  namespace_begin(Graphics) diff --git a/source/modules/asura-core/Graphics/Canvas.h b/source/modules/asura-core/Graphics/Canvas.h index 0ec55bc..de02b9d 100644 --- a/source/modules/asura-core/Graphics/Canvas.h +++ b/source/modules/asura-core/Graphics/Canvas.h @@ -1,10 +1,10 @@  #ifndef _ASURA_ENGINE_CANVAS_H_  #define _ASURA_ENGINE_CANVAS_H_ -#include <asura-utils/Scripting/Portable.hpp> -#include <asura-utils/Math/Rect.hpp> -#include <asura-utils/Math/Vector2.hpp> -#include <asura-utils/Exceptions/Exception.h> +#include <asura-base/Scripting/Scripting.h> +#include <asura-base/Math/Rect.hpp> +#include <asura-base/Math/Vector2.hpp> +#include <asura-base/Exception.h>  #include "GfxDevice.h"  #include "Texture.h" diff --git a/source/modules/asura-core/Graphics/Color.h b/source/modules/asura-core/Graphics/Color.h index a16f17d..c81b601 100644 --- a/source/modules/asura-core/Graphics/Color.h +++ b/source/modules/asura-core/Graphics/Color.h @@ -1,8 +1,8 @@  #ifndef _ASURA_ENGINE_COLOR_H_  #define _ASURA_ENGINE_COLOR_H_ -#include <asura-utils/Scripting/Portable.hpp> -#include <asura-utils/Classes.h> +#include <asura-base/Scripting/Scripting.h> +#include <asura-base/Classes.h>  #include "../CoreConfig.h" diff --git a/source/modules/asura-core/Graphics/Color32.h b/source/modules/asura-core/Graphics/Color32.h index aa445fe..4dbfe2d 100644 --- a/source/modules/asura-core/Graphics/Color32.h +++ b/source/modules/asura-core/Graphics/Color32.h @@ -1,8 +1,8 @@  #ifndef _ASURA_ENGINE_COLOR32_H__  #define _ASURA_ENGINE_COLOR32_H__ -#include <asura-utils/Classes.h> -#include <asura-utils/Scripting/Portable.hpp> +#include <asura-base/Classes.h> +#include <asura-base/Scripting/Scripting.h>  #include "../CoreConfig.h" diff --git a/source/modules/asura-core/Graphics/DrawInfo.h b/source/modules/asura-core/Graphics/DrawInfo.h index 9042f2f..0082102 100644 --- a/source/modules/asura-core/Graphics/DrawInfo.h +++ b/source/modules/asura-core/Graphics/DrawInfo.h @@ -1,7 +1,7 @@  #ifndef _ASURA_ENGINE_DRAWINFO_H_  #define _ASURA_ENGINE_DRAWINFO_H_ -#include <asura-utils/Classes.h> +#include <asura-base/Classes.h>  namespace_begin(AsuraEngine)  namespace_begin(Graphics) diff --git a/source/modules/asura-core/Graphics/GPUBuffer.h b/source/modules/asura-core/Graphics/GPUBuffer.h index 0aa3c29..565db17 100644 --- a/source/modules/asura-core/Graphics/GPUBuffer.h +++ b/source/modules/asura-core/Graphics/GPUBuffer.h @@ -1,9 +1,9 @@  #ifndef _ASURA_GPU_BUFFER_H_  #define _ASURA_GPU_BUFFER_H_ -#include <asura-utils/Scripting/Portable.hpp> -#include <asura-utils/Exceptions/Exception.h> -#include <asura-utils/type.h> +#include <asura-base/Scripting/Scripting.h> +#include <asura-base/Exception.h> +#include <asura-base/type.h>  #include "GfxDevice.h" diff --git a/source/modules/asura-core/Graphics/GfxDevice.cpp b/source/modules/asura-core/Graphics/GfxDevice.cpp index ea95f54..529a76c 100644 --- a/source/modules/asura-core/Graphics/GfxDevice.cpp +++ b/source/modules/asura-core/Graphics/GfxDevice.cpp @@ -1,4 +1,4 @@ -#include <asura-utils/type.h> +#include <asura-base/type.h>  #include "../CoreConfig.h" diff --git a/source/modules/asura-core/Graphics/GfxDevice.h b/source/modules/asura-core/Graphics/GfxDevice.h index 02c7392..2b105df 100644 --- a/source/modules/asura-core/Graphics/GfxDevice.h +++ b/source/modules/asura-core/Graphics/GfxDevice.h @@ -5,10 +5,10 @@  #include <glad/glad.h> -#include <asura-utils/Scripting/Portable.hpp> -#include <asura-utils/Math/Rect.hpp> -#include <asura-utils/Math/matrix44.h> -#include <asura-utils/Math/vector4.h> +#include <asura-base/Scripting/Scripting.h> +#include <asura-base/Math/Rect.hpp> +#include <asura-base/Math/matrix44.h> +#include <asura-base/Math/vector4.h>  #include "Color.h"  #include "MatrixStack.h" diff --git a/source/modules/asura-core/Graphics/GraphicsHelper.h b/source/modules/asura-core/Graphics/GraphicsHelper.h index b93756a..3125292 100644 --- a/source/modules/asura-core/Graphics/GraphicsHelper.h +++ b/source/modules/asura-core/Graphics/GraphicsHelper.h @@ -1,7 +1,7 @@  #ifndef _ASURA_GRAPHICS_HELPER_H_  #define _ASURA_GRAPHICS_HELPER_H_ -#include <asura-utils/Classes.h> +#include <asura-base/Classes.h>  namespace_begin(AsuraEngine)  namespace_begin(Graphics) diff --git a/source/modules/asura-core/Graphics/Image.cpp b/source/modules/asura-core/Graphics/Image.cpp index d2b2ec9..36d2478 100644 --- a/source/modules/asura-core/Graphics/Image.cpp +++ b/source/modules/asura-core/Graphics/Image.cpp @@ -1,4 +1,4 @@ -#include <asura-utils/Exceptions/Exception.h> +#include <asura-base/Exception.h>  #include "../CoreConfig.h" @@ -6,7 +6,7 @@  #include "Image.h"  #include "GfxDevice.h" -using namespace AEIO; +using namespace AEFileSystem;  using namespace AEImage;  namespace_begin(AsuraEngine) diff --git a/source/modules/asura-core/Graphics/Image.h b/source/modules/asura-core/Graphics/Image.h index 5cbfe23..a76d06f 100644 --- a/source/modules/asura-core/Graphics/Image.h +++ b/source/modules/asura-core/Graphics/Image.h @@ -2,12 +2,12 @@  #define _ASURA_ENGINE_IMAGE_H_  // asura modules  -#include <asura-utils/Math/Rect.hpp> -#include <asura-utils/Math/Vector2.hpp> -#include <asura-utils/Scripting/Portable.hpp> -#include <asura-utils/IO/Renewable.h> -#include <asura-utils/Stringmap.hpp> -#include <asura-utils/Manager.hpp> +#include <asura-base/Math/Rect.hpp> +#include <asura-base/Math/Vector2.hpp> +#include <asura-base/Scripting/Scripting.h> +#include <asura-base/FileSystem/Renewable.h> +#include <asura-base/Utilities/Stringmap.hpp> +#include <asura-base/Manager.hpp>  // module  #include "../Image/ImageData.h" diff --git a/source/modules/asura-core/Graphics/IndexBuffer.h b/source/modules/asura-core/Graphics/IndexBuffer.h index 73a6f9b..b7886b7 100644 --- a/source/modules/asura-core/Graphics/IndexBuffer.h +++ b/source/modules/asura-core/Graphics/IndexBuffer.h @@ -1,7 +1,7 @@  #ifndef _ASURA_INDEX_BUFFER_H_  #define _ASURA_INDEX_BUFFER_H_ -#include <asura-utils/Scripting/Portable.hpp> +#include <asura-base/Scripting/Scripting.h>  #include "GPUBuffer.h" diff --git a/source/modules/asura-core/Graphics/MatrixStack.h b/source/modules/asura-core/Graphics/MatrixStack.h index 867011e..8dd56bf 100644 --- a/source/modules/asura-core/Graphics/MatrixStack.h +++ b/source/modules/asura-core/Graphics/MatrixStack.h @@ -1,9 +1,9 @@  #ifndef _ASURA_MATRIX_STACK_H_  #define _ASURA_MATRIX_STACK_H_ -#include <asura-utils/Type.h> -#include <asura-utils/Math/Matrix44.h> -#include <asura-utils/Classes.h> +#include <asura-base/Type.h> +#include <asura-base/Math/Matrix44.h> +#include <asura-base/Classes.h>  namespace_begin(AsuraEngine)  namespace_begin(Graphics) diff --git a/source/modules/asura-core/Graphics/Mesh2D.h b/source/modules/asura-core/Graphics/Mesh2D.h index 1546765..7a0f62e 100644 --- a/source/modules/asura-core/Graphics/Mesh2D.h +++ b/source/modules/asura-core/Graphics/Mesh2D.h @@ -5,8 +5,8 @@  #include <vector>  // asura modules -#include <asura-utils/Scripting/Portable.hpp> -#include <asura-utils/Math/Vector2.hpp> +#include <asura-base/Scripting/Scripting.h> +#include <asura-base/Math/Vector2.hpp>  // module   #include "../Mesh/Mesh2dData.h" diff --git a/source/modules/asura-core/Graphics/RenderState.h b/source/modules/asura-core/Graphics/RenderState.h index 5dcf12d..23804d8 100644 --- a/source/modules/asura-core/Graphics/RenderState.h +++ b/source/modules/asura-core/Graphics/RenderState.h @@ -1,8 +1,8 @@  #ifndef _ASURA_ENGINE_RENDER_STATE_H_  #define _ASURA_ENGINE_RENDER_STATE_H_ -#include <asura-utils/Math/Vector2.hpp> -#include <asura-utils/Math/Transform.h> +#include <asura-base/Math/Vector2.hpp> +#include <asura-base/Math/Transform.h>  #include "BlendMode.h" diff --git a/source/modules/asura-core/Graphics/RenderTarget.h b/source/modules/asura-core/Graphics/RenderTarget.h index bcd7276..ab09e35 100644 --- a/source/modules/asura-core/Graphics/RenderTarget.h +++ b/source/modules/asura-core/Graphics/RenderTarget.h @@ -1,9 +1,9 @@  #ifndef _ASURA_ENGINE_RENDERTARGET_H_  #define _ASURA_ENGINE_RENDERTARGET_H_ -#include <asura-utils/Math/Vector2.hpp> -#include <asura-utils/Math/Rect.hpp> -#include <asura-utils/Scripting/Portable.hpp> +#include <asura-base/Math/Vector2.hpp> +#include <asura-base/Math/Rect.hpp> +#include <asura-base/Scripting/Scripting.h>  #include "Texture.h"  #include "Color.h" diff --git a/source/modules/asura-core/Graphics/Shader.cpp b/source/modules/asura-core/Graphics/Shader.cpp index 30e0161..329b3f1 100644 --- a/source/modules/asura-core/Graphics/Shader.cpp +++ b/source/modules/asura-core/Graphics/Shader.cpp @@ -1,4 +1,4 @@ -#include <asura-utils/Exceptions/Exception.h> +#include <asura-base/Exception.h>  #include "GfxDevice.h"  #include "Shader.h" diff --git a/source/modules/asura-core/Graphics/Shader.h b/source/modules/asura-core/Graphics/Shader.h index c96b99f..615b028 100644 --- a/source/modules/asura-core/Graphics/Shader.h +++ b/source/modules/asura-core/Graphics/Shader.h @@ -4,15 +4,15 @@  #include <map>  #include <string> -#include <asura-utils/Exceptions/Exception.h> -#include <asura-utils/Scripting/Portable.hpp> -#include <asura-utils/IO/Renewable.h> -#include <asura-utils/Math/Vector2.hpp> -#include <asura-utils/Math/vector3.hpp> -#include <asura-utils/Math/vector4.h> -#include <asura-utils/Math/matrix44.h> -#include <asura-utils/Stringmap.hpp> -#include <asura-utils/Manager.hpp> +#include <asura-base/Exception.h> +#include <asura-base/Scripting/Scripting.h> +#include <asura-base/FileSystem/Renewable.h> +#include <asura-base/Math/Vector2.hpp> +#include <asura-base/Math/vector3.hpp> +#include <asura-base/Math/vector4.h> +#include <asura-base/Math/matrix44.h> +#include <asura-base/Utilities/Stringmap.hpp> +#include <asura-base/Manager.hpp>  #include "GfxDevice.h"  #include "Color.h" @@ -30,7 +30,7 @@ namespace_begin(Graphics)  ///  class Shader ASURA_FINAL  	: public Scripting::Portable<Shader> -	, public AEIO::Renewable +	, public AEFileSystem::Renewable  {  public: diff --git a/source/modules/asura-core/Graphics/SpriteBatch.h b/source/modules/asura-core/Graphics/SpriteBatch.h index a98d1f4..30cb56c 100644 --- a/source/modules/asura-core/Graphics/SpriteBatch.h +++ b/source/modules/asura-core/Graphics/SpriteBatch.h @@ -1,7 +1,7 @@  #ifndef _ASURA_ENGINE_SPRITE_BATCH_H_  #define _ASURA_ENGINE_SPRITE_BATCH_H_ -#include <asura-utils/Scripting/Portable.hpp> +#include <asura-base/Scripting/Scripting.h>  #include "GPUBuffer.h" diff --git a/source/modules/asura-core/Graphics/Texture.cpp b/source/modules/asura-core/Graphics/Texture.cpp index bae0f7c..03f005d 100644 --- a/source/modules/asura-core/Graphics/Texture.cpp +++ b/source/modules/asura-core/Graphics/Texture.cpp @@ -1,4 +1,4 @@ -#include <asura-utils/Exceptions/Exception.h> +#include <asura-base/Exception.h>  #include "Texture.h" diff --git a/source/modules/asura-core/Graphics/Texture.h b/source/modules/asura-core/Graphics/Texture.h index 7d37c31..76b9a8f 100644 --- a/source/modules/asura-core/Graphics/Texture.h +++ b/source/modules/asura-core/Graphics/Texture.h @@ -1,8 +1,8 @@  #ifndef _ASURA_TEXTURE_H_  #define _ASURA_TEXTURE_H_ -#include <asura-utils/Math/Vector2.hpp> -#include <asura-utils/Math/Rect.hpp> +#include <asura-base/Math/Vector2.hpp> +#include <asura-base/Math/Rect.hpp>  #include "../CoreConfig.h" diff --git a/source/modules/asura-core/Graphics/VBO.h b/source/modules/asura-core/Graphics/VBO.h index 80f405f..f80991e 100644 --- a/source/modules/asura-core/Graphics/VBO.h +++ b/source/modules/asura-core/Graphics/VBO.h @@ -1,7 +1,7 @@  #ifndef _ASURA_ENGINE_VBO_H_  #define _ASURA_ENGINE_VBO_H_ -#include <asura-utils/Classes.h> +#include <asura-base/Classes.h>  namespace_begin(AsuraEngine)  namespace_begin(Graphics) diff --git a/source/modules/asura-core/Graphics/VertexBuffer.h b/source/modules/asura-core/Graphics/VertexBuffer.h index 83e9b09..0622388 100644 --- a/source/modules/asura-core/Graphics/VertexBuffer.h +++ b/source/modules/asura-core/Graphics/VertexBuffer.h @@ -1,7 +1,7 @@  #ifndef _ASURA_VERTEX_BUFFER_H_  #define _ASURA_VERTEX_BUFFER_H_ -#include <asura-utils/Scripting/Portable.hpp> +#include <asura-base/Scripting/Scripting.h>  #include "GPUBuffer.h" diff --git a/source/modules/asura-core/Image/ImageData.cpp b/source/modules/asura-core/Image/ImageData.cpp index c75166f..bbfd177 100644 --- a/source/modules/asura-core/Image/ImageData.cpp +++ b/source/modules/asura-core/Image/ImageData.cpp @@ -31,7 +31,7 @@ ImageData::~ImageData()  		delete[] pixels;  } -void ImageData::Decode(IO::DataBuffer& buffer) +void ImageData::Decode(FileSystem::DataBuffer& buffer)  {  	for (ImageDecoder* decoder : ImageDecoders)  	{ diff --git a/source/modules/asura-core/Image/ImageData.h b/source/modules/asura-core/Image/ImageData.h index cd2fe1a..2d70edc 100644 --- a/source/modules/asura-core/Image/ImageData.h +++ b/source/modules/asura-core/Image/ImageData.h @@ -3,11 +3,11 @@  #include <list> -#include <asura-utils/Scripting/Portable.hpp> -#include <asura-utils/IO/DecodedData.h> -#include <asura-utils/IO/DataBuffer.h> -#include <asura-utils/Threads/Thread.h> -#include <asura-utils/Threads/Mutex.h> +#include <asura-base/Scripting/Scripting.h> +#include <asura-base/FileSystem/DecodedData.h> +#include <asura-base/FileSystem/DataBuffer.h> +#include <asura-base/Threads/Thread.h> +#include <asura-base/Threads/Mutex.h>  #include "../Graphics/Texture.h"  #include "../Graphics/Color.h" @@ -19,7 +19,7 @@ class ImageDecoder;  class ImageData ASURA_FINAL  	: public Scripting::Portable<ImageData> -	, public AEIO::DecodedData +	, public AEFileSystem::DecodedData  {  public: @@ -29,7 +29,7 @@ public:  	ImageData();  	~ImageData(); -	void Decode(AEIO::DataBuffer& buffer) override; +	void Decode(AEFileSystem::DataBuffer& buffer) override;  	void Lock();  	void Unlock(); diff --git a/source/modules/asura-core/Image/ImageDecodeTask.h b/source/modules/asura-core/Image/ImageDecodeTask.h index 74ecf24..194ac3e 100644 --- a/source/modules/asura-core/Image/ImageDecodeTask.h +++ b/source/modules/asura-core/Image/ImageDecodeTask.h @@ -1,9 +1,9 @@  #ifndef _ASURA_IMAGE_DECODE_TASK_H_  #define _ASURA_IMAGE_DECODE_TASK_H_ -#include <asura-utils/Threads/task.h> -#include <asura-utils/Scripting/Portable.hpp> -#include <asura-utils/Classes.h> +#include <asura-base/Threads/task.h> +#include <asura-base/Scripting/Scripting.h> +#include <asura-base/Classes.h>  namespace_begin(AsuraEngine)  namespace_begin(Image) diff --git a/source/modules/asura-core/Image/ImageDecoder.h b/source/modules/asura-core/Image/ImageDecoder.h index 7de92d6..6cea8fd 100644 --- a/source/modules/asura-core/Image/ImageDecoder.h +++ b/source/modules/asura-core/Image/ImageDecoder.h @@ -1,7 +1,7 @@  #ifndef _ASURA_ENGINE_IMAGE_DECODER_H_  #define _ASURA_ENGINE_IMAGE_DECODER_H_ -#include <asura-utils/IO/DataBuffer.h> +#include <asura-base/FileSystem/DataBuffer.h>  #include "ImageData.h" @@ -18,12 +18,12 @@ public:  	///  	/// жڴǷñdecoderѹ  	/// -	virtual bool CanDecode(AEIO::DataBuffer& input) = 0; +	virtual bool CanDecode(AEFileSystem::DataBuffer& input) = 0;  	///  	/// һڴ棬һѹImage dataѹʧܷnullptr  	/// -	virtual void Decode(AEIO::DataBuffer& input, ImageData& target) = 0; +	virtual void Decode(AEFileSystem::DataBuffer& input, ImageData& target) = 0;  }; diff --git a/source/modules/asura-core/Image/PngDecoder.cpp b/source/modules/asura-core/Image/PngDecoder.cpp index 618c16e..b314561 100644 --- a/source/modules/asura-core/Image/PngDecoder.cpp +++ b/source/modules/asura-core/Image/PngDecoder.cpp @@ -3,12 +3,12 @@  namespace_begin(AsuraEngine)  namespace_begin(Image) -bool PNGDecoder::CanDecode(AEIO::DataBuffer& buffer) +bool PNGDecoder::CanDecode(AEFileSystem::DataBuffer& buffer)  {  	return false;  } -void PNGDecoder::Decode(AEIO::DataBuffer& buffer, ImageData& data) +void PNGDecoder::Decode(AEFileSystem::DataBuffer& buffer, ImageData& data)  {  } diff --git a/source/modules/asura-core/Image/PngDecoder.h b/source/modules/asura-core/Image/PngDecoder.h index b6ea3ba..3b2a39c 100644 --- a/source/modules/asura-core/Image/PngDecoder.h +++ b/source/modules/asura-core/Image/PngDecoder.h @@ -13,9 +13,9 @@ class PNGDecoder ASURA_FINAL: public ImageDecoder  {  public: -	bool CanDecode(AEIO::DataBuffer& buffer) override; +	bool CanDecode(AEFileSystem::DataBuffer& buffer) override; -	void Decode(AEIO::DataBuffer& buffer, ImageData& data) override; +	void Decode(AEFileSystem::DataBuffer& buffer, ImageData& data) override;  }; diff --git a/source/modules/asura-core/Image/StbDecoder.cpp b/source/modules/asura-core/Image/StbDecoder.cpp index 8d3537c..101b148 100644 --- a/source/modules/asura-core/Image/StbDecoder.cpp +++ b/source/modules/asura-core/Image/StbDecoder.cpp @@ -1,4 +1,4 @@ -#include <asura-utils/Exceptions/Exception.h> +#include <asura-base/Exception.h>  #include "StbDecoder.h" @@ -10,7 +10,7 @@ using namespace AEGraphics;  namespace_begin(AsuraEngine)  namespace_begin(Image) -bool STBDecoder::CanDecode(IO::DataBuffer& buffer) +bool STBDecoder::CanDecode(FileSystem::DataBuffer& buffer)  {  	int w = 0;  	int h = 0; @@ -21,7 +21,7 @@ bool STBDecoder::CanDecode(IO::DataBuffer& buffer)  	return status == 1 && w > 0 && h > 0;  } -void STBDecoder::Decode(IO::DataBuffer& db, ImageData& imageData) +void STBDecoder::Decode(FileSystem::DataBuffer& db, ImageData& imageData)  {  	const stbi_uc *buffer = (const stbi_uc *)db.GetData();  	// databufferݳ diff --git a/source/modules/asura-core/Image/StbDecoder.h b/source/modules/asura-core/Image/StbDecoder.h index a86073a..23e8c38 100644 --- a/source/modules/asura-core/Image/StbDecoder.h +++ b/source/modules/asura-core/Image/StbDecoder.h @@ -14,9 +14,9 @@ class STBDecoder ASURA_FINAL  {  public: -	bool CanDecode(AEIO::DataBuffer& buffer) override; +	bool CanDecode(AEFileSystem::DataBuffer& buffer) override; -	void Decode(AEIO::DataBuffer& buffer, ImageData& data) override; +	void Decode(AEFileSystem::DataBuffer& buffer, ImageData& data) override;  }; diff --git a/source/modules/asura-core/Image/binding/_image_data.cpp b/source/modules/asura-core/Image/binding/_image_data.cpp index 77f3a96..375f854 100644 --- a/source/modules/asura-core/Image/binding/_image_data.cpp +++ b/source/modules/asura-core/Image/binding/_image_data.cpp @@ -1,11 +1,11 @@ -#include <asura-utils/Threads/Thread.h> -#include <asura-utils/IO/DataBuffer.h> +#include <asura-base/Threads/Thread.h> +#include <asura-base/FileSystem/DataBuffer.h>  #include "../ImageData.h"  using namespace std;  using namespace AEThreading; -using namespace AEIO; +using namespace AEFileSystem;  namespace_begin(AsuraEngine)  namespace_begin(Image) diff --git a/source/modules/asura-core/Input/Button.h b/source/modules/asura-core/Input/Button.h index 5c3c0de..528063d 100644 --- a/source/modules/asura-core/Input/Button.h +++ b/source/modules/asura-core/Input/Button.h @@ -1,7 +1,7 @@  #ifndef __BUTTON_H__  #define __BUTTON_H__ -#include <asura-utils/Classes.h> +#include <asura-base/Classes.h>  namespace_begin(AsuraEngine)  namespace_begin(Input) diff --git a/source/modules/asura-core/Input/InputAxis.h b/source/modules/asura-core/Input/InputAxis.h index 3052f0b..9f721d7 100644 --- a/source/modules/asura-core/Input/InputAxis.h +++ b/source/modules/asura-core/Input/InputAxis.h @@ -1,7 +1,7 @@  #ifndef _ASURA_ENGINE_INPUT_AXIS_H_  #define _ASURA_ENGINE_INPUT_AXIS_H_ -#include <asura-utils/Classes.h> +#include <asura-base/Classes.h>  namespace_begin(AsuraEngine)  namespace_begin(Input) diff --git a/source/modules/asura-core/Input/InputDevice.h b/source/modules/asura-core/Input/InputDevice.h index 0ecce99..2b3ff9b 100644 --- a/source/modules/asura-core/Input/InputDevice.h +++ b/source/modules/asura-core/Input/InputDevice.h @@ -1,9 +1,11 @@  #ifndef _ASURA_ENGINE_INPUT_BASE_H_  #define _ASURA_ENGINE_INPUT_BASE_H_ -#include <asura-utils/Math/Vector2.hpp> -#include <asura-utils/Scripting/Portable.hpp> -#include <asura-utils/Singleton.hpp> +#include <asura-base/Math/Vector2.hpp> +#include <asura-base/Scripting/Scripting.h> +#include <asura-base/Singleton.hpp> + +#include <windows.h>  #include "../CoreConfig.h" @@ -14,28 +16,63 @@  namespace_begin(AsuraEngine)  namespace_begin(Input) -class InputDevice +class InputDevice ASURA_FINAL  {  public:   	InputDevice(); -	virtual ~InputDevice(); +	~InputDevice(); + +#if ASURA_EDITOR  + +	bool Open(HWND window); +	void Close(); + +	bool ToggleFullscreen(bool fullscreen, HWND window); + +	bool Process(bool discard); +	LRESULT OnKey(HWND window, UINT message, WPARAM wParam, LPARAM lParam); +	LRESULT OnInput(HWND window, UINT message, WPARAM wParam, LPARAM lParam); +	LRESULT OnDeviceChange(LPCWSTR name, bool add); + +	static bool ConvertPositionToClientAreaCoord(HWND activeWindow, POINT position, AEMath::Vector2f& newPos); + +#elif ASURA_RUNNER  + +	bool Open();  +	void Close(); + +#endif + +	bool Activate(bool active); + +	bool GetJoystickNames(std::vector<std::string> &names);  protected:  -	virtual bool UpdateState(); +	bool UpdateState();  	MouseState m_Mouse;  	KeyboardState m_Keyboard;  	JoystickState m_Joysticks; -private:  +private:  	bool UpdateMousePosition();  }; -//bool ConvertPositionToClientAreaCoord(); +extern InputDevice g_InputDevice; + +#if ASURA_EDITOR  + +bool ConvertPositionToClientAreaCoord(); + +#elif ASURA_RUNNER  + +bool ConvertPositionToClientAreaCoord(); + +#endif  namespace_end  namespace_end diff --git a/source/modules/asura-core/Input/InputEvent.h b/source/modules/asura-core/Input/InputEvent.h index d7643b6..c643b75 100644 --- a/source/modules/asura-core/Input/InputEvent.h +++ b/source/modules/asura-core/Input/InputEvent.h @@ -2,8 +2,8 @@  #define _ASURA_ENGINE_INPUT_EVENT_H_  #include <asura-base/Configure.h> -#include <asura-utils/Classes.h> -#include <asura-utils/Math/Vector2.hpp> +#include <asura-base/Classes.h> +#include <asura-base/Math/Vector2.hpp>  #include <windows.h>  #include <vector> diff --git a/source/modules/asura-core/Input/InputManager.cpp b/source/modules/asura-core/Input/InputManager.cpp index fe49c29..cec1b36 100644 --- a/source/modules/asura-core/Input/InputManager.cpp +++ b/source/modules/asura-core/Input/InputManager.cpp @@ -17,69 +17,85 @@ void InputManager::Reset()  bool InputManager::GetButton(const std::string& name)  { +	return 0;  }  bool InputManager::GetButtonDown(const std::string& name)  { +	return 0;  }  bool InputManager::GetButtonUp(const std::string& name)  { +	return 0;  }  bool InputManager::HasAxisOrButton(const std::string& name)  { +	return 0;  }  float InputManager::GetAxis(const std::string& name)  { +	return 0;  }  float InputManager::GetAxisRaw(const std::string& name)  { +	return 0;  }  bool InputManager::GetMouseButton(int mouseBut)  { +	return 0;  }  bool InputManager::GetMouseButtonState(int mouseBut)  { +	return 0;  }  bool InputManager::GetMouseButtonDown(int mouseBut)  { +	return 0;  }  bool InputManager::GetMouseButtonUp(int mouseBut)  { +	return 0;  }  bool InputManager::GetKey(int key)  { +	return 0;  }  bool InputManager::GetKeyDown(int key)  { +	return 0;  }  bool InputManager::GetKeyUp(int key)  { +	return 0;  }  const AEMath::Vector2f& InputManager::GetMouseDelta()  { +	return m_MouseDelta;  }  const AEMath::Vector2f& InputManager::GetMousePosition()  { +	return m_MousePos;  }  float InputManager::GetJoystickPosition()  { +	return 0;  }  void  InputManager::setJoystickPosition() diff --git a/source/modules/asura-core/Input/InputManager.h b/source/modules/asura-core/Input/InputManager.h index bbdafd8..3c44745 100644 --- a/source/modules/asura-core/Input/InputManager.h +++ b/source/modules/asura-core/Input/InputManager.h @@ -1,11 +1,11 @@  #ifndef _ASURA_INPUT_MAMANGER_H_  #define _ASURA_INPUT_MAMANGER_H_ -#include <asura-utils/Math/Vector2.hpp> -#include <asura-utils/Scripting/Portable.hpp> -#include <asura-utils/Singleton.hpp> -#include <asura-utils/Classes.h> -#include <asura-utils/dynamic_bitset.h> +#include <asura-base/Math/Vector2.hpp> +#include <asura-base/Scripting/Scripting.h> +#include <asura-base/Singleton.hpp> +#include <asura-base/Classes.h> +#include <asura-base/Utilities/dynamic_bitset.h>  #include <string>  #include <vector> diff --git a/source/modules/asura-core/Input/JoystickState.h b/source/modules/asura-core/Input/JoystickState.h index 42d0a79..e97e235 100644 --- a/source/modules/asura-core/Input/JoystickState.h +++ b/source/modules/asura-core/Input/JoystickState.h @@ -1,7 +1,7 @@  #ifndef _ASURA_JOYSTICKSTATE_H_  #define _ASURA_JOYSTICKSTATE_H_ -#include <asura-utils/Classes.h> +#include <asura-base/Classes.h>  namespace_begin(AsuraEngine)  namespace_begin(Input) diff --git a/source/modules/asura-core/Input/MouseState.h b/source/modules/asura-core/Input/MouseState.h index 1192a34..6b44070 100644 --- a/source/modules/asura-core/Input/MouseState.h +++ b/source/modules/asura-core/Input/MouseState.h @@ -1,7 +1,7 @@  #ifndef _ASURA_MOUSESTATE_H_  #define _ASURA_MOUSESTATE_H_ -#include <asura-utils/Classes.h> +#include <asura-base/Classes.h>  namespace_begin(AsuraEngine)  namespace_begin(Input) diff --git a/source/modules/asura-core/Mesh/Am2Handler.h b/source/modules/asura-core/Mesh/Am2Handler.h index 8bd0612..ff5dbfa 100644 --- a/source/modules/asura-core/Mesh/Am2Handler.h +++ b/source/modules/asura-core/Mesh/Am2Handler.h @@ -16,11 +16,11 @@ public:  	AM2Handler();  	~AM2Handler(); -	bool CanDecode(AEIO::DataBuffer& input) override; +	bool CanDecode(AEFileSystem::DataBuffer& input) override; -	void Decode(AEIO::DataBuffer& input, Mesh2DData& target) override;  +	void Decode(AEFileSystem::DataBuffer& input, Mesh2DData& target) override;  -	void Encode(Mesh2DData& input, AEIO::DataBuffer& target) override; +	void Encode(Mesh2DData& input, AEFileSystem::DataBuffer& target) override;  }; diff --git a/source/modules/asura-core/Mesh/Mesh2DData.h b/source/modules/asura-core/Mesh/Mesh2DData.h index 1144846..3e30a06 100644 --- a/source/modules/asura-core/Mesh/Mesh2DData.h +++ b/source/modules/asura-core/Mesh/Mesh2DData.h @@ -5,9 +5,9 @@  #include <vector>  // asura modules -#include <asura-utils/Scripting/Portable.hpp> -#include <asura-utils/Math/Vector2.hpp> -#include <asura-utils/IO/DecodedData.h> +#include <asura-base/Scripting/Scripting.h> +#include <asura-base/Math/Vector2.hpp> +#include <asura-base/FileSystem/DecodedData.h>  // module  #include "../Graphics/Color.h" @@ -30,7 +30,7 @@ struct Vertex  /// meshĶݺ  ///  class Mesh2DData -	: AEIO::DecodedData +	: AEFileSystem::DecodedData  	, AEScripting::Portable<Mesh2DData>  {  public: @@ -45,7 +45,7 @@ public:  		MESH2D_COMPONENT_TEXCOORD3,  	}; -	void Decode(AEIO::DataBuffer& buffer) override; +	void Decode(AEFileSystem::DataBuffer& buffer) override;  private: diff --git a/source/modules/asura-core/Mesh/Mesh2DHandler.h b/source/modules/asura-core/Mesh/Mesh2DHandler.h index e50ace8..9ddb724 100644 --- a/source/modules/asura-core/Mesh/Mesh2DHandler.h +++ b/source/modules/asura-core/Mesh/Mesh2DHandler.h @@ -1,8 +1,8 @@  #ifndef _ASURA_MESH2D_HANDLER_H__  #define _ASURA_MESH2D_HANDLER_H__ -#include <asura-utils/IO/DataBuffer.h> -#include <asura-utils/Type.h> +#include <asura-base/FileSystem/DataBuffer.h> +#include <asura-base/Type.h>  #include "Mesh2dData.h" @@ -18,11 +18,11 @@ public:  	Mesh2DHandler() {};  	virtual ~Mesh2DHandler() {}; -	virtual bool CanDecode(AEIO::DataBuffer& input) = 0; +	virtual bool CanDecode(AEFileSystem::DataBuffer& input) = 0; -	virtual void Decode(AEIO::DataBuffer& input, Mesh2DData& target) = 0; +	virtual void Decode(AEFileSystem::DataBuffer& input, Mesh2DData& target) = 0; -	virtual void Encode(Mesh2DData& input, AEIO::DataBuffer& target) = 0; +	virtual void Encode(Mesh2DData& input, AEFileSystem::DataBuffer& target) = 0;  }; diff --git a/source/modules/asura-core/Threads/Channel.h b/source/modules/asura-core/Threads/Channel.h index 01b9ded..901564f 100644 --- a/source/modules/asura-core/Threads/Channel.h +++ b/source/modules/asura-core/Threads/Channel.h @@ -1,8 +1,8 @@  #ifndef _ASURA_THREAD_CHANNEL_H_  #define _ASURA_THREAD_CHANNEL_H_ -#include <asura-utils/Scripting/Portable.hpp> -#include <asura-utils/Classes.h> +#include <asura-base/Scripting/Scripting.h> +#include <asura-base/Classes.h>  namespace_begin(AsuraEngine)  namespace_begin(Threads) diff --git a/source/modules/asura-core/Threads/ThreadEx.cpp b/source/modules/asura-core/Threads/ThreadEx.cpp index cc8107c..cec5ba7 100644 --- a/source/modules/asura-core/Threads/ThreadEx.cpp +++ b/source/modules/asura-core/Threads/ThreadEx.cpp @@ -1,4 +1,4 @@ -#include <asura-utils/Classes.h> +#include <asura-base/Classes.h>  #include "ThreadEx.h" diff --git a/source/modules/asura-core/Threads/ThreadEx.h b/source/modules/asura-core/Threads/ThreadEx.h index 53600a6..ec597c5 100644 --- a/source/modules/asura-core/Threads/ThreadEx.h +++ b/source/modules/asura-core/Threads/ThreadEx.h @@ -1,8 +1,8 @@  #ifndef _ASURA_THREAD_EX_H_  #define _ASURA_THREAD_EX_H_ -#include <asura-utils/Scripting/Portable.hpp> -#include <asura-utils/Threads/Thread.h> +#include <asura-base/Scripting/Scripting.h> +#include <asura-base/Threads/Thread.h>  namespace_begin(AsuraEngine)  namespace_begin(Threads) diff --git a/source/modules/asura-core/Type.h b/source/modules/asura-core/Type.h deleted file mode 100644 index 39880e2..0000000 --- a/source/modules/asura-core/Type.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef _ASURA_ENGINE_TYPE_H_ -#define _ASURA_ENGINE_TYPE_H_ - -#include <stdint.h> - -namespace AsuraEngine -{ - -} - -#endif
\ No newline at end of file diff --git a/source/modules/asura-core/Window/Window.cpp b/source/modules/asura-core/Window/Window.cpp index adba7c9..d75b9a7 100644 --- a/source/modules/asura-core/Window/Window.cpp +++ b/source/modules/asura-core/Window/Window.cpp @@ -1,4 +1,4 @@ -#include <asura-utils/Exceptions/Exception.h> +#include <asura-base/Exception.h>  #include "window.h" diff --git a/source/modules/asura-core/Window/Window.h b/source/modules/asura-core/Window/Window.h index f5498c1..0f2850b 100644 --- a/source/modules/asura-core/Window/Window.h +++ b/source/modules/asura-core/Window/Window.h @@ -1,9 +1,9 @@  #ifndef _ASURA_ENGINE_WINDOW_H_  #define _ASURA_ENGINE_WINDOW_H_ -#include <asura-utils/Scripting/Portable.hpp> -#include <asura-utils/Math/Vector2.hpp> -#include <asura-utils/Singleton.hpp> +#include <asura-base/Scripting/Scripting.h> +#include <asura-base/Math/Vector2.hpp> +#include <asura-base/Singleton.hpp>  #include "../Graphics/Image.h"  #include "../Graphics/RenderState.h" diff --git a/source/modules/asura-core/Window/WindowImplSDL.cpp b/source/modules/asura-core/Window/WindowImplSDL.cpp index 3cbad70..23b2aed 100644 --- a/source/modules/asura-core/Window/WindowImplSDL.cpp +++ b/source/modules/asura-core/Window/WindowImplSDL.cpp @@ -4,7 +4,7 @@  #include <SDL2/SDL.h> -#include <asura-utils/Exceptions/Exception.h> +#include <asura-base/Exception.h>  #include "WindowImplSDL.h" diff --git a/source/modules/asura-core/application.h b/source/modules/asura-core/application.h index 696d125..cccd6f7 100644 --- a/source/modules/asura-core/application.h +++ b/source/modules/asura-core/application.h @@ -1,9 +1,9 @@  #ifndef _ASURA_ENGINE_APPLICATION_H_  #define _ASURA_ENGINE_APPLICATION_H_ -#include <asura-utils/Scripting/Portable.hpp> -#include <asura-utils/Module.h> -#include <asura-utils/Classes.h> +#include <asura-base/Scripting/Scripting.h> +#include <asura-base/Module.h> +#include <asura-base/Classes.h>  #include <queue>  #include "CoreConfig.h" diff --git a/source/modules/asura-core/font/string.hpp b/source/modules/asura-core/font/string.hpp index 13a8b2d..845a1d5 100644 --- a/source/modules/asura-core/font/string.hpp +++ b/source/modules/asura-core/font/string.hpp @@ -1,7 +1,7 @@  //#ifndef _ASURA_ENGINE_STRING_H_  //#define _ASURA_ENGINE_STRING_H_  // -//#include <asura-utils/type.h> +//#include <asura-base/type.h>  //  //#include <iterator>  //#include <locale> diff --git a/source/modules/asura-core/graphics/canvas.h b/source/modules/asura-core/graphics/canvas.h index 0ec55bc..de02b9d 100644 --- a/source/modules/asura-core/graphics/canvas.h +++ b/source/modules/asura-core/graphics/canvas.h @@ -1,10 +1,10 @@  #ifndef _ASURA_ENGINE_CANVAS_H_  #define _ASURA_ENGINE_CANVAS_H_ -#include <asura-utils/Scripting/Portable.hpp> -#include <asura-utils/Math/Rect.hpp> -#include <asura-utils/Math/Vector2.hpp> -#include <asura-utils/Exceptions/Exception.h> +#include <asura-base/Scripting/Scripting.h> +#include <asura-base/Math/Rect.hpp> +#include <asura-base/Math/Vector2.hpp> +#include <asura-base/Exception.h>  #include "GfxDevice.h"  #include "Texture.h" diff --git a/source/modules/asura-core/graphics/color.h b/source/modules/asura-core/graphics/color.h index a16f17d..c81b601 100644 --- a/source/modules/asura-core/graphics/color.h +++ b/source/modules/asura-core/graphics/color.h @@ -1,8 +1,8 @@  #ifndef _ASURA_ENGINE_COLOR_H_  #define _ASURA_ENGINE_COLOR_H_ -#include <asura-utils/Scripting/Portable.hpp> -#include <asura-utils/Classes.h> +#include <asura-base/Scripting/Scripting.h> +#include <asura-base/Classes.h>  #include "../CoreConfig.h" diff --git a/source/modules/asura-core/graphics/color32.h b/source/modules/asura-core/graphics/color32.h index aa445fe..4dbfe2d 100644 --- a/source/modules/asura-core/graphics/color32.h +++ b/source/modules/asura-core/graphics/color32.h @@ -1,8 +1,8 @@  #ifndef _ASURA_ENGINE_COLOR32_H__  #define _ASURA_ENGINE_COLOR32_H__ -#include <asura-utils/Classes.h> -#include <asura-utils/Scripting/Portable.hpp> +#include <asura-base/Classes.h> +#include <asura-base/Scripting/Scripting.h>  #include "../CoreConfig.h" diff --git a/source/modules/asura-core/graphics/image.cpp b/source/modules/asura-core/graphics/image.cpp index d2b2ec9..36d2478 100644 --- a/source/modules/asura-core/graphics/image.cpp +++ b/source/modules/asura-core/graphics/image.cpp @@ -1,4 +1,4 @@ -#include <asura-utils/Exceptions/Exception.h> +#include <asura-base/Exception.h>  #include "../CoreConfig.h" @@ -6,7 +6,7 @@  #include "Image.h"  #include "GfxDevice.h" -using namespace AEIO; +using namespace AEFileSystem;  using namespace AEImage;  namespace_begin(AsuraEngine) diff --git a/source/modules/asura-core/graphics/image.h b/source/modules/asura-core/graphics/image.h index 5cbfe23..a76d06f 100644 --- a/source/modules/asura-core/graphics/image.h +++ b/source/modules/asura-core/graphics/image.h @@ -2,12 +2,12 @@  #define _ASURA_ENGINE_IMAGE_H_  // asura modules  -#include <asura-utils/Math/Rect.hpp> -#include <asura-utils/Math/Vector2.hpp> -#include <asura-utils/Scripting/Portable.hpp> -#include <asura-utils/IO/Renewable.h> -#include <asura-utils/Stringmap.hpp> -#include <asura-utils/Manager.hpp> +#include <asura-base/Math/Rect.hpp> +#include <asura-base/Math/Vector2.hpp> +#include <asura-base/Scripting/Scripting.h> +#include <asura-base/FileSystem/Renewable.h> +#include <asura-base/Utilities/Stringmap.hpp> +#include <asura-base/Manager.hpp>  // module  #include "../Image/ImageData.h" diff --git a/source/modules/asura-core/graphics/mesh2d.h b/source/modules/asura-core/graphics/mesh2d.h index 1546765..7a0f62e 100644 --- a/source/modules/asura-core/graphics/mesh2d.h +++ b/source/modules/asura-core/graphics/mesh2d.h @@ -5,8 +5,8 @@  #include <vector>  // asura modules -#include <asura-utils/Scripting/Portable.hpp> -#include <asura-utils/Math/Vector2.hpp> +#include <asura-base/Scripting/Scripting.h> +#include <asura-base/Math/Vector2.hpp>  // module   #include "../Mesh/Mesh2dData.h" diff --git a/source/modules/asura-core/graphics/shader.cpp b/source/modules/asura-core/graphics/shader.cpp index 30e0161..329b3f1 100644 --- a/source/modules/asura-core/graphics/shader.cpp +++ b/source/modules/asura-core/graphics/shader.cpp @@ -1,4 +1,4 @@ -#include <asura-utils/Exceptions/Exception.h> +#include <asura-base/Exception.h>  #include "GfxDevice.h"  #include "Shader.h" diff --git a/source/modules/asura-core/graphics/shader.h b/source/modules/asura-core/graphics/shader.h index c96b99f..615b028 100644 --- a/source/modules/asura-core/graphics/shader.h +++ b/source/modules/asura-core/graphics/shader.h @@ -4,15 +4,15 @@  #include <map>  #include <string> -#include <asura-utils/Exceptions/Exception.h> -#include <asura-utils/Scripting/Portable.hpp> -#include <asura-utils/IO/Renewable.h> -#include <asura-utils/Math/Vector2.hpp> -#include <asura-utils/Math/vector3.hpp> -#include <asura-utils/Math/vector4.h> -#include <asura-utils/Math/matrix44.h> -#include <asura-utils/Stringmap.hpp> -#include <asura-utils/Manager.hpp> +#include <asura-base/Exception.h> +#include <asura-base/Scripting/Scripting.h> +#include <asura-base/FileSystem/Renewable.h> +#include <asura-base/Math/Vector2.hpp> +#include <asura-base/Math/vector3.hpp> +#include <asura-base/Math/vector4.h> +#include <asura-base/Math/matrix44.h> +#include <asura-base/Utilities/Stringmap.hpp> +#include <asura-base/Manager.hpp>  #include "GfxDevice.h"  #include "Color.h" @@ -30,7 +30,7 @@ namespace_begin(Graphics)  ///  class Shader ASURA_FINAL  	: public Scripting::Portable<Shader> -	, public AEIO::Renewable +	, public AEFileSystem::Renewable  {  public: diff --git a/source/modules/asura-core/graphics/texture.cpp b/source/modules/asura-core/graphics/texture.cpp index bae0f7c..03f005d 100644 --- a/source/modules/asura-core/graphics/texture.cpp +++ b/source/modules/asura-core/graphics/texture.cpp @@ -1,4 +1,4 @@ -#include <asura-utils/Exceptions/Exception.h> +#include <asura-base/Exception.h>  #include "Texture.h" diff --git a/source/modules/asura-core/graphics/texture.h b/source/modules/asura-core/graphics/texture.h index 7d37c31..76b9a8f 100644 --- a/source/modules/asura-core/graphics/texture.h +++ b/source/modules/asura-core/graphics/texture.h @@ -1,8 +1,8 @@  #ifndef _ASURA_TEXTURE_H_  #define _ASURA_TEXTURE_H_ -#include <asura-utils/Math/Vector2.hpp> -#include <asura-utils/Math/Rect.hpp> +#include <asura-base/Math/Vector2.hpp> +#include <asura-base/Math/Rect.hpp>  #include "../CoreConfig.h" diff --git a/source/modules/asura-core/image/binding/_image_data.cpp b/source/modules/asura-core/image/binding/_image_data.cpp index 77f3a96..375f854 100644 --- a/source/modules/asura-core/image/binding/_image_data.cpp +++ b/source/modules/asura-core/image/binding/_image_data.cpp @@ -1,11 +1,11 @@ -#include <asura-utils/Threads/Thread.h> -#include <asura-utils/IO/DataBuffer.h> +#include <asura-base/Threads/Thread.h> +#include <asura-base/FileSystem/DataBuffer.h>  #include "../ImageData.h"  using namespace std;  using namespace AEThreading; -using namespace AEIO; +using namespace AEFileSystem;  namespace_begin(AsuraEngine)  namespace_begin(Image) diff --git a/source/modules/asura-core/input/button.h b/source/modules/asura-core/input/button.h index 5c3c0de..528063d 100644 --- a/source/modules/asura-core/input/button.h +++ b/source/modules/asura-core/input/button.h @@ -1,7 +1,7 @@  #ifndef __BUTTON_H__  #define __BUTTON_H__ -#include <asura-utils/Classes.h> +#include <asura-base/Classes.h>  namespace_begin(AsuraEngine)  namespace_begin(Input) diff --git a/source/modules/asura-core/type.h b/source/modules/asura-core/type.h deleted file mode 100644 index 39880e2..0000000 --- a/source/modules/asura-core/type.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef _ASURA_ENGINE_TYPE_H_ -#define _ASURA_ENGINE_TYPE_H_ - -#include <stdint.h> - -namespace AsuraEngine -{ - -} - -#endif
\ No newline at end of file diff --git a/source/modules/asura-core/window/window.cpp b/source/modules/asura-core/window/window.cpp index adba7c9..d75b9a7 100644 --- a/source/modules/asura-core/window/window.cpp +++ b/source/modules/asura-core/window/window.cpp @@ -1,4 +1,4 @@ -#include <asura-utils/Exceptions/Exception.h> +#include <asura-base/Exception.h>  #include "window.h" diff --git a/source/modules/asura-core/window/window.h b/source/modules/asura-core/window/window.h index f5498c1..0f2850b 100644 --- a/source/modules/asura-core/window/window.h +++ b/source/modules/asura-core/window/window.h @@ -1,9 +1,9 @@  #ifndef _ASURA_ENGINE_WINDOW_H_  #define _ASURA_ENGINE_WINDOW_H_ -#include <asura-utils/Scripting/Portable.hpp> -#include <asura-utils/Math/Vector2.hpp> -#include <asura-utils/Singleton.hpp> +#include <asura-base/Scripting/Scripting.h> +#include <asura-base/Math/Vector2.hpp> +#include <asura-base/Singleton.hpp>  #include "../Graphics/Image.h"  #include "../Graphics/RenderState.h" diff --git a/source/modules/asura-openal/Audio/Audio.h b/source/modules/asura-openal/Audio/Audio.h index b9f718f..a29c448 100644 --- a/source/modules/asura-openal/Audio/Audio.h +++ b/source/modules/asura-openal/Audio/Audio.h @@ -1,7 +1,7 @@  #ifndef _ASURA_AUDIO_H_  #define _ASURA_AUDIO_H_ -#include <asura-utils/Classes.h> +#include <asura-base/Classes.h>  namespace_begin(AsuraEngine)  namespace_begin(Audio) diff --git a/source/modules/asura-openal/Audio/Sound.h b/source/modules/asura-openal/Audio/Sound.h index ab309f3..1a3d280 100644 --- a/source/modules/asura-openal/Audio/Sound.h +++ b/source/modules/asura-openal/Audio/Sound.h @@ -1,7 +1,7 @@  #ifndef __ASURA_ENGINE_SOUND_H__  #define __ASURA_ENGINE_SOUND_H__ -#include <asura-utils/Scripting/Portable.hpp> +#include <asura-base/Scripting/Scripting.h>  namespace AsuraEngine  { diff --git a/source/modules/asura-openal/Audio/SoundDecoder.h b/source/modules/asura-openal/Audio/SoundDecoder.h index c149d6f..8392a03 100644 --- a/source/modules/asura-openal/Audio/SoundDecoder.h +++ b/source/modules/asura-openal/Audio/SoundDecoder.h @@ -1,7 +1,7 @@  #ifndef __ASURA_ENGINE_SOUND_DECODER_H__  #define __ASURA_ENGINE_SOUND_DECODER_H__ -#include <asura-utils/IO/DataBuffer.h> +#include <asura-base/FileSystem/DataBuffer.h>  #include "sound.h" @@ -20,7 +20,7 @@ namespace AsuraEngine  			SoundDecoder();  			virtual ~SoundDecoder(); -			virtual Sound* Decode(const AEIO::DataBuffer* db); +			virtual Sound* Decode(const AEFileSystem::DataBuffer* db);  		}; diff --git a/source/modules/asura-openal/audio/audio.h b/source/modules/asura-openal/audio/audio.h index b9f718f..a29c448 100644 --- a/source/modules/asura-openal/audio/audio.h +++ b/source/modules/asura-openal/audio/audio.h @@ -1,7 +1,7 @@  #ifndef _ASURA_AUDIO_H_  #define _ASURA_AUDIO_H_ -#include <asura-utils/Classes.h> +#include <asura-base/Classes.h>  namespace_begin(AsuraEngine)  namespace_begin(Audio) diff --git a/source/modules/asura-openal/audio/sound.h b/source/modules/asura-openal/audio/sound.h index ab309f3..1a3d280 100644 --- a/source/modules/asura-openal/audio/sound.h +++ b/source/modules/asura-openal/audio/sound.h @@ -1,7 +1,7 @@  #ifndef __ASURA_ENGINE_SOUND_H__  #define __ASURA_ENGINE_SOUND_H__ -#include <asura-utils/Scripting/Portable.hpp> +#include <asura-base/Scripting/Scripting.h>  namespace AsuraEngine  { diff --git a/source/modules/asura-utils/Classes.h b/source/modules/asura-utils/Classes.h deleted file mode 100644 index b2700f0..0000000 --- a/source/modules/asura-utils/Classes.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef _ASURAENGINE_CLASSES_H_ -#define _ASURAENGINE_CLASSES_H_ - -#define GET_SET(TYPE,PROP_NAME,VAR_NAME)	void Set##PROP_NAME (TYPE val) { VAR_NAME = val; }	TYPE Get##PROP_NAME () {return VAR_NAME; } - -#define namespace_begin(NAMESPACE) namespace NAMESPACE {  -#define namespace_end } - -#endif diff --git a/source/modules/asura-utils/Exceptions/Exception.cpp b/source/modules/asura-utils/Exceptions/Exception.cpp deleted file mode 100644 index 5240c49..0000000 --- a/source/modules/asura-utils/Exceptions/Exception.cpp +++ /dev/null @@ -1,40 +0,0 @@ -#include "Exception.h" - -#include <cstdarg> -#include <iostream> - -namespace AsuraEngine -{ - -	Exception::Exception(const char *fmt, ...) -	{ -		va_list args; -		int size_buffer = 256, size_out; -		char *buffer; -		while (true) -		{ -			buffer = new char[size_buffer]; -			memset(buffer, 0, size_buffer); - -			va_start(args, fmt); -			size_out = vsnprintf(buffer, size_buffer, fmt, args); -			va_end(args); - -			if (size_out == size_buffer || size_out == -1 || size_out == size_buffer - 1) -				size_buffer *= 2; -			else if (size_out > size_buffer) -				size_buffer = size_out + 2; -			else -				break; - -			delete[] buffer; -		} -		message = std::string(buffer); -		delete[] buffer; -	} - -	Exception::~Exception() throw() -	{ -	} - -} diff --git a/source/modules/asura-utils/Exceptions/Exception.h b/source/modules/asura-utils/Exceptions/Exception.h deleted file mode 100644 index 73c0861..0000000 --- a/source/modules/asura-utils/Exceptions/Exception.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef _ASURA_ENGINE_EXCEPTION_H_ -#define _ASURA_ENGINE_EXCEPTION_H_ - -#include <string> -#include <exception> - -namespace AsuraEngine -{ -	 -class Exception : public std::exception -{ -public: - -	Exception(const char *fmt, ...); -	virtual ~Exception() throw(); - -	inline virtual const char *what() const throw() -	{ -		return message.c_str(); -	} - -private: - -	std::string message; - -}; // Exception - -} - -#endif
\ No newline at end of file diff --git a/source/modules/asura-utils/IO/Compressor.cpp b/source/modules/asura-utils/IO/Compressor.cpp deleted file mode 100644 index 4202263..0000000 --- a/source/modules/asura-utils/IO/Compressor.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "Compressor.h" - -namespace AsuraEngine -{ -	namespace IO -	{ - - - -	} -}
\ No newline at end of file diff --git a/source/modules/asura-utils/IO/Compressor.h b/source/modules/asura-utils/IO/Compressor.h deleted file mode 100644 index dc25e2a..0000000 --- a/source/modules/asura-utils/IO/Compressor.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef _ASURA_COMPRESSOR_H_ -#define _ASURA_COMPRESSOR_H_ - -#include "../Scripting/Portable.hpp" - -namespace AsuraEngine -{ -	namespace IO -	{ - -		class Compressor ASURA_FINAL  -			: public AEScripting::Portable<Compressor> -		{ -		public: - -			LUAX_DECL_SINGLETON(Compressor); - -		private: - -			LUAX_DECL_METHOD(_Compress); -			LUAX_DECL_METHOD(_Decompress); - -		}; - -	} -} - -#endif
\ No newline at end of file diff --git a/source/modules/asura-utils/IO/DataBuffer.cpp b/source/modules/asura-utils/IO/DataBuffer.cpp deleted file mode 100644 index 6660a94..0000000 --- a/source/modules/asura-utils/IO/DataBuffer.cpp +++ /dev/null @@ -1,156 +0,0 @@ -#include <cstdlib> -#include <cstring> -#include "DataBuffer.h" - -using namespace AEThreading; - -namespace AsuraEngine -{ -	namespace IO -	{ - -		DataBuffer::DataBuffer(DataBuffer& src) -			: m_Size(0) -			, m_Capacity(0) -			, m_Bytes(nullptr) -		{ -			// ʼ -			lock(m_Mutex) -			{ -			 m_Capacity = src.m_Size; -			 m_Bytes = new byte[m_Capacity]; -				Clear(); - -				Load(src); -			} -		} - -		DataBuffer::DataBuffer(std::size_t capacity) -			: m_Size(0) -			, m_Capacity(0) -			, m_Bytes(nullptr) -		{ -			lock(m_Mutex) -			{ -			 m_Capacity = capacity; -			 m_Bytes = new byte[m_Capacity]; -				Clear(); -			} -		} - -		DataBuffer::DataBuffer(const void* data, std::size_t size) -			: m_Capacity(0) -			, m_Size(0) -			, m_Bytes(nullptr) -		{ -			lock(m_Mutex) -			{ -			 m_Capacity = size; -			 m_Bytes = new byte[m_Capacity]; -				Clear(); - -				Load(data, size); -			} -		} - -		DataBuffer::~DataBuffer() -		{ -			lock(m_Mutex) -			{ -				delete[] m_Bytes; -			} -		} - -		void DataBuffer::Refactor(size_t capacity) -		{ -			lock(m_Mutex) -			{ -				if (!m_Bytes || m_Capacity != capacity) -				{ -					if(m_Bytes) -						delete[] m_Bytes; -				 m_Capacity = capacity; -				 m_Bytes = new byte[m_Capacity]; -				 m_Size = 0; -				} -				Clear(); -			} -		} - -		void DataBuffer::Load(DataBuffer& db) -		{ -			lock(m_Mutex) -			{ -				Load(db.GetData(), db.GetSize()); -			} -		} - -		void DataBuffer::Load(const void* data, std::size_t size) -		{ -			lock(m_Mutex) -			{ -				ASSERT(m_Capacity >= size); -				memcpy(m_Bytes, data, size); -			 m_Size = size; -			} -		} - -		void DataBuffer::Move(void* bytes, std::size_t size) -		{ -			lock(m_Mutex) -			{ -				if (m_Bytes == bytes) -				{ -					// sizeֵڶļʱ -				 m_Size = size; -				} -				else -				{ -					if (m_Bytes) -						delete[] m_Bytes; -				 m_Bytes = (byte*)bytes; -				 m_Size = size; -				 m_Capacity = size; -				} -			} -		} - -		byte* DataBuffer::GetData() -		{ -			return m_Bytes; -		} - -		void DataBuffer::Clear() -		{ -			lock(m_Mutex) -			{ -				if (m_Bytes) -				{ -					memset(m_Bytes, 0, m_Size); -				 m_Size = 0; -				} -			} -		} -		 -		std::size_t DataBuffer::GetSize() -		{ -			return m_Size; -		} - -		std::size_t DataBuffer::GetCapacity() -		{ -			return m_Capacity; -		} - -		void DataBuffer::Lock() -		{ -		 m_Mutex.Lock(); -		} - -		void DataBuffer::Unlock() -		{ -		 m_Mutex.Unlock(); -		} - -	} -}
\ No newline at end of file diff --git a/source/modules/asura-utils/IO/DataBuffer.h b/source/modules/asura-utils/IO/DataBuffer.h deleted file mode 100644 index 93fac6e..0000000 --- a/source/modules/asura-utils/IO/DataBuffer.h +++ /dev/null @@ -1,87 +0,0 @@ -#ifndef _ASURA_ENGINE_DATABUFFER_H_ -#define _ASURA_ENGINE_DATABUFFER_H_ - -#include <cstdlib> - -#include "../Scripting/Portable.hpp" -#include "../Threads/Mutex.h" - -namespace AsuraEngine -{ -	namespace IO -	{ - -		/// -		/// ڴݵķװеʹData bufferװֱʹconst void*ͨresource managerȡ -		/// -		class DataBuffer ASURA_FINAL -			: public AEScripting::Portable<DataBuffer> -		{ -		public: - -			LUAX_DECL_FACTORY(DataBuffer); - -			DataBuffer(DataBuffer& src); -			DataBuffer(std::size_t capacity); -			DataBuffer(const void* bytes, std::size_t size); -			~DataBuffer(); - -			byte* GetData(); -			size_t GetSize(); -			size_t GetCapacity(); - -			/// -			///  -			/// -			void Refactor(size_t capacity); - -			/// -			/// Դ˻ -			/// -			void Load(DataBuffer& db); -			void Load(const void* bytes, std::size_t size); - -			/// -			/// bytesӵȨcapacityΪsize -			/// -			void Move(void* bytes, std::size_t size); - -			/// -			///  -			/// -			void Clear(); - -			void Lock(); -			void Unlock(); -			 -		private: - -			LUAX_DECL_METHOD(_New); -			LUAX_DECL_METHOD(_GetData); -			LUAX_DECL_METHOD(_GetSize); -			LUAX_DECL_METHOD(_GetCapacity); -			LUAX_DECL_METHOD(_Refactor); -			LUAX_DECL_METHOD(_Load); -			LUAX_DECL_METHOD(_Clear); - -			/// -			/// Bufferַݵij -			/// -			byte* m_Bytes; -			size_t m_Size; - -			/// -			/// Buffer -			/// -			size_t m_Capacity; - -			AEThreading::Mutex m_Mutex; - -		}; - -	} -} - -namespace AEIO = AsuraEngine::IO; - -#endif
\ No newline at end of file diff --git a/source/modules/asura-utils/IO/DecodedData.h b/source/modules/asura-utils/IO/DecodedData.h deleted file mode 100644 index 73a2f74..0000000 --- a/source/modules/asura-utils/IO/DecodedData.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef _ASURA_ENGINE_DATA_H_ -#define _ASURA_ENGINE_DATA_H_ - -#include <cstdlib> - -#include <asura-utils/Threads/Thread.h> - -#include "../Scripting/Portable.hpp" - -#include "DataBuffer.h" - -namespace AsuraEngine -{ -	namespace IO -	{ - -		/// -		/// һ̹߳data̳дࡣͼƬݡƵݵȣһ߳нԭ -		/// ļڲݸʽصȡ -		/// -		ASURA_ABSTRACT class DecodedData -		{ -		public: - -			/// -			/// ڴйdataԷһ߳棬Դϵͳء -			/// -			DecodedData() {}; -			virtual ~DecodedData() {}; - -			/// -			/// ڴеݲijָʽ档 -			/// -			virtual void Decode(DataBuffer& buffer) = 0; - -		}; - -	} -} - -#endif
\ No newline at end of file diff --git a/source/modules/asura-utils/IO/File.cpp b/source/modules/asura-utils/IO/File.cpp deleted file mode 100644 index 6d5f4eb..0000000 --- a/source/modules/asura-utils/IO/File.cpp +++ /dev/null @@ -1,294 +0,0 @@ -#include <physfs/physfs.h> - -#include <asura-utils/Exceptions/Exception.h> - -#include "File.h" - -namespace AsuraEngine -{ -	namespace IO -	{ - -		File::File(const std::string& filename) -			: m_FileName(filename) -			, m_FileHandle(nullptr) -			, m_Mode(FILE_MODE_CLOSED) -			, m_BufferMode(BUFFER_MODE_NONE) -			, m_BufferSize(0) -		{ -			size_t dot = filename.rfind('.'); -			if (dot != std::string::npos) -			{ -			 m_Extension = filename.substr(dot + 1); -			 m_Name = filename.substr(0, dot); -			} -			else -			 m_Name = filename; -		} - -		File::~File() -		{ -			if (m_Mode != FILE_MODE_CLOSED) -				Close(); -		} - -		bool File::Open(FileMode mode) -		{ -			if (!PHYSFS_isInit()) -				throw Exception("Physfs is NOT initialized."); - -			if (mode == FILE_MODE_CLOSED) -				return false; - -			if (mode == FILE_MODE_READ && !PHYSFS_exists(m_FileName.c_str())) -				throw Exception("Could NOT open file %s. Does not exist.", m_FileName.c_str()); - -			if (mode == FILE_MODE_APPEND || mode == FILE_MODE_WRITE) -			{ -				if (!PHYSFS_getWriteDir()) -				{ -					throw Exception("Could NOT set write directory."); -				} -			} - -			// Ѿ֮ǰͲٴµhandle -			if (m_FileHandle != nullptr) -				return true; - -			PHYSFS_getLastErrorCode(); - -			PHYSFS_File* handle = nullptr; - -			switch (mode) -			{ -			case FILE_MODE_READ: -				handle = PHYSFS_openRead(m_FileName.c_str()); -				break; -			case FILE_MODE_APPEND: -				handle = PHYSFS_openAppend(m_FileName.c_str()); -				break; -			case FILE_MODE_WRITE: -				handle = PHYSFS_openWrite(m_FileName.c_str()); -				break; -			} - -			if (handle == nullptr) -			{ -				const char *err = PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode()); -				if (err == nullptr) -					err = "unknown error"; -				throw Exception("Could not open file %s (%s)", m_FileName.c_str(), err); -			} - -			m_FileHandle = handle; -			m_Mode = mode;  - -			if (m_FileHandle && !SetBuffer(m_BufferMode,m_BufferSize)) -			{ -			 m_BufferMode = BUFFER_MODE_NONE;  -			 m_BufferSize = 0; -			} - -			return m_FileHandle != nullptr; -		} - -		bool File::Close() -		{ -			if (m_FileHandle == nullptr || !PHYSFS_close(m_FileHandle)) -				return false; -		 m_Mode = FILE_MODE_CLOSED; -		 m_FileHandle = nullptr; -			return true; -		} - -		bool File::IsOpen() -		{ -			return m_Mode != FILE_MODE_CLOSED && m_FileHandle != nullptr; -		} - -		size_t File::GetSize() -		{ -			if (m_FileHandle == nullptr) -			{ -				Open(FILE_MODE_READ); -				size_t size = PHYSFS_fileLength(m_FileHandle); -				Close();  -				return size; -			} -			return PHYSFS_fileLength(m_FileHandle); -		} - -		size_t File::Read(ASURA_OUT DataBuffer* dst, size_t length) -		{ -			ASSERT(dst); - -			if (dst->GetCapacity() < length) -				throw Exception("Data buffer is too small compares to read length."); - -			if (!m_FileHandle || m_Mode != FILE_MODE_READ) -				throw Exception("File \"%s\" is not opened for reading", m_FileName); - -			size_t max = PHYSFS_fileLength(m_FileHandle); -			length = (length > max) ? max : length; - -			if (length < 0) -				throw Exception("Invalid read size."); - -			dst->Lock(); -			size_t size = PHYSFS_readBytes(m_FileHandle, dst->GetData(), length); -			dst->Unlock(); -			return size; -		} - -		size_t File::ReadAll(ASURA_OUT DataBuffer* dst) -		{ -			ASSERT(dst); - -			if (!m_FileHandle || m_Mode != FILE_MODE_READ) -				throw Exception("File \"%s\" is not opened for reading", m_FileName); - -			size_t length = PHYSFS_fileLength(m_FileHandle); - -			if (dst->GetCapacity() < length) -				throw Exception("Data buffer is too small compares to file length."); - -			dst->Lock(); -			byte* data = dst->GetData(); -			size_t size = PHYSFS_readBytes(m_FileHandle, data, length); -			dst->Move(data, length); -			dst->Unlock(); -			return size; -		} - -#ifdef ASURA_WINDOWS -		inline bool test_eof(File *that, PHYSFS_File *) -		{ -			int64 pos = that->Tell(); -			int64 size = that->GetSize(); -			return pos == -1 || size == -1 || pos >= size; -		} -#else -		inline bool test_eof(File *, PHYSFS_File *file) -		{ -			return PHYSFS_eof(file); -		} -#endif - -		bool File::IsEOF() -		{ -			return m_FileHandle == nullptr || test_eof(this, m_FileHandle); -		} - -		size_t File::Tell() -		{ -			if (!m_FileHandle) -				return - 1; - -			return PHYSFS_tell(m_FileHandle); -		} - -		bool File::Seek(size_t pos) -		{ -			return m_FileHandle != nullptr && PHYSFS_seek(m_FileHandle, pos) != 0; -		} - -		bool File::Write(ASURA_REF DataBuffer* src) -		{ -			if (!m_FileHandle || (m_Mode != FILE_MODE_APPEND && m_Mode != FILE_MODE_WRITE)) -				throw Exception("File is not opened for writing."); - -			byte* data = src->GetData(); -			int size = src->GetSize(); - -			if (size < 0) -				throw Exception("Invalid write size."); - -			size_t written = PHYSFS_writeBytes(m_FileHandle, data, size); - -			if (written != src->GetSize()) -				return false;  - -			// л -			if (m_BufferSize == BUFFER_MODE_LINE && m_BufferSize > size) -			{ -				if (memchr(data, '\n', size) != nullptr) -					Flush(); -			} - -			return true; -		} - -		bool File::Flush() -		{ -			if (!m_FileHandle || (m_Mode != FILE_MODE_WRITE && m_Mode != FILE_MODE_APPEND)) -				throw Exception("File is not opened for writing."); - -			return PHYSFS_flush(m_FileHandle) != 0; -		} - -		bool File::SetBuffer(BufferMode mode, size_t size) -		{ -			if (size < 0) -				return false; - -			// If the file isn't open, we'll make sure the buffer values are set in -			// File::open. -			if (!IsOpen()) -			{ -			 m_BufferMode = mode; -			 m_BufferSize = size; -				return true; -			} - -			int ret = 1; - -			switch (mode) -			{ -			case BUFFER_MODE_NONE: -			default: -				ret = PHYSFS_setBuffer(m_FileHandle, 0); -				size = 0; -				break; -			case BUFFER_MODE_LINE: -			case BUFFER_MODE_FULL: -				ret = PHYSFS_setBuffer(m_FileHandle, size); -				break; -			} - -			if (ret == 0) -				return false; - -		 m_BufferMode = mode; -		 m_BufferSize = size; - -			return true; -		} - -		File::BufferMode File::GetBuffer(ASURA_OUT size_t& size)  -		{ -			size = m_BufferSize;  -			return m_BufferMode;  -		} - -		const std::string& File::GetFileName() -		{ -			return m_FileName; -		} - -		const std::string& File::GetName() -		{ -			return m_Name; -		} - -		const std::string& File::GetExtension() -		{ -			return m_Extension; -		} - -		File::FileMode File::GetMode() -		{ -			return m_Mode; -		} - -	} -}
\ No newline at end of file diff --git a/source/modules/asura-utils/IO/File.h b/source/modules/asura-utils/IO/File.h deleted file mode 100644 index d11fa4f..0000000 --- a/source/modules/asura-utils/IO/File.h +++ /dev/null @@ -1,146 +0,0 @@ -#ifndef _ASURA_ENGINE_FILE_H_ -#define _ASURA_ENGINE_FILE_H_ - -#include "physfs/physfs.h" - -#include "../Scripting/Portable.hpp" -#include "../Threads/Thread.h" - -#include "FileData.h" - -namespace AsuraEngine -{ -	namespace IO -	{ - -		/// -		/// ʽļָд㡢Сʹȡʱʹñ࣬ʹFilesystem.read()ֱӶȡļȫ -		/// ݣһFileData -		/// -		class File ASURA_FINAL -			: public AEScripting::Portable<File> -		{ -		public: - -			LUAX_DECL_FACTORY(File); - -			/// -			/// ļдģʽ -			/// -			enum FileMode -			{ -				FILE_MODE_CLOSED, -				FILE_MODE_READ, -				FILE_MODE_WRITE, -				FILE_MODE_APPEND, -			}; - -			/// -			/// ļдʱΪ -			/// -			enum BufferMode -			{ -				BUFFER_MODE_NONE, ///< ʹû壬дļ -				BUFFER_MODE_LINE, ///< л壬зߴﵽСʱдļ -				BUFFER_MODE_FULL, ///< ȫ壬ʱдļ -			}; - -			File(const std::string& filename); -			~File(); - -			bool Open(FileMode mode);  -			bool Close(); -			bool IsOpen(); -			FileMode GetMode(); -			size_t GetSize();  - -			/// -			/// ȡdata bufferض -			/// -			size_t Read(ASURA_OUT DataBuffer* dst, size_t length); -			size_t ReadAll(ASURA_OUT DataBuffer* dst); -			size_t ReadAsync(ASURA_OUT DataBuffer* dst); - -			/// -			/// Ƿļβ -			/// -			bool IsEOF(); - -			/// -			/// data bufferед룬Ƿɹ -			/// -			bool Write(ASURA_REF DataBuffer* src); - -			/// -			/// 첽дļдļtaskthreadĶС -			/// -			bool WriteAsync(ASURA_REF DataBuffer* src, AEThreading::Thread* thread); - -			/// -			/// ˻壬ǿջдļ -			/// -			bool Flush(); - -			/// -			/// صǰдλ -			/// -			size_t Tell(); - -			/// -			/// Ӧλ -			/// -			bool Seek(size_t pos); - -			/// -			/// ûСģʽ -			/// -			bool SetBuffer(BufferMode mode, size_t size); - -			/// -			/// ȡСģʽ -			/// -			BufferMode GetBuffer(ASURA_OUT size_t& size); - -			const std::string& GetFileName(); -			const std::string& GetName(); -			const std::string& GetExtension(); - -		private: - -			PHYSFS_File* m_FileHandle; ///< physfs ļ -			std::string  m_FileName;   ///< ļ -			std::string  m_Extension;  ///< չ -			std::string  m_Name;       ///< չļ -			FileMode     m_Mode;       ///< ļģʽ -			BufferMode   m_BufferMode;	///< д뻺ģʽ -			size_t       m_BufferSize;	///< д뻺С - -			LUAX_DECL_ENUM(FileMode); -			LUAX_DECL_ENUM(BufferMode); - -			LUAX_DECL_METHOD(_New); -			LUAX_DECL_METHOD(_Open); -			LUAX_DECL_METHOD(_Close); -			LUAX_DECL_METHOD(_IsOpen); -			LUAX_DECL_METHOD(_GetMode); -			LUAX_DECL_METHOD(_GetSize); -			LUAX_DECL_METHOD(_Read); -			LUAX_DECL_METHOD(_Write); -			LUAX_DECL_METHOD(_ReadAsync); -			LUAX_DECL_METHOD(_WriteAsync); -			LUAX_DECL_METHOD(_IsEOF); -			LUAX_DECL_METHOD(_Flush); -			LUAX_DECL_METHOD(_Tell); -			LUAX_DECL_METHOD(_Seek); -			LUAX_DECL_METHOD(_SetBuffer); -			LUAX_DECL_METHOD(_GetBuffer); -			LUAX_DECL_METHOD(_GetFileName); -			LUAX_DECL_METHOD(_GetExtension); -			LUAX_DECL_METHOD(_GetName); - -		}; - -	} -} - -#endif
\ No newline at end of file diff --git a/source/modules/asura-utils/IO/FileData.cpp b/source/modules/asura-utils/IO/FileData.cpp deleted file mode 100644 index ca1cce7..0000000 --- a/source/modules/asura-utils/IO/FileData.cpp +++ /dev/null @@ -1,59 +0,0 @@ -#include "FileData.h" - -namespace AsuraEngine -{ -	namespace IO -	{ - -		FileData::FileData(const std::string& filename) -			: m_Data(nullptr) -			, m_FileName(filename) -		{ -			size_t dot = filename.rfind('.'); -			if (dot != std::string::npos) -			{ -			 m_Extension = filename.substr(dot + 1); -			 m_Name = filename.substr(0, dot); -			} -			else -			 m_Name = filename; -		} - -		FileData::~FileData() -		{ -			if (m_Data) -			 m_Data->Release(); -		} - -		const std::string& FileData::GetFileName() -		{ -			return m_FileName; -		} - -		const std::string& FileData::GetExtension() -		{ -			return m_Extension; -		} - -		const std::string& FileData::GetName() -		{ -			return m_Name; -		} - -		void FileData::BindData(ASURA_MOVE DataBuffer* buffer) -		{ -			if (!buffer) -				return; -			if (m_Data) -			 m_Data->Release(); -		 m_Data = buffer; -		 m_Data->Retain(); -		} - -		DataBuffer* FileData::GetDataBuffer() -		{ -			return m_Data; -		} - -	} -}
\ No newline at end of file diff --git a/source/modules/asura-utils/IO/FileData.h b/source/modules/asura-utils/IO/FileData.h deleted file mode 100644 index f93040c..0000000 --- a/source/modules/asura-utils/IO/FileData.h +++ /dev/null @@ -1,69 +0,0 @@ -#ifndef _ASURA_ENGINE_FILE_DATA_H_ -#define _ASURA_ENGINE_FILE_DATA_H_ - -#include <string> - -#include <asura-utils/Scripting/Portable.hpp> - -#include "DataBuffer.h" - -namespace AsuraEngine -{ -	namespace IO -	{ - -		class Filesystem; - -		/// -		/// filesystemֱӶȡļʱFileDataļݺϢFilesystem -		/// -		class FileData ASURA_FINAL -			: public AEScripting::Portable<FileData> -		{ -		public: - -			LUAX_DECL_FACTORY(FileData); - -			~FileData(); - -			/// -			/// ļݣͨDatabufferݺʹСڲӿڶData bufferΪҲdata buffer -			/// -			DataBuffer* GetDataBuffer(); - -			const std::string& GetFileName();  -			const std::string& GetExtension(); -			const std::string& GetName(); - -		private: - -			friend class Filesystem; - -			FileData(const std::string& name); - -			/// -			/// data buffer -			/// -			void BindData(ASURA_MOVE DataBuffer* buffer); - -			/// -			/// Data bufferfiledataʱ٣luaüΪ0ʱluaGC١mDataʱһԱá -			/// -			ASURA_REF DataBuffer* m_Data; -			Luax::LuaxMemberRef   m_DataRef; - -			std::string m_FileName;  ///< չļ -			std::string m_Extension; ///< չ -			std::string m_Name;      ///< ͺļ - -			LUAX_DECL_METHOD(_GetDataBuffer); -			LUAX_DECL_METHOD(_GetFileName); -			LUAX_DECL_METHOD(_GetExtension); -			LUAX_DECL_METHOD(_GetName); - -		}; - -	} -} - -#endif
\ No newline at end of file diff --git a/source/modules/asura-utils/IO/FileSystem.cpp b/source/modules/asura-utils/IO/FileSystem.cpp deleted file mode 100644 index 9d0acf0..0000000 --- a/source/modules/asura-utils/IO/FileSystem.cpp +++ /dev/null @@ -1,198 +0,0 @@ -#include <physfs/physfs.h> - -#include "../exceptions/exception.h" - -#include "File.h" -#include "FileData.h" -#include "FileSystem.h" - -using namespace std; - -namespace AsuraEngine -{ -	namespace IO -	{ - -#ifdef ASURA_WINDOWS -	#include <windows.h> -	#include <direct.h> -#else -	#include <sys/param.h> -	#include <unistd.h> -#endif - -		Filesystem::~Filesystem() -		{ -			if (m_Inited) //PHYSFS_isInit -				PHYSFS_deinit(); -		} - -		void Filesystem::Init(const char* arg0) -		{ -			if (!PHYSFS_init(arg0)) -				throw Exception("Failed to initialize filesystem: %s", PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode())); - -		 m_Inited = true; -		} - -		bool Filesystem::Mount(const std::string& locpath, const std::string& montpoint/* = "/"*/, bool prepend /*= false*/) -		{ -			if (!m_Inited) -				return false; - -			return PHYSFS_mount(locpath.c_str(), montpoint.c_str(), !prepend); -		} - -		bool Filesystem::Mount(DataBuffer* db, const std::string& archivename, const std::string& mountpoint /*= "/"*/, bool prepend /*= false*/) -		{ -			if (!m_Inited) -				return false; -			if (PHYSFS_mountMemory(db->GetData(), db->GetSize(), nullptr, archivename.c_str(), mountpoint.c_str(), !prepend)) -			{ -			 m_MountData[archivename] = db; -				return true; -			} -			return false; -		} - -		bool Filesystem::Unmount(const std::string& locpath) -		{ -			if (!m_Inited) -				return false; - -			// ǹ鵵ӳɾ -			auto datait = m_MountData.find(locpath); -			if (datait != m_MountData.end() && PHYSFS_unmount(locpath.c_str()) != 0) -			{ -			 m_MountData.erase(datait); -				return true; -			} - -			return PHYSFS_unmount(locpath.c_str()); -		} - -		bool Filesystem::Unmount(DataBuffer* db) -		{ -			for (const auto& dp : m_MountData) -			{ -				if (dp.second == db) -				{ -					std::string archive = dp.first; -					return Unmount(archive); -				} -			} -		} - -		bool Filesystem::GetMountPoint(const std::string& locpath, ASURA_OUT std::string& mountpoint) -		{ -			if (!m_Inited) -				return false; -			const char* point = PHYSFS_getMountPoint(locpath.c_str()); -			if (point != nullptr) -			{ -				mountpoint = point; -				return true; -			} -			return false; -		} - -		void Filesystem::SetWriteDirectory(const std::string locpath) -		{ -			if (!m_Inited) -				return; -			if (!PHYSFS_setWriteDir(locpath.c_str())) -				throw Exception("Failed to set write directory %s", locpath.c_str()); -		} - -		std::string Filesystem::GetWriteDirectory() -		{ -			return PHYSFS_getWriteDir(); -		} - -		File* Filesystem::NewFile(const std::string& name) -		{ -			return new File(name); -		} - -		bool Filesystem::NewDirectory(const std::string& path) -		{ -			if (!m_Inited) -				return false; -			if (!PHYSFS_getWriteDir()) -				return false; -			if (!PHYSFS_mkdir(path.c_str())) -				return false; -			return true; -		} - -		bool Filesystem::Write(const std::string& name, ASURA_REF DataBuffer* buffer) -		{ -			File file(name); -			file.Open(File::FILE_MODE_WRITE); -			if (!file.Write(buffer)) -				throw Exception("Data could not be written."); -		} - -		bool Filesystem::Append(const std::string& name, ASURA_REF DataBuffer* buffer) -		{ -			File file(name); -			file.Open(File::FILE_MODE_APPEND); -			if (!file.Write(buffer)) -				throw Exception("Data could not be append."); -		} - -		FileData* Filesystem::Read(const std::string& name) -		{ -			File file = File(name); -			file.Open(File::FILE_MODE_READ); -			int size = file.GetSize(); -			DataBuffer* db = new DataBuffer(size); -			if (db) -			{ -				file.ReadAll(db); -				FileData* fd = new FileData(name); -				fd->BindData(db); -				return fd; -			} -			return nullptr; -		} - -		bool Filesystem::Remove(const std::string& path) -		{ -			if (!m_Inited) -				return false; -			if (PHYSFS_getWriteDir() == 0) -				return false; - -			if (!PHYSFS_delete(path.c_str())) -				return false; - -			return true; -		} - -		bool Filesystem::GetFileInfo(const std::string& filepath, ASURA_OUT FileInfo* info) -		{ -			if (!m_Inited) -				return false; - -			PHYSFS_Stat stat = {}; -			if (!PHYSFS_stat(filepath.c_str(), &stat)) -				return false; - -			info->size = (int64)stat.filesize; -			info->modtime = (int64)stat.modtime; - -			if (stat.filetype == PHYSFS_FILETYPE_REGULAR) -				info->type = FILE_TYPE_FILE; -			else if (stat.filetype == PHYSFS_FILETYPE_DIRECTORY) -				info->type = FILE_TYPE_DIRECTORY; -			else if (stat.filetype == PHYSFS_FILETYPE_SYMLINK) -				info->type = FILE_TYPE_SYMLINK; -			else -				info->type = FILE_TYPE_OTHER; - -			return true; -		} - -	} -}
\ No newline at end of file diff --git a/source/modules/asura-utils/IO/FileSystem.h b/source/modules/asura-utils/IO/FileSystem.h deleted file mode 100644 index f0ac6ba..0000000 --- a/source/modules/asura-utils/IO/FileSystem.h +++ /dev/null @@ -1,112 +0,0 @@ -#ifndef _ASURA_ENGINE_FILESYSTEM_H_ -#define _ASURA_ENGINE_FILESYSTEM_H_ - -#include <map> -#include <string> - -#include "../Scripting/Portable.hpp" -#include "../Singleton.hpp" -#include "../Type.h" - -#include "FileData.h" -#include "File.h" - -namespace AsuraEngine -{ -	namespace IO -	{ - -		enum FileType -		{ -			FILE_TYPE_FILE, 		 ///< ļ -			FILE_TYPE_DIRECTORY, ///< ļ -			FILE_TYPE_SYMLINK, 	 ///<  -			FILE_TYPE_OTHER,		 ///<  -		}; - -		struct FileInfo -		{ -			int64 size;  -			int64 modtime;  -			FileType type; -		}; - -		/// -		/// Դء洢ԴָĿ¼ȡ۱༭ʱҪƷʵĻƣûIJϷĿ¼ -		/// £file systemµġFilesystemʱͱ༭õ࣬AssetDatabaseԴ࣬framework -		/// ʵ֣дFilesystemʵ֣AssetDatabaseṩļݴӦԴķ -		/// -		class Filesystem ASURA_FINAL -			: public Singleton<Filesystem> -			, public AEScripting::Portable<Filesystem> -		{ -		public: - -			LUAX_DECL_SINGLETON(Filesystem); - -			~Filesystem(); - -			void Init(const char* arg0); - -			/// -			/// ǰִļļ -			/// -			std::string GetWorkingDirectory(); - -			bool Mount(const std::string& locpath, const std::string& montpoint = "/", bool prepend = false); -			bool Mount(DataBuffer* db, const std::string& archivename, const std::string& mountpoint = "/", bool prepend = false); - -			bool Unmount(const std::string& locpath); -			bool Unmount(DataBuffer* db); - -			bool GetMountPoint(const std::string& locpath, ASURA_OUT std::string& mountpoint); - -			void SetWriteDirectory(const std::string locpath); -			std::string GetWriteDirectory(); -			File* NewFile(const std::string& name); -			bool NewDirectory(const std::string& path); -			bool Write(const std::string& path, ASURA_REF DataBuffer* buffer); -			bool Append(const std::string& path, ASURA_REF DataBuffer* buffer); -			bool Remove(const std::string& path); - -			FileData* Read(const std::string& path); -			bool GetFileInfo(const std::string& path, ASURA_OUT FileInfo* info); - -			bool GetDirectoryItems(const std::string& path, ASURA_OUT std::vector<std::string>& items) { return false; }; - -		private: - -			typedef std::map<std::string, DataBuffer*> MountDataMap; - -			bool         m_Inited;    ///< Ƿʼɹ -			std::string  m_Cwd;       ///< ǰִļĹĿ¼ -			MountDataMap m_MountData; ///< ·ѹĵӳ - -			LUAX_DECL_METHOD(_Init); -			LUAX_DECL_METHOD(_Mount); -			LUAX_DECL_METHOD(_Unmount); -			LUAX_DECL_METHOD(_GetMountPoint); - -			LUAX_DECL_METHOD(_SetWriteDirectory); -			LUAX_DECL_METHOD(_GetWriteDirectory); -			LUAX_DECL_METHOD(_CreateFile); -			LUAX_DECL_METHOD(_CreateDirectory); - -			LUAX_DECL_METHOD(_Write); -			LUAX_DECL_METHOD(_Append); -			LUAX_DECL_METHOD(_Remove); - -			LUAX_DECL_METHOD(_Read); - -			LUAX_DECL_METHOD(_GetFileInfo); - -			LUAX_DECL_METHOD(_GetDirectoryItems); - -		}; - -	} -} - -namespace AEIO = AsuraEngine::IO; - -#endif
\ No newline at end of file diff --git a/source/modules/asura-utils/IO/IOBatchTask.cpp b/source/modules/asura-utils/IO/IOBatchTask.cpp deleted file mode 100644 index e69de29..0000000 --- a/source/modules/asura-utils/IO/IOBatchTask.cpp +++ /dev/null diff --git a/source/modules/asura-utils/IO/IOBatchTask.h b/source/modules/asura-utils/IO/IOBatchTask.h deleted file mode 100644 index a9355d5..0000000 --- a/source/modules/asura-utils/IO/IOBatchTask.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef _ASURA_IO_BATCH_TASK_H_ -#define _ASURA_IO_BATCH_TASK_H_ - -#include "IOTask.h" - -namespace AsuraEngine -{ -	namespace IO -	{ - -		/// -		/// дһύһtableδؽ -		/// -		class IOBatchTask ASURA_FINAL : public AEThreading::Task -		{ -		public: - -		private: - -			/// -			/// ÿһĽṹ£ -			/// { path = "", } -			///  -			Luax::LuaxMemberRef m_Tasks; - -		}; - -	} -} - -#endif
\ No newline at end of file diff --git a/source/modules/asura-utils/IO/IOTask.cpp b/source/modules/asura-utils/IO/IOTask.cpp deleted file mode 100644 index bfa6726..0000000 --- a/source/modules/asura-utils/IO/IOTask.cpp +++ /dev/null @@ -1,61 +0,0 @@ -#include "FileSystem.h" -#include "IOTask.h" - -#include <iostream> - -using namespace AEScripting; -using namespace Luax; - -namespace AsuraEngine -{ -	namespace IO -	{ - -		IOTask::IOTask(const std::string& path, DataBuffer* buffer, IOTaskType type) -			: m_Path(path) -			, m_Buffer(buffer) -		{ -			if (buffer) -				buffer->Retain(); -		} - -		IOTask::~IOTask() -		{ -			if (m_Buffer) -			 m_Buffer->Release(); -		} - -		bool IOTask::Execute() -		{ -			File file(m_Path); -			if (m_Type == IOTASK_TYPE_WRITE) -			{ - -			} -			// pathȡݱmBuffer -			else if (m_Type == IOTASK_TYPE_READ) -			{ -				if (!m_Buffer) -					return false;  -				file.Open(File::FILE_MODE_READ); -				file.ReadAll(m_Buffer); -				file.Close(); -			} -			return true; -		} - -		void IOTask::Invoke(lua_State* invokeThreaad) -		{ -			if (m_Callback) -			{ -				LuaxScopedState state(invokeThreaad); -				if (this->PushLuaxMemberRef(state, m_Callback)) -				{ -					this->PushLuaxMemberRef(state, m_BufferRef); -					state.Call(1, 0); -				} -			} -		} - -	} -} diff --git a/source/modules/asura-utils/IO/IOTask.h b/source/modules/asura-utils/IO/IOTask.h deleted file mode 100644 index a35fc54..0000000 --- a/source/modules/asura-utils/IO/IOTask.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef _ASURA_IO_TASK_H_ -#define _ASURA_IO_TASK_H_ - -#include <string> - -#include "../Scripting/Portable.hpp" -#include "../Threads/Task.h" - -#include "DataBuffer.h" - -namespace AsuraEngine -{ -	namespace IO -	{ - -		enum IOTaskType -		{ -			IOTASK_TYPE_READ,  -			IOTASK_TYPE_WRITE, -			IOTASK_TYPE_APPEND, -		}; - -		/// -		/// ȡļ -		/// -		class IOTask ASURA_FINAL -			: public AEScripting::Portable<IOTask, AEThreading::Task> -		{ -		public: - -			LUAX_DECL_FACTORY(IOTask); - -			IOTask(const std::string& path, DataBuffer* buffer, IOTaskType type); -			~IOTask(); - -			bool Execute() override ; -			void Invoke(lua_State* invokeThreaad) override; - -		private: - -			LUAX_DECL_ENUM(IOTaskType); - -			LUAX_DECL_METHOD(_New); - -			std::string m_Path; -			IOTaskType  m_Type; - -			DataBuffer*         m_Buffer; -			Luax::LuaxMemberRef m_BufferRef; - -		}; - -	} -} - -#endif
\ No newline at end of file diff --git a/source/modules/asura-utils/IO/Renewable.h b/source/modules/asura-utils/IO/Renewable.h deleted file mode 100644 index 90867f2..0000000 --- a/source/modules/asura-utils/IO/Renewable.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef __ASURA_ENGINE_RENEWABLE_H__ -#define __ASURA_ENGINE_RENEWABLE_H__ - -#include "../scripting/portable.hpp" - -#include "DecodedData.h" - -namespace AsuraEngine -{ -	namespace IO -	{ - -		/// -		/// ¹ݽṹͼƬƵ֣ӽݿֱӹڱ༭ -		/// ¹handleֵı䲻߱ƻԣڲıhandleԴ -		/// -		ASURA_ABSTRACT class  Renewable -		{ -		public: -			 Renewable() {}; -			 virtual ~Renewable() {}; -		}; - -	} -} - -namespace AEIO = AsuraEngine::IO; - -#endif
\ No newline at end of file diff --git a/source/modules/asura-utils/IO/binding/_compressor.cpp b/source/modules/asura-utils/IO/binding/_compressor.cpp deleted file mode 100644 index e69de29..0000000 --- a/source/modules/asura-utils/IO/binding/_compressor.cpp +++ /dev/null diff --git a/source/modules/asura-utils/IO/binding/_data_buffer.cpp b/source/modules/asura-utils/IO/binding/_data_buffer.cpp deleted file mode 100644 index 9d3f3a0..0000000 --- a/source/modules/asura-utils/IO/binding/_data_buffer.cpp +++ /dev/null @@ -1,132 +0,0 @@ -#include "../DataBuffer.h" - -using namespace Luax; - -namespace AsuraEngine -{ -	namespace IO -	{ - -		LUAX_REGISTRY(DataBuffer) -		{ -			LUAX_REGISTER_METHODS(state,  -				{ "New",         _New         }, -				{ "GetData",     _GetData     }, -				{ "GetSize",     _GetSize     }, -				{ "GetCapacity", _GetCapacity }, -				{ "Refactor",    _Refactor    }, -				{ "Load",        _Load        }, -				{ "Clear",       _Clear       } -			); -		} - -		LUAX_POSTPROCESS(DataBuffer) -		{ -		} - -		// databuffer = DataBuffer.New(lstring) -		// databuffer = DataBuffer.New(capacity) -		LUAX_IMPL_METHOD(DataBuffer, _New) -		{ -			LUAX_STATE(L); - -			if (state.IsType(1, LUA_TSTRING)) -			{ -				size_t size; -				const byte* bytes = lua_tolstring(L, 1, &size); -				DataBuffer* buffer = new DataBuffer(bytes, size); -				buffer->PushLuaxUserdata(state); -				return 1; -			} -			else if (state.IsType(1, LUA_TNUMBER)) -			{ -				size_t capacity = lua_tonumber(L, 1); -				DataBuffer* buffer = new DataBuffer(capacity); -				buffer->PushLuaxUserdata(state); -				return 1; -			} -			else -			{ -				return state.ErrorType(1, "number or string"); -			} -		} - -		// lsting, len = databuffer:GetData() -		LUAX_IMPL_METHOD(DataBuffer, _GetData) -		{ -			LUAX_SETUP(L, "U"); - -			DataBuffer* self = state.GetUserdata<DataBuffer>(1); -			lua_pushlstring(L, self->GetData(), self->GetSize()); -			return 1; -		} - -		// length = databuffer:GetSize() -		LUAX_IMPL_METHOD(DataBuffer, _GetSize) -		{ -			LUAX_SETUP(L, "U"); - -			DataBuffer* self = state.GetUserdata<DataBuffer>(1); -			lua_pushinteger(L, self->GetSize()); -			return 1; -		} - -		// capacity = databuffer:GetCapacity() -		LUAX_IMPL_METHOD(DataBuffer, _GetCapacity) -		{ -			LUAX_SETUP(L, "U"); - -			DataBuffer* self = state.GetUserdata<DataBuffer>(1); -			lua_pushinteger(L, self->GetCapacity()); -			return 1; -		} - -		// databuffer:Refactor(capacity) -		LUAX_IMPL_METHOD(DataBuffer, _Refactor) -		{ -			LUAX_PREPARE(L, DataBuffer); - -			size_t capacity = state.CheckValue<int>(2); -			self->Refactor(capacity); -			return 0; -		} - -		// size = databuffer:Load(lstring) -		// size = databuffer:Load(src) -		LUAX_IMPL_METHOD(DataBuffer, _Load) -		{ -			LUAX_STATE(L); - -			DataBuffer* buffer = state.GetUserdata<DataBuffer>(1);  -			const byte* data; -			size_t size; -			if (state.IsType(2, LUA_TSTRING)) -			{ -				data = lua_tolstring(L, 2, &size); -				buffer->Load(data, size); -				return 0; -			} -			else if(state.IsType(2, LUA_TUSERDATA)) -			{ -				DataBuffer* src = state.CheckUserdata<DataBuffer>(2); -				buffer->Load(*src); -				return 0; -			} -			else -			{ -				return state.ErrorType(1, "lstring or DataBuffer"); -			} -		} - -		// databuffer:Clear() -		LUAX_IMPL_METHOD(DataBuffer, _Clear) -		{ -			LUAX_SETUP(L, "U"); - -			DataBuffer* self = state.GetUserdata<DataBuffer>(1); -			self->Clear();  -			return 0; -		} - -	} -}
\ No newline at end of file diff --git a/source/modules/asura-utils/IO/binding/_file.cpp b/source/modules/asura-utils/IO/binding/_file.cpp deleted file mode 100644 index c44bc90..0000000 --- a/source/modules/asura-utils/IO/binding/_file.cpp +++ /dev/null @@ -1,223 +0,0 @@ -#include "../file.h" - -namespace AsuraEngine -{ -	namespace IO -	{ - -		LUAX_REGISTRY(File) -		{ -			LUAX_REGISTER_METHODS(state,  -				{ "New",          _New          }, -				{ "Open",         _Open         }, -				{ "Close",        _Close        }, -				{ "IsOpen",       _IsOpen       }, -				{ "GetMode",      _GetMode      }, -				{ "GetSize",      _GetSize      }, -				{ "Read",         _Read         }, -				{ "IsEOF",        _IsEOF        }, -				{ "Write",        _Write        }, -				{ "Flush",        _Flush        }, -				{ "Tell",         _Tell         }, -				{ "Seek",         _Seek         }, -				{ "SetBuffer",    _SetBuffer    }, -				{ "GetBuffer",    _GetBuffer    }, -				{ "GetFileName",  _GetFileName  }, -				{ "GetExtension", _GetExtension }, -				{ "GetName",      _GetName      } -			); -		} - -		LUAX_POSTPROCESS(File) -		{ -			LUAX_REGISTER_ENUM(state, "EFileMode", -				{ "CLOSED",	FILE_MODE_CLOSED }, -				{ "READ",		FILE_MODE_READ   }, -				{ "WRITE",	FILE_MODE_WRITE  }, -				{ "APPEND",	FILE_MODE_APPEND } -			); - -			LUAX_REGISTER_ENUM(state, "EBufferMode",  -				{ "NONE", BUFFER_MODE_NONE},  -				{ "LINE", BUFFER_MODE_LINE},  -				{ "FULL", BUFFER_MODE_FULL}  -			); -		} - -		// file = File.New(name) -		LUAX_IMPL_METHOD(File, _New) -		{ -			LUAX_STATE(L); - -			cc8* name = state.CheckValue<cc8*>(1);  -			File* file = new File(name); -			file->PushLuaxUserdata(state);  -			return 1; -		} - -		// successsed = file:Open(mode) -		LUAX_IMPL_METHOD(File, _Open) -		{ -			LUAX_PREPARE(L, File);  - -			File::FileMode mode = (File::FileMode)state.CheckValue<int>(2); -			state.Push(self->Open(mode)); -			return 1; -		} - -		// successed = file:Close()   -		LUAX_IMPL_METHOD(File, _Close) -		{ -			LUAX_PREPARE(L, File); - -			state.Push(self->Close()); -			return 1; -		} - -		// opened = file:IsOpen()  -		LUAX_IMPL_METHOD(File, _IsOpen) -		{ -			LUAX_PREPARE(L, File); - -			state.Push(self->IsOpen()); -			return 1; -		} - -		// mode = file:GetMode()  -		LUAX_IMPL_METHOD(File, _GetMode) -		{ -			LUAX_PREPARE(L, File); - -			File::FileMode mode = self->GetMode(); -			state.Push((int)mode); -			return 1; -		} - -		// size = file:GetSize()  -		LUAX_IMPL_METHOD(File, _GetSize) -		{ -			LUAX_PREPARE(L, File); - -			state.Push(self->GetSize()); -			return 1; -		} - -		// size = file:Read(dst, len) -		// returns: -		//   size ʵʶĴС -		// params:  -		//   self ļ -		//   dst  Ŀ껺 -		//   len  ĴС -		LUAX_IMPL_METHOD(File, _Read) -		{ -			LUAX_PREPARE(L, File); - -			DataBuffer* db = state.CheckUserdata<DataBuffer>(2); -			if (!db) return state.ErrorType(2, "DataBuffer"); -			int len = state.CheckValue<int>(3); -			int size = self->Read(db, len); -			state.Push(size);  -			return 1; -		} - -		// isEOF = file:IsEOF() -		LUAX_IMPL_METHOD(File, _IsEOF) -		{ -			LUAX_PREPARE(L, File); - -			state.Push(self->IsEOF()); -			return 1; -		} - -		// isWrite = file:Write(data buffer[, size]) -		LUAX_IMPL_METHOD(File, _Write) -		{ -			LUAX_PREPARE(L, File); - -			DataBuffer* db = state.CheckUserdata<DataBuffer>(2); -			if (!db) return state.ErrorType(2, "DataBuffer"); -			state.Push(self->Write(db)); -			return 1; -		} - -		// isFlushed = file:Flush()  -		LUAX_IMPL_METHOD(File, _Flush) -		{ -			LUAX_PREPARE(L, File); - -			state.Push(self->Flush()); -			return 1; -		} - -		// pos = file:Tell()  -		LUAX_IMPL_METHOD(File, _Tell) -		{ -			LUAX_PREPARE(L, File); - -			state.Push(self->Tell()); -			return 1; -		} - -		// isSeek = file:Seek(pos) -		LUAX_IMPL_METHOD(File, _Seek) -		{ -			LUAX_PREPARE(L, File); - -			int pos = state.CheckValue<int>(2); -			state.Push(self->Seek(pos)); -			return 1; -		} - -		// isSetted = file:SetBuffer(mode, size) -		LUAX_IMPL_METHOD(File, _SetBuffer) -		{ -			LUAX_PREPARE(L, File); - -			BufferMode mode = (BufferMode)state.CheckValue<int>(2); -			int size = state.CheckValue<int>(3); -			state.Push(self->SetBuffer(mode, size)); -			return 1; -		} - -		// size, mode = file:GetBuffer()  -		LUAX_IMPL_METHOD(File, _GetBuffer) -		{ -			LUAX_PREPARE(L, File); - -			size_t size = 0;  -			BufferMode mode = self->GetBuffer(ASURA_OUT size);  -			state.Push((int)size); -			state.Push((int)mode); -			return 2; -		} - -		// name = file:GetFileName()  -		LUAX_IMPL_METHOD(File, _GetFileName) -		{ -			LUAX_PREPARE(L, File); - -			state.Push(self->GetFileName()); -			return 1; -		} - -		// name = file:GetExtension()  -		LUAX_IMPL_METHOD(File, _GetExtension) -		{ -			LUAX_PREPARE(L, File); - -			state.Push(self->GetExtension()); -			return 1; -		} - -		// name = file:GetName()  -		LUAX_IMPL_METHOD(File, _GetName) -		{ -			LUAX_PREPARE(L, File); - -			state.Push(self->GetName()); -			return 1; -		} - -	} -}
\ No newline at end of file diff --git a/source/modules/asura-utils/IO/binding/_file_data.cpp b/source/modules/asura-utils/IO/binding/_file_data.cpp deleted file mode 100644 index 55cbc8b..0000000 --- a/source/modules/asura-utils/IO/binding/_file_data.cpp +++ /dev/null @@ -1,60 +0,0 @@ -#include "../FileData.h" - -using namespace std; - -namespace AsuraEngine -{ -	namespace IO -	{ - -		LUAX_REGISTRY(FileData) -		{ -			LUAX_REGISTER_METHODS(state,  -				{ "GetFileName",   _GetFileName   }, -				{ "GetExtension",  _GetExtension  }, -				{ "GetName",       _GetName       }, -				{ "GetDataBuffer", _GetDataBuffer } -			); -		} - -		LUAX_POSTPROCESS(FileData) -		{ -		} - -		// filename = filedata:GetFileName() -		LUAX_IMPL_METHOD(FileData, _GetFileName) -		{ -			LUAX_PREPARE(L, FileData); -			string filename = self->GetFileName();  -			state.Push(filename); -			return 1; -		} - -		// extension = filedata:GetExtension() -		LUAX_IMPL_METHOD(FileData, _GetExtension) -		{ -			LUAX_PREPARE(L, FileData); -			string extension = self->GetExtension(); -			state.Push(extension); -			return 1; -		} - -		// name = filedata:GetName() -		LUAX_IMPL_METHOD(FileData, _GetName) -		{ -			LUAX_PREPARE(L, FileData); -			string extension = self->GetName(); -			state.Push(extension); -			return 1; -		} - -		// databuffer = filedata:GetDataBuffer() -		LUAX_IMPL_METHOD(FileData, _GetDataBuffer) -		{ -			LUAX_PREPARE(L, FileData); -			self->PushLuaxMemberRef(state, self->m_DataRef); -			return 1; -		} - -	} -}
\ No newline at end of file diff --git a/source/modules/asura-utils/IO/binding/_file_system.cpp b/source/modules/asura-utils/IO/binding/_file_system.cpp deleted file mode 100644 index ace3c5f..0000000 --- a/source/modules/asura-utils/IO/binding/_file_system.cpp +++ /dev/null @@ -1,265 +0,0 @@ -#include "../FileSystem.h" - -using namespace Luax; - -namespace AsuraEngine -{ -	namespace IO -	{ - -#define PREPARE(l) \ -	LUAX_STATE(l); \ -	Filesystem* fs = Filesystem::Get(); - -		LUAX_REGISTRY(Filesystem) -		{ -			LUAX_REGISTER_METHODS(state,  -				{ "Init",              _Init              }, -				{ "Mount",             _Mount             }, -				{ "Unmount",           _Unmount           }, -				{ "GetMountPoint",     _GetMountPoint     }, -				{ "SetWriteDirectory", _SetWriteDirectory }, -				{ "GetWriteDirectory", _GetWriteDirectory }, -				{ "CreateFile",        _CreateFile        }, -				{ "CreateDirectory",   _CreateDirectory   }, -				{ "Write",             _Write             }, -				{ "Append",            _Append            }, -				{ "Remove",            _Remove            }, -				{ "Read",              _Read              }, -				{ "GetFileInfo",       _GetFileInfo       }, -				{ "GetDirectoryItems", _GetDirectoryItems } -			); -		} - -		LUAX_POSTPROCESS(Filesystem) -		{ -			LUAX_REGISTER_ENUM(state, "EFileType", -				{ "FILE",      FILE_TYPE_FILE      }, -				{ "DIRECTORY", FILE_TYPE_DIRECTORY }, -				{ "SYMLINK",   FILE_TYPE_SYMLINK   }, -				{ "OTHER",     FILE_TYPE_OTHER     } -			); -		} - -		// Filesystem.Init(arg0) -		LUAX_IMPL_METHOD(Filesystem, _Init) -		{ -			PREPARE(L); - -			const char* arg0 = state.CheckValue<const char*>(1); -			fs->Init(arg0); -			return 0; -		} - -		// successed = Filesystem.Mount(path, mountpoint[, prepend = false]) -		// successed = Filesystem.Mount(data buffer, archievename, mountpoint[, prepend = false]) -		LUAX_IMPL_METHOD(Filesystem, _Mount) -		{ -			PREPARE(L); -			bool mounted = false; - -			if (state.IsType(1, LUA_TSTRING)) -			{ -				cc8* path = state.GetValue<cc8*>(1, ""); -				cc8* moutpoint = state.GetValue<cc8*>(2, "/"); -				bool prepend = state.GetValue<bool>(3, false); -				mounted = fs->Mount(path, moutpoint, prepend); -			} -			else if (state.IsType(1, LUA_TUSERDATA)) -			{ -				DataBuffer* db = state.CheckUserdata<DataBuffer>(1); -				if (!db) -					return state.ErrorType(1, "Data Buffer"); -				cc8* arcname = state.GetValue<cc8*>(2, ""); -				cc8* mountpoint = state.GetValue<cc8*>(3, "/"); -				bool prepend = state.GetValue<bool>(4, false); -				mounted = fs->Mount(db, arcname, mountpoint, prepend); -				// retain -				fs->LuaxRetain<DataBuffer>(state, db); -			} -			state.Push(mounted); -			return 1; -		} - -		// successed = Filesystem.Unmount(path)  -		// successed = Filesystem.Unmount(data buffer) -		LUAX_IMPL_METHOD(Filesystem, _Unmount) -		{ -			PREPARE(L);  -			bool unmounted = false; - -			if (state.IsType(1, LUA_TSTRING)) -			{ -				cc8* path = state.GetValue<cc8*>(1, ""); -				unmounted = fs->Unmount(path); -			} -			else if (state.IsType(1, LUA_TUSERDATA)) -			{ -				DataBuffer* db = state.CheckUserdata<DataBuffer>(1); -				if (!db) -					return state.ErrorType(1, "Data Buffer"); -				unmounted = fs->Unmount(db);  -				if (unmounted) -					fs->LuaxRelease<DataBuffer>(state, db); -			} -			state.Push(unmounted); -			return 1; -		} - -		// moutpoint = Filesystem.GetMountPoint(path)  -		LUAX_IMPL_METHOD(Filesystem, _GetMountPoint) -		{ -			PREPARE(L); - -			cc8* path = state.CheckValue<cc8*>(1); -			std::string mp; -			if (fs->GetMountPoint(path, ASURA_OUT mp)) -				state.Push(mp); -			else -				state.PushNil(); - -			return 1; -		} - -		// Filesystem.SetWriteDirectory(dir) -		LUAX_IMPL_METHOD(Filesystem, _SetWriteDirectory) -		{ -			PREPARE(L); - -			cc8* dir = state.CheckValue<cc8*>(1); -			fs->SetWriteDirectory(dir); -			return 0; -		} - -		// dir = Filesystem.GetWriteDirectory() -		LUAX_IMPL_METHOD(Filesystem, _GetWriteDirectory) -		{ -			PREPARE(L); - -			std::string dir = fs->GetWriteDirectory();  -			state.Push(dir);  -			return 1; -		} - -		// file = Filesystem.CreateFile(name)  -		LUAX_IMPL_METHOD(Filesystem, _CreateFile) -		{ -			PREPARE(L); - -			cc8* name = state.CheckValue<cc8*>(1);  -			File* file = fs->NewFile(name); -			if (file) -				file->PushLuaxUserdata(state); -			else -				state.PushNil();  -			return 1; -		} - -		// successed = Filesystem.CreateDirectory(name)  -		LUAX_IMPL_METHOD(Filesystem, _CreateDirectory) -		{ -			PREPARE(L); - -			cc8* path = state.CheckValue<cc8*>(1);  -			state.Push(fs->NewDirectory(path)); -			return 1; -		} - -		// successed = Filesystem.Write(path, data buffer)  -		LUAX_IMPL_METHOD(Filesystem, _Write) -		{ -			PREPARE(L); - -			cc8* path = state.CheckValue<cc8*>(1); -			DataBuffer* db = state.CheckUserdata<DataBuffer>(2); -			state.Push(fs->Write(path, db)); -			return 1; -		} - -		// successed = Filesystem.Append(path, data buffer)  -		LUAX_IMPL_METHOD(Filesystem, _Append) -		{ -			PREPARE(L); - -			cc8* path = state.CheckValue<cc8*>(1); -			DataBuffer* db = state.CheckUserdata<DataBuffer>(2); -			state.Push(fs->Append(path, db)); -			return 1; -		} - -		// successed = Filesystem.Remove(path)  -		LUAX_IMPL_METHOD(Filesystem, _Remove) -		{ -			PREPARE(L); - -			cc8* path = state.CheckValue<cc8*>(1); -			state.Push(fs->Remove(path)); -			return 1; -		} - -		// filedata = Filesystem.Read(path) -		LUAX_IMPL_METHOD(Filesystem, _Read) -		{ -			PREPARE(L); - -			cc8* path = state.CheckValue<cc8*>(1); -			FileData* fd = fs->Read(path); -			if (fd) -			{ -				fd->m_Data->PushLuaxUserdata(state);  -				fd->SetLuaxMemberRef(state, fd->m_DataRef, -1); // fd->m_DataRef = data buffer -				state.Pop(1); // data buffer -				fd->PushLuaxUserdata(state); -			} -			else -			{ -				state.PushNil(); -			} -			return 1; -		} - -		// fileinfo = Filesystem.GetFileInfo(path) -		LUAX_IMPL_METHOD(Filesystem, _GetFileInfo) -		{ -			PREPARE(L); - -			cc8* path = state.CheckValue<cc8*>(1); -			FileInfo info; -			if (fs->GetFileInfo(path, &info)) -			{ -				lua_newtable(L); // info table  -				state.SetField(-1, "size", info.size); -				state.SetField(-1, "modtime", info.modtime); -				state.SetField(-1, "type", info.type); -			} -			else -			{ -				state.PushNil();  -			} -			return 1; -		} - -		// items = Filesystem.GetDirectoryItems(path) -		LUAX_IMPL_METHOD(Filesystem, _GetDirectoryItems) -		{ -			PREPARE(L); - -			cc8* path = state.CheckValue<cc8*>(1); -			std::vector<std::string> items; -			if(fs->GetDirectoryItems(path, ASURA_OUT items)) -			{ -				lua_newtable(L); // item list  -				for (int i = 0; i < items.size(); ++i) -				{ -					state.SetFieldByIndex(-1, i + 1, items[i]); -				} -			} -			else -			{ -				state.PushNil();  -			} -			return 1; -		} - -	} -}
\ No newline at end of file diff --git a/source/modules/asura-utils/IO/binding/_io_task.cpp b/source/modules/asura-utils/IO/binding/_io_task.cpp deleted file mode 100644 index 058f4fd..0000000 --- a/source/modules/asura-utils/IO/binding/_io_task.cpp +++ /dev/null @@ -1,46 +0,0 @@ -#include "../IOTask.h" - -using namespace std; - -namespace AsuraEngine  -{ -	namespace IO  -	{ -		 -		LUAX_REGISTRY(IOTask) -		{ -			LUAX_REGISTER_METHODS(state, -				{ "New", _New } -			); -		} - -		LUAX_POSTPROCESS(IOTask) -		{ -			LUAX_REGISTER_ENUM(state, "EIOTaskType", -				{ "READ",   IOTASK_TYPE_READ   }, -				{ "WRITE",  IOTASK_TYPE_WRITE  }, -				{ "APPEND", IOTASK_TYPE_APPEND } -			); - -		} - -		// task = IOTask.New(path, buffer, type, callback) -		LUAX_IMPL_METHOD(IOTask, _New) -		{ -			LUAX_STATE(L); - -			cc8* path = state.CheckValue<cc8*>(1); -			DataBuffer* db = state.CheckUserdata<DataBuffer>(2); -			IOTaskType type = (IOTaskType)state.CheckValue<int>(3); -			bool cbk = state.GetTop() >= 4 && state.IsType(4, LUA_TFUNCTION); - -			IOTask* task = new IOTask(path, db, type); -			task->SetLuaxMemberRef(state, task->m_BufferRef, 2); -			if(cbk) -				task->SetLuaxMemberRef(state, task->m_Callback, 4); -			task->PushLuaxUserdata(state); -			return 1; -		} - -	} -} diff --git a/source/modules/asura-utils/Manager.hpp b/source/modules/asura-utils/Manager.hpp deleted file mode 100644 index c6817b1..0000000 --- a/source/modules/asura-utils/Manager.hpp +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef _ASURA_ENGINE_MANAGER_H_ -#define _ASURA_ENGINE_MANAGER_H_ - -namespace AsuraEngine -{ - -	class Manager -	{ - -	}; - -} - -#endif
\ No newline at end of file diff --git a/source/modules/asura-utils/Math/Curve.cpp b/source/modules/asura-utils/Math/Curve.cpp deleted file mode 100644 index e69de29..0000000 --- a/source/modules/asura-utils/Math/Curve.cpp +++ /dev/null diff --git a/source/modules/asura-utils/Math/Curve.h b/source/modules/asura-utils/Math/Curve.h deleted file mode 100644 index e69de29..0000000 --- a/source/modules/asura-utils/Math/Curve.h +++ /dev/null diff --git a/source/modules/asura-utils/Math/Functions.cpp b/source/modules/asura-utils/Math/Functions.cpp deleted file mode 100644 index e69de29..0000000 --- a/source/modules/asura-utils/Math/Functions.cpp +++ /dev/null diff --git a/source/modules/asura-utils/Math/Functions.h b/source/modules/asura-utils/Math/Functions.h deleted file mode 100644 index e69de29..0000000 --- a/source/modules/asura-utils/Math/Functions.h +++ /dev/null diff --git a/source/modules/asura-utils/Math/Matrix44.cpp b/source/modules/asura-utils/Math/Matrix44.cpp deleted file mode 100644 index 9ecf448..0000000 --- a/source/modules/asura-utils/Math/Matrix44.cpp +++ /dev/null @@ -1,217 +0,0 @@ -#include "Matrix44.h" - -#include <cstring> // memcpy -#include <cmath> - -namespace AsuraEngine -{ -	namespace Math -	{ - -		const Matrix44 Matrix44::Identity; - -		// | e0 e4 e8  e12 | -		// | e1 e5 e9  e13 | -		// | e2 e6 e10 e14 | -		// | e3 e7 e11 e15 | - -		Matrix44::Matrix44() -		{ -			SetIdentity(); -		} - -		Matrix44::Matrix44(const Matrix44& m) -		{ -			memcpy(&e, &m.e, 16 * sizeof(float)); -		} - -		Matrix44::~Matrix44() -		{ -		} - -		void Matrix44::operator = (const Matrix44& m) -		{ -			memcpy(&e, &m.e, 16 * sizeof(float)); -		} - -		void Matrix44::SetOrtho(float l, float r, float b, float t, float n, float f) -		{ -			SetIdentity(); -			float w = r - l; -			float h = t - b; -			float z = f - n; -			e[0] = 2 / w; -			e[5] = 2 / h; -			e[10] = -2 / z; -			e[12] = -(r + l) / w; -			e[13] = -(t + b) / h; -			e[14] = -(f + n) / z; -			e[15] = 1; -		} - -		//                 | e0 e4 e8  e12 | -		//                 | e1 e5 e9  e13 | -		//                 | e2 e6 e10 e14 | -		//                 | e3 e7 e11 e15 | -		// | e0 e4 e8  e12 | -		// | e1 e5 e9  e13 | -		// | e2 e6 e10 e14 | -		// | e3 e7 e11 e15 | - -		Matrix44 Matrix44::operator * (const Matrix44 & m) const -		{ -			Matrix44 t; - -			t.e[0] = (e[0] * m.e[0]) + (e[4] * m.e[1]) + (e[8] * m.e[2]) + (e[12] * m.e[3]); -			t.e[4] = (e[0] * m.e[4]) + (e[4] * m.e[5]) + (e[8] * m.e[6]) + (e[12] * m.e[7]); -			t.e[8] = (e[0] * m.e[8]) + (e[4] * m.e[9]) + (e[8] * m.e[10]) + (e[12] * m.e[11]); -			t.e[12] = (e[0] * m.e[12]) + (e[4] * m.e[13]) + (e[8] * m.e[14]) + (e[12] * m.e[15]); - -			t.e[1] = (e[1] * m.e[0]) + (e[5] * m.e[1]) + (e[9] * m.e[2]) + (e[13] * m.e[3]); -			t.e[5] = (e[1] * m.e[4]) + (e[5] * m.e[5]) + (e[9] * m.e[6]) + (e[13] * m.e[7]); -			t.e[9] = (e[1] * m.e[8]) + (e[5] * m.e[9]) + (e[9] * m.e[10]) + (e[13] * m.e[11]); -			t.e[13] = (e[1] * m.e[12]) + (e[5] * m.e[13]) + (e[9] * m.e[14]) + (e[13] * m.e[15]); - -			t.e[2] = (e[2] * m.e[0]) + (e[6] * m.e[1]) + (e[10] * m.e[2]) + (e[14] * m.e[3]); -			t.e[6] = (e[2] * m.e[4]) + (e[6] * m.e[5]) + (e[10] * m.e[6]) + (e[14] * m.e[7]); -			t.e[10] = (e[2] * m.e[8]) + (e[6] * m.e[9]) + (e[10] * m.e[10]) + (e[14] * m.e[11]); -			t.e[14] = (e[2] * m.e[12]) + (e[6] * m.e[13]) + (e[10] * m.e[14]) + (e[14] * m.e[15]); - -			t.e[3] = (e[3] * m.e[0]) + (e[7] * m.e[1]) + (e[11] * m.e[2]) + (e[15] * m.e[3]); -			t.e[7] = (e[3] * m.e[4]) + (e[7] * m.e[5]) + (e[11] * m.e[6]) + (e[15] * m.e[7]); -			t.e[11] = (e[3] * m.e[8]) + (e[7] * m.e[9]) + (e[11] * m.e[10]) + (e[15] * m.e[11]); -			t.e[15] = (e[3] * m.e[12]) + (e[7] * m.e[13]) + (e[11] * m.e[14]) + (e[15] * m.e[15]); - -			return t; -		} - -		void Matrix44::operator *= (const Matrix44 & m) -		{ -			Matrix44 t = (*this) * m; -			memcpy((void*)this->e, (void*)t.e, sizeof(float) * 16); -		} - -		const float * Matrix44::GetElements() const -		{ -			return e; -		} - -		void Matrix44::SetIdentity() -		{ -			memset(e, 0, sizeof(float) * 16); -			e[0] = e[5] = e[10] = e[15] = 1; -		} - -		void Matrix44::SetTranslation(float x, float y) -		{ -			SetIdentity(); -			e[12] = x; -			e[13] = y; -		} - -		void Matrix44::SetRotation(float rad) -		{ -			SetIdentity(); -			float c = cos(rad), s = sin(rad); -			e[0] = c; e[4] = -s; -			e[1] = s; e[5] = c; -		} - -		void Matrix44::SetScale(float sx, float sy) -		{ -			SetIdentity(); -			e[0] = sx; -			e[5] = sy; -		} - -		void Matrix44::SetShear(float kx, float ky) -		{ -			SetIdentity(); -			e[1] = ky; -			e[4] = kx; -		} - -		void Matrix44::SetTransformation(float x, float y, float angle, float sx, float sy, float ox, float oy) -		{ -			memset(e, 0, sizeof(float) * 16); // zero out matrix -			float c = cos(angle), s = sin(angle); -			// matrix multiplication carried out on paper: -			// |1     x| |c -s    | |sx       | |1     -ox| -			// |  1   y| |s  c    | |   sy    | |  1   -oy| -			// |    1  | |     1  | |      1  | |    1    | -			// |      1| |       1| |        1| |       1 | -			//   move      rotate      scale      origin -			e[10] = e[15] = 1.0f; -			e[0] = c * sx; // = a -			e[1] = s * sx; // = b -			e[4] = -s * sy; // = c -			e[5] = c * sy; // = d -			e[12] = x - ox * e[0] - oy * e[4]; -			e[13] = y - ox * e[1] - oy * e[5]; -		} - -		void Matrix44::Translate(float x, float y) -		{ -			Matrix44 t; -			t.SetTranslation(x, y); -			this->operator *=(t); -		} - -		void Matrix44::Rotate(float rad) -		{ -			Matrix44 t; -			t.SetRotation(rad); -			this->operator *=(t); -		} - -		void Matrix44::Scale(float sx, float sy) -		{ -			Matrix44 t; -			t.SetScale(sx, sy); -			this->operator *=(t); -		} - -		void Matrix44::Shear(float kx, float ky) -		{ -			Matrix44 t; -			t.SetShear(kx, ky); -			this->operator *=(t); -		} - -		void Matrix44::Transform(float x, float y, float angle, float sx, float sy, float ox, float oy) -		{ -			Matrix44 t;  -			t.SetTransformation(x, y, angle, sx, sy, ox, oy); -			this->operator *=(t); -		} - -		void Matrix44::Ortho(float left, float right, float bottom, float top, float near, float far) -		{ -			Matrix44 t; -			t.SetOrtho(left, right, bottom, top, near, far); -			this->operator *=(t); -		} - -		//                 | x | -		//                 | y | -		//                 | 0 | -		//                 | 1 | -		// | e0 e4 e8  e12 | -		// | e1 e5 e9  e13 | -		// | e2 e6 e10 e14 | -		// | e3 e7 e11 e15 | - -		//void Matrix44::transform(Graphics::Vertex* dst, const Graphics::Vertex* src, int size) const -		//{ -		//	for (int i = 0; i<size; ++i) -		//	{ -		//		// Store in temp variables in case src = dst -		//		float x = (e[0] * src[i].xy.x()) + (e[4] * src[i].xy.y()) + (0) + (e[12]); -		//		float y = (e[1] * src[i].xy.x()) + (e[5] * src[i].xy.y()) + (0) + (e[13]); - -		//		dst[i].xy.Set(x, y); -		//	} -		//} - -	} // namespace Math -} // namespace JinEngine
\ No newline at end of file diff --git a/source/modules/asura-utils/Math/Matrix44.h b/source/modules/asura-utils/Math/Matrix44.h deleted file mode 100644 index 503242f..0000000 --- a/source/modules/asura-utils/Math/Matrix44.h +++ /dev/null @@ -1,96 +0,0 @@ -#ifndef _ASURA_MATRIX_H_ -#define _ASURA_MATRIX_H_ - -#include <asura-utils/Classes.h> - -#include "../Scripting/Portable.hpp" - -namespace_begin(AsuraEngine) -namespace_begin(Math) - -/// ҪתõOpenGLglm::mat4 -/// https://blog.csdn.net/candycat1992/article/details/8830894 -class Matrix44 -{ -public: - -	static const Matrix44 Identity; - -	Matrix44(); - -	Matrix44(const Matrix44& m); - -	~Matrix44(); - -	void operator = (const Matrix44& m); - -	void SetOrtho(float _left, float _right, float _bottom, float _top, float _near, float _far); - -	Matrix44 operator * (const Matrix44 & m) const; - -	void operator *= (const Matrix44 & m); - -	const float* GetElements() const; - -	void SetIdentity(); - -	void SetTranslation(float x, float y); - -	void SetRotation(float r); - -	void SetScale(float sx, float sy); - -	void SetShear(float kx, float ky); - -	void SetTransformation(float x, float y, float angle, float sx, float sy, float ox, float oy); - -	void Translate(float x, float y); - -	void Rotate(float r); - -	void Scale(float sx, float sy); - -	void Transform(float x, float y, float angle, float sx, float sy, float ox, float oy); - -	///  -	/// Multiplies this Matrix44 with a shear transformation. -	/// @param kx Shear along the x-axis. -	/// @param ky Shear along the y-axis. -	///  -	void Shear(float kx, float ky); - -	void Ortho(float left, float right, float bottom, float top, float near, float far); - -	/////  -	///// Transforms an array of vertices by this Matrix44. The sources and -	///// destination arrays may be the same. -	///// -	///// @param dst Storage for the transformed vertices. -	///// @param src The source vertices. -	///// @param size The number of vertices. -	/////  -	//void transform(Graphics::Vertex* dst, const Graphics::Vertex * src, int size) const; - -	/// -	/// ʽ -	/// -	float Calculate(); - -private: - -	///  -	/// | e0 e4 e8  e12 | -	/// | e1 e5 e9  e13 | -	/// | e2 e6 e10 e14 | -	/// | e3 e7 e11 e15 | -	/// -	float e[16]; - -}; - -namespace_end -namespace_end - -namespace AEMath = AsuraEngine::Math; - -#endif
\ No newline at end of file diff --git a/source/modules/asura-utils/Math/Quaternion.cpp b/source/modules/asura-utils/Math/Quaternion.cpp deleted file mode 100644 index e69de29..0000000 --- a/source/modules/asura-utils/Math/Quaternion.cpp +++ /dev/null diff --git a/source/modules/asura-utils/Math/Quaternion.h b/source/modules/asura-utils/Math/Quaternion.h deleted file mode 100644 index e69de29..0000000 --- a/source/modules/asura-utils/Math/Quaternion.h +++ /dev/null diff --git a/source/modules/asura-utils/Math/Rand/Rand.h b/source/modules/asura-utils/Math/Rand/Rand.h deleted file mode 100644 index 74b1102..0000000 --- a/source/modules/asura-utils/Math/Rand/Rand.h +++ /dev/null @@ -1,88 +0,0 @@ -#ifndef RAND_H -#define RAND_H - -#include "../../Type.h" -#include "../../Classes.h" - -namespace_begin(AsuraEngine) -namespace_begin(Math) - -/* -Some random generator timings: -MacBook Pro w/ Core 2 Duo 2.4GHz. Times are for gcc 4.0.1 (OS X 10.6.2) / VS2008 SP1 (Win XP SP3), -in milliseconds for this loop (4915200 calls): - -for (int j = 0; j < 100; ++j) -for (int i = 0; i < 128*128*3; ++i) -data[i] = (rnd.get() & 0x3) << 6; - -gcc   vs2008    Size -C's rand():       57.0  109.3 ms     1 -Mersenne Twister: 56.0   37.4 ms  2500 -Unity 2.x LCG:    11.1    9.2 ms     4 -Xorshift 128:     15.0   17.8 ms    16 -Xorshift 32:      20.6   10.7 ms     4 -WELL 512:         43.6   55.1 ms    68 -*/ - -// Xorshift 128 implementation -// Xorshift paper: http://www.jstatsoft.org/v08/i14/paper -// Wikipedia: http://en.wikipedia.org/wiki/Xorshift -class Rand { -public: - -	Rand(uint32 seed = 0) -	{ -		SetSeed(seed); -	} - -	uint32 Get() -	{ -		uint32 t; -		t = x ^ (x << 11); -		x = y; y = z; z = w; -		return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); -	} - -	inline static float GetFloatFromInt(uint32 value) -	{ -		// take 23 bits of integer, and divide by 2^23-1 -		return float(value & 0x007FFFFF) * (1.0f / 8388607.0f); -	} - -	inline static uint8 GetByteFromInt(uint32 value) -	{ -		// take the most significant byte from the 23-bit value -		return uint8(value >> (23 - 8)); -	} - -	// random number between 0.0 and 1.0 -	float GetFloat() -	{ -		return GetFloatFromInt(Get()); -	} - -	// random number between -1.0 and 1.0 -	float GetSignedFloat() -	{ -		return GetFloat() * 2.0f - 1.0f; -	} - -	void SetSeed(uint32 seed) -	{ -		x = seed; -		y = x * 1812433253U + 1; -		z = y * 1812433253U + 1; -		w = z * 1812433253U + 1; -	} - -	uint32 GetSeed() const { return x; } - -private: -	uint32 x, y, z, w; -}; - -namespace_end -namespace_end - -#endif
\ No newline at end of file diff --git a/source/modules/asura-utils/Math/Rand/Random.h b/source/modules/asura-utils/Math/Rand/Random.h deleted file mode 100644 index cf2fc54..0000000 --- a/source/modules/asura-utils/Math/Rand/Random.h +++ /dev/null @@ -1,9 +0,0 @@ -#include "Rand.h" - -namespace_begin(AsuraEngine) -namespace_begin(Math) - - - -namespace_end -namespace_end
\ No newline at end of file diff --git a/source/modules/asura-utils/Math/RangedValue.cpp b/source/modules/asura-utils/Math/RangedValue.cpp deleted file mode 100644 index e69de29..0000000 --- a/source/modules/asura-utils/Math/RangedValue.cpp +++ /dev/null diff --git a/source/modules/asura-utils/Math/RangedValue.h b/source/modules/asura-utils/Math/RangedValue.h deleted file mode 100644 index e69de29..0000000 --- a/source/modules/asura-utils/Math/RangedValue.h +++ /dev/null diff --git a/source/modules/asura-utils/Math/Rect.hpp b/source/modules/asura-utils/Math/Rect.hpp deleted file mode 100644 index 45bf1ba..0000000 --- a/source/modules/asura-utils/Math/Rect.hpp +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef _ASURA_ENGINE_RECT_H_ -#define _ASURA_ENGINE_RECT_H_ - -namespace AsuraEngine -{ -	namespace Math -	{ -		 -		template<typename T>  -		struct Rect -		{ -		public: -			Rect(); -			Rect(T x, T y, T w, T h); -			~Rect() {}; - -			/// -			/// x,yǷrectڡ -			/// -			bool Contain(T x, T y); - -			/// -			/// Ƿཻཻľ -			/// -			bool Intersect(const Rect& src, Rect& intersection); -			 -			/// -			///  Ƿཻཻľ -			/// -			static bool Intersect(const Rect<T>& src1, const Rect<T>& src2, Rect<T>& intersection); - -			void Set(T x, T y, T w, T h); - -			T x, y, w, h; -		}; -		 -#include "Rect.inc" - -		// Define the most common types -		typedef Rect<int>          Recti; -		typedef Rect<unsigned int> Rectu; -		typedef Rect<float>        Rectf; -		typedef Rect<long>         Reftl; - -	} -} - -namespace AEMath = AsuraEngine::Math; - -#endif
\ No newline at end of file diff --git a/source/modules/asura-utils/Math/Rect.inc b/source/modules/asura-utils/Math/Rect.inc deleted file mode 100644 index efafbf9..0000000 --- a/source/modules/asura-utils/Math/Rect.inc +++ /dev/null @@ -1,28 +0,0 @@ -template <typename T> -inline Rect<T>::Rect()  -	: x(0) -	, y(0) -	, w(0) -	, h(0) -{ - -} - -template <typename T> -inline Rect<T>::Rect(T X, T Y, T W, T H) -	: x(X) -	, y(Y) -	, w(W) -	, h(H) -{ - -} - -template <typename T>  -void Rect<T>::Set(T X, T Y, T W, T H) -{ -	x = X; -	y = Y; -	w = W; -	h = H; -}
\ No newline at end of file diff --git a/source/modules/asura-utils/Math/Transform.cpp b/source/modules/asura-utils/Math/Transform.cpp deleted file mode 100644 index e69de29..0000000 --- a/source/modules/asura-utils/Math/Transform.cpp +++ /dev/null diff --git a/source/modules/asura-utils/Math/Transform.h b/source/modules/asura-utils/Math/Transform.h deleted file mode 100644 index 23d0709..0000000 --- a/source/modules/asura-utils/Math/Transform.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef _ASURA_ENGINE_TRANSFORM_H_ -#define _ASURA_ENGINE_TRANSFORM_H_ - -#include "../scripting/Portable.hpp" - -namespace AsuraEngine -{ -	namespace Math -	{ - -		class Transform -		{ -		public: - -			void Set(float x, float y, float sx, float sy, float ox, float oy, float r); - -			void LoadIdentity(); - -			void Move(float dx = 0, float dy = 0); -			void Rotate(float r); -			void Scale(float sx, float sy); - -			float m[16]; //4x4 matrix - -		}; - -	} -} - -#endif
\ No newline at end of file diff --git a/source/modules/asura-utils/Math/Vector2.hpp b/source/modules/asura-utils/Math/Vector2.hpp deleted file mode 100644 index 326a57e..0000000 --- a/source/modules/asura-utils/Math/Vector2.hpp +++ /dev/null @@ -1,72 +0,0 @@ -#ifndef _ASURA_ENGINE_VECTOR2_H__ -#define _ASURA_ENGINE_VECTOR2_H__ - -#include <asura-utils/Classes.h> - -namespace_begin(AsuraEngine) -namespace_begin(Math) - -template <typename T> -class Vector2 -{ -public: -	Vector2(); -	Vector2(T X, T Y); - -	template <typename U> -	explicit Vector2(const Vector2<U>& vector); - -	void Set(T X, T Y); - -	T x; ///< X coordinate of the vector -	T y; ///< Y coordinate of the vector -}; - -template <typename T> -Vector2<T> operator -(const Vector2<T>& right); - -template <typename T> -Vector2<T>& operator +=(Vector2<T>& left, const Vector2<T>& right); - -template <typename T> -Vector2<T>& operator -=(Vector2<T>& left, const Vector2<T>& right); - -template <typename T> -Vector2<T> operator +(const Vector2<T>& left, const Vector2<T>& right); - -template <typename T> -Vector2<T> operator -(const Vector2<T>& left, const Vector2<T>& right); - -template <typename T> -Vector2<T> operator *(const Vector2<T>& left, T right); - -template <typename T> -Vector2<T> operator *(T left, const Vector2<T>& right); - -template <typename T> -Vector2<T>& operator *=(Vector2<T>& left, T right); - -template <typename T> -Vector2<T> operator /(const Vector2<T>& left, T right); - -template <typename T> -Vector2<T>& operator /=(Vector2<T>& left, T right); - -template <typename T> -bool operator ==(const Vector2<T>& left, const Vector2<T>& right); - -template <typename T> -bool operator !=(const Vector2<T>& left, const Vector2<T>& right); - -#include "Vector2.inc" - -typedef Vector2<int>          Vector2i; -typedef Vector2<unsigned int> Vector2u; -typedef Vector2<float>        Vector2f; - -namespace_end -namespace_end - -namespace AEMath = AsuraEngine::Math; - -#endif
\ No newline at end of file diff --git a/source/modules/asura-utils/Math/Vector2.inc b/source/modules/asura-utils/Math/Vector2.inc deleted file mode 100644 index 155432a..0000000 --- a/source/modules/asura-utils/Math/Vector2.inc +++ /dev/null @@ -1,114 +0,0 @@ -template <typename T> -inline Vector2<T>::Vector2() : -	x(0), -	y(0) -{ - -} - -template <typename T> -inline Vector2<T>::Vector2(T X, T Y) : -	x(X), -	y(Y) -{ - -} - -template <typename T> -template <typename U> -inline Vector2<T>::Vector2(const Vector2<U>& vector) : -	x(static_cast<T>(vector.x)), -	y(static_cast<T>(vector.y)) -{ -} - -template <typename T> -inline void Vector2<T>::Set(T X, T Y) -{ -	x = X; -	y = Y; -} - -template <typename T> -inline Vector2<T> operator -(const Vector2<T>& right) -{ -	return Vector2<T>(-right.x, -right.y); -} - -template <typename T> -inline Vector2<T>& operator +=(Vector2<T>& left, const Vector2<T>& right) -{ -	left.x += right.x; -	left.y += right.y; - -	return left; -} - -template <typename T> -inline Vector2<T>& operator -=(Vector2<T>& left, const Vector2<T>& right) -{ -	left.x -= right.x; -	left.y -= right.y; - -	return left; -} - -template <typename T> -inline Vector2<T> operator +(const Vector2<T>& left, const Vector2<T>& right) -{ -	return Vector2<T>(left.x + right.x, left.y + right.y); -} - -template <typename T> -inline Vector2<T> operator -(const Vector2<T>& left, const Vector2<T>& right) -{ -	return Vector2<T>(left.x - right.x, left.y - right.y); -} - -template <typename T> -inline Vector2<T> operator *(const Vector2<T>& left, T right) -{ -	return Vector2<T>(left.x * right, left.y * right); -} - -template <typename T> -inline Vector2<T> operator *(T left, const Vector2<T>& right) -{ -	return Vector2<T>(right.x * left, right.y * left); -} - -template <typename T> -inline Vector2<T>& operator *=(Vector2<T>& left, T right) -{ -	left.x *= right; -	left.y *= right; - -	return left; -} - -template <typename T> -inline Vector2<T> operator /(const Vector2<T>& left, T right) -{ -	return Vector2<T>(left.x / right, left.y / right); -} - -template <typename T> -inline Vector2<T>& operator /=(Vector2<T>& left, T right) -{ -	left.x /= right; -	left.y /= right; - -	return left; -} - -template <typename T> -inline bool operator ==(const Vector2<T>& left, const Vector2<T>& right) -{ -	return (left.x == right.x) && (left.y == right.y); -} - -template <typename T> -inline bool operator !=(const Vector2<T>& left, const Vector2<T>& right) -{ -	return (left.x != right.x) || (left.y != right.y); -} diff --git a/source/modules/asura-utils/Math/Vector3.hpp b/source/modules/asura-utils/Math/Vector3.hpp deleted file mode 100644 index c526ace..0000000 --- a/source/modules/asura-utils/Math/Vector3.hpp +++ /dev/null @@ -1,235 +0,0 @@ -#ifndef _ASURA_ENGINE_VECTOR3_H__ -#define _ASURA_ENGINE_VECTOR3_H__ - -namespace AsuraEngine -{ -	namespace Math -	{ -		template <typename T> -		class Vector3 -		{ -		public: - -			//////////////////////////////////////////////////////////// -			/// \brief Default constructor -			/// -			/// Creates a Vector3(0, 0, 0). -			/// -			//////////////////////////////////////////////////////////// -			Vector3(); - -			//////////////////////////////////////////////////////////// -			/// \brief Construct the vector from its coordinates -			/// -			/// \param X X coordinate -			/// \param Y Y coordinate -			/// \param Z Z coordinate -			/// -			//////////////////////////////////////////////////////////// -			Vector3(T X, T Y, T Z); - -			//////////////////////////////////////////////////////////// -			/// \brief Construct the vector from another type of vector -			/// -			/// This constructor doesn't replace the copy constructor, -			/// it's called only when U != T. -			/// A call to this constructor will fail to compile if U -			/// is not convertible to T. -			/// -			/// \param vector Vector to convert -			/// -			//////////////////////////////////////////////////////////// -			template <typename U> -			explicit Vector3(const Vector3<U>& vector); - -			//////////////////////////////////////////////////////////// -			// Member data -			//////////////////////////////////////////////////////////// -			T x; ///< X coordinate of the vector -			T y; ///< Y coordinate of the vector -			T z; ///< Z coordinate of the vector -		}; - -		//////////////////////////////////////////////////////////// -		/// \relates Vector3 -		/// \brief Overload of unary operator - -		/// -		/// \param left Vector to negate -		/// -		/// \return Memberwise opposite of the vector -		/// -		//////////////////////////////////////////////////////////// -		template <typename T> -		Vector3<T> operator -(const Vector3<T>& left); - -		//////////////////////////////////////////////////////////// -		/// \relates Vector3 -		/// \brief Overload of binary operator += -		/// -		/// This operator performs a memberwise addition of both vectors, -		/// and assigns the result to \a left. -		/// -		/// \param left  Left operand (a vector) -		/// \param right Right operand (a vector) -		/// -		/// \return Reference to \a left -		/// -		//////////////////////////////////////////////////////////// -		template <typename T> -		Vector3<T>& operator +=(Vector3<T>& left, const Vector3<T>& right); - -		//////////////////////////////////////////////////////////// -		/// \relates Vector3 -		/// \brief Overload of binary operator -= -		/// -		/// This operator performs a memberwise subtraction of both vectors, -		/// and assigns the result to \a left. -		/// -		/// \param left  Left operand (a vector) -		/// \param right Right operand (a vector) -		/// -		/// \return Reference to \a left -		/// -		//////////////////////////////////////////////////////////// -		template <typename T> -		Vector3<T>& operator -=(Vector3<T>& left, const Vector3<T>& right); - -		//////////////////////////////////////////////////////////// -		/// \relates Vector3 -		/// \brief Overload of binary operator + -		/// -		/// \param left  Left operand (a vector) -		/// \param right Right operand (a vector) -		/// -		/// \return Memberwise addition of both vectors -		/// -		//////////////////////////////////////////////////////////// -		template <typename T> -		Vector3<T> operator +(const Vector3<T>& left, const Vector3<T>& right); - -		//////////////////////////////////////////////////////////// -		/// \relates Vector3 -		/// \brief Overload of binary operator - -		/// -		/// \param left  Left operand (a vector) -		/// \param right Right operand (a vector) -		/// -		/// \return Memberwise subtraction of both vectors -		/// -		//////////////////////////////////////////////////////////// -		template <typename T> -		Vector3<T> operator -(const Vector3<T>& left, const Vector3<T>& right); - -		//////////////////////////////////////////////////////////// -		/// \relates Vector3 -		/// \brief Overload of binary operator * -		/// -		/// \param left  Left operand (a vector) -		/// \param right Right operand (a scalar value) -		/// -		/// \return Memberwise multiplication by \a right -		/// -		//////////////////////////////////////////////////////////// -		template <typename T> -		Vector3<T> operator *(const Vector3<T>& left, T right); - -		//////////////////////////////////////////////////////////// -		/// \relates Vector3 -		/// \brief Overload of binary operator * -		/// -		/// \param left  Left operand (a scalar value) -		/// \param right Right operand (a vector) -		/// -		/// \return Memberwise multiplication by \a left -		/// -		//////////////////////////////////////////////////////////// -		template <typename T> -		Vector3<T> operator *(T left, const Vector3<T>& right); - -		//////////////////////////////////////////////////////////// -		/// \relates Vector3 -		/// \brief Overload of binary operator *= -		/// -		/// This operator performs a memberwise multiplication by \a right, -		/// and assigns the result to \a left. -		/// -		/// \param left  Left operand (a vector) -		/// \param right Right operand (a scalar value) -		/// -		/// \return Reference to \a left -		/// -		//////////////////////////////////////////////////////////// -		template <typename T> -		Vector3<T>& operator *=(Vector3<T>& left, T right); - -		//////////////////////////////////////////////////////////// -		/// \relates Vector3 -		/// \brief Overload of binary operator / -		/// -		/// \param left  Left operand (a vector) -		/// \param right Right operand (a scalar value) -		/// -		/// \return Memberwise division by \a right -		/// -		//////////////////////////////////////////////////////////// -		template <typename T> -		Vector3<T> operator /(const Vector3<T>& left, T right); - -		//////////////////////////////////////////////////////////// -		/// \relates Vector3 -		/// \brief Overload of binary operator /= -		/// -		/// This operator performs a memberwise division by \a right, -		/// and assigns the result to \a left. -		/// -		/// \param left  Left operand (a vector) -		/// \param right Right operand (a scalar value) -		/// -		/// \return Reference to \a left -		/// -		//////////////////////////////////////////////////////////// -		template <typename T> -		Vector3<T>& operator /=(Vector3<T>& left, T right); - -		//////////////////////////////////////////////////////////// -		/// \relates Vector3 -		/// \brief Overload of binary operator == -		/// -		/// This operator compares strict equality between two vectors. -		/// -		/// \param left  Left operand (a vector) -		/// \param right Right operand (a vector) -		/// -		/// \return True if \a left is equal to \a right -		/// -		//////////////////////////////////////////////////////////// -		template <typename T> -		bool operator ==(const Vector3<T>& left, const Vector3<T>& right); - -		//////////////////////////////////////////////////////////// -		/// \relates Vector3 -		/// \brief Overload of binary operator != -		/// -		/// This operator compares strict difference between two vectors. -		/// -		/// \param left  Left operand (a vector) -		/// \param right Right operand (a vector) -		/// -		/// \return True if \a left is not equal to \a right -		/// -		//////////////////////////////////////////////////////////// -		template <typename T> -		bool operator !=(const Vector3<T>& left, const Vector3<T>& right); - -#include "Vector3.inc" - -		// Define the most common types -		typedef Vector3<int>   Vector3i; -		typedef Vector3<float> Vector3f; - -	} -} - -namespace AEMath = AsuraEngine::Math; - -#endif
\ No newline at end of file diff --git a/source/modules/asura-utils/Math/Vector3.inc b/source/modules/asura-utils/Math/Vector3.inc deleted file mode 100644 index 3a2aa93..0000000 --- a/source/modules/asura-utils/Math/Vector3.inc +++ /dev/null @@ -1,145 +0,0 @@ - - -//////////////////////////////////////////////////////////// -template <typename T> -inline Vector3<T>::Vector3() : -	x(0), -	y(0), -	z(0) -{ - -} - - -//////////////////////////////////////////////////////////// -template <typename T> -inline Vector3<T>::Vector3(T X, T Y, T Z) : -	x(X), -	y(Y), -	z(Z) -{ - -} - - -//////////////////////////////////////////////////////////// -template <typename T> -template <typename U> -inline Vector3<T>::Vector3(const Vector3<U>& vector) : -	x(static_cast<T>(vector.x)), -	y(static_cast<T>(vector.y)), -	z(static_cast<T>(vector.z)) -{ -} - - -//////////////////////////////////////////////////////////// -template <typename T> -inline Vector3<T> operator -(const Vector3<T>& left) -{ -	return Vector3<T>(-left.x, -left.y, -left.z); -} - - -//////////////////////////////////////////////////////////// -template <typename T> -inline Vector3<T>& operator +=(Vector3<T>& left, const Vector3<T>& right) -{ -	left.x += right.x; -	left.y += right.y; -	left.z += right.z; - -	return left; -} - - -//////////////////////////////////////////////////////////// -template <typename T> -inline Vector3<T>& operator -=(Vector3<T>& left, const Vector3<T>& right) -{ -	left.x -= right.x; -	left.y -= right.y; -	left.z -= right.z; - -	return left; -} - - -//////////////////////////////////////////////////////////// -template <typename T> -inline Vector3<T> operator +(const Vector3<T>& left, const Vector3<T>& right) -{ -	return Vector3<T>(left.x + right.x, left.y + right.y, left.z + right.z); -} - - -//////////////////////////////////////////////////////////// -template <typename T> -inline Vector3<T> operator -(const Vector3<T>& left, const Vector3<T>& right) -{ -	return Vector3<T>(left.x - right.x, left.y - right.y, left.z - right.z); -} - - -//////////////////////////////////////////////////////////// -template <typename T> -inline Vector3<T> operator *(const Vector3<T>& left, T right) -{ -	return Vector3<T>(left.x * right, left.y * right, left.z * right); -} - - -//////////////////////////////////////////////////////////// -template <typename T> -inline Vector3<T> operator *(T left, const Vector3<T>& right) -{ -	return Vector3<T>(right.x * left, right.y * left, right.z * left); -} - - -//////////////////////////////////////////////////////////// -template <typename T> -inline Vector3<T>& operator *=(Vector3<T>& left, T right) -{ -	left.x *= right; -	left.y *= right; -	left.z *= right; - -	return left; -} - - -//////////////////////////////////////////////////////////// -template <typename T> -inline Vector3<T> operator /(const Vector3<T>& left, T right) -{ -	return Vector3<T>(left.x / right, left.y / right, left.z / right); -} - - -//////////////////////////////////////////////////////////// -template <typename T> -inline Vector3<T>& operator /=(Vector3<T>& left, T right) -{ -	left.x /= right; -	left.y /= right; -	left.z /= right; - -	return left; -} - - -//////////////////////////////////////////////////////////// -template <typename T> -inline bool operator ==(const Vector3<T>& left, const Vector3<T>& right) -{ -	return (left.x == right.x) && (left.y == right.y) && (left.z == right.z); -} - - -//////////////////////////////////////////////////////////// -template <typename T> -inline bool operator !=(const Vector3<T>& left, const Vector3<T>& right) -{ -	return (left.x != right.x) || (left.y != right.y) || (left.z != right.z); -} diff --git a/source/modules/asura-utils/Math/Vector4.h b/source/modules/asura-utils/Math/Vector4.h deleted file mode 100644 index a5bf549..0000000 --- a/source/modules/asura-utils/Math/Vector4.h +++ /dev/null @@ -1,234 +0,0 @@ -#ifndef _ASURA_ENGINE_VECTOR4_H__ -#define _ASURA_ENGINE_VECTOR4_H__ - -namespace AsuraEngine -{ -	namespace Math -	{ -		template <typename T> -		class Vector4 -		{ -		public: - -			//////////////////////////////////////////////////////////// -			/// \brief Default constructor -			/// -			/// Creates a Vector4(0, 0, 0). -			/// -			//////////////////////////////////////////////////////////// -			Vector4(); - -			//////////////////////////////////////////////////////////// -			/// \brief Construct the vector from its coordinates -			/// -			/// \param X X coordinate -			/// \param Y Y coordinate -			/// \param Z Z coordinate -			/// -			//////////////////////////////////////////////////////////// -			Vector4(T X, T Y, T Z, T W); - -			//////////////////////////////////////////////////////////// -			/// \brief Construct the vector from another type of vector -			/// -			/// This constructor doesn't replace the copy constructor, -			/// it's called only when U != T. -			/// A call to this constructor will fail to compile if U -			/// is not convertible to T. -			/// -			/// \param vector Vector to convert -			/// -			//////////////////////////////////////////////////////////// -			template <typename U> -			explicit Vector4(const Vector4<U>& vector); - -			//////////////////////////////////////////////////////////// -			// Member data -			//////////////////////////////////////////////////////////// -			T x; ///< X coordinate of the vector -			T y; ///< Y coordinate of the vector -			T z; ///< Z coordinate of the vector -			T w; ///< W coordinate of the vector -		}; - -		//////////////////////////////////////////////////////////// -		/// \relates Vector4 -		/// \brief Overload of unary operator - -		/// -		/// \param left Vector to negate -		/// -		/// \return Memberwise opposite of the vector -		/// -		//////////////////////////////////////////////////////////// -		template <typename T> -		Vector4<T> operator -(const Vector4<T>& left); - -		//////////////////////////////////////////////////////////// -		/// \relates Vector4 -		/// \brief Overload of binary operator += -		/// -		/// This operator performs a memberwise addition of both vectors, -		/// and assigns the result to \a left. -		/// -		/// \param left  Left operand (a vector) -		/// \param right Right operand (a vector) -		/// -		/// \return Reference to \a left -		/// -		//////////////////////////////////////////////////////////// -		template <typename T> -		Vector4<T>& operator +=(Vector4<T>& left, const Vector4<T>& right); - -		//////////////////////////////////////////////////////////// -		/// \relates Vector4 -		/// \brief Overload of binary operator -= -		/// -		/// This operator performs a memberwise subtraction of both vectors, -		/// and assigns the result to \a left. -		/// -		/// \param left  Left operand (a vector) -		/// \param right Right operand (a vector) -		/// -		/// \return Reference to \a left -		/// -		//////////////////////////////////////////////////////////// -		template <typename T> -		Vector4<T>& operator -=(Vector4<T>& left, const Vector4<T>& right); - -		//////////////////////////////////////////////////////////// -		/// \relates Vector4 -		/// \brief Overload of binary operator + -		/// -		/// \param left  Left operand (a vector) -		/// \param right Right operand (a vector) -		/// -		/// \return Memberwise addition of both vectors -		/// -		//////////////////////////////////////////////////////////// -		template <typename T> -		Vector4<T> operator +(const Vector4<T>& left, const Vector4<T>& right); - -		//////////////////////////////////////////////////////////// -		/// \relates Vector4 -		/// \brief Overload of binary operator - -		/// -		/// \param left  Left operand (a vector) -		/// \param right Right operand (a vector) -		/// -		/// \return Memberwise subtraction of both vectors -		/// -		//////////////////////////////////////////////////////////// -		template <typename T> -		Vector4<T> operator -(const Vector4<T>& left, const Vector4<T>& right); - -		//////////////////////////////////////////////////////////// -		/// \relates Vector4 -		/// \brief Overload of binary operator * -		/// -		/// \param left  Left operand (a vector) -		/// \param right Right operand (a scalar value) -		/// -		/// \return Memberwise multiplication by \a right -		/// -		//////////////////////////////////////////////////////////// -		template <typename T> -		Vector4<T> operator *(const Vector4<T>& left, T right); - -		//////////////////////////////////////////////////////////// -		/// \relates Vector4 -		/// \brief Overload of binary operator * -		/// -		/// \param left  Left operand (a scalar value) -		/// \param right Right operand (a vector) -		/// -		/// \return Memberwise multiplication by \a left -		/// -		//////////////////////////////////////////////////////////// -		template <typename T> -		Vector4<T> operator *(T left, const Vector4<T>& right); - -		//////////////////////////////////////////////////////////// -		/// \relates Vector4 -		/// \brief Overload of binary operator *= -		/// -		/// This operator performs a memberwise multiplication by \a right, -		/// and assigns the result to \a left. -		/// -		/// \param left  Left operand (a vector) -		/// \param right Right operand (a scalar value) -		/// -		/// \return Reference to \a left -		/// -		//////////////////////////////////////////////////////////// -		template <typename T> -		Vector4<T>& operator *=(Vector4<T>& left, T right); - -		//////////////////////////////////////////////////////////// -		/// \relates Vector4 -		/// \brief Overload of binary operator / -		/// -		/// \param left  Left operand (a vector) -		/// \param right Right operand (a scalar value) -		/// -		/// \return Memberwise division by \a right -		/// -		//////////////////////////////////////////////////////////// -		template <typename T> -		Vector4<T> operator /(const Vector4<T>& left, T right); - -		//////////////////////////////////////////////////////////// -		/// \relates Vector4 -		/// \brief Overload of binary operator /= -		/// -		/// This operator performs a memberwise division by \a right, -		/// and assigns the result to \a left. -		/// -		/// \param left  Left operand (a vector) -		/// \param right Right operand (a scalar value) -		/// -		/// \return Reference to \a left -		/// -		//////////////////////////////////////////////////////////// -		template <typename T> -		Vector4<T>& operator /=(Vector4<T>& left, T right); - -		//////////////////////////////////////////////////////////// -		/// \relates Vector4 -		/// \brief Overload of binary operator == -		/// -		/// This operator compares strict equality between two vectors. -		/// -		/// \param left  Left operand (a vector) -		/// \param right Right operand (a vector) -		/// -		/// \return True if \a left is equal to \a right -		/// -		//////////////////////////////////////////////////////////// -		template <typename T> -		bool operator ==(const Vector4<T>& left, const Vector4<T>& right); - -		//////////////////////////////////////////////////////////// -		/// \relates Vector4 -		/// \brief Overload of binary operator != -		/// -		/// This operator compares strict difference between two vectors. -		/// -		/// \param left  Left operand (a vector) -		/// \param right Right operand (a vector) -		/// -		/// \return True if \a left is not equal to \a right -		/// -		//////////////////////////////////////////////////////////// -		template <typename T> -		bool operator !=(const Vector4<T>& left, const Vector4<T>& right); - -#include "Vector4.inc" - -		// Define the most common types -		typedef Vector4<int>   Vector4i; -		typedef Vector4<float> Vector4f; - -	} -} - -#endif
\ No newline at end of file diff --git a/source/modules/asura-utils/Math/Vector4.inc b/source/modules/asura-utils/Math/Vector4.inc deleted file mode 100644 index 4b043a1..0000000 --- a/source/modules/asura-utils/Math/Vector4.inc +++ /dev/null @@ -1,152 +0,0 @@ - - -//////////////////////////////////////////////////////////// -template <typename T> -inline Vector4<T>::Vector4() : -	x(0), -	y(0), -	z(0), -	w(0) -{ - -} - - -//////////////////////////////////////////////////////////// -template <typename T> -inline Vector4<T>::Vector4(T X, T Y, T Z, T W) : -	x(X), -	y(Y), -	z(Z), -	w(W) -{ - -} - - -//////////////////////////////////////////////////////////// -template <typename T> -template <typename U> -inline Vector4<T>::Vector4(const Vector4<U>& vector) : -	x(static_cast<T>(vector.x)), -	y(static_cast<T>(vector.y)), -	z(static_cast<T>(vector.z)), -	w(static_cast<T>(vector.w)) -{ -} - - -//////////////////////////////////////////////////////////// -template <typename T> -inline Vector4<T> operator -(const Vector4<T>& left) -{ -	return Vector4<T>(-left.x, -left.y, -left.z, -left.w); -} - - -//////////////////////////////////////////////////////////// -template <typename T> -inline Vector4<T>& operator +=(Vector4<T>& left, const Vector4<T>& right) -{ -	left.x += right.x; -	left.y += right.y; -	left.z += right.z; -	left.w += right.w; - -	return left; -} - - -//////////////////////////////////////////////////////////// -template <typename T> -inline Vector4<T>& operator -=(Vector4<T>& left, const Vector4<T>& right) -{ -	left.x -= right.x; -	left.y -= right.y; -	left.z -= right.z; -	left.w -= right.w; - -	return left; -} - - -//////////////////////////////////////////////////////////// -template <typename T> -inline Vector4<T> operator +(const Vector4<T>& left, const Vector4<T>& right) -{ -	return Vector4<T>(left.x + right.x, left.y + right.y, left.z + right.z, left.w + right.w); -} - - -//////////////////////////////////////////////////////////// -template <typename T> -inline Vector4<T> operator -(const Vector4<T>& left, const Vector4<T>& right) -{ -	return Vector4<T>(left.x - right.x, left.y - right.y, left.z - right.z, left.w - right.w); -} - - -//////////////////////////////////////////////////////////// -template <typename T> -inline Vector4<T> operator *(const Vector4<T>& left, T right) -{ -	return Vector4<T>(left.x * right, left.y * right, left.z * right, left.w * right); -} - - -//////////////////////////////////////////////////////////// -template <typename T> -inline Vector4<T> operator *(T left, const Vector4<T>& right) -{ -	return Vector4<T>(right.x * left, right.y * left, right.z * left, right.w * left); -} - - -//////////////////////////////////////////////////////////// -template <typename T> -inline Vector4<T>& operator *=(Vector4<T>& left, T right) -{ -	left.x *= right; -	left.y *= right; -	left.z *= right; -	left.w *= right; - -	return left; -} - - -//////////////////////////////////////////////////////////// -template <typename T> -inline Vector4<T> operator /(const Vector4<T>& left, T right) -{ -	return Vector4<T>(left.x / right, left.y / right, left.z / right, left.w / right); -} - - -//////////////////////////////////////////////////////////// -template <typename T> -inline Vector4<T>& operator /=(Vector4<T>& left, T right) -{ -	left.x /= right; -	left.y /= right; -	left.z /= right; -	left.w /= right; - -	return left; -} - - -//////////////////////////////////////////////////////////// -template <typename T> -inline bool operator ==(const Vector4<T>& left, const Vector4<T>& right) -{ -	return (left.x == right.x) && (left.y == right.y) && (left.z == right.z) && (left.w == right.w); -} - - -//////////////////////////////////////////////////////////// -template <typename T> -inline bool operator !=(const Vector4<T>& left, const Vector4<T>& right) -{ -	return (left.x != right.x) || (left.y != right.y) || (left.z != right.z) || (left.w != right.w); -} diff --git a/source/modules/asura-utils/Module.h b/source/modules/asura-utils/Module.h deleted file mode 100644 index 2cc91d6..0000000 --- a/source/modules/asura-utils/Module.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef _ASURA_MODULE_H_ -#define _ASURA_MODULE_H_ - -#include "Type.h" -#include "Scripting/Portable.hpp" - -namespace AsuraEngine -{ - -	/// -	/// Asura libs Ҫ̳д࣬Կעᡣģа˳Щģ飬Ȼ˳InitializeFinalizeʼ -	/// رЩģ顣 -	///  -	ASURA_ABSTRACT class Module -	{ -	public: - -		/// -		/// ʼģ顣 -		/// -		virtual void Initialize(Luax::LuaxState& state) = 0; - -		/// -		/// رģ顣 -		/// -		virtual void Finalize(Luax::LuaxState& state) = 0; - -	}; - -} - -#endif
\ No newline at end of file diff --git a/source/modules/asura-utils/Scripting/Portable.hpp b/source/modules/asura-utils/Scripting/Portable.hpp deleted file mode 100644 index 1eee123..0000000 --- a/source/modules/asura-utils/Scripting/Portable.hpp +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef _ASURA_ENGINE_PORTABLE_H_ -#define _ASURA_ENGINE_PORTABLE_H_ - -extern "C" { -#include <lua51/lua.h> -#include <lua51/lualib.h> -#include <lua51/lauxlib.h> -} - -#include <luax/luax.h> - -#include "../Type.h" -#include "../Classes.h" - -namespace_begin(AsuraEngine) -namespace_begin(Scripting) - - -/// ҪΪ࣬userdatamember ref̳д࣬ע̳С -using Object = Luax::LuaxObject; - -/// ҪעluanativeҪ̳дģ塣BASEָ࣬ĬLuaxObjectָLuaxObjectࡢ -template<typename TYPE, typename BASE = Luax::LuaxObject> -using Portable = Luax::LuaxNativeClass<TYPE, BASE>; - -namespace_end -namespace_end - -namespace AEScripting = AsuraEngine::Scripting; - -#endif
\ No newline at end of file diff --git a/source/modules/asura-utils/Singleton.hpp b/source/modules/asura-utils/Singleton.hpp deleted file mode 100644 index 9bb7336..0000000 --- a/source/modules/asura-utils/Singleton.hpp +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef _ASURA_SINGLETON_H_ -#define _ASURA_SINGLETON_H_ - -#include "UtilsConfig.h" - -namespace AsuraEngine -{ - -	/// -	/// ̳Singletonڵһʵʱʵ֮ٴʵᱨ -	///  -	template<class T> -	class Singleton -	{ -	public: - -		static T* Get() -		{ -			// ֮ǰûдһ -			if (!instance) instance = new T; -			// ʵ -			return instance; -		} - -		static void Destroy() -		{ -			delete instance; -			instance = nullptr; -		} - -	protected: - -		Singleton() -		{ -			// instanceζִһʵǴġ -			ASSERT(!instance); -			// ʵΪʵ -			instance = static_cast<T*>(this); -		}; - -		virtual ~Singleton() {}; - -		static T* instance; - -	private: - -		Singleton(const Singleton& singleton); - -		Singleton& operator = (const Singleton& singleton); - -	}; - -	// ʵʼΪ -	template<class T> -	T* Singleton<T>::instance = nullptr; - -} - -#endif // _ASURA_SINGLETON_H_
\ No newline at end of file diff --git a/source/modules/asura-utils/StringMap.cpp b/source/modules/asura-utils/StringMap.cpp deleted file mode 100644 index e69de29..0000000 --- a/source/modules/asura-utils/StringMap.cpp +++ /dev/null diff --git a/source/modules/asura-utils/StringMap.hpp b/source/modules/asura-utils/StringMap.hpp deleted file mode 100644 index 15d28ee..0000000 --- a/source/modules/asura-utils/StringMap.hpp +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef _ASURA_ENGINE_STRINGMAP_H_ -#define _ASURA_ENGINE_STRINGMAP_H_ - -#include <string> - -namespace AsuraEngine -{ - -	/// -	/// һ˫һһӦӳ䣬shader uniformsstatemathine state parameterID -	/// -	template<typename key_type>  -	class StringMap -	{ -	public: - -		bool ContainsKey(const key_type& key); - -		bool ContainsString(const std::string& str); - -		std::string GetStringByKey(const key_type& key); - -		key_type GetKeyByString(const std::string& str); - -	}; - -} - -#endif
\ No newline at end of file diff --git a/source/modules/asura-utils/Threads/Conditional.cpp b/source/modules/asura-utils/Threads/Conditional.cpp deleted file mode 100644 index f86a81e..0000000 --- a/source/modules/asura-utils/Threads/Conditional.cpp +++ /dev/null @@ -1,84 +0,0 @@ -#include "Conditional.h" - -namespace_begin(AsuraEngine) -namespace_begin(Threads) - -Conditional::Conditional() -	: m_Waiting(0) -	, m_Signals(0) -{ -} - -Conditional::~Conditional() -{ -} - -void Conditional::Signal() -{ -	m_Mutex.Lock();  -	if (m_Waiting > m_Signals) -	{ -		++m_Signals; -		signal(m_WaitSem); -		m_Mutex.Unlock();  -		wait(m_DoneSem); -	} -	else -	{ -		m_Mutex.Unlock(); -	} -} - -void Conditional::Broadcast() -{ -	m_Mutex.Lock(); -	if (m_Waiting> m_Signals) { -		int i, num_waiting; - -		num_waiting = (m_Waiting - m_Signals); -		m_Signals = m_Waiting; -		for (i = 0; i < num_waiting; ++i) { -			signal(m_WaitSem); -		} -		m_Mutex.Unlock(); -		for (i = 0; i < num_waiting; ++i) { -			wait(m_DoneSem); -		} -	} -	else { -		m_Mutex.Unlock(); -	} - -} - -bool Conditional::Wait(Mutex* mutex, int timeout /*= ASURA_MUTEX_MAXWAIT*/) -{ -	bool retval; - -	m_Mutex.Lock(); -	++m_Waiting; -	m_Mutex.Unlock(); - -	mutex->Unlock(); - -	retval = wait(m_WaitSem, timeout); - -	m_Mutex.Lock(); -	if (m_Signals > 0) { -		if (!retval) { -			wait(m_WaitSem); -		} -		signal(m_DoneSem); - -		--m_Signals; -	} -	--m_Waiting; -	m_Mutex.Unlock(); - -	m_Mutex.Lock(); - -	return retval; -} - -namespace_end -namespace_end
\ No newline at end of file diff --git a/source/modules/asura-utils/Threads/Conditional.h b/source/modules/asura-utils/Threads/Conditional.h deleted file mode 100644 index 7a99ea1..0000000 --- a/source/modules/asura-utils/Threads/Conditional.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef _ASURA_CONDITIONAL_H_ -#define _ASURA_CONDITIONAL_H_ - -#include <asura-utils/Classes.h> - -#include "Mutex.h" -#include "Semaphore.h" - -namespace_begin(AsuraEngine) -namespace_begin(Threads) - -/// -///  -/// -class Conditional -{ -public: - -	Conditional(); -	~Conditional(); - -	void Signal(); -	void Broadcast(); -	bool Wait(Mutex* mutex, int timeout = ASURA_MUTEX_MAXWAIT); - -private: - -	Mutex m_Mutex;  - -	Semaphore m_WaitSem; -	Semaphore m_DoneSem;  - -	int m_Waiting;  -	int m_Signals; - -}; - -namespace_end -namespace_end - -#endif
\ No newline at end of file diff --git a/source/modules/asura-utils/Threads/Coroutine.cpp b/source/modules/asura-utils/Threads/Coroutine.cpp deleted file mode 100644 index 5c4ab68..0000000 --- a/source/modules/asura-utils/Threads/Coroutine.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include "coroutine.h" - -namespace_begin(AsuraEngine) -namespace_begin(Threads) - -/* -Coroutine::Coroutine() -{ - -} -*/ - - -namespace_end -namespace_end diff --git a/source/modules/asura-utils/Threads/Coroutine.h b/source/modules/asura-utils/Threads/Coroutine.h deleted file mode 100644 index cdb21f8..0000000 --- a/source/modules/asura-utils/Threads/Coroutine.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef _ASURA_COROUTINE_H_ -#define _ASURA_COROUTINE_H_ - -#include <asura-utils/Classes.h> - -#include "../Scripting/Portable.hpp" - -namespace_begin(AsuraEngine) -namespace_begin(Threads) - -/// -/// luaЭ̣һЩ -/// -class Coroutine ASURA_FINAL -	: public AEScripting::Portable<Coroutine> -{ -public: - -	LUAX_DECL_FACTORY(Coroutine); - - - -private: - -	/// -	/// ǰЭ̵state -	/// -	lua_State* m_ThreadState; - -	LUAX_DECL_METHOD(_New); -	LUAX_DECL_METHOD(_Run); - -}; - -namespace_end -namespace_end - -namespace AEThreading = AsuraEngine::Threads; - -#endif
\ No newline at end of file diff --git a/source/modules/asura-utils/Threads/Mutex.cpp b/source/modules/asura-utils/Threads/Mutex.cpp deleted file mode 100644 index 501a0ed..0000000 --- a/source/modules/asura-utils/Threads/Mutex.cpp +++ /dev/null @@ -1,105 +0,0 @@ -#include <asura-utils/Exceptions/Exception.h> - -#include "Mutex.h" - -namespace_begin(AsuraEngine) -namespace_begin(Threads) - -#define try_create_mutex(impl)\ -if (!m_Impl)						  \ -{											  \ -try									  \ -{										  \ -	m_Impl = new impl(); \ -}										  \ -catch (Exception& e)  \ -{										  \ -	m_Impl = nullptr;	  \ -}										  \ -}											  - -Mutex::Mutex() -	: m_Impl(nullptr) -{ -#if ASURA_MUTEX_WIN32_CRITICLE_SECTION -	try_create_mutex(MutexImplWin32_CS); -#endif -#if ASURA_MUTEX_WIN32_KERNAL_MUTEX -	try_create_mutex(MutexImplWin32_KM); -#endif -	ASSERT(m_Impl); -} - -Mutex::~Mutex() -{ -	if(m_Impl) -		delete m_Impl; -} - -void Mutex::Lock() -{ -	ASSERT(m_Impl); - -	m_Impl->Lock(); -} - -void Mutex::Unlock() -{ -	ASSERT(m_Impl); - -	m_Impl->Unlock(); -} - -#if ASURA_MUTEX_WIN32_CRITICLE_SECTION  - -MutexImplWin32_CS::MutexImplWin32_CS() -{ -	::InitializeCriticalSection(&m_Mutex); -} - -MutexImplWin32_CS::~MutexImplWin32_CS() -{ -	::DeleteCriticalSection(&m_Mutex); -} - -void MutexImplWin32_CS::Lock() -{ -	::EnterCriticalSection(&m_Mutex); -} - -void MutexImplWin32_CS::Unlock() -{ -	::LeaveCriticalSection(&m_Mutex); -} - -#endif // ASURA_MUTEX_WIN32_CRITICLE_SECTION - -#if ASURA_MUTEX_WIN32_KERNAL_MUTEX - -MutexImplWin32_KM::MutexImplWin32_KM() -{ -	m_Handle = ::CreateMutex(NULL, FALSE, NULL); -	if (!m_Handle) -		throw Exception("Cant use win32 mutex."); -} - -MutexImplWin32_KM::~MutexImplWin32_KM() -{ -	::CloseHandle(m_Handle); -	m_Handle = NULL; -} - -void MutexImplWin32_KM::Lock() -{ -	::WaitForSingleObject(m_Handle, ASURA_MUTEX_MAXWAIT); -} - -void MutexImplWin32_KM::Unlock() -{ -	::ReleaseMutex(m_Handle); -} - -#endif // ASURA_MUTEX_WIN32_KERNAL_MUTEX - -namespace_end -namespace_end
\ No newline at end of file diff --git a/source/modules/asura-utils/Threads/Mutex.h b/source/modules/asura-utils/Threads/Mutex.h deleted file mode 100644 index 4269c05..0000000 --- a/source/modules/asura-utils/Threads/Mutex.h +++ /dev/null @@ -1,128 +0,0 @@ -#ifndef _ASURA_MUTEX_H_ -#define _ASURA_MUTEX_H_ - -#include <asura-utils/Type.h> -#include <asura-utils/Classes.h> - -#include "../UtilsConfig.h" - -#if ASURA_THREAD_WIN32 -#include <windows.h> -#endif - -namespace_begin(AsuraEngine) -namespace_begin(Threads) - -#define ASURA_MUTEX_MAXWAIT (~(uint32)0) - -class MutexImpl; - -class Mutex -{ -public: - -	Mutex(); -	~Mutex(); - -	void Lock(); -	void Unlock(); - -private: - -	// ֹ -	Mutex(const Mutex&); -	Mutex& operator=(const Mutex&); - -	MutexImpl* m_Impl; - -}; - -class _mutex_locker -{ -public: -	_mutex_locker(Mutex& mutex) -		: m(mutex) -	{ -		m.Lock(); -	}; -	~_mutex_locker() -	{ -		m.Unlock(); -	} -	operator bool() { return false; }; -private:  -	void* operator new(size_t); -	Mutex& m; -}; - -#define lock(m) \ -if(_mutex_locker _asura_mutex_locker = m){} else - -ASURA_ABSTRACT class MutexImpl -{ -public: - -	MutexImpl() {}; -	virtual ~MutexImpl() {}; - -	virtual void Lock() = 0;  -	virtual void Unlock() = 0; - -}; - -#if ASURA_MUTEX_WIN32_CRITICLE_SECTION - -//https://blog.csdn.net/l799623787/article/details/18259949 -class MutexImplWin32_CS ASURA_FINAL : public MutexImpl -{ -public: - -	MutexImplWin32_CS(); -	~MutexImplWin32_CS(); - -	void Lock() override; -	void Unlock() override; - -private: - -	//HANDLE m_Handle; -	CRITICAL_SECTION m_Mutex; - -}; - -#endif // ASURA_MUTEX_WIN32_CRITICLE_SECTION - -#if ASURA_MUTEX_WIN32_KERNAL_MUTEX - -class MutexImplWin32_KM ASURA_FINAL : public MutexImpl -{ -public: - -	MutexImplWin32_KM(); -	~MutexImplWin32_KM(); - -	void Lock() override; -	void Unlock() override; - -private: - -	HANDLE m_Handle; - -}; - -#endif // ASURA_MUTEX_WIN32_KERNAL_MUTEX - -#if ASURA_THREAD_STD  - -class MutexImplSTD ASURA_FINAL : public MutexImpl -{ -}; - -#endif // ASURA_THREAD_STD  - -namespace_end -namespace_end - -namespace AEThreading = AsuraEngine::Threads; - -#endif
\ No newline at end of file diff --git a/source/modules/asura-utils/Threads/Semaphore.cpp b/source/modules/asura-utils/Threads/Semaphore.cpp deleted file mode 100644 index a222f3d..0000000 --- a/source/modules/asura-utils/Threads/Semaphore.cpp +++ /dev/null @@ -1,99 +0,0 @@ -#include "../Exceptions/Exception.h" -#include "../Type.h" - -#include "Mutex.h" -#include "Semaphore.h" - -namespace_begin(AsuraEngine) -namespace_begin(Threads) - -#define try_create_semaphore(impl) \ -if (!m_Impl)												\ -{																	\ -	try															\ -	{																\ -		m_Impl = new impl(init_count);	\ -	}																\ -	catch (Exception& e)						\ -	{																\ -		m_Impl = nullptr;							\ -	}																\ -} - -Semaphore::Semaphore(unsigned int init_count) -	: m_Impl(nullptr) -{ -#ifdef ASURA_THREAD_WIN32  -	try_create_semaphore(SemaphoreWin32); -#endif -	//ASSERT(m_Impl); -} - -Semaphore::~Semaphore() -{ -	if (m_Impl) delete m_Impl; -} - -void Semaphore::Signal() -{ -	ASSERT(m_Impl); -	m_Impl->Signal(); -} - -bool Semaphore::Wait(int timeout /*= ASURA_MUTEX_MAXWAIT*/) -{ -	ASSERT(m_Impl); -	return m_Impl->Wait(timeout); -} - -#if ASURA_THREAD_WIN32  - -SemaphoreWin32::SemaphoreWin32(unsigned int init_value) -	: SemaphoreImpl(init_value) -{ -	// UINT_MAX get error. -	m_Sem = CreateSemaphore(NULL, init_value, INT_MAX, NULL); -	if (!m_Sem) -	{ -		int errorCode = GetLastError(); -		throw Exception("Cant use win32 semaphore. Error code: %d.", errorCode); -	} -} - -SemaphoreWin32::~SemaphoreWin32() -{ -	CloseHandle(m_Sem); -} - -void SemaphoreWin32::Signal() -{ -	InterlockedIncrement(&m_Count); -	if (ReleaseSemaphore(m_Sem, 1, NULL) == FALSE) -		InterlockedDecrement(&m_Count); -} - -bool SemaphoreWin32::Wait(int timeout) -{ -	int result; -	result = WaitForSingleObject(m_Sem, timeout); -	if (result == WAIT_OBJECT_0) -	{ -		InterlockedDecrement(&m_Count); -		return true; -	} -	else if(result == WAIT_TIMEOUT) -	{ -		// ʱ -		return false; -	} -	else -	{ -		// δ֪ -		throw Exception("WaitForSingleObject() failed"); -	} -} - -#endif // ASURA_THREAD_WIN32  - -namespace_end -namespace_end
\ No newline at end of file diff --git a/source/modules/asura-utils/Threads/Semaphore.h b/source/modules/asura-utils/Threads/Semaphore.h deleted file mode 100644 index 41b1fd2..0000000 --- a/source/modules/asura-utils/Threads/Semaphore.h +++ /dev/null @@ -1,68 +0,0 @@ -#ifndef _ASURA_SEMAPHORE_H_ -#define _ASURA_SEMAPHORE_H_ - -#include "../UtilsConfig.h" - -#if ASURA_THREAD_WIN32  -#include <windows.h> -#endif - -namespace_begin(AsuraEngine) -namespace_begin(Threads) - -class SemaphoreImpl; - -/// -/// ź -/// -class Semaphore -{ -public: - -	Semaphore(unsigned int init_count = 1); -	~Semaphore(); - -	void Signal(); -	bool Wait(int timeout = ASURA_MUTEX_MAXWAIT); - -private:  -	SemaphoreImpl* m_Impl; -}; - -class SemaphoreImpl -{ -public: -	SemaphoreImpl(unsigned int init_value)  -		: m_Count(init_value) -	{ -	}; -	virtual ~SemaphoreImpl() {}; -	virtual void Signal() = 0; -	virtual bool Wait(int timeout) = 0; -	inline int Current() { return m_Count; } -protected:  -	unsigned int m_Count; -}; - -#define wait(sem, ...) sem.Wait(__VA_ARGS__) -#define signal(sem) sem.Signal() -		 -#if ASURA_THREAD_WIN32 - -class SemaphoreWin32 : public SemaphoreImpl -{ -public: -	SemaphoreWin32(unsigned int init_value); -	~SemaphoreWin32(); -	void Signal() override;  -	bool Wait(int timeout) override; -private: -	HANDLE m_Sem; -}; - -#endif // ASURA_THREAD_WIN32 - -namespace_end -namespace_end - -#endif
\ No newline at end of file diff --git a/source/modules/asura-utils/Threads/Task.cpp b/source/modules/asura-utils/Threads/Task.cpp deleted file mode 100644 index 9666cc6..0000000 --- a/source/modules/asura-utils/Threads/Task.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "task.h" -#include "../scripting/Portable.hpp" - -using namespace AEScripting; - -namespace_begin(AsuraEngine) -namespace_begin(Threads) - -namespace_end -namespace_end diff --git a/source/modules/asura-utils/Threads/Task.h b/source/modules/asura-utils/Threads/Task.h deleted file mode 100644 index b871303..0000000 --- a/source/modules/asura-utils/Threads/Task.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef _ASURA_THRAD_TASK_H_ -#define _ASURA_THRAD_TASK_H_ - -#include <asura-utils/Type.h> -#include <asura-utils/Scripting/Portable.hpp> -#include <asura-utils/Classes.h> - -namespace_begin(AsuraEngine) -namespace_begin(Threads) - -/// -/// ϣһ̴̳߳TaskдExecute -/// -ASURA_ABSTRACT class Task : public AEScripting::Object -{ -public: - -	Task() {}; -	virtual ~Task() {}; - -	/// -	/// ִɺtrueûص -	/// -	virtual bool Execute() = 0; - -	/// -	/// ûصinvoke threadص -	/// -	virtual void Invoke(lua_State* invokeThreaad) = 0; - -protected: - -	// ȡص -	Luax::LuaxMemberRef m_Callback; - -}; - -namespace_end -namespace_end - -namespace AEThreading = AsuraEngine::Threads; - -#endif
\ No newline at end of file diff --git a/source/modules/asura-utils/Threads/Thread.cpp b/source/modules/asura-utils/Threads/Thread.cpp deleted file mode 100644 index 1153912..0000000 --- a/source/modules/asura-utils/Threads/Thread.cpp +++ /dev/null @@ -1,287 +0,0 @@ -#include "Thread.h" - -#include "ThreadImplWin32.h" -#include "ThreadImplPosix.h" -#include "ThreadImplSdl.h" -#include "ThreadImplStd.h" - -namespace_begin(AsuraEngine) -namespace_begin(Threads) - -Thread::Thread(lua_State* luaThread, ThreadType type /*= THREAD_TYPE_DEFERRED*/, uint sleepTime /*= 0*/, const std::string& name /*= ""*/) -	: m_Name(name) -	, m_State(THREAD_STATE_IDLE) -	, m_Type(type) -	, m_LuaThread(luaThread) -	, m_CallbackThread(nullptr) -	, m_SleepTime(sleepTime) -{ -	LUAX_STATE(luaThread); -	if (type == THREAD_TYPE_IMMEDIATE) -	{ -		Luax::LuaxVM* vm = state.GetVM(); -		ASSERT(vm); -		m_CallbackThread = vm->CreateThread(); -		ASSERT(m_CallbackThread); -		SetLuaxMemberRef(state, m_CallbackThreadRef, -1); -		state.Pop(); // callback thread -	} -} - -Thread::~Thread() -{ -	if (m_Impl) -	{ -		delete m_Impl; -		m_Impl = nullptr; -	} -} - -bool Thread::AddTask(Task* task) -{ -	lock(m_TaskQueueMutex) -	{ -		task->Retain(); -		m_TaskQueue.push(task); -	} -	return true; -} - -uint Thread::GetTaskCount() -{ -	return m_TaskQueue.size(); -} - -void Thread::Idle() -{ -	m_State = THREAD_STATE_IDLE; -} - -#define try_start_thread(impl)\ -if (!m_Impl) \ -{ \ -m_Impl = new impl(); \ -if (!m_Impl->Start(this, stacksize)) \ -{ \ -	delete m_Impl; \ -	m_Impl = nullptr; \ -} \ -} - -bool Thread::Start(bool isDaemon /*= true*/, uint32 stacksize /*= 0*/) -{ -	if (m_State != THREAD_STATE_IDLE) -		return false; - -	// Ѿһ֮ǰģر -	if (m_Impl) -	{ -			delete m_Impl; -			m_Impl = nullptr; -	} - -#if ASURA_THREAD_WIN32 -	try_start_thread(ThreadImplWin32); -#endif - -	if (!m_Impl) -		return false; - -	m_IsDaemon = isDaemon; -	m_StateMutex.Lock(); -	m_State = THREAD_STATE_RUNNING; -	m_StateMutex.Unlock(); -} - -void Thread::Pause() -{ -	ASSERT(m_Impl); - -	lock(m_StateMutex) -	{ -		m_State = THREAD_STATE_PAUSED; -	} -} - -void Thread::Resume() -{ -	ASSERT(m_Impl); - -	lock(m_StateMutex) -	{ -		if (m_State == THREAD_STATE_PAUSED) -			m_State = THREAD_STATE_RUNNING; -	} -} - -void Thread::Stop() -{ -	ASSERT(m_Impl); - -	lock(m_StateMutex) -	{ -		m_State = THREAD_STATE_STOPPED; -	} -} - -void Thread::PauseSync() -{ -	Pause(); -	wait(m_SemPause); -} - -void Thread::ResumeSync() -{ -	Resume(); -	wait(m_SemResume); -} - -void Thread::StopSync() -{ -	Stop(); -	wait(m_SemStop); -} - -void Thread::Join() -{ -	ASSERT(m_Impl);  -	m_Impl->Join(); -} - -ThreadState Thread::GetState() -{ -	ThreadState state; -	lock(m_StateMutex) -	{ -		state = m_State; -	} -	return state; -} - -bool Thread::IsRunning() -{ -	ASSERT(m_Impl); - -	return GetState() == THREAD_STATE_RUNNING; -} - -bool Thread::IsPaused() -{ -	ASSERT(m_Impl); - -	return GetState() == THREAD_STATE_PAUSED; -} - -bool Thread::IsStopped() -{ -	ASSERT(m_Impl); - -	return GetState() == THREAD_STATE_STOPPED; -} - -bool Thread::IsCurrent() -{ -	ASSERT(m_Impl); - -	return m_Impl->IsCurrent();  -} - -const std::string& Thread::GetName() -{ -	return m_Name; -} - -int Thread::Process() -{ -	LUAX_STATE(m_LuaThread); - -	do{ -		if (IsRunning()) -		{ -			while (!m_TaskQueue.empty()) -			{ -				Task* task = m_TaskQueue.front(); -				if (task && task->Execute()) -				{ -					if (m_Type == THREAD_TYPE_DEFERRED) -					{ -						m_FinishedMutex.Lock(); -						task->Retain(); -						m_FinishedTasks.push(task); -						m_FinishedMutex.Unlock(); -					} -					else if (m_Type == THREAD_TYPE_IMMEDIATE) -					{ -						// unsafe -						task->Invoke(m_CallbackThread); -						this->LuaxRelease<Task>(state, task); -					} -					m_TaskQueueMutex.Lock(); -					m_TaskQueue.pop(); -					task->Release(); -					m_TaskQueueMutex.Unlock(); -				} -			} -		} - -		// ˳ѭ -		if (IsStopped()) -			break; - -		// CPUʹ -		Sleep(m_SleepTime); - -	} while (m_IsDaemon); - -	// ػ̣߳еstop״̬ -	if (!m_IsDaemon) -		Stop(); - -	signal(m_SemStop); - -	// ״̬ΪIdle -	Idle(); - -	return 0; -} - -/// -/// ӳģʽص -///  -void Thread::Dispatch() -{ -	if (m_Type != THREAD_TYPE_DEFERRED) -		return; - -	LUAX_STATE(m_LuaThread); -	while (!m_FinishedTasks.empty()) -	{ -		Task* task = m_FinishedTasks.front();  -		if (task) -		{ -			task->Invoke(m_LuaThread); -			this->LuaxRelease<Task>(state, task); -			m_FinishedMutex.Lock(); -			m_FinishedTasks.pop(); -			task->Release(); -			m_FinishedMutex.Unlock(); -		} -	} -} - -void Thread::Sleep(uint ms) -{ -	ASSERT(m_Impl); -	if (m_Impl) -	{ -		m_Impl->Sleep(ms); -	} -} - -void Thread::SetSleepTime(uint ms) -{ -	m_SleepTime = ms; -} - -namespace_end -namespace_end
\ No newline at end of file diff --git a/source/modules/asura-utils/Threads/Thread.h b/source/modules/asura-utils/Threads/Thread.h deleted file mode 100644 index bc6f14e..0000000 --- a/source/modules/asura-utils/Threads/Thread.h +++ /dev/null @@ -1,222 +0,0 @@ -#ifndef _ASURA_THREAD_H_ -#define _ASURA_THREAD_H_ - -#include <string> -#include <queue> - -#include <asura-utils/Scripting/Portable.hpp> - -#include "Task.h" -#include "Mutex.h" -#include "Semaphore.h" -#include "Threadable.h" - -namespace_begin(AsuraEngine) -namespace_begin(Threads) - -class ThreadImpl; - -/// -/// ̵߳ļֲͬʵ֣ -///     1: Deferredӳģʽ߳ϵɺҪ̵ֶ߳Dispatch -///        ̵߳ص첽Ϊͬlua_Stateͻ⡣ -///     2: Immediateģʽÿһ߳άһlua_newthreadlua_State -///        صڲͬlua_Stateеãⲻ̷ͬ߳ͬһlua_State -/// -enum ThreadType -{ -	THREAD_TYPE_DEFERRED, -	THREAD_TYPE_IMMEDIATE, // unsafe -}; - -enum ThreadState -{ -	THREAD_STATE_IDLE,    ///< ãδں˶ -	THREAD_STATE_RUNNING,	///< ѭ -	THREAD_STATE_PAUSED,	///< ѭͣ -	THREAD_STATE_STOPPED,	///< ˳ѭ -}; - -/// -/// ߳壬ÿ߳άһtask queue -/// -class Thread ASURA_FINAL -	: public AEScripting::Portable<Thread> -	, public Threadable -{ -public: - -	LUAX_DECL_FACTORY(Thread); - -	Thread(lua_State* luaThread, ThreadType type = THREAD_TYPE_DEFERRED, uint sleepTime = 1, const std::string& name = ""); -	~Thread(); - -	bool AddTask(Task* task); -	/// -	/// õȴ -	/// -	uint GetTaskCount(); - -	void Idle(); - -	/// -	/// ں˶Сdaemonȴֶstopijʱ̶ɺԶstop -	/// -	bool Start(bool daemon = true, uint32 stacksize = 0); - -	/// -	/// ͬ߳̿ƣʵʱġҪ߳ʹIsȷϵָ״̬ -	/// -	void Pause(); -	void Resume(); -	void Stop(); - -	/// -	/// ͬ߳̿ƣȷźźִС̵߳ȴ -	/// -	void PauseSync(); -	void ResumeSync(); -	void StopSync(); - -	/// -	/// ̵߳ȴ߳̽żִС -	/// -	void Join(); - -	ThreadState GetState(); - -	/// -	/// ߳״̬ -	///     1: IdleУ̴߳Ĭ״̬ʱStart -	///     2: RunningУں˶´Ѿں˵УTask -	///     3: PausedͣȻںУ˶Ĵͣ -	///     4: StoppedֹͣȻںУѾ -	///  -	bool IsIdle(); -	bool IsRunning(); -	bool IsPaused();  -	bool IsStopped(); - -	bool IsCurrent(); - -	/// -	/// ִС -	/// -	int Process() override; - -	const std::string& GetName(); - -	/// -	/// ص -	/// -	void Dispatch(); - -	/// -	/// ߺ -	/// -	void Sleep(uint ms); - -	/// -	/// ʱ -	/// -	void SetSleepTime(uint ms); - -private: - -	//----------------------------------------------------------------------------// - -	LUAX_DECL_ENUM(ThreadType); -	LUAX_DECL_ENUM(ThreadState); - -	LUAX_DECL_METHOD(_New); -	LUAX_DECL_METHOD(_AddTask); -	LUAX_DECL_METHOD(_Start); -	LUAX_DECL_METHOD(_Idle); -	LUAX_DECL_METHOD(_Pause); -	LUAX_DECL_METHOD(_Resume); -	LUAX_DECL_METHOD(_Stop); -	LUAX_DECL_METHOD(_Join); -	LUAX_DECL_METHOD(_IsRunning); -	LUAX_DECL_METHOD(_IsPaused); -	LUAX_DECL_METHOD(_IsStopped); -	LUAX_DECL_METHOD(_IsCurrent); -	LUAX_DECL_METHOD(_Sleep); -	LUAX_DECL_METHOD(_Dispatch); -	LUAX_DECL_METHOD(_GetName); -	LUAX_DECL_METHOD(_GetType); -	LUAX_DECL_METHOD(_GetState); -	LUAX_DECL_METHOD(_SetSleepTime); - -	//----------------------------------------------------------------------------// - -	ThreadImpl* m_Impl; - -	lua_State*  m_LuaThread; - -	/// -	/// ˴Ƿػģʽ -	/// -	bool m_IsDaemon; - -	std::string m_Name; -	ThreadType  m_Type; -	uint        m_SleepTime; - -	ThreadState m_State; -	Mutex       m_StateMutex; - -	/// -	/// ͬصź -	/// -	Semaphore m_SemPause; -	Semaphore m_SemResume; -	Semaphore m_SemStop; - -	/// -	/// С -	/// -	std::queue<Task*> m_TaskQueue; -	Mutex             m_TaskQueueMutex; - -	///  -	/// ӳģʽʹ -	/// -	std::queue<Task*> m_FinishedTasks; -	Mutex             m_FinishedMutex; - -	/// -	/// ģʽʹãصʹõlua߳ -	/// -	lua_State*          m_CallbackThread; -	Luax::LuaxMemberRef m_CallbackThreadRef; - -}; - -/// -/// ̵߳ľʵ֣ûģһֲԣ -///     1: win32  -///     2: posix -///     3: SDL  -///     4: std::thread -/// -ASURA_ABSTRACT class ThreadImpl -{ -public: -	ThreadImpl() {}; -	virtual ~ThreadImpl() {}; - -	virtual bool Start(Threadable* thread, uint32 stacksize = 0) = 0; -	virtual void Join() = 0; -	virtual void Kill() = 0; - -	virtual void Sleep(uint ms) = 0; - -	virtual bool IsRunning() = 0; -	virtual bool IsCurrent() = 0; - -}; - -namespace_end -namespace_end - -#endif
\ No newline at end of file diff --git a/source/modules/asura-utils/Threads/ThreadImplPosix.cpp b/source/modules/asura-utils/Threads/ThreadImplPosix.cpp deleted file mode 100644 index e69de29..0000000 --- a/source/modules/asura-utils/Threads/ThreadImplPosix.cpp +++ /dev/null diff --git a/source/modules/asura-utils/Threads/ThreadImplPosix.h b/source/modules/asura-utils/Threads/ThreadImplPosix.h deleted file mode 100644 index 3089f0a..0000000 --- a/source/modules/asura-utils/Threads/ThreadImplPosix.h +++ /dev/null @@ -1,2 +0,0 @@ -#include <asura-utils/Classes.h> - diff --git a/source/modules/asura-utils/Threads/ThreadImplSDL.cpp b/source/modules/asura-utils/Threads/ThreadImplSDL.cpp deleted file mode 100644 index e69de29..0000000 --- a/source/modules/asura-utils/Threads/ThreadImplSDL.cpp +++ /dev/null diff --git a/source/modules/asura-utils/Threads/ThreadImplSDL.h b/source/modules/asura-utils/Threads/ThreadImplSDL.h deleted file mode 100644 index e69de29..0000000 --- a/source/modules/asura-utils/Threads/ThreadImplSDL.h +++ /dev/null diff --git a/source/modules/asura-utils/Threads/ThreadImplStd.cpp b/source/modules/asura-utils/Threads/ThreadImplStd.cpp deleted file mode 100644 index e69de29..0000000 --- a/source/modules/asura-utils/Threads/ThreadImplStd.cpp +++ /dev/null diff --git a/source/modules/asura-utils/Threads/ThreadImplStd.h b/source/modules/asura-utils/Threads/ThreadImplStd.h deleted file mode 100644 index 452f569..0000000 --- a/source/modules/asura-utils/Threads/ThreadImplStd.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef _ASURA_THREAD_STD_H_ -#define _ASURA_THREAD_STD_H_ - -#include "../UtilsConfig.h" - -#if ASURA_THREAD_STD - -#include <windows.h> - -#include "Thread.h" - -namespace_begin(AsuraEngine) -namespace_begin(Threads) - -/// -/// Threadstd::threadʵ֡ -/// -class ThreadImplSTD : public ThreadImpl -{ -public: - -	ThreadImplSTD(); -	~ThreadImplSTD(); - -	bool Start(Threadable* thread, uint32 stacksize) override; -	void Join() override; -	void Kill() override; - -	bool IsRunning() override; -	bool IsCurrent() override; - -private: - -}; - -namespace_end -namespace_end - -#endif // #if ASURA_THREAD_STD - -#endif // _ASURA_THREAD_STD_H_
\ No newline at end of file diff --git a/source/modules/asura-utils/Threads/ThreadImplWin32.cpp b/source/modules/asura-utils/Threads/ThreadImplWin32.cpp deleted file mode 100644 index 2467f87..0000000 --- a/source/modules/asura-utils/Threads/ThreadImplWin32.cpp +++ /dev/null @@ -1,77 +0,0 @@ -#include "ThreadImplWin32.h" -#include "Thread.h" - -#include <iostream> - -#if ASURA_THREAD_WIN32 - -namespace_begin(AsuraEngine) -namespace_begin(Threads) - -static DWORD WINAPI _thread_win32_runner(LPVOID param) -{ -	Threadable* thread = (Threadable*)param; -	return thread->Process(); // β -} - -ThreadImplWin32::ThreadImplWin32() -{ -} - -ThreadImplWin32::~ThreadImplWin32() -{ -	if (!m_Handle) return; -	::CloseHandle(m_Handle); -	m_Handle = 0; -} - -bool ThreadImplWin32::Start(Threadable* thread, uint32 stacksize/*=0*/) -{ -	assert(!IsRunning()); -	m_Handle = ::CreateThread( -		NULL -		, stacksize -		, _thread_win32_runner -		, thread -		, 0 /*е*/ -		, NULL); - -	return m_Handle; -} - -void ThreadImplWin32::Join() -{ -	// ̵߳ȴ̷߳ -	::WaitForSingleObject(m_Handle, INFINITE); -} - -void ThreadImplWin32::Kill() -{ -	::TerminateThread(m_Handle, FALSE); -} - -void ThreadImplWin32::Sleep(uint ms) -{ -	::Sleep(ms); -} - -bool ThreadImplWin32::IsRunning() -{ -	if (m_Handle) { -		DWORD exitCode = 0; -		// https://blog.csdn.net/yuanmeng567/article/details/19485719 -		::GetExitCodeThread(m_Handle, &exitCode); -		return exitCode == STILL_ACTIVE; -	} -	return false; -} - -bool ThreadImplWin32::IsCurrent() -{ -	return m_Handle == ::GetCurrentThread(); -} - -namespace_end -namespace_end - -#endif // ASURA_THREAD_WIN32
\ No newline at end of file diff --git a/source/modules/asura-utils/Threads/ThreadImplWin32.h b/source/modules/asura-utils/Threads/ThreadImplWin32.h deleted file mode 100644 index 93ca477..0000000 --- a/source/modules/asura-utils/Threads/ThreadImplWin32.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef _ASURA_THREAD_WIN32_H__ -#define _ASURA_THREAD_WIN32_H__ - -#include "../UtilsConfig.h" - -#if ASURA_THREAD_WIN32 - -#include <windows.h> - -#include "thread.h" - -namespace_begin(AsuraEngine) -namespace_begin(Threads) - -/// -/// Threadwin32ʵ֡ -/// -class ThreadImplWin32 : public ThreadImpl -{ -public: - -	ThreadImplWin32(); -	~ThreadImplWin32(); - -	bool Start(Threadable* thread, uint32 stacksize) override; -	void Join() override; -	void Kill() override; - -	void Sleep(uint ms) override; - -	bool IsRunning() override; -	bool IsCurrent() override; - -private: - -	HANDLE m_Handle; - -}; - -namespace_end -namespace_end - -#endif // #if ASURA_THREAD_WIN32 -#endif // _ASURA_THREAD_WIN32_H__
\ No newline at end of file diff --git a/source/modules/asura-utils/Threads/Threadable.h b/source/modules/asura-utils/Threads/Threadable.h deleted file mode 100644 index fce7350..0000000 --- a/source/modules/asura-utils/Threads/Threadable.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef _ASURA_THREADABLE_H_ -#define _ASURA_THREADABLE_H_ - -#include "../Type.h" - -namespace_begin(AsuraEngine) -namespace_begin(Threads) - -ASURA_ABSTRACT class Threadable -{ -public:  - -	Threadable() {}; -	virtual ~Threadable() {}; - -	virtual int Process() = 0; - -}; - -namespace_end -namespace_end - -#endif
\ No newline at end of file diff --git a/source/modules/asura-utils/Threads/binding/_coroutine.cpp b/source/modules/asura-utils/Threads/binding/_coroutine.cpp deleted file mode 100644 index 0656079..0000000 --- a/source/modules/asura-utils/Threads/binding/_coroutine.cpp +++ /dev/null @@ -1,38 +0,0 @@ -#include "../Coroutine.h" - -using namespace std; - -namespace_begin(AsuraEngine) -namespace_begin(Threads) -		 -		LUAX_REGISTRY(Coroutine) -		{ -			LUAX_REGISTER_METHODS(state, -				{ "New", _New }, -				{ "Run", _Run } -			); -		} - -		LUAX_POSTPROCESS(Coroutine) -		{ - -		} - -		// Coroutine.New() -		LUAX_IMPL_METHOD(Coroutine, _New) -		{ -			LUAX_STATE(L); - -			return 0; -		} - -		// coroutine:Run() -		LUAX_IMPL_METHOD(Coroutine, _Run) -		{ -			LUAX_PREPARE(L, Coroutine); - -			return 0; -		} - -	} -} diff --git a/source/modules/asura-utils/Threads/binding/_thread.cpp b/source/modules/asura-utils/Threads/binding/_thread.cpp deleted file mode 100644 index aaa9e8d..0000000 --- a/source/modules/asura-utils/Threads/binding/_thread.cpp +++ /dev/null @@ -1,208 +0,0 @@ -#include "../Thread.h" - -using namespace std; - -namespace_begin(AsuraEngine) -namespace_begin(Threads) -		 -		LUAX_REGISTRY(Thread) -		{ -			LUAX_REGISTER_METHODS(state, -				{ "New",       _New       }, -				{ "AddTask",   _AddTask   }, -				{ "Start",     _Start     }, -				{ "Idle",      _Idle      }, -				{ "Pause",     _Pause     }, -				{ "Resume",    _Resume    }, -				{ "Stop",      _Stop      }, -				{ "Join",      _Join      }, -				{ "IsRunning", _IsRunning }, -				{ "IsPaused",  _IsPaused  }, -				{ "IsStopped", _IsStopped }, -				{ "IsCurrent", _IsCurrent }, -				{ "Sleep",     _Sleep     }, -				{ "Dispatch",  _Dispatch  }, -				{ "GetName",   _GetName   }, -				{ "GetType",   _GetType   }, -				{ "GetState",  _GetState  } -			); -		} - -		LUAX_POSTPROCESS(Thread) -		{ -			LUAX_REGISTER_ENUM(state, "EThreadType", -				{ "DEFERRED",  THREAD_TYPE_DEFERRED  }, -				{ "IMMEDIATE", THREAD_TYPE_IMMEDIATE } -			); -			LUAX_REGISTER_ENUM(state, "EThreadState", -				{ "IDLE",    THREAD_STATE_IDLE    }, -				{ "RUNNING", THREAD_STATE_RUNNING }, -				{ "PAUSED",  THREAD_STATE_PAUSED  }, -				{ "STOPPED", THREAD_STATE_STOPPED } -			); -		} - -		// thread = Thread.New(thread_type, sleepTime, name) -		LUAX_IMPL_METHOD(Thread, _New) -		{ -			LUAX_STATE(L); - -			ThreadType type = (ThreadType)state.GetValue<int>(1, THREAD_TYPE_DEFERRED); -			uint sleepTime = state.GetValue<uint>(2,1); -			cc8* name = state.GetValue<cc8*>(3, ""); - -			Thread* thread = new Thread(state, type, sleepTime, name); -			thread->PushLuaxUserdata(state); - -			return 1; -		} - -		// thread:AddTask(task) -		LUAX_IMPL_METHOD(Thread, _AddTask) -		{ -			LUAX_PREPARE(L, Thread); - -			Task* task = state.GetUserdata<Task>(2); -			self->AddTask(task); -			self->LuaxRetain<Task>(state, task); -			return 0; -		} - -		// successed = thread:Start(isDeamon, stackSize) -		LUAX_IMPL_METHOD(Thread, _Start) -		{ -			LUAX_PREPARE(L, Thread); - -			bool isDaemon = state.GetValue(2, true); -			uint stackSize = state.GetValue(3, 0); - -			state.Push(self->Start(isDaemon, stackSize)); -			return 1; -		} - -		// thread:Idle() -		LUAX_IMPL_METHOD(Thread, _Idle) -		{ -			LUAX_PREPARE(L, Thread); -			self->Idle(); -			return 0; -		} - -		// thread:Pause() -		LUAX_IMPL_METHOD(Thread, _Pause) -		{ -			LUAX_PREPARE(L, Thread); -			self->Pause(); -			return 0; -		} - -		// thread:Resume() -		LUAX_IMPL_METHOD(Thread, _Resume) -		{ -			LUAX_PREPARE(L, Thread); -			self->Resume(); -			return 0; -		} - -		// thread:Stop() -		LUAX_IMPL_METHOD(Thread, _Stop) -		{ -			LUAX_PREPARE(L, Thread); -			self->Stop(); -			return 0; -		} - -		// thread:Join() -		LUAX_IMPL_METHOD(Thread, _Join) -		{ -			LUAX_PREPARE(L, Thread); -			self->Join(); -			return 0; -		} - -		// thread:IsRunning() -		LUAX_IMPL_METHOD(Thread, _IsRunning) -		{ -			LUAX_PREPARE(L, Thread); -			state.Push(self->IsRunning()); -			return 1; -		} - -		// thread:IsPaused() -		LUAX_IMPL_METHOD(Thread, _IsPaused) -		{ -			LUAX_PREPARE(L, Thread); -			state.Push(self->IsPaused()); -			return 1; -		} - -		// thread:IsStopped() -		LUAX_IMPL_METHOD(Thread, _IsStopped) -		{ -			LUAX_PREPARE(L, Thread); -			state.Push(self->IsStopped()); -			return 1; -		} - -		// thread:IsCurrent() -		LUAX_IMPL_METHOD(Thread, _IsCurrent) -		{ -			LUAX_PREPARE(L, Thread); -			state.Push(self->IsCurrent()); -			return 1; -		} - -		// Thread.Sleep(ms) -		LUAX_IMPL_METHOD(Thread, _Sleep) -		{ -			LUAX_STATE(L); -			uint ms = state.GetValue(1, 0); -#ifdef _WIN32 -			::Sleep(ms); -#endif -			return 0; -		} - -		// thread:Dispatch() -		LUAX_IMPL_METHOD(Thread, _Dispatch) -		{ -			LUAX_PREPARE(L, Thread); -			self->Dispatch(); -			return 0; -		} - -		// thread:GetName() -		LUAX_IMPL_METHOD(Thread, _GetName) -		{ -			LUAX_PREPARE(L, Thread); -			state.Push(self->GetName()); -			return 1; -		} - -		// thread:GetType() -		LUAX_IMPL_METHOD(Thread, _GetType) -		{ -			LUAX_PREPARE(L, Thread); -			state.Push(self->m_Type); -			return 1; -		} - -		// thread:GetState() -		LUAX_IMPL_METHOD(Thread, _GetState) -		{ -			LUAX_PREPARE(L, Thread); -			state.Push(self->m_State); -			return 1; -		} - -		// thread:SetSleepTime(sleepTime) -		LUAX_IMPL_METHOD(Thread, _SetSleepTime) -		{ -			LUAX_PREPARE(L, Thread); -			uint time = state.CheckValue<uint>(2); -			self->SetSleepTime(time); -			return 0; -		} - -	} -} diff --git a/source/modules/asura-utils/Type.h b/source/modules/asura-utils/Type.h deleted file mode 100644 index 5100fa3..0000000 --- a/source/modules/asura-utils/Type.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef _ASURA_UTILS_TYPE_H_ -#define _ASURA_UTILS_TYPE_H_ - -#include <assert.h> -#include <cstdlib> -#include <stdint.h> - -#include "asura-base/Configure.h" - -namespace AsuraEngine -{ - -	//--------------------------------------------------------------------------------// - -	typedef int8_t   int8; -	typedef uint8_t  uint8; -	//typedef uint8	   byte; -	typedef char	   byte; -	typedef int16_t  int16; -	typedef uint16_t uint16; -	typedef int32_t  int32; -	typedef uint32_t uint32; -	typedef int64_t  int64; -	typedef uint64_t uint64; - -	typedef uint32_t uint; -	typedef int32_t  sint; - -	typedef std::size_t size_t; - -	typedef const char cc8; - -#define Assert assert - -} // namespace AsuraEngine - -#endif // _ASURA_CONFIG_H_
\ No newline at end of file diff --git a/source/modules/asura-utils/Utils.h b/source/modules/asura-utils/Utils.h deleted file mode 100644 index dfcd2a6..0000000 --- a/source/modules/asura-utils/Utils.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef _ASURA_UTILS_H_ -#define _ASURA_UTILS_H_ - -#include "UtilsModule.h" - -#endif
\ No newline at end of file diff --git a/source/modules/asura-utils/UtilsConfig.h b/source/modules/asura-utils/UtilsConfig.h deleted file mode 100644 index df52b13..0000000 --- a/source/modules/asura-utils/UtilsConfig.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef _ASURA_UTILS_CONFIG_H_ -#define _ASURA_UTILS_CONFIG_H_ - -// ı -#include "asura-base/Configure.h"  - -#define ASURA_THREAD_WIN32 1 -#define ASURA_THREAD_STD 1 - -#define ASURA_MUTEX_WIN32_CRITICLE_SECTION 1 -#define ASURA_MUTEX_WIN32_KERNAL_MUTEX     1 - -#endif
\ No newline at end of file diff --git a/source/modules/asura-utils/UtilsModule.cpp b/source/modules/asura-utils/UtilsModule.cpp deleted file mode 100644 index 5735270..0000000 --- a/source/modules/asura-utils/UtilsModule.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "UtilsModule.h" - -using namespace AsuraEngine::IO; -using namespace AsuraEngine::Threads; - -namespace AsuraEngine -{ - -	void UtilsModule::Initialize(Luax::LuaxState& state) -	{ -		// IO  -		LUAX_REGISTER_SINGLETON(state, Filesystem); -		LUAX_REGISTER_FACTORY(state, IOTask); -		LUAX_REGISTER_FACTORY(state, DataBuffer); -		LUAX_REGISTER_FACTORY(state, FileData); -		LUAX_REGISTER_FACTORY(state, File); -		// Threads -		LUAX_REGISTER_FACTORY(state, Thread); -	} - -	void UtilsModule::Finalize(Luax::LuaxState& state) -	{ -	} - -}
\ No newline at end of file diff --git a/source/modules/asura-utils/UtilsModule.h b/source/modules/asura-utils/UtilsModule.h deleted file mode 100644 index b61dca9..0000000 --- a/source/modules/asura-utils/UtilsModule.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef _ASURA_LIBS_UTIL_MODULE_H_ -#define _ASURA_LIBS_UTIL_MODULE_H_ - -#include "IO/FileSystem.h" -#include "IO/DataBuffer.h" -#include "IO/FileData.h" -#include "IO/file.h" -#include "IO/IOTask.h" - -#include "Threads/Thread.h" - -#include "Module.h" - -#include "Classes.h" - -namespace AsuraEngine -{ - -	/// -	/// Asuraģ -	/// -	class UtilsModule ASURA_FINAL : public Module -	{ -	public: - -		void Initialize(Luax::LuaxState& state) override;  - -		void Finalize(Luax::LuaxState& state) override; -		 -	}; - -} - -#endif
\ No newline at end of file diff --git a/source/modules/asura-utils/classes.h b/source/modules/asura-utils/classes.h deleted file mode 100644 index b2700f0..0000000 --- a/source/modules/asura-utils/classes.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef _ASURAENGINE_CLASSES_H_ -#define _ASURAENGINE_CLASSES_H_ - -#define GET_SET(TYPE,PROP_NAME,VAR_NAME)	void Set##PROP_NAME (TYPE val) { VAR_NAME = val; }	TYPE Get##PROP_NAME () {return VAR_NAME; } - -#define namespace_begin(NAMESPACE) namespace NAMESPACE {  -#define namespace_end } - -#endif diff --git a/source/modules/asura-utils/dynamic_bitset.h b/source/modules/asura-utils/dynamic_bitset.h deleted file mode 100644 index 2b04d07..0000000 --- a/source/modules/asura-utils/dynamic_bitset.h +++ /dev/null @@ -1,1150 +0,0 @@ -#ifndef DYNAMIC_BITSET_H -#define DYNAMIC_BITSET_H -// (C) Copyright Chuck Allison and Jeremy Siek 2001, 2002. -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all -// copies. This software is provided "as is" without express or -// implied warranty, and with no claim as to its suitability for any -// purpose. - -// With optimizations, bug fixes, and improvements by Gennaro Prota. - -// See http://www.boost.org/libs/dynamic_bitset for documentation. - -// ------------------------------------- -// CHANGE LOG: -// -// - corrected workaround for Dinkum lib's allocate() [GP] -// - changed macro test for old iostreams [GP] -// - removed #include <vector> for now. [JGS] -// - Added __GNUC__ to compilers that cannot handle the constructor from basic_string. [JGS] -// - corrected to_block_range [GP] -// - corrected from_block_range [GP] -// - Removed __GNUC__ from compilers that cannot handle the constructor -//     from basic_string and added the workaround suggested by GP. [JGS] -// - Removed __BORLANDC__ from the #if around the basic_string -//     constructor. Luckily the fix by GP for g++ also fixes Borland. [JGS] - -#include <cassert> -#include <string> -#include <cstring>             // for memset, memcpy, memcmp, etc. -#include <algorithm>           // for std::swap, std::min, std::copy, std::fill -#include <memory>           // for std::swap, std::min, std::copy, std::fill -#include <stdlib.h> - -#include "Type.h" - -namespace std -{ -	typedef ::size_t size_t; -} -// (C) Copyright Chuck Allison and Jeremy Siek 2001, 2002. -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all -// copies. This software is provided "as is" without express or -// implied warranty, and with no claim as to its suitability for any -// purpose. - -// With optimizations by Gennaro Prota. - -class dynamic_bitset_base -{ -	typedef std::size_t size_type; -public: -#if defined(LINUX) && (defined (__LP64__) || defined(_AMD64_)) -	typedef unsigned int Block; -#else -	typedef unsigned long Block; -#endif -	enum { bits_per_block = 8 * sizeof(Block) }; - -	dynamic_bitset_base() -		: m_bits(0), m_num_bits(0), m_num_blocks(0) { } - -	dynamic_bitset_base(size_type num_bits) : -		m_num_bits(num_bits), -		m_num_blocks(calc_num_blocks(num_bits)) -	{ -		if (m_num_blocks != 0) -		{ -			m_bits = new Block[m_num_blocks]; -			memset(m_bits, 0, m_num_blocks * sizeof(Block)); // G.P.S. ask to Jeremy -		} -		else -			m_bits = 0; -	} -	~dynamic_bitset_base() { -		delete[]m_bits;; -	} - -	Block* m_bits; -	size_type m_num_bits; -	size_type m_num_blocks; - -	static size_type word(size_type bit) { return bit / bits_per_block; } // [gps] -	static size_type offset(size_type bit) { return bit % bits_per_block; } // [gps] -	static Block mask1(size_type bit) { return Block(1) << offset(bit); } -	static Block mask0(size_type bit) { return ~(Block(1) << offset(bit)); } -	static size_type calc_num_blocks(size_type num_bits) -	{ -		return (num_bits + bits_per_block - 1) / bits_per_block; -	} -}; - - -// ------- count table implementation -------------- - -typedef unsigned char byte_t; - -template <bool bogus = true> -struct bitcount { -	typedef byte_t element_type; -	static const byte_t table[]; - -}; -//typedef count<true> table_t; - - -// the table: wrapped in a class template, so -// that it is only instantiated if/when needed -// -template <bool bogus> -const byte_t bitcount<bogus>::table[] = -{ -	// Automatically generated by GPTableGen.exe v.1.0 -	// -0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, -1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, -1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, -2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, -1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, -2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, -2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, -3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8 -}; - - -// ------------------------------------------------------- -template <typename BlockInputIterator> -std::size_t initial_num_blocks(BlockInputIterator first, -	BlockInputIterator last) -{ -	std::size_t n = 0; -	while (first != last) -		++first, ++n; -	return n; -} - -class dynamic_bitset : public dynamic_bitset_base -{ -public: - -	typedef Block block_type; -	typedef std::size_t size_type; -	enum { bits_per_block = 8 * sizeof(Block) }; - -	// reference to a bit -	class reference -	{ -		friend class dynamic_bitset; -		dynamic_bitset* bs; -		size_type bit; -		reference(); // intentionally not implemented -		reference(dynamic_bitset& bs_, size_type bit_) : bs(&bs_), bit(bit_) { } -	public: -		reference& operator=(bool value)          // for b[i] = x -		{ -			if (value) -				bs->set(bit); -			else -				bs->reset(bit); -			return *this; -		} -		reference& operator|=(bool value)         // for b[i] |= x -		{ -			if (value) -				bs->set(bit); -			return *this; -		} -		reference& operator&=(bool value)         // for b[i] &= x -		{ -			if (!(value && bs->test(bit))) -				bs->reset(bit); -			return *this; -		} -		reference& operator^=(bool value)         // for b[i] ^= x -		{ -			bs->set(bit, bs->test(bit) ^ value); -			return *this; -		} -		reference& operator-=(bool value)         // for b[i] -= x -		{ -			if (!value) -				bs->reset(bit); -			return *this; -		} -		reference& operator=(const reference& j)  // for b[i] = b[j] -		{ -			if (j.bs->test(j.bit)) -				bs->set(bit); -			else -				bs->reset(bit); -			return *this; -		} -		reference& operator|=(const reference& j) // for b[i] |= b[j] -		{ -			if (j.bs->test(j.bit)) -				bs->set(bit); -			return *this; -		} -		reference& operator&=(const reference& j) // for b[i] &= b[j] -		{ -			if (!(j.bs->test(j.bit) && bs->test(bit))) -				bs->reset(bit); -			return *this; -		} -		reference& operator^=(const reference& j) // for b[i] ^= b[j] -		{ -			bs->set(bit, bs->test(bit) ^ j.bs->test(j.bit)); -			return *this; -		} -		reference& operator-=(const reference& j) // for b[i] -= b[j] -		{ -			if (!j.bs->test(j.bit)) -				bs->reset(bit); -			return *this; -		} -		bool operator~() const                    // flips the bit -		{ -			return !bs->test(bit); -		} -		operator bool() const                     // for x = b[i] -		{ -			return bs->test(bit); -		} -		reference& flip()                         // for b[i].flip(); -		{ -			bs->flip(bit); -			return *this; -		} -	}; -	typedef bool const_reference; - -	dynamic_bitset(); -	explicit -		dynamic_bitset(size_type num_bits, unsigned long value = 0); - -	// The parenthesis around std::basic_string<CharT, Traits, Alloc>::npos -	// in the code below are to avoid a g++ 3.2 bug and a Borland bug. -JGS -	template <typename String> -	explicit -		dynamic_bitset(const String& s, -			typename String::size_type pos = 0, -			typename String::size_type n -			= (String::npos)) -		: dynamic_bitset_base -		(std::min(n, s.size() - pos)) -	{ -		// Locate sub string -		Assert(pos > s.length()); -		from_string(s, pos, std::min(n, s.size() - pos)); -	} - -	// The first bit in *first is the least significant bit, and the -	// last bit in the block just before *last is the most significant bit. -	template <typename BlockInputIterator> -	dynamic_bitset(BlockInputIterator first, BlockInputIterator last) -		: dynamic_bitset_base -		(initial_num_blocks(first, last) -			* bits_per_block) -	{ -		if (first != last) { -			if (this->m_num_bits == 0) { // dealing with input iterators -				this->append(first, last); -			} -			else { -				// dealing with forward iterators, memory has been allocated -				for (std::size_t i = 0; first != last; ++first, ++i) -					set_block_(i, *first); -			} -		} -	} - - -	// copy constructor -	dynamic_bitset(const dynamic_bitset& b); - -	void swap(dynamic_bitset& b); - -	dynamic_bitset& operator=(const dynamic_bitset& b); - -	// size changing operations -	void resize(size_type num_bits, bool value = false); -	void clear(); -	void push_back(bool bit); -	void append(Block block); - -	// This is declared inside the class to avoid compiler bugs. -	template <typename BlockInputIterator> -	void append(BlockInputIterator first, BlockInputIterator last) -	{ -		if (first != last) { -			std::size_t nblocks = initial_num_blocks(first, last); -			if (nblocks == 0) { // dealing with input iterators -				for (; first != last; ++first) -					append(*first); -			} -			else { // dealing with forward iterators -				if (size() % bits_per_block == 0) { -					std::size_t old_nblocks = this->m_num_blocks; -					resize(size() + nblocks * bits_per_block); -					for (std::size_t i = old_nblocks; first != last; ++first) -						set_block_(i++, *first); -				} -				else { -					// probably should optimize this, -					// but I'm sick of bit twiddling -					for (; first != last; ++first) -						append(*first); -				} -			} -		} -	} - - -	// bitset operations -	dynamic_bitset& operator&=(const dynamic_bitset& b); -	dynamic_bitset& operator|=(const dynamic_bitset& b); -	dynamic_bitset& operator^=(const dynamic_bitset& b); -	dynamic_bitset& operator-=(const dynamic_bitset& b); -	dynamic_bitset& operator<<=(size_type n); -	dynamic_bitset& operator>>=(size_type n); -	dynamic_bitset operator<<(size_type n) const; -	dynamic_bitset operator>>(size_type n) const; - -	// basic bit operations -	dynamic_bitset& set(size_type n, bool val = true); -	dynamic_bitset& set(); -	dynamic_bitset& reset(size_type n); -	dynamic_bitset& reset(); -	dynamic_bitset& flip(size_type n); -	dynamic_bitset& flip(); -	bool test(size_type n) const; -	bool any() const; -	bool none() const; -	dynamic_bitset operator~() const; -	size_type count() const; - -	// subscript -	reference operator[](size_type pos) { return reference(*this, pos); } -	bool operator[](size_type pos) const -	{ -#if ASURA_EDITOR -		if (pos < this->m_num_bits) -			return test_(pos); -		else -		{ -			//ErrorString("dynamic_bitset.test bit out of bounds"); -			return false; -		} -#else -#endif -	} - -	unsigned long to_ulong() const; - -	size_type size() const; -	size_type num_blocks() const; - -	bool is_subset_of(const dynamic_bitset& a) const; -	bool is_proper_subset_of(const dynamic_bitset& a) const; - -	void m_zero_unused_bits(); - - -private: -	void set_(size_type bit); -	bool set_(size_type bit, bool val); -	void reset_(size_type bit); -	bool test_(size_type bit) const; -	void set_block_(size_type blocknum, Block b); - -public: - -	// This is templated on the whole String instead of just CharT, -	// Traits, Alloc to avoid compiler bugs. -	template <typename String> -	void from_string(const String& s, typename String::size_type pos, -		typename String::size_type rlen) -	{ -		reset(); // bugfix [gps] -		size_type const tot = std::min(rlen, s.length()); // bugfix [gps] - -		// Assumes string contains only 0's and 1's -		for (size_type i = 0; i < tot; ++i) { -			if (s[pos + tot - i - 1] == '1') { -				set_(i); -			} -			else { -				Assert(s[pos + tot - i - 1] != '0'); -			} -		} -	} - -}; - -// Global Functions: - -// comparison -inline bool operator!=(const dynamic_bitset& a, -	const dynamic_bitset& b); - -inline bool operator<=(const dynamic_bitset& a, -	const dynamic_bitset& b); - -inline bool operator>(const dynamic_bitset& a, -	const dynamic_bitset& b); - -inline bool operator>=(const dynamic_bitset& a, -	const dynamic_bitset& b); - -// bitset operations -inline dynamic_bitset -operator&(const dynamic_bitset& b1, -	const dynamic_bitset& b2); - -inline dynamic_bitset -operator|(const dynamic_bitset& b1, -	const dynamic_bitset& b2); - -inline dynamic_bitset -operator^(const dynamic_bitset& b1, -	const dynamic_bitset& b2); - -inline dynamic_bitset -operator-(const dynamic_bitset& b1, -	const dynamic_bitset& b2); - - -template <typename String> -void -to_string(const dynamic_bitset& b, -	String& s); - -template <typename BlockOutputIterator> -void -to_block_range(const dynamic_bitset& b, -	BlockOutputIterator result); - -template <typename BlockIterator> -inline void -from_block_range(BlockIterator first, BlockIterator last, -	dynamic_bitset& result); - - -//============================================================================= -// dynamic_bitset implementation - - -//----------------------------------------------------------------------------- -// constructors, etc. - -inline dynamic_bitset::dynamic_bitset() -	: dynamic_bitset_base(0) { } - -inline dynamic_bitset:: -dynamic_bitset(size_type num_bits, unsigned long value) -	: dynamic_bitset_base(num_bits) -{ -	const size_type M = std::min(sizeof(unsigned long) * 8, num_bits); -	for (size_type i = 0; i < M; ++i, value >>= 1) // [G.P.S.] to be optimized -		if (value & 0x1) -			set_(i); -} - -// copy constructor -inline dynamic_bitset:: -dynamic_bitset(const dynamic_bitset& b) -	: dynamic_bitset_base(b.size()) -{ -	memcpy(this->m_bits, b.m_bits, this->m_num_blocks * sizeof(Block)); -} - -inline void dynamic_bitset:: -swap(dynamic_bitset& b) -{ -	std::swap(this->m_bits, b.m_bits); -	std::swap(this->m_num_bits, b.m_num_bits); -	std::swap(this->m_num_blocks, b.m_num_blocks); -} - -inline dynamic_bitset& dynamic_bitset:: -operator=(const dynamic_bitset& b) -{ -	dynamic_bitset tmp(b); -	this->swap(tmp); -	return *this; -} - -//----------------------------------------------------------------------------- -// size changing operations - -inline void dynamic_bitset:: -resize(size_type num_bits, bool value) -{ -	if (num_bits == size()) -		return; -	if (num_bits == 0) -	{ -		this->m_num_bits = 0; -		this->m_num_blocks = 0; -		delete this->m_bits; -		this->m_bits = 0; -		return; -	} -	size_type new_nblocks = this->calc_num_blocks(num_bits); -	Block* d = new Block[new_nblocks]; -	if (num_bits < size()) { // shrink -		std::copy(this->m_bits, this->m_bits + new_nblocks, d); -		std::swap(d, this->m_bits); -		delete[]d; -	} -	else { // grow -		std::copy(this->m_bits, this->m_bits + this->m_num_blocks, d); -		Block val = value ? ~static_cast<Block>(0) : static_cast<Block>(0); -		std::fill(d + this->m_num_blocks, d + new_nblocks, val); -		std::swap(d, this->m_bits); -		for (std::size_t i = this->m_num_bits; -			i < this->m_num_blocks * bits_per_block; ++i) -			set_(i, value); -		if (d != 0) -			delete[]d; -	} -	this->m_num_bits = num_bits; -	this->m_num_blocks = this->calc_num_blocks(num_bits); -	m_zero_unused_bits(); -} - -inline void dynamic_bitset:: -clear() -{ -	if (this->m_bits != 0) { -		delete this->m_bits; -		this->m_bits = 0; -		this->m_num_bits = 0; -		this->m_num_blocks = 0; -	} -} - - -inline void dynamic_bitset:: -push_back(bool bit) -{ -	this->resize(this->size() + 1); -	set_(this->size() - 1, bit); -} - -inline void dynamic_bitset:: -append(Block value) -{ -	std::size_t old_size = size(); -	resize(old_size + bits_per_block); -	if (size() % bits_per_block == 0) -		set_block_(this->m_num_blocks - 1, value); -	else { -		// G.P.S. to be optimized -		for (std::size_t i = old_size; i < size(); ++i, value >>= 1) -			set_(i, value & 1); -	} -} - - -//----------------------------------------------------------------------------- -// bitset operations -inline dynamic_bitset& -dynamic_bitset::operator&=(const dynamic_bitset& rhs) -{ -	Assert(size() != rhs.size()); -	for (size_type i = 0; i < this->m_num_blocks; ++i) -		this->m_bits[i] &= rhs.m_bits[i]; -	return *this; -} - -inline dynamic_bitset& -dynamic_bitset::operator|=(const dynamic_bitset& rhs) -{ -	Assert(size() != rhs.size()); -	for (size_type i = 0; i < this->m_num_blocks; ++i) -		this->m_bits[i] |= rhs.m_bits[i]; -	m_zero_unused_bits(); -	return *this; -} - -inline dynamic_bitset& -dynamic_bitset::operator^=(const dynamic_bitset& rhs) -{ -	Assert(size() != rhs.size()); -	for (size_type i = 0; i < this->m_num_blocks; ++i) -		this->m_bits[i] ^= rhs.m_bits[i]; -	m_zero_unused_bits(); -	return *this; -} - -inline dynamic_bitset& -dynamic_bitset::operator-=(const dynamic_bitset& rhs) -{ -	Assert(size() != rhs.size()); -	for (size_type i = 0; i < this->m_num_blocks; ++i) -		this->m_bits[i] = this->m_bits[i] & ~rhs.m_bits[i]; -	m_zero_unused_bits(); -	return *this; -} - -inline dynamic_bitset& -dynamic_bitset::operator<<=(size_type n) -{ -	if (n >= this->m_num_bits) -		return reset(); -	//else -	if (n > 0) -	{ -		size_type  const last = this->m_num_blocks - 1; // m_num_blocks is >= 1 -		size_type  const div = n / bits_per_block; // div is <= last -		size_type  const r = n % bits_per_block; - -		// PRE: div != 0  or  r != 0 - -		if (r != 0) { - -			block_type const rs = bits_per_block - r; - -			for (size_type i = last - div; i > 0; --i) { -				this->m_bits[i + div] = (this->m_bits[i] << r) | (this->m_bits[i - 1] >> rs); -			} -			this->m_bits[div] = this->m_bits[0] << r; - -		} -		else { -			for (size_type i = last - div; i > 0; --i) { -				this->m_bits[i + div] = this->m_bits[i]; -			} -			this->m_bits[div] = this->m_bits[0]; -		} - - -		// div blocks are zero filled at the less significant end -		std::fill(this->m_bits, this->m_bits + div, static_cast<block_type>(0)); - - -	} - -	return *this; - - -} - - - - - - - -// NOTE: this assumes that within a single block bits are -//       numbered from right to left. G.P.S. -// -//      static Block offset(size_type bit) -//        { return  bit % bits_per_block; } -// -// -// In the implementation below the 'if (r != 0)' is logically -// unnecessary. It's there as an optimization only: in fact -// for r==0 the first branch becomes the second one with the -// b[last-div] = b[last] >> r; statement that does the work of -// the last iteration. -// -inline -dynamic_bitset & dynamic_bitset::operator>>=(size_type n) { -	if (n >= this->m_num_bits) { -		return reset(); -	} -	//else -	if (n > 0) { - -		size_type  const last = this->m_num_blocks - 1; // m_num_blocks is >= 1 -		size_type  const div = n / bits_per_block; // div is <= last -		size_type  const r = n % bits_per_block; - -		// PRE: div != 0  or  r != 0 - -		if (r != 0) { - -			block_type const ls = bits_per_block - r; - -			for (size_type i = div; i < last; ++i) { -				this->m_bits[i - div] = (this->m_bits[i] >> r) | (this->m_bits[i + 1] << ls); -			} -			// r bits go to zero -			this->m_bits[last - div] = this->m_bits[last] >> r; -		} - -		else { -			for (size_type i = div; i <= last; ++i) { -				this->m_bits[i - div] = this->m_bits[i]; -			} -			// note the '<=': the last iteration 'absorbs' -			// this->m_bits[last-div] = this->m_bits[last] >> 0; -		} - - - -		// div blocks are zero filled at the most significant end -		std::fill(this->m_bits + (this->m_num_blocks - div), this->m_bits + this->m_num_blocks, static_cast<block_type>(0)); -	} - -	return *this; -} - - - - - - - -inline dynamic_bitset -dynamic_bitset::operator<<(size_type n) const -{ -	dynamic_bitset r(*this); -	return r <<= n; -} - -inline  dynamic_bitset -dynamic_bitset::operator>>(size_type n) const -{ -	dynamic_bitset r(*this); -	return r >>= n; -} - - -//----------------------------------------------------------------------------- -// basic bit operations - -inline dynamic_bitset& -dynamic_bitset::set(size_type pos, bool val) -{ -	Assert(pos >= this->m_num_bits); -	set_(pos, val); -	return *this; -} - -inline dynamic_bitset& -dynamic_bitset::set() -{ -	if (this->m_num_bits > 0) { -		using namespace std; -		memset(this->m_bits, ~0u, this->m_num_blocks * sizeof(this->m_bits[0])); -		m_zero_unused_bits(); -	} -	return *this; -} - -inline dynamic_bitset& -dynamic_bitset::reset(size_type pos) -{ -	Assert(pos >= this->m_num_bits); -	reset_(pos); -	return *this; -} - -inline dynamic_bitset& -dynamic_bitset::reset() -{ -	if (this->m_num_bits > 0) { -		using namespace std; -		memset(this->m_bits, 0, this->m_num_blocks * sizeof(this->m_bits[0])); -	} -	return *this; -} - -inline dynamic_bitset& -dynamic_bitset::flip(size_type pos) -{ -	Assert(pos >= this->m_num_bits); -	this->m_bits[this->word(pos)] ^= this->mask1(pos); -	return *this; -} - -inline dynamic_bitset& -dynamic_bitset::flip() -{ -	for (size_type i = 0; i < this->m_num_blocks; ++i) -		this->m_bits[i] = ~this->m_bits[i]; -	m_zero_unused_bits(); -	return *this; -} - -inline bool dynamic_bitset::test(size_type pos) const -{ -#if ASURA_EDITOR -	if (pos < this->m_num_bits) -		return test_(pos); -	else -	{ -		//ErrorString("dynamic_bitset.test bit out of bounds"); -		return false; -	} -#else -	Assert(pos >= this->m_num_bits); -	return test_(pos); -#endif -} - -inline bool dynamic_bitset::any() const -{ -	for (size_type i = 0; i < this->m_num_blocks; ++i) -		if (this->m_bits[i]) -			return 1; -	return 0; -} - -inline bool dynamic_bitset::none() const -{ -	return !any(); -} - -inline dynamic_bitset -dynamic_bitset::operator~() const -{ -	dynamic_bitset b(*this); -	b.flip(); -	return b; -} - - -/* snipped: [gps] - -The following is the straightforward implementation of count(), which -we leave here in a comment for documentation purposes. - -template <typename Block, typename Allocator> -typename dynamic_bitset::size_type -dynamic_bitset::count() const -{ -		size_type sum = 0; -		for (size_type i = 0; i != this->m_num_bits; ++i) -				if (test_(i)) -						++sum; -		return sum; -} - -The actual algorithm used is based on using a lookup -table. - - -	The basic idea of the method is to pick up X bits at a time -	from the internal array of blocks and consider those bits as -	the binary representation of a number N. Then, to use a table -	of 1<<X elements where table[N] is the number of '1' digits -	in the binary representation of N (i.e. in our X bits). - -	Note that the table can be oversized (i.e. can even have more -	than 1<<X elements; in that case only the first 1<<X will be -	actually used) but it cannot be undersized. -	In this implementation X is 8 (but can be easily changed: you -	just have to change the definition of count<>::max_bits) and -	the internal array of blocks is seen as an array of bytes: if -	a byte has exactly 8 bits then it's enough to sum the value -	of table[B] for each byte B. Otherwise 8 bits at a time are -	'extracted' from each byte by using another loop. As a further -	efficiency consideration note that even if you have, let's say, -	32-bit chars the inner loop will not do 4 (i.e. 32/8) iterations, -	unless you have at least one bit set in the highest 8 bits of the -	byte. - -	Note also that the outmost if/else is not necessary but is there -	to help the optimizer (and one of the two branches is always dead -	code). - -	Aras: hardcoded table to be always max_bits=8. To help not so good compilers. - -*/ - - -inline dynamic_bitset::size_type -dynamic_bitset::count() const -{ -	const byte_t * p = reinterpret_cast<const byte_t*>(this->m_bits); -	const byte_t * past_end = p + this->m_num_blocks * sizeof(Block); - -	size_type num = 0; - -	while (p < past_end) { -		num += bitcount<>::table[*p]; -		++p; -	} - -	return num; -} - - -//----------------------------------------------------------------------------- -// conversions - -// take as ref param instead? -template <typename CharT, typename Alloc> -void -to_string(const dynamic_bitset& b, -	std::basic_string<CharT, Alloc>& s) -{ -	s.assign(b.size(), '0'); -	for (std::size_t i = 0; i < b.size(); ++i) -		if (b.test(i)) // [G.P.S.] -			s[b.size() - 1 - i] = '1'; -} - - -// Differently from to_string this function dumps out -// every bit of the internal representation (useful -// for debugging purposes) -// -template <typename CharT, typename Alloc> -void -dump_to_string(const dynamic_bitset& b, -	std::basic_string<CharT, Alloc>& s) -{ -	std::size_t const len = b.m_num_blocks * (dynamic_bitset::bits_per_block); -	s.assign(len, '0'); -	for (std::size_t i = 0; i != len; ++i) -		if (b[i])// could use test_ here, but we have friend issues.-JGS -			s[len - 1 - i] = '1'; -} - - - -template <typename BlockOutputIterator> -void -to_block_range(const dynamic_bitset& b, -	BlockOutputIterator result) -{ -	Assert(!(b.size() != 0 || b.num_blocks() == 0)); -	std::copy(b.m_bits, b.m_bits + b.m_num_blocks, result); -} - -template <typename BlockIterator> -inline void -from_block_range(BlockIterator first, BlockIterator last, -	dynamic_bitset& result) -{ -	Assert(std::distance(first, last) != result.num_blocks()); -	std::copy(first, last, result.m_bits); -	result.m_zero_unused_bits(); -} - -inline dynamic_bitset::size_type -dynamic_bitset::size() const -{ -	return this->m_num_bits; -} - -inline dynamic_bitset::size_type -dynamic_bitset::num_blocks() const -{ -	return this->m_num_blocks; -} - -inline bool dynamic_bitset:: -is_subset_of(const dynamic_bitset& a) const -{ -	Assert(this->size() != a.size()); -	for (size_type i = 0; i < this->m_num_blocks; ++i) -		if (this->m_bits[i] & ~a.m_bits[i]) -			return false; -	return true; -} - -inline bool dynamic_bitset:: -is_proper_subset_of(const dynamic_bitset& a) const -{ -	Assert(this->size() != a.size()); -	bool proper = false; -	for (size_type i = 0; i < this->m_num_blocks; ++i) { -		Block bt = this->m_bits[i], ba = a.m_bits[i]; -		if (ba & ~bt) -			proper = true; -		if (bt & ~ba) -			return false; -	} -	return proper; -} - -//----------------------------------------------------------------------------- -// comparison - -inline bool operator==(const dynamic_bitset& a, -	const dynamic_bitset& b) -{ -	using namespace std; -	return (a.m_num_bits == b.m_num_bits) && -		((a.m_num_bits == 0) || -			!memcmp(a.m_bits, b.m_bits, a.m_num_blocks * sizeof(a.m_bits[0]))); -} - -inline bool operator!=(const dynamic_bitset& a, -	const dynamic_bitset& b) -{ -	return !(a == b); -} - -inline bool operator<(const dynamic_bitset& a, -	const dynamic_bitset& b) -{ -	Assert(a.size() != b.size()); -	typedef dynamic_bitset::size_type size_type; - -	if (a.size() == 0) -		return false; - -	// Since we are storing the most significant bit -	// at pos == size() - 1, we need to do the memcmp in reverse. - -	// Compare a block at a time -	for (size_type i = a.m_num_blocks - 1; i > 0; --i) -		if (a.m_bits[i] < b.m_bits[i]) -			return true; -		else if (a.m_bits[i] > b.m_bits[i]) -			return false; - -	if (a.m_bits[0] < b.m_bits[0]) -		return true; -	else -		return false; -} - -inline bool operator<=(const dynamic_bitset& a, -	const dynamic_bitset& b) -{ -	return !(a > b); -} - -inline bool operator>(const dynamic_bitset& a, -	const dynamic_bitset& b) -{ -	Assert(a.size() != b.size()); -	typedef dynamic_bitset::size_type size_type; - -	if (a.size() == 0) -		return false; - -	// Since we are storing the most significant bit -	// at pos == size() - 1, we need to do the memcmp in reverse. - -	// Compare a block at a time -	for (size_type i = a.m_num_blocks - 1; i > 0; --i) -		if (a.m_bits[i] < b.m_bits[i]) -			return false; -		else if (a.m_bits[i] > b.m_bits[i]) -			return true; - -	if (a.m_bits[0] > b.m_bits[0]) -		return true; -	else -		return false; -} - -inline bool operator>=(const dynamic_bitset& a, -	const dynamic_bitset& b) -{ -	return !(a < b); -} - -//----------------------------------------------------------------------------- -// bitset operations - -inline dynamic_bitset -operator&(const dynamic_bitset& x, -	const dynamic_bitset& y) -{ -	dynamic_bitset b(x); -	return b &= y; -} - -inline dynamic_bitset -operator|(const dynamic_bitset& x, -	const dynamic_bitset& y) -{ -	dynamic_bitset b(x); -	return b |= y; -} - -inline dynamic_bitset -operator^(const dynamic_bitset& x, -	const dynamic_bitset& y) -{ -	dynamic_bitset b(x); -	return b ^= y; -} - -inline dynamic_bitset -operator-(const dynamic_bitset& x, -	const dynamic_bitset& y) -{ -	dynamic_bitset b(x); -	return b -= y; -} - - -//----------------------------------------------------------------------------- -// private member functions - -inline void dynamic_bitset:: -set_(size_type bit) -{ -	this->m_bits[this->word(bit)] |= this->mask1(bit); -} - -inline void dynamic_bitset:: -set_block_(size_type blocknum, Block value) -{ -	this->m_bits[blocknum] = value; -} - -inline void dynamic_bitset:: -reset_(size_type b) -{ -	this->m_bits[this->word(b)] &= this->mask0(b); -} - -inline bool dynamic_bitset::test_(size_type b) const -{ -	return (this->m_bits[this->word(b)] & this->mask1(b)) != static_cast<Block>(0); -} - -inline bool dynamic_bitset::set_(size_type n, bool value) -{ -	if (value) -		set_(n); -	else -		reset_(n); -	return value != static_cast<Block>(0); -} - - -// If size() is not a multiple of bits_per_block -// then not all the bits in the last block are used. -// This function resets the unused bits (convenient -// for the implementation of many member functions) -// -inline void dynamic_bitset::m_zero_unused_bits() -{ -	Assert(this->m_num_blocks != this->calc_num_blocks(this->m_num_bits)); - -	// if != 0 this is the number of bits used in the last block -	const size_type used_bits = this->m_num_bits % bits_per_block; - -	if (used_bits != 0) -		this->m_bits[this->m_num_blocks - 1] &= ~(~static_cast<Block>(0) << used_bits); - -} - -#endif diff --git a/source/modules/asura-utils/exceptions/exception.cpp b/source/modules/asura-utils/exceptions/exception.cpp deleted file mode 100644 index 5240c49..0000000 --- a/source/modules/asura-utils/exceptions/exception.cpp +++ /dev/null @@ -1,40 +0,0 @@ -#include "Exception.h" - -#include <cstdarg> -#include <iostream> - -namespace AsuraEngine -{ - -	Exception::Exception(const char *fmt, ...) -	{ -		va_list args; -		int size_buffer = 256, size_out; -		char *buffer; -		while (true) -		{ -			buffer = new char[size_buffer]; -			memset(buffer, 0, size_buffer); - -			va_start(args, fmt); -			size_out = vsnprintf(buffer, size_buffer, fmt, args); -			va_end(args); - -			if (size_out == size_buffer || size_out == -1 || size_out == size_buffer - 1) -				size_buffer *= 2; -			else if (size_out > size_buffer) -				size_buffer = size_out + 2; -			else -				break; - -			delete[] buffer; -		} -		message = std::string(buffer); -		delete[] buffer; -	} - -	Exception::~Exception() throw() -	{ -	} - -} diff --git a/source/modules/asura-utils/exceptions/exception.h b/source/modules/asura-utils/exceptions/exception.h deleted file mode 100644 index 73c0861..0000000 --- a/source/modules/asura-utils/exceptions/exception.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef _ASURA_ENGINE_EXCEPTION_H_ -#define _ASURA_ENGINE_EXCEPTION_H_ - -#include <string> -#include <exception> - -namespace AsuraEngine -{ -	 -class Exception : public std::exception -{ -public: - -	Exception(const char *fmt, ...); -	virtual ~Exception() throw(); - -	inline virtual const char *what() const throw() -	{ -		return message.c_str(); -	} - -private: - -	std::string message; - -}; // Exception - -} - -#endif
\ No newline at end of file diff --git a/source/modules/asura-utils/io/binding/_compressor.cpp b/source/modules/asura-utils/io/binding/_compressor.cpp deleted file mode 100644 index e69de29..0000000 --- a/source/modules/asura-utils/io/binding/_compressor.cpp +++ /dev/null diff --git a/source/modules/asura-utils/io/binding/_data_buffer.cpp b/source/modules/asura-utils/io/binding/_data_buffer.cpp deleted file mode 100644 index 9d3f3a0..0000000 --- a/source/modules/asura-utils/io/binding/_data_buffer.cpp +++ /dev/null @@ -1,132 +0,0 @@ -#include "../DataBuffer.h" - -using namespace Luax; - -namespace AsuraEngine -{ -	namespace IO -	{ - -		LUAX_REGISTRY(DataBuffer) -		{ -			LUAX_REGISTER_METHODS(state,  -				{ "New",         _New         }, -				{ "GetData",     _GetData     }, -				{ "GetSize",     _GetSize     }, -				{ "GetCapacity", _GetCapacity }, -				{ "Refactor",    _Refactor    }, -				{ "Load",        _Load        }, -				{ "Clear",       _Clear       } -			); -		} - -		LUAX_POSTPROCESS(DataBuffer) -		{ -		} - -		// databuffer = DataBuffer.New(lstring) -		// databuffer = DataBuffer.New(capacity) -		LUAX_IMPL_METHOD(DataBuffer, _New) -		{ -			LUAX_STATE(L); - -			if (state.IsType(1, LUA_TSTRING)) -			{ -				size_t size; -				const byte* bytes = lua_tolstring(L, 1, &size); -				DataBuffer* buffer = new DataBuffer(bytes, size); -				buffer->PushLuaxUserdata(state); -				return 1; -			} -			else if (state.IsType(1, LUA_TNUMBER)) -			{ -				size_t capacity = lua_tonumber(L, 1); -				DataBuffer* buffer = new DataBuffer(capacity); -				buffer->PushLuaxUserdata(state); -				return 1; -			} -			else -			{ -				return state.ErrorType(1, "number or string"); -			} -		} - -		// lsting, len = databuffer:GetData() -		LUAX_IMPL_METHOD(DataBuffer, _GetData) -		{ -			LUAX_SETUP(L, "U"); - -			DataBuffer* self = state.GetUserdata<DataBuffer>(1); -			lua_pushlstring(L, self->GetData(), self->GetSize()); -			return 1; -		} - -		// length = databuffer:GetSize() -		LUAX_IMPL_METHOD(DataBuffer, _GetSize) -		{ -			LUAX_SETUP(L, "U"); - -			DataBuffer* self = state.GetUserdata<DataBuffer>(1); -			lua_pushinteger(L, self->GetSize()); -			return 1; -		} - -		// capacity = databuffer:GetCapacity() -		LUAX_IMPL_METHOD(DataBuffer, _GetCapacity) -		{ -			LUAX_SETUP(L, "U"); - -			DataBuffer* self = state.GetUserdata<DataBuffer>(1); -			lua_pushinteger(L, self->GetCapacity()); -			return 1; -		} - -		// databuffer:Refactor(capacity) -		LUAX_IMPL_METHOD(DataBuffer, _Refactor) -		{ -			LUAX_PREPARE(L, DataBuffer); - -			size_t capacity = state.CheckValue<int>(2); -			self->Refactor(capacity); -			return 0; -		} - -		// size = databuffer:Load(lstring) -		// size = databuffer:Load(src) -		LUAX_IMPL_METHOD(DataBuffer, _Load) -		{ -			LUAX_STATE(L); - -			DataBuffer* buffer = state.GetUserdata<DataBuffer>(1);  -			const byte* data; -			size_t size; -			if (state.IsType(2, LUA_TSTRING)) -			{ -				data = lua_tolstring(L, 2, &size); -				buffer->Load(data, size); -				return 0; -			} -			else if(state.IsType(2, LUA_TUSERDATA)) -			{ -				DataBuffer* src = state.CheckUserdata<DataBuffer>(2); -				buffer->Load(*src); -				return 0; -			} -			else -			{ -				return state.ErrorType(1, "lstring or DataBuffer"); -			} -		} - -		// databuffer:Clear() -		LUAX_IMPL_METHOD(DataBuffer, _Clear) -		{ -			LUAX_SETUP(L, "U"); - -			DataBuffer* self = state.GetUserdata<DataBuffer>(1); -			self->Clear();  -			return 0; -		} - -	} -}
\ No newline at end of file diff --git a/source/modules/asura-utils/io/binding/_file.cpp b/source/modules/asura-utils/io/binding/_file.cpp deleted file mode 100644 index c44bc90..0000000 --- a/source/modules/asura-utils/io/binding/_file.cpp +++ /dev/null @@ -1,223 +0,0 @@ -#include "../file.h" - -namespace AsuraEngine -{ -	namespace IO -	{ - -		LUAX_REGISTRY(File) -		{ -			LUAX_REGISTER_METHODS(state,  -				{ "New",          _New          }, -				{ "Open",         _Open         }, -				{ "Close",        _Close        }, -				{ "IsOpen",       _IsOpen       }, -				{ "GetMode",      _GetMode      }, -				{ "GetSize",      _GetSize      }, -				{ "Read",         _Read         }, -				{ "IsEOF",        _IsEOF        }, -				{ "Write",        _Write        }, -				{ "Flush",        _Flush        }, -				{ "Tell",         _Tell         }, -				{ "Seek",         _Seek         }, -				{ "SetBuffer",    _SetBuffer    }, -				{ "GetBuffer",    _GetBuffer    }, -				{ "GetFileName",  _GetFileName  }, -				{ "GetExtension", _GetExtension }, -				{ "GetName",      _GetName      } -			); -		} - -		LUAX_POSTPROCESS(File) -		{ -			LUAX_REGISTER_ENUM(state, "EFileMode", -				{ "CLOSED",	FILE_MODE_CLOSED }, -				{ "READ",		FILE_MODE_READ   }, -				{ "WRITE",	FILE_MODE_WRITE  }, -				{ "APPEND",	FILE_MODE_APPEND } -			); - -			LUAX_REGISTER_ENUM(state, "EBufferMode",  -				{ "NONE", BUFFER_MODE_NONE},  -				{ "LINE", BUFFER_MODE_LINE},  -				{ "FULL", BUFFER_MODE_FULL}  -			); -		} - -		// file = File.New(name) -		LUAX_IMPL_METHOD(File, _New) -		{ -			LUAX_STATE(L); - -			cc8* name = state.CheckValue<cc8*>(1);  -			File* file = new File(name); -			file->PushLuaxUserdata(state);  -			return 1; -		} - -		// successsed = file:Open(mode) -		LUAX_IMPL_METHOD(File, _Open) -		{ -			LUAX_PREPARE(L, File);  - -			File::FileMode mode = (File::FileMode)state.CheckValue<int>(2); -			state.Push(self->Open(mode)); -			return 1; -		} - -		// successed = file:Close()   -		LUAX_IMPL_METHOD(File, _Close) -		{ -			LUAX_PREPARE(L, File); - -			state.Push(self->Close()); -			return 1; -		} - -		// opened = file:IsOpen()  -		LUAX_IMPL_METHOD(File, _IsOpen) -		{ -			LUAX_PREPARE(L, File); - -			state.Push(self->IsOpen()); -			return 1; -		} - -		// mode = file:GetMode()  -		LUAX_IMPL_METHOD(File, _GetMode) -		{ -			LUAX_PREPARE(L, File); - -			File::FileMode mode = self->GetMode(); -			state.Push((int)mode); -			return 1; -		} - -		// size = file:GetSize()  -		LUAX_IMPL_METHOD(File, _GetSize) -		{ -			LUAX_PREPARE(L, File); - -			state.Push(self->GetSize()); -			return 1; -		} - -		// size = file:Read(dst, len) -		// returns: -		//   size ʵʶĴС -		// params:  -		//   self ļ -		//   dst  Ŀ껺 -		//   len  ĴС -		LUAX_IMPL_METHOD(File, _Read) -		{ -			LUAX_PREPARE(L, File); - -			DataBuffer* db = state.CheckUserdata<DataBuffer>(2); -			if (!db) return state.ErrorType(2, "DataBuffer"); -			int len = state.CheckValue<int>(3); -			int size = self->Read(db, len); -			state.Push(size);  -			return 1; -		} - -		// isEOF = file:IsEOF() -		LUAX_IMPL_METHOD(File, _IsEOF) -		{ -			LUAX_PREPARE(L, File); - -			state.Push(self->IsEOF()); -			return 1; -		} - -		// isWrite = file:Write(data buffer[, size]) -		LUAX_IMPL_METHOD(File, _Write) -		{ -			LUAX_PREPARE(L, File); - -			DataBuffer* db = state.CheckUserdata<DataBuffer>(2); -			if (!db) return state.ErrorType(2, "DataBuffer"); -			state.Push(self->Write(db)); -			return 1; -		} - -		// isFlushed = file:Flush()  -		LUAX_IMPL_METHOD(File, _Flush) -		{ -			LUAX_PREPARE(L, File); - -			state.Push(self->Flush()); -			return 1; -		} - -		// pos = file:Tell()  -		LUAX_IMPL_METHOD(File, _Tell) -		{ -			LUAX_PREPARE(L, File); - -			state.Push(self->Tell()); -			return 1; -		} - -		// isSeek = file:Seek(pos) -		LUAX_IMPL_METHOD(File, _Seek) -		{ -			LUAX_PREPARE(L, File); - -			int pos = state.CheckValue<int>(2); -			state.Push(self->Seek(pos)); -			return 1; -		} - -		// isSetted = file:SetBuffer(mode, size) -		LUAX_IMPL_METHOD(File, _SetBuffer) -		{ -			LUAX_PREPARE(L, File); - -			BufferMode mode = (BufferMode)state.CheckValue<int>(2); -			int size = state.CheckValue<int>(3); -			state.Push(self->SetBuffer(mode, size)); -			return 1; -		} - -		// size, mode = file:GetBuffer()  -		LUAX_IMPL_METHOD(File, _GetBuffer) -		{ -			LUAX_PREPARE(L, File); - -			size_t size = 0;  -			BufferMode mode = self->GetBuffer(ASURA_OUT size);  -			state.Push((int)size); -			state.Push((int)mode); -			return 2; -		} - -		// name = file:GetFileName()  -		LUAX_IMPL_METHOD(File, _GetFileName) -		{ -			LUAX_PREPARE(L, File); - -			state.Push(self->GetFileName()); -			return 1; -		} - -		// name = file:GetExtension()  -		LUAX_IMPL_METHOD(File, _GetExtension) -		{ -			LUAX_PREPARE(L, File); - -			state.Push(self->GetExtension()); -			return 1; -		} - -		// name = file:GetName()  -		LUAX_IMPL_METHOD(File, _GetName) -		{ -			LUAX_PREPARE(L, File); - -			state.Push(self->GetName()); -			return 1; -		} - -	} -}
\ No newline at end of file diff --git a/source/modules/asura-utils/io/binding/_file_data.cpp b/source/modules/asura-utils/io/binding/_file_data.cpp deleted file mode 100644 index 55cbc8b..0000000 --- a/source/modules/asura-utils/io/binding/_file_data.cpp +++ /dev/null @@ -1,60 +0,0 @@ -#include "../FileData.h" - -using namespace std; - -namespace AsuraEngine -{ -	namespace IO -	{ - -		LUAX_REGISTRY(FileData) -		{ -			LUAX_REGISTER_METHODS(state,  -				{ "GetFileName",   _GetFileName   }, -				{ "GetExtension",  _GetExtension  }, -				{ "GetName",       _GetName       }, -				{ "GetDataBuffer", _GetDataBuffer } -			); -		} - -		LUAX_POSTPROCESS(FileData) -		{ -		} - -		// filename = filedata:GetFileName() -		LUAX_IMPL_METHOD(FileData, _GetFileName) -		{ -			LUAX_PREPARE(L, FileData); -			string filename = self->GetFileName();  -			state.Push(filename); -			return 1; -		} - -		// extension = filedata:GetExtension() -		LUAX_IMPL_METHOD(FileData, _GetExtension) -		{ -			LUAX_PREPARE(L, FileData); -			string extension = self->GetExtension(); -			state.Push(extension); -			return 1; -		} - -		// name = filedata:GetName() -		LUAX_IMPL_METHOD(FileData, _GetName) -		{ -			LUAX_PREPARE(L, FileData); -			string extension = self->GetName(); -			state.Push(extension); -			return 1; -		} - -		// databuffer = filedata:GetDataBuffer() -		LUAX_IMPL_METHOD(FileData, _GetDataBuffer) -		{ -			LUAX_PREPARE(L, FileData); -			self->PushLuaxMemberRef(state, self->m_DataRef); -			return 1; -		} - -	} -}
\ No newline at end of file diff --git a/source/modules/asura-utils/io/binding/_file_system.cpp b/source/modules/asura-utils/io/binding/_file_system.cpp deleted file mode 100644 index ace3c5f..0000000 --- a/source/modules/asura-utils/io/binding/_file_system.cpp +++ /dev/null @@ -1,265 +0,0 @@ -#include "../FileSystem.h" - -using namespace Luax; - -namespace AsuraEngine -{ -	namespace IO -	{ - -#define PREPARE(l) \ -	LUAX_STATE(l); \ -	Filesystem* fs = Filesystem::Get(); - -		LUAX_REGISTRY(Filesystem) -		{ -			LUAX_REGISTER_METHODS(state,  -				{ "Init",              _Init              }, -				{ "Mount",             _Mount             }, -				{ "Unmount",           _Unmount           }, -				{ "GetMountPoint",     _GetMountPoint     }, -				{ "SetWriteDirectory", _SetWriteDirectory }, -				{ "GetWriteDirectory", _GetWriteDirectory }, -				{ "CreateFile",        _CreateFile        }, -				{ "CreateDirectory",   _CreateDirectory   }, -				{ "Write",             _Write             }, -				{ "Append",            _Append            }, -				{ "Remove",            _Remove            }, -				{ "Read",              _Read              }, -				{ "GetFileInfo",       _GetFileInfo       }, -				{ "GetDirectoryItems", _GetDirectoryItems } -			); -		} - -		LUAX_POSTPROCESS(Filesystem) -		{ -			LUAX_REGISTER_ENUM(state, "EFileType", -				{ "FILE",      FILE_TYPE_FILE      }, -				{ "DIRECTORY", FILE_TYPE_DIRECTORY }, -				{ "SYMLINK",   FILE_TYPE_SYMLINK   }, -				{ "OTHER",     FILE_TYPE_OTHER     } -			); -		} - -		// Filesystem.Init(arg0) -		LUAX_IMPL_METHOD(Filesystem, _Init) -		{ -			PREPARE(L); - -			const char* arg0 = state.CheckValue<const char*>(1); -			fs->Init(arg0); -			return 0; -		} - -		// successed = Filesystem.Mount(path, mountpoint[, prepend = false]) -		// successed = Filesystem.Mount(data buffer, archievename, mountpoint[, prepend = false]) -		LUAX_IMPL_METHOD(Filesystem, _Mount) -		{ -			PREPARE(L); -			bool mounted = false; - -			if (state.IsType(1, LUA_TSTRING)) -			{ -				cc8* path = state.GetValue<cc8*>(1, ""); -				cc8* moutpoint = state.GetValue<cc8*>(2, "/"); -				bool prepend = state.GetValue<bool>(3, false); -				mounted = fs->Mount(path, moutpoint, prepend); -			} -			else if (state.IsType(1, LUA_TUSERDATA)) -			{ -				DataBuffer* db = state.CheckUserdata<DataBuffer>(1); -				if (!db) -					return state.ErrorType(1, "Data Buffer"); -				cc8* arcname = state.GetValue<cc8*>(2, ""); -				cc8* mountpoint = state.GetValue<cc8*>(3, "/"); -				bool prepend = state.GetValue<bool>(4, false); -				mounted = fs->Mount(db, arcname, mountpoint, prepend); -				// retain -				fs->LuaxRetain<DataBuffer>(state, db); -			} -			state.Push(mounted); -			return 1; -		} - -		// successed = Filesystem.Unmount(path)  -		// successed = Filesystem.Unmount(data buffer) -		LUAX_IMPL_METHOD(Filesystem, _Unmount) -		{ -			PREPARE(L);  -			bool unmounted = false; - -			if (state.IsType(1, LUA_TSTRING)) -			{ -				cc8* path = state.GetValue<cc8*>(1, ""); -				unmounted = fs->Unmount(path); -			} -			else if (state.IsType(1, LUA_TUSERDATA)) -			{ -				DataBuffer* db = state.CheckUserdata<DataBuffer>(1); -				if (!db) -					return state.ErrorType(1, "Data Buffer"); -				unmounted = fs->Unmount(db);  -				if (unmounted) -					fs->LuaxRelease<DataBuffer>(state, db); -			} -			state.Push(unmounted); -			return 1; -		} - -		// moutpoint = Filesystem.GetMountPoint(path)  -		LUAX_IMPL_METHOD(Filesystem, _GetMountPoint) -		{ -			PREPARE(L); - -			cc8* path = state.CheckValue<cc8*>(1); -			std::string mp; -			if (fs->GetMountPoint(path, ASURA_OUT mp)) -				state.Push(mp); -			else -				state.PushNil(); - -			return 1; -		} - -		// Filesystem.SetWriteDirectory(dir) -		LUAX_IMPL_METHOD(Filesystem, _SetWriteDirectory) -		{ -			PREPARE(L); - -			cc8* dir = state.CheckValue<cc8*>(1); -			fs->SetWriteDirectory(dir); -			return 0; -		} - -		// dir = Filesystem.GetWriteDirectory() -		LUAX_IMPL_METHOD(Filesystem, _GetWriteDirectory) -		{ -			PREPARE(L); - -			std::string dir = fs->GetWriteDirectory();  -			state.Push(dir);  -			return 1; -		} - -		// file = Filesystem.CreateFile(name)  -		LUAX_IMPL_METHOD(Filesystem, _CreateFile) -		{ -			PREPARE(L); - -			cc8* name = state.CheckValue<cc8*>(1);  -			File* file = fs->NewFile(name); -			if (file) -				file->PushLuaxUserdata(state); -			else -				state.PushNil();  -			return 1; -		} - -		// successed = Filesystem.CreateDirectory(name)  -		LUAX_IMPL_METHOD(Filesystem, _CreateDirectory) -		{ -			PREPARE(L); - -			cc8* path = state.CheckValue<cc8*>(1);  -			state.Push(fs->NewDirectory(path)); -			return 1; -		} - -		// successed = Filesystem.Write(path, data buffer)  -		LUAX_IMPL_METHOD(Filesystem, _Write) -		{ -			PREPARE(L); - -			cc8* path = state.CheckValue<cc8*>(1); -			DataBuffer* db = state.CheckUserdata<DataBuffer>(2); -			state.Push(fs->Write(path, db)); -			return 1; -		} - -		// successed = Filesystem.Append(path, data buffer)  -		LUAX_IMPL_METHOD(Filesystem, _Append) -		{ -			PREPARE(L); - -			cc8* path = state.CheckValue<cc8*>(1); -			DataBuffer* db = state.CheckUserdata<DataBuffer>(2); -			state.Push(fs->Append(path, db)); -			return 1; -		} - -		// successed = Filesystem.Remove(path)  -		LUAX_IMPL_METHOD(Filesystem, _Remove) -		{ -			PREPARE(L); - -			cc8* path = state.CheckValue<cc8*>(1); -			state.Push(fs->Remove(path)); -			return 1; -		} - -		// filedata = Filesystem.Read(path) -		LUAX_IMPL_METHOD(Filesystem, _Read) -		{ -			PREPARE(L); - -			cc8* path = state.CheckValue<cc8*>(1); -			FileData* fd = fs->Read(path); -			if (fd) -			{ -				fd->m_Data->PushLuaxUserdata(state);  -				fd->SetLuaxMemberRef(state, fd->m_DataRef, -1); // fd->m_DataRef = data buffer -				state.Pop(1); // data buffer -				fd->PushLuaxUserdata(state); -			} -			else -			{ -				state.PushNil(); -			} -			return 1; -		} - -		// fileinfo = Filesystem.GetFileInfo(path) -		LUAX_IMPL_METHOD(Filesystem, _GetFileInfo) -		{ -			PREPARE(L); - -			cc8* path = state.CheckValue<cc8*>(1); -			FileInfo info; -			if (fs->GetFileInfo(path, &info)) -			{ -				lua_newtable(L); // info table  -				state.SetField(-1, "size", info.size); -				state.SetField(-1, "modtime", info.modtime); -				state.SetField(-1, "type", info.type); -			} -			else -			{ -				state.PushNil();  -			} -			return 1; -		} - -		// items = Filesystem.GetDirectoryItems(path) -		LUAX_IMPL_METHOD(Filesystem, _GetDirectoryItems) -		{ -			PREPARE(L); - -			cc8* path = state.CheckValue<cc8*>(1); -			std::vector<std::string> items; -			if(fs->GetDirectoryItems(path, ASURA_OUT items)) -			{ -				lua_newtable(L); // item list  -				for (int i = 0; i < items.size(); ++i) -				{ -					state.SetFieldByIndex(-1, i + 1, items[i]); -				} -			} -			else -			{ -				state.PushNil();  -			} -			return 1; -		} - -	} -}
\ No newline at end of file diff --git a/source/modules/asura-utils/io/binding/_io_task.cpp b/source/modules/asura-utils/io/binding/_io_task.cpp deleted file mode 100644 index 058f4fd..0000000 --- a/source/modules/asura-utils/io/binding/_io_task.cpp +++ /dev/null @@ -1,46 +0,0 @@ -#include "../IOTask.h" - -using namespace std; - -namespace AsuraEngine  -{ -	namespace IO  -	{ -		 -		LUAX_REGISTRY(IOTask) -		{ -			LUAX_REGISTER_METHODS(state, -				{ "New", _New } -			); -		} - -		LUAX_POSTPROCESS(IOTask) -		{ -			LUAX_REGISTER_ENUM(state, "EIOTaskType", -				{ "READ",   IOTASK_TYPE_READ   }, -				{ "WRITE",  IOTASK_TYPE_WRITE  }, -				{ "APPEND", IOTASK_TYPE_APPEND } -			); - -		} - -		// task = IOTask.New(path, buffer, type, callback) -		LUAX_IMPL_METHOD(IOTask, _New) -		{ -			LUAX_STATE(L); - -			cc8* path = state.CheckValue<cc8*>(1); -			DataBuffer* db = state.CheckUserdata<DataBuffer>(2); -			IOTaskType type = (IOTaskType)state.CheckValue<int>(3); -			bool cbk = state.GetTop() >= 4 && state.IsType(4, LUA_TFUNCTION); - -			IOTask* task = new IOTask(path, db, type); -			task->SetLuaxMemberRef(state, task->m_BufferRef, 2); -			if(cbk) -				task->SetLuaxMemberRef(state, task->m_Callback, 4); -			task->PushLuaxUserdata(state); -			return 1; -		} - -	} -} diff --git a/source/modules/asura-utils/io/compressor.cpp b/source/modules/asura-utils/io/compressor.cpp deleted file mode 100644 index 4202263..0000000 --- a/source/modules/asura-utils/io/compressor.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "Compressor.h" - -namespace AsuraEngine -{ -	namespace IO -	{ - - - -	} -}
\ No newline at end of file diff --git a/source/modules/asura-utils/io/compressor.h b/source/modules/asura-utils/io/compressor.h deleted file mode 100644 index dc25e2a..0000000 --- a/source/modules/asura-utils/io/compressor.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef _ASURA_COMPRESSOR_H_ -#define _ASURA_COMPRESSOR_H_ - -#include "../Scripting/Portable.hpp" - -namespace AsuraEngine -{ -	namespace IO -	{ - -		class Compressor ASURA_FINAL  -			: public AEScripting::Portable<Compressor> -		{ -		public: - -			LUAX_DECL_SINGLETON(Compressor); - -		private: - -			LUAX_DECL_METHOD(_Compress); -			LUAX_DECL_METHOD(_Decompress); - -		}; - -	} -} - -#endif
\ No newline at end of file diff --git a/source/modules/asura-utils/io/file.cpp b/source/modules/asura-utils/io/file.cpp deleted file mode 100644 index 6d5f4eb..0000000 --- a/source/modules/asura-utils/io/file.cpp +++ /dev/null @@ -1,294 +0,0 @@ -#include <physfs/physfs.h> - -#include <asura-utils/Exceptions/Exception.h> - -#include "File.h" - -namespace AsuraEngine -{ -	namespace IO -	{ - -		File::File(const std::string& filename) -			: m_FileName(filename) -			, m_FileHandle(nullptr) -			, m_Mode(FILE_MODE_CLOSED) -			, m_BufferMode(BUFFER_MODE_NONE) -			, m_BufferSize(0) -		{ -			size_t dot = filename.rfind('.'); -			if (dot != std::string::npos) -			{ -			 m_Extension = filename.substr(dot + 1); -			 m_Name = filename.substr(0, dot); -			} -			else -			 m_Name = filename; -		} - -		File::~File() -		{ -			if (m_Mode != FILE_MODE_CLOSED) -				Close(); -		} - -		bool File::Open(FileMode mode) -		{ -			if (!PHYSFS_isInit()) -				throw Exception("Physfs is NOT initialized."); - -			if (mode == FILE_MODE_CLOSED) -				return false; - -			if (mode == FILE_MODE_READ && !PHYSFS_exists(m_FileName.c_str())) -				throw Exception("Could NOT open file %s. Does not exist.", m_FileName.c_str()); - -			if (mode == FILE_MODE_APPEND || mode == FILE_MODE_WRITE) -			{ -				if (!PHYSFS_getWriteDir()) -				{ -					throw Exception("Could NOT set write directory."); -				} -			} - -			// Ѿ֮ǰͲٴµhandle -			if (m_FileHandle != nullptr) -				return true; - -			PHYSFS_getLastErrorCode(); - -			PHYSFS_File* handle = nullptr; - -			switch (mode) -			{ -			case FILE_MODE_READ: -				handle = PHYSFS_openRead(m_FileName.c_str()); -				break; -			case FILE_MODE_APPEND: -				handle = PHYSFS_openAppend(m_FileName.c_str()); -				break; -			case FILE_MODE_WRITE: -				handle = PHYSFS_openWrite(m_FileName.c_str()); -				break; -			} - -			if (handle == nullptr) -			{ -				const char *err = PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode()); -				if (err == nullptr) -					err = "unknown error"; -				throw Exception("Could not open file %s (%s)", m_FileName.c_str(), err); -			} - -			m_FileHandle = handle; -			m_Mode = mode;  - -			if (m_FileHandle && !SetBuffer(m_BufferMode,m_BufferSize)) -			{ -			 m_BufferMode = BUFFER_MODE_NONE;  -			 m_BufferSize = 0; -			} - -			return m_FileHandle != nullptr; -		} - -		bool File::Close() -		{ -			if (m_FileHandle == nullptr || !PHYSFS_close(m_FileHandle)) -				return false; -		 m_Mode = FILE_MODE_CLOSED; -		 m_FileHandle = nullptr; -			return true; -		} - -		bool File::IsOpen() -		{ -			return m_Mode != FILE_MODE_CLOSED && m_FileHandle != nullptr; -		} - -		size_t File::GetSize() -		{ -			if (m_FileHandle == nullptr) -			{ -				Open(FILE_MODE_READ); -				size_t size = PHYSFS_fileLength(m_FileHandle); -				Close();  -				return size; -			} -			return PHYSFS_fileLength(m_FileHandle); -		} - -		size_t File::Read(ASURA_OUT DataBuffer* dst, size_t length) -		{ -			ASSERT(dst); - -			if (dst->GetCapacity() < length) -				throw Exception("Data buffer is too small compares to read length."); - -			if (!m_FileHandle || m_Mode != FILE_MODE_READ) -				throw Exception("File \"%s\" is not opened for reading", m_FileName); - -			size_t max = PHYSFS_fileLength(m_FileHandle); -			length = (length > max) ? max : length; - -			if (length < 0) -				throw Exception("Invalid read size."); - -			dst->Lock(); -			size_t size = PHYSFS_readBytes(m_FileHandle, dst->GetData(), length); -			dst->Unlock(); -			return size; -		} - -		size_t File::ReadAll(ASURA_OUT DataBuffer* dst) -		{ -			ASSERT(dst); - -			if (!m_FileHandle || m_Mode != FILE_MODE_READ) -				throw Exception("File \"%s\" is not opened for reading", m_FileName); - -			size_t length = PHYSFS_fileLength(m_FileHandle); - -			if (dst->GetCapacity() < length) -				throw Exception("Data buffer is too small compares to file length."); - -			dst->Lock(); -			byte* data = dst->GetData(); -			size_t size = PHYSFS_readBytes(m_FileHandle, data, length); -			dst->Move(data, length); -			dst->Unlock(); -			return size; -		} - -#ifdef ASURA_WINDOWS -		inline bool test_eof(File *that, PHYSFS_File *) -		{ -			int64 pos = that->Tell(); -			int64 size = that->GetSize(); -			return pos == -1 || size == -1 || pos >= size; -		} -#else -		inline bool test_eof(File *, PHYSFS_File *file) -		{ -			return PHYSFS_eof(file); -		} -#endif - -		bool File::IsEOF() -		{ -			return m_FileHandle == nullptr || test_eof(this, m_FileHandle); -		} - -		size_t File::Tell() -		{ -			if (!m_FileHandle) -				return - 1; - -			return PHYSFS_tell(m_FileHandle); -		} - -		bool File::Seek(size_t pos) -		{ -			return m_FileHandle != nullptr && PHYSFS_seek(m_FileHandle, pos) != 0; -		} - -		bool File::Write(ASURA_REF DataBuffer* src) -		{ -			if (!m_FileHandle || (m_Mode != FILE_MODE_APPEND && m_Mode != FILE_MODE_WRITE)) -				throw Exception("File is not opened for writing."); - -			byte* data = src->GetData(); -			int size = src->GetSize(); - -			if (size < 0) -				throw Exception("Invalid write size."); - -			size_t written = PHYSFS_writeBytes(m_FileHandle, data, size); - -			if (written != src->GetSize()) -				return false;  - -			// л -			if (m_BufferSize == BUFFER_MODE_LINE && m_BufferSize > size) -			{ -				if (memchr(data, '\n', size) != nullptr) -					Flush(); -			} - -			return true; -		} - -		bool File::Flush() -		{ -			if (!m_FileHandle || (m_Mode != FILE_MODE_WRITE && m_Mode != FILE_MODE_APPEND)) -				throw Exception("File is not opened for writing."); - -			return PHYSFS_flush(m_FileHandle) != 0; -		} - -		bool File::SetBuffer(BufferMode mode, size_t size) -		{ -			if (size < 0) -				return false; - -			// If the file isn't open, we'll make sure the buffer values are set in -			// File::open. -			if (!IsOpen()) -			{ -			 m_BufferMode = mode; -			 m_BufferSize = size; -				return true; -			} - -			int ret = 1; - -			switch (mode) -			{ -			case BUFFER_MODE_NONE: -			default: -				ret = PHYSFS_setBuffer(m_FileHandle, 0); -				size = 0; -				break; -			case BUFFER_MODE_LINE: -			case BUFFER_MODE_FULL: -				ret = PHYSFS_setBuffer(m_FileHandle, size); -				break; -			} - -			if (ret == 0) -				return false; - -		 m_BufferMode = mode; -		 m_BufferSize = size; - -			return true; -		} - -		File::BufferMode File::GetBuffer(ASURA_OUT size_t& size)  -		{ -			size = m_BufferSize;  -			return m_BufferMode;  -		} - -		const std::string& File::GetFileName() -		{ -			return m_FileName; -		} - -		const std::string& File::GetName() -		{ -			return m_Name; -		} - -		const std::string& File::GetExtension() -		{ -			return m_Extension; -		} - -		File::FileMode File::GetMode() -		{ -			return m_Mode; -		} - -	} -}
\ No newline at end of file diff --git a/source/modules/asura-utils/io/file.h b/source/modules/asura-utils/io/file.h deleted file mode 100644 index d11fa4f..0000000 --- a/source/modules/asura-utils/io/file.h +++ /dev/null @@ -1,146 +0,0 @@ -#ifndef _ASURA_ENGINE_FILE_H_ -#define _ASURA_ENGINE_FILE_H_ - -#include "physfs/physfs.h" - -#include "../Scripting/Portable.hpp" -#include "../Threads/Thread.h" - -#include "FileData.h" - -namespace AsuraEngine -{ -	namespace IO -	{ - -		/// -		/// ʽļָд㡢Сʹȡʱʹñ࣬ʹFilesystem.read()ֱӶȡļȫ -		/// ݣһFileData -		/// -		class File ASURA_FINAL -			: public AEScripting::Portable<File> -		{ -		public: - -			LUAX_DECL_FACTORY(File); - -			/// -			/// ļдģʽ -			/// -			enum FileMode -			{ -				FILE_MODE_CLOSED, -				FILE_MODE_READ, -				FILE_MODE_WRITE, -				FILE_MODE_APPEND, -			}; - -			/// -			/// ļдʱΪ -			/// -			enum BufferMode -			{ -				BUFFER_MODE_NONE, ///< ʹû壬дļ -				BUFFER_MODE_LINE, ///< л壬зߴﵽСʱдļ -				BUFFER_MODE_FULL, ///< ȫ壬ʱдļ -			}; - -			File(const std::string& filename); -			~File(); - -			bool Open(FileMode mode);  -			bool Close(); -			bool IsOpen(); -			FileMode GetMode(); -			size_t GetSize();  - -			/// -			/// ȡdata bufferض -			/// -			size_t Read(ASURA_OUT DataBuffer* dst, size_t length); -			size_t ReadAll(ASURA_OUT DataBuffer* dst); -			size_t ReadAsync(ASURA_OUT DataBuffer* dst); - -			/// -			/// Ƿļβ -			/// -			bool IsEOF(); - -			/// -			/// data bufferед룬Ƿɹ -			/// -			bool Write(ASURA_REF DataBuffer* src); - -			/// -			/// 첽дļдļtaskthreadĶС -			/// -			bool WriteAsync(ASURA_REF DataBuffer* src, AEThreading::Thread* thread); - -			/// -			/// ˻壬ǿջдļ -			/// -			bool Flush(); - -			/// -			/// صǰдλ -			/// -			size_t Tell(); - -			/// -			/// Ӧλ -			/// -			bool Seek(size_t pos); - -			/// -			/// ûСģʽ -			/// -			bool SetBuffer(BufferMode mode, size_t size); - -			/// -			/// ȡСģʽ -			/// -			BufferMode GetBuffer(ASURA_OUT size_t& size); - -			const std::string& GetFileName(); -			const std::string& GetName(); -			const std::string& GetExtension(); - -		private: - -			PHYSFS_File* m_FileHandle; ///< physfs ļ -			std::string  m_FileName;   ///< ļ -			std::string  m_Extension;  ///< չ -			std::string  m_Name;       ///< չļ -			FileMode     m_Mode;       ///< ļģʽ -			BufferMode   m_BufferMode;	///< д뻺ģʽ -			size_t       m_BufferSize;	///< д뻺С - -			LUAX_DECL_ENUM(FileMode); -			LUAX_DECL_ENUM(BufferMode); - -			LUAX_DECL_METHOD(_New); -			LUAX_DECL_METHOD(_Open); -			LUAX_DECL_METHOD(_Close); -			LUAX_DECL_METHOD(_IsOpen); -			LUAX_DECL_METHOD(_GetMode); -			LUAX_DECL_METHOD(_GetSize); -			LUAX_DECL_METHOD(_Read); -			LUAX_DECL_METHOD(_Write); -			LUAX_DECL_METHOD(_ReadAsync); -			LUAX_DECL_METHOD(_WriteAsync); -			LUAX_DECL_METHOD(_IsEOF); -			LUAX_DECL_METHOD(_Flush); -			LUAX_DECL_METHOD(_Tell); -			LUAX_DECL_METHOD(_Seek); -			LUAX_DECL_METHOD(_SetBuffer); -			LUAX_DECL_METHOD(_GetBuffer); -			LUAX_DECL_METHOD(_GetFileName); -			LUAX_DECL_METHOD(_GetExtension); -			LUAX_DECL_METHOD(_GetName); - -		}; - -	} -} - -#endif
\ No newline at end of file diff --git a/source/modules/asura-utils/io/renewable.h b/source/modules/asura-utils/io/renewable.h deleted file mode 100644 index 90867f2..0000000 --- a/source/modules/asura-utils/io/renewable.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef __ASURA_ENGINE_RENEWABLE_H__ -#define __ASURA_ENGINE_RENEWABLE_H__ - -#include "../scripting/portable.hpp" - -#include "DecodedData.h" - -namespace AsuraEngine -{ -	namespace IO -	{ - -		/// -		/// ¹ݽṹͼƬƵ֣ӽݿֱӹڱ༭ -		/// ¹handleֵı䲻߱ƻԣڲıhandleԴ -		/// -		ASURA_ABSTRACT class  Renewable -		{ -		public: -			 Renewable() {}; -			 virtual ~Renewable() {}; -		}; - -	} -} - -namespace AEIO = AsuraEngine::IO; - -#endif
\ No newline at end of file diff --git a/source/modules/asura-utils/manager.hpp b/source/modules/asura-utils/manager.hpp deleted file mode 100644 index c6817b1..0000000 --- a/source/modules/asura-utils/manager.hpp +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef _ASURA_ENGINE_MANAGER_H_ -#define _ASURA_ENGINE_MANAGER_H_ - -namespace AsuraEngine -{ - -	class Manager -	{ - -	}; - -} - -#endif
\ No newline at end of file diff --git a/source/modules/asura-utils/math/curve.cpp b/source/modules/asura-utils/math/curve.cpp deleted file mode 100644 index e69de29..0000000 --- a/source/modules/asura-utils/math/curve.cpp +++ /dev/null diff --git a/source/modules/asura-utils/math/curve.h b/source/modules/asura-utils/math/curve.h deleted file mode 100644 index e69de29..0000000 --- a/source/modules/asura-utils/math/curve.h +++ /dev/null diff --git a/source/modules/asura-utils/math/functions.cpp b/source/modules/asura-utils/math/functions.cpp deleted file mode 100644 index e69de29..0000000 --- a/source/modules/asura-utils/math/functions.cpp +++ /dev/null diff --git a/source/modules/asura-utils/math/functions.h b/source/modules/asura-utils/math/functions.h deleted file mode 100644 index e69de29..0000000 --- a/source/modules/asura-utils/math/functions.h +++ /dev/null diff --git a/source/modules/asura-utils/math/matrix44.cpp b/source/modules/asura-utils/math/matrix44.cpp deleted file mode 100644 index 9ecf448..0000000 --- a/source/modules/asura-utils/math/matrix44.cpp +++ /dev/null @@ -1,217 +0,0 @@ -#include "Matrix44.h" - -#include <cstring> // memcpy -#include <cmath> - -namespace AsuraEngine -{ -	namespace Math -	{ - -		const Matrix44 Matrix44::Identity; - -		// | e0 e4 e8  e12 | -		// | e1 e5 e9  e13 | -		// | e2 e6 e10 e14 | -		// | e3 e7 e11 e15 | - -		Matrix44::Matrix44() -		{ -			SetIdentity(); -		} - -		Matrix44::Matrix44(const Matrix44& m) -		{ -			memcpy(&e, &m.e, 16 * sizeof(float)); -		} - -		Matrix44::~Matrix44() -		{ -		} - -		void Matrix44::operator = (const Matrix44& m) -		{ -			memcpy(&e, &m.e, 16 * sizeof(float)); -		} - -		void Matrix44::SetOrtho(float l, float r, float b, float t, float n, float f) -		{ -			SetIdentity(); -			float w = r - l; -			float h = t - b; -			float z = f - n; -			e[0] = 2 / w; -			e[5] = 2 / h; -			e[10] = -2 / z; -			e[12] = -(r + l) / w; -			e[13] = -(t + b) / h; -			e[14] = -(f + n) / z; -			e[15] = 1; -		} - -		//                 | e0 e4 e8  e12 | -		//                 | e1 e5 e9  e13 | -		//                 | e2 e6 e10 e14 | -		//                 | e3 e7 e11 e15 | -		// | e0 e4 e8  e12 | -		// | e1 e5 e9  e13 | -		// | e2 e6 e10 e14 | -		// | e3 e7 e11 e15 | - -		Matrix44 Matrix44::operator * (const Matrix44 & m) const -		{ -			Matrix44 t; - -			t.e[0] = (e[0] * m.e[0]) + (e[4] * m.e[1]) + (e[8] * m.e[2]) + (e[12] * m.e[3]); -			t.e[4] = (e[0] * m.e[4]) + (e[4] * m.e[5]) + (e[8] * m.e[6]) + (e[12] * m.e[7]); -			t.e[8] = (e[0] * m.e[8]) + (e[4] * m.e[9]) + (e[8] * m.e[10]) + (e[12] * m.e[11]); -			t.e[12] = (e[0] * m.e[12]) + (e[4] * m.e[13]) + (e[8] * m.e[14]) + (e[12] * m.e[15]); - -			t.e[1] = (e[1] * m.e[0]) + (e[5] * m.e[1]) + (e[9] * m.e[2]) + (e[13] * m.e[3]); -			t.e[5] = (e[1] * m.e[4]) + (e[5] * m.e[5]) + (e[9] * m.e[6]) + (e[13] * m.e[7]); -			t.e[9] = (e[1] * m.e[8]) + (e[5] * m.e[9]) + (e[9] * m.e[10]) + (e[13] * m.e[11]); -			t.e[13] = (e[1] * m.e[12]) + (e[5] * m.e[13]) + (e[9] * m.e[14]) + (e[13] * m.e[15]); - -			t.e[2] = (e[2] * m.e[0]) + (e[6] * m.e[1]) + (e[10] * m.e[2]) + (e[14] * m.e[3]); -			t.e[6] = (e[2] * m.e[4]) + (e[6] * m.e[5]) + (e[10] * m.e[6]) + (e[14] * m.e[7]); -			t.e[10] = (e[2] * m.e[8]) + (e[6] * m.e[9]) + (e[10] * m.e[10]) + (e[14] * m.e[11]); -			t.e[14] = (e[2] * m.e[12]) + (e[6] * m.e[13]) + (e[10] * m.e[14]) + (e[14] * m.e[15]); - -			t.e[3] = (e[3] * m.e[0]) + (e[7] * m.e[1]) + (e[11] * m.e[2]) + (e[15] * m.e[3]); -			t.e[7] = (e[3] * m.e[4]) + (e[7] * m.e[5]) + (e[11] * m.e[6]) + (e[15] * m.e[7]); -			t.e[11] = (e[3] * m.e[8]) + (e[7] * m.e[9]) + (e[11] * m.e[10]) + (e[15] * m.e[11]); -			t.e[15] = (e[3] * m.e[12]) + (e[7] * m.e[13]) + (e[11] * m.e[14]) + (e[15] * m.e[15]); - -			return t; -		} - -		void Matrix44::operator *= (const Matrix44 & m) -		{ -			Matrix44 t = (*this) * m; -			memcpy((void*)this->e, (void*)t.e, sizeof(float) * 16); -		} - -		const float * Matrix44::GetElements() const -		{ -			return e; -		} - -		void Matrix44::SetIdentity() -		{ -			memset(e, 0, sizeof(float) * 16); -			e[0] = e[5] = e[10] = e[15] = 1; -		} - -		void Matrix44::SetTranslation(float x, float y) -		{ -			SetIdentity(); -			e[12] = x; -			e[13] = y; -		} - -		void Matrix44::SetRotation(float rad) -		{ -			SetIdentity(); -			float c = cos(rad), s = sin(rad); -			e[0] = c; e[4] = -s; -			e[1] = s; e[5] = c; -		} - -		void Matrix44::SetScale(float sx, float sy) -		{ -			SetIdentity(); -			e[0] = sx; -			e[5] = sy; -		} - -		void Matrix44::SetShear(float kx, float ky) -		{ -			SetIdentity(); -			e[1] = ky; -			e[4] = kx; -		} - -		void Matrix44::SetTransformation(float x, float y, float angle, float sx, float sy, float ox, float oy) -		{ -			memset(e, 0, sizeof(float) * 16); // zero out matrix -			float c = cos(angle), s = sin(angle); -			// matrix multiplication carried out on paper: -			// |1     x| |c -s    | |sx       | |1     -ox| -			// |  1   y| |s  c    | |   sy    | |  1   -oy| -			// |    1  | |     1  | |      1  | |    1    | -			// |      1| |       1| |        1| |       1 | -			//   move      rotate      scale      origin -			e[10] = e[15] = 1.0f; -			e[0] = c * sx; // = a -			e[1] = s * sx; // = b -			e[4] = -s * sy; // = c -			e[5] = c * sy; // = d -			e[12] = x - ox * e[0] - oy * e[4]; -			e[13] = y - ox * e[1] - oy * e[5]; -		} - -		void Matrix44::Translate(float x, float y) -		{ -			Matrix44 t; -			t.SetTranslation(x, y); -			this->operator *=(t); -		} - -		void Matrix44::Rotate(float rad) -		{ -			Matrix44 t; -			t.SetRotation(rad); -			this->operator *=(t); -		} - -		void Matrix44::Scale(float sx, float sy) -		{ -			Matrix44 t; -			t.SetScale(sx, sy); -			this->operator *=(t); -		} - -		void Matrix44::Shear(float kx, float ky) -		{ -			Matrix44 t; -			t.SetShear(kx, ky); -			this->operator *=(t); -		} - -		void Matrix44::Transform(float x, float y, float angle, float sx, float sy, float ox, float oy) -		{ -			Matrix44 t;  -			t.SetTransformation(x, y, angle, sx, sy, ox, oy); -			this->operator *=(t); -		} - -		void Matrix44::Ortho(float left, float right, float bottom, float top, float near, float far) -		{ -			Matrix44 t; -			t.SetOrtho(left, right, bottom, top, near, far); -			this->operator *=(t); -		} - -		//                 | x | -		//                 | y | -		//                 | 0 | -		//                 | 1 | -		// | e0 e4 e8  e12 | -		// | e1 e5 e9  e13 | -		// | e2 e6 e10 e14 | -		// | e3 e7 e11 e15 | - -		//void Matrix44::transform(Graphics::Vertex* dst, const Graphics::Vertex* src, int size) const -		//{ -		//	for (int i = 0; i<size; ++i) -		//	{ -		//		// Store in temp variables in case src = dst -		//		float x = (e[0] * src[i].xy.x()) + (e[4] * src[i].xy.y()) + (0) + (e[12]); -		//		float y = (e[1] * src[i].xy.x()) + (e[5] * src[i].xy.y()) + (0) + (e[13]); - -		//		dst[i].xy.Set(x, y); -		//	} -		//} - -	} // namespace Math -} // namespace JinEngine
\ No newline at end of file diff --git a/source/modules/asura-utils/math/matrix44.h b/source/modules/asura-utils/math/matrix44.h deleted file mode 100644 index 503242f..0000000 --- a/source/modules/asura-utils/math/matrix44.h +++ /dev/null @@ -1,96 +0,0 @@ -#ifndef _ASURA_MATRIX_H_ -#define _ASURA_MATRIX_H_ - -#include <asura-utils/Classes.h> - -#include "../Scripting/Portable.hpp" - -namespace_begin(AsuraEngine) -namespace_begin(Math) - -/// ҪתõOpenGLglm::mat4 -/// https://blog.csdn.net/candycat1992/article/details/8830894 -class Matrix44 -{ -public: - -	static const Matrix44 Identity; - -	Matrix44(); - -	Matrix44(const Matrix44& m); - -	~Matrix44(); - -	void operator = (const Matrix44& m); - -	void SetOrtho(float _left, float _right, float _bottom, float _top, float _near, float _far); - -	Matrix44 operator * (const Matrix44 & m) const; - -	void operator *= (const Matrix44 & m); - -	const float* GetElements() const; - -	void SetIdentity(); - -	void SetTranslation(float x, float y); - -	void SetRotation(float r); - -	void SetScale(float sx, float sy); - -	void SetShear(float kx, float ky); - -	void SetTransformation(float x, float y, float angle, float sx, float sy, float ox, float oy); - -	void Translate(float x, float y); - -	void Rotate(float r); - -	void Scale(float sx, float sy); - -	void Transform(float x, float y, float angle, float sx, float sy, float ox, float oy); - -	///  -	/// Multiplies this Matrix44 with a shear transformation. -	/// @param kx Shear along the x-axis. -	/// @param ky Shear along the y-axis. -	///  -	void Shear(float kx, float ky); - -	void Ortho(float left, float right, float bottom, float top, float near, float far); - -	/////  -	///// Transforms an array of vertices by this Matrix44. The sources and -	///// destination arrays may be the same. -	///// -	///// @param dst Storage for the transformed vertices. -	///// @param src The source vertices. -	///// @param size The number of vertices. -	/////  -	//void transform(Graphics::Vertex* dst, const Graphics::Vertex * src, int size) const; - -	/// -	/// ʽ -	/// -	float Calculate(); - -private: - -	///  -	/// | e0 e4 e8  e12 | -	/// | e1 e5 e9  e13 | -	/// | e2 e6 e10 e14 | -	/// | e3 e7 e11 e15 | -	/// -	float e[16]; - -}; - -namespace_end -namespace_end - -namespace AEMath = AsuraEngine::Math; - -#endif
\ No newline at end of file diff --git a/source/modules/asura-utils/math/quaternion.cpp b/source/modules/asura-utils/math/quaternion.cpp deleted file mode 100644 index e69de29..0000000 --- a/source/modules/asura-utils/math/quaternion.cpp +++ /dev/null diff --git a/source/modules/asura-utils/math/quaternion.h b/source/modules/asura-utils/math/quaternion.h deleted file mode 100644 index e69de29..0000000 --- a/source/modules/asura-utils/math/quaternion.h +++ /dev/null diff --git a/source/modules/asura-utils/math/rect.hpp b/source/modules/asura-utils/math/rect.hpp deleted file mode 100644 index 45bf1ba..0000000 --- a/source/modules/asura-utils/math/rect.hpp +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef _ASURA_ENGINE_RECT_H_ -#define _ASURA_ENGINE_RECT_H_ - -namespace AsuraEngine -{ -	namespace Math -	{ -		 -		template<typename T>  -		struct Rect -		{ -		public: -			Rect(); -			Rect(T x, T y, T w, T h); -			~Rect() {}; - -			/// -			/// x,yǷrectڡ -			/// -			bool Contain(T x, T y); - -			/// -			/// Ƿཻཻľ -			/// -			bool Intersect(const Rect& src, Rect& intersection); -			 -			/// -			///  Ƿཻཻľ -			/// -			static bool Intersect(const Rect<T>& src1, const Rect<T>& src2, Rect<T>& intersection); - -			void Set(T x, T y, T w, T h); - -			T x, y, w, h; -		}; -		 -#include "Rect.inc" - -		// Define the most common types -		typedef Rect<int>          Recti; -		typedef Rect<unsigned int> Rectu; -		typedef Rect<float>        Rectf; -		typedef Rect<long>         Reftl; - -	} -} - -namespace AEMath = AsuraEngine::Math; - -#endif
\ No newline at end of file diff --git a/source/modules/asura-utils/math/transform.cpp b/source/modules/asura-utils/math/transform.cpp deleted file mode 100644 index e69de29..0000000 --- a/source/modules/asura-utils/math/transform.cpp +++ /dev/null diff --git a/source/modules/asura-utils/math/transform.h b/source/modules/asura-utils/math/transform.h deleted file mode 100644 index 23d0709..0000000 --- a/source/modules/asura-utils/math/transform.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef _ASURA_ENGINE_TRANSFORM_H_ -#define _ASURA_ENGINE_TRANSFORM_H_ - -#include "../scripting/Portable.hpp" - -namespace AsuraEngine -{ -	namespace Math -	{ - -		class Transform -		{ -		public: - -			void Set(float x, float y, float sx, float sy, float ox, float oy, float r); - -			void LoadIdentity(); - -			void Move(float dx = 0, float dy = 0); -			void Rotate(float r); -			void Scale(float sx, float sy); - -			float m[16]; //4x4 matrix - -		}; - -	} -} - -#endif
\ No newline at end of file diff --git a/source/modules/asura-utils/math/vector2.hpp b/source/modules/asura-utils/math/vector2.hpp deleted file mode 100644 index 326a57e..0000000 --- a/source/modules/asura-utils/math/vector2.hpp +++ /dev/null @@ -1,72 +0,0 @@ -#ifndef _ASURA_ENGINE_VECTOR2_H__ -#define _ASURA_ENGINE_VECTOR2_H__ - -#include <asura-utils/Classes.h> - -namespace_begin(AsuraEngine) -namespace_begin(Math) - -template <typename T> -class Vector2 -{ -public: -	Vector2(); -	Vector2(T X, T Y); - -	template <typename U> -	explicit Vector2(const Vector2<U>& vector); - -	void Set(T X, T Y); - -	T x; ///< X coordinate of the vector -	T y; ///< Y coordinate of the vector -}; - -template <typename T> -Vector2<T> operator -(const Vector2<T>& right); - -template <typename T> -Vector2<T>& operator +=(Vector2<T>& left, const Vector2<T>& right); - -template <typename T> -Vector2<T>& operator -=(Vector2<T>& left, const Vector2<T>& right); - -template <typename T> -Vector2<T> operator +(const Vector2<T>& left, const Vector2<T>& right); - -template <typename T> -Vector2<T> operator -(const Vector2<T>& left, const Vector2<T>& right); - -template <typename T> -Vector2<T> operator *(const Vector2<T>& left, T right); - -template <typename T> -Vector2<T> operator *(T left, const Vector2<T>& right); - -template <typename T> -Vector2<T>& operator *=(Vector2<T>& left, T right); - -template <typename T> -Vector2<T> operator /(const Vector2<T>& left, T right); - -template <typename T> -Vector2<T>& operator /=(Vector2<T>& left, T right); - -template <typename T> -bool operator ==(const Vector2<T>& left, const Vector2<T>& right); - -template <typename T> -bool operator !=(const Vector2<T>& left, const Vector2<T>& right); - -#include "Vector2.inc" - -typedef Vector2<int>          Vector2i; -typedef Vector2<unsigned int> Vector2u; -typedef Vector2<float>        Vector2f; - -namespace_end -namespace_end - -namespace AEMath = AsuraEngine::Math; - -#endif
\ No newline at end of file diff --git a/source/modules/asura-utils/math/vector3.hpp b/source/modules/asura-utils/math/vector3.hpp deleted file mode 100644 index c526ace..0000000 --- a/source/modules/asura-utils/math/vector3.hpp +++ /dev/null @@ -1,235 +0,0 @@ -#ifndef _ASURA_ENGINE_VECTOR3_H__ -#define _ASURA_ENGINE_VECTOR3_H__ - -namespace AsuraEngine -{ -	namespace Math -	{ -		template <typename T> -		class Vector3 -		{ -		public: - -			//////////////////////////////////////////////////////////// -			/// \brief Default constructor -			/// -			/// Creates a Vector3(0, 0, 0). -			/// -			//////////////////////////////////////////////////////////// -			Vector3(); - -			//////////////////////////////////////////////////////////// -			/// \brief Construct the vector from its coordinates -			/// -			/// \param X X coordinate -			/// \param Y Y coordinate -			/// \param Z Z coordinate -			/// -			//////////////////////////////////////////////////////////// -			Vector3(T X, T Y, T Z); - -			//////////////////////////////////////////////////////////// -			/// \brief Construct the vector from another type of vector -			/// -			/// This constructor doesn't replace the copy constructor, -			/// it's called only when U != T. -			/// A call to this constructor will fail to compile if U -			/// is not convertible to T. -			/// -			/// \param vector Vector to convert -			/// -			//////////////////////////////////////////////////////////// -			template <typename U> -			explicit Vector3(const Vector3<U>& vector); - -			//////////////////////////////////////////////////////////// -			// Member data -			//////////////////////////////////////////////////////////// -			T x; ///< X coordinate of the vector -			T y; ///< Y coordinate of the vector -			T z; ///< Z coordinate of the vector -		}; - -		//////////////////////////////////////////////////////////// -		/// \relates Vector3 -		/// \brief Overload of unary operator - -		/// -		/// \param left Vector to negate -		/// -		/// \return Memberwise opposite of the vector -		/// -		//////////////////////////////////////////////////////////// -		template <typename T> -		Vector3<T> operator -(const Vector3<T>& left); - -		//////////////////////////////////////////////////////////// -		/// \relates Vector3 -		/// \brief Overload of binary operator += -		/// -		/// This operator performs a memberwise addition of both vectors, -		/// and assigns the result to \a left. -		/// -		/// \param left  Left operand (a vector) -		/// \param right Right operand (a vector) -		/// -		/// \return Reference to \a left -		/// -		//////////////////////////////////////////////////////////// -		template <typename T> -		Vector3<T>& operator +=(Vector3<T>& left, const Vector3<T>& right); - -		//////////////////////////////////////////////////////////// -		/// \relates Vector3 -		/// \brief Overload of binary operator -= -		/// -		/// This operator performs a memberwise subtraction of both vectors, -		/// and assigns the result to \a left. -		/// -		/// \param left  Left operand (a vector) -		/// \param right Right operand (a vector) -		/// -		/// \return Reference to \a left -		/// -		//////////////////////////////////////////////////////////// -		template <typename T> -		Vector3<T>& operator -=(Vector3<T>& left, const Vector3<T>& right); - -		//////////////////////////////////////////////////////////// -		/// \relates Vector3 -		/// \brief Overload of binary operator + -		/// -		/// \param left  Left operand (a vector) -		/// \param right Right operand (a vector) -		/// -		/// \return Memberwise addition of both vectors -		/// -		//////////////////////////////////////////////////////////// -		template <typename T> -		Vector3<T> operator +(const Vector3<T>& left, const Vector3<T>& right); - -		//////////////////////////////////////////////////////////// -		/// \relates Vector3 -		/// \brief Overload of binary operator - -		/// -		/// \param left  Left operand (a vector) -		/// \param right Right operand (a vector) -		/// -		/// \return Memberwise subtraction of both vectors -		/// -		//////////////////////////////////////////////////////////// -		template <typename T> -		Vector3<T> operator -(const Vector3<T>& left, const Vector3<T>& right); - -		//////////////////////////////////////////////////////////// -		/// \relates Vector3 -		/// \brief Overload of binary operator * -		/// -		/// \param left  Left operand (a vector) -		/// \param right Right operand (a scalar value) -		/// -		/// \return Memberwise multiplication by \a right -		/// -		//////////////////////////////////////////////////////////// -		template <typename T> -		Vector3<T> operator *(const Vector3<T>& left, T right); - -		//////////////////////////////////////////////////////////// -		/// \relates Vector3 -		/// \brief Overload of binary operator * -		/// -		/// \param left  Left operand (a scalar value) -		/// \param right Right operand (a vector) -		/// -		/// \return Memberwise multiplication by \a left -		/// -		//////////////////////////////////////////////////////////// -		template <typename T> -		Vector3<T> operator *(T left, const Vector3<T>& right); - -		//////////////////////////////////////////////////////////// -		/// \relates Vector3 -		/// \brief Overload of binary operator *= -		/// -		/// This operator performs a memberwise multiplication by \a right, -		/// and assigns the result to \a left. -		/// -		/// \param left  Left operand (a vector) -		/// \param right Right operand (a scalar value) -		/// -		/// \return Reference to \a left -		/// -		//////////////////////////////////////////////////////////// -		template <typename T> -		Vector3<T>& operator *=(Vector3<T>& left, T right); - -		//////////////////////////////////////////////////////////// -		/// \relates Vector3 -		/// \brief Overload of binary operator / -		/// -		/// \param left  Left operand (a vector) -		/// \param right Right operand (a scalar value) -		/// -		/// \return Memberwise division by \a right -		/// -		//////////////////////////////////////////////////////////// -		template <typename T> -		Vector3<T> operator /(const Vector3<T>& left, T right); - -		//////////////////////////////////////////////////////////// -		/// \relates Vector3 -		/// \brief Overload of binary operator /= -		/// -		/// This operator performs a memberwise division by \a right, -		/// and assigns the result to \a left. -		/// -		/// \param left  Left operand (a vector) -		/// \param right Right operand (a scalar value) -		/// -		/// \return Reference to \a left -		/// -		//////////////////////////////////////////////////////////// -		template <typename T> -		Vector3<T>& operator /=(Vector3<T>& left, T right); - -		//////////////////////////////////////////////////////////// -		/// \relates Vector3 -		/// \brief Overload of binary operator == -		/// -		/// This operator compares strict equality between two vectors. -		/// -		/// \param left  Left operand (a vector) -		/// \param right Right operand (a vector) -		/// -		/// \return True if \a left is equal to \a right -		/// -		//////////////////////////////////////////////////////////// -		template <typename T> -		bool operator ==(const Vector3<T>& left, const Vector3<T>& right); - -		//////////////////////////////////////////////////////////// -		/// \relates Vector3 -		/// \brief Overload of binary operator != -		/// -		/// This operator compares strict difference between two vectors. -		/// -		/// \param left  Left operand (a vector) -		/// \param right Right operand (a vector) -		/// -		/// \return True if \a left is not equal to \a right -		/// -		//////////////////////////////////////////////////////////// -		template <typename T> -		bool operator !=(const Vector3<T>& left, const Vector3<T>& right); - -#include "Vector3.inc" - -		// Define the most common types -		typedef Vector3<int>   Vector3i; -		typedef Vector3<float> Vector3f; - -	} -} - -namespace AEMath = AsuraEngine::Math; - -#endif
\ No newline at end of file diff --git a/source/modules/asura-utils/math/vector4.h b/source/modules/asura-utils/math/vector4.h deleted file mode 100644 index a5bf549..0000000 --- a/source/modules/asura-utils/math/vector4.h +++ /dev/null @@ -1,234 +0,0 @@ -#ifndef _ASURA_ENGINE_VECTOR4_H__ -#define _ASURA_ENGINE_VECTOR4_H__ - -namespace AsuraEngine -{ -	namespace Math -	{ -		template <typename T> -		class Vector4 -		{ -		public: - -			//////////////////////////////////////////////////////////// -			/// \brief Default constructor -			/// -			/// Creates a Vector4(0, 0, 0). -			/// -			//////////////////////////////////////////////////////////// -			Vector4(); - -			//////////////////////////////////////////////////////////// -			/// \brief Construct the vector from its coordinates -			/// -			/// \param X X coordinate -			/// \param Y Y coordinate -			/// \param Z Z coordinate -			/// -			//////////////////////////////////////////////////////////// -			Vector4(T X, T Y, T Z, T W); - -			//////////////////////////////////////////////////////////// -			/// \brief Construct the vector from another type of vector -			/// -			/// This constructor doesn't replace the copy constructor, -			/// it's called only when U != T. -			/// A call to this constructor will fail to compile if U -			/// is not convertible to T. -			/// -			/// \param vector Vector to convert -			/// -			//////////////////////////////////////////////////////////// -			template <typename U> -			explicit Vector4(const Vector4<U>& vector); - -			//////////////////////////////////////////////////////////// -			// Member data -			//////////////////////////////////////////////////////////// -			T x; ///< X coordinate of the vector -			T y; ///< Y coordinate of the vector -			T z; ///< Z coordinate of the vector -			T w; ///< W coordinate of the vector -		}; - -		//////////////////////////////////////////////////////////// -		/// \relates Vector4 -		/// \brief Overload of unary operator - -		/// -		/// \param left Vector to negate -		/// -		/// \return Memberwise opposite of the vector -		/// -		//////////////////////////////////////////////////////////// -		template <typename T> -		Vector4<T> operator -(const Vector4<T>& left); - -		//////////////////////////////////////////////////////////// -		/// \relates Vector4 -		/// \brief Overload of binary operator += -		/// -		/// This operator performs a memberwise addition of both vectors, -		/// and assigns the result to \a left. -		/// -		/// \param left  Left operand (a vector) -		/// \param right Right operand (a vector) -		/// -		/// \return Reference to \a left -		/// -		//////////////////////////////////////////////////////////// -		template <typename T> -		Vector4<T>& operator +=(Vector4<T>& left, const Vector4<T>& right); - -		//////////////////////////////////////////////////////////// -		/// \relates Vector4 -		/// \brief Overload of binary operator -= -		/// -		/// This operator performs a memberwise subtraction of both vectors, -		/// and assigns the result to \a left. -		/// -		/// \param left  Left operand (a vector) -		/// \param right Right operand (a vector) -		/// -		/// \return Reference to \a left -		/// -		//////////////////////////////////////////////////////////// -		template <typename T> -		Vector4<T>& operator -=(Vector4<T>& left, const Vector4<T>& right); - -		//////////////////////////////////////////////////////////// -		/// \relates Vector4 -		/// \brief Overload of binary operator + -		/// -		/// \param left  Left operand (a vector) -		/// \param right Right operand (a vector) -		/// -		/// \return Memberwise addition of both vectors -		/// -		//////////////////////////////////////////////////////////// -		template <typename T> -		Vector4<T> operator +(const Vector4<T>& left, const Vector4<T>& right); - -		//////////////////////////////////////////////////////////// -		/// \relates Vector4 -		/// \brief Overload of binary operator - -		/// -		/// \param left  Left operand (a vector) -		/// \param right Right operand (a vector) -		/// -		/// \return Memberwise subtraction of both vectors -		/// -		//////////////////////////////////////////////////////////// -		template <typename T> -		Vector4<T> operator -(const Vector4<T>& left, const Vector4<T>& right); - -		//////////////////////////////////////////////////////////// -		/// \relates Vector4 -		/// \brief Overload of binary operator * -		/// -		/// \param left  Left operand (a vector) -		/// \param right Right operand (a scalar value) -		/// -		/// \return Memberwise multiplication by \a right -		/// -		//////////////////////////////////////////////////////////// -		template <typename T> -		Vector4<T> operator *(const Vector4<T>& left, T right); - -		//////////////////////////////////////////////////////////// -		/// \relates Vector4 -		/// \brief Overload of binary operator * -		/// -		/// \param left  Left operand (a scalar value) -		/// \param right Right operand (a vector) -		/// -		/// \return Memberwise multiplication by \a left -		/// -		//////////////////////////////////////////////////////////// -		template <typename T> -		Vector4<T> operator *(T left, const Vector4<T>& right); - -		//////////////////////////////////////////////////////////// -		/// \relates Vector4 -		/// \brief Overload of binary operator *= -		/// -		/// This operator performs a memberwise multiplication by \a right, -		/// and assigns the result to \a left. -		/// -		/// \param left  Left operand (a vector) -		/// \param right Right operand (a scalar value) -		/// -		/// \return Reference to \a left -		/// -		//////////////////////////////////////////////////////////// -		template <typename T> -		Vector4<T>& operator *=(Vector4<T>& left, T right); - -		//////////////////////////////////////////////////////////// -		/// \relates Vector4 -		/// \brief Overload of binary operator / -		/// -		/// \param left  Left operand (a vector) -		/// \param right Right operand (a scalar value) -		/// -		/// \return Memberwise division by \a right -		/// -		//////////////////////////////////////////////////////////// -		template <typename T> -		Vector4<T> operator /(const Vector4<T>& left, T right); - -		//////////////////////////////////////////////////////////// -		/// \relates Vector4 -		/// \brief Overload of binary operator /= -		/// -		/// This operator performs a memberwise division by \a right, -		/// and assigns the result to \a left. -		/// -		/// \param left  Left operand (a vector) -		/// \param right Right operand (a scalar value) -		/// -		/// \return Reference to \a left -		/// -		//////////////////////////////////////////////////////////// -		template <typename T> -		Vector4<T>& operator /=(Vector4<T>& left, T right); - -		//////////////////////////////////////////////////////////// -		/// \relates Vector4 -		/// \brief Overload of binary operator == -		/// -		/// This operator compares strict equality between two vectors. -		/// -		/// \param left  Left operand (a vector) -		/// \param right Right operand (a vector) -		/// -		/// \return True if \a left is equal to \a right -		/// -		//////////////////////////////////////////////////////////// -		template <typename T> -		bool operator ==(const Vector4<T>& left, const Vector4<T>& right); - -		//////////////////////////////////////////////////////////// -		/// \relates Vector4 -		/// \brief Overload of binary operator != -		/// -		/// This operator compares strict difference between two vectors. -		/// -		/// \param left  Left operand (a vector) -		/// \param right Right operand (a vector) -		/// -		/// \return True if \a left is not equal to \a right -		/// -		//////////////////////////////////////////////////////////// -		template <typename T> -		bool operator !=(const Vector4<T>& left, const Vector4<T>& right); - -#include "Vector4.inc" - -		// Define the most common types -		typedef Vector4<int>   Vector4i; -		typedef Vector4<float> Vector4f; - -	} -} - -#endif
\ No newline at end of file diff --git a/source/modules/asura-utils/module.h b/source/modules/asura-utils/module.h deleted file mode 100644 index 2cc91d6..0000000 --- a/source/modules/asura-utils/module.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef _ASURA_MODULE_H_ -#define _ASURA_MODULE_H_ - -#include "Type.h" -#include "Scripting/Portable.hpp" - -namespace AsuraEngine -{ - -	/// -	/// Asura libs Ҫ̳д࣬Կעᡣģа˳Щģ飬Ȼ˳InitializeFinalizeʼ -	/// رЩģ顣 -	///  -	ASURA_ABSTRACT class Module -	{ -	public: - -		/// -		/// ʼģ顣 -		/// -		virtual void Initialize(Luax::LuaxState& state) = 0; - -		/// -		/// رģ顣 -		/// -		virtual void Finalize(Luax::LuaxState& state) = 0; - -	}; - -} - -#endif
\ No newline at end of file diff --git a/source/modules/asura-utils/scripting/portable.hpp b/source/modules/asura-utils/scripting/portable.hpp deleted file mode 100644 index 1eee123..0000000 --- a/source/modules/asura-utils/scripting/portable.hpp +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef _ASURA_ENGINE_PORTABLE_H_ -#define _ASURA_ENGINE_PORTABLE_H_ - -extern "C" { -#include <lua51/lua.h> -#include <lua51/lualib.h> -#include <lua51/lauxlib.h> -} - -#include <luax/luax.h> - -#include "../Type.h" -#include "../Classes.h" - -namespace_begin(AsuraEngine) -namespace_begin(Scripting) - - -/// ҪΪ࣬userdatamember ref̳д࣬ע̳С -using Object = Luax::LuaxObject; - -/// ҪעluanativeҪ̳дģ塣BASEָ࣬ĬLuaxObjectָLuaxObjectࡢ -template<typename TYPE, typename BASE = Luax::LuaxObject> -using Portable = Luax::LuaxNativeClass<TYPE, BASE>; - -namespace_end -namespace_end - -namespace AEScripting = AsuraEngine::Scripting; - -#endif
\ No newline at end of file diff --git a/source/modules/asura-utils/singleton.hpp b/source/modules/asura-utils/singleton.hpp deleted file mode 100644 index 9bb7336..0000000 --- a/source/modules/asura-utils/singleton.hpp +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef _ASURA_SINGLETON_H_ -#define _ASURA_SINGLETON_H_ - -#include "UtilsConfig.h" - -namespace AsuraEngine -{ - -	/// -	/// ̳Singletonڵһʵʱʵ֮ٴʵᱨ -	///  -	template<class T> -	class Singleton -	{ -	public: - -		static T* Get() -		{ -			// ֮ǰûдһ -			if (!instance) instance = new T; -			// ʵ -			return instance; -		} - -		static void Destroy() -		{ -			delete instance; -			instance = nullptr; -		} - -	protected: - -		Singleton() -		{ -			// instanceζִһʵǴġ -			ASSERT(!instance); -			// ʵΪʵ -			instance = static_cast<T*>(this); -		}; - -		virtual ~Singleton() {}; - -		static T* instance; - -	private: - -		Singleton(const Singleton& singleton); - -		Singleton& operator = (const Singleton& singleton); - -	}; - -	// ʵʼΪ -	template<class T> -	T* Singleton<T>::instance = nullptr; - -} - -#endif // _ASURA_SINGLETON_H_
\ No newline at end of file diff --git a/source/modules/asura-utils/stringmap.cpp b/source/modules/asura-utils/stringmap.cpp deleted file mode 100644 index e69de29..0000000 --- a/source/modules/asura-utils/stringmap.cpp +++ /dev/null diff --git a/source/modules/asura-utils/stringmap.hpp b/source/modules/asura-utils/stringmap.hpp deleted file mode 100644 index 15d28ee..0000000 --- a/source/modules/asura-utils/stringmap.hpp +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef _ASURA_ENGINE_STRINGMAP_H_ -#define _ASURA_ENGINE_STRINGMAP_H_ - -#include <string> - -namespace AsuraEngine -{ - -	/// -	/// һ˫һһӦӳ䣬shader uniformsstatemathine state parameterID -	/// -	template<typename key_type>  -	class StringMap -	{ -	public: - -		bool ContainsKey(const key_type& key); - -		bool ContainsString(const std::string& str); - -		std::string GetStringByKey(const key_type& key); - -		key_type GetKeyByString(const std::string& str); - -	}; - -} - -#endif
\ No newline at end of file diff --git a/source/modules/asura-utils/type.h b/source/modules/asura-utils/type.h deleted file mode 100644 index 5100fa3..0000000 --- a/source/modules/asura-utils/type.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef _ASURA_UTILS_TYPE_H_ -#define _ASURA_UTILS_TYPE_H_ - -#include <assert.h> -#include <cstdlib> -#include <stdint.h> - -#include "asura-base/Configure.h" - -namespace AsuraEngine -{ - -	//--------------------------------------------------------------------------------// - -	typedef int8_t   int8; -	typedef uint8_t  uint8; -	//typedef uint8	   byte; -	typedef char	   byte; -	typedef int16_t  int16; -	typedef uint16_t uint16; -	typedef int32_t  int32; -	typedef uint32_t uint32; -	typedef int64_t  int64; -	typedef uint64_t uint64; - -	typedef uint32_t uint; -	typedef int32_t  sint; - -	typedef std::size_t size_t; - -	typedef const char cc8; - -#define Assert assert - -} // namespace AsuraEngine - -#endif // _ASURA_CONFIG_H_
\ No newline at end of file diff --git a/source/modules/asura-utils/utils.h b/source/modules/asura-utils/utils.h deleted file mode 100644 index dfcd2a6..0000000 --- a/source/modules/asura-utils/utils.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef _ASURA_UTILS_H_ -#define _ASURA_UTILS_H_ - -#include "UtilsModule.h" - -#endif
\ No newline at end of file  | 
