mirror of
https://github.com/borgesdan/xn65
synced 2024-12-29 21:54:47 +01:00
Correções em type.hpp
This commit is contained in:
parent
3f875f916e
commit
f4a839eac9
@ -1,7 +1,8 @@
|
|||||||
#ifndef XNA_CSHARP_TYPE_HPP
|
#ifndef XNA_CSHARP_TYPE_HPP
|
||||||
#define XNA_CSHARP_TYPE_HPP
|
#define XNA_CSHARP_TYPE_HPP
|
||||||
|
|
||||||
#include "xna/helpers.hpp"
|
#include "../helpers.hpp"
|
||||||
|
#include "../exception.hpp"
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -60,38 +61,30 @@ namespace xna {
|
|||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
inline std::shared_ptr<Type> typeof() {
|
inline std::shared_ptr<Type> typeof() {
|
||||||
if (std::is_arithmetic<T>::value) {
|
|
||||||
auto primitiveType = std::make_shared<Type>();
|
|
||||||
primitiveType->fullName = typeid(T).name();
|
|
||||||
primitiveType->isPrimitive = true;
|
|
||||||
primitiveType->isValueType = true;
|
|
||||||
return primitiveType;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (std::is_enum<T>::value) {
|
auto type = std::make_shared<Type>();
|
||||||
auto enumType = std::make_shared<Type>();
|
type->fullName = typeid(T).name();
|
||||||
enumType->fullName = typeid(T).name();
|
|
||||||
enumType->isValueType = true;
|
|
||||||
enumType->isEnum = true;
|
|
||||||
return enumType;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (std::is_pointer<T>::value) {
|
if (std::is_arithmetic<T>::value) {
|
||||||
auto pointerType = std::make_shared<Type>();
|
type->isPrimitive = true;
|
||||||
pointerType->fullName = typeid(T).name();
|
type->isValueType = true;
|
||||||
pointerType->isPointer = true;
|
|
||||||
return pointerType;
|
|
||||||
}
|
}
|
||||||
|
else if (std::is_enum<T>::value) {
|
||||||
if (std::is_class<T>::value) {
|
type->isValueType = true;
|
||||||
auto classType = std::make_shared<Type>();
|
type->isEnum = true;
|
||||||
classType->fullName = typeid(T).name();
|
}
|
||||||
classType->isClass = true;
|
else if (std::is_pointer<T>::value) {
|
||||||
|
type->isPointer = true;
|
||||||
return classType;
|
}
|
||||||
|
else if (std::is_class<T>::value) {
|
||||||
|
type->isClass = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Exception::Throw(Exception::INVALID_OPERATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user