From 7d1533f18e1d5d572e6e440377ffbe2bfe8a1d27 Mon Sep 17 00:00:00 2001 From: Danilo Date: Fri, 8 Nov 2024 16:22:26 -0300 Subject: [PATCH] =?UTF-8?q?Corre=C3=A7=C3=B5es=20em=20Type?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- includes/xna/csharp/type.hpp | 39 ++++++++++++++++++++----------- sources/framework/CMakeLists.txt | 2 +- sources/framework/csharp/type.cpp | 15 ------------ 3 files changed, 26 insertions(+), 30 deletions(-) delete mode 100644 sources/framework/csharp/type.cpp diff --git a/includes/xna/csharp/type.hpp b/includes/xna/csharp/type.hpp index 7313cc3..186ee95 100644 --- a/includes/xna/csharp/type.hpp +++ b/includes/xna/csharp/type.hpp @@ -1,22 +1,33 @@ #ifndef XNA_CSHARP_TYPE_HPP #define XNA_CSHARP_TYPE_HPP -#include "../default.hpp" +#include "xna/helpers.hpp" +#include +#include +#include #include #include -#include namespace xna { class Type { public: - constexpr String FullName() const { return fullName; } + constexpr std::string FullName() const { return fullName; } constexpr bool IsClass() const { return isClass; } constexpr bool IsEnum() const { return isEnum; } constexpr bool IsValueType() const { return isValueType; } constexpr bool IsPrimitive() const { return isPrimitive; } constexpr bool IsPointer() const { return isPointer; } - size_t GetHashCode() const; + constexpr size_t GetHashCode() const { + size_t seed = 0; + XnaHelper::HashCombine(seed, fullName); + XnaHelper::HashCombine(seed, isClass); + XnaHelper::HashCombine(seed, isEnum); + XnaHelper::HashCombine(seed, isValueType); + XnaHelper::HashCombine(seed, isPrimitive); + + return seed; + } constexpr bool operator==(const Type& other) const { return @@ -33,13 +44,13 @@ namespace xna { } template - friend sptr typeof(); + friend std::shared_ptr typeof(); public: - inline static auto NameOfRegisteredTypes = std::map>(); + inline static auto NameOfRegisteredTypes = std::map>(); private: - String fullName; + std::string fullName; bool isClass{ false }; bool isEnum{ false }; bool isValueType{ false }; @@ -48,9 +59,9 @@ namespace xna { }; template - inline sptr typeof() { + inline std::shared_ptr typeof() { if (std::is_arithmetic::value) { - auto primitiveType = snew(); + auto primitiveType = std::make_shared(); primitiveType->fullName = typeid(T).name(); primitiveType->isPrimitive = true; primitiveType->isValueType = true; @@ -58,7 +69,7 @@ namespace xna { } if (std::is_enum::value) { - auto enumType = snew(); + auto enumType = std::make_shared(); enumType->fullName = typeid(T).name(); enumType->isValueType = true; enumType->isEnum = true; @@ -66,14 +77,14 @@ namespace xna { } if (std::is_pointer::value) { - auto pointerType = snew(); + auto pointerType = std::make_shared(); pointerType->fullName = typeid(T).name(); pointerType->isPointer = true; return pointerType; } if (std::is_class::value) { - auto classType = snew(); + auto classType = std::make_shared(); classType->fullName = typeid(T).name(); classType->isClass = true; @@ -84,12 +95,12 @@ namespace xna { } template - inline sptr typeof(T const* object) { + inline std::shared_ptr typeof(T const* object) { return typeof(); } template - inline sptr typeof(T const& object) { + inline std::shared_ptr typeof(T const& object) { return typeof(); } } diff --git a/sources/framework/CMakeLists.txt b/sources/framework/CMakeLists.txt index 82f9a8b..426434b 100644 --- a/sources/framework/CMakeLists.txt +++ b/sources/framework/CMakeLists.txt @@ -6,7 +6,7 @@ add_library (Xn65 STATIC "csharp/stream.cpp" "csharp/binary.cpp" -"csharp/type.cpp" + "game/component.cpp" "game/servicecontainer.cpp" "content/manager.cpp" diff --git a/sources/framework/csharp/type.cpp b/sources/framework/csharp/type.cpp deleted file mode 100644 index c7922c8..0000000 --- a/sources/framework/csharp/type.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include "xna/csharp/type.hpp" - -namespace xna { - size_t Type::GetHashCode() const - { - size_t seed = 0; - XnaHelper::HashCombine(seed, fullName); - XnaHelper::HashCombine(seed, isClass); - XnaHelper::HashCombine(seed, isEnum); - XnaHelper::HashCombine(seed, isValueType); - XnaHelper::HashCombine(seed, isPrimitive); - - return seed; - } -} \ No newline at end of file