From f4a839eac9fa3e226d097077610400f36ff4be82 Mon Sep 17 00:00:00 2001 From: Danilo Date: Mon, 11 Nov 2024 13:42:07 -0300 Subject: [PATCH] =?UTF-8?q?Corre=C3=A7=C3=B5es=20em=20type.hpp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- includes/xna/csharp/type.hpp | 49 ++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 28 deletions(-) diff --git a/includes/xna/csharp/type.hpp b/includes/xna/csharp/type.hpp index 186ee95..de2eaa6 100644 --- a/includes/xna/csharp/type.hpp +++ b/includes/xna/csharp/type.hpp @@ -1,7 +1,8 @@ #ifndef XNA_CSHARP_TYPE_HPP #define XNA_CSHARP_TYPE_HPP -#include "xna/helpers.hpp" +#include "../helpers.hpp" +#include "../exception.hpp" #include #include #include @@ -60,38 +61,30 @@ namespace xna { template inline std::shared_ptr typeof() { - if (std::is_arithmetic::value) { - auto primitiveType = std::make_shared(); - primitiveType->fullName = typeid(T).name(); - primitiveType->isPrimitive = true; - primitiveType->isValueType = true; - return primitiveType; - } - if (std::is_enum::value) { - auto enumType = std::make_shared(); - enumType->fullName = typeid(T).name(); - enumType->isValueType = true; - enumType->isEnum = true; - return enumType; - } + auto type = std::make_shared(); + type->fullName = typeid(T).name(); - if (std::is_pointer::value) { - auto pointerType = std::make_shared(); - pointerType->fullName = typeid(T).name(); - pointerType->isPointer = true; - return pointerType; + if (std::is_arithmetic::value) { + type->isPrimitive = true; + type->isValueType = true; } - - if (std::is_class::value) { - auto classType = std::make_shared(); - classType->fullName = typeid(T).name(); - classType->isClass = true; - - return classType; + else if (std::is_enum::value) { + type->isValueType = true; + type->isEnum = true; + } + else if (std::is_pointer::value) { + type->isPointer = true; + } + else if (std::is_class::value) { + type->isClass = true; + } + else + { + Exception::Throw(Exception::INVALID_OPERATION); } - return nullptr; + return type; } template